From 518da4a923ee1cee15d1134001735c4d4b2579bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Wed, 10 Apr 2013 16:19:29 -0700 Subject: [PATCH] B --- Conf/.lang.yaml.swp | Bin 12288 -> 12288 bytes Conf/.task.yaml.swp | Bin 12288 -> 12288 bytes Conf/lang.yaml | 22 ++ Conf/task.yaml | 28 +++ Lang/ACL2/Bitwise-operations | 1 + Lang/ALGOL-68/Bitmap | 1 + Lang/ALGOL-68/Bitmap-B-zier-curves-Cubic | 1 + .../ALGOL-68/Bitmap-Bresenhams-line-algorithm | 1 + .../ALGOL-68/Bitmap-Midpoint-circle-algorithm | 1 + Lang/ALGOL-68/Bitwise-IO | 1 + Lang/ALGOL-68/Bitwise-operations | 1 + Lang/ALGOL-68/Boolean-values | 1 + Lang/ALGOL-68/Box-the-compass | 1 + Lang/AWK/Bitwise-operations | 1 + Lang/AWK/Boolean-values | 1 + Lang/AWK/Box-the-compass | 1 + Lang/ActionScript/Bitwise-operations | 1 + Lang/Ada/Bitmap | 1 + Lang/Ada/Bitmap-B-zier-curves-Cubic | 1 + Lang/Ada/Bitmap-B-zier-curves-Quadratic | 1 + Lang/Ada/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Ada/Bitmap-Flood-fill | 1 + Lang/Ada/Bitmap-Histogram | 1 + Lang/Ada/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Ada/Bitmap-Read-a-PPM-file | 1 + Lang/Ada/Bitmap-Write-a-PPM-file | 1 + Lang/Ada/Bitwise-IO | 1 + Lang/Ada/Bitwise-operations | 1 + Lang/Ada/Boolean-values | 1 + Lang/Ada/Box-the-compass | 1 + Lang/Ada/Break-OO-privacy | 1 + Lang/Ada/Bulls-and-cows-Player | 1 + Lang/Aikido/Bitwise-operations | 1 + Lang/AutoHotkey/Bitmap | 1 + .../Bitmap-Bresenhams-line-algorithm | 1 + Lang/AutoHotkey/Bitmap-Flood-fill | 1 + Lang/AutoHotkey/Bitmap-Read-a-PPM-file | 1 + .../Bitmap-Read-an-image-through-a-pipe | 1 + Lang/AutoHotkey/Bitmap-Write-a-PPM-file | 1 + Lang/AutoHotkey/Bitwise-operations | 1 + Lang/AutoHotkey/Box-the-compass | 1 + Lang/AutoIt/Box-the-compass | 1 + Lang/BASIC/Bitwise-operations | 1 + Lang/BASIC/Boolean-values | 1 + Lang/BASIC256/0DESCRIPTION | 25 +++ Lang/BASIC256/100-doors | 1 + Lang/BASIC256/99-Bottles-of-Beer | 1 + Lang/BASIC256/A+B | 1 + Lang/BASIC256/Ackermann-function | 1 + Lang/BASIC256/Arithmetic-Integer | 1 + Lang/BASIC256/Arrays | 1 + Lang/BASIC256/Associative-array-Creation | 1 + Lang/BASIC256/Bitmap | 1 + Lang/BASIC256/Bitwise-operations | 1 + Lang/BASIC256/Boolean-values | 1 + Lang/BASIC256/Forest-fire | 1 + Lang/BASIC256/Pi | 1 + Lang/BBC-BASIC/0DESCRIPTION | 10 + Lang/BBC-BASIC/100-doors | 1 + Lang/BBC-BASIC/24-game | 1 + Lang/BBC-BASIC/99-Bottles-of-Beer | 1 + Lang/BBC-BASIC/A+B | 1 + Lang/BBC-BASIC/Abstract-type | 1 + Lang/BBC-BASIC/Accumulator-factory | 1 + Lang/BBC-BASIC/Ackermann-function | 1 + Lang/BBC-BASIC/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/BBC-BASIC/Address-of-a-variable | 1 + Lang/BBC-BASIC/Align-columns | 1 + Lang/BBC-BASIC/Anagrams | 1 + Lang/BBC-BASIC/Anagrams-Deranged-anagrams | 1 + Lang/BBC-BASIC/Animate-a-pendulum | 1 + Lang/BBC-BASIC/Animation | 1 + Lang/BBC-BASIC/Anonymous-recursion | 1 + Lang/BBC-BASIC/Apply-a-callback-to-an-array | 1 + Lang/BBC-BASIC/Arithmetic-Complex | 1 + Lang/BBC-BASIC/Arithmetic-Integer | 1 + Lang/BBC-BASIC/Arithmetic-Rational | 1 + Lang/BBC-BASIC/Arithmetic-evaluation | 1 + Lang/BBC-BASIC/Arithmetic-geometric-mean | 1 + Lang/BBC-BASIC/Array-concatenation | 1 + Lang/BBC-BASIC/Arrays | 1 + Lang/BBC-BASIC/Assertions | 1 + Lang/BBC-BASIC/Associative-array-Creation | 1 + Lang/BBC-BASIC/Associative-array-Iteration | 1 + Lang/BBC-BASIC/Atomic-updates | 1 + Lang/BBC-BASIC/Average-loop-length | 1 + Lang/BBC-BASIC/Averages-Arithmetic-mean | 1 + Lang/BBC-BASIC/Averages-Mean-angle | 1 + Lang/BBC-BASIC/Averages-Median | 1 + Lang/BBC-BASIC/Averages-Mode | 1 + Lang/BBC-BASIC/Averages-Pythagorean-means | 1 + Lang/BBC-BASIC/Averages-Root-mean-square | 1 + Lang/BBC-BASIC/Averages-Simple-moving-average | 1 + Lang/BBC-BASIC/Balanced-brackets | 1 + Lang/BBC-BASIC/Best-shuffle | 1 + Lang/BBC-BASIC/Binary-search | 1 + Lang/BBC-BASIC/Binary-strings | 1 + Lang/BBC-BASIC/Bitmap | 1 + Lang/BBC-BASIC/Bitmap-B-zier-curves-Cubic | 1 + Lang/BBC-BASIC/Bitmap-B-zier-curves-Quadratic | 1 + .../Bitmap-Bresenhams-line-algorithm | 1 + Lang/BBC-BASIC/Bitmap-Flood-fill | 1 + Lang/BBC-BASIC/Bitmap-Histogram | 1 + .../Bitmap-Midpoint-circle-algorithm | 1 + Lang/BBC-BASIC/Bitmap-Read-a-PPM-file | 1 + Lang/BBC-BASIC/Bitmap-Write-a-PPM-file | 1 + Lang/BBC-BASIC/Bitwise-IO | 1 + Lang/BBC-BASIC/Bitwise-operations | 1 + Lang/BBC-BASIC/Boolean-values | 1 + Lang/BBC-BASIC/Box-the-compass | 1 + Lang/BBC-BASIC/Bulls-and-cows | 1 + Lang/BBC-BASIC/Bulls-and-cows-Player | 1 + Lang/BBC-BASIC/Caesar-cipher | 1 + Lang/BBC-BASIC/Calendar | 1 + Lang/BBC-BASIC/Check-that-file-exists | 1 + Lang/BBC-BASIC/Checkpoint-synchronization | 1 + Lang/BBC-BASIC/Classes | 1 + Lang/BBC-BASIC/Closest-pair-problem | 1 + Lang/BBC-BASIC/Collections | 1 + Lang/BBC-BASIC/Color-of-a-screen-pixel | 1 + Lang/BBC-BASIC/Comments | 1 + Lang/BBC-BASIC/Delete-a-file | 1 + Lang/BBC-BASIC/Detect-division-by-zero | 1 + .../Determine-if-a-string-is-numeric | 1 + Lang/BBC-BASIC/FizzBuzz | 1 + Lang/BBC-BASIC/Forest-fire | 1 + Lang/BBC-BASIC/Infinity | 1 + Lang/BBC-BASIC/Knuth-shuffle | 1 + Lang/BBC-BASIC/Narcissist | 1 + Lang/BBC-BASIC/Ordered-words | 1 + Lang/BBC-BASIC/Pi | 1 + Lang/BBC-BASIC/Quine | 1 + Lang/BBC-BASIC/Search-a-list | 1 + Lang/BCPL/0DESCRIPTION | 12 + Lang/BCPL/Ackermann-function | 1 + Lang/Batch-File/0DESCRIPTION | 1 + Lang/Batch-File/100-doors | 1 + Lang/Batch-File/99-Bottles-of-Beer | 1 + Lang/Batch-File/A+B | 1 + Lang/Batch-File/Ackermann-function | 1 + Lang/Batch-File/Arithmetic-Integer | 1 + Lang/Batch-File/Arrays | 1 + Lang/Batch-File/Associative-array-Creation | 1 + Lang/Batch-File/Bitwise-operations | 1 + Lang/Batch-File/Check-that-file-exists | 1 + Lang/Batch-File/Comments | 1 + Lang/Batch-File/Delete-a-file | 1 + Lang/Batch-File/FizzBuzz | 1 + Lang/Batch-File/Quine | 1 + Lang/Bc/0DESCRIPTION | 53 +++++ Lang/Beta/0DESCRIPTION | 5 + Lang/Biferno/0DESCRIPTION | 14 ++ Lang/Blast/0DESCRIPTION | 4 + Lang/Blast/Comments | 1 + Lang/BlitzMax/0DESCRIPTION | 22 ++ Lang/BlitzMax/100-doors | 1 + Lang/Boo/0DESCRIPTION | 13 ++ Lang/Boo/FizzBuzz | 1 + Lang/Bori/0DESCRIPTION | 12 + Lang/Brace/0DESCRIPTION | 4 + Lang/Bracmat/0DESCRIPTION | 19 ++ Lang/Bracmat/100-doors | 1 + Lang/Bracmat/24-game | 1 + Lang/Bracmat/99-Bottles-of-Beer | 1 + Lang/Bracmat/A+B | 1 + Lang/Bracmat/Ackermann-function | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Bracmat/Anagrams | 1 + Lang/Bracmat/Anagrams-Deranged-anagrams | 1 + Lang/Bracmat/Anonymous-recursion | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Bracmat/Averages-Arithmetic-mean | 1 + Lang/Bracmat/Averages-Median | 1 + Lang/Bracmat/Balanced-brackets | 1 + Lang/Bracmat/Best-shuffle | 1 + Lang/Bracmat/Determine-if-a-string-is-numeric | 1 + Lang/Bracmat/FizzBuzz | 1 + Lang/Bracmat/Ordered-words | 1 + Lang/Bracmat/Pi | 1 + Lang/Bracmat/Quine | 1 + Lang/Brainf---/0DESCRIPTION | 50 +++++ Lang/Brainf---/99-Bottles-of-Beer | 1 + Lang/Brainf---/A+B | 1 + Lang/Brainf---/Averages-Arithmetic-mean | 1 + Lang/Brainf---/Comments | 1 + Lang/Brainf---/FizzBuzz | 1 + Lang/Brainf---/Quine | 1 + Lang/Brat/0DESCRIPTION | 15 ++ Lang/Brat/99-Bottles-of-Beer | 1 + Lang/Brat/A+B | 1 + Lang/Brat/Accumulator-factory | 1 + Lang/Brat/Ackermann-function | 1 + Lang/Brat/Apply-a-callback-to-an-array | 1 + Lang/Brat/Arithmetic-Integer | 1 + Lang/Brat/Assertions | 1 + Lang/Brat/Associative-array-Creation | 1 + Lang/Brat/Associative-array-Iteration | 1 + Lang/Brat/Averages-Arithmetic-mean | 1 + Lang/Brat/Balanced-brackets | 1 + Lang/Brat/Binary-search | 1 + Lang/Brat/Bulls-and-cows | 1 + Lang/Brat/Comments | 1 + Lang/Brat/FizzBuzz | 1 + Lang/Brat/Knuth-shuffle | 1 + Lang/Brlcad/0DESCRIPTION | 7 + Lang/Brlcad/Comments | 1 + Lang/Brlcad/Death-Star | 1 + Lang/Burlesque/0DESCRIPTION | 28 +++ Lang/Burlesque/100-doors | 1 + Lang/Burlesque/A+B | 1 + Lang/Burlesque/Array-concatenation | 1 + Lang/Burlesque/Averages-Arithmetic-mean | 1 + Lang/Burlesque/Comments | 1 + .../Determine-if-a-string-is-numeric | 1 + Lang/Burlesque/Entropy | 1 + Lang/Burlesque/Ordered-words | 1 + Lang/Burlesque/Quine | 1 + Lang/Burlesque/Search-a-list | 1 + Lang/C/Bitcoin-address-validation | 1 + Lang/C/Bitmap | 1 + Lang/C/Bitmap-B-zier-curves-Cubic | 1 + Lang/C/Bitmap-B-zier-curves-Quadratic | 1 + Lang/C/Bitmap-Bresenhams-line-algorithm | 1 + Lang/C/Bitmap-Flood-fill | 1 + Lang/C/Bitmap-Histogram | 1 + Lang/C/Bitmap-PPM-conversion-through-a-pipe | 1 + Lang/C/Bitmap-Read-a-PPM-file | 1 + Lang/C/Bitmap-Read-an-image-through-a-pipe | 1 + Lang/C/Bitmap-Write-a-PPM-file | 1 + Lang/C/Bitwise-IO | 1 + Lang/C/Bitwise-operations | 1 + Lang/C/Box-the-compass | 1 + Lang/C/Bulls-and-cows-Player | 1 + Lang/Clojure/Bitmap | 1 + Lang/Clojure/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Clojure/Bitwise-operations | 1 + Lang/Clojure/Box-the-compass | 1 + Lang/CoffeeScript/Bitwise-operations | 1 + Lang/CoffeeScript/Boolean-values | 1 + Lang/Erlang/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Erlang/Bitwise-operations | 1 + Lang/Erlang/Boolean-values | 1 + Lang/Forth/Bitmap | 1 + Lang/Forth/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Forth/Bitmap-Flood-fill | 1 + Lang/Forth/Bitmap-Histogram | 1 + Lang/Forth/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Forth/Bitmap-Read-a-PPM-file | 1 + Lang/Forth/Bitmap-Write-a-PPM-file | 1 + Lang/Forth/Bitwise-IO | 1 + Lang/Forth/Bitwise-operations | 1 + Lang/Forth/Boolean-values | 1 + Lang/Fortran/Bitmap-B-zier-curves-Cubic | 1 + Lang/Fortran/Bitmap-B-zier-curves-Quadratic | 1 + Lang/Fortran/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Fortran/Bitmap-Flood-fill | 1 + Lang/Fortran/Bitmap-Histogram | 1 + Lang/Fortran/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Fortran/Bitmap-Read-a-PPM-file | 1 + Lang/Fortran/Bitmap-Write-a-PPM-file | 1 + Lang/Fortran/Bitwise-operations | 1 + Lang/Fortran/Box-the-compass | 1 + Lang/Fortran/Bulls-and-cows-Player | 1 + Lang/Go/Bitmap | 1 + Lang/Go/Bitmap-B-zier-curves-Cubic | 1 + Lang/Go/Bitmap-B-zier-curves-Quadratic | 1 + Lang/Go/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Go/Bitmap-Flood-fill | 1 + Lang/Go/Bitmap-Histogram | 1 + Lang/Go/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Go/Bitmap-PPM-conversion-through-a-pipe | 1 + Lang/Go/Bitmap-Read-a-PPM-file | 1 + Lang/Go/Bitmap-Read-an-image-through-a-pipe | 1 + Lang/Go/Bitmap-Write-a-PPM-file | 1 + Lang/Go/Bitwise-operations | 1 + Lang/Go/Box-the-compass | 1 + Lang/Go/Bulls-and-cows-Player | 1 + Lang/Haskell/Bitmap | 1 + Lang/Haskell/Bitmap-B-zier-curves-Quadratic | 1 + Lang/Haskell/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Haskell/Bitmap-Flood-fill | 1 + Lang/Haskell/Bitmap-Histogram | 1 + Lang/Haskell/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Haskell/Bitmap-Read-a-PPM-file | 1 + Lang/Haskell/Bitmap-Write-a-PPM-file | 1 + Lang/Haskell/Bitwise-IO | 1 + Lang/Haskell/Bitwise-operations | 1 + Lang/Haskell/Boolean-values | 1 + Lang/Haskell/Box-the-compass | 1 + Lang/Haskell/Bulls-and-cows-Player | 1 + Lang/Java/Bitmap | 1 + Lang/Java/Bitmap-Flood-fill | 1 + Lang/Java/Bitwise-operations | 1 + Lang/Java/Box-the-compass | 1 + Lang/Java/Break-OO-privacy | 1 + .../Bitmap-Bresenhams-line-algorithm | 1 + Lang/JavaScript/Bitwise-operations | 1 + Lang/JavaScript/Box-the-compass | 1 + Lang/Lua/Bitmap | 1 + Lang/Lua/Bitmap-Histogram | 1 + Lang/Lua/Bitmap-Read-a-PPM-file | 1 + Lang/Lua/Bitmap-Write-a-PPM-file | 1 + Lang/Lua/Bitwise-operations | 1 + Lang/Lua/Boolean-values | 1 + Lang/Lua/Box-the-compass | 1 + Lang/MATLAB/Bitmap | 1 + Lang/MATLAB/Bitmap-B-zier-curves-Cubic | 1 + Lang/MATLAB/Bitmap-B-zier-curves-Quadratic | 1 + Lang/MATLAB/Bitmap-Bresenhams-line-algorithm | 1 + Lang/MATLAB/Bitwise-operations | 1 + Lang/MATLAB/Boolean-values | 1 + Lang/MATLAB/Box-the-compass | 1 + Lang/PHP/Bitmap | 1 + Lang/PHP/Bitmap-B-zier-curves-Cubic | 1 + Lang/PHP/Bitmap-Histogram | 1 + Lang/PHP/Bitmap-Write-a-PPM-file | 1 + Lang/PHP/Bitwise-operations | 1 + Lang/PHP/Break-OO-privacy | 1 + Lang/Perl/Bitcoin-address-validation | 1 + Lang/Perl/Bitmap | 1 + Lang/Perl/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Perl/Bitmap-Flood-fill | 1 + Lang/Perl/Bitmap-Read-a-PPM-file | 1 + Lang/Perl/Bitmap-Write-a-PPM-file | 1 + Lang/Perl/Bitwise-IO | 1 + Lang/Perl/Bitwise-operations | 1 + Lang/Perl/Boolean-values | 1 + Lang/Perl/Box-the-compass | 1 + Lang/Perl/Bulls-and-cows-Player | 1 + Lang/PicoLisp/Bitmap | 1 + Lang/PicoLisp/Bitmap-B-zier-curves-Cubic | 1 + Lang/PicoLisp/Bitmap-B-zier-curves-Quadratic | 1 + .../PicoLisp/Bitmap-Bresenhams-line-algorithm | 1 + Lang/PicoLisp/Bitmap-Flood-fill | 1 + Lang/PicoLisp/Bitmap-Histogram | 1 + .../PicoLisp/Bitmap-Midpoint-circle-algorithm | 1 + .../Bitmap-PPM-conversion-through-a-pipe | 1 + Lang/PicoLisp/Bitmap-Read-a-PPM-file | 1 + .../Bitmap-Read-an-image-through-a-pipe | 1 + Lang/PicoLisp/Bitmap-Write-a-PPM-file | 1 + Lang/PicoLisp/Bitwise-IO | 1 + Lang/PicoLisp/Bitwise-operations | 1 + Lang/PicoLisp/Box-the-compass | 1 + Lang/PicoLisp/Break-OO-privacy | 1 + Lang/PicoLisp/Bulls-and-cows-Player | 1 + Lang/Prolog/Box-the-compass | 1 + Lang/Prolog/Bulls-and-cows-Player | 1 + Lang/Python/Bitcoin-address-validation | 1 + Lang/Python/Bitmap-B-zier-curves-Cubic | 1 + Lang/Python/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Python/Bitmap-Flood-fill | 1 + Lang/Python/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Python/Bitmap-Read-a-PPM-file | 1 + Lang/Python/Bitmap-Write-a-PPM-file | 1 + Lang/Python/Bitwise-IO | 1 + Lang/Python/Bitwise-operations | 1 + Lang/Python/Boolean-values | 1 + Lang/Python/Box-the-compass | 1 + Lang/Python/Break-OO-privacy | 1 + Lang/Python/Bulls-and-cows-Player | 1 + Lang/R/Bitmap | 1 + Lang/R/Bitmap-B-zier-curves-Cubic | 1 + Lang/R/Bitmap-Write-a-PPM-file | 1 + Lang/R/Bitwise-operations | 1 + Lang/REXX/Bitmap | 1 + Lang/REXX/Bitmap-Bresenhams-line-algorithm | 1 + Lang/REXX/Bitmap-Midpoint-circle-algorithm | 1 + Lang/REXX/Bitmap-Write-a-PPM-file | 1 + Lang/REXX/Bitwise-IO | 1 + Lang/REXX/Bitwise-operations | 1 + Lang/REXX/Boolean-values | 1 + Lang/REXX/Box-the-compass | 1 + Lang/Racket/Bitmap | 1 + Lang/Racket/Bitmap-Flood-fill | 1 + Lang/Racket/Bitwise-operations | 1 + Lang/Racket/Boolean-values | 1 + Lang/Racket/Box-the-compass | 1 + Lang/Ruby/Bitmap | 1 + Lang/Ruby/Bitmap-B-zier-curves-Cubic | 1 + Lang/Ruby/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Ruby/Bitmap-Flood-fill | 1 + Lang/Ruby/Bitmap-Histogram | 1 + Lang/Ruby/Bitmap-Midpoint-circle-algorithm | 1 + .../Ruby/Bitmap-PPM-conversion-through-a-pipe | 1 + Lang/Ruby/Bitmap-Read-a-PPM-file | 1 + Lang/Ruby/Bitmap-Read-an-image-through-a-pipe | 1 + Lang/Ruby/Bitmap-Write-a-PPM-file | 1 + Lang/Ruby/Bitwise-IO | 1 + Lang/Ruby/Bitwise-operations | 1 + Lang/Ruby/Box-the-compass | 1 + Lang/Ruby/Break-OO-privacy | 1 + Lang/Ruby/Bulls-and-cows-Player | 1 + Lang/SNUSP/Boolean-values | 1 + Lang/Sather/Boolean-values | 1 + Lang/Scala/Bitmap | 1 + Lang/Scala/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Scala/Bitmap-Histogram | 1 + Lang/Scala/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Scala/Bitmap-Read-a-PPM-file | 1 + Lang/Scala/Bitmap-Write-a-PPM-file | 1 + Lang/Scala/Bitwise-operations | 1 + Lang/Scala/Box-the-compass | 1 + Lang/Scheme/Bitmap | 1 + Lang/Scheme/Bitmap-Write-a-PPM-file | 1 + Lang/Scheme/Bitwise-operations | 1 + Lang/Smalltalk/Bitwise-operations | 1 + Lang/Tcl/Bitcoin-address-validation | 1 + Lang/Tcl/Bitmap | 1 + Lang/Tcl/Bitmap-B-zier-curves-Cubic | 1 + Lang/Tcl/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Tcl/Bitmap-Flood-fill | 1 + Lang/Tcl/Bitmap-Histogram | 1 + Lang/Tcl/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Tcl/Bitmap-PPM-conversion-through-a-pipe | 1 + Lang/Tcl/Bitmap-Read-a-PPM-file | 1 + Lang/Tcl/Bitmap-Read-an-image-through-a-pipe | 1 + Lang/Tcl/Bitmap-Write-a-PPM-file | 1 + Lang/Tcl/Bitwise-IO | 1 + Lang/Tcl/Bitwise-operations | 1 + Lang/Tcl/Boolean-values | 1 + Lang/Tcl/Box-the-compass | 1 + Lang/Tcl/Break-OO-privacy | 1 + Lang/Tcl/Bulls-and-cows-Player | 1 + Meta/Lang.yaml | 85 +++++++ Meta/Task.yaml | 72 ++++++ Task/100-doors/BASIC256/100-doors.basic256 | 34 +++ Task/100-doors/BBC-BASIC/100-doors.bbc | 11 + Task/100-doors/Batch-File/100-doors-1.bat | 10 + Task/100-doors/Batch-File/100-doors-2.bat | 9 + Task/100-doors/BlitzMax/100-doors.blitz | 10 + Task/100-doors/Bracmat/100-doors-1.bracmat | 26 +++ Task/100-doors/Bracmat/100-doors-2.bracmat | 30 +++ Task/100-doors/Bracmat/100-doors-3.bracmat | 25 +++ Task/100-doors/Bracmat/100-doors-4.bracmat | 22 ++ Task/100-doors/Bracmat/100-doors-5.bracmat | 4 + Task/100-doors/Burlesque/100-doors.blq | 2 + Task/24-game/BBC-BASIC/24-game.bbc | 66 ++++++ Task/24-game/Bracmat/24-game.bracmat | 78 +++++++ .../BASIC256/99-bottles-of-beer.basic256 | 33 +++ .../BBC-BASIC/99-bottles-of-beer.bbc | 32 +++ .../Batch-File/99-bottles-of-beer.bat | 47 ++++ .../Bracmat/99-bottles-of-beer.bracmat | 59 +++++ .../Brainf---/99-bottles-of-beer.bf | 44 ++++ .../Brat/99-bottles-of-beer.brat | 7 + Task/A+B/BASIC256/a+b.basic256 | 4 + Task/A+B/BBC-BASIC/a+b-1.bbc | 14 ++ Task/A+B/BBC-BASIC/a+b-2.bbc | 5 + Task/A+B/Batch-File/a+b-1.bat | 8 + Task/A+B/Batch-File/a+b-2.bat | 8 + Task/A+B/Batch-File/a+b-3.bat | 6 + Task/A+B/Batch-File/a+b-4.bat | 13 ++ Task/A+B/Bracmat/a+b.bracmat | 8 + Task/A+B/Brainf---/a+b.bf | 6 + Task/A+B/Brat/a+b.brat | 2 + Task/A+B/Burlesque/a+b.blq | 1 + .../Abstract-type/BBC-BASIC/abstract-type.bbc | 19 ++ .../BBC-BASIC/accumulator-factory.bbc | 17 ++ .../Brat/accumulator-factory.brat | 8 + .../BASIC256/ackermann-function-1.basic256 | 33 +++ .../BASIC256/ackermann-function-2.basic256 | 19 ++ .../BBC-BASIC/ackermann-function.bbc | 7 + .../BCPL/ackermann-function.bcpl | 11 + .../Batch-File/ackermann-function-1.bat | 31 +++ .../Batch-File/ackermann-function-2.bat | 4 + .../Bracmat/ackermann-function-1.bracmat | 8 + .../Bracmat/ackermann-function-2.bracmat | 61 +++++ .../Bracmat/ackermann-function-3.bracmat | 11 + .../Brat/ackermann-function.brat | 7 + .../Active-object/BBC-BASIC/active-object.bbc | 23 ++ ...ariable-to-a-class-instance-at-runtime.bbc | 31 +++ ...e-to-a-class-instance-at-runtime-1.bracmat | 26 +++ ...e-to-a-class-instance-at-runtime-2.bracmat | 15 ++ .../BBC-BASIC/address-of-a-variable.bbc | 5 + .../Align-columns/BBC-BASIC/align-columns.bbc | 56 +++++ .../BBC-BASIC/anagrams-deranged-anagrams.bbc | 53 +++++ .../anagrams-deranged-anagrams.bracmat | 63 ++++++ Task/Anagrams/BBC-BASIC/anagrams.bbc | 64 ++++++ Task/Anagrams/Bracmat/anagrams.bracmat | 28 +++ .../BBC-BASIC/animate-a-pendulum.bbc | 29 +++ Task/Animation/BBC-BASIC/animation.bbc | 15 ++ .../BBC-BASIC/anonymous-recursion.bbc | 6 + .../Bracmat/anonymous-recursion-1.bracmat | 18 ++ .../Bracmat/anonymous-recursion-2.bracmat | 21 ++ .../apply-a-callback-to-an-array.bbc | 16 ++ .../Brat/apply-a-callback-to-an-array-1.brat | 4 + .../Brat/apply-a-callback-to-an-array-2.brat | 1 + ...rary-precision-integers-(included).bracmat | 4 + .../BBC-BASIC/arithmetic-complex.bbc | 40 ++++ .../BASIC256/arithmetic-integer.basic256 | 9 + .../BBC-BASIC/arithmetic-integer.bbc | 9 + .../Batch-File/arithmetic-integer.bat | 13 ++ .../Brat/arithmetic-integer.brat | 7 + .../BBC-BASIC/arithmetic-rational.bbc | 62 ++++++ .../BBC-BASIC/arithmetic-evaluation.bbc | 58 +++++ .../BBC-BASIC/arithmetic-geometric-mean.bbc | 13 ++ .../BBC-BASIC/array-concatenation.bbc | 19 ++ .../Burlesque/array-concatenation.blq | 2 + Task/Arrays/BASIC256/arrays.basic256 | 29 +++ Task/Arrays/BBC-BASIC/arrays.bbc | 17 ++ Task/Arrays/Batch-File/arrays.bat | 24 ++ Task/Assertions/BBC-BASIC/assertions.bbc | 6 + Task/Assertions/Brat/assertions.brat | 4 + .../associative-array-creation.basic256 | 106 +++++++++ .../BBC-BASIC/associative-array-creation.bbc | 21 ++ .../Batch-File/associative-array-creation.bat | 24 ++ .../Brat/associative-array-creation.brat | 8 + .../BBC-BASIC/associative-array-iteration.bbc | 26 +++ .../Brat/associative-array-iteration.brat | 16 ++ .../BBC-BASIC/atomic-updates.bbc | 52 +++++ .../BBC-BASIC/average-loop-length.bbc | 33 +++ .../BBC-BASIC/averages-arithmetic-mean.bbc | 28 +++ .../averages-arithmetic-mean-1.bracmat | 24 ++ .../averages-arithmetic-mean-2.bracmat | 6 + .../Brainf---/averages-arithmetic-mean.bf | 1 + .../Brat/averages-arithmetic-mean.brat | 5 + .../Burlesque/averages-arithmetic-mean.blq | 4 + .../BBC-BASIC/averages-mean-angle.bbc | 20 ++ .../BBC-BASIC/averages-median.bbc | 16 ++ .../Bracmat/averages-median.bracmat | 25 +++ .../Averages-Mode/BBC-BASIC/averages-mode.bbc | 33 +++ .../BBC-BASIC/averages-pythagorean-means.bbc | 23 ++ .../BBC-BASIC/averages-root-mean-square.bbc | 7 + .../averages-simple-moving-average.bbc | 18 ++ .../BBC-BASIC/balanced-brackets.bbc | 29 +++ .../Bracmat/balanced-brackets.bracmat | 27 +++ .../Brat/balanced-brackets.brat | 31 +++ Task/Best-shuffle/BBC-BASIC/best-shuffle.bbc | 30 +++ .../Bracmat/best-shuffle-1.bracmat | 28 +++ .../Bracmat/best-shuffle-2.bracmat | 34 +++ .../Binary-search/BBC-BASIC/binary-search.bbc | 23 ++ Task/Binary-search/Brat/binary-search.brat | 31 +++ .../BBC-BASIC/binary-strings.bbc | 15 ++ Task/Bitcoin-address-validation/0DESCRIPTION | 22 ++ .../C/bitcoin-address-validation.c | 61 +++++ .../Perl/bitcoin-address-validation.pl | 26 +++ .../Python/bitcoin-address-validation-1.py | 20 ++ .../Python/bitcoin-address-validation-2.py | 6 + .../Tcl/bitcoin-address-validation-1.tcl | 34 +++ .../Tcl/bitcoin-address-validation-2.tcl | 2 + Task/Bitmap-B-zier-curves-Cubic/0DESCRIPTION | 2 + Task/Bitmap-B-zier-curves-Cubic/1META.yaml | 2 + .../ALGOL-68/bitmap-b-zier-curves-cubic.alg | 34 +++ .../Ada/bitmap-b-zier-curves-cubic-1.ada | 24 ++ .../Ada/bitmap-b-zier-curves-cubic-2.ada | 5 + .../BBC-BASIC/bitmap-b-zier-curves-cubic.bbc | 52 +++++ .../C/bitmap-b-zier-curves-cubic-1.c | 9 + .../C/bitmap-b-zier-curves-cubic-2.c | 54 +++++ .../Fortran/bitmap-b-zier-curves-cubic.f | 27 +++ .../Go/bitmap-b-zier-curves-cubic-1.go | 29 +++ .../Go/bitmap-b-zier-curves-cubic-2.go | 15 ++ .../MATLAB/bitmap-b-zier-curves-cubic-1.m | 30 +++ .../MATLAB/bitmap-b-zier-curves-cubic-2.m | 4 + .../PHP/bitmap-b-zier-curves-cubic.php | 29 +++ .../PicoLisp/bitmap-b-zier-curves-cubic-1.l | 24 ++ .../PicoLisp/bitmap-b-zier-curves-cubic-2.l | 8 + .../Python/bitmap-b-zier-curves-cubic.py | 46 ++++ .../R/bitmap-b-zier-curves-cubic.r | 39 ++++ .../Ruby/bitmap-b-zier-curves-cubic.rb | 41 ++++ .../Tcl/bitmap-b-zier-curves-cubic.tcl | 60 +++++ .../0DESCRIPTION | 2 + .../Bitmap-B-zier-curves-Quadratic/1META.yaml | 2 + .../Ada/bitmap-b-zier-curves-quadratic-1.ada | 23 ++ .../Ada/bitmap-b-zier-curves-quadratic-2.ada | 5 + .../bitmap-b-zier-curves-quadratic.bbc | 51 +++++ .../C/bitmap-b-zier-curves-quadratic-1.c | 8 + .../C/bitmap-b-zier-curves-quadratic-2.c | 50 +++++ .../Fortran/bitmap-b-zier-curves-quadratic.f | 26 +++ .../Go/bitmap-b-zier-curves-quadratic-1.go | 27 +++ .../Go/bitmap-b-zier-curves-quadratic-2.go | 15 ++ .../Haskell/bitmap-b-zier-curves-quadratic.hs | 47 ++++ .../MATLAB/bitmap-b-zier-curves-quadratic-1.m | 29 +++ .../MATLAB/bitmap-b-zier-curves-quadratic-2.m | 4 + .../bitmap-b-zier-curves-quadratic-1.l | 11 + .../bitmap-b-zier-curves-quadratic-2.l | 8 + .../0DESCRIPTION | 1 + .../1META.yaml | 4 + .../bitmap-bresenhams-line-algorithm.alg | 53 +++++ .../bitmap-bresenhams-line-algorithm-1.ada | 40 ++++ .../bitmap-bresenhams-line-algorithm-2.ada | 8 + .../bitmap-bresenhams-line-algorithm.ahk | 19 ++ .../bitmap-bresenhams-line-algorithm.bbc | 34 +++ .../C/bitmap-bresenhams-line-algorithm.c | 14 ++ .../bitmap-bresenhams-line-algorithm.clj | 23 ++ .../bitmap-bresenhams-line-algorithm-1.erl | 45 ++++ .../bitmap-bresenhams-line-algorithm-2.erl | 30 +++ .../bitmap-bresenhams-line-algorithm.fth | 48 ++++ .../bitmap-bresenhams-line-algorithm-1.f | 70 ++++++ .../bitmap-bresenhams-line-algorithm-2.f | 27 +++ .../Go/bitmap-bresenhams-line-algorithm-1.go | 46 ++++ .../Go/bitmap-bresenhams-line-algorithm-2.go | 23 ++ .../bitmap-bresenhams-line-algorithm.hs | 33 +++ .../bitmap-bresenhams-line-algorithm.js | 14 ++ .../bitmap-bresenhams-line-algorithm-1.m | 61 +++++ .../bitmap-bresenhams-line-algorithm-2.m | 8 + .../Perl/bitmap-bresenhams-line-algorithm.pl | 63 ++++++ .../bitmap-bresenhams-line-algorithm.l | 39 ++++ .../bitmap-bresenhams-line-algorithm.py | 58 +++++ .../bitmap-bresenhams-line-algorithm.rexx | 64 ++++++ .../Ruby/bitmap-bresenhams-line-algorithm.rb | 48 ++++ .../bitmap-bresenhams-line-algorithm.scala | 24 ++ .../Tcl/bitmap-bresenhams-line-algorithm.tcl | 39 ++++ Task/Bitmap-Flood-fill/0DESCRIPTION | 8 + Task/Bitmap-Flood-fill/1META.yaml | 4 + .../Ada/bitmap-flood-fill-1.ada | 106 +++++++++ .../Ada/bitmap-flood-fill-2.ada | 19 ++ .../AutoHotkey/bitmap-flood-fill-1.ahk | 41 ++++ .../AutoHotkey/bitmap-flood-fill-2.ahk | 55 +++++ .../BBC-BASIC/bitmap-flood-fill.bbc | 24 ++ .../Bitmap-Flood-fill/C/bitmap-flood-fill-1.c | 106 +++++++++ .../Bitmap-Flood-fill/C/bitmap-flood-fill-2.c | 9 + .../Bitmap-Flood-fill/C/bitmap-flood-fill-3.c | 93 ++++++++ .../Bitmap-Flood-fill/C/bitmap-flood-fill-4.c | 27 +++ .../Forth/bitmap-flood-fill.fth | 28 +++ .../Fortran/bitmap-flood-fill-1.f | 106 +++++++++ .../Fortran/bitmap-flood-fill-2.f | 1 + .../Go/bitmap-flood-fill-1.go | 17 ++ .../Go/bitmap-flood-fill-2.go | 20 ++ .../Haskell/bitmap-flood-fill.hs | 110 +++++++++ .../Java/bitmap-flood-fill-1.java | 42 ++++ .../Java/bitmap-flood-fill-2.java | 18 ++ .../Perl/bitmap-flood-fill-1.pl | 10 + .../Perl/bitmap-flood-fill-2.pl | 48 ++++ .../PicoLisp/bitmap-flood-fill.l | 10 + .../Python/bitmap-flood-fill-1.py | 44 ++++ .../Python/bitmap-flood-fill-2.py | 7 + .../Racket/bitmap-flood-fill.rkt | 82 +++++++ .../Ruby/bitmap-flood-fill.rb | 57 +++++ .../Tcl/bitmap-flood-fill.tcl | 74 ++++++ Task/Bitmap-Histogram/0DESCRIPTION | 10 + Task/Bitmap-Histogram/1META.yaml | 2 + .../Ada/bitmap-histogram-1.ada | 17 ++ .../Ada/bitmap-histogram-2.ada | 17 ++ .../Ada/bitmap-histogram-3.ada | 22 ++ .../BBC-BASIC/bitmap-histogram.bbc | 59 +++++ Task/Bitmap-Histogram/C/bitmap-histogram-1.c | 7 + Task/Bitmap-Histogram/C/bitmap-histogram-2.c | 20 ++ Task/Bitmap-Histogram/C/bitmap-histogram-3.c | 19 ++ Task/Bitmap-Histogram/C/bitmap-histogram-4.c | 50 +++++ .../Forth/bitmap-histogram.fth | 4 + .../Fortran/bitmap-histogram-1.f | 40 ++++ .../Fortran/bitmap-histogram-2.f | 42 ++++ .../Bitmap-Histogram/Go/bitmap-histogram-1.go | 24 ++ .../Bitmap-Histogram/Go/bitmap-histogram-2.go | 45 ++++ .../Haskell/bitmap-histogram-1.hs | 32 +++ .../Haskell/bitmap-histogram-2.hs | 27 +++ .../Bitmap-Histogram/Lua/bitmap-histogram.lua | 52 +++++ .../Bitmap-Histogram/PHP/bitmap-histogram.php | 54 +++++ .../PicoLisp/bitmap-histogram.l | 6 + .../Bitmap-Histogram/Ruby/bitmap-histogram.rb | 41 ++++ .../Scala/bitmap-histogram-1.scala | 32 +++ .../Scala/bitmap-histogram-2.scala | 11 + .../Bitmap-Histogram/Tcl/bitmap-histogram.tcl | 50 +++++ .../0DESCRIPTION | 2 + .../1META.yaml | 2 + .../bitmap-midpoint-circle-algorithm.alg | 46 ++++ .../bitmap-midpoint-circle-algorithm-1.ada | 35 +++ .../bitmap-midpoint-circle-algorithm-2.ada | 5 + .../bitmap-midpoint-circle-algorithm-1.bbc | 43 ++++ .../bitmap-midpoint-circle-algorithm-2.bbc | 8 + .../bitmap-midpoint-circle-algorithm-3.bbc | 44 ++++ .../bitmap-midpoint-circle-algorithm.fth | 29 +++ .../bitmap-midpoint-circle-algorithm-1.f | 5 + .../bitmap-midpoint-circle-algorithm-2.f | 74 ++++++ .../Go/bitmap-midpoint-circle-algorithm-1.go | 36 +++ .../Go/bitmap-midpoint-circle-algorithm-2.go | 21 ++ .../bitmap-midpoint-circle-algorithm-1.hs | 28 +++ .../bitmap-midpoint-circle-algorithm-2.hs | 31 +++ .../bitmap-midpoint-circle-algorithm-3.hs | 11 + .../bitmap-midpoint-circle-algorithm.l | 27 +++ .../bitmap-midpoint-circle-algorithm.py | 67 ++++++ .../bitmap-midpoint-circle-algorithm.rexx | 49 ++++ .../Ruby/bitmap-midpoint-circle-algorithm.rb | 39 ++++ .../bitmap-midpoint-circle-algorithm.scala | 36 +++ .../Tcl/bitmap-midpoint-circle-algorithm.tcl | 48 ++++ .../0DESCRIPTION | 3 + .../1META.yaml | 2 + .../bitmap-ppm-conversion-through-a-pipe-1.c | 2 + .../bitmap-ppm-conversion-through-a-pipe-2.c | 17 ++ .../bitmap-ppm-conversion-through-a-pipe-3.c | 12 + .../bitmap-ppm-conversion-through-a-pipe-1.go | 59 +++++ .../bitmap-ppm-conversion-through-a-pipe-2.go | 15 ++ .../bitmap-ppm-conversion-through-a-pipe.l | 11 + .../bitmap-ppm-conversion-through-a-pipe.rb | 39 ++++ ...bitmap-ppm-conversion-through-a-pipe-1.tcl | 8 + ...bitmap-ppm-conversion-through-a-pipe-2.tcl | 8 + Task/Bitmap-Read-a-PPM-file/0DESCRIPTION | 4 + Task/Bitmap-Read-a-PPM-file/1META.yaml | 4 + .../Ada/bitmap-read-a-ppm-file-1.ada | 70 ++++++ .../Ada/bitmap-read-a-ppm-file-2.ada | 9 + .../AutoHotkey/bitmap-read-a-ppm-file.ahk | 57 +++++ .../BBC-BASIC/bitmap-read-a-ppm-file.bbc | 30 +++ .../C/bitmap-read-a-ppm-file-1.c | 1 + .../C/bitmap-read-a-ppm-file-2.c | 38 ++++ .../C/bitmap-read-a-ppm-file-3.c | 16 ++ .../Forth/bitmap-read-a-ppm-file.fth | 38 ++++ .../Fortran/bitmap-read-a-ppm-file.f | 42 ++++ .../Go/bitmap-read-a-ppm-file-1.go | 68 ++++++ .../Go/bitmap-read-a-ppm-file-2.go | 28 +++ .../Haskell/bitmap-read-a-ppm-file-1.hs | 12 + .../Haskell/bitmap-read-a-ppm-file-2.hs | 4 + .../Lua/bitmap-read-a-ppm-file.lua | 34 +++ .../Perl/bitmap-read-a-ppm-file.pl | 14 ++ .../PicoLisp/bitmap-read-a-ppm-file-1.l | 18 ++ .../PicoLisp/bitmap-read-a-ppm-file-2.l | 1 + .../Python/bitmap-read-a-ppm-file.py | 69 ++++++ .../Ruby/bitmap-read-a-ppm-file.rb | 33 +++ .../Scala/bitmap-read-a-ppm-file-1.scala | 46 ++++ .../Scala/bitmap-read-a-ppm-file-2.scala | 15 ++ .../Tcl/bitmap-read-a-ppm-file-1.tcl | 5 + .../Tcl/bitmap-read-a-ppm-file-2.tcl | 21 ++ .../Tcl/bitmap-read-a-ppm-file-3.tcl | 12 + .../0DESCRIPTION | 1 + .../1META.yaml | 4 + .../bitmap-read-an-image-through-a-pipe.ahk | 60 +++++ .../C/bitmap-read-an-image-through-a-pipe-1.c | 1 + .../C/bitmap-read-an-image-through-a-pipe-2.c | 28 +++ .../Go/bitmap-read-an-image-through-a-pipe.go | 38 ++++ .../bitmap-read-an-image-through-a-pipe.l | 1 + .../bitmap-read-an-image-through-a-pipe.rb | 40 ++++ .../bitmap-read-an-image-through-a-pipe.tcl | 10 + Task/Bitmap-Write-a-PPM-file/0DESCRIPTION | 2 + Task/Bitmap-Write-a-PPM-file/1META.yaml | 4 + .../Ada/bitmap-write-a-ppm-file.ada | 26 +++ .../AutoHotkey/bitmap-write-a-ppm-file.ahk | 31 +++ .../BBC-BASIC/bitmap-write-a-ppm-file.bbc | 30 +++ .../C/bitmap-write-a-ppm-file-1.c | 23 ++ .../C/bitmap-write-a-ppm-file-2.c | 36 +++ .../C/bitmap-write-a-ppm-file-3.c | 1 + .../C/bitmap-write-a-ppm-file-4.c | 10 + .../Forth/bitmap-write-a-ppm-file.fth | 14 ++ .../Fortran/bitmap-write-a-ppm-file.f | 26 +++ .../Go/bitmap-write-a-ppm-file-1.go | 54 +++++ .../Go/bitmap-write-a-ppm-file-2.go | 19 ++ .../Haskell/bitmap-write-a-ppm-file.hs | 50 +++++ .../Lua/bitmap-write-a-ppm-file.lua | 106 +++++++++ .../PHP/bitmap-write-a-ppm-file.php | 52 +++++ .../Perl/bitmap-write-a-ppm-file-1.pl | 14 ++ .../Perl/bitmap-write-a-ppm-file-2.pl | 1 + .../PicoLisp/bitmap-write-a-ppm-file.l | 6 + .../Python/bitmap-write-a-ppm-file.py | 62 ++++++ .../R/bitmap-write-a-ppm-file.r | 6 + .../REXX/bitmap-write-a-ppm-file.rexx | 17 ++ .../Ruby/bitmap-write-a-ppm-file.rb | 20 ++ .../Scala/bitmap-write-a-ppm-file.scala | 13 ++ .../Scheme/bitmap-write-a-ppm-file-1.ss | 22 ++ .../Scheme/bitmap-write-a-ppm-file-2.ss | 4 + .../Tcl/bitmap-write-a-ppm-file.tcl | 19 ++ Task/Bitmap/0DESCRIPTION | 10 + Task/Bitmap/1META.yaml | 2 + Task/Bitmap/ALGOL-68/bitmap.alg | 54 +++++ Task/Bitmap/Ada/bitmap-1.ada | 17 ++ Task/Bitmap/Ada/bitmap-2.ada | 28 +++ Task/Bitmap/Ada/bitmap-3.ada | 7 + Task/Bitmap/AutoHotkey/bitmap.ahk | 93 ++++++++ Task/Bitmap/BASIC256/bitmap.basic256 | 18 ++ Task/Bitmap/BBC-BASIC/bitmap.bbc | 34 +++ Task/Bitmap/C/bitmap-1.c | 41 ++++ Task/Bitmap/C/bitmap-2.c | 58 +++++ Task/Bitmap/Clojure/bitmap.clj | 16 ++ Task/Bitmap/Forth/bitmap.fth | 44 ++++ Task/Bitmap/Go/bitmap.go | 120 ++++++++++ Task/Bitmap/Haskell/bitmap-1.hs | 77 +++++++ Task/Bitmap/Haskell/bitmap-2.hs | 23 ++ Task/Bitmap/Java/bitmap-1.java | 36 +++ Task/Bitmap/Java/bitmap-2.java | 19 ++ Task/Bitmap/Lua/bitmap-1.lua | 22 ++ Task/Bitmap/Lua/bitmap-2.lua | 4 + Task/Bitmap/MATLAB/bitmap-1.m | 159 +++++++++++++ Task/Bitmap/MATLAB/bitmap-2.m | 18 ++ Task/Bitmap/PHP/bitmap.php | 39 ++++ Task/Bitmap/Perl/bitmap.pl | 27 +++ Task/Bitmap/PicoLisp/bitmap.l | 17 ++ Task/Bitmap/R/bitmap.r | 19 ++ Task/Bitmap/REXX/bitmap.rexx | 35 +++ Task/Bitmap/Racket/bitmap.rkt | 41 ++++ Task/Bitmap/Ruby/bitmap.rb | 49 ++++ Task/Bitmap/Scala/bitmap-1.scala | 15 ++ Task/Bitmap/Scala/bitmap-2.scala | 8 + Task/Bitmap/Scheme/bitmap-1.ss | 18 ++ Task/Bitmap/Scheme/bitmap-2.ss | 14 ++ Task/Bitmap/Scheme/bitmap-3.ss | 5 + Task/Bitmap/Scheme/bitmap-4.ss | 5 + Task/Bitmap/Scheme/bitmap-5.ss | 1 + Task/Bitmap/Tcl/bitmap.tcl | 30 +++ Task/Bitwise-IO/0DESCRIPTION | 22 ++ Task/Bitwise-IO/ALGOL-68/bitwise-io.alg | 131 +++++++++++ Task/Bitwise-IO/Ada/bitwise-io-1.ada | 20 ++ Task/Bitwise-IO/Ada/bitwise-io-2.ada | 33 +++ Task/Bitwise-IO/Ada/bitwise-io-3.ada | 33 +++ Task/Bitwise-IO/BBC-BASIC/bitwise-io.bbc | 43 ++++ Task/Bitwise-IO/C/bitwise-io.c | 114 ++++++++++ Task/Bitwise-IO/Forth/bitwise-io.fth | 21 ++ Task/Bitwise-IO/Haskell/bitwise-io.hs | 30 +++ Task/Bitwise-IO/Perl/bitwise-io-1.pl | 44 ++++ Task/Bitwise-IO/Perl/bitwise-io-2.pl | 6 + Task/Bitwise-IO/Perl/bitwise-io-3.pl | 7 + Task/Bitwise-IO/PicoLisp/bitwise-io-1.l | 22 ++ Task/Bitwise-IO/PicoLisp/bitwise-io-2.l | 11 + Task/Bitwise-IO/Python/bitwise-io-1.py | 51 +++++ Task/Bitwise-IO/Python/bitwise-io-2.py | 9 + Task/Bitwise-IO/Python/bitwise-io-3.py | 10 + Task/Bitwise-IO/REXX/bitwise-io.rexx | 26 +++ Task/Bitwise-IO/Ruby/bitwise-io.rb | 35 +++ Task/Bitwise-IO/Tcl/bitwise-io.tcl | 48 ++++ Task/Bitwise-operations/0DESCRIPTION | 1 + Task/Bitwise-operations/1META.yaml | 2 + .../ACL2/bitwise-operations.acl2 | 7 + .../ALGOL-68/bitwise-operations-1.alg | 64 ++++++ .../ALGOL-68/bitwise-operations-2.alg | 13 ++ .../AWK/bitwise-operations.awk | 10 + .../ActionScript/bitwise-operations.as | 10 + .../Ada/bitwise-operations.ada | 24 ++ .../Aikido/bitwise-operations.aikido | 9 + .../AutoHotkey/bitwise-operations.ahk | 10 + .../BASIC/bitwise-operations-1.bas | 6 + .../BASIC/bitwise-operations-2.bas | 12 + .../BASIC256/bitwise-operations.basic256 | 8 + .../BBC-BASIC/bitwise-operations.bbc | 12 + .../Batch-File/bitwise-operations.bat | 73 ++++++ .../C/bitwise-operations-1.c | 14 ++ .../C/bitwise-operations-2.c | 5 + .../C/bitwise-operations-3.c | 5 + .../Clojure/bitwise-operations.clj | 7 + .../CoffeeScript/bitwise-operations-1.coffee | 12 + .../CoffeeScript/bitwise-operations-2.coffee | 7 + .../Erlang/bitwise-operations-1.erl | 13 ++ .../Erlang/bitwise-operations-2.erl | 6 + .../Forth/bitwise-operations.fth | 11 + .../Fortran/bitwise-operations-1.f | 27 +++ .../Fortran/bitwise-operations-2.f | 1 + .../Go/bitwise-operations.go | 45 ++++ .../Haskell/bitwise-operations.hs | 18 ++ .../Java/bitwise-operations-1.java | 11 + .../Java/bitwise-operations-2.java | 4 + .../JavaScript/bitwise-operations.js | 9 + .../Lua/bitwise-operations.lua | 65 ++++++ .../MATLAB/bitwise-operations-1.m | 9 + .../MATLAB/bitwise-operations-2.m | 6 + .../PHP/bitwise-operations.php | 9 + .../Perl/bitwise-operations.pl | 15 ++ .../PicoLisp/bitwise-operations-1.l | 5 + .../PicoLisp/bitwise-operations-2.l | 8 + .../PicoLisp/bitwise-operations-3.l | 5 + .../PicoLisp/bitwise-operations-4.l | 5 + .../PicoLisp/bitwise-operations-5.l | 11 + .../Python/bitwise-operations-1.py | 7 + .../Python/bitwise-operations-2.py | 8 + .../Python/bitwise-operations-3.py | 41 ++++ .../R/bitwise-operations-1.r | 5 + .../R/bitwise-operations-2.r | 13 ++ .../R/bitwise-operations-3.r | 8 + .../R/bitwise-operations-4.r | 14 ++ .../REXX/bitwise-operations.rexx | 35 +++ .../Racket/bitwise-operations.rkt | 9 + .../Ruby/bitwise-operations.rb | 8 + .../Scala/bitwise-operations.scala | 11 + .../Scheme/bitwise-operations-1.ss | 13 ++ .../Scheme/bitwise-operations-2.ss | 5 + .../Smalltalk/bitwise-operations-1.st | 10 + .../Smalltalk/bitwise-operations-2.st | 8 + .../Tcl/bitwise-operations-1.tcl | 8 + .../Tcl/bitwise-operations-2.tcl | 13 ++ Task/Boolean-values/0DESCRIPTION | 4 + Task/Boolean-values/1META.yaml | 2 + .../ALGOL-68/boolean-values.alg | 30 +++ Task/Boolean-values/AWK/boolean-values.awk | 18 ++ Task/Boolean-values/Ada/boolean-values.ada | 1 + Task/Boolean-values/BASIC/boolean-values.bas | 11 + .../BASIC256/boolean-values.basic256 | 7 + .../BBC-BASIC/boolean-values.bbc | 5 + .../CoffeeScript/boolean-values.coffee | 28 +++ Task/Boolean-values/Erlang/boolean-values.erl | 6 + Task/Boolean-values/Forth/boolean-values.fth | 2 + Task/Boolean-values/Haskell/boolean-values.hs | 1 + Task/Boolean-values/Lua/boolean-values.lua | 6 + Task/Boolean-values/MATLAB/boolean-values.m | 35 +++ Task/Boolean-values/Perl/boolean-values-1.pl | 2 + Task/Boolean-values/Perl/boolean-values-2.pl | 10 + Task/Boolean-values/Perl/boolean-values-3.pl | 5 + Task/Boolean-values/Perl/boolean-values-4.pl | 5 + Task/Boolean-values/Python/boolean-values.py | 39 ++++ .../Boolean-values/REXX/boolean-values-1.rexx | 2 + .../Boolean-values/REXX/boolean-values-2.rexx | 2 + .../Boolean-values/REXX/boolean-values-3.rexx | 2 + .../Boolean-values/REXX/boolean-values-4.rexx | 2 + .../Boolean-values/REXX/boolean-values-5.rexx | 1 + .../Boolean-values/REXX/boolean-values-6.rexx | 4 + Task/Boolean-values/Racket/boolean-values.rkt | 3 + .../Boolean-values/SNUSP/boolean-values.snusp | 2 + Task/Boolean-values/Sather/boolean-values.sa | 7 + Task/Boolean-values/Tcl/boolean-values-1.tcl | 2 + Task/Boolean-values/Tcl/boolean-values-2.tcl | 1 + Task/Box-the-compass/0DESCRIPTION | 21 ++ .../ALGOL-68/box-the-compass.alg | 96 ++++++++ Task/Box-the-compass/AWK/box-the-compass.awk | 18 ++ Task/Box-the-compass/Ada/box-the-compass.ada | 66 ++++++ .../AutoHotkey/box-the-compass.ahk | 39 ++++ .../AutoIt/box-the-compass.autoit | 18 ++ .../BBC-BASIC/box-the-compass.bbc | 27 +++ Task/Box-the-compass/C/box-the-compass.c | 53 +++++ .../Clojure/box-the-compass.clj | 26 +++ .../Box-the-compass/Fortran/box-the-compass.f | 38 ++++ Task/Box-the-compass/Go/box-the-compass.go | 67 ++++++ .../Haskell/box-the-compass.hs | 25 +++ .../Box-the-compass/Java/box-the-compass.java | 49 ++++ .../JavaScript/box-the-compass.js | 45 ++++ Task/Box-the-compass/Lua/box-the-compass.lua | 49 ++++ Task/Box-the-compass/MATLAB/box-the-compass.m | 3 + .../Box-the-compass/Perl/box-the-compass-1.pl | 45 ++++ .../Box-the-compass/Perl/box-the-compass-2.pl | 33 +++ .../PicoLisp/box-the-compass.l | 34 +++ .../Prolog/box-the-compass-1.pro | 37 +++ .../Prolog/box-the-compass-2.pro | 7 + .../Prolog/box-the-compass-3.pro | 36 +++ .../Box-the-compass/Python/box-the-compass.py | 25 +++ .../Box-the-compass/REXX/box-the-compass.rexx | 32 +++ .../Racket/box-the-compass.rkt | 55 +++++ .../Box-the-compass/Ruby/box-the-compass-1.rb | 16 ++ .../Box-the-compass/Ruby/box-the-compass-2.rb | 53 +++++ .../Scala/box-the-compass.scala | 22 ++ Task/Box-the-compass/Tcl/box-the-compass.tcl | 27 +++ Task/Break-OO-privacy/0DESCRIPTION | 3 + .../Ada/break-oo-privacy-1.ada | 10 + .../Ada/break-oo-privacy-2.ada | 16 ++ .../Java/break-oo-privacy.java | 29 +++ .../PHP/break-oo-privacy-1.php | 19 ++ .../PHP/break-oo-privacy-2.php | 8 + .../PHP/break-oo-privacy-3.php | 12 + .../PicoLisp/break-oo-privacy-1.l | 12 + .../PicoLisp/break-oo-privacy-2.l | 20 ++ .../Python/break-oo-privacy.py | 16 ++ .../Break-OO-privacy/Ruby/break-oo-privacy.rb | 15 ++ .../Break-OO-privacy/Tcl/break-oo-privacy.tcl | 11 + Task/Bulls-and-cows-Player/0DESCRIPTION | 9 + Task/Bulls-and-cows-Player/1META.yaml | 2 + .../Ada/bulls-and-cows-player.ada | 210 ++++++++++++++++++ .../BBC-BASIC/bulls-and-cows-player.bbc | 58 +++++ .../C/bulls-and-cows-player-1.c | 102 +++++++++ .../C/bulls-and-cows-player-2.c | 15 ++ .../C/bulls-and-cows-player-3.c | 36 +++ .../Fortran/bulls-and-cows-player.f | 109 +++++++++ .../Go/bulls-and-cows-player.go | 96 ++++++++ .../Haskell/bulls-and-cows-player-1.hs | 33 +++ .../Haskell/bulls-and-cows-player-2.hs | 14 ++ .../Perl/bulls-and-cows-player-1.pl | 53 +++++ .../Perl/bulls-and-cows-player-2.pl | 11 + .../PicoLisp/bulls-and-cows-player.l | 19 ++ .../Prolog/bulls-and-cows-player-1.pro | 132 +++++++++++ .../Prolog/bulls-and-cows-player-2.pro | 21 ++ .../Python/bulls-and-cows-player.py | 55 +++++ .../Ruby/bulls-and-cows-player.rb | 28 +++ .../Tcl/bulls-and-cows-player.tcl | 52 +++++ .../BBC-BASIC/bulls-and-cows.bbc | 32 +++ Task/Bulls-and-cows/Brat/bulls-and-cows.brat | 39 ++++ .../Caesar-cipher/BBC-BASIC/caesar-cipher.bbc | 22 ++ Task/Calendar/BBC-BASIC/calendar.bbc | 35 +++ .../BBC-BASIC/check-that-file-exists.bbc | 23 ++ .../Batch-File/check-that-file-exists.bat | 4 + .../BBC-BASIC/checkpoint-synchronization.bbc | 59 +++++ Task/Classes/BBC-BASIC/classes.bbc | 18 ++ .../BBC-BASIC/closest-pair-problem.bbc | 26 +++ Task/Collections/BBC-BASIC/collections-1.bbc | 3 + Task/Collections/BBC-BASIC/collections-2.bbc | 5 + Task/Collections/BBC-BASIC/collections-3.bbc | 24 ++ .../BBC-BASIC/color-of-a-screen-pixel.bbc | 2 + Task/Comments/BBC-BASIC/comments.bbc | 2 + Task/Comments/Batch-File/comments-1.bat | 1 + Task/Comments/Batch-File/comments-2.bat | 2 + Task/Comments/Blast/comments.blast | 1 + Task/Comments/Brainf---/comments.bf | 1 + Task/Comments/Brat/comments.brat | 5 + Task/Comments/Brlcad/comments.brlcad | 2 + Task/Comments/Burlesque/comments-1.blq | 1 + Task/Comments/Burlesque/comments-2.blq | 3 + Task/Death-Star/Brlcad/death-star.brlcad | 26 +++ .../BBC-BASIC/delete-a-file-1.bbc | 4 + .../BBC-BASIC/delete-a-file-2.bbc | 2 + .../Batch-File/delete-a-file.bat | 5 + .../BBC-BASIC/detect-division-by-zero.bbc | 19 ++ .../determine-if-a-string-is-numeric.bbc | 19 ++ ...determine-if-a-string-is-numeric-1.bracmat | 11 + ...determine-if-a-string-is-numeric-2.bracmat | 29 +++ ...determine-if-a-string-is-numeric-3.bracmat | 35 +++ .../determine-if-a-string-is-numeric.blq | 1 + Task/Entropy/Burlesque/entropy.blq | 2 + Task/FizzBuzz/BBC-BASIC/fizzbuzz.bbc | 8 + Task/FizzBuzz/Batch-File/fizzbuzz-1.bat | 24 ++ Task/FizzBuzz/Batch-File/fizzbuzz-2.bat | 28 +++ Task/FizzBuzz/Boo/fizzbuzz.boo | 12 + Task/FizzBuzz/Bracmat/fizzbuzz-1.bracmat | 1 + Task/FizzBuzz/Bracmat/fizzbuzz-2.bracmat | 12 + Task/FizzBuzz/Brainf---/fizzbuzz.bf | 156 +++++++++++++ Task/FizzBuzz/Brat/fizzbuzz.brat | 11 + .../Forest-fire/BASIC256/forest-fire.basic256 | 38 ++++ Task/Forest-fire/BBC-BASIC/forest-fire.bbc | 36 +++ Task/Infinity/BBC-BASIC/infinity.bbc | 19 ++ .../BBC-BASIC/knuth-shuffle-1.bbc | 12 + .../BBC-BASIC/knuth-shuffle-2.bbc | 44 ++++ Task/Knuth-shuffle/Brat/knuth-shuffle.brat | 12 + Task/Narcissist/BBC-BASIC/narcissist.bbc | 1 + .../Ordered-words/BBC-BASIC/ordered-words.bbc | 19 ++ .../Bracmat/ordered-words.bracmat | 25 +++ .../Ordered-words/Burlesque/ordered-words.blq | 1 + Task/Pi/BASIC256/pi.basic256 | 59 +++++ Task/Pi/BBC-BASIC/pi-1.bbc | 23 ++ Task/Pi/BBC-BASIC/pi-2.bbc | 23 ++ Task/Pi/Bracmat/pi.bracmat | 29 +++ Task/Quine/BBC-BASIC/quine-1.bbc | 1 + Task/Quine/BBC-BASIC/quine-2.bbc | 1 + Task/Quine/Batch-File/quine-1.bat | 1 + Task/Quine/Batch-File/quine-2.bat | 1 + Task/Quine/Bracmat/quine-1.bracmat | 2 + Task/Quine/Bracmat/quine-2.bracmat | 1 + Task/Quine/Brainf---/quine.bf | 7 + Task/Quine/Burlesque/quine.blq | 2 + .../Search-a-list/BBC-BASIC/search-a-list.bbc | 21 ++ .../Burlesque/search-a-list-1.blq | 2 + .../Burlesque/search-a-list-2.blq | 2 + 1019 files changed, 15877 insertions(+) create mode 120000 Lang/ACL2/Bitwise-operations create mode 120000 Lang/ALGOL-68/Bitmap create mode 120000 Lang/ALGOL-68/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/ALGOL-68/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/ALGOL-68/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/ALGOL-68/Bitwise-IO create mode 120000 Lang/ALGOL-68/Bitwise-operations create mode 120000 Lang/ALGOL-68/Boolean-values create mode 120000 Lang/ALGOL-68/Box-the-compass create mode 120000 Lang/AWK/Bitwise-operations create mode 120000 Lang/AWK/Boolean-values create mode 120000 Lang/AWK/Box-the-compass create mode 120000 Lang/ActionScript/Bitwise-operations create mode 120000 Lang/Ada/Bitmap create mode 120000 Lang/Ada/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/Ada/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/Ada/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Ada/Bitmap-Flood-fill create mode 120000 Lang/Ada/Bitmap-Histogram create mode 120000 Lang/Ada/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Ada/Bitmap-Read-a-PPM-file create mode 120000 Lang/Ada/Bitmap-Write-a-PPM-file create mode 120000 Lang/Ada/Bitwise-IO create mode 120000 Lang/Ada/Bitwise-operations create mode 120000 Lang/Ada/Boolean-values create mode 120000 Lang/Ada/Box-the-compass create mode 120000 Lang/Ada/Break-OO-privacy create mode 120000 Lang/Ada/Bulls-and-cows-Player create mode 120000 Lang/Aikido/Bitwise-operations create mode 120000 Lang/AutoHotkey/Bitmap create mode 120000 Lang/AutoHotkey/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/AutoHotkey/Bitmap-Flood-fill create mode 120000 Lang/AutoHotkey/Bitmap-Read-a-PPM-file create mode 120000 Lang/AutoHotkey/Bitmap-Read-an-image-through-a-pipe create mode 120000 Lang/AutoHotkey/Bitmap-Write-a-PPM-file create mode 120000 Lang/AutoHotkey/Bitwise-operations create mode 120000 Lang/AutoHotkey/Box-the-compass create mode 120000 Lang/AutoIt/Box-the-compass create mode 120000 Lang/BASIC/Bitwise-operations create mode 120000 Lang/BASIC/Boolean-values create mode 100644 Lang/BASIC256/0DESCRIPTION create mode 120000 Lang/BASIC256/100-doors create mode 120000 Lang/BASIC256/99-Bottles-of-Beer create mode 120000 Lang/BASIC256/A+B create mode 120000 Lang/BASIC256/Ackermann-function create mode 120000 Lang/BASIC256/Arithmetic-Integer create mode 120000 Lang/BASIC256/Arrays create mode 120000 Lang/BASIC256/Associative-array-Creation create mode 120000 Lang/BASIC256/Bitmap create mode 120000 Lang/BASIC256/Bitwise-operations create mode 120000 Lang/BASIC256/Boolean-values create mode 120000 Lang/BASIC256/Forest-fire create mode 120000 Lang/BASIC256/Pi create mode 100644 Lang/BBC-BASIC/0DESCRIPTION create mode 120000 Lang/BBC-BASIC/100-doors create mode 120000 Lang/BBC-BASIC/24-game create mode 120000 Lang/BBC-BASIC/99-Bottles-of-Beer create mode 120000 Lang/BBC-BASIC/A+B create mode 120000 Lang/BBC-BASIC/Abstract-type create mode 120000 Lang/BBC-BASIC/Accumulator-factory create mode 120000 Lang/BBC-BASIC/Ackermann-function create mode 120000 Lang/BBC-BASIC/Active-object create mode 120000 Lang/BBC-BASIC/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/BBC-BASIC/Address-of-a-variable create mode 120000 Lang/BBC-BASIC/Align-columns create mode 120000 Lang/BBC-BASIC/Anagrams create mode 120000 Lang/BBC-BASIC/Anagrams-Deranged-anagrams create mode 120000 Lang/BBC-BASIC/Animate-a-pendulum create mode 120000 Lang/BBC-BASIC/Animation create mode 120000 Lang/BBC-BASIC/Anonymous-recursion create mode 120000 Lang/BBC-BASIC/Apply-a-callback-to-an-array create mode 120000 Lang/BBC-BASIC/Arithmetic-Complex create mode 120000 Lang/BBC-BASIC/Arithmetic-Integer create mode 120000 Lang/BBC-BASIC/Arithmetic-Rational create mode 120000 Lang/BBC-BASIC/Arithmetic-evaluation create mode 120000 Lang/BBC-BASIC/Arithmetic-geometric-mean create mode 120000 Lang/BBC-BASIC/Array-concatenation create mode 120000 Lang/BBC-BASIC/Arrays create mode 120000 Lang/BBC-BASIC/Assertions create mode 120000 Lang/BBC-BASIC/Associative-array-Creation create mode 120000 Lang/BBC-BASIC/Associative-array-Iteration create mode 120000 Lang/BBC-BASIC/Atomic-updates create mode 120000 Lang/BBC-BASIC/Average-loop-length create mode 120000 Lang/BBC-BASIC/Averages-Arithmetic-mean create mode 120000 Lang/BBC-BASIC/Averages-Mean-angle create mode 120000 Lang/BBC-BASIC/Averages-Median create mode 120000 Lang/BBC-BASIC/Averages-Mode create mode 120000 Lang/BBC-BASIC/Averages-Pythagorean-means create mode 120000 Lang/BBC-BASIC/Averages-Root-mean-square create mode 120000 Lang/BBC-BASIC/Averages-Simple-moving-average create mode 120000 Lang/BBC-BASIC/Balanced-brackets create mode 120000 Lang/BBC-BASIC/Best-shuffle create mode 120000 Lang/BBC-BASIC/Binary-search create mode 120000 Lang/BBC-BASIC/Binary-strings create mode 120000 Lang/BBC-BASIC/Bitmap create mode 120000 Lang/BBC-BASIC/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/BBC-BASIC/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/BBC-BASIC/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/BBC-BASIC/Bitmap-Flood-fill create mode 120000 Lang/BBC-BASIC/Bitmap-Histogram create mode 120000 Lang/BBC-BASIC/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/BBC-BASIC/Bitmap-Read-a-PPM-file create mode 120000 Lang/BBC-BASIC/Bitmap-Write-a-PPM-file create mode 120000 Lang/BBC-BASIC/Bitwise-IO create mode 120000 Lang/BBC-BASIC/Bitwise-operations create mode 120000 Lang/BBC-BASIC/Boolean-values create mode 120000 Lang/BBC-BASIC/Box-the-compass create mode 120000 Lang/BBC-BASIC/Bulls-and-cows create mode 120000 Lang/BBC-BASIC/Bulls-and-cows-Player create mode 120000 Lang/BBC-BASIC/Caesar-cipher create mode 120000 Lang/BBC-BASIC/Calendar create mode 120000 Lang/BBC-BASIC/Check-that-file-exists create mode 120000 Lang/BBC-BASIC/Checkpoint-synchronization create mode 120000 Lang/BBC-BASIC/Classes create mode 120000 Lang/BBC-BASIC/Closest-pair-problem create mode 120000 Lang/BBC-BASIC/Collections create mode 120000 Lang/BBC-BASIC/Color-of-a-screen-pixel create mode 120000 Lang/BBC-BASIC/Comments create mode 120000 Lang/BBC-BASIC/Delete-a-file create mode 120000 Lang/BBC-BASIC/Detect-division-by-zero create mode 120000 Lang/BBC-BASIC/Determine-if-a-string-is-numeric create mode 120000 Lang/BBC-BASIC/FizzBuzz create mode 120000 Lang/BBC-BASIC/Forest-fire create mode 120000 Lang/BBC-BASIC/Infinity create mode 120000 Lang/BBC-BASIC/Knuth-shuffle create mode 120000 Lang/BBC-BASIC/Narcissist create mode 120000 Lang/BBC-BASIC/Ordered-words create mode 120000 Lang/BBC-BASIC/Pi create mode 120000 Lang/BBC-BASIC/Quine create mode 120000 Lang/BBC-BASIC/Search-a-list create mode 100644 Lang/BCPL/0DESCRIPTION create mode 120000 Lang/BCPL/Ackermann-function create mode 100644 Lang/Batch-File/0DESCRIPTION create mode 120000 Lang/Batch-File/100-doors create mode 120000 Lang/Batch-File/99-Bottles-of-Beer create mode 120000 Lang/Batch-File/A+B create mode 120000 Lang/Batch-File/Ackermann-function create mode 120000 Lang/Batch-File/Arithmetic-Integer create mode 120000 Lang/Batch-File/Arrays create mode 120000 Lang/Batch-File/Associative-array-Creation create mode 120000 Lang/Batch-File/Bitwise-operations create mode 120000 Lang/Batch-File/Check-that-file-exists create mode 120000 Lang/Batch-File/Comments create mode 120000 Lang/Batch-File/Delete-a-file create mode 120000 Lang/Batch-File/FizzBuzz create mode 120000 Lang/Batch-File/Quine create mode 100644 Lang/Bc/0DESCRIPTION create mode 100644 Lang/Beta/0DESCRIPTION create mode 100644 Lang/Biferno/0DESCRIPTION create mode 100644 Lang/Blast/0DESCRIPTION create mode 120000 Lang/Blast/Comments create mode 100644 Lang/BlitzMax/0DESCRIPTION create mode 120000 Lang/BlitzMax/100-doors create mode 100644 Lang/Boo/0DESCRIPTION create mode 120000 Lang/Boo/FizzBuzz create mode 100644 Lang/Bori/0DESCRIPTION create mode 100644 Lang/Brace/0DESCRIPTION create mode 100644 Lang/Bracmat/0DESCRIPTION create mode 120000 Lang/Bracmat/100-doors create mode 120000 Lang/Bracmat/24-game create mode 120000 Lang/Bracmat/99-Bottles-of-Beer create mode 120000 Lang/Bracmat/A+B create mode 120000 Lang/Bracmat/Ackermann-function create mode 120000 Lang/Bracmat/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Bracmat/Anagrams create mode 120000 Lang/Bracmat/Anagrams-Deranged-anagrams create mode 120000 Lang/Bracmat/Anonymous-recursion create mode 120000 Lang/Bracmat/Arbitrary-precision-integers-(included) create mode 120000 Lang/Bracmat/Averages-Arithmetic-mean create mode 120000 Lang/Bracmat/Averages-Median create mode 120000 Lang/Bracmat/Balanced-brackets create mode 120000 Lang/Bracmat/Best-shuffle create mode 120000 Lang/Bracmat/Determine-if-a-string-is-numeric create mode 120000 Lang/Bracmat/FizzBuzz create mode 120000 Lang/Bracmat/Ordered-words create mode 120000 Lang/Bracmat/Pi create mode 120000 Lang/Bracmat/Quine create mode 100644 Lang/Brainf---/0DESCRIPTION create mode 120000 Lang/Brainf---/99-Bottles-of-Beer create mode 120000 Lang/Brainf---/A+B create mode 120000 Lang/Brainf---/Averages-Arithmetic-mean create mode 120000 Lang/Brainf---/Comments create mode 120000 Lang/Brainf---/FizzBuzz create mode 120000 Lang/Brainf---/Quine create mode 100644 Lang/Brat/0DESCRIPTION create mode 120000 Lang/Brat/99-Bottles-of-Beer create mode 120000 Lang/Brat/A+B create mode 120000 Lang/Brat/Accumulator-factory create mode 120000 Lang/Brat/Ackermann-function create mode 120000 Lang/Brat/Apply-a-callback-to-an-array create mode 120000 Lang/Brat/Arithmetic-Integer create mode 120000 Lang/Brat/Assertions create mode 120000 Lang/Brat/Associative-array-Creation create mode 120000 Lang/Brat/Associative-array-Iteration create mode 120000 Lang/Brat/Averages-Arithmetic-mean create mode 120000 Lang/Brat/Balanced-brackets create mode 120000 Lang/Brat/Binary-search create mode 120000 Lang/Brat/Bulls-and-cows create mode 120000 Lang/Brat/Comments create mode 120000 Lang/Brat/FizzBuzz create mode 120000 Lang/Brat/Knuth-shuffle create mode 100644 Lang/Brlcad/0DESCRIPTION create mode 120000 Lang/Brlcad/Comments create mode 120000 Lang/Brlcad/Death-Star create mode 100644 Lang/Burlesque/0DESCRIPTION create mode 120000 Lang/Burlesque/100-doors create mode 120000 Lang/Burlesque/A+B create mode 120000 Lang/Burlesque/Array-concatenation create mode 120000 Lang/Burlesque/Averages-Arithmetic-mean create mode 120000 Lang/Burlesque/Comments create mode 120000 Lang/Burlesque/Determine-if-a-string-is-numeric create mode 120000 Lang/Burlesque/Entropy create mode 120000 Lang/Burlesque/Ordered-words create mode 120000 Lang/Burlesque/Quine create mode 120000 Lang/Burlesque/Search-a-list create mode 120000 Lang/C/Bitcoin-address-validation create mode 120000 Lang/C/Bitmap create mode 120000 Lang/C/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/C/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/C/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/C/Bitmap-Flood-fill create mode 120000 Lang/C/Bitmap-Histogram create mode 120000 Lang/C/Bitmap-PPM-conversion-through-a-pipe create mode 120000 Lang/C/Bitmap-Read-a-PPM-file create mode 120000 Lang/C/Bitmap-Read-an-image-through-a-pipe create mode 120000 Lang/C/Bitmap-Write-a-PPM-file create mode 120000 Lang/C/Bitwise-IO create mode 120000 Lang/C/Bitwise-operations create mode 120000 Lang/C/Box-the-compass create mode 120000 Lang/C/Bulls-and-cows-Player create mode 120000 Lang/Clojure/Bitmap create mode 120000 Lang/Clojure/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Clojure/Bitwise-operations create mode 120000 Lang/Clojure/Box-the-compass create mode 120000 Lang/CoffeeScript/Bitwise-operations create mode 120000 Lang/CoffeeScript/Boolean-values create mode 120000 Lang/Erlang/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Erlang/Bitwise-operations create mode 120000 Lang/Erlang/Boolean-values create mode 120000 Lang/Forth/Bitmap create mode 120000 Lang/Forth/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Forth/Bitmap-Flood-fill create mode 120000 Lang/Forth/Bitmap-Histogram create mode 120000 Lang/Forth/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Forth/Bitmap-Read-a-PPM-file create mode 120000 Lang/Forth/Bitmap-Write-a-PPM-file create mode 120000 Lang/Forth/Bitwise-IO create mode 120000 Lang/Forth/Bitwise-operations create mode 120000 Lang/Forth/Boolean-values create mode 120000 Lang/Fortran/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/Fortran/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/Fortran/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Fortran/Bitmap-Flood-fill create mode 120000 Lang/Fortran/Bitmap-Histogram create mode 120000 Lang/Fortran/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Fortran/Bitmap-Read-a-PPM-file create mode 120000 Lang/Fortran/Bitmap-Write-a-PPM-file create mode 120000 Lang/Fortran/Bitwise-operations create mode 120000 Lang/Fortran/Box-the-compass create mode 120000 Lang/Fortran/Bulls-and-cows-Player create mode 120000 Lang/Go/Bitmap create mode 120000 Lang/Go/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/Go/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/Go/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Go/Bitmap-Flood-fill create mode 120000 Lang/Go/Bitmap-Histogram create mode 120000 Lang/Go/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Go/Bitmap-PPM-conversion-through-a-pipe create mode 120000 Lang/Go/Bitmap-Read-a-PPM-file create mode 120000 Lang/Go/Bitmap-Read-an-image-through-a-pipe create mode 120000 Lang/Go/Bitmap-Write-a-PPM-file create mode 120000 Lang/Go/Bitwise-operations create mode 120000 Lang/Go/Box-the-compass create mode 120000 Lang/Go/Bulls-and-cows-Player create mode 120000 Lang/Haskell/Bitmap create mode 120000 Lang/Haskell/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/Haskell/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Haskell/Bitmap-Flood-fill create mode 120000 Lang/Haskell/Bitmap-Histogram create mode 120000 Lang/Haskell/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Haskell/Bitmap-Read-a-PPM-file create mode 120000 Lang/Haskell/Bitmap-Write-a-PPM-file create mode 120000 Lang/Haskell/Bitwise-IO create mode 120000 Lang/Haskell/Bitwise-operations create mode 120000 Lang/Haskell/Boolean-values create mode 120000 Lang/Haskell/Box-the-compass create mode 120000 Lang/Haskell/Bulls-and-cows-Player create mode 120000 Lang/Java/Bitmap create mode 120000 Lang/Java/Bitmap-Flood-fill create mode 120000 Lang/Java/Bitwise-operations create mode 120000 Lang/Java/Box-the-compass create mode 120000 Lang/Java/Break-OO-privacy create mode 120000 Lang/JavaScript/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/JavaScript/Bitwise-operations create mode 120000 Lang/JavaScript/Box-the-compass create mode 120000 Lang/Lua/Bitmap create mode 120000 Lang/Lua/Bitmap-Histogram create mode 120000 Lang/Lua/Bitmap-Read-a-PPM-file create mode 120000 Lang/Lua/Bitmap-Write-a-PPM-file create mode 120000 Lang/Lua/Bitwise-operations create mode 120000 Lang/Lua/Boolean-values create mode 120000 Lang/Lua/Box-the-compass create mode 120000 Lang/MATLAB/Bitmap create mode 120000 Lang/MATLAB/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/MATLAB/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/MATLAB/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/MATLAB/Bitwise-operations create mode 120000 Lang/MATLAB/Boolean-values create mode 120000 Lang/MATLAB/Box-the-compass create mode 120000 Lang/PHP/Bitmap create mode 120000 Lang/PHP/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/PHP/Bitmap-Histogram create mode 120000 Lang/PHP/Bitmap-Write-a-PPM-file create mode 120000 Lang/PHP/Bitwise-operations create mode 120000 Lang/PHP/Break-OO-privacy create mode 120000 Lang/Perl/Bitcoin-address-validation create mode 120000 Lang/Perl/Bitmap create mode 120000 Lang/Perl/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Perl/Bitmap-Flood-fill create mode 120000 Lang/Perl/Bitmap-Read-a-PPM-file create mode 120000 Lang/Perl/Bitmap-Write-a-PPM-file create mode 120000 Lang/Perl/Bitwise-IO create mode 120000 Lang/Perl/Bitwise-operations create mode 120000 Lang/Perl/Boolean-values create mode 120000 Lang/Perl/Box-the-compass create mode 120000 Lang/Perl/Bulls-and-cows-Player create mode 120000 Lang/PicoLisp/Bitmap create mode 120000 Lang/PicoLisp/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/PicoLisp/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/PicoLisp/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/PicoLisp/Bitmap-Flood-fill create mode 120000 Lang/PicoLisp/Bitmap-Histogram create mode 120000 Lang/PicoLisp/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/PicoLisp/Bitmap-PPM-conversion-through-a-pipe create mode 120000 Lang/PicoLisp/Bitmap-Read-a-PPM-file create mode 120000 Lang/PicoLisp/Bitmap-Read-an-image-through-a-pipe create mode 120000 Lang/PicoLisp/Bitmap-Write-a-PPM-file create mode 120000 Lang/PicoLisp/Bitwise-IO create mode 120000 Lang/PicoLisp/Bitwise-operations create mode 120000 Lang/PicoLisp/Box-the-compass create mode 120000 Lang/PicoLisp/Break-OO-privacy create mode 120000 Lang/PicoLisp/Bulls-and-cows-Player create mode 120000 Lang/Prolog/Box-the-compass create mode 120000 Lang/Prolog/Bulls-and-cows-Player create mode 120000 Lang/Python/Bitcoin-address-validation create mode 120000 Lang/Python/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/Python/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Python/Bitmap-Flood-fill create mode 120000 Lang/Python/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Python/Bitmap-Read-a-PPM-file create mode 120000 Lang/Python/Bitmap-Write-a-PPM-file create mode 120000 Lang/Python/Bitwise-IO create mode 120000 Lang/Python/Bitwise-operations create mode 120000 Lang/Python/Boolean-values create mode 120000 Lang/Python/Box-the-compass create mode 120000 Lang/Python/Break-OO-privacy create mode 120000 Lang/Python/Bulls-and-cows-Player create mode 120000 Lang/R/Bitmap create mode 120000 Lang/R/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/R/Bitmap-Write-a-PPM-file create mode 120000 Lang/R/Bitwise-operations create mode 120000 Lang/REXX/Bitmap create mode 120000 Lang/REXX/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/REXX/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/REXX/Bitmap-Write-a-PPM-file create mode 120000 Lang/REXX/Bitwise-IO create mode 120000 Lang/REXX/Bitwise-operations create mode 120000 Lang/REXX/Boolean-values create mode 120000 Lang/REXX/Box-the-compass create mode 120000 Lang/Racket/Bitmap create mode 120000 Lang/Racket/Bitmap-Flood-fill create mode 120000 Lang/Racket/Bitwise-operations create mode 120000 Lang/Racket/Boolean-values create mode 120000 Lang/Racket/Box-the-compass create mode 120000 Lang/Ruby/Bitmap create mode 120000 Lang/Ruby/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/Ruby/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Ruby/Bitmap-Flood-fill create mode 120000 Lang/Ruby/Bitmap-Histogram create mode 120000 Lang/Ruby/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Ruby/Bitmap-PPM-conversion-through-a-pipe create mode 120000 Lang/Ruby/Bitmap-Read-a-PPM-file create mode 120000 Lang/Ruby/Bitmap-Read-an-image-through-a-pipe create mode 120000 Lang/Ruby/Bitmap-Write-a-PPM-file create mode 120000 Lang/Ruby/Bitwise-IO create mode 120000 Lang/Ruby/Bitwise-operations create mode 120000 Lang/Ruby/Box-the-compass create mode 120000 Lang/Ruby/Break-OO-privacy create mode 120000 Lang/Ruby/Bulls-and-cows-Player create mode 120000 Lang/SNUSP/Boolean-values create mode 120000 Lang/Sather/Boolean-values create mode 120000 Lang/Scala/Bitmap create mode 120000 Lang/Scala/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Scala/Bitmap-Histogram create mode 120000 Lang/Scala/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Scala/Bitmap-Read-a-PPM-file create mode 120000 Lang/Scala/Bitmap-Write-a-PPM-file create mode 120000 Lang/Scala/Bitwise-operations create mode 120000 Lang/Scala/Box-the-compass create mode 120000 Lang/Scheme/Bitmap create mode 120000 Lang/Scheme/Bitmap-Write-a-PPM-file create mode 120000 Lang/Scheme/Bitwise-operations create mode 120000 Lang/Smalltalk/Bitwise-operations create mode 120000 Lang/Tcl/Bitcoin-address-validation create mode 120000 Lang/Tcl/Bitmap create mode 120000 Lang/Tcl/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/Tcl/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Tcl/Bitmap-Flood-fill create mode 120000 Lang/Tcl/Bitmap-Histogram create mode 120000 Lang/Tcl/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Tcl/Bitmap-PPM-conversion-through-a-pipe create mode 120000 Lang/Tcl/Bitmap-Read-a-PPM-file create mode 120000 Lang/Tcl/Bitmap-Read-an-image-through-a-pipe create mode 120000 Lang/Tcl/Bitmap-Write-a-PPM-file create mode 120000 Lang/Tcl/Bitwise-IO create mode 120000 Lang/Tcl/Bitwise-operations create mode 120000 Lang/Tcl/Boolean-values create mode 120000 Lang/Tcl/Box-the-compass create mode 120000 Lang/Tcl/Break-OO-privacy create mode 120000 Lang/Tcl/Bulls-and-cows-Player create mode 100644 Task/100-doors/BASIC256/100-doors.basic256 create mode 100644 Task/100-doors/BBC-BASIC/100-doors.bbc create mode 100644 Task/100-doors/Batch-File/100-doors-1.bat create mode 100644 Task/100-doors/Batch-File/100-doors-2.bat create mode 100644 Task/100-doors/BlitzMax/100-doors.blitz create mode 100644 Task/100-doors/Bracmat/100-doors-1.bracmat create mode 100644 Task/100-doors/Bracmat/100-doors-2.bracmat create mode 100644 Task/100-doors/Bracmat/100-doors-3.bracmat create mode 100644 Task/100-doors/Bracmat/100-doors-4.bracmat create mode 100644 Task/100-doors/Bracmat/100-doors-5.bracmat create mode 100644 Task/100-doors/Burlesque/100-doors.blq create mode 100644 Task/24-game/BBC-BASIC/24-game.bbc create mode 100644 Task/24-game/Bracmat/24-game.bracmat create mode 100644 Task/99-Bottles-of-Beer/BASIC256/99-bottles-of-beer.basic256 create mode 100644 Task/99-Bottles-of-Beer/BBC-BASIC/99-bottles-of-beer.bbc create mode 100644 Task/99-Bottles-of-Beer/Batch-File/99-bottles-of-beer.bat create mode 100644 Task/99-Bottles-of-Beer/Bracmat/99-bottles-of-beer.bracmat create mode 100644 Task/99-Bottles-of-Beer/Brainf---/99-bottles-of-beer.bf create mode 100644 Task/99-Bottles-of-Beer/Brat/99-bottles-of-beer.brat create mode 100644 Task/A+B/BASIC256/a+b.basic256 create mode 100644 Task/A+B/BBC-BASIC/a+b-1.bbc create mode 100644 Task/A+B/BBC-BASIC/a+b-2.bbc create mode 100644 Task/A+B/Batch-File/a+b-1.bat create mode 100644 Task/A+B/Batch-File/a+b-2.bat create mode 100644 Task/A+B/Batch-File/a+b-3.bat create mode 100644 Task/A+B/Batch-File/a+b-4.bat create mode 100644 Task/A+B/Bracmat/a+b.bracmat create mode 100644 Task/A+B/Brainf---/a+b.bf create mode 100644 Task/A+B/Brat/a+b.brat create mode 100644 Task/A+B/Burlesque/a+b.blq create mode 100644 Task/Abstract-type/BBC-BASIC/abstract-type.bbc create mode 100644 Task/Accumulator-factory/BBC-BASIC/accumulator-factory.bbc create mode 100644 Task/Accumulator-factory/Brat/accumulator-factory.brat create mode 100644 Task/Ackermann-function/BASIC256/ackermann-function-1.basic256 create mode 100644 Task/Ackermann-function/BASIC256/ackermann-function-2.basic256 create mode 100644 Task/Ackermann-function/BBC-BASIC/ackermann-function.bbc create mode 100644 Task/Ackermann-function/BCPL/ackermann-function.bcpl create mode 100644 Task/Ackermann-function/Batch-File/ackermann-function-1.bat create mode 100644 Task/Ackermann-function/Batch-File/ackermann-function-2.bat create mode 100644 Task/Ackermann-function/Bracmat/ackermann-function-1.bracmat create mode 100644 Task/Ackermann-function/Bracmat/ackermann-function-2.bracmat create mode 100644 Task/Ackermann-function/Bracmat/ackermann-function-3.bracmat create mode 100644 Task/Ackermann-function/Brat/ackermann-function.brat create mode 100644 Task/Active-object/BBC-BASIC/active-object.bbc create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/BBC-BASIC/add-a-variable-to-a-class-instance-at-runtime.bbc create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-1.bracmat create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-2.bracmat create mode 100644 Task/Address-of-a-variable/BBC-BASIC/address-of-a-variable.bbc create mode 100644 Task/Align-columns/BBC-BASIC/align-columns.bbc create mode 100644 Task/Anagrams-Deranged-anagrams/BBC-BASIC/anagrams-deranged-anagrams.bbc create mode 100644 Task/Anagrams-Deranged-anagrams/Bracmat/anagrams-deranged-anagrams.bracmat create mode 100644 Task/Anagrams/BBC-BASIC/anagrams.bbc create mode 100644 Task/Anagrams/Bracmat/anagrams.bracmat create mode 100644 Task/Animate-a-pendulum/BBC-BASIC/animate-a-pendulum.bbc create mode 100644 Task/Animation/BBC-BASIC/animation.bbc create mode 100644 Task/Anonymous-recursion/BBC-BASIC/anonymous-recursion.bbc create mode 100644 Task/Anonymous-recursion/Bracmat/anonymous-recursion-1.bracmat create mode 100644 Task/Anonymous-recursion/Bracmat/anonymous-recursion-2.bracmat create mode 100644 Task/Apply-a-callback-to-an-array/BBC-BASIC/apply-a-callback-to-an-array.bbc create mode 100644 Task/Apply-a-callback-to-an-array/Brat/apply-a-callback-to-an-array-1.brat create mode 100644 Task/Apply-a-callback-to-an-array/Brat/apply-a-callback-to-an-array-2.brat create mode 100644 Task/Arbitrary-precision-integers-(included)/Bracmat/arbitrary-precision-integers-(included).bracmat create mode 100644 Task/Arithmetic-Complex/BBC-BASIC/arithmetic-complex.bbc create mode 100644 Task/Arithmetic-Integer/BASIC256/arithmetic-integer.basic256 create mode 100644 Task/Arithmetic-Integer/BBC-BASIC/arithmetic-integer.bbc create mode 100644 Task/Arithmetic-Integer/Batch-File/arithmetic-integer.bat create mode 100644 Task/Arithmetic-Integer/Brat/arithmetic-integer.brat create mode 100644 Task/Arithmetic-Rational/BBC-BASIC/arithmetic-rational.bbc create mode 100644 Task/Arithmetic-evaluation/BBC-BASIC/arithmetic-evaluation.bbc create mode 100644 Task/Arithmetic-geometric-mean/BBC-BASIC/arithmetic-geometric-mean.bbc create mode 100644 Task/Array-concatenation/BBC-BASIC/array-concatenation.bbc create mode 100644 Task/Array-concatenation/Burlesque/array-concatenation.blq create mode 100644 Task/Arrays/BASIC256/arrays.basic256 create mode 100644 Task/Arrays/BBC-BASIC/arrays.bbc create mode 100644 Task/Arrays/Batch-File/arrays.bat create mode 100644 Task/Assertions/BBC-BASIC/assertions.bbc create mode 100644 Task/Assertions/Brat/assertions.brat create mode 100644 Task/Associative-array-Creation/BASIC256/associative-array-creation.basic256 create mode 100644 Task/Associative-array-Creation/BBC-BASIC/associative-array-creation.bbc create mode 100644 Task/Associative-array-Creation/Batch-File/associative-array-creation.bat create mode 100644 Task/Associative-array-Creation/Brat/associative-array-creation.brat create mode 100644 Task/Associative-array-Iteration/BBC-BASIC/associative-array-iteration.bbc create mode 100644 Task/Associative-array-Iteration/Brat/associative-array-iteration.brat create mode 100644 Task/Atomic-updates/BBC-BASIC/atomic-updates.bbc create mode 100644 Task/Average-loop-length/BBC-BASIC/average-loop-length.bbc create mode 100644 Task/Averages-Arithmetic-mean/BBC-BASIC/averages-arithmetic-mean.bbc create mode 100644 Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-1.bracmat create mode 100644 Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-2.bracmat create mode 100644 Task/Averages-Arithmetic-mean/Brainf---/averages-arithmetic-mean.bf create mode 100644 Task/Averages-Arithmetic-mean/Brat/averages-arithmetic-mean.brat create mode 100644 Task/Averages-Arithmetic-mean/Burlesque/averages-arithmetic-mean.blq create mode 100644 Task/Averages-Mean-angle/BBC-BASIC/averages-mean-angle.bbc create mode 100644 Task/Averages-Median/BBC-BASIC/averages-median.bbc create mode 100644 Task/Averages-Median/Bracmat/averages-median.bracmat create mode 100644 Task/Averages-Mode/BBC-BASIC/averages-mode.bbc create mode 100644 Task/Averages-Pythagorean-means/BBC-BASIC/averages-pythagorean-means.bbc create mode 100644 Task/Averages-Root-mean-square/BBC-BASIC/averages-root-mean-square.bbc create mode 100644 Task/Averages-Simple-moving-average/BBC-BASIC/averages-simple-moving-average.bbc create mode 100644 Task/Balanced-brackets/BBC-BASIC/balanced-brackets.bbc create mode 100644 Task/Balanced-brackets/Bracmat/balanced-brackets.bracmat create mode 100644 Task/Balanced-brackets/Brat/balanced-brackets.brat create mode 100644 Task/Best-shuffle/BBC-BASIC/best-shuffle.bbc create mode 100644 Task/Best-shuffle/Bracmat/best-shuffle-1.bracmat create mode 100644 Task/Best-shuffle/Bracmat/best-shuffle-2.bracmat create mode 100644 Task/Binary-search/BBC-BASIC/binary-search.bbc create mode 100644 Task/Binary-search/Brat/binary-search.brat create mode 100644 Task/Binary-strings/BBC-BASIC/binary-strings.bbc create mode 100644 Task/Bitcoin-address-validation/0DESCRIPTION create mode 100644 Task/Bitcoin-address-validation/C/bitcoin-address-validation.c create mode 100644 Task/Bitcoin-address-validation/Perl/bitcoin-address-validation.pl create mode 100644 Task/Bitcoin-address-validation/Python/bitcoin-address-validation-1.py create mode 100644 Task/Bitcoin-address-validation/Python/bitcoin-address-validation-2.py create mode 100644 Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-1.tcl create mode 100644 Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-2.tcl create mode 100644 Task/Bitmap-B-zier-curves-Cubic/0DESCRIPTION create mode 100644 Task/Bitmap-B-zier-curves-Cubic/1META.yaml create mode 100644 Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic.alg create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-1.ada create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-2.ada create mode 100644 Task/Bitmap-B-zier-curves-Cubic/BBC-BASIC/bitmap-b-zier-curves-cubic.bbc create mode 100644 Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-1.c create mode 100644 Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-2.c create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Fortran/bitmap-b-zier-curves-cubic.f create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-1.go create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-2.go create mode 100644 Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-1.m create mode 100644 Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-2.m create mode 100644 Task/Bitmap-B-zier-curves-Cubic/PHP/bitmap-b-zier-curves-cubic.php create mode 100644 Task/Bitmap-B-zier-curves-Cubic/PicoLisp/bitmap-b-zier-curves-cubic-1.l create mode 100644 Task/Bitmap-B-zier-curves-Cubic/PicoLisp/bitmap-b-zier-curves-cubic-2.l create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Python/bitmap-b-zier-curves-cubic.py create mode 100644 Task/Bitmap-B-zier-curves-Cubic/R/bitmap-b-zier-curves-cubic.r create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Ruby/bitmap-b-zier-curves-cubic.rb create mode 100644 Task/Bitmap-B-zier-curves-Cubic/Tcl/bitmap-b-zier-curves-cubic.tcl create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/0DESCRIPTION create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/1META.yaml create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-1.ada create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-2.ada create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/BBC-BASIC/bitmap-b-zier-curves-quadratic.bbc create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-1.c create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-2.c create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/Fortran/bitmap-b-zier-curves-quadratic.f create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-1.go create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-2.go create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/Haskell/bitmap-b-zier-curves-quadratic.hs create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-1.m create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-2.m create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-1.l create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-2.l create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/0DESCRIPTION create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/1META.yaml create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-1.ada create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-2.ada create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/AutoHotkey/bitmap-bresenhams-line-algorithm.ahk create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/BBC-BASIC/bitmap-bresenhams-line-algorithm.bbc create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/C/bitmap-bresenhams-line-algorithm.c create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Clojure/bitmap-bresenhams-line-algorithm.clj create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-1.erl create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-2.erl create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Forth/bitmap-bresenhams-line-algorithm.fth create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-1.f create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-2.f create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-1.go create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-2.go create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Haskell/bitmap-bresenhams-line-algorithm.hs create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/JavaScript/bitmap-bresenhams-line-algorithm.js create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-1.m create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-2.m create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Perl/bitmap-bresenhams-line-algorithm.pl create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/PicoLisp/bitmap-bresenhams-line-algorithm.l create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Python/bitmap-bresenhams-line-algorithm.py create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/REXX/bitmap-bresenhams-line-algorithm.rexx create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Ruby/bitmap-bresenhams-line-algorithm.rb create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Scala/bitmap-bresenhams-line-algorithm.scala create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Tcl/bitmap-bresenhams-line-algorithm.tcl create mode 100644 Task/Bitmap-Flood-fill/0DESCRIPTION create mode 100644 Task/Bitmap-Flood-fill/1META.yaml create mode 100644 Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-1.ada create mode 100644 Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-2.ada create mode 100644 Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-1.ahk create mode 100644 Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-2.ahk create mode 100644 Task/Bitmap-Flood-fill/BBC-BASIC/bitmap-flood-fill.bbc create mode 100644 Task/Bitmap-Flood-fill/C/bitmap-flood-fill-1.c create mode 100644 Task/Bitmap-Flood-fill/C/bitmap-flood-fill-2.c create mode 100644 Task/Bitmap-Flood-fill/C/bitmap-flood-fill-3.c create mode 100644 Task/Bitmap-Flood-fill/C/bitmap-flood-fill-4.c create mode 100644 Task/Bitmap-Flood-fill/Forth/bitmap-flood-fill.fth create mode 100644 Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-1.f create mode 100644 Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-2.f create mode 100644 Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go create mode 100644 Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go create mode 100644 Task/Bitmap-Flood-fill/Haskell/bitmap-flood-fill.hs create mode 100644 Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-1.java create mode 100644 Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-2.java create mode 100644 Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-1.pl create mode 100644 Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-2.pl create mode 100644 Task/Bitmap-Flood-fill/PicoLisp/bitmap-flood-fill.l create mode 100644 Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-1.py create mode 100644 Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-2.py create mode 100644 Task/Bitmap-Flood-fill/Racket/bitmap-flood-fill.rkt create mode 100644 Task/Bitmap-Flood-fill/Ruby/bitmap-flood-fill.rb create mode 100644 Task/Bitmap-Flood-fill/Tcl/bitmap-flood-fill.tcl create mode 100644 Task/Bitmap-Histogram/0DESCRIPTION create mode 100644 Task/Bitmap-Histogram/1META.yaml create mode 100644 Task/Bitmap-Histogram/Ada/bitmap-histogram-1.ada create mode 100644 Task/Bitmap-Histogram/Ada/bitmap-histogram-2.ada create mode 100644 Task/Bitmap-Histogram/Ada/bitmap-histogram-3.ada create mode 100644 Task/Bitmap-Histogram/BBC-BASIC/bitmap-histogram.bbc create mode 100644 Task/Bitmap-Histogram/C/bitmap-histogram-1.c create mode 100644 Task/Bitmap-Histogram/C/bitmap-histogram-2.c create mode 100644 Task/Bitmap-Histogram/C/bitmap-histogram-3.c create mode 100644 Task/Bitmap-Histogram/C/bitmap-histogram-4.c create mode 100644 Task/Bitmap-Histogram/Forth/bitmap-histogram.fth create mode 100644 Task/Bitmap-Histogram/Fortran/bitmap-histogram-1.f create mode 100644 Task/Bitmap-Histogram/Fortran/bitmap-histogram-2.f create mode 100644 Task/Bitmap-Histogram/Go/bitmap-histogram-1.go create mode 100644 Task/Bitmap-Histogram/Go/bitmap-histogram-2.go create mode 100644 Task/Bitmap-Histogram/Haskell/bitmap-histogram-1.hs create mode 100644 Task/Bitmap-Histogram/Haskell/bitmap-histogram-2.hs create mode 100644 Task/Bitmap-Histogram/Lua/bitmap-histogram.lua create mode 100644 Task/Bitmap-Histogram/PHP/bitmap-histogram.php create mode 100644 Task/Bitmap-Histogram/PicoLisp/bitmap-histogram.l create mode 100644 Task/Bitmap-Histogram/Ruby/bitmap-histogram.rb create mode 100644 Task/Bitmap-Histogram/Scala/bitmap-histogram-1.scala create mode 100644 Task/Bitmap-Histogram/Scala/bitmap-histogram-2.scala create mode 100644 Task/Bitmap-Histogram/Tcl/bitmap-histogram.tcl create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/0DESCRIPTION create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/1META.yaml create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm.alg create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-1.ada create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-2.ada create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-1.bbc create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-2.bbc create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-3.bbc create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Forth/bitmap-midpoint-circle-algorithm.fth create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-1.f create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-2.f create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-1.go create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-2.go create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-1.hs create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-2.hs create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-3.hs create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/PicoLisp/bitmap-midpoint-circle-algorithm.l create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Python/bitmap-midpoint-circle-algorithm.py create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/REXX/bitmap-midpoint-circle-algorithm.rexx create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Ruby/bitmap-midpoint-circle-algorithm.rb create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Scala/bitmap-midpoint-circle-algorithm.scala create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Tcl/bitmap-midpoint-circle-algorithm.tcl create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/0DESCRIPTION create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/1META.yaml create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-1.c create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-2.c create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-3.c create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-1.go create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-2.go create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/PicoLisp/bitmap-ppm-conversion-through-a-pipe.l create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/Ruby/bitmap-ppm-conversion-through-a-pipe.rb create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-1.tcl create mode 100644 Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-2.tcl create mode 100644 Task/Bitmap-Read-a-PPM-file/0DESCRIPTION create mode 100644 Task/Bitmap-Read-a-PPM-file/1META.yaml create mode 100644 Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-1.ada create mode 100644 Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-2.ada create mode 100644 Task/Bitmap-Read-a-PPM-file/AutoHotkey/bitmap-read-a-ppm-file.ahk create mode 100644 Task/Bitmap-Read-a-PPM-file/BBC-BASIC/bitmap-read-a-ppm-file.bbc create mode 100644 Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-1.c create mode 100644 Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-2.c create mode 100644 Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-3.c create mode 100644 Task/Bitmap-Read-a-PPM-file/Forth/bitmap-read-a-ppm-file.fth create mode 100644 Task/Bitmap-Read-a-PPM-file/Fortran/bitmap-read-a-ppm-file.f create mode 100644 Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-1.go create mode 100644 Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-2.go create mode 100644 Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-1.hs create mode 100644 Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-2.hs create mode 100644 Task/Bitmap-Read-a-PPM-file/Lua/bitmap-read-a-ppm-file.lua create mode 100644 Task/Bitmap-Read-a-PPM-file/Perl/bitmap-read-a-ppm-file.pl create mode 100644 Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-1.l create mode 100644 Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-2.l create mode 100644 Task/Bitmap-Read-a-PPM-file/Python/bitmap-read-a-ppm-file.py create mode 100644 Task/Bitmap-Read-a-PPM-file/Ruby/bitmap-read-a-ppm-file.rb create mode 100644 Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-1.scala create mode 100644 Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-2.scala create mode 100644 Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-1.tcl create mode 100644 Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-2.tcl create mode 100644 Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-3.tcl create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/0DESCRIPTION create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/1META.yaml create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/AutoHotkey/bitmap-read-an-image-through-a-pipe.ahk create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-1.c create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-2.c create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/Go/bitmap-read-an-image-through-a-pipe.go create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/PicoLisp/bitmap-read-an-image-through-a-pipe.l create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/Ruby/bitmap-read-an-image-through-a-pipe.rb create mode 100644 Task/Bitmap-Read-an-image-through-a-pipe/Tcl/bitmap-read-an-image-through-a-pipe.tcl create mode 100644 Task/Bitmap-Write-a-PPM-file/0DESCRIPTION create mode 100644 Task/Bitmap-Write-a-PPM-file/1META.yaml create mode 100644 Task/Bitmap-Write-a-PPM-file/Ada/bitmap-write-a-ppm-file.ada create mode 100644 Task/Bitmap-Write-a-PPM-file/AutoHotkey/bitmap-write-a-ppm-file.ahk create mode 100644 Task/Bitmap-Write-a-PPM-file/BBC-BASIC/bitmap-write-a-ppm-file.bbc create mode 100644 Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-1.c create mode 100644 Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-2.c create mode 100644 Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-3.c create mode 100644 Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-4.c create mode 100644 Task/Bitmap-Write-a-PPM-file/Forth/bitmap-write-a-ppm-file.fth create mode 100644 Task/Bitmap-Write-a-PPM-file/Fortran/bitmap-write-a-ppm-file.f create mode 100644 Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-1.go create mode 100644 Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-2.go create mode 100644 Task/Bitmap-Write-a-PPM-file/Haskell/bitmap-write-a-ppm-file.hs create mode 100644 Task/Bitmap-Write-a-PPM-file/Lua/bitmap-write-a-ppm-file.lua create mode 100644 Task/Bitmap-Write-a-PPM-file/PHP/bitmap-write-a-ppm-file.php create mode 100644 Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-1.pl create mode 100644 Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-2.pl create mode 100644 Task/Bitmap-Write-a-PPM-file/PicoLisp/bitmap-write-a-ppm-file.l create mode 100644 Task/Bitmap-Write-a-PPM-file/Python/bitmap-write-a-ppm-file.py create mode 100644 Task/Bitmap-Write-a-PPM-file/R/bitmap-write-a-ppm-file.r create mode 100644 Task/Bitmap-Write-a-PPM-file/REXX/bitmap-write-a-ppm-file.rexx create mode 100644 Task/Bitmap-Write-a-PPM-file/Ruby/bitmap-write-a-ppm-file.rb create mode 100644 Task/Bitmap-Write-a-PPM-file/Scala/bitmap-write-a-ppm-file.scala create mode 100644 Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-1.ss create mode 100644 Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-2.ss create mode 100644 Task/Bitmap-Write-a-PPM-file/Tcl/bitmap-write-a-ppm-file.tcl create mode 100644 Task/Bitmap/0DESCRIPTION create mode 100644 Task/Bitmap/1META.yaml create mode 100644 Task/Bitmap/ALGOL-68/bitmap.alg create mode 100644 Task/Bitmap/Ada/bitmap-1.ada create mode 100644 Task/Bitmap/Ada/bitmap-2.ada create mode 100644 Task/Bitmap/Ada/bitmap-3.ada create mode 100644 Task/Bitmap/AutoHotkey/bitmap.ahk create mode 100644 Task/Bitmap/BASIC256/bitmap.basic256 create mode 100644 Task/Bitmap/BBC-BASIC/bitmap.bbc create mode 100644 Task/Bitmap/C/bitmap-1.c create mode 100644 Task/Bitmap/C/bitmap-2.c create mode 100644 Task/Bitmap/Clojure/bitmap.clj create mode 100644 Task/Bitmap/Forth/bitmap.fth create mode 100644 Task/Bitmap/Go/bitmap.go create mode 100644 Task/Bitmap/Haskell/bitmap-1.hs create mode 100644 Task/Bitmap/Haskell/bitmap-2.hs create mode 100644 Task/Bitmap/Java/bitmap-1.java create mode 100644 Task/Bitmap/Java/bitmap-2.java create mode 100644 Task/Bitmap/Lua/bitmap-1.lua create mode 100644 Task/Bitmap/Lua/bitmap-2.lua create mode 100644 Task/Bitmap/MATLAB/bitmap-1.m create mode 100644 Task/Bitmap/MATLAB/bitmap-2.m create mode 100644 Task/Bitmap/PHP/bitmap.php create mode 100644 Task/Bitmap/Perl/bitmap.pl create mode 100644 Task/Bitmap/PicoLisp/bitmap.l create mode 100644 Task/Bitmap/R/bitmap.r create mode 100644 Task/Bitmap/REXX/bitmap.rexx create mode 100644 Task/Bitmap/Racket/bitmap.rkt create mode 100644 Task/Bitmap/Ruby/bitmap.rb create mode 100644 Task/Bitmap/Scala/bitmap-1.scala create mode 100644 Task/Bitmap/Scala/bitmap-2.scala create mode 100644 Task/Bitmap/Scheme/bitmap-1.ss create mode 100644 Task/Bitmap/Scheme/bitmap-2.ss create mode 100644 Task/Bitmap/Scheme/bitmap-3.ss create mode 100644 Task/Bitmap/Scheme/bitmap-4.ss create mode 100644 Task/Bitmap/Scheme/bitmap-5.ss create mode 100644 Task/Bitmap/Tcl/bitmap.tcl create mode 100644 Task/Bitwise-IO/0DESCRIPTION create mode 100644 Task/Bitwise-IO/ALGOL-68/bitwise-io.alg create mode 100644 Task/Bitwise-IO/Ada/bitwise-io-1.ada create mode 100644 Task/Bitwise-IO/Ada/bitwise-io-2.ada create mode 100644 Task/Bitwise-IO/Ada/bitwise-io-3.ada create mode 100644 Task/Bitwise-IO/BBC-BASIC/bitwise-io.bbc create mode 100644 Task/Bitwise-IO/C/bitwise-io.c create mode 100644 Task/Bitwise-IO/Forth/bitwise-io.fth create mode 100644 Task/Bitwise-IO/Haskell/bitwise-io.hs create mode 100644 Task/Bitwise-IO/Perl/bitwise-io-1.pl create mode 100644 Task/Bitwise-IO/Perl/bitwise-io-2.pl create mode 100644 Task/Bitwise-IO/Perl/bitwise-io-3.pl create mode 100644 Task/Bitwise-IO/PicoLisp/bitwise-io-1.l create mode 100644 Task/Bitwise-IO/PicoLisp/bitwise-io-2.l create mode 100644 Task/Bitwise-IO/Python/bitwise-io-1.py create mode 100644 Task/Bitwise-IO/Python/bitwise-io-2.py create mode 100644 Task/Bitwise-IO/Python/bitwise-io-3.py create mode 100644 Task/Bitwise-IO/REXX/bitwise-io.rexx create mode 100644 Task/Bitwise-IO/Ruby/bitwise-io.rb create mode 100644 Task/Bitwise-IO/Tcl/bitwise-io.tcl create mode 100644 Task/Bitwise-operations/0DESCRIPTION create mode 100644 Task/Bitwise-operations/1META.yaml create mode 100644 Task/Bitwise-operations/ACL2/bitwise-operations.acl2 create mode 100644 Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg create mode 100644 Task/Bitwise-operations/ALGOL-68/bitwise-operations-2.alg create mode 100644 Task/Bitwise-operations/AWK/bitwise-operations.awk create mode 100644 Task/Bitwise-operations/ActionScript/bitwise-operations.as create mode 100644 Task/Bitwise-operations/Ada/bitwise-operations.ada create mode 100644 Task/Bitwise-operations/Aikido/bitwise-operations.aikido create mode 100644 Task/Bitwise-operations/AutoHotkey/bitwise-operations.ahk create mode 100644 Task/Bitwise-operations/BASIC/bitwise-operations-1.bas create mode 100644 Task/Bitwise-operations/BASIC/bitwise-operations-2.bas create mode 100644 Task/Bitwise-operations/BASIC256/bitwise-operations.basic256 create mode 100644 Task/Bitwise-operations/BBC-BASIC/bitwise-operations.bbc create mode 100644 Task/Bitwise-operations/Batch-File/bitwise-operations.bat create mode 100644 Task/Bitwise-operations/C/bitwise-operations-1.c create mode 100644 Task/Bitwise-operations/C/bitwise-operations-2.c create mode 100644 Task/Bitwise-operations/C/bitwise-operations-3.c create mode 100644 Task/Bitwise-operations/Clojure/bitwise-operations.clj create mode 100644 Task/Bitwise-operations/CoffeeScript/bitwise-operations-1.coffee create mode 100644 Task/Bitwise-operations/CoffeeScript/bitwise-operations-2.coffee create mode 100644 Task/Bitwise-operations/Erlang/bitwise-operations-1.erl create mode 100644 Task/Bitwise-operations/Erlang/bitwise-operations-2.erl create mode 100644 Task/Bitwise-operations/Forth/bitwise-operations.fth create mode 100644 Task/Bitwise-operations/Fortran/bitwise-operations-1.f create mode 100644 Task/Bitwise-operations/Fortran/bitwise-operations-2.f create mode 100644 Task/Bitwise-operations/Go/bitwise-operations.go create mode 100644 Task/Bitwise-operations/Haskell/bitwise-operations.hs create mode 100644 Task/Bitwise-operations/Java/bitwise-operations-1.java create mode 100644 Task/Bitwise-operations/Java/bitwise-operations-2.java create mode 100644 Task/Bitwise-operations/JavaScript/bitwise-operations.js create mode 100644 Task/Bitwise-operations/Lua/bitwise-operations.lua create mode 100644 Task/Bitwise-operations/MATLAB/bitwise-operations-1.m create mode 100644 Task/Bitwise-operations/MATLAB/bitwise-operations-2.m create mode 100644 Task/Bitwise-operations/PHP/bitwise-operations.php create mode 100644 Task/Bitwise-operations/Perl/bitwise-operations.pl create mode 100644 Task/Bitwise-operations/PicoLisp/bitwise-operations-1.l create mode 100644 Task/Bitwise-operations/PicoLisp/bitwise-operations-2.l create mode 100644 Task/Bitwise-operations/PicoLisp/bitwise-operations-3.l create mode 100644 Task/Bitwise-operations/PicoLisp/bitwise-operations-4.l create mode 100644 Task/Bitwise-operations/PicoLisp/bitwise-operations-5.l create mode 100644 Task/Bitwise-operations/Python/bitwise-operations-1.py create mode 100644 Task/Bitwise-operations/Python/bitwise-operations-2.py create mode 100644 Task/Bitwise-operations/Python/bitwise-operations-3.py create mode 100644 Task/Bitwise-operations/R/bitwise-operations-1.r create mode 100644 Task/Bitwise-operations/R/bitwise-operations-2.r create mode 100644 Task/Bitwise-operations/R/bitwise-operations-3.r create mode 100644 Task/Bitwise-operations/R/bitwise-operations-4.r create mode 100644 Task/Bitwise-operations/REXX/bitwise-operations.rexx create mode 100644 Task/Bitwise-operations/Racket/bitwise-operations.rkt create mode 100644 Task/Bitwise-operations/Ruby/bitwise-operations.rb create mode 100644 Task/Bitwise-operations/Scala/bitwise-operations.scala create mode 100644 Task/Bitwise-operations/Scheme/bitwise-operations-1.ss create mode 100644 Task/Bitwise-operations/Scheme/bitwise-operations-2.ss create mode 100644 Task/Bitwise-operations/Smalltalk/bitwise-operations-1.st create mode 100644 Task/Bitwise-operations/Smalltalk/bitwise-operations-2.st create mode 100644 Task/Bitwise-operations/Tcl/bitwise-operations-1.tcl create mode 100644 Task/Bitwise-operations/Tcl/bitwise-operations-2.tcl create mode 100644 Task/Boolean-values/0DESCRIPTION create mode 100644 Task/Boolean-values/1META.yaml create mode 100644 Task/Boolean-values/ALGOL-68/boolean-values.alg create mode 100644 Task/Boolean-values/AWK/boolean-values.awk create mode 100644 Task/Boolean-values/Ada/boolean-values.ada create mode 100644 Task/Boolean-values/BASIC/boolean-values.bas create mode 100644 Task/Boolean-values/BASIC256/boolean-values.basic256 create mode 100644 Task/Boolean-values/BBC-BASIC/boolean-values.bbc create mode 100644 Task/Boolean-values/CoffeeScript/boolean-values.coffee create mode 100644 Task/Boolean-values/Erlang/boolean-values.erl create mode 100644 Task/Boolean-values/Forth/boolean-values.fth create mode 100644 Task/Boolean-values/Haskell/boolean-values.hs create mode 100644 Task/Boolean-values/Lua/boolean-values.lua create mode 100644 Task/Boolean-values/MATLAB/boolean-values.m create mode 100644 Task/Boolean-values/Perl/boolean-values-1.pl create mode 100644 Task/Boolean-values/Perl/boolean-values-2.pl create mode 100644 Task/Boolean-values/Perl/boolean-values-3.pl create mode 100644 Task/Boolean-values/Perl/boolean-values-4.pl create mode 100644 Task/Boolean-values/Python/boolean-values.py create mode 100644 Task/Boolean-values/REXX/boolean-values-1.rexx create mode 100644 Task/Boolean-values/REXX/boolean-values-2.rexx create mode 100644 Task/Boolean-values/REXX/boolean-values-3.rexx create mode 100644 Task/Boolean-values/REXX/boolean-values-4.rexx create mode 100644 Task/Boolean-values/REXX/boolean-values-5.rexx create mode 100644 Task/Boolean-values/REXX/boolean-values-6.rexx create mode 100644 Task/Boolean-values/Racket/boolean-values.rkt create mode 100644 Task/Boolean-values/SNUSP/boolean-values.snusp create mode 100644 Task/Boolean-values/Sather/boolean-values.sa create mode 100644 Task/Boolean-values/Tcl/boolean-values-1.tcl create mode 100644 Task/Boolean-values/Tcl/boolean-values-2.tcl create mode 100644 Task/Box-the-compass/0DESCRIPTION create mode 100644 Task/Box-the-compass/ALGOL-68/box-the-compass.alg create mode 100644 Task/Box-the-compass/AWK/box-the-compass.awk create mode 100644 Task/Box-the-compass/Ada/box-the-compass.ada create mode 100644 Task/Box-the-compass/AutoHotkey/box-the-compass.ahk create mode 100644 Task/Box-the-compass/AutoIt/box-the-compass.autoit create mode 100644 Task/Box-the-compass/BBC-BASIC/box-the-compass.bbc create mode 100644 Task/Box-the-compass/C/box-the-compass.c create mode 100644 Task/Box-the-compass/Clojure/box-the-compass.clj create mode 100644 Task/Box-the-compass/Fortran/box-the-compass.f create mode 100644 Task/Box-the-compass/Go/box-the-compass.go create mode 100644 Task/Box-the-compass/Haskell/box-the-compass.hs create mode 100644 Task/Box-the-compass/Java/box-the-compass.java create mode 100644 Task/Box-the-compass/JavaScript/box-the-compass.js create mode 100644 Task/Box-the-compass/Lua/box-the-compass.lua create mode 100644 Task/Box-the-compass/MATLAB/box-the-compass.m create mode 100644 Task/Box-the-compass/Perl/box-the-compass-1.pl create mode 100644 Task/Box-the-compass/Perl/box-the-compass-2.pl create mode 100644 Task/Box-the-compass/PicoLisp/box-the-compass.l create mode 100644 Task/Box-the-compass/Prolog/box-the-compass-1.pro create mode 100644 Task/Box-the-compass/Prolog/box-the-compass-2.pro create mode 100644 Task/Box-the-compass/Prolog/box-the-compass-3.pro create mode 100644 Task/Box-the-compass/Python/box-the-compass.py create mode 100644 Task/Box-the-compass/REXX/box-the-compass.rexx create mode 100644 Task/Box-the-compass/Racket/box-the-compass.rkt create mode 100644 Task/Box-the-compass/Ruby/box-the-compass-1.rb create mode 100644 Task/Box-the-compass/Ruby/box-the-compass-2.rb create mode 100644 Task/Box-the-compass/Scala/box-the-compass.scala create mode 100644 Task/Box-the-compass/Tcl/box-the-compass.tcl create mode 100644 Task/Break-OO-privacy/0DESCRIPTION create mode 100644 Task/Break-OO-privacy/Ada/break-oo-privacy-1.ada create mode 100644 Task/Break-OO-privacy/Ada/break-oo-privacy-2.ada create mode 100644 Task/Break-OO-privacy/Java/break-oo-privacy.java create mode 100644 Task/Break-OO-privacy/PHP/break-oo-privacy-1.php create mode 100644 Task/Break-OO-privacy/PHP/break-oo-privacy-2.php create mode 100644 Task/Break-OO-privacy/PHP/break-oo-privacy-3.php create mode 100644 Task/Break-OO-privacy/PicoLisp/break-oo-privacy-1.l create mode 100644 Task/Break-OO-privacy/PicoLisp/break-oo-privacy-2.l create mode 100644 Task/Break-OO-privacy/Python/break-oo-privacy.py create mode 100644 Task/Break-OO-privacy/Ruby/break-oo-privacy.rb create mode 100644 Task/Break-OO-privacy/Tcl/break-oo-privacy.tcl create mode 100644 Task/Bulls-and-cows-Player/0DESCRIPTION create mode 100644 Task/Bulls-and-cows-Player/1META.yaml create mode 100644 Task/Bulls-and-cows-Player/Ada/bulls-and-cows-player.ada create mode 100644 Task/Bulls-and-cows-Player/BBC-BASIC/bulls-and-cows-player.bbc create mode 100644 Task/Bulls-and-cows-Player/C/bulls-and-cows-player-1.c create mode 100644 Task/Bulls-and-cows-Player/C/bulls-and-cows-player-2.c create mode 100644 Task/Bulls-and-cows-Player/C/bulls-and-cows-player-3.c create mode 100644 Task/Bulls-and-cows-Player/Fortran/bulls-and-cows-player.f create mode 100644 Task/Bulls-and-cows-Player/Go/bulls-and-cows-player.go create mode 100644 Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-1.hs create mode 100644 Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-2.hs create mode 100644 Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-1.pl create mode 100644 Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-2.pl create mode 100644 Task/Bulls-and-cows-Player/PicoLisp/bulls-and-cows-player.l create mode 100644 Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-1.pro create mode 100644 Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-2.pro create mode 100644 Task/Bulls-and-cows-Player/Python/bulls-and-cows-player.py create mode 100644 Task/Bulls-and-cows-Player/Ruby/bulls-and-cows-player.rb create mode 100644 Task/Bulls-and-cows-Player/Tcl/bulls-and-cows-player.tcl create mode 100644 Task/Bulls-and-cows/BBC-BASIC/bulls-and-cows.bbc create mode 100644 Task/Bulls-and-cows/Brat/bulls-and-cows.brat create mode 100644 Task/Caesar-cipher/BBC-BASIC/caesar-cipher.bbc create mode 100644 Task/Calendar/BBC-BASIC/calendar.bbc create mode 100644 Task/Check-that-file-exists/BBC-BASIC/check-that-file-exists.bbc create mode 100644 Task/Check-that-file-exists/Batch-File/check-that-file-exists.bat create mode 100644 Task/Checkpoint-synchronization/BBC-BASIC/checkpoint-synchronization.bbc create mode 100644 Task/Classes/BBC-BASIC/classes.bbc create mode 100644 Task/Closest-pair-problem/BBC-BASIC/closest-pair-problem.bbc create mode 100644 Task/Collections/BBC-BASIC/collections-1.bbc create mode 100644 Task/Collections/BBC-BASIC/collections-2.bbc create mode 100644 Task/Collections/BBC-BASIC/collections-3.bbc create mode 100644 Task/Color-of-a-screen-pixel/BBC-BASIC/color-of-a-screen-pixel.bbc create mode 100644 Task/Comments/BBC-BASIC/comments.bbc create mode 100644 Task/Comments/Batch-File/comments-1.bat create mode 100644 Task/Comments/Batch-File/comments-2.bat create mode 100644 Task/Comments/Blast/comments.blast create mode 100644 Task/Comments/Brainf---/comments.bf create mode 100644 Task/Comments/Brat/comments.brat create mode 100644 Task/Comments/Brlcad/comments.brlcad create mode 100644 Task/Comments/Burlesque/comments-1.blq create mode 100644 Task/Comments/Burlesque/comments-2.blq create mode 100644 Task/Death-Star/Brlcad/death-star.brlcad create mode 100644 Task/Delete-a-file/BBC-BASIC/delete-a-file-1.bbc create mode 100644 Task/Delete-a-file/BBC-BASIC/delete-a-file-2.bbc create mode 100644 Task/Delete-a-file/Batch-File/delete-a-file.bat create mode 100644 Task/Detect-division-by-zero/BBC-BASIC/detect-division-by-zero.bbc create mode 100644 Task/Determine-if-a-string-is-numeric/BBC-BASIC/determine-if-a-string-is-numeric.bbc create mode 100644 Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-1.bracmat create mode 100644 Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-2.bracmat create mode 100644 Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-3.bracmat create mode 100644 Task/Determine-if-a-string-is-numeric/Burlesque/determine-if-a-string-is-numeric.blq create mode 100644 Task/Entropy/Burlesque/entropy.blq create mode 100644 Task/FizzBuzz/BBC-BASIC/fizzbuzz.bbc create mode 100644 Task/FizzBuzz/Batch-File/fizzbuzz-1.bat create mode 100644 Task/FizzBuzz/Batch-File/fizzbuzz-2.bat create mode 100644 Task/FizzBuzz/Boo/fizzbuzz.boo create mode 100644 Task/FizzBuzz/Bracmat/fizzbuzz-1.bracmat create mode 100644 Task/FizzBuzz/Bracmat/fizzbuzz-2.bracmat create mode 100644 Task/FizzBuzz/Brainf---/fizzbuzz.bf create mode 100644 Task/FizzBuzz/Brat/fizzbuzz.brat create mode 100644 Task/Forest-fire/BASIC256/forest-fire.basic256 create mode 100644 Task/Forest-fire/BBC-BASIC/forest-fire.bbc create mode 100644 Task/Infinity/BBC-BASIC/infinity.bbc create mode 100644 Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-1.bbc create mode 100644 Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-2.bbc create mode 100644 Task/Knuth-shuffle/Brat/knuth-shuffle.brat create mode 100644 Task/Narcissist/BBC-BASIC/narcissist.bbc create mode 100644 Task/Ordered-words/BBC-BASIC/ordered-words.bbc create mode 100644 Task/Ordered-words/Bracmat/ordered-words.bracmat create mode 100644 Task/Ordered-words/Burlesque/ordered-words.blq create mode 100644 Task/Pi/BASIC256/pi.basic256 create mode 100644 Task/Pi/BBC-BASIC/pi-1.bbc create mode 100644 Task/Pi/BBC-BASIC/pi-2.bbc create mode 100644 Task/Pi/Bracmat/pi.bracmat create mode 100644 Task/Quine/BBC-BASIC/quine-1.bbc create mode 100644 Task/Quine/BBC-BASIC/quine-2.bbc create mode 100644 Task/Quine/Batch-File/quine-1.bat create mode 100644 Task/Quine/Batch-File/quine-2.bat create mode 100644 Task/Quine/Bracmat/quine-1.bracmat create mode 100644 Task/Quine/Bracmat/quine-2.bracmat create mode 100644 Task/Quine/Brainf---/quine.bf create mode 100644 Task/Quine/Burlesque/quine.blq create mode 100644 Task/Search-a-list/BBC-BASIC/search-a-list.bbc create mode 100644 Task/Search-a-list/Burlesque/search-a-list-1.blq create mode 100644 Task/Search-a-list/Burlesque/search-a-list-2.blq diff --git a/Conf/.lang.yaml.swp b/Conf/.lang.yaml.swp index fa5b64bcdaa2fcfea0a57c1436110b1fdf56d9a4..3230c9f12ad857de3e01bafeefaeb15cf9f60416 100644 GIT binary patch delta 577 zcmYMwJxCj29LMqh6$MF@#KA>79Qa0~DWPhM0R=CqC@NZ|E(P^GFM8!n@H}6aI5tdfz0p zut@a3{blpri44|>IO)lyT(0IYc@ffb`SS2xs4Q0^avOM#vZYsP+3#f{BN###l4wT@ z8c>V3s6Y^fQjrJT;V=H+H!g9GQygI*d-#cMtYa1P$Y2s9rIM9lCOt@^6*1JK8kGnm zfI?8@9{+HIYh2+1XE?zz4zPeq0}SXT+HETzhtA&W?-Wxt2MhM$?bKWKwGFq*IYd66Olt0V#< z`C{(2R@-RDzC6aAgY zqmNJY(7_8DctRZ&JmMZDTtXw|lB6UF$A}?{9YheoI#ys}88d$W!x%&SppOr{p@TMB gPRp=29oA&4YxtDXH>G`*$;yGwUKexPx(Zd7=8?TTA^-pY diff --git a/Conf/.task.yaml.swp b/Conf/.task.yaml.swp index 39124cc3dc2d2e1a2d49f5cf7ff4db17d7fa8042..222d3864dbbcbd2a542553e3b66dbe5babf47cef 100644 GIT binary patch delta 949 zcmZwEL1+^}6b9g_X{gmo(u-g(4pdWvVnh)kCy62!2}z1n4<0hvo$L;_rL5F(`0SzSHy$nY5{;+9ppB5t8W+HG#%LM}0K#d#L>mKi)!aOD|ZqtD4_`H!=O*3nW2PVqnuNmziSN2$k>-?^8zg(-f6im`U zbKFtToGsB(iTYZ!n1ve(YMBNu$0QA(8MIYU%Ht?#F)!rtZxOVG;Z*rtvp}dw4h82+ z{e%YdbJw&8IAye4F4DS)2SR21VSzIn%c7#e9FDuR3LO`TzVLS^{aYNLW+~a?+6aXy zTpj(dyeMp62^mmJXv;$zo}V zgv^d-wuTdK3};*jYr|hPH(a``F=wbJK1_s|3sezrEdl-V$7#K41(kmxURN3fqhMzHXv!K9d ze%@XV28O?!5T&7$1r<)$OYkr-a02mvZU%-oKzs#=cL4D`Af5`u^*~$%#F0Sk55&$u zY!1YdK+Ffk|G5|#o&oU@Al?nctAKa`5Kji;E+DQ1;(Q>^1mY+l_61@aAT|JEMJ@(q z23a6O42XGv8055vKztU6&j9ghAU?&pnUTekV{)gu_T&ZXB0$Wsd5gLf6Q5IQPEN5x RVqS_ua(;R7W;LB#%mCqcH+KL4 diff --git a/Conf/lang.yaml b/Conf/lang.yaml index 103c24eaef..a5d9540a9d 100644 --- a/Conf/lang.yaml +++ b/Conf/lang.yaml @@ -67,8 +67,30 @@ Babel: ext: pb BASIC: ext: bas +BASIC256: +Batch File: + ext: bat +BBC BASIC: +Bc: +BCPL: Befunge: ext: bf +Beta: +Biferno: +Blast: +BlitzMax: + ext: blitz +Boo: +Bori: +Brace: +Bracmat: +Brainf***: + ext: bf +Brat: +Brlcad: +Burlesque: + ext: blq + C: Clojure: ext: clj diff --git a/Conf/task.yaml b/Conf/task.yaml index 93829a455c..aa5527aeb8 100644 --- a/Conf/task.yaml +++ b/Conf/task.yaml @@ -47,7 +47,35 @@ Best shuffle: # Binary digits: Binary search: Binary strings: +Bitcoin/address validation: +Bitmap: +Bitmap/Bresenham's line algorithm: #' +Bitmap/Bézier curves/Cubic: +Bitmap/Bézier curves/Quadratic: +Bitmap/Flood fill: +Bitmap/Histogram: +Bitmap/Midpoint circle algorithm: +Bitmap/PPM conversion through a pipe: +Bitmap/Read a PPM file: +Bitmap/Read an image through a pipe: +Bitmap/Write a PPM file: +Bitwise IO: +Bitwise operations: +Boolean values: +Box the compass: +Break OO privacy: +# Brownian tree: Bulls and cows: +Bulls and cows/Player: + + +# Balanced brackets: +# Balanced ternary: +# Best shuffle: +# # Binary digits: +# Binary search: +# Binary strings: +# Bulls and cows: Caesar cipher: Calendar: # Catalan numbers: diff --git a/Lang/ACL2/Bitwise-operations b/Lang/ACL2/Bitwise-operations new file mode 120000 index 0000000000..18d8dbc7cb --- /dev/null +++ b/Lang/ACL2/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/ACL2 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitmap b/Lang/ALGOL-68/Bitmap new file mode 120000 index 0000000000..bca3054657 --- /dev/null +++ b/Lang/ALGOL-68/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitmap-B-zier-curves-Cubic b/Lang/ALGOL-68/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..7204c2994a --- /dev/null +++ b/Lang/ALGOL-68/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitmap-Bresenhams-line-algorithm b/Lang/ALGOL-68/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..4a6a4a9892 --- /dev/null +++ b/Lang/ALGOL-68/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitmap-Midpoint-circle-algorithm b/Lang/ALGOL-68/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..c729251c91 --- /dev/null +++ b/Lang/ALGOL-68/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitwise-IO b/Lang/ALGOL-68/Bitwise-IO new file mode 120000 index 0000000000..eb190cfa25 --- /dev/null +++ b/Lang/ALGOL-68/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitwise-operations b/Lang/ALGOL-68/Bitwise-operations new file mode 120000 index 0000000000..add311d1a5 --- /dev/null +++ b/Lang/ALGOL-68/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Boolean-values b/Lang/ALGOL-68/Boolean-values new file mode 120000 index 0000000000..34f45c57a4 --- /dev/null +++ b/Lang/ALGOL-68/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Box-the-compass b/Lang/ALGOL-68/Box-the-compass new file mode 120000 index 0000000000..f7951f050d --- /dev/null +++ b/Lang/ALGOL-68/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/ALGOL-68 \ No newline at end of file diff --git a/Lang/AWK/Bitwise-operations b/Lang/AWK/Bitwise-operations new file mode 120000 index 0000000000..225d0d4d7d --- /dev/null +++ b/Lang/AWK/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/AWK \ No newline at end of file diff --git a/Lang/AWK/Boolean-values b/Lang/AWK/Boolean-values new file mode 120000 index 0000000000..edc57821b5 --- /dev/null +++ b/Lang/AWK/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/AWK \ No newline at end of file diff --git a/Lang/AWK/Box-the-compass b/Lang/AWK/Box-the-compass new file mode 120000 index 0000000000..470bd12122 --- /dev/null +++ b/Lang/AWK/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/AWK \ No newline at end of file diff --git a/Lang/ActionScript/Bitwise-operations b/Lang/ActionScript/Bitwise-operations new file mode 120000 index 0000000000..93603c5dad --- /dev/null +++ b/Lang/ActionScript/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/ActionScript \ No newline at end of file diff --git a/Lang/Ada/Bitmap b/Lang/Ada/Bitmap new file mode 120000 index 0000000000..b56d75bc99 --- /dev/null +++ b/Lang/Ada/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-B-zier-curves-Cubic b/Lang/Ada/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..bd10d75ee0 --- /dev/null +++ b/Lang/Ada/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-B-zier-curves-Quadratic b/Lang/Ada/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..7bc38a93c7 --- /dev/null +++ b/Lang/Ada/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-Bresenhams-line-algorithm b/Lang/Ada/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..6e65fc901e --- /dev/null +++ b/Lang/Ada/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-Flood-fill b/Lang/Ada/Bitmap-Flood-fill new file mode 120000 index 0000000000..d4b2b74bc4 --- /dev/null +++ b/Lang/Ada/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-Histogram b/Lang/Ada/Bitmap-Histogram new file mode 120000 index 0000000000..240ef55b36 --- /dev/null +++ b/Lang/Ada/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-Midpoint-circle-algorithm b/Lang/Ada/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..7f03bf8628 --- /dev/null +++ b/Lang/Ada/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-Read-a-PPM-file b/Lang/Ada/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..7fe18aa00b --- /dev/null +++ b/Lang/Ada/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitmap-Write-a-PPM-file b/Lang/Ada/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..784629e1b0 --- /dev/null +++ b/Lang/Ada/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitwise-IO b/Lang/Ada/Bitwise-IO new file mode 120000 index 0000000000..fa037f34bb --- /dev/null +++ b/Lang/Ada/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Ada \ No newline at end of file diff --git a/Lang/Ada/Bitwise-operations b/Lang/Ada/Bitwise-operations new file mode 120000 index 0000000000..43be5c4fec --- /dev/null +++ b/Lang/Ada/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Ada \ No newline at end of file diff --git a/Lang/Ada/Boolean-values b/Lang/Ada/Boolean-values new file mode 120000 index 0000000000..a1d4e58950 --- /dev/null +++ b/Lang/Ada/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Ada \ No newline at end of file diff --git a/Lang/Ada/Box-the-compass b/Lang/Ada/Box-the-compass new file mode 120000 index 0000000000..7ec723e8a2 --- /dev/null +++ b/Lang/Ada/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Ada \ No newline at end of file diff --git a/Lang/Ada/Break-OO-privacy b/Lang/Ada/Break-OO-privacy new file mode 120000 index 0000000000..771faafcf2 --- /dev/null +++ b/Lang/Ada/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Ada \ No newline at end of file diff --git a/Lang/Ada/Bulls-and-cows-Player b/Lang/Ada/Bulls-and-cows-Player new file mode 120000 index 0000000000..c432602079 --- /dev/null +++ b/Lang/Ada/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Ada \ No newline at end of file diff --git a/Lang/Aikido/Bitwise-operations b/Lang/Aikido/Bitwise-operations new file mode 120000 index 0000000000..936e526a78 --- /dev/null +++ b/Lang/Aikido/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Aikido \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitmap b/Lang/AutoHotkey/Bitmap new file mode 120000 index 0000000000..976de04d45 --- /dev/null +++ b/Lang/AutoHotkey/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitmap-Bresenhams-line-algorithm b/Lang/AutoHotkey/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..80224b8edc --- /dev/null +++ b/Lang/AutoHotkey/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitmap-Flood-fill b/Lang/AutoHotkey/Bitmap-Flood-fill new file mode 120000 index 0000000000..fd1de2b26d --- /dev/null +++ b/Lang/AutoHotkey/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitmap-Read-a-PPM-file b/Lang/AutoHotkey/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..9c43e32d5c --- /dev/null +++ b/Lang/AutoHotkey/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitmap-Read-an-image-through-a-pipe b/Lang/AutoHotkey/Bitmap-Read-an-image-through-a-pipe new file mode 120000 index 0000000000..c647d4443f --- /dev/null +++ b/Lang/AutoHotkey/Bitmap-Read-an-image-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-Read-an-image-through-a-pipe/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitmap-Write-a-PPM-file b/Lang/AutoHotkey/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..de7d865cd1 --- /dev/null +++ b/Lang/AutoHotkey/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Bitwise-operations b/Lang/AutoHotkey/Bitwise-operations new file mode 120000 index 0000000000..c99b992c00 --- /dev/null +++ b/Lang/AutoHotkey/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Box-the-compass b/Lang/AutoHotkey/Box-the-compass new file mode 120000 index 0000000000..b56d3432eb --- /dev/null +++ b/Lang/AutoHotkey/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoIt/Box-the-compass b/Lang/AutoIt/Box-the-compass new file mode 120000 index 0000000000..37a1e864f1 --- /dev/null +++ b/Lang/AutoIt/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/AutoIt \ No newline at end of file diff --git a/Lang/BASIC/Bitwise-operations b/Lang/BASIC/Bitwise-operations new file mode 120000 index 0000000000..89b005bb6e --- /dev/null +++ b/Lang/BASIC/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Boolean-values b/Lang/BASIC/Boolean-values new file mode 120000 index 0000000000..4d9be9c9c7 --- /dev/null +++ b/Lang/BASIC/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/BASIC \ No newline at end of file diff --git a/Lang/BASIC256/0DESCRIPTION b/Lang/BASIC256/0DESCRIPTION new file mode 100644 index 0000000000..657286ba6f --- /dev/null +++ b/Lang/BASIC256/0DESCRIPTION @@ -0,0 +1,25 @@ +{{language|BASIC256 +|site=http://www.basic256.org +|tags=BASIC256}} +{{implementation|BASIC}} +'''BASIC-256''' is an easy to use version of [[BASIC]] designed to teach anybody (especially middle and high-school students) the basics of computer programming. It uses traditional control structures like gosub, for/next, and goto, which helps kids easily see how program flow-control works. It has a built-in graphics mode which lets them draw pictures on screen in minutes, and a set of detailed, easy-to-follow tutorials that introduce programming concepts through fun exercises. + +; Features +* fast graphics suitable for animation +* native [[speech synthesis]] +* mouse and keyboard events +* graphic files manipulation (saving, retrieving) +* playing sounds from WAV files +* sprites handling +* database functions +* socket networking +* error handling +* files I/O +* true functions/subroutines (version 0.9.9.1 and later) + +; Disadvantages +* BASIC-256 does not support three- and N-dimensional arrays in general (N>2) + +BASIC256 is open source and available for [[Linux]], [[Windows]] and [[Mac]]. + +For more information see [http://www.basic256.org basic256.org] or to download and install [http://sourceforge.net/projects/kidbasic/ sourceforge]. \ No newline at end of file diff --git a/Lang/BASIC256/100-doors b/Lang/BASIC256/100-doors new file mode 120000 index 0000000000..1df0602bc1 --- /dev/null +++ b/Lang/BASIC256/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/99-Bottles-of-Beer b/Lang/BASIC256/99-Bottles-of-Beer new file mode 120000 index 0000000000..bd398f73ed --- /dev/null +++ b/Lang/BASIC256/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/A+B b/Lang/BASIC256/A+B new file mode 120000 index 0000000000..e70ccb0534 --- /dev/null +++ b/Lang/BASIC256/A+B @@ -0,0 +1 @@ +../../Task/A+B/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Ackermann-function b/Lang/BASIC256/Ackermann-function new file mode 120000 index 0000000000..ec00a3cb4d --- /dev/null +++ b/Lang/BASIC256/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Arithmetic-Integer b/Lang/BASIC256/Arithmetic-Integer new file mode 120000 index 0000000000..e922894ffd --- /dev/null +++ b/Lang/BASIC256/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Arrays b/Lang/BASIC256/Arrays new file mode 120000 index 0000000000..19226d07c2 --- /dev/null +++ b/Lang/BASIC256/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Associative-array-Creation b/Lang/BASIC256/Associative-array-Creation new file mode 120000 index 0000000000..e3d102d30c --- /dev/null +++ b/Lang/BASIC256/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Bitmap b/Lang/BASIC256/Bitmap new file mode 120000 index 0000000000..a2ceb348cb --- /dev/null +++ b/Lang/BASIC256/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Bitwise-operations b/Lang/BASIC256/Bitwise-operations new file mode 120000 index 0000000000..b292bf9abb --- /dev/null +++ b/Lang/BASIC256/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Boolean-values b/Lang/BASIC256/Boolean-values new file mode 120000 index 0000000000..21db548e04 --- /dev/null +++ b/Lang/BASIC256/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Forest-fire b/Lang/BASIC256/Forest-fire new file mode 120000 index 0000000000..e8ccdf840a --- /dev/null +++ b/Lang/BASIC256/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Pi b/Lang/BASIC256/Pi new file mode 120000 index 0000000000..367b70e9cf --- /dev/null +++ b/Lang/BASIC256/Pi @@ -0,0 +1 @@ +../../Task/Pi/BASIC256 \ No newline at end of file diff --git a/Lang/BBC-BASIC/0DESCRIPTION b/Lang/BBC-BASIC/0DESCRIPTION new file mode 100644 index 0000000000..5784e280d3 --- /dev/null +++ b/Lang/BBC-BASIC/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|BBC BASIC +|site=http://www.bbcbasic.co.uk/bbcbasic.html +|tags=bbcbasic}} +{{implementation|BASIC}} + +'''BBC BASIC''' is a version of the [[BASIC]] programming language. It is notable for being one of the few modern dialects that makes no attempt to be compatible to any great degree with [[Microsoft]] BASICs. + +BBC BASIC was originally written for the [[wp:BBC Micro|BBC Microcomputer]] as part of the '''BBC Computer Literacy Project''' under the direction of the [[wp:BBC|British Broadcasting Corporation]] (thus the name), but now runs on most modern, popular operating systems (and several older and/or less-popular ones). + +Wikipedia has [[wp:BBC BASIC|an article about BBC BASIC]], but the best source of information is probably [http://www.bbcbasic.co.uk/bbcbasic.html the BBC BASIC homepage]. \ No newline at end of file diff --git a/Lang/BBC-BASIC/100-doors b/Lang/BBC-BASIC/100-doors new file mode 120000 index 0000000000..6c22b4462c --- /dev/null +++ b/Lang/BBC-BASIC/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/24-game b/Lang/BBC-BASIC/24-game new file mode 120000 index 0000000000..23687ffe3f --- /dev/null +++ b/Lang/BBC-BASIC/24-game @@ -0,0 +1 @@ +../../Task/24-game/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/99-Bottles-of-Beer b/Lang/BBC-BASIC/99-Bottles-of-Beer new file mode 120000 index 0000000000..4a85de4aaa --- /dev/null +++ b/Lang/BBC-BASIC/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/A+B b/Lang/BBC-BASIC/A+B new file mode 120000 index 0000000000..7385341f41 --- /dev/null +++ b/Lang/BBC-BASIC/A+B @@ -0,0 +1 @@ +../../Task/A+B/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Abstract-type b/Lang/BBC-BASIC/Abstract-type new file mode 120000 index 0000000000..4ac314de98 --- /dev/null +++ b/Lang/BBC-BASIC/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Accumulator-factory b/Lang/BBC-BASIC/Accumulator-factory new file mode 120000 index 0000000000..b427b7e631 --- /dev/null +++ b/Lang/BBC-BASIC/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Ackermann-function b/Lang/BBC-BASIC/Ackermann-function new file mode 120000 index 0000000000..a246751d26 --- /dev/null +++ b/Lang/BBC-BASIC/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Active-object b/Lang/BBC-BASIC/Active-object new file mode 120000 index 0000000000..ab4a0190c4 --- /dev/null +++ b/Lang/BBC-BASIC/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Add-a-variable-to-a-class-instance-at-runtime b/Lang/BBC-BASIC/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..4916247521 --- /dev/null +++ b/Lang/BBC-BASIC/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Address-of-a-variable b/Lang/BBC-BASIC/Address-of-a-variable new file mode 120000 index 0000000000..bc198a5479 --- /dev/null +++ b/Lang/BBC-BASIC/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Align-columns b/Lang/BBC-BASIC/Align-columns new file mode 120000 index 0000000000..ce45a0825b --- /dev/null +++ b/Lang/BBC-BASIC/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Anagrams b/Lang/BBC-BASIC/Anagrams new file mode 120000 index 0000000000..5f4ef852be --- /dev/null +++ b/Lang/BBC-BASIC/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Anagrams-Deranged-anagrams b/Lang/BBC-BASIC/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..ff170febed --- /dev/null +++ b/Lang/BBC-BASIC/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Animate-a-pendulum b/Lang/BBC-BASIC/Animate-a-pendulum new file mode 120000 index 0000000000..fb8433cb84 --- /dev/null +++ b/Lang/BBC-BASIC/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Animation b/Lang/BBC-BASIC/Animation new file mode 120000 index 0000000000..d933afdb92 --- /dev/null +++ b/Lang/BBC-BASIC/Animation @@ -0,0 +1 @@ +../../Task/Animation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Anonymous-recursion b/Lang/BBC-BASIC/Anonymous-recursion new file mode 120000 index 0000000000..a7356b5fcf --- /dev/null +++ b/Lang/BBC-BASIC/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Apply-a-callback-to-an-array b/Lang/BBC-BASIC/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..74c8a00fb5 --- /dev/null +++ b/Lang/BBC-BASIC/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arithmetic-Complex b/Lang/BBC-BASIC/Arithmetic-Complex new file mode 120000 index 0000000000..7a4f469232 --- /dev/null +++ b/Lang/BBC-BASIC/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arithmetic-Integer b/Lang/BBC-BASIC/Arithmetic-Integer new file mode 120000 index 0000000000..a01ca3b3a6 --- /dev/null +++ b/Lang/BBC-BASIC/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arithmetic-Rational b/Lang/BBC-BASIC/Arithmetic-Rational new file mode 120000 index 0000000000..7cce2dab70 --- /dev/null +++ b/Lang/BBC-BASIC/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arithmetic-evaluation b/Lang/BBC-BASIC/Arithmetic-evaluation new file mode 120000 index 0000000000..2890c28df6 --- /dev/null +++ b/Lang/BBC-BASIC/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arithmetic-geometric-mean b/Lang/BBC-BASIC/Arithmetic-geometric-mean new file mode 120000 index 0000000000..eab22b5fcc --- /dev/null +++ b/Lang/BBC-BASIC/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Array-concatenation b/Lang/BBC-BASIC/Array-concatenation new file mode 120000 index 0000000000..c5df8c5df6 --- /dev/null +++ b/Lang/BBC-BASIC/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arrays b/Lang/BBC-BASIC/Arrays new file mode 120000 index 0000000000..dff61fac09 --- /dev/null +++ b/Lang/BBC-BASIC/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Assertions b/Lang/BBC-BASIC/Assertions new file mode 120000 index 0000000000..31075d706a --- /dev/null +++ b/Lang/BBC-BASIC/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Associative-array-Creation b/Lang/BBC-BASIC/Associative-array-Creation new file mode 120000 index 0000000000..a97509f1f7 --- /dev/null +++ b/Lang/BBC-BASIC/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Associative-array-Iteration b/Lang/BBC-BASIC/Associative-array-Iteration new file mode 120000 index 0000000000..0f63907ac3 --- /dev/null +++ b/Lang/BBC-BASIC/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Atomic-updates b/Lang/BBC-BASIC/Atomic-updates new file mode 120000 index 0000000000..dec922ee5a --- /dev/null +++ b/Lang/BBC-BASIC/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Average-loop-length b/Lang/BBC-BASIC/Average-loop-length new file mode 120000 index 0000000000..30f1119044 --- /dev/null +++ b/Lang/BBC-BASIC/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Arithmetic-mean b/Lang/BBC-BASIC/Averages-Arithmetic-mean new file mode 120000 index 0000000000..6f60e5356c --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Mean-angle b/Lang/BBC-BASIC/Averages-Mean-angle new file mode 120000 index 0000000000..551d9a0487 --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Median b/Lang/BBC-BASIC/Averages-Median new file mode 120000 index 0000000000..1a486c8a31 --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Mode b/Lang/BBC-BASIC/Averages-Mode new file mode 120000 index 0000000000..6a798bde77 --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Pythagorean-means b/Lang/BBC-BASIC/Averages-Pythagorean-means new file mode 120000 index 0000000000..4e3e7fca8e --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Root-mean-square b/Lang/BBC-BASIC/Averages-Root-mean-square new file mode 120000 index 0000000000..0157d56453 --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Averages-Simple-moving-average b/Lang/BBC-BASIC/Averages-Simple-moving-average new file mode 120000 index 0000000000..eb74453a28 --- /dev/null +++ b/Lang/BBC-BASIC/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Balanced-brackets b/Lang/BBC-BASIC/Balanced-brackets new file mode 120000 index 0000000000..50c94052fe --- /dev/null +++ b/Lang/BBC-BASIC/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Best-shuffle b/Lang/BBC-BASIC/Best-shuffle new file mode 120000 index 0000000000..561a4e2ecf --- /dev/null +++ b/Lang/BBC-BASIC/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Binary-search b/Lang/BBC-BASIC/Binary-search new file mode 120000 index 0000000000..625528b589 --- /dev/null +++ b/Lang/BBC-BASIC/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Binary-strings b/Lang/BBC-BASIC/Binary-strings new file mode 120000 index 0000000000..11af695bcd --- /dev/null +++ b/Lang/BBC-BASIC/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap b/Lang/BBC-BASIC/Bitmap new file mode 120000 index 0000000000..8ed83e2a3b --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-B-zier-curves-Cubic b/Lang/BBC-BASIC/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..2fd02f72ba --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-B-zier-curves-Quadratic b/Lang/BBC-BASIC/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..c0ddf85849 --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-Bresenhams-line-algorithm b/Lang/BBC-BASIC/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..c06ef77bef --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-Flood-fill b/Lang/BBC-BASIC/Bitmap-Flood-fill new file mode 120000 index 0000000000..5b0550fbc3 --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-Histogram b/Lang/BBC-BASIC/Bitmap-Histogram new file mode 120000 index 0000000000..da8cf0a74f --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-Midpoint-circle-algorithm b/Lang/BBC-BASIC/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..c690e4f02b --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-Read-a-PPM-file b/Lang/BBC-BASIC/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..fbdef0c626 --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitmap-Write-a-PPM-file b/Lang/BBC-BASIC/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..c0df265724 --- /dev/null +++ b/Lang/BBC-BASIC/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitwise-IO b/Lang/BBC-BASIC/Bitwise-IO new file mode 120000 index 0000000000..b1779f7220 --- /dev/null +++ b/Lang/BBC-BASIC/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bitwise-operations b/Lang/BBC-BASIC/Bitwise-operations new file mode 120000 index 0000000000..20687d13ab --- /dev/null +++ b/Lang/BBC-BASIC/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Boolean-values b/Lang/BBC-BASIC/Boolean-values new file mode 120000 index 0000000000..3db38a1d4a --- /dev/null +++ b/Lang/BBC-BASIC/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Box-the-compass b/Lang/BBC-BASIC/Box-the-compass new file mode 120000 index 0000000000..65b7e6a960 --- /dev/null +++ b/Lang/BBC-BASIC/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bulls-and-cows b/Lang/BBC-BASIC/Bulls-and-cows new file mode 120000 index 0000000000..915f5fda15 --- /dev/null +++ b/Lang/BBC-BASIC/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bulls-and-cows-Player b/Lang/BBC-BASIC/Bulls-and-cows-Player new file mode 120000 index 0000000000..b2837e4597 --- /dev/null +++ b/Lang/BBC-BASIC/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Caesar-cipher b/Lang/BBC-BASIC/Caesar-cipher new file mode 120000 index 0000000000..c86cdd127b --- /dev/null +++ b/Lang/BBC-BASIC/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Calendar b/Lang/BBC-BASIC/Calendar new file mode 120000 index 0000000000..86bb908dfe --- /dev/null +++ b/Lang/BBC-BASIC/Calendar @@ -0,0 +1 @@ +../../Task/Calendar/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Check-that-file-exists b/Lang/BBC-BASIC/Check-that-file-exists new file mode 120000 index 0000000000..6024136e21 --- /dev/null +++ b/Lang/BBC-BASIC/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Checkpoint-synchronization b/Lang/BBC-BASIC/Checkpoint-synchronization new file mode 120000 index 0000000000..1bdc6365f2 --- /dev/null +++ b/Lang/BBC-BASIC/Checkpoint-synchronization @@ -0,0 +1 @@ +../../Task/Checkpoint-synchronization/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Classes b/Lang/BBC-BASIC/Classes new file mode 120000 index 0000000000..2042b68e49 --- /dev/null +++ b/Lang/BBC-BASIC/Classes @@ -0,0 +1 @@ +../../Task/Classes/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Closest-pair-problem b/Lang/BBC-BASIC/Closest-pair-problem new file mode 120000 index 0000000000..dc47866487 --- /dev/null +++ b/Lang/BBC-BASIC/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Collections b/Lang/BBC-BASIC/Collections new file mode 120000 index 0000000000..b3b5f12cc3 --- /dev/null +++ b/Lang/BBC-BASIC/Collections @@ -0,0 +1 @@ +../../Task/Collections/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Color-of-a-screen-pixel b/Lang/BBC-BASIC/Color-of-a-screen-pixel new file mode 120000 index 0000000000..47fa67ca8d --- /dev/null +++ b/Lang/BBC-BASIC/Color-of-a-screen-pixel @@ -0,0 +1 @@ +../../Task/Color-of-a-screen-pixel/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Comments b/Lang/BBC-BASIC/Comments new file mode 120000 index 0000000000..64913a2943 --- /dev/null +++ b/Lang/BBC-BASIC/Comments @@ -0,0 +1 @@ +../../Task/Comments/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Delete-a-file b/Lang/BBC-BASIC/Delete-a-file new file mode 120000 index 0000000000..d868bbb5b4 --- /dev/null +++ b/Lang/BBC-BASIC/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Detect-division-by-zero b/Lang/BBC-BASIC/Detect-division-by-zero new file mode 120000 index 0000000000..2241d2b34c --- /dev/null +++ b/Lang/BBC-BASIC/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Determine-if-a-string-is-numeric b/Lang/BBC-BASIC/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..5669398101 --- /dev/null +++ b/Lang/BBC-BASIC/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/FizzBuzz b/Lang/BBC-BASIC/FizzBuzz new file mode 120000 index 0000000000..45e69c96cb --- /dev/null +++ b/Lang/BBC-BASIC/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Forest-fire b/Lang/BBC-BASIC/Forest-fire new file mode 120000 index 0000000000..c37228b302 --- /dev/null +++ b/Lang/BBC-BASIC/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Infinity b/Lang/BBC-BASIC/Infinity new file mode 120000 index 0000000000..b8d839566a --- /dev/null +++ b/Lang/BBC-BASIC/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Knuth-shuffle b/Lang/BBC-BASIC/Knuth-shuffle new file mode 120000 index 0000000000..9930fdec04 --- /dev/null +++ b/Lang/BBC-BASIC/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Narcissist b/Lang/BBC-BASIC/Narcissist new file mode 120000 index 0000000000..46f1350750 --- /dev/null +++ b/Lang/BBC-BASIC/Narcissist @@ -0,0 +1 @@ +../../Task/Narcissist/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Ordered-words b/Lang/BBC-BASIC/Ordered-words new file mode 120000 index 0000000000..4c48f91481 --- /dev/null +++ b/Lang/BBC-BASIC/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pi b/Lang/BBC-BASIC/Pi new file mode 120000 index 0000000000..e4a7ce9c87 --- /dev/null +++ b/Lang/BBC-BASIC/Pi @@ -0,0 +1 @@ +../../Task/Pi/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Quine b/Lang/BBC-BASIC/Quine new file mode 120000 index 0000000000..194e762d52 --- /dev/null +++ b/Lang/BBC-BASIC/Quine @@ -0,0 +1 @@ +../../Task/Quine/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Search-a-list b/Lang/BBC-BASIC/Search-a-list new file mode 120000 index 0000000000..a721b912b4 --- /dev/null +++ b/Lang/BBC-BASIC/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/BBC-BASIC \ No newline at end of file diff --git a/Lang/BCPL/0DESCRIPTION b/Lang/BCPL/0DESCRIPTION new file mode 100644 index 0000000000..584a4edd2a --- /dev/null +++ b/Lang/BCPL/0DESCRIPTION @@ -0,0 +1,12 @@ +{{language +|site=http://www.cl.cam.ac.uk/users/mr10 +|hopl id=374 +}} +BCPL is a typeless ancestor of [[C]]. + +BCPL was first implemented at MIT by Martin Richards early in 1967. It was strongly influenced by CPL which was a general purpose language developed jointly at Cambridge and London Universities between 1962 and 1966. + +BCPL is a very simple typeless language in which all values are of the same size, typically a 32-bit word. It +has a compiler freely available via http://www.cl.cam.ac.uk/users/mr10. This web page also contains several link to other items including Cintpos an interpretive implementation of the Tripos Portable Operating System and a manual covering both BCPL and Cintpos. + +BCPL and Cintpos are still undergoing slow development. \ No newline at end of file diff --git a/Lang/BCPL/Ackermann-function b/Lang/BCPL/Ackermann-function new file mode 120000 index 0000000000..39418e300a --- /dev/null +++ b/Lang/BCPL/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/BCPL \ No newline at end of file diff --git a/Lang/Batch-File/0DESCRIPTION b/Lang/Batch-File/0DESCRIPTION new file mode 100644 index 0000000000..bea7157500 --- /dev/null +++ b/Lang/Batch-File/0DESCRIPTION @@ -0,0 +1 @@ +{{language|Batch File}}'''Batch files''' are the scripting languages for [[Microsoft]] command line shells, such as [[MS-DOS]], COMMAND.EXE, and CMD.EXE. They typically have either the .BAT or .CMD extension. \ No newline at end of file diff --git a/Lang/Batch-File/100-doors b/Lang/Batch-File/100-doors new file mode 120000 index 0000000000..a04f3b7091 --- /dev/null +++ b/Lang/Batch-File/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/99-Bottles-of-Beer b/Lang/Batch-File/99-Bottles-of-Beer new file mode 120000 index 0000000000..a6102c729d --- /dev/null +++ b/Lang/Batch-File/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/A+B b/Lang/Batch-File/A+B new file mode 120000 index 0000000000..3ffdc5e5e4 --- /dev/null +++ b/Lang/Batch-File/A+B @@ -0,0 +1 @@ +../../Task/A+B/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Ackermann-function b/Lang/Batch-File/Ackermann-function new file mode 120000 index 0000000000..889c1cd3c7 --- /dev/null +++ b/Lang/Batch-File/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Arithmetic-Integer b/Lang/Batch-File/Arithmetic-Integer new file mode 120000 index 0000000000..0cbfb554c1 --- /dev/null +++ b/Lang/Batch-File/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Arrays b/Lang/Batch-File/Arrays new file mode 120000 index 0000000000..9faaf471b9 --- /dev/null +++ b/Lang/Batch-File/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Associative-array-Creation b/Lang/Batch-File/Associative-array-Creation new file mode 120000 index 0000000000..03f25370ef --- /dev/null +++ b/Lang/Batch-File/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Bitwise-operations b/Lang/Batch-File/Bitwise-operations new file mode 120000 index 0000000000..e7ee4a9e35 --- /dev/null +++ b/Lang/Batch-File/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Check-that-file-exists b/Lang/Batch-File/Check-that-file-exists new file mode 120000 index 0000000000..680ac7ed08 --- /dev/null +++ b/Lang/Batch-File/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Comments b/Lang/Batch-File/Comments new file mode 120000 index 0000000000..30b576de21 --- /dev/null +++ b/Lang/Batch-File/Comments @@ -0,0 +1 @@ +../../Task/Comments/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Delete-a-file b/Lang/Batch-File/Delete-a-file new file mode 120000 index 0000000000..29e1f9ebd8 --- /dev/null +++ b/Lang/Batch-File/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/FizzBuzz b/Lang/Batch-File/FizzBuzz new file mode 120000 index 0000000000..415794ac13 --- /dev/null +++ b/Lang/Batch-File/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Quine b/Lang/Batch-File/Quine new file mode 120000 index 0000000000..32a6297b0c --- /dev/null +++ b/Lang/Batch-File/Quine @@ -0,0 +1 @@ +../../Task/Quine/Batch-File \ No newline at end of file diff --git a/Lang/Bc/0DESCRIPTION b/Lang/Bc/0DESCRIPTION new file mode 100644 index 0000000000..d20347e1f6 --- /dev/null +++ b/Lang/Bc/0DESCRIPTION @@ -0,0 +1,53 @@ +{{language +|exec=interpreted +|checking=static +|hopl id=1854 +}} + +'''bc''' is the standard calculator for [[Unix]] systems. bc boasts unlimited precision, to handle numbers with very many digits. With the bc language, you can write programs that perform numeric calculations and print the results. (See also [[wp:Bc programming language|Bc programming language]] on Wikipedia.) + +bc has an interactive mode, which is convenient for brief calculations. + + $ '''bc''' + '''2 + 3''' + 5 + '''2 ^ 200''' + 1606938044258990275541962092341162602522202993782792835301376 + '''i = -5''' + '''3 - i * 4''' + 23 + '''obase = 2''' + '''i''' + -101 + '''ibase = 16''' + '''FE80''' + 1111111010000000 + +Division and sqrt will not give an infinite number of digits. The special variable scale controls when to stop. + + $ '''bc''' + '''65.9 / 3''' + 21 + '''scale = 6''' + '''65.9 / 3''' + 21.966666 + '''sqrt(2)''' + 1.414213 + '''scale = 60''' + '''sqrt(2)''' + 1.414213562373095048801688724209698078569671875376948073176679 + +bc language resembles [[C|C language]]: bc has most of the same operators and control structures ('if', 'while', 'for'). Expressions print themselves, unless they are assignments. The newline is a statement separator, like the semicolon. + +bc has excellent numeric operations, but is a poor language. The original bc, the "Bell Calculator" of Unix V7, translated the program to [[dc]] and inherited the limitations of [[dc]]. + +* Names of variables, and custom functions, may have only one letter. +* There is no 'else' branch of an 'if' statement. +* Relational operators (== <= => != < >) only work in the condition of an 'if', 'while' or 'for' statement. +* There are no boolean operators (! && ||). + +Some newer implementations, like [[GNU bc]] and [[OpenBSD bc]], discard these silly limitations, but users can still feel their effects. OpenBSD says, "a = b < c is interpreted as "(a = b) < c, which is probably not what the programmer intended," and "!a < b is interpreted as !(a < b)". + +bc can only print a string, and has no other string operations, so bc cannot do tasks like [[reverse a string]]. bc has no way to read user input, except to go to interactive mode after loading a program. + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Beta/0DESCRIPTION b/Lang/Beta/0DESCRIPTION new file mode 100644 index 0000000000..f4492f4be8 --- /dev/null +++ b/Lang/Beta/0DESCRIPTION @@ -0,0 +1,5 @@ +{{stub}} +{{language +|site=http://www.daimi.au.dk/~beta/ +}} +BETA is a modern language in the Simula tradition. The resulting language is smaller than Simula in spite of being considerably more expressive. BETA is a strongly typed language like [[Simula]], [[Eiffel]] and [[C++]], with most type checking being carried out at compile-time. It is well known that it is not possible to obtain all type checking at compile time without sacrificing the expressiveness of the language. BETA has optimum balance between compile-time type checking and run-time type checking. \ No newline at end of file diff --git a/Lang/Biferno/0DESCRIPTION b/Lang/Biferno/0DESCRIPTION new file mode 100644 index 0000000000..853a9691c3 --- /dev/null +++ b/Lang/Biferno/0DESCRIPTION @@ -0,0 +1,14 @@ +{{stub}}{{language}} + +Biferno is a new generation, Cross Platform Web Scripting Language that allows developers the rapid implementation of dynamic Web applications and of Web sites that offer a high degree of user interactivity. + +Biferno is an Open Source Project distributed under the GNU GENERAL PUBLIC LICENSE, its current version is 1.6.0. + +Biferno is a Web server add-on module that allows dynamic generation of HTML pages. The result of the processing of the Biferno code by the server determines the page content. A Biferno script is therefore a server-side script, i.e. the Web server is tasked with code processing. + +Biferno is currently implemented as an interpreted language. + +Biferno is also a "HTML-embedded" language. Scripts can be written in pure Biferno language, but can also contain HTML code segments between Biferno code blocks. +The Biferno code is always delimited by special tags that allow separation from the rest of the code (HTML or whatever). + +http://www.tabasoft.it/biferno/ \ No newline at end of file diff --git a/Lang/Blast/0DESCRIPTION b/Lang/Blast/0DESCRIPTION new file mode 100644 index 0000000000..8ba731d5b3 --- /dev/null +++ b/Lang/Blast/0DESCRIPTION @@ -0,0 +1,4 @@ +{{stub}}{{language|Blast +|site=http://www.opencomm.co.uk/}} + +'''Blast''' is a cross platorm communication scripting language that can be used to perform data transfers between two hosts. \ No newline at end of file diff --git a/Lang/Blast/Comments b/Lang/Blast/Comments new file mode 120000 index 0000000000..04e16add05 --- /dev/null +++ b/Lang/Blast/Comments @@ -0,0 +1 @@ +../../Task/Comments/Blast \ No newline at end of file diff --git a/Lang/BlitzMax/0DESCRIPTION b/Lang/BlitzMax/0DESCRIPTION new file mode 100644 index 0000000000..6c98eff6f6 --- /dev/null +++ b/Lang/BlitzMax/0DESCRIPTION @@ -0,0 +1,22 @@ +{{language +|strength=weak +|checking=static +|gc=yes}}'''BlitzMax'''
+BlitzMax Paradigm imperative, object-oriented, modular, reflective
+Appeared in 2004
+Designed by Mark Sibly
+Developer Blitz Research Ltd.
+Stable release 1.42 (March 31, 2011; 3 months ago)
+Typing discipline Static, Weak
+Influenced by BlitzBasic
+OS Microsoft Windows, Mac OS X, Linux
+{{language programming paradigm|imperative}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|reflective}} +The first BlitzMax compiler was released in December 2004 for [[Mac OS X]]. This made it the first Blitz dialect that could be compiled on *nix platforms. Compilers for [[Microsoft]] [[Windows]] and [[Linux]] were subsequently released in May 2005. BlitzMax brought the largest change of language structure to the modern range of Blitz products by extending the type system to include object-oriented concepts and modifying the graphics API to better suit [[OpenGL]]. BlitzMax was also the first of the Blitz languages to represent strings internally using UCS2, allowing native-support for strings literals composed of non-ASCII characters. + +BlitzMax's platform-agnostic command-set allows developers to compile and run source code on multiple platforms. However the official compiler and build chain will only generate binaries for the platform that it is executing on. Unofficially, users have been able to get Linux and Mac OS X to cross-compile to the Windows platform. + +BlitzMax is also the first modular version of the Blitz languages, improving the extensibility of the command-set. In addition, all of the standard modules shipped with the compiler are open-source and so can be tweaked and recompiled by the programmer if necessary. The official BlitzMax cross-platform GUI module (known as MaxGUI) allows developers to write GUI interfaces for their applications on Linux (FLTK), Mac ([[Cocoa]]) and Windows. Various user-contributed modules extend the use of the language by wrapping such libraries as wxWidgets, Cairo, Fontconfig as well as a selection of database modules. There are also a selection of third-party 3D modules available namely MiniB3D - an open-source OpenGL engine which can be compiled and used on all 3 of BlitzMax's supported platforms. + +In October 2007, BlitzMax 1.26 was released which included the addition of a reflection module. BlitzMax 1.32 shipped new threading and Lua scripting modules and most of the standard library functions have been updated so that they are unicode friendly. \ No newline at end of file diff --git a/Lang/BlitzMax/100-doors b/Lang/BlitzMax/100-doors new file mode 120000 index 0000000000..3f76d473ba --- /dev/null +++ b/Lang/BlitzMax/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/BlitzMax \ No newline at end of file diff --git a/Lang/Boo/0DESCRIPTION b/Lang/Boo/0DESCRIPTION new file mode 100644 index 0000000000..fb11527d19 --- /dev/null +++ b/Lang/Boo/0DESCRIPTION @@ -0,0 +1,13 @@ +{{stub}} +{{language| +|exec=bytecode +|strength=strong +|safety=safe +|express=both +|checking=both +|gc=yes +|site=http://boo.codehaus.org/ +|LCT=yes}} +{{language programming paradigm|Object-oriented}} + +Boo is a new object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility. \ No newline at end of file diff --git a/Lang/Boo/FizzBuzz b/Lang/Boo/FizzBuzz new file mode 120000 index 0000000000..96b147e26b --- /dev/null +++ b/Lang/Boo/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Boo \ No newline at end of file diff --git a/Lang/Bori/0DESCRIPTION b/Lang/Bori/0DESCRIPTION new file mode 100644 index 0000000000..4f6c412eb6 --- /dev/null +++ b/Lang/Bori/0DESCRIPTION @@ -0,0 +1,12 @@ +{{language|Bori +|exec=bytecode +|safety=safe +|strength=strong +|express=explicit +|checking=static +|parampass=value +|gc=yes +|site=http://borilang.org/}} +Bori is a simple language that can be used for developing Windows or Android applications. + +Bori is developed by Sangdeuk Kim. \ No newline at end of file diff --git a/Lang/Brace/0DESCRIPTION b/Lang/Brace/0DESCRIPTION new file mode 100644 index 0000000000..df56264f54 --- /dev/null +++ b/Lang/Brace/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language +|site=http://sam.ai.ki/brace/ +}} +[http://sam.ai.ki/brace/ Brace] is a dialect of [[C]] that looks like [[Python]]. It has coroutines, hygenic macros, header generation, #! scripting and cached executables, libraries with graphics and sound, and many animated demos. It is a work in progress and most likely will not build on your system without some hacking, unless you are using Debian. Please check out the web page and contact the developer sam@ai.ki if you are interested in having a look at brace, or helping with its development. \ No newline at end of file diff --git a/Lang/Bracmat/0DESCRIPTION b/Lang/Bracmat/0DESCRIPTION new file mode 100644 index 0000000000..e5a937026c --- /dev/null +++ b/Lang/Bracmat/0DESCRIPTION @@ -0,0 +1,19 @@ +{{language +|exec=interpreted +|gc=yes +|programming paradigm=declarative +|programming paradigm=reflective +|parampass=value +|checking=dynamic +|compat=duck +|express=implicit +|strength=weak +|tags=bracmat +}} +Bracmat is an interpreted programming language that is developed by Bart Jongejan, starting in 1986. Originally it was designed as a Computer Algebra system, but it has shown its merits in natural language processing as well. Bracmat has been used in the field of General Relativity for the algebraic computation of Ricci tensors from given space-time metrics, for the implementation of a dialogue-manager in virtual world project that allowed a user to communicate with software agents in plain English and with gestures, for the analysis of texts in a "Controlled Language"-project and for automatic error correction of hundreds of [[HTML]] pages. Bracmat has also shown its utility in some real-world applications: for example to identify persons, companies etc. in pre-tagged texts that must be anonymised. The to date most advanced application of Bracmat is as workflow planner and executor. Instead of letting the user choose between software tools, which the user may not know very well, the planner asks the user to specify what kind of output she wants. With this information the planner computes all (not necessarily sequential) combinations of tools and their parameter settings that combine into workflows that are guaranteed to produce the specified output from the given input. The computed list is condensed into a short format that highlights the differences between the workflows for the user and leaves out all that is of less importance. + +Bracmat's strength is [[pattern matching]], in strings as well as in tree structures. + +Bracmat is inspired by [[SNOBOL4]] (pattern matching, success/failure), by [[Lisp]] (Bracmat programs are made of the same stuff as Bracmat data), by [[Prolog]] (backtracking) and a little bit by [[object-oriented]] languages. The first implementation was for an ARM based computer. The ARM processor's 4-bit condition code selector on every instruction were the inspiration for Bracmat's flags ~ [ ! !! ` @ % > < # / ? that can be set on any node in an expression. For example, the ! and ? flags turn a symbol into a variable. When flags are combined, care has been taken that the semantics of a combination of flags is close to a combination of the semantics of each flag. + +The Bracmat-interpreter is written in Standard [[C]] and can be compiled for many platforms, such as Epoc, [[Windows]], [[Mac OS]], [[Linux]] and [[Unix]]. The compiled code measures about 130 KB (statically linked), depending on the platform. The runtime is not very memory hungry, as compared to e.g. [[Java]]. \ No newline at end of file diff --git a/Lang/Bracmat/100-doors b/Lang/Bracmat/100-doors new file mode 120000 index 0000000000..3bef8226af --- /dev/null +++ b/Lang/Bracmat/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/24-game b/Lang/Bracmat/24-game new file mode 120000 index 0000000000..e3fceed589 --- /dev/null +++ b/Lang/Bracmat/24-game @@ -0,0 +1 @@ +../../Task/24-game/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/99-Bottles-of-Beer b/Lang/Bracmat/99-Bottles-of-Beer new file mode 120000 index 0000000000..bb06a67252 --- /dev/null +++ b/Lang/Bracmat/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/A+B b/Lang/Bracmat/A+B new file mode 120000 index 0000000000..5bd57f4f73 --- /dev/null +++ b/Lang/Bracmat/A+B @@ -0,0 +1 @@ +../../Task/A+B/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Ackermann-function b/Lang/Bracmat/Ackermann-function new file mode 120000 index 0000000000..19a78b0148 --- /dev/null +++ b/Lang/Bracmat/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Bracmat/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..f49e805bd7 --- /dev/null +++ b/Lang/Bracmat/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Anagrams b/Lang/Bracmat/Anagrams new file mode 120000 index 0000000000..e334219348 --- /dev/null +++ b/Lang/Bracmat/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Anagrams-Deranged-anagrams b/Lang/Bracmat/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..775a6c452c --- /dev/null +++ b/Lang/Bracmat/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Anonymous-recursion b/Lang/Bracmat/Anonymous-recursion new file mode 120000 index 0000000000..0a65b27283 --- /dev/null +++ b/Lang/Bracmat/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Arbitrary-precision-integers-(included) b/Lang/Bracmat/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..5edf79c35b --- /dev/null +++ b/Lang/Bracmat/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Averages-Arithmetic-mean b/Lang/Bracmat/Averages-Arithmetic-mean new file mode 120000 index 0000000000..3f38315834 --- /dev/null +++ b/Lang/Bracmat/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Averages-Median b/Lang/Bracmat/Averages-Median new file mode 120000 index 0000000000..9fb86548fc --- /dev/null +++ b/Lang/Bracmat/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Balanced-brackets b/Lang/Bracmat/Balanced-brackets new file mode 120000 index 0000000000..1ec84194b5 --- /dev/null +++ b/Lang/Bracmat/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Best-shuffle b/Lang/Bracmat/Best-shuffle new file mode 120000 index 0000000000..ed6442c46d --- /dev/null +++ b/Lang/Bracmat/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Determine-if-a-string-is-numeric b/Lang/Bracmat/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..f825629cba --- /dev/null +++ b/Lang/Bracmat/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/FizzBuzz b/Lang/Bracmat/FizzBuzz new file mode 120000 index 0000000000..e4430eb395 --- /dev/null +++ b/Lang/Bracmat/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Ordered-words b/Lang/Bracmat/Ordered-words new file mode 120000 index 0000000000..14338ef9db --- /dev/null +++ b/Lang/Bracmat/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Pi b/Lang/Bracmat/Pi new file mode 120000 index 0000000000..47b8221526 --- /dev/null +++ b/Lang/Bracmat/Pi @@ -0,0 +1 @@ +../../Task/Pi/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Quine b/Lang/Bracmat/Quine new file mode 120000 index 0000000000..406793e6de --- /dev/null +++ b/Lang/Bracmat/Quine @@ -0,0 +1 @@ +../../Task/Quine/Bracmat \ No newline at end of file diff --git a/Lang/Brainf---/0DESCRIPTION b/Lang/Brainf---/0DESCRIPTION new file mode 100644 index 0000000000..2c650ee8a6 --- /dev/null +++ b/Lang/Brainf---/0DESCRIPTION @@ -0,0 +1,50 @@ +{{language|Brainf***|bnf=http://ninh.nl/blog/2008/10/25/brainfck-birds-of-a-feather-session-take-2/}}Also known as '''Brainfuck''', but identified as '''Brainf***''' for reasons described [[Rosetta Code:Brainf***|here]]. Created by Urban Müller in 1993 in an attempt to create the world's smallest Turing-complete compiler. It is noted as an [[:Category:Esoteric_Languages|esoteric programming language]], as it is not ordinarily used for applications development, but it also noted as being a minimalist language. + +The construct for the language is similar to a [[wp:Turing Machine|Turing Machine]]. The commands themselves act on an array or "tape" (usually a byte or integer array and usually "infinite" on one or both ends) and a pointer to a position in that array. The complete specification for the language can be summed up with the following eight symbols: + +{| class="wikitable" +!align="center"|Character +!align="left" |Meaning +|- +|style="text-align:center"|> +||increment the pointer (to point to the next cell to the right). +|- +|style="text-align:center"|< +||decrement the pointer (to point to the next cell to the left). +|- +|style="text-align:center"|+ +||increment (increase by one) the byte at the pointer. +|- +|style="text-align:center"|- +||decrement (decrease by one) the byte at the pointer. +|- +|style="text-align:center"|. +||output the value of the byte at the pointer (usually interpreted to a character). +|- +|style="text-align:center"|, +||accept one byte of input (usually interpreted from a character), storing its value in the byte at the pointer. +|- +|style="text-align:center"|[ +||jump forward to the command after the corresponding ] if the byte at the pointer is zero. +|- +|style="text-align:center"|] +||jump back to the command after the corresponding [ if the byte at the pointer is nonzero. +|} + +Alternatively, the ] command may instead be translated as an unconditional jump '''to''' the corresponding [ command, or vice versa; programs will behave the same but will run more slowly. + +All other symbols, including traditional whitespace characters, are interpreted as comments. + +Due to this minimal instruction set, Brainf*** is used as an introduction to compilers and has even been successfully implemented as a microprocessor core and the foundation to an operating system using a slightly extended syntax for output. + +==See also== +* [[RCBF]] - BF interpreters as a Rosetta Code task + +==Citations== + +* [[eso:Brainfuck|Esoteric languages wiki entry]] +*[[wp:Brainfuck|Wikipedia entry on Brainf***]] +* [http://dmoz.org/Computers/Programming/Languages/Brainfuck/ DMOZ Brainf*** category] +* [http://www.iwriteiam.nl/Ha_BF.html Brainf*** tutorial] + +[[Category:Esoteric_Languages]] \ No newline at end of file diff --git a/Lang/Brainf---/99-Bottles-of-Beer b/Lang/Brainf---/99-Bottles-of-Beer new file mode 120000 index 0000000000..2ae380be76 --- /dev/null +++ b/Lang/Brainf---/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/A+B b/Lang/Brainf---/A+B new file mode 120000 index 0000000000..70abe6414c --- /dev/null +++ b/Lang/Brainf---/A+B @@ -0,0 +1 @@ +../../Task/A+B/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Averages-Arithmetic-mean b/Lang/Brainf---/Averages-Arithmetic-mean new file mode 120000 index 0000000000..cb841c05d8 --- /dev/null +++ b/Lang/Brainf---/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Comments b/Lang/Brainf---/Comments new file mode 120000 index 0000000000..8c26a2d3ef --- /dev/null +++ b/Lang/Brainf---/Comments @@ -0,0 +1 @@ +../../Task/Comments/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/FizzBuzz b/Lang/Brainf---/FizzBuzz new file mode 120000 index 0000000000..a916b13259 --- /dev/null +++ b/Lang/Brainf---/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Quine b/Lang/Brainf---/Quine new file mode 120000 index 0000000000..b05aab3a13 --- /dev/null +++ b/Lang/Brainf---/Quine @@ -0,0 +1 @@ +../../Task/Quine/Brainf--- \ No newline at end of file diff --git a/Lang/Brat/0DESCRIPTION b/Lang/Brat/0DESCRIPTION new file mode 100644 index 0000000000..143daefae0 --- /dev/null +++ b/Lang/Brat/0DESCRIPTION @@ -0,0 +1,15 @@ +{{language +|exec=bytecode +|express=implicit +|checking=dynamic +|gc=yes +|site=http://brat-lang.org +}} +{{language programming paradigm|Dynamic}} +{{language programming paradigm|Object-oriented}} + +Brat is a little language which tries to let you do what you want to do, because it knows no one is the boss of you. While influenced by [[Ruby]] in many ways, it accidentally resembles [[Javascript]]. The language design attempts to avoid "special cases" as much as possible, and therefore has no keywords and very few special symbols. + +In Brat, everything is either an object or a function, and all functions are closures. Objects are essentially just collections of functions which can have inheritance relationships with other objects. The object system in Brat uses a prototyping approach, so new objects are always created as children of some existing object. Functions in Brat are first-class values which can be passed around like any other value. + +Brat is also a very eager language. The only way to delay code evaluation is to enclose it in a function. Any use of a variable containing a function is assumed to be calling the function. \ No newline at end of file diff --git a/Lang/Brat/99-Bottles-of-Beer b/Lang/Brat/99-Bottles-of-Beer new file mode 120000 index 0000000000..a38e6fdf84 --- /dev/null +++ b/Lang/Brat/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Brat \ No newline at end of file diff --git a/Lang/Brat/A+B b/Lang/Brat/A+B new file mode 120000 index 0000000000..af235f9125 --- /dev/null +++ b/Lang/Brat/A+B @@ -0,0 +1 @@ +../../Task/A+B/Brat \ No newline at end of file diff --git a/Lang/Brat/Accumulator-factory b/Lang/Brat/Accumulator-factory new file mode 120000 index 0000000000..358027fb06 --- /dev/null +++ b/Lang/Brat/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Brat \ No newline at end of file diff --git a/Lang/Brat/Ackermann-function b/Lang/Brat/Ackermann-function new file mode 120000 index 0000000000..1cd051fdf7 --- /dev/null +++ b/Lang/Brat/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Brat \ No newline at end of file diff --git a/Lang/Brat/Apply-a-callback-to-an-array b/Lang/Brat/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..552018969c --- /dev/null +++ b/Lang/Brat/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Brat \ No newline at end of file diff --git a/Lang/Brat/Arithmetic-Integer b/Lang/Brat/Arithmetic-Integer new file mode 120000 index 0000000000..81a2517317 --- /dev/null +++ b/Lang/Brat/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Brat \ No newline at end of file diff --git a/Lang/Brat/Assertions b/Lang/Brat/Assertions new file mode 120000 index 0000000000..584cdb04c8 --- /dev/null +++ b/Lang/Brat/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Brat \ No newline at end of file diff --git a/Lang/Brat/Associative-array-Creation b/Lang/Brat/Associative-array-Creation new file mode 120000 index 0000000000..e5a39963bf --- /dev/null +++ b/Lang/Brat/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Brat \ No newline at end of file diff --git a/Lang/Brat/Associative-array-Iteration b/Lang/Brat/Associative-array-Iteration new file mode 120000 index 0000000000..01383f5388 --- /dev/null +++ b/Lang/Brat/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Brat \ No newline at end of file diff --git a/Lang/Brat/Averages-Arithmetic-mean b/Lang/Brat/Averages-Arithmetic-mean new file mode 120000 index 0000000000..2a3611ac2a --- /dev/null +++ b/Lang/Brat/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Brat \ No newline at end of file diff --git a/Lang/Brat/Balanced-brackets b/Lang/Brat/Balanced-brackets new file mode 120000 index 0000000000..8a3db38ff2 --- /dev/null +++ b/Lang/Brat/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Brat \ No newline at end of file diff --git a/Lang/Brat/Binary-search b/Lang/Brat/Binary-search new file mode 120000 index 0000000000..82c6e6392f --- /dev/null +++ b/Lang/Brat/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Brat \ No newline at end of file diff --git a/Lang/Brat/Bulls-and-cows b/Lang/Brat/Bulls-and-cows new file mode 120000 index 0000000000..cdaee99b41 --- /dev/null +++ b/Lang/Brat/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Brat \ No newline at end of file diff --git a/Lang/Brat/Comments b/Lang/Brat/Comments new file mode 120000 index 0000000000..da281fff49 --- /dev/null +++ b/Lang/Brat/Comments @@ -0,0 +1 @@ +../../Task/Comments/Brat \ No newline at end of file diff --git a/Lang/Brat/FizzBuzz b/Lang/Brat/FizzBuzz new file mode 120000 index 0000000000..52c819858b --- /dev/null +++ b/Lang/Brat/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Brat \ No newline at end of file diff --git a/Lang/Brat/Knuth-shuffle b/Lang/Brat/Knuth-shuffle new file mode 120000 index 0000000000..535e47e36f --- /dev/null +++ b/Lang/Brat/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Brat \ No newline at end of file diff --git a/Lang/Brlcad/0DESCRIPTION b/Lang/Brlcad/0DESCRIPTION new file mode 100644 index 0000000000..1f3b9c8b88 --- /dev/null +++ b/Lang/Brlcad/0DESCRIPTION @@ -0,0 +1,7 @@ +{{stub}}{{language|BRL-CAD +|site=http://www.brlcad.org/}} + +The brlcad language is the scripting language used by the mged geometry editor shell. + + +[[Category:Constructive Solid Geometry]] \ No newline at end of file diff --git a/Lang/Brlcad/Comments b/Lang/Brlcad/Comments new file mode 120000 index 0000000000..c292ed11fc --- /dev/null +++ b/Lang/Brlcad/Comments @@ -0,0 +1 @@ +../../Task/Comments/Brlcad \ No newline at end of file diff --git a/Lang/Brlcad/Death-Star b/Lang/Brlcad/Death-Star new file mode 120000 index 0000000000..8a24271564 --- /dev/null +++ b/Lang/Brlcad/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/Brlcad \ No newline at end of file diff --git a/Lang/Burlesque/0DESCRIPTION b/Lang/Burlesque/0DESCRIPTION new file mode 100644 index 0000000000..f4c2e90e61 --- /dev/null +++ b/Lang/Burlesque/0DESCRIPTION @@ -0,0 +1,28 @@ +{{language|Burlesque +|exec=interpreted +|site=http://mroman.ch/burlesque +|checking=dynamic +}} + +'The Burlesque Programming Language' as a stack-based, dynamic typed, concatenative, lazy and esoteric programming language developed by +Roman Müntener since 2012. It was designed to write short and compact code for simple problems. The language specification does not specify +I/O support but the official interpreter pushes stdin on program start and prints remaining elements on the stack on program termination. Other +than that there are no I/O capabilities. Due to it being lazy it supports stuff like infinite lists (although the Burlesque term for list is block). +It does not allow random stack access directly however methods have been found to achieve that. Since Version 1.7.0 there is a hidden state feature which +allows to hide elements at the bottom of the stack and load it from there. Burlesque's main advantage is its rich set of builtins and implicit loops. +(There is only a while loop, but functions like map/reduce/filter obviously loop over lists implicit. Therefore, while loops are rarely used). Burlesque +is turing-complete. A brainfuck interpreter: + + +".""X"r~"-""\/^^{vvvv}c!!!-.256.%{vvvv}c!sa\/"r~"+""\/^^{vvvv}c!!!+. +256.%{vvvv}c!sa\/"r~"[""{"r~"]""}{\/^^{vvvv}c!!!}w!"r~">""+."r~"<"" +-."r~"X""\/^^{vvvv}c!!!L[+]\/+]\/+]^^3\/.+1RAp^\/+]\/[-1RA^^-]\/[-\/ +"r~"\'\'1 128r@{vv0}m[0"\/.+pse!vvvv<-sh + + + +You might also want to read the article on [[eso:Burlesque|esowiki]]. + +{{language programming paradigm|concatenative}} + +[[Category:Esoteric Languages]] \ No newline at end of file diff --git a/Lang/Burlesque/100-doors b/Lang/Burlesque/100-doors new file mode 120000 index 0000000000..33e36c19f3 --- /dev/null +++ b/Lang/Burlesque/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/A+B b/Lang/Burlesque/A+B new file mode 120000 index 0000000000..eb3c21961d --- /dev/null +++ b/Lang/Burlesque/A+B @@ -0,0 +1 @@ +../../Task/A+B/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Array-concatenation b/Lang/Burlesque/Array-concatenation new file mode 120000 index 0000000000..23be4205cc --- /dev/null +++ b/Lang/Burlesque/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Averages-Arithmetic-mean b/Lang/Burlesque/Averages-Arithmetic-mean new file mode 120000 index 0000000000..bed98910a6 --- /dev/null +++ b/Lang/Burlesque/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Comments b/Lang/Burlesque/Comments new file mode 120000 index 0000000000..5653ad2634 --- /dev/null +++ b/Lang/Burlesque/Comments @@ -0,0 +1 @@ +../../Task/Comments/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Determine-if-a-string-is-numeric b/Lang/Burlesque/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..969e311df6 --- /dev/null +++ b/Lang/Burlesque/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Entropy b/Lang/Burlesque/Entropy new file mode 120000 index 0000000000..02f9833679 --- /dev/null +++ b/Lang/Burlesque/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Ordered-words b/Lang/Burlesque/Ordered-words new file mode 120000 index 0000000000..1c5bb607ad --- /dev/null +++ b/Lang/Burlesque/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Quine b/Lang/Burlesque/Quine new file mode 120000 index 0000000000..d854d208c0 --- /dev/null +++ b/Lang/Burlesque/Quine @@ -0,0 +1 @@ +../../Task/Quine/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Search-a-list b/Lang/Burlesque/Search-a-list new file mode 120000 index 0000000000..50b66dc15b --- /dev/null +++ b/Lang/Burlesque/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Burlesque \ 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..9620f10a86 --- /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/Bitmap b/Lang/C/Bitmap new file mode 120000 index 0000000000..001256cd78 --- /dev/null +++ b/Lang/C/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/C \ No newline at end of file diff --git a/Lang/C/Bitmap-B-zier-curves-Cubic b/Lang/C/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..354e218c6c --- /dev/null +++ b/Lang/C/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/C \ No newline at end of file diff --git a/Lang/C/Bitmap-B-zier-curves-Quadratic b/Lang/C/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..bf24802d96 --- /dev/null +++ b/Lang/C/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/C \ No newline at end of file diff --git a/Lang/C/Bitmap-Bresenhams-line-algorithm b/Lang/C/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..91e657b491 --- /dev/null +++ b/Lang/C/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/C \ No newline at end of file diff --git a/Lang/C/Bitmap-Flood-fill b/Lang/C/Bitmap-Flood-fill new file mode 120000 index 0000000000..d38ae8e853 --- /dev/null +++ b/Lang/C/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/C \ No newline at end of file diff --git a/Lang/C/Bitmap-Histogram b/Lang/C/Bitmap-Histogram new file mode 120000 index 0000000000..6d1cc30baa --- /dev/null +++ b/Lang/C/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/C \ No newline at end of file diff --git a/Lang/C/Bitmap-PPM-conversion-through-a-pipe b/Lang/C/Bitmap-PPM-conversion-through-a-pipe new file mode 120000 index 0000000000..8ce740c78b --- /dev/null +++ b/Lang/C/Bitmap-PPM-conversion-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-PPM-conversion-through-a-pipe/C \ No newline at end of file diff --git a/Lang/C/Bitmap-Read-a-PPM-file b/Lang/C/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..d495a909fd --- /dev/null +++ b/Lang/C/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/C \ No newline at end of file diff --git a/Lang/C/Bitmap-Read-an-image-through-a-pipe b/Lang/C/Bitmap-Read-an-image-through-a-pipe new file mode 120000 index 0000000000..95e25310c0 --- /dev/null +++ b/Lang/C/Bitmap-Read-an-image-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-Read-an-image-through-a-pipe/C \ No newline at end of file diff --git a/Lang/C/Bitmap-Write-a-PPM-file b/Lang/C/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..1667ea49cf --- /dev/null +++ b/Lang/C/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/C \ No newline at end of file diff --git a/Lang/C/Bitwise-IO b/Lang/C/Bitwise-IO new file mode 120000 index 0000000000..ab12b023b0 --- /dev/null +++ b/Lang/C/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/C \ No newline at end of file diff --git a/Lang/C/Bitwise-operations b/Lang/C/Bitwise-operations new file mode 120000 index 0000000000..75de5d6a82 --- /dev/null +++ b/Lang/C/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/C \ No newline at end of file diff --git a/Lang/C/Box-the-compass b/Lang/C/Box-the-compass new file mode 120000 index 0000000000..a99823a35b --- /dev/null +++ b/Lang/C/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/C \ No newline at end of file diff --git a/Lang/C/Bulls-and-cows-Player b/Lang/C/Bulls-and-cows-Player new file mode 120000 index 0000000000..73aa27eecd --- /dev/null +++ b/Lang/C/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/C \ No newline at end of file diff --git a/Lang/Clojure/Bitmap b/Lang/Clojure/Bitmap new file mode 120000 index 0000000000..e69d37c976 --- /dev/null +++ b/Lang/Clojure/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Bitmap-Bresenhams-line-algorithm b/Lang/Clojure/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..055635008f --- /dev/null +++ b/Lang/Clojure/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Bitwise-operations b/Lang/Clojure/Bitwise-operations new file mode 120000 index 0000000000..3222bd7020 --- /dev/null +++ b/Lang/Clojure/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Box-the-compass b/Lang/Clojure/Box-the-compass new file mode 120000 index 0000000000..efe3229e22 --- /dev/null +++ b/Lang/Clojure/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Clojure \ No newline at end of file diff --git a/Lang/CoffeeScript/Bitwise-operations b/Lang/CoffeeScript/Bitwise-operations new file mode 120000 index 0000000000..e77dbf18b7 --- /dev/null +++ b/Lang/CoffeeScript/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Boolean-values b/Lang/CoffeeScript/Boolean-values new file mode 120000 index 0000000000..8a59eb9fe2 --- /dev/null +++ b/Lang/CoffeeScript/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/CoffeeScript \ No newline at end of file diff --git a/Lang/Erlang/Bitmap-Bresenhams-line-algorithm b/Lang/Erlang/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..6955d51794 --- /dev/null +++ b/Lang/Erlang/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Bitwise-operations b/Lang/Erlang/Bitwise-operations new file mode 120000 index 0000000000..3848b12e8c --- /dev/null +++ b/Lang/Erlang/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Boolean-values b/Lang/Erlang/Boolean-values new file mode 120000 index 0000000000..a0a8cccaca --- /dev/null +++ b/Lang/Erlang/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Erlang \ No newline at end of file diff --git a/Lang/Forth/Bitmap b/Lang/Forth/Bitmap new file mode 120000 index 0000000000..f4f1d4d18a --- /dev/null +++ b/Lang/Forth/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitmap-Bresenhams-line-algorithm b/Lang/Forth/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..76fad8395b --- /dev/null +++ b/Lang/Forth/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitmap-Flood-fill b/Lang/Forth/Bitmap-Flood-fill new file mode 120000 index 0000000000..2e4011073d --- /dev/null +++ b/Lang/Forth/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitmap-Histogram b/Lang/Forth/Bitmap-Histogram new file mode 120000 index 0000000000..cedaf56c19 --- /dev/null +++ b/Lang/Forth/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitmap-Midpoint-circle-algorithm b/Lang/Forth/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..82362ed8a6 --- /dev/null +++ b/Lang/Forth/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitmap-Read-a-PPM-file b/Lang/Forth/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..937f3d1386 --- /dev/null +++ b/Lang/Forth/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitmap-Write-a-PPM-file b/Lang/Forth/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..9308d6d3e9 --- /dev/null +++ b/Lang/Forth/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitwise-IO b/Lang/Forth/Bitwise-IO new file mode 120000 index 0000000000..8e87a9d2a6 --- /dev/null +++ b/Lang/Forth/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Forth \ No newline at end of file diff --git a/Lang/Forth/Bitwise-operations b/Lang/Forth/Bitwise-operations new file mode 120000 index 0000000000..ae59f82496 --- /dev/null +++ b/Lang/Forth/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Forth \ No newline at end of file diff --git a/Lang/Forth/Boolean-values b/Lang/Forth/Boolean-values new file mode 120000 index 0000000000..3ca46c321a --- /dev/null +++ b/Lang/Forth/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Forth \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-B-zier-curves-Cubic b/Lang/Fortran/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..476c218dbf --- /dev/null +++ b/Lang/Fortran/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-B-zier-curves-Quadratic b/Lang/Fortran/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..7cca859497 --- /dev/null +++ b/Lang/Fortran/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-Bresenhams-line-algorithm b/Lang/Fortran/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..94088346b5 --- /dev/null +++ b/Lang/Fortran/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-Flood-fill b/Lang/Fortran/Bitmap-Flood-fill new file mode 120000 index 0000000000..ff30e7b141 --- /dev/null +++ b/Lang/Fortran/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-Histogram b/Lang/Fortran/Bitmap-Histogram new file mode 120000 index 0000000000..9ab974ae67 --- /dev/null +++ b/Lang/Fortran/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-Midpoint-circle-algorithm b/Lang/Fortran/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..3aaac02893 --- /dev/null +++ b/Lang/Fortran/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-Read-a-PPM-file b/Lang/Fortran/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..96dd258b83 --- /dev/null +++ b/Lang/Fortran/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitmap-Write-a-PPM-file b/Lang/Fortran/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..e35582fb49 --- /dev/null +++ b/Lang/Fortran/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bitwise-operations b/Lang/Fortran/Bitwise-operations new file mode 120000 index 0000000000..1dd959850d --- /dev/null +++ b/Lang/Fortran/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Box-the-compass b/Lang/Fortran/Box-the-compass new file mode 120000 index 0000000000..1e42d18411 --- /dev/null +++ b/Lang/Fortran/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Bulls-and-cows-Player b/Lang/Fortran/Bulls-and-cows-Player new file mode 120000 index 0000000000..768dcee235 --- /dev/null +++ b/Lang/Fortran/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Fortran \ No newline at end of file diff --git a/Lang/Go/Bitmap b/Lang/Go/Bitmap new file mode 120000 index 0000000000..cfe1abe6f5 --- /dev/null +++ b/Lang/Go/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-B-zier-curves-Cubic b/Lang/Go/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..c528c9e60a --- /dev/null +++ b/Lang/Go/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-B-zier-curves-Quadratic b/Lang/Go/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..2a622f3d7a --- /dev/null +++ b/Lang/Go/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Bresenhams-line-algorithm b/Lang/Go/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..f9bc314b98 --- /dev/null +++ b/Lang/Go/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Flood-fill b/Lang/Go/Bitmap-Flood-fill new file mode 120000 index 0000000000..b21880b83d --- /dev/null +++ b/Lang/Go/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Histogram b/Lang/Go/Bitmap-Histogram new file mode 120000 index 0000000000..9e75a99ccb --- /dev/null +++ b/Lang/Go/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Midpoint-circle-algorithm b/Lang/Go/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..b1692aa712 --- /dev/null +++ b/Lang/Go/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-PPM-conversion-through-a-pipe b/Lang/Go/Bitmap-PPM-conversion-through-a-pipe new file mode 120000 index 0000000000..e02aa2ccf8 --- /dev/null +++ b/Lang/Go/Bitmap-PPM-conversion-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-PPM-conversion-through-a-pipe/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Read-a-PPM-file b/Lang/Go/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..e2fdf926c8 --- /dev/null +++ b/Lang/Go/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Read-an-image-through-a-pipe b/Lang/Go/Bitmap-Read-an-image-through-a-pipe new file mode 120000 index 0000000000..addb60068a --- /dev/null +++ b/Lang/Go/Bitmap-Read-an-image-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-Read-an-image-through-a-pipe/Go \ No newline at end of file diff --git a/Lang/Go/Bitmap-Write-a-PPM-file b/Lang/Go/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..b2d2b91b59 --- /dev/null +++ b/Lang/Go/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Go \ No newline at end of file diff --git a/Lang/Go/Bitwise-operations b/Lang/Go/Bitwise-operations new file mode 120000 index 0000000000..d318770a6d --- /dev/null +++ b/Lang/Go/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Go \ No newline at end of file diff --git a/Lang/Go/Box-the-compass b/Lang/Go/Box-the-compass new file mode 120000 index 0000000000..d8b6c13239 --- /dev/null +++ b/Lang/Go/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Go \ No newline at end of file diff --git a/Lang/Go/Bulls-and-cows-Player b/Lang/Go/Bulls-and-cows-Player new file mode 120000 index 0000000000..665d0db489 --- /dev/null +++ b/Lang/Go/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Go \ No newline at end of file diff --git a/Lang/Haskell/Bitmap b/Lang/Haskell/Bitmap new file mode 120000 index 0000000000..42dd9e9f82 --- /dev/null +++ b/Lang/Haskell/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-B-zier-curves-Quadratic b/Lang/Haskell/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..8952899c33 --- /dev/null +++ b/Lang/Haskell/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-Bresenhams-line-algorithm b/Lang/Haskell/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..55d86797d2 --- /dev/null +++ b/Lang/Haskell/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-Flood-fill b/Lang/Haskell/Bitmap-Flood-fill new file mode 120000 index 0000000000..d271cf5cd6 --- /dev/null +++ b/Lang/Haskell/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-Histogram b/Lang/Haskell/Bitmap-Histogram new file mode 120000 index 0000000000..4a232647bd --- /dev/null +++ b/Lang/Haskell/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-Midpoint-circle-algorithm b/Lang/Haskell/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..8f02b6595c --- /dev/null +++ b/Lang/Haskell/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-Read-a-PPM-file b/Lang/Haskell/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..faf571f0a5 --- /dev/null +++ b/Lang/Haskell/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitmap-Write-a-PPM-file b/Lang/Haskell/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..1aea592857 --- /dev/null +++ b/Lang/Haskell/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitwise-IO b/Lang/Haskell/Bitwise-IO new file mode 120000 index 0000000000..6a4a84b99a --- /dev/null +++ b/Lang/Haskell/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bitwise-operations b/Lang/Haskell/Bitwise-operations new file mode 120000 index 0000000000..d4455c592e --- /dev/null +++ b/Lang/Haskell/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Boolean-values b/Lang/Haskell/Boolean-values new file mode 120000 index 0000000000..16e5378caf --- /dev/null +++ b/Lang/Haskell/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Box-the-compass b/Lang/Haskell/Box-the-compass new file mode 120000 index 0000000000..d1f29841e4 --- /dev/null +++ b/Lang/Haskell/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Bulls-and-cows-Player b/Lang/Haskell/Bulls-and-cows-Player new file mode 120000 index 0000000000..6fd5f5eb4f --- /dev/null +++ b/Lang/Haskell/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Haskell \ No newline at end of file diff --git a/Lang/Java/Bitmap b/Lang/Java/Bitmap new file mode 120000 index 0000000000..c7fad9400e --- /dev/null +++ b/Lang/Java/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Java \ No newline at end of file diff --git a/Lang/Java/Bitmap-Flood-fill b/Lang/Java/Bitmap-Flood-fill new file mode 120000 index 0000000000..7ed1d6dbe1 --- /dev/null +++ b/Lang/Java/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Java \ No newline at end of file diff --git a/Lang/Java/Bitwise-operations b/Lang/Java/Bitwise-operations new file mode 120000 index 0000000000..c81f21cabe --- /dev/null +++ b/Lang/Java/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Java \ No newline at end of file diff --git a/Lang/Java/Box-the-compass b/Lang/Java/Box-the-compass new file mode 120000 index 0000000000..cfa19868d4 --- /dev/null +++ b/Lang/Java/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Java \ No newline at end of file diff --git a/Lang/Java/Break-OO-privacy b/Lang/Java/Break-OO-privacy new file mode 120000 index 0000000000..d2a911072c --- /dev/null +++ b/Lang/Java/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Java \ No newline at end of file diff --git a/Lang/JavaScript/Bitmap-Bresenhams-line-algorithm b/Lang/JavaScript/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..e644a70e0f --- /dev/null +++ b/Lang/JavaScript/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Bitwise-operations b/Lang/JavaScript/Bitwise-operations new file mode 120000 index 0000000000..f3fe08b34a --- /dev/null +++ b/Lang/JavaScript/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Box-the-compass b/Lang/JavaScript/Box-the-compass new file mode 120000 index 0000000000..3160b46eba --- /dev/null +++ b/Lang/JavaScript/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/JavaScript \ No newline at end of file diff --git a/Lang/Lua/Bitmap b/Lang/Lua/Bitmap new file mode 120000 index 0000000000..f3c440390a --- /dev/null +++ b/Lang/Lua/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Lua \ No newline at end of file diff --git a/Lang/Lua/Bitmap-Histogram b/Lang/Lua/Bitmap-Histogram new file mode 120000 index 0000000000..d4e222fd64 --- /dev/null +++ b/Lang/Lua/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Lua \ No newline at end of file diff --git a/Lang/Lua/Bitmap-Read-a-PPM-file b/Lang/Lua/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..060597f3cd --- /dev/null +++ b/Lang/Lua/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Bitmap-Write-a-PPM-file b/Lang/Lua/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..a46af97315 --- /dev/null +++ b/Lang/Lua/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Bitwise-operations b/Lang/Lua/Bitwise-operations new file mode 120000 index 0000000000..79df0287a8 --- /dev/null +++ b/Lang/Lua/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Lua \ No newline at end of file diff --git a/Lang/Lua/Boolean-values b/Lang/Lua/Boolean-values new file mode 120000 index 0000000000..17aa8c632d --- /dev/null +++ b/Lang/Lua/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Lua \ No newline at end of file diff --git a/Lang/Lua/Box-the-compass b/Lang/Lua/Box-the-compass new file mode 120000 index 0000000000..48bb6de320 --- /dev/null +++ b/Lang/Lua/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Lua \ No newline at end of file diff --git a/Lang/MATLAB/Bitmap b/Lang/MATLAB/Bitmap new file mode 120000 index 0000000000..6d1b3288f5 --- /dev/null +++ b/Lang/MATLAB/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Bitmap-B-zier-curves-Cubic b/Lang/MATLAB/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..9a29c50f71 --- /dev/null +++ b/Lang/MATLAB/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Bitmap-B-zier-curves-Quadratic b/Lang/MATLAB/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..edffb376be --- /dev/null +++ b/Lang/MATLAB/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Bitmap-Bresenhams-line-algorithm b/Lang/MATLAB/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..53d68d763d --- /dev/null +++ b/Lang/MATLAB/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Bitwise-operations b/Lang/MATLAB/Bitwise-operations new file mode 120000 index 0000000000..83ebe89701 --- /dev/null +++ b/Lang/MATLAB/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Boolean-values b/Lang/MATLAB/Boolean-values new file mode 120000 index 0000000000..b6d3cca45e --- /dev/null +++ b/Lang/MATLAB/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Box-the-compass b/Lang/MATLAB/Box-the-compass new file mode 120000 index 0000000000..d6d4b64b7c --- /dev/null +++ b/Lang/MATLAB/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/MATLAB \ No newline at end of file diff --git a/Lang/PHP/Bitmap b/Lang/PHP/Bitmap new file mode 120000 index 0000000000..158a3141b7 --- /dev/null +++ b/Lang/PHP/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/PHP \ No newline at end of file diff --git a/Lang/PHP/Bitmap-B-zier-curves-Cubic b/Lang/PHP/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..d74ddf1497 --- /dev/null +++ b/Lang/PHP/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/PHP \ No newline at end of file diff --git a/Lang/PHP/Bitmap-Histogram b/Lang/PHP/Bitmap-Histogram new file mode 120000 index 0000000000..3f10c81676 --- /dev/null +++ b/Lang/PHP/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/PHP \ No newline at end of file diff --git a/Lang/PHP/Bitmap-Write-a-PPM-file b/Lang/PHP/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..59bd393578 --- /dev/null +++ b/Lang/PHP/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/PHP \ No newline at end of file diff --git a/Lang/PHP/Bitwise-operations b/Lang/PHP/Bitwise-operations new file mode 120000 index 0000000000..1007b5c4b6 --- /dev/null +++ b/Lang/PHP/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/PHP \ No newline at end of file diff --git a/Lang/PHP/Break-OO-privacy b/Lang/PHP/Break-OO-privacy new file mode 120000 index 0000000000..3897c1d818 --- /dev/null +++ b/Lang/PHP/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/PHP \ No newline at end of file diff --git a/Lang/Perl/Bitcoin-address-validation b/Lang/Perl/Bitcoin-address-validation new file mode 120000 index 0000000000..1fa3d96857 --- /dev/null +++ b/Lang/Perl/Bitcoin-address-validation @@ -0,0 +1 @@ +../../Task/Bitcoin-address-validation/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitmap b/Lang/Perl/Bitmap new file mode 120000 index 0000000000..c24d9b7bad --- /dev/null +++ b/Lang/Perl/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitmap-Bresenhams-line-algorithm b/Lang/Perl/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..dc3ccb1d8d --- /dev/null +++ b/Lang/Perl/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitmap-Flood-fill b/Lang/Perl/Bitmap-Flood-fill new file mode 120000 index 0000000000..cec8a22fa0 --- /dev/null +++ b/Lang/Perl/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitmap-Read-a-PPM-file b/Lang/Perl/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..c8ca94cbb2 --- /dev/null +++ b/Lang/Perl/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitmap-Write-a-PPM-file b/Lang/Perl/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..be3c1a6862 --- /dev/null +++ b/Lang/Perl/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitwise-IO b/Lang/Perl/Bitwise-IO new file mode 120000 index 0000000000..57f649dd54 --- /dev/null +++ b/Lang/Perl/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Perl \ No newline at end of file diff --git a/Lang/Perl/Bitwise-operations b/Lang/Perl/Bitwise-operations new file mode 120000 index 0000000000..32aedc3b0a --- /dev/null +++ b/Lang/Perl/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Perl \ No newline at end of file diff --git a/Lang/Perl/Boolean-values b/Lang/Perl/Boolean-values new file mode 120000 index 0000000000..1144d09524 --- /dev/null +++ b/Lang/Perl/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Perl \ No newline at end of file diff --git a/Lang/Perl/Box-the-compass b/Lang/Perl/Box-the-compass new file mode 120000 index 0000000000..641a4922fd --- /dev/null +++ b/Lang/Perl/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Perl \ No newline at end of file diff --git a/Lang/Perl/Bulls-and-cows-Player b/Lang/Perl/Bulls-and-cows-Player new file mode 120000 index 0000000000..cacb807ae4 --- /dev/null +++ b/Lang/Perl/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Perl \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap b/Lang/PicoLisp/Bitmap new file mode 120000 index 0000000000..6d38cadbef --- /dev/null +++ b/Lang/PicoLisp/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-B-zier-curves-Cubic b/Lang/PicoLisp/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..8b9b5b6ba6 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-B-zier-curves-Quadratic b/Lang/PicoLisp/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..d9ba56633e --- /dev/null +++ b/Lang/PicoLisp/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Bresenhams-line-algorithm b/Lang/PicoLisp/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..69a3d699ba --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Flood-fill b/Lang/PicoLisp/Bitmap-Flood-fill new file mode 120000 index 0000000000..aa1088ecb7 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Histogram b/Lang/PicoLisp/Bitmap-Histogram new file mode 120000 index 0000000000..36d6845986 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Midpoint-circle-algorithm b/Lang/PicoLisp/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..3c28d3a0f4 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-PPM-conversion-through-a-pipe b/Lang/PicoLisp/Bitmap-PPM-conversion-through-a-pipe new file mode 120000 index 0000000000..ee4242f453 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-PPM-conversion-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-PPM-conversion-through-a-pipe/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Read-a-PPM-file b/Lang/PicoLisp/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..0e094a6789 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Read-an-image-through-a-pipe b/Lang/PicoLisp/Bitmap-Read-an-image-through-a-pipe new file mode 120000 index 0000000000..7324535b42 --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Read-an-image-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-Read-an-image-through-a-pipe/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitmap-Write-a-PPM-file b/Lang/PicoLisp/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..04bf8f27ac --- /dev/null +++ b/Lang/PicoLisp/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitwise-IO b/Lang/PicoLisp/Bitwise-IO new file mode 120000 index 0000000000..a059c517cb --- /dev/null +++ b/Lang/PicoLisp/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bitwise-operations b/Lang/PicoLisp/Bitwise-operations new file mode 120000 index 0000000000..baeb586fa9 --- /dev/null +++ b/Lang/PicoLisp/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Box-the-compass b/Lang/PicoLisp/Box-the-compass new file mode 120000 index 0000000000..d1a70f55f4 --- /dev/null +++ b/Lang/PicoLisp/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Break-OO-privacy b/Lang/PicoLisp/Break-OO-privacy new file mode 120000 index 0000000000..11245b45f5 --- /dev/null +++ b/Lang/PicoLisp/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Bulls-and-cows-Player b/Lang/PicoLisp/Bulls-and-cows-Player new file mode 120000 index 0000000000..0148747df4 --- /dev/null +++ b/Lang/PicoLisp/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/PicoLisp \ No newline at end of file diff --git a/Lang/Prolog/Box-the-compass b/Lang/Prolog/Box-the-compass new file mode 120000 index 0000000000..535c000e61 --- /dev/null +++ b/Lang/Prolog/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Bulls-and-cows-Player b/Lang/Prolog/Bulls-and-cows-Player new file mode 120000 index 0000000000..ba118222de --- /dev/null +++ b/Lang/Prolog/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Prolog \ No newline at end of file diff --git a/Lang/Python/Bitcoin-address-validation b/Lang/Python/Bitcoin-address-validation new file mode 120000 index 0000000000..33ad58db8b --- /dev/null +++ b/Lang/Python/Bitcoin-address-validation @@ -0,0 +1 @@ +../../Task/Bitcoin-address-validation/Python \ No newline at end of file diff --git a/Lang/Python/Bitmap-B-zier-curves-Cubic b/Lang/Python/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..272954dcb4 --- /dev/null +++ b/Lang/Python/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Python \ No newline at end of file diff --git a/Lang/Python/Bitmap-Bresenhams-line-algorithm b/Lang/Python/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..6c55393c8c --- /dev/null +++ b/Lang/Python/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Bitmap-Flood-fill b/Lang/Python/Bitmap-Flood-fill new file mode 120000 index 0000000000..87c0ecac09 --- /dev/null +++ b/Lang/Python/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Python \ No newline at end of file diff --git a/Lang/Python/Bitmap-Midpoint-circle-algorithm b/Lang/Python/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..d69df2b2df --- /dev/null +++ b/Lang/Python/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Bitmap-Read-a-PPM-file b/Lang/Python/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..98944847cf --- /dev/null +++ b/Lang/Python/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Python \ No newline at end of file diff --git a/Lang/Python/Bitmap-Write-a-PPM-file b/Lang/Python/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..b7b75b4527 --- /dev/null +++ b/Lang/Python/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Python \ No newline at end of file diff --git a/Lang/Python/Bitwise-IO b/Lang/Python/Bitwise-IO new file mode 120000 index 0000000000..4fc66e83f1 --- /dev/null +++ b/Lang/Python/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Python \ No newline at end of file diff --git a/Lang/Python/Bitwise-operations b/Lang/Python/Bitwise-operations new file mode 120000 index 0000000000..82022e0c21 --- /dev/null +++ b/Lang/Python/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Python \ No newline at end of file diff --git a/Lang/Python/Boolean-values b/Lang/Python/Boolean-values new file mode 120000 index 0000000000..ef7c1123fc --- /dev/null +++ b/Lang/Python/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Python \ No newline at end of file diff --git a/Lang/Python/Box-the-compass b/Lang/Python/Box-the-compass new file mode 120000 index 0000000000..d786d1c7a1 --- /dev/null +++ b/Lang/Python/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Python \ No newline at end of file diff --git a/Lang/Python/Break-OO-privacy b/Lang/Python/Break-OO-privacy new file mode 120000 index 0000000000..5efb2516d4 --- /dev/null +++ b/Lang/Python/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Python \ No newline at end of file diff --git a/Lang/Python/Bulls-and-cows-Player b/Lang/Python/Bulls-and-cows-Player new file mode 120000 index 0000000000..8a46db3370 --- /dev/null +++ b/Lang/Python/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Python \ No newline at end of file diff --git a/Lang/R/Bitmap b/Lang/R/Bitmap new file mode 120000 index 0000000000..28fad3da6a --- /dev/null +++ b/Lang/R/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/R \ No newline at end of file diff --git a/Lang/R/Bitmap-B-zier-curves-Cubic b/Lang/R/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..af5b39dacd --- /dev/null +++ b/Lang/R/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/R \ No newline at end of file diff --git a/Lang/R/Bitmap-Write-a-PPM-file b/Lang/R/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..b2c1fef460 --- /dev/null +++ b/Lang/R/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/R \ No newline at end of file diff --git a/Lang/R/Bitwise-operations b/Lang/R/Bitwise-operations new file mode 120000 index 0000000000..382ea8decb --- /dev/null +++ b/Lang/R/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/R \ No newline at end of file diff --git a/Lang/REXX/Bitmap b/Lang/REXX/Bitmap new file mode 120000 index 0000000000..690831b43d --- /dev/null +++ b/Lang/REXX/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/REXX \ No newline at end of file diff --git a/Lang/REXX/Bitmap-Bresenhams-line-algorithm b/Lang/REXX/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..47a68a770f --- /dev/null +++ b/Lang/REXX/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Bitmap-Midpoint-circle-algorithm b/Lang/REXX/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..a88d782ea1 --- /dev/null +++ b/Lang/REXX/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Bitmap-Write-a-PPM-file b/Lang/REXX/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..9a9ba25fed --- /dev/null +++ b/Lang/REXX/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Bitwise-IO b/Lang/REXX/Bitwise-IO new file mode 120000 index 0000000000..4471a82f36 --- /dev/null +++ b/Lang/REXX/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/REXX \ No newline at end of file diff --git a/Lang/REXX/Bitwise-operations b/Lang/REXX/Bitwise-operations new file mode 120000 index 0000000000..9775fc903d --- /dev/null +++ b/Lang/REXX/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/REXX \ No newline at end of file diff --git a/Lang/REXX/Boolean-values b/Lang/REXX/Boolean-values new file mode 120000 index 0000000000..c2b785fd64 --- /dev/null +++ b/Lang/REXX/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/REXX \ No newline at end of file diff --git a/Lang/REXX/Box-the-compass b/Lang/REXX/Box-the-compass new file mode 120000 index 0000000000..62985f1512 --- /dev/null +++ b/Lang/REXX/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/REXX \ No newline at end of file diff --git a/Lang/Racket/Bitmap b/Lang/Racket/Bitmap new file mode 120000 index 0000000000..2c20b0cc97 --- /dev/null +++ b/Lang/Racket/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Racket \ No newline at end of file diff --git a/Lang/Racket/Bitmap-Flood-fill b/Lang/Racket/Bitmap-Flood-fill new file mode 120000 index 0000000000..5aa44dd451 --- /dev/null +++ b/Lang/Racket/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Racket \ No newline at end of file diff --git a/Lang/Racket/Bitwise-operations b/Lang/Racket/Bitwise-operations new file mode 120000 index 0000000000..60e5961ea1 --- /dev/null +++ b/Lang/Racket/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Racket \ No newline at end of file diff --git a/Lang/Racket/Boolean-values b/Lang/Racket/Boolean-values new file mode 120000 index 0000000000..c74e219ec4 --- /dev/null +++ b/Lang/Racket/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Racket \ No newline at end of file diff --git a/Lang/Racket/Box-the-compass b/Lang/Racket/Box-the-compass new file mode 120000 index 0000000000..a7e016a704 --- /dev/null +++ b/Lang/Racket/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Racket \ No newline at end of file diff --git a/Lang/Ruby/Bitmap b/Lang/Ruby/Bitmap new file mode 120000 index 0000000000..6aaa099f73 --- /dev/null +++ b/Lang/Ruby/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-B-zier-curves-Cubic b/Lang/Ruby/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..a16cb26158 --- /dev/null +++ b/Lang/Ruby/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Bresenhams-line-algorithm b/Lang/Ruby/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..7c7ff95480 --- /dev/null +++ b/Lang/Ruby/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Flood-fill b/Lang/Ruby/Bitmap-Flood-fill new file mode 120000 index 0000000000..928fc2b26d --- /dev/null +++ b/Lang/Ruby/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Histogram b/Lang/Ruby/Bitmap-Histogram new file mode 120000 index 0000000000..b98346fe09 --- /dev/null +++ b/Lang/Ruby/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Midpoint-circle-algorithm b/Lang/Ruby/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..4ea4323ab4 --- /dev/null +++ b/Lang/Ruby/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-PPM-conversion-through-a-pipe b/Lang/Ruby/Bitmap-PPM-conversion-through-a-pipe new file mode 120000 index 0000000000..a5147ad4a1 --- /dev/null +++ b/Lang/Ruby/Bitmap-PPM-conversion-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-PPM-conversion-through-a-pipe/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Read-a-PPM-file b/Lang/Ruby/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..93371c0173 --- /dev/null +++ b/Lang/Ruby/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Read-an-image-through-a-pipe b/Lang/Ruby/Bitmap-Read-an-image-through-a-pipe new file mode 120000 index 0000000000..615bba5d7e --- /dev/null +++ b/Lang/Ruby/Bitmap-Read-an-image-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-Read-an-image-through-a-pipe/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitmap-Write-a-PPM-file b/Lang/Ruby/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..1439820836 --- /dev/null +++ b/Lang/Ruby/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitwise-IO b/Lang/Ruby/Bitwise-IO new file mode 120000 index 0000000000..d8b37d9273 --- /dev/null +++ b/Lang/Ruby/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bitwise-operations b/Lang/Ruby/Bitwise-operations new file mode 120000 index 0000000000..6d9e87bcb7 --- /dev/null +++ b/Lang/Ruby/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Box-the-compass b/Lang/Ruby/Box-the-compass new file mode 120000 index 0000000000..b39a99934a --- /dev/null +++ b/Lang/Ruby/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Break-OO-privacy b/Lang/Ruby/Break-OO-privacy new file mode 120000 index 0000000000..35f812140c --- /dev/null +++ b/Lang/Ruby/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Bulls-and-cows-Player b/Lang/Ruby/Bulls-and-cows-Player new file mode 120000 index 0000000000..46b2931207 --- /dev/null +++ b/Lang/Ruby/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Ruby \ No newline at end of file diff --git a/Lang/SNUSP/Boolean-values b/Lang/SNUSP/Boolean-values new file mode 120000 index 0000000000..38eabbde50 --- /dev/null +++ b/Lang/SNUSP/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/SNUSP \ No newline at end of file diff --git a/Lang/Sather/Boolean-values b/Lang/Sather/Boolean-values new file mode 120000 index 0000000000..d0fe3e4090 --- /dev/null +++ b/Lang/Sather/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Sather \ No newline at end of file diff --git a/Lang/Scala/Bitmap b/Lang/Scala/Bitmap new file mode 120000 index 0000000000..0858dff4f3 --- /dev/null +++ b/Lang/Scala/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Scala \ No newline at end of file diff --git a/Lang/Scala/Bitmap-Bresenhams-line-algorithm b/Lang/Scala/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..78ac9da006 --- /dev/null +++ b/Lang/Scala/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Scala \ No newline at end of file diff --git a/Lang/Scala/Bitmap-Histogram b/Lang/Scala/Bitmap-Histogram new file mode 120000 index 0000000000..63180fabea --- /dev/null +++ b/Lang/Scala/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Scala \ No newline at end of file diff --git a/Lang/Scala/Bitmap-Midpoint-circle-algorithm b/Lang/Scala/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..fe7f545a11 --- /dev/null +++ b/Lang/Scala/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Scala \ No newline at end of file diff --git a/Lang/Scala/Bitmap-Read-a-PPM-file b/Lang/Scala/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..4f0a8e5b41 --- /dev/null +++ b/Lang/Scala/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Scala \ No newline at end of file diff --git a/Lang/Scala/Bitmap-Write-a-PPM-file b/Lang/Scala/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..3ec0cf05d7 --- /dev/null +++ b/Lang/Scala/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Scala \ No newline at end of file diff --git a/Lang/Scala/Bitwise-operations b/Lang/Scala/Bitwise-operations new file mode 120000 index 0000000000..28750a4524 --- /dev/null +++ b/Lang/Scala/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Scala \ No newline at end of file diff --git a/Lang/Scala/Box-the-compass b/Lang/Scala/Box-the-compass new file mode 120000 index 0000000000..3fe10af4a9 --- /dev/null +++ b/Lang/Scala/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Scala \ No newline at end of file diff --git a/Lang/Scheme/Bitmap b/Lang/Scheme/Bitmap new file mode 120000 index 0000000000..2894dc361a --- /dev/null +++ b/Lang/Scheme/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Bitmap-Write-a-PPM-file b/Lang/Scheme/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..cff26dc962 --- /dev/null +++ b/Lang/Scheme/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Bitwise-operations b/Lang/Scheme/Bitwise-operations new file mode 120000 index 0000000000..0e1b56ff75 --- /dev/null +++ b/Lang/Scheme/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Scheme \ No newline at end of file diff --git a/Lang/Smalltalk/Bitwise-operations b/Lang/Smalltalk/Bitwise-operations new file mode 120000 index 0000000000..985f6c3565 --- /dev/null +++ b/Lang/Smalltalk/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Smalltalk \ No newline at end of file diff --git a/Lang/Tcl/Bitcoin-address-validation b/Lang/Tcl/Bitcoin-address-validation new file mode 120000 index 0000000000..0f37b4436c --- /dev/null +++ b/Lang/Tcl/Bitcoin-address-validation @@ -0,0 +1 @@ +../../Task/Bitcoin-address-validation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap b/Lang/Tcl/Bitmap new file mode 120000 index 0000000000..6a571fad23 --- /dev/null +++ b/Lang/Tcl/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-B-zier-curves-Cubic b/Lang/Tcl/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..8033c6146e --- /dev/null +++ b/Lang/Tcl/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Bresenhams-line-algorithm b/Lang/Tcl/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..f649542a1f --- /dev/null +++ b/Lang/Tcl/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Flood-fill b/Lang/Tcl/Bitmap-Flood-fill new file mode 120000 index 0000000000..b00b473d87 --- /dev/null +++ b/Lang/Tcl/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Histogram b/Lang/Tcl/Bitmap-Histogram new file mode 120000 index 0000000000..da61bbc136 --- /dev/null +++ b/Lang/Tcl/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Midpoint-circle-algorithm b/Lang/Tcl/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..714ac991e2 --- /dev/null +++ b/Lang/Tcl/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-PPM-conversion-through-a-pipe b/Lang/Tcl/Bitmap-PPM-conversion-through-a-pipe new file mode 120000 index 0000000000..c502e05e84 --- /dev/null +++ b/Lang/Tcl/Bitmap-PPM-conversion-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-PPM-conversion-through-a-pipe/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Read-a-PPM-file b/Lang/Tcl/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..ae8f1daea9 --- /dev/null +++ b/Lang/Tcl/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Read-an-image-through-a-pipe b/Lang/Tcl/Bitmap-Read-an-image-through-a-pipe new file mode 120000 index 0000000000..f3e05c6e39 --- /dev/null +++ b/Lang/Tcl/Bitmap-Read-an-image-through-a-pipe @@ -0,0 +1 @@ +../../Task/Bitmap-Read-an-image-through-a-pipe/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitmap-Write-a-PPM-file b/Lang/Tcl/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..31a628c966 --- /dev/null +++ b/Lang/Tcl/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitwise-IO b/Lang/Tcl/Bitwise-IO new file mode 120000 index 0000000000..319e149b2b --- /dev/null +++ b/Lang/Tcl/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bitwise-operations b/Lang/Tcl/Bitwise-operations new file mode 120000 index 0000000000..75ec9669a7 --- /dev/null +++ b/Lang/Tcl/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Boolean-values b/Lang/Tcl/Boolean-values new file mode 120000 index 0000000000..48522b042f --- /dev/null +++ b/Lang/Tcl/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Box-the-compass b/Lang/Tcl/Box-the-compass new file mode 120000 index 0000000000..e88e4d7895 --- /dev/null +++ b/Lang/Tcl/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Break-OO-privacy b/Lang/Tcl/Break-OO-privacy new file mode 120000 index 0000000000..1cf8f22a82 --- /dev/null +++ b/Lang/Tcl/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Bulls-and-cows-Player b/Lang/Tcl/Bulls-and-cows-Player new file mode 120000 index 0000000000..5fe9434add --- /dev/null +++ b/Lang/Tcl/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Tcl \ No newline at end of file diff --git a/Meta/Lang.yaml b/Meta/Lang.yaml index f961496fbb..9660da9f45 100644 --- a/Meta/Lang.yaml +++ b/Meta/Lang.yaml @@ -264,16 +264,101 @@ BASIC: name: BASIC path: BASIC url: BASIC +BASIC256: + ext: basic256 + name: BASIC256 + path: BASIC256 + url: BASIC256 +BBC BASIC: + ext: bbc + name: BBC BASIC + path: BBC-BASIC + url: BBC_BASIC +BCPL: + ext: bcpl + name: BCPL + path: BCPL + url: BCPL Babel: ext: pb name: Babel path: Babel url: Babel +Batch File: + ext: bat + name: Batch File + path: Batch-File + url: Batch_File +Bc: + ext: bc + name: Bc + path: Bc + url: Bc Befunge: ext: bf name: Befunge path: Befunge url: Befunge +Beta: + ext: beta + name: Beta + path: Beta + url: Beta +Biferno: + ext: biferno + name: Biferno + path: Biferno + url: Biferno +Blast: + ext: blast + name: Blast + path: Blast + url: Blast +BlitzMax: + ext: blitz + name: BlitzMax + path: BlitzMax + url: BlitzMax +Boo: + ext: boo + name: Boo + path: Boo + url: Boo +Bori: + ext: bori + name: Bori + path: Bori + url: Bori +Brace: + ext: brace + name: Brace + path: Brace + url: Brace +Bracmat: + ext: bracmat + name: Bracmat + path: Bracmat + url: Bracmat +Brainf***: + ext: bf + name: Brainf*** + path: Brainf--- + url: Brainf*** +Brat: + ext: brat + name: Brat + path: Brat + url: Brat +Brlcad: + ext: brlcad + name: Brlcad + path: Brlcad + url: Brlcad +Burlesque: + ext: blq + name: Burlesque + path: Burlesque + url: Burlesque C: ext: c name: C diff --git a/Meta/Task.yaml b/Meta/Task.yaml index 20f7fd76b3..21d3b49627 100644 --- a/Meta/Task.yaml +++ b/Meta/Task.yaml @@ -183,10 +183,82 @@ Binary strings: name: Binary strings path: Binary-strings url: Binary_strings +Bitcoin/address validation: + name: Bitcoin/address validation + path: Bitcoin-address-validation + url: Bitcoin/address_validation +Bitmap: + name: Bitmap + path: Bitmap + url: Bitmap +Bitmap/Bresenham's line algorithm: + name: Bitmap/Bresenham's line algorithm + path: Bitmap-Bresenhams-line-algorithm + url: Bitmap/Bresenham's_line_algorithm +Bitmap/Bézier curves/Cubic: + name: Bitmap/Bézier curves/Cubic + path: Bitmap-B-zier-curves-Cubic + url: Bitmap/Bézier_curves/Cubic +Bitmap/Bézier curves/Quadratic: + name: Bitmap/Bézier curves/Quadratic + path: Bitmap-B-zier-curves-Quadratic + url: Bitmap/Bézier_curves/Quadratic +Bitmap/Flood fill: + name: Bitmap/Flood fill + path: Bitmap-Flood-fill + url: Bitmap/Flood_fill +Bitmap/Histogram: + name: Bitmap/Histogram + path: Bitmap-Histogram + url: Bitmap/Histogram +Bitmap/Midpoint circle algorithm: + name: Bitmap/Midpoint circle algorithm + path: Bitmap-Midpoint-circle-algorithm + url: Bitmap/Midpoint_circle_algorithm +Bitmap/PPM conversion through a pipe: + name: Bitmap/PPM conversion through a pipe + path: Bitmap-PPM-conversion-through-a-pipe + url: Bitmap/PPM_conversion_through_a_pipe +Bitmap/Read a PPM file: + name: Bitmap/Read a PPM file + path: Bitmap-Read-a-PPM-file + url: Bitmap/Read_a_PPM_file +Bitmap/Read an image through a pipe: + name: Bitmap/Read an image through a pipe + path: Bitmap-Read-an-image-through-a-pipe + url: Bitmap/Read_an_image_through_a_pipe +Bitmap/Write a PPM file: + name: Bitmap/Write a PPM file + path: Bitmap-Write-a-PPM-file + url: Bitmap/Write_a_PPM_file +Bitwise IO: + name: Bitwise IO + path: Bitwise-IO + url: Bitwise_IO +Bitwise operations: + name: Bitwise operations + path: Bitwise-operations + url: Bitwise_operations +Boolean values: + name: Boolean values + path: Boolean-values + url: Boolean_values +Box the compass: + name: Box the compass + path: Box-the-compass + url: Box_the_compass +Break OO privacy: + name: Break OO privacy + path: Break-OO-privacy + url: Break_OO_privacy Bulls and cows: name: Bulls and cows path: Bulls-and-cows url: Bulls_and_cows +Bulls and cows/Player: + name: Bulls and cows/Player + path: Bulls-and-cows-Player + url: Bulls_and_cows/Player Caesar cipher: name: Caesar cipher path: Caesar-cipher diff --git a/Task/100-doors/BASIC256/100-doors.basic256 b/Task/100-doors/BASIC256/100-doors.basic256 new file mode 100644 index 0000000000..b5630f49ac --- /dev/null +++ b/Task/100-doors/BASIC256/100-doors.basic256 @@ -0,0 +1,34 @@ +# 100 doors problem +dim d(100) + +# simple solution +print "simple solution" +gosub initialize +for t = 1 to 100 + for j = t to 100 step t + d[j-1] = not d[j-1] + next j +next t +gosub showopen + +# more optimized solution +print "more optimized solution" +gosub initialize +for t = 1 to 10 + d[t^2-1] = true +next t +gosub showopen +end + +initialize: +for t = 1 to d[?] + d[t-1] = false # closed +next t +return + +showopen: +for t = 1 to d[?] + print d[t-1]+ " "; + if t%10 = 0 then print +next t +return diff --git a/Task/100-doors/BBC-BASIC/100-doors.bbc b/Task/100-doors/BBC-BASIC/100-doors.bbc new file mode 100644 index 0000000000..d6f2ec6320 --- /dev/null +++ b/Task/100-doors/BBC-BASIC/100-doors.bbc @@ -0,0 +1,11 @@ + DIM doors%(100) + + FOR pass% = 1 TO 100 + FOR door% = pass% TO 100 STEP pass% + doors%(door%) = NOT doors%(door%) + NEXT door% + NEXT pass% + + FOR door% = 1 TO 100 + IF doors%(door%) PRINT "Door " ; door% " is open" + NEXT door% diff --git a/Task/100-doors/Batch-File/100-doors-1.bat b/Task/100-doors/Batch-File/100-doors-1.bat new file mode 100644 index 0000000000..6ff40e7c3a --- /dev/null +++ b/Task/100-doors/Batch-File/100-doors-1.bat @@ -0,0 +1,10 @@ +@echo off +setlocal enableDelayedExpansion +:: 0 = closed +:: 1 = open +:: SET /A treats undefined variable as 0 +:: Negation operator ! must be escaped because delayed expansion is enabled +for /l %%p in (1 1 100) do for /l %%d in (%%p %%p 100) do set /a "door%%d=^!door%%d" +for /l %%d in (1 1 100) do if !door%%d!==1 ( + echo door %%d is open +) else echo door %%d is closed diff --git a/Task/100-doors/Batch-File/100-doors-2.bat b/Task/100-doors/Batch-File/100-doors-2.bat new file mode 100644 index 0000000000..a7e1fad57c --- /dev/null +++ b/Task/100-doors/Batch-File/100-doors-2.bat @@ -0,0 +1,9 @@ +@echo off +setlocal enableDelayedExpansion +set /a square=1, incr=3 +for /l %%d in (1 1 100) do ( + if %%d neq !square! (echo door %%d is closed) else ( + echo door %%d is open + set /a square+=incr, incr+=2 + ) +) diff --git a/Task/100-doors/BlitzMax/100-doors.blitz b/Task/100-doors/BlitzMax/100-doors.blitz new file mode 100644 index 0000000000..bfa8dc2dd6 --- /dev/null +++ b/Task/100-doors/BlitzMax/100-doors.blitz @@ -0,0 +1,10 @@ +Graphics 640,480 +i=1 +While ((i*i)<=100) + a$=i*i + DrawText a$,10,20*i + Print i*i + i=i+1 +Wend +Flip +WaitKey diff --git a/Task/100-doors/Bracmat/100-doors-1.bracmat b/Task/100-doors/Bracmat/100-doors-1.bracmat new file mode 100644 index 0000000000..43cc70826d --- /dev/null +++ b/Task/100-doors/Bracmat/100-doors-1.bracmat @@ -0,0 +1,26 @@ +( 100doors-tbl += door step + . tbl$(doors.101) { Create an array. Indexing is 0-based. Add one extra for addressing element nr. 100 } + & 0:?step + & whl + ' ( 1+!step:~>100:?step { ~> means 'not greater than', i.e. 'less than or equal' } + & 0:?door + & whl + ' ( !step+!door:~>100:?door + & 1+-1*!(!door$doors):?doors { $ sets the current index, which stays the same until explicitly changed. } + ) + ) + & 0:?door + & whl + ' ( 1+!door:~>100:?door + & out + $ ( door + !door + is + ( !(!door$doors):1&open + | closed + ) + ) + ) + & tbl$(doors.0) { clean up the array } +) diff --git a/Task/100-doors/Bracmat/100-doors-2.bracmat b/Task/100-doors/Bracmat/100-doors-2.bracmat new file mode 100644 index 0000000000..e9fc525e0c --- /dev/null +++ b/Task/100-doors/Bracmat/100-doors-2.bracmat @@ -0,0 +1,30 @@ +( 100doors-var += step door + . 0:?door + & whl + ' ( 1+!door:~>100:?door + & closed:?!door { this creates a variable and assigns a value 'closed' to it } + ) + & 0:?step + & whl + ' ( 1+!step:~>100:?step + & 0:?door + & whl + ' ( !step+!door:~>100:?door + & ( !!door:closed&open + | closed + ) + : ?!door + ) + ) + & 0:?door + & whl + ' ( 1+!door:~>100:?door + & out$(door !door is !!door) + ) + & 0:?door + & whl + ' ( 1+!door:~>100:?door + & tbl$(!door.0) { cleanup the variable } + ) +) diff --git a/Task/100-doors/Bracmat/100-doors-3.bracmat b/Task/100-doors/Bracmat/100-doors-3.bracmat new file mode 100644 index 0000000000..f55a2cebde --- /dev/null +++ b/Task/100-doors/Bracmat/100-doors-3.bracmat @@ -0,0 +1,25 @@ +( 100doors-list += doors door doorIndex step + . :?doors + & 0:?door + & whl + ' ( 1+!door:~>100:?door + & closed !doors:?doors + ) + & 0:?skip + & whl + ' ( :?ndoors + & whl + ' ( !doors:?skipped [!skip %?door ?doors { the [ pattern only succeeds when the scanning cursor is at position } + & !ndoors + !skipped + ( !door:open&closed + | open + ) + : ?ndoors + ) + & !ndoors !doors:?doors + & 1+!skip:<100:?skip + ) + & out$!doors +) diff --git a/Task/100-doors/Bracmat/100-doors-4.bracmat b/Task/100-doors/Bracmat/100-doors-4.bracmat new file mode 100644 index 0000000000..88f837f105 --- /dev/null +++ b/Task/100-doors/Bracmat/100-doors-4.bracmat @@ -0,0 +1,22 @@ +( 100doors-obj += doors door doorIndex step + . :?doors + & 0:?door + & whl + ' ( 1+!door:~>100:?door + & new$(=closed) !doors:?doors + ) + & 0:?skip + & whl + ' ( !doors:?tododoors + & whl + ' ( !tododoors:? [!skip %?door ?tododoors + & ( !(door.):open&closed + | open + ) + : ?(door.) + ) + & 1+!skip:<100:?skip + ) + & out$!doors +) diff --git a/Task/100-doors/Bracmat/100-doors-5.bracmat b/Task/100-doors/Bracmat/100-doors-5.bracmat new file mode 100644 index 0000000000..a287b2bb18 --- /dev/null +++ b/Task/100-doors/Bracmat/100-doors-5.bracmat @@ -0,0 +1,4 @@ +100doors-tbl$ +& 100doors-var$ +& 100doors-list$ +& 100doors-obj$; diff --git a/Task/100-doors/Burlesque/100-doors.blq b/Task/100-doors/Burlesque/100-doors.blq new file mode 100644 index 0000000000..c7791b1ed6 --- /dev/null +++ b/Task/100-doors/Burlesque/100-doors.blq @@ -0,0 +1,2 @@ +blsq ) 10ro2?^ +{1 4 9 16 25 36 49 64 81 100} diff --git a/Task/24-game/BBC-BASIC/24-game.bbc b/Task/24-game/BBC-BASIC/24-game.bbc new file mode 100644 index 0000000000..2566ab90a8 --- /dev/null +++ b/Task/24-game/BBC-BASIC/24-game.bbc @@ -0,0 +1,66 @@ + REM Choose four random digits (1-9) with repetitions allowed: + DIM digits%(4), check%(4) + FOR choice% = 1 TO 4 + digits%(choice%) = RND(9) + NEXT choice% + + REM Prompt the player: + PRINT "Enter an equation (using all of, and only, the single digits "; + FOR index% = 1 TO 4 + PRINT ; digits%(index%) ; + IF index%<>4 PRINT " " ; + NEXT + PRINT ")" + PRINT "which evaluates to exactly 24. Only multiplication (*), division (/)," + PRINT "addition (+) & subtraction (-) operations and parentheses are allowed:" + INPUT "24 = " equation$ + + REPEAT + + REM Check that the correct digits are used: + check%() = 0 + FOR char% = 1 TO LEN(equation$) + digit% = INSTR("0123456789", MID$(equation$, char%, 1)) - 1 + IF digit% >= 0 THEN + FOR index% = 1 TO 4 + IF digit% = digits%(index%) THEN + IF NOT check%(index%) check%(index%) = TRUE : EXIT FOR + ENDIF + NEXT index% + IF index% > 4 THEN + PRINT "Sorry, you used the illegal digit "; digit% + EXIT REPEAT + ENDIF + ENDIF + NEXT char% + + FOR index% = 1 TO 4 + IF NOT check%(index%) THEN + PRINT "Sorry, you failed to use the digit " ; digits%(index%) + EXIT REPEAT + ENDIF + NEXT index% + + REM Check that no pairs of digits are used: + FOR pair% = 11 TO 99 + IF INSTR(equation$, STR$(pair%)) THEN + PRINT "Sorry, you may not use a pair of digits "; pair% + EXIT REPEAT + ENDIF + NEXT pair% + + REM Check whether the equation evaluates to 24: + ON ERROR LOCAL PRINT "Sorry, there was an error in the equation" : EXIT REPEAT + result = EVAL(equation$) + RESTORE ERROR + IF result = 24 THEN + PRINT "Congratulations, you succeeded in the task!" + ELSE + PRINT "Sorry, your equation evaluated to " ; result " rather than 24!" + ENDIF + + UNTIL TRUE + + INPUT '"Play again", answer$ + IF LEFT$(answer$,1) = "y" OR LEFT$(answer$,1) = "Y" THEN CLS : RUN + QUIT diff --git a/Task/24-game/Bracmat/24-game.bracmat b/Task/24-game/Bracmat/24-game.bracmat new file mode 100644 index 0000000000..647b05fc40 --- /dev/null +++ b/Task/24-game/Bracmat/24-game.bracmat @@ -0,0 +1,78 @@ + ( 24-game + = m-w m-z 4numbers answer expr numbers + , seed get-random convertBinaryMinusToUnary + , convertDivisionToMultiplication isExpresssion reciprocal + . (seed=.!arg:(~0:~/#?m-w.~0:~/#?m-z)) + & seed$!arg + & ( get-random + = + . 36969*mod$(!m-z.65536)+div$(!m-z.65536):?m-z + & 18000*mod$(!m-w.65536)+div$(!m-w.65536):?m-w + & mod$(!m-z*65536+!m-w.9)+1 + ) + & ( convertBinaryMinusToUnary + = a z + . @(!arg:%?a "-" ?z) + & str$(!a "+-1*" convertBinaryMinusToUnary$!z) + | !arg + ) + & (reciprocal=.!arg^-1) + & ( convertDivisionToMultiplication + = a z + . @(!arg:?a "/" ?z) + & str$(!a "*reciprocal$" convertDivisionToMultiplication$!z) + | !arg + ) + & ( isExpresssion + = A Z expr + . @( !arg + : ?A + ("+"|"-"|"*"|"/") + ( ?Z + & isExpresssion$!A + & isExpresssion$!Z + ) + ) + | !numbers:?A !arg ?Z + & !A !Z:?numbers + | ( @(!arg:"(" ?expr ")") + | @(!arg:(" "|\t) ?expr) + | @(!arg:?expr (" "|\t)) + ) + & isExpresssion$!expr + ) + & out + $ "Enter an expression that evaluates to 24 by combining the following numbers." + & out$"You may only use the operators + - * /" + & out$"Parentheses and spaces are allowed." + & whl + ' ( get-random$() get-random$() get-random$() get-random$ + : ?4numbers + & out$!4numbers + & whl + ' ( get'(,STR):?expr:~ + & !4numbers:?numbers + & ~(isExpresssion$!expr&!numbers:) + & out + $ ( str + $ ( "[" + !expr + "] is not a valid expression. Try another expression." + ) + ) + ) + & !expr:~ + & convertBinaryMinusToUnary$!expr:?expr + & convertDivisionToMultiplication$!expr:?expr + & get$(!expr,MEM):?answer + & out$(str$(!expr " = " !answer)) + & !answer + : ( 24&out$Right! + | #&out$Wrong! + ) + & out$"Try another one:" + ) + & out$bye + ) +& 24-game$(13.14) +& ; diff --git a/Task/99-Bottles-of-Beer/BASIC256/99-bottles-of-beer.basic256 b/Task/99-Bottles-of-Beer/BASIC256/99-bottles-of-beer.basic256 new file mode 100644 index 0000000000..795e9dcabd --- /dev/null +++ b/Task/99-Bottles-of-Beer/BASIC256/99-bottles-of-beer.basic256 @@ -0,0 +1,33 @@ +#length of querter and eight note in ms +n4 = 1000 * 60 / 80 / 4 +n8 = n4 / 2 + +#frequency of musical notes in hz +e = 330 +ef = 311 +b = 247 +bf = 233 +f = 349 +c = 262 +d = 294 +ds = 311 +a = 220 + +dim notes(1) +dim lengs(1) + +# redim is automatic when using a {} list to assign an array +notes = {ef, ef, ef, bf, bf, bf, ef, ef, ef, ef, f , f , f , c , c , c , f , d , d , d , d , d , d , d , bf, bf, bf, c , c , ef, ef, ef, ef, ef} +lengs = {n8, n8, n8, n8, n8, n8, n8, n8, n8, n4, n8, n8, n8, n8, n8, n8, n4, n4, n8, n8, n8, n8, n8, n4, n8, n8, n8, n8, n8, n8, n8, n8, n8, n4 } + +for x = 99 to 1 step -1 + for t = 0 to notes[?]-1 + if t = 0 then print x + " bottles of beer on the wall" + if t = 11 then print x + " bottles of beer" + if t = 18 then print "Take one down, pass it around" + if t = 25 then print(x-1) + " bottles of beer on the wall" + sound notes[t], lengs[t] + pause .002 + next t + print +next x diff --git a/Task/99-Bottles-of-Beer/BBC-BASIC/99-bottles-of-beer.bbc b/Task/99-Bottles-of-Beer/BBC-BASIC/99-bottles-of-beer.bbc new file mode 100644 index 0000000000..f55119ce84 --- /dev/null +++ b/Task/99-Bottles-of-Beer/BBC-BASIC/99-bottles-of-beer.bbc @@ -0,0 +1,32 @@ + N_Bottles = 99 + + beer$ = " of beer" + wall$ = " on the wall" + unit$ = "99 bottles" + + WHILE N_Bottles >= 0 + + IF N_Bottles=0 THEN + PRINT '"No more bottles" beer$ wall$ ", " unit$ beer$ "." + PRINT "Go to the store and buy some more, "; + ELSE + PRINT 'unit$ beer$ wall$ ", " unit$ beer$ "." + PRINT "Take one down and pass it around, "; + ENDIF + + N_Bottles -= 1 + + CASE N_Bottles OF + WHEN 0: + unit$ = "no more bottles" + WHEN 1: + unit$ = "1 bottle" + OTHERWISE: + unit$ = STR$((N_Bottles + 100) MOD 100) + " bottles" + ENDCASE + + PRINT unit$ beer$ wall$ "." + + ENDWHILE + + END diff --git a/Task/99-Bottles-of-Beer/Batch-File/99-bottles-of-beer.bat b/Task/99-Bottles-of-Beer/Batch-File/99-bottles-of-beer.bat new file mode 100644 index 0000000000..a9ff3467ac --- /dev/null +++ b/Task/99-Bottles-of-Beer/Batch-File/99-bottles-of-beer.bat @@ -0,0 +1,47 @@ +@echo off +setlocal +:main +for /L %%i in (99,-1,1) do ( + call :verse %%i +) +echo no bottles of beer on the wall +echo no bottles of beer +echo go to the store and buy some more +echo 99 bottles of beer on the wall +echo. +set /p q="Keep drinking? " +if %q% == y goto main +if %q% == Y goto main +goto :eof + +:verse +call :plural %1 res +echo %res% of beer on the wall +echo %res% of beer +call :oneit %1 res +echo take %res% down and pass it round +set /a c=%1-1 +call :plural %c% res +echo %res% of beer on the wall +echo. +goto :eof + +:plural +if %1 gtr 1 goto :gtr +if %1 equ 1 goto :equ +set %2=no bottles +goto :eof +:gtr +set %2=%1 bottles +goto :eof +:equ +set %2=1 bottle +goto :eof + +:oneit +if %1 equ 1 ( + set %2=it +) else ( + set %2=one +) +goto :eof diff --git a/Task/99-Bottles-of-Beer/Bracmat/99-bottles-of-beer.bracmat b/Task/99-Bottles-of-Beer/Bracmat/99-bottles-of-beer.bracmat new file mode 100644 index 0000000000..1c766f890b --- /dev/null +++ b/Task/99-Bottles-of-Beer/Bracmat/99-bottles-of-beer.bracmat @@ -0,0 +1,59 @@ +{BottlesOfBeer.bra + +See http://99-bottles-of-beer.net/} + +X= + new += n upper nbottles lyrics + . 99:?n + & ( upper + = .@(!arg:%@?a ?z)&str$(upp$!a !z) + ) + & ( nbottles + = + . str + $ ( ( !arg:>0 + & !arg + " bottle" + (!arg:1&|s) + | "no more bottles" + ) + " of beer" + ) + ) + & ( lyrics + = (upper$(nbottles$!n:?x) " on the wall, " !x ".\n") + ( !n+-1:?n:~<0 + & "Take one down and pass it around, " + nbottles$!n + " on the wall. + +" + !lyrics + | "Go to the store and buy some more, " + nbottles$99 + " on the wall. +" + ) + ) + & put$(str$!lyrics); + +r= + get'"BottlesOfBeer.bra" +& rmv$(str$(BottlesOfBeer ".bak")) +& ren$("BottlesOfBeer.bra".str$(BottlesOfBeer ".bak")) +& put + $ ( "{BottlesOfBeer.bra + +See http://99-bottles-of-beer.net/} + +" + , "BottlesOfBeer.bra" + , NEW + ) +& lst'(X,"BottlesOfBeer.bra",APP) +& put'(\n,"BottlesOfBeer.bra",APP) +& lst'(r,"BottlesOfBeer.bra",APP) +& put$(str$("\nnew'" X ";\n"),"BottlesOfBeer.bra",APP); + +new'X; diff --git a/Task/99-Bottles-of-Beer/Brainf---/99-bottles-of-beer.bf b/Task/99-Bottles-of-Beer/Brainf---/99-bottles-of-beer.bf new file mode 100644 index 0000000000..74cb56e92c --- /dev/null +++ b/Task/99-Bottles-of-Beer/Brainf---/99-bottles-of-beer.bf @@ -0,0 +1,44 @@ +>+++++++++[<+++++++++++>-]<[>[-]>[-]<<[>+>+<<-]>>[<<+>>-]>>> +[-]<<<+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+< +-]<<-<-]+++++++++>[<->-]>>+>[<[-]<<+>>>-]>[-]+<<[>+>-<<-]<<< +[>>+>+<<<-]>>>[<<<+>>>-]>[<+>-]<<-[>[-]<[-]]>>+<[>[-]<-]<+++ ++++++[<++++++<++++++>>-]>>>[>+>+<<-]>>[<<+>>-]<[<<<<<.>>>>>- +]<<<<<<.>>[-]>[-]++++[<++++++++>-]<.>++++[<++++++++>-]<++.>+ +++++[<+++++++++>-]<.><+++++..--------.-------.>>[>>+>+<<<-]> +>>[<<<+>>>-]<[<<<<++++++++++++++.>>>>-]<<<<[-]>++++[<+++++++ ++>-]<.>+++++++++[<+++++++++>-]<--.---------.>+++++++[<------ +---->-]<.>++++++[<+++++++++++>-]<.+++..+++++++++++++.>++++++ +++[<---------->-]<--.>+++++++++[<+++++++++>-]<--.-.>++++++++ +[<---------->-]<++.>++++++++[<++++++++++>-]<++++.----------- +-.---.>+++++++[<---------->-]<+.>++++++++[<+++++++++++>-]<-. +>++[<----------->-]<.+++++++++++..>+++++++++[<---------->-]< +-----.---.>>>[>+>+<<-]>>[<<+>>-]<[<<<<<.>>>>>-]<<<<<<.>>>+++ ++[<++++++>-]<--.>++++[<++++++++>-]<++.>+++++[<+++++++++>-]<. +><+++++..--------.-------.>>[>>+>+<<<-]>>>[<<<+>>>-]<[<<<<++ +++++++++++++.>>>>-]<<<<[-]>++++[<++++++++>-]<.>+++++++++[<++ ++++++++>-]<--.---------.>+++++++[<---------->-]<.>++++++[<++ ++++++++++>-]<.+++..+++++++++++++.>++++++++++[<---------->-]< +-.---.>+++++++[<++++++++++>-]<++++.+++++++++++++.++++++++++. +------.>+++++++[<---------->-]<+.>++++++++[<++++++++++>-]<-. +-.---------.>+++++++[<---------->-]<+.>+++++++[<++++++++++>- +]<--.+++++++++++.++++++++.---------.>++++++++[<---------->-] +<++.>+++++[<+++++++++++++>-]<.+++++++++++++.----------.>++++ ++++[<---------->-]<++.>++++++++[<++++++++++>-]<.>+++[<-----> +-]<.>+++[<++++++>-]<..>+++++++++[<--------->-]<--.>+++++++[< +++++++++++>-]<+++.+++++++++++.>++++++++[<----------->-]<++++ +.>+++++[<+++++++++++++>-]<.>+++[<++++++>-]<-.---.++++++.---- +---.----------.>++++++++[<----------->-]<+.---.[-]<<<->[-]>[ +-]<<[>+>+<<-]>>[<<+>>-]>>>[-]<<<+++++++++<[>>>+<<[>+>[-]<<-] +>[<+>-]>[<<++++++++++>>>+<-]<<-<-]+++++++++>[<->-]>>+>[<[-]< +<+>>>-]>[-]+<<[>+>-<<-]<<<[>>+>+<<<-]>>>[<<<+>>>-]<>>[<+>-]< +<-[>[-]<[-]]>>+<[>[-]<-]<++++++++[<++++++<++++++>>-]>>>[>+>+ +<<-]>>[<<+>>-]<[<<<<<.>>>>>-]<<<<<<.>>[-]>[-]++++[<++++++++> +-]<.>++++[<++++++++>-]<++.>+++++[<+++++++++>-]<.><+++++..--- +-----.-------.>>[>>+>+<<<-]>>>[<<<+>>>-]<[<<<<++++++++++++++ +.>>>>-]<<<<[-]>++++[<++++++++>-]<.>+++++++++[<+++++++++>-]<- +-.---------.>+++++++[<---------->-]<.>++++++[<+++++++++++>-] +<.+++..+++++++++++++.>++++++++[<---------->-]<--.>+++++++++[ +<+++++++++>-]<--.-.>++++++++[<---------->-]<++.>++++++++[<++ +++++++++>-]<++++.------------.---.>+++++++[<---------->-]<+. +>++++++++[<+++++++++++>-]<-.>++[<----------->-]<.+++++++++++ +..>+++++++++[<---------->-]<-----.---.+++.---.[-]<<<] diff --git a/Task/99-Bottles-of-Beer/Brat/99-bottles-of-beer.brat b/Task/99-Bottles-of-Beer/Brat/99-bottles-of-beer.brat new file mode 100644 index 0000000000..42bb798f07 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Brat/99-bottles-of-beer.brat @@ -0,0 +1,7 @@ +99.to 2 { n | + p "#{n} bottles of beer on the wall, #{n} bottles of beer!" + p "Take one down, pass it around, #{n - 1} bottle#{true? n > 2 's' ''} of beer on the wall." +} + +p "One bottle of beer on the wall, one bottle of beer!" +p "Take one down, pass it around, no more bottles of beer on the wall." diff --git a/Task/A+B/BASIC256/a+b.basic256 b/Task/A+B/BASIC256/a+b.basic256 new file mode 100644 index 0000000000..568af72ac5 --- /dev/null +++ b/Task/A+B/BASIC256/a+b.basic256 @@ -0,0 +1,4 @@ +dim a(2) +input "Enter two numbers seperated by a space?", t$ +a = explode(t$," ") +print t$ + " " + (a[0] + a[1]) diff --git a/Task/A+B/BBC-BASIC/a+b-1.bbc b/Task/A+B/BBC-BASIC/a+b-1.bbc new file mode 100644 index 0000000000..e5ece06465 --- /dev/null +++ b/Task/A+B/BBC-BASIC/a+b-1.bbc @@ -0,0 +1,14 @@ + REPEAT + hereY% = VPOS + INPUT LINE "" q$ + hereX% = LEN(q$) + 1 + WHILE LEFT$(q$, 1) = " " + q$ = MID$(q$, 2) + ENDWHILE + space% = INSTR(q$, " ") + IF space% THEN + a = VAL(LEFT$(q$, space% - 1)) + b = VAL(MID$(q$, space% + 1)) + PRINT TAB(hereX%, hereY%) ; a + b + ENDIF + UNTIL FALSE diff --git a/Task/A+B/BBC-BASIC/a+b-2.bbc b/Task/A+B/BBC-BASIC/a+b-2.bbc new file mode 100644 index 0000000000..bed13e0202 --- /dev/null +++ b/Task/A+B/BBC-BASIC/a+b-2.bbc @@ -0,0 +1,5 @@ + REPEAT + INPUT LINE "" q$ + space% = INSTR(q$," ") + PRINT VAL LEFT$(q$,space%-1) + VAL MID$(q$,space%+1) + UNTIL FALSE diff --git a/Task/A+B/Batch-File/a+b-1.bat b/Task/A+B/Batch-File/a+b-1.bat new file mode 100644 index 0000000000..fa0f99d3ea --- /dev/null +++ b/Task/A+B/Batch-File/a+b-1.bat @@ -0,0 +1,8 @@ +::aplusb.cmd +@echo off +setlocal +set /p a="A: " +set /p b="B: " +set /a c=a+b +echo %c% +endlocal diff --git a/Task/A+B/Batch-File/a+b-2.bat b/Task/A+B/Batch-File/a+b-2.bat new file mode 100644 index 0000000000..5aaa18d2aa --- /dev/null +++ b/Task/A+B/Batch-File/a+b-2.bat @@ -0,0 +1,8 @@ +::aplusb.cmd +@echo off +setlocal +set a=%1 +set b=%2 +set /a c=a+b +echo %c% +endlocal diff --git a/Task/A+B/Batch-File/a+b-3.bat b/Task/A+B/Batch-File/a+b-3.bat new file mode 100644 index 0000000000..f89aab8525 --- /dev/null +++ b/Task/A+B/Batch-File/a+b-3.bat @@ -0,0 +1,6 @@ +::aplusb.cmd +@echo off +setlocal +set /a c=%~1 +echo %c% +endlocal diff --git a/Task/A+B/Batch-File/a+b-4.bat b/Task/A+B/Batch-File/a+b-4.bat new file mode 100644 index 0000000000..5a49096102 --- /dev/null +++ b/Task/A+B/Batch-File/a+b-4.bat @@ -0,0 +1,13 @@ +::aplusb.cmd +@echo off +setlocal +set /p a="Input stream: " +call :add %a% +echo %res% +endlocal +goto :eof + +:add +set /a res=res+%1 +shift +if "%1" neq "" goto :add diff --git a/Task/A+B/Bracmat/a+b.bracmat b/Task/A+B/Bracmat/a+b.bracmat new file mode 100644 index 0000000000..e5301fd996 --- /dev/null +++ b/Task/A+B/Bracmat/a+b.bracmat @@ -0,0 +1,8 @@ +( out +$ ( put$"Enter two integer numbers between -1000 and 1000:" + & (filter=~/#%:~<-1000:~>1000) + & get':(!filter:?a) (!filter:?b) + & !a+!b + | "Invalid input. Try again" + ) +); diff --git a/Task/A+B/Brainf---/a+b.bf b/Task/A+B/Brainf---/a+b.bf new file mode 100644 index 0000000000..e8aa29a60e --- /dev/null +++ b/Task/A+B/Brainf---/a+b.bf @@ -0,0 +1,6 @@ +, Read first number +>,, Eat separator and read second number +[<+>-] Add ASCII values +,++ Use newline to get a 12 +[<---->-] Subtract 48 to get back to ASCII +<. and print diff --git a/Task/A+B/Brat/a+b.brat b/Task/A+B/Brat/a+b.brat new file mode 100644 index 0000000000..dadfccb890 --- /dev/null +++ b/Task/A+B/Brat/a+b.brat @@ -0,0 +1,2 @@ +numbers = g.split[0,1].map(:to_i) +p numbers[0] + numbers[1] #Prints the sum of the input diff --git a/Task/A+B/Burlesque/a+b.blq b/Task/A+B/Burlesque/a+b.blq new file mode 100644 index 0000000000..c4d3805160 --- /dev/null +++ b/Task/A+B/Burlesque/a+b.blq @@ -0,0 +1 @@ +ps++ diff --git a/Task/Abstract-type/BBC-BASIC/abstract-type.bbc b/Task/Abstract-type/BBC-BASIC/abstract-type.bbc new file mode 100644 index 0000000000..bc5fa6d8f1 --- /dev/null +++ b/Task/Abstract-type/BBC-BASIC/abstract-type.bbc @@ -0,0 +1,19 @@ + INSTALL @lib$+"CLASSLIB" + + REM Declare a class with no implementation: + DIM abstract{method} + PROC_class(abstract{}) + + REM Inherit from the abstract class: + DIM derived{member%} + PROC_inherit(derived{}, abstract{}) + PROC_class(derived{}) + + REM Provide an implementation for the derived class: + DEF derived.method : PRINT "Hello world!" : ENDPROC + + REM Instantiate the derived class: + PROC_new(instance{}, derived{}) + + REM Test by calling the method: + PROC(instance.method) diff --git a/Task/Accumulator-factory/BBC-BASIC/accumulator-factory.bbc b/Task/Accumulator-factory/BBC-BASIC/accumulator-factory.bbc new file mode 100644 index 0000000000..918490c241 --- /dev/null +++ b/Task/Accumulator-factory/BBC-BASIC/accumulator-factory.bbc @@ -0,0 +1,17 @@ + x = FNaccumulator(1) + dummy = FN(x)(5) + dummy = FNaccumulator(3) + PRINT FN(x)(2.3) + END + + DEF FNaccumulator(sum) + LOCAL I%, P%, Q% + DIM P% 53 : Q% = !^FNdummy() + FOR I% = 0 TO 49 : P%?I% = Q%?I% : NEXT + P%!I% = P% : sum = FN(P%+I%)(sum) + = P%+I% + + DEF FNdummy(n) + PRIVATE sum + sum += n + = sum diff --git a/Task/Accumulator-factory/Brat/accumulator-factory.brat b/Task/Accumulator-factory/Brat/accumulator-factory.brat new file mode 100644 index 0000000000..7669ff601b --- /dev/null +++ b/Task/Accumulator-factory/Brat/accumulator-factory.brat @@ -0,0 +1,8 @@ +accumulator = { sum | + { n | sum = sum + n } +} + +x = accumulator 1 +x 5 +accumulator 3 #Does not affect x +p x 2.3 #Prints 8.3 (1 + 5 + 2.3) diff --git a/Task/Ackermann-function/BASIC256/ackermann-function-1.basic256 b/Task/Ackermann-function/BASIC256/ackermann-function-1.basic256 new file mode 100644 index 0000000000..43af40969f --- /dev/null +++ b/Task/Ackermann-function/BASIC256/ackermann-function-1.basic256 @@ -0,0 +1,33 @@ +dim stack(5000, 3) # BASIC-256 lacks functions (as of ver. 0.9.6.66) +stack[0,0] = 3 # M +stack[0,1] = 7 # N +lev = 0 + +gosub ackermann +print "A("+stack[0,0]+","+stack[0,1]+") = "+stack[0,2] +end + +ackermann: + if stack[lev,0]=0 then + stack[lev,2] = stack[lev,1]+1 + return + end if + if stack[lev,1]=0 then + lev = lev+1 + stack[lev,0] = stack[lev-1,0]-1 + stack[lev,1] = 1 + gosub ackermann + stack[lev-1,2] = stack[lev,2] + lev = lev-1 + return + end if + lev = lev+1 + stack[lev,0] = stack[lev-1,0] + stack[lev,1] = stack[lev-1,1]-1 + gosub ackermann + stack[lev,0] = stack[lev-1,0]-1 + stack[lev,1] = stack[lev,2] + gosub ackermann + stack[lev-1,2] = stack[lev,2] + lev = lev-1 + return diff --git a/Task/Ackermann-function/BASIC256/ackermann-function-2.basic256 b/Task/Ackermann-function/BASIC256/ackermann-function-2.basic256 new file mode 100644 index 0000000000..2cba1997b2 --- /dev/null +++ b/Task/Ackermann-function/BASIC256/ackermann-function-2.basic256 @@ -0,0 +1,19 @@ +# BASIC256 since 0.9.9.1 supports functions +for m = 0 to 3 + for n = 0 to 4 + print m + " " + n + " " + ackermann(m,n) + next n +next m +end + +function ackermann(m,n) + if m = 0 then + ackermann = n+1 + else + if n = 0 then + ackermann = ackermann(m-1,1) + else + ackermann = ackermann(m-1,ackermann(m,n-1)) + endif + end if +end function diff --git a/Task/Ackermann-function/BBC-BASIC/ackermann-function.bbc b/Task/Ackermann-function/BBC-BASIC/ackermann-function.bbc new file mode 100644 index 0000000000..f9d288f262 --- /dev/null +++ b/Task/Ackermann-function/BBC-BASIC/ackermann-function.bbc @@ -0,0 +1,7 @@ + PRINT FNackermann(3, 7) + END + + DEF FNackermann(M%, N%) + IF M% = 0 THEN = N% + 1 + IF N% = 0 THEN = FNackermann(M% - 1, 1) + = FNackermann(M% - 1, FNackermann(M%, N%-1)) diff --git a/Task/Ackermann-function/BCPL/ackermann-function.bcpl b/Task/Ackermann-function/BCPL/ackermann-function.bcpl new file mode 100644 index 0000000000..b5ed700c73 --- /dev/null +++ b/Task/Ackermann-function/BCPL/ackermann-function.bcpl @@ -0,0 +1,11 @@ +GET "libhdr" + +LET ack(m, n) = m=0 -> n+1, + n=0 -> ack(m-1, 1), + ack(m-1, ack(m, n-1)) + +LET start() = VALOF +{ FOR i = 0 TO 6 FOR m = 0 TO 3 DO + writef("ack(%n, %n) = %n*n", m, n, ack(m,n)) + RESULTIS 0 +} diff --git a/Task/Ackermann-function/Batch-File/ackermann-function-1.bat b/Task/Ackermann-function/Batch-File/ackermann-function-1.bat new file mode 100644 index 0000000000..2864cc4f5d --- /dev/null +++ b/Task/Ackermann-function/Batch-File/ackermann-function-1.bat @@ -0,0 +1,31 @@ +::Ackermann.cmd +@echo off +set depth=0 +:ack +if %1==0 goto m0 +if %2==0 goto n0 + +:else +set /a n=%2-1 +set /a depth+=1 +call :ack %1 %n% +set t=%errorlevel% +set /a depth-=1 +set /a m=%1-1 +set /a depth+=1 +call :ack %m% %t% +set t=%errorlevel% +set /a depth-=1 +if %depth%==0 ( exit %t% ) else ( exit /b %t% ) + +:m0 +set/a n=%2+1 +if %depth%==0 ( exit %n% ) else ( exit /b %n% ) + +:n0 +set /a m=%1-1 +set /a depth+=1 +call :ack %m% 1 +set t=%errorlevel% +set /a depth-=1 +if %depth%==0 ( exit %t% ) else ( exit /b %t% ) diff --git a/Task/Ackermann-function/Batch-File/ackermann-function-2.bat b/Task/Ackermann-function/Batch-File/ackermann-function-2.bat new file mode 100644 index 0000000000..5682320723 --- /dev/null +++ b/Task/Ackermann-function/Batch-File/ackermann-function-2.bat @@ -0,0 +1,4 @@ +::Ack.cmd +@echo off +cmd/c ackermann.cmd %1 %2 +echo Ackermann(%1, %2)=%errorlevel% diff --git a/Task/Ackermann-function/Bracmat/ackermann-function-1.bracmat b/Task/Ackermann-function/Bracmat/ackermann-function-1.bracmat new file mode 100644 index 0000000000..7a9c6a7d70 --- /dev/null +++ b/Task/Ackermann-function/Bracmat/ackermann-function-1.bracmat @@ -0,0 +1,8 @@ +( Ack += m n + . !arg:(?m,?n) + & ( !m:0&!n+1 + | !n:0&Ack$(!m+-1,1) + | Ack$(!m+-1,Ack$(!m,!n+-1)) + ) +); diff --git a/Task/Ackermann-function/Bracmat/ackermann-function-2.bracmat b/Task/Ackermann-function/Bracmat/ackermann-function-2.bracmat new file mode 100644 index 0000000000..893b04651f --- /dev/null +++ b/Task/Ackermann-function/Bracmat/ackermann-function-2.bracmat @@ -0,0 +1,61 @@ + ( A + = m n value key eq chain + , find insert future stack va val + . ( chain + = key future skey + . !arg:(?key.?future) + & str$!key:?skey + & (cache..insert)$(!skey..!future) + & + ) + & (find=.(cache..find)$(str$!arg)) + & ( insert + = key value future v futureeq futurem skey + . !arg:(?key.?value) + & str$!key:?skey + & ( (cache..find)$!skey:(?key.?v.?future) + & (cache..remove)$!skey + & (cache..insert)$(!skey.!value.) + & ( !future:(?futurem.?futureeq) + & (!futurem,!value.!futureeq) + | + ) + | (cache..insert)$(!skey.!value.)& + ) + ) + & !arg:(?m,?n) + & !n+1:?value + & :?eq:?stack + & whl + ' ( (!m,!n):?key + & ( find$!key:(?.#%?value.?future) + & insert$(!eq.!value) !future + | !m:0 + & !n+1:?value + & ( !eq:&insert$(!key.!value) + | insert$(!key.!value) !stack:?stack + & insert$(!eq.!value) + ) + | !n:0 + & (!m+-1,1.!key) + (!eq:|(!key.!eq)) + | find$(!m,!n+-1):(?.?val.?) + & ( !val:#% + & ( find$(!m+-1,!val):(?.?va.?) + & !va:#% + & insert$(!key.!va) + | (!m+-1,!val.!eq) + (!m,!n.!eq) + ) + | + ) + | chain$(!m,!n+-1.!m+-1.!key) + & (!m,!n+-1.) + (!eq:|(!key.!eq)) + ) + !stack + : (?m,?n.?eq) ?stack + ) + & !value + ) +& new$hash:?cache diff --git a/Task/Ackermann-function/Bracmat/ackermann-function-3.bracmat b/Task/Ackermann-function/Bracmat/ackermann-function-3.bracmat new file mode 100644 index 0000000000..f59bed5339 --- /dev/null +++ b/Task/Ackermann-function/Bracmat/ackermann-function-3.bracmat @@ -0,0 +1,11 @@ +( AckFormula += m n + . !arg:(?m,?n) + & ( !m:0&!n+1 + | !m:1&!n+2 + | !m:2&2*!n+3 + | !m:3&2^(!n+3)+-3 + | !n:0&AckFormula$(!m+-1,1) + | AckFormula$(!m+-1,AckFormula$(!m,!n+-1)) + ) +) diff --git a/Task/Ackermann-function/Brat/ackermann-function.brat b/Task/Ackermann-function/Brat/ackermann-function.brat new file mode 100644 index 0000000000..c379a682fc --- /dev/null +++ b/Task/Ackermann-function/Brat/ackermann-function.brat @@ -0,0 +1,7 @@ +ackermann = { m, n | + when { m == 0 } { n + 1 } + { m > 0 && n == 0 } { ackermann(m - 1, 1) } + { m > 0 && n > 0 } { ackermann(m - 1, ackermann(m, n - 1)) } +} + +p ackermann 3, 4 #Prints 125 diff --git a/Task/Active-object/BBC-BASIC/active-object.bbc b/Task/Active-object/BBC-BASIC/active-object.bbc new file mode 100644 index 0000000000..bb3f3c39bc --- /dev/null +++ b/Task/Active-object/BBC-BASIC/active-object.bbc @@ -0,0 +1,23 @@ + INSTALL @lib$+"CLASSLIB" + INSTALL @lib$+"TIMERLIB" + INSTALL @lib$+"NOWAIT" + + REM Integrator class: + DIM integ{f$, t#, v#, tid%, @init, @@exit, input, output, tick} + PROC_class(integ{}) + + REM Methods: + DEF integ.@init integ.f$ = "0" : integ.tid% = FN_ontimer(10, PROC(integ.tick), 1) : ENDPROC + DEF integ.@@exit PROC_killtimer(integ.tid%) : ENDPROC + DEF integ.input (f$) integ.f$ = f$ : ENDPROC + DEF integ.output = integ.v# + DEF integ.tick integ.t# += 0.01 : integ.v# += EVAL(integ.f$) : ENDPROC + + REM Test: + PROC_new(myinteg{}, integ{}) + PROC(myinteg.input) ("SIN(2*PI*0.5*myinteg.t#)") + PROCwait(200) + PROC(myinteg.input) ("0") + PROCwait(50) + PRINT "Final value = " FN(myinteg.output) + PROC_discard(myinteg{}) diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/BBC-BASIC/add-a-variable-to-a-class-instance-at-runtime.bbc b/Task/Add-a-variable-to-a-class-instance-at-runtime/BBC-BASIC/add-a-variable-to-a-class-instance-at-runtime.bbc new file mode 100644 index 0000000000..44ddc965af --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/BBC-BASIC/add-a-variable-to-a-class-instance-at-runtime.bbc @@ -0,0 +1,31 @@ + INSTALL @lib$+"CLASSLIB" + + REM Create a base class with no members: + DIM class{method} + PROC_class(class{}) + + REM Instantiate the class: + PROC_new(myobject{}, class{}) + + REM Add a member at run-time: + member$ = "mymember#" + PROCaddmember(myobject{}, member$, 8) + + REM Test that the member can be accessed: + PROCassign("myobject." + member$, "PI") + PRINT EVAL("myobject." + member$) + END + + DEF PROCaddmember(RETURN obj{}, mem$, size%) + LOCAL D%, F%, P% + DIM D% DIM(obj{}) + size% - 1, F% LEN(mem$) + 8 + P% = !^obj{} + 4 + WHILE !P% : P% = !P% : ENDWHILE : !P% = F% + $$(F%+4) = mem$ : F%!(LEN(mem$) + 5) = DIM(obj{}) + !(^obj{} + 4) = D% + ENDPROC + + DEF PROCassign(v$, n$) + IF EVAL("FNassign(" + v$ + "," + n$ + ")") + ENDPROC + DEF FNassign(RETURN n, v) : n = v : = 0 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-1.bracmat b/Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-1.bracmat new file mode 100644 index 0000000000..10d43a2642 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-1.bracmat @@ -0,0 +1,26 @@ +( ( struktuur + = (aMember=) (aMethod=.!(its.aMember)) + ) +& new$struktuur:?object +& out$"Object as originally created:" +& lst$object +& A value:?(object..aMember) +& !object:(=?originalMembersAndMethods) +& new + $ ( + ' ( (anotherMember=) + (anotherMethod=.!(its.anotherMember)) + ()$originalMembersAndMethods + ) + ) + : ?object +& out + $ " +Object with additional member and method and with 'aMember' already set to some interesting value:" +& lst$object +& some other value:?(object..anotherMember) +& out$" +Call both methods and output their return values." +& out$("aMember contains:" (object..aMethod)$) +& out$("anotherMember contains:" (object..anotherMethod)$) +&); diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-2.bracmat b/Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-2.bracmat new file mode 100644 index 0000000000..797934bf50 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Bracmat/add-a-variable-to-a-class-instance-at-runtime-2.bracmat @@ -0,0 +1,15 @@ +Object as originally created: +(object= +=(aMember=) (aMethod=.!(its.aMember))); + +Object with additional member and method and with 'aMember' already set to some interesting value: +(object= + += (anotherMember=) + (anotherMethod=.!(its.anotherMember)) + (aMember=A value) + (aMethod=.!(its.aMember))); + +Call both methods and output their return values. +aMember contains: A value +anotherMember contains: some other value diff --git a/Task/Address-of-a-variable/BBC-BASIC/address-of-a-variable.bbc b/Task/Address-of-a-variable/BBC-BASIC/address-of-a-variable.bbc new file mode 100644 index 0000000000..9aa342f4c8 --- /dev/null +++ b/Task/Address-of-a-variable/BBC-BASIC/address-of-a-variable.bbc @@ -0,0 +1,5 @@ +REM get a variable's address: +y% = ^x% + +REM can't set a variable's address, but can access a given memory location (4 bytes): +x% = !y% diff --git a/Task/Align-columns/BBC-BASIC/align-columns.bbc b/Task/Align-columns/BBC-BASIC/align-columns.bbc new file mode 100644 index 0000000000..df3196f749 --- /dev/null +++ b/Task/Align-columns/BBC-BASIC/align-columns.bbc @@ -0,0 +1,56 @@ + DATA 6 + DATA "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" + DATA "are$delineated$by$a$single$'dollar'$character,$write$a$program" + DATA "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" + DATA "column$are$separated$by$at$least$one$space." + DATA "Further,$allow$for$each$word$in$a$column$to$be$either$left$" + DATA "justified,$right$justified,$or$center$justified$within$its$column." + + REM First find the maximum length of a 'word': + max% = 0 + READ nlines% + FOR Line% = 1 TO nlines% + READ text$ + REPEAT + word$ = FNword(text$, "$") + IF LEN(word$) > max% THEN max% = LEN(word$) + UNTIL word$ = "" + NEXT Line% + @% = max% : REM set column width + + REM Now display the aligned text: + RESTORE + READ nlines% + FOR Line% = 1 TO nlines% + READ text$ + REPEAT + word$ = FNword(text$, "$") + PRINT FNjustify(word$, max%, "left"),; + UNTIL word$ = "" + PRINT + NEXT Line% + + END + + DEF FNword(text$, delim$) + PRIVATE delim% + LOCAL previous% + IF delim% = 0 THEN + previous% = 1 + ELSE + previous% = delim% + LEN(delim$) + ENDIF + delim% = INSTR(text$+delim$, delim$, previous%) + IF delim% = 0 THEN + = "" + ELSE + = MID$(text$, previous%, delim%-previous%) + " " + ENDIF + + DEF FNjustify(word$, field%, mode$) + IF word$ = "" THEN = "" + CASE mode$ OF + WHEN "center": = STRING$((field%-LEN(word$)) DIV 2, " ") + word$ + WHEN "right": = STRING$(field%-LEN(word$), " ") + word$ + ENDCASE + = word$ diff --git a/Task/Anagrams-Deranged-anagrams/BBC-BASIC/anagrams-deranged-anagrams.bbc b/Task/Anagrams-Deranged-anagrams/BBC-BASIC/anagrams-deranged-anagrams.bbc new file mode 100644 index 0000000000..b6cafaa43a --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/BBC-BASIC/anagrams-deranged-anagrams.bbc @@ -0,0 +1,53 @@ + INSTALL @lib$+"SORTLIB" + Sort% = FN_sortinit(0,0) + + DIM dict$(26000), sort$(26000), indx%(26000) + + REM Load the dictionary: + dict% = OPENIN("C:\unixdict.txt") + IF dict%=0 ERROR 100, "No dictionary file" + index% = 0 + REPEAT + index% += 1 + dict$(index%) = GET$#dict% + indx%(index%) = index% + UNTIL EOF#dict% + CLOSE #dict% + Total% = index% + + TIME = 0 + REM Sort the letters in each word: + FOR index% = 1 TO Total% + sort$(index%) = FNsortstring(dict$(index%)) + NEXT + + REM Sort the sorted words: + C% = Total% + CALL Sort%, sort$(1), indx%(1) + + REM Find anagrams and deranged anagrams: + maxlen% = 0 + maxidx% = 0 + FOR index% = 1 TO Total%-1 + IF sort$(index%) = sort$(index%+1) THEN + One$ = dict$(indx%(index%)) + Two$ = dict$(indx%(index%+1)) + FOR c% = 1 TO LEN(One$) + IF MID$(One$,c%,1) = MID$(Two$,c%,1) EXIT FOR + NEXT + IF c%>LEN(One$) IF c%>maxlen% maxlen% = c% : maxidx% = index% + ENDIF + NEXT + + PRINT "The longest deranged anagrams are '" dict$(indx%(maxidx%)); + PRINT "' and '" dict$(indx%(maxidx%+1)) "'" + PRINT "(taking " ; TIME/100 " seconds)" + END + + DEF FNsortstring(A$) + LOCAL C%, a&() + C% = LEN(A$) + DIM a&(C%) + $$^a&(0) = A$ + CALL Sort%, a&(0) + = $$^a&(0) diff --git a/Task/Anagrams-Deranged-anagrams/Bracmat/anagrams-deranged-anagrams.bracmat b/Task/Anagrams-Deranged-anagrams/Bracmat/anagrams-deranged-anagrams.bracmat new file mode 100644 index 0000000000..b1a742d9c4 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Bracmat/anagrams-deranged-anagrams.bracmat @@ -0,0 +1,63 @@ + get$("unixdict.txt",STR):?wordList +& 1:?product +& :?unsorted +& whl + ' ( @(!wordList:(%?word:?letterString) \n ?wordList) + & :?letterSum + & whl + ' ( @(!letterString:%?letter ?letterString) + & (!letter:~#|str$(N !letter))+!letterSum + : ?letterSum + ) + & !letterSum^!word !unsorted:?unsorted + ) +& ( mergeSort + = newL L first second + . !arg:?L + & whl + ' ( !L:% % + & :?newL + & whl + ' ( !L:%?first %?second ?L + & !first*!second !newL:?newL + ) + & !L !newL:?L + ) + & !L + ) +& mergeSort$!unsorted:?product +& 0:?maxLength:?oldMaxLength +& :?derangedAnagrams +& ( deranged + = nextLetter Atail Btail + . !arg + : ( (.) + | ( @(?:%@?nextLetter ?Atail) + . @(?:(%@:~!nextLetter) ?Btail) + ) + & deranged$(!Atail.!Btail) + ) + ) +& ( !product + : ? + * ? + ^ ( %+% + : @(%:? ([~!oldMaxLength:?oldMaxLength + & + | !derangedAnagrams + ) + : ?derangedAnagrams + & ~ + ) + ) + * ? + | out$!derangedAnagrams + ); diff --git a/Task/Anagrams/BBC-BASIC/anagrams.bbc b/Task/Anagrams/BBC-BASIC/anagrams.bbc new file mode 100644 index 0000000000..aae6807be6 --- /dev/null +++ b/Task/Anagrams/BBC-BASIC/anagrams.bbc @@ -0,0 +1,64 @@ + INSTALL @lib$+"SORTLIB" + sort% = FN_sortinit(0,0) + + REM Count number of words in dictionary: + nwords% = 0 + dict% = OPENIN("unixdict.txt") + WHILE NOT EOF#dict% + word$ = GET$#dict% + nwords% += 1 + ENDWHILE + CLOSE #dict% + + REM Create arrays big enough to contain the dictionary: + DIM dict$(nwords%), sort$(nwords%) + + REM Load the dictionary and sort the characters in the words: + dict% = OPENIN("unixdict.txt") + FOR word% = 1 TO nwords% + word$ = GET$#dict% + dict$(word%) = word$ + sort$(word%) = FNsortchars(word$) + NEXT word% + CLOSE #dict% + + REM Sort arrays using the 'sorted character' words as a key: + C% = nwords% + CALL sort%, sort$(1), dict$(1) + + REM Count the longest sets of anagrams: + max% = 0 + set% = 1 + FOR word% = 1 TO nwords%-1 + IF sort$(word%) = sort$(word%+1) THEN + set% += 1 + ELSE + IF set% > max% THEN max% = set% + set% = 1 + ENDIF + NEXT word% + + REM Output the results: + set% = 1 + FOR word% = 1 TO nwords%-1 + IF sort$(word%) = sort$(word%+1) THEN + set% += 1 + ELSE + IF set% = max% THEN + FOR anagram% = word%-max%+1 TO word% + PRINT dict$(anagram%),; + NEXT + PRINT + ENDIF + set% = 1 + ENDIF + NEXT word% + END + + DEF FNsortchars(word$) + LOCAL C%, char&() + DIM char&(LEN(word$)) + $$^char&(0) = word$ + C% = LEN(word$) + CALL sort%, char&(0) + = $$^char&(0) diff --git a/Task/Anagrams/Bracmat/anagrams.bracmat b/Task/Anagrams/Bracmat/anagrams.bracmat new file mode 100644 index 0000000000..9cf6bf8688 --- /dev/null +++ b/Task/Anagrams/Bracmat/anagrams.bracmat @@ -0,0 +1,28 @@ +( get$("unixdict.txt",STR):?list +& 1:?product +& whl + ' ( @(!list:(%?word:?w) \n ?list) + & :?sum + & whl + ' ( @(!w:%?let ?w) + & (!let:~#|str$(N !let))+!sum:?sum + ) + & !sum^!word*!product:?product + ) +& lst$(product,"product.txt",NEW) +& 0:?max +& :?group +& ( !product + : ? + * ?^(%+%:?exp) + * ( ? + & !exp + : ? + + ( [>!max:[?max&!exp:?group + | [~p diff --git a/Task/Arbitrary-precision-integers-(included)/Bracmat/arbitrary-precision-integers-(included).bracmat b/Task/Arbitrary-precision-integers-(included)/Bracmat/arbitrary-precision-integers-(included).bracmat new file mode 100644 index 0000000000..0cf1eaa821 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Bracmat/arbitrary-precision-integers-(included).bracmat @@ -0,0 +1,4 @@ +{?} @(5^4^3^2:?first [20 ? [-21 ?last [?length)&str$(!first "..." !last "\nlength " !length) +{!} 62060698786608744707...92256259918212890625 +length 183231 + S 2,46 sec diff --git a/Task/Arithmetic-Complex/BBC-BASIC/arithmetic-complex.bbc b/Task/Arithmetic-Complex/BBC-BASIC/arithmetic-complex.bbc new file mode 100644 index 0000000000..521038097e --- /dev/null +++ b/Task/Arithmetic-Complex/BBC-BASIC/arithmetic-complex.bbc @@ -0,0 +1,40 @@ + DIM Complex{r, i} + + DIM a{} = Complex{} : a.r = 1.0 : a.i = 1.0 + DIM b{} = Complex{} : b.r = PI# : b.i = 1.2 + DIM o{} = Complex{} + + PROCcomplexadd(o{}, a{}, b{}) + PRINT "Result of addition is " FNcomplexshow(o{}) + PROCcomplexmul(o{}, a{}, b{}) + PRINT "Result of multiplication is " ; FNcomplexshow(o{}) + PROCcomplexneg(o{}, a{}) + PRINT "Result of negation is " ; FNcomplexshow(o{}) + PROCcomplexinv(o{}, a{}) + PRINT "Result of inversion is " ; FNcomplexshow(o{}) + END + + DEF PROCcomplexadd(dst{}, one{}, two{}) + dst.r = one.r + two.r + dst.i = one.i + two.i + ENDPROC + + DEF PROCcomplexmul(dst{}, one{}, two{}) + dst.r = one.r*two.r - one.i*two.i + dst.i = one.i*two.r + one.r*two.i + ENDPROC + + DEF PROCcomplexneg(dst{}, src{}) + dst.r = -src.r + dst.i = -src.i + ENDPROC + + DEF PROCcomplexinv(dst{}, src{}) + LOCAL denom : denom = src.r^2 + src.i^ 2 + dst.r = src.r / denom + dst.i = -src.i / denom + ENDPROC + + DEF FNcomplexshow(src{}) + IF src.i >= 0 THEN = STR$(src.r) + " + " +STR$(src.i) + "i" + = STR$(src.r) + " - " + STR$(-src.i) + "i" diff --git a/Task/Arithmetic-Integer/BASIC256/arithmetic-integer.basic256 b/Task/Arithmetic-Integer/BASIC256/arithmetic-integer.basic256 new file mode 100644 index 0000000000..1aae6e200e --- /dev/null +++ b/Task/Arithmetic-Integer/BASIC256/arithmetic-integer.basic256 @@ -0,0 +1,9 @@ +input "enter a number ?", a +input "enter another number ?", b + +print "addition " + a + " + " + b + " = " + (a + b) +print "subtraction " + a + " - " + b + " = " + (a - b) +print "multiplication " + a + " * " + b + " = " + (a * b) +print "integer division " + a + " \ " + b + " = " + (a \ b) +print "remainder or modulo " + a + " % " + b + " = " + (a % b) +print "power " + a + " ^ " + b + " = " + (a ^ b) diff --git a/Task/Arithmetic-Integer/BBC-BASIC/arithmetic-integer.bbc b/Task/Arithmetic-Integer/BBC-BASIC/arithmetic-integer.bbc new file mode 100644 index 0000000000..c5ede9c5b0 --- /dev/null +++ b/Task/Arithmetic-Integer/BBC-BASIC/arithmetic-integer.bbc @@ -0,0 +1,9 @@ + INPUT "Enter the first integer: " first% + INPUT "Enter the second integer: " second% + + PRINT "The sum is " ; first% + second% + PRINT "The difference is " ; first% - second% + PRINT "The product is " ; first% * second% + PRINT "The integer quotient is " ; first% DIV second% " (rounds towards 0)" + PRINT "The remainder is " ; first% MOD second% " (sign matches first operand)" + PRINT "The first raised to the power of the second is " ; first% ^ second% diff --git a/Task/Arithmetic-Integer/Batch-File/arithmetic-integer.bat b/Task/Arithmetic-Integer/Batch-File/arithmetic-integer.bat new file mode 100644 index 0000000000..57a9750703 --- /dev/null +++ b/Task/Arithmetic-Integer/Batch-File/arithmetic-integer.bat @@ -0,0 +1,13 @@ +@echo off +set /P A=Enter 1st Number : +set /P B=Enter 2nd Number : +set D=%A% + %B% & call :printC +set D=%A% - %B% & call :printC +set D=%A% * %B% & call :printC +set D=%A% / %B% & call :printC & rem truncates toward 0 +set D=%A% %% %B% & call :printC & rem matches sign of 1st operand +exit /b + +:printC +set /A C=%D% +echo %D% = %C% diff --git a/Task/Arithmetic-Integer/Brat/arithmetic-integer.brat b/Task/Arithmetic-Integer/Brat/arithmetic-integer.brat new file mode 100644 index 0000000000..fbee55fdd1 --- /dev/null +++ b/Task/Arithmetic-Integer/Brat/arithmetic-integer.brat @@ -0,0 +1,7 @@ +x = ask("First number: ").to_i +y = ask("Second number: ").to_i + +#Division uses floating point +#Remainder uses sign of right hand side +[:+ :- :* :/ :% :^].each { op | + p "#{x} #{op} #{y} = #{x.call_method op, y}" diff --git a/Task/Arithmetic-Rational/BBC-BASIC/arithmetic-rational.bbc b/Task/Arithmetic-Rational/BBC-BASIC/arithmetic-rational.bbc new file mode 100644 index 0000000000..f7e2bde0df --- /dev/null +++ b/Task/Arithmetic-Rational/BBC-BASIC/arithmetic-rational.bbc @@ -0,0 +1,62 @@ + *FLOAT64 + DIM frac{num, den} + DIM Sum{} = frac{}, Kf{} = frac{}, One{} = frac{} + One.num = 1 : One.den = 1 + + FOR n% = 2 TO 2^19-1 + Sum.num = 1 : Sum.den = n% + FOR k% = 2 TO SQR(n%) + IF (n% MOD k%) = 0 THEN + Kf.num = 1 : Kf.den = k% + PROCadd(Sum{}, Kf{}) + PROCnormalise(Sum{}) + Kf.den = n% DIV k% + PROCadd(Sum{}, Kf{}) + PROCnormalise(Sum{}) + ENDIF + NEXT + IF FNeq(Sum{}, One{}) PRINT n% " is perfect" + NEXT n% + END + + DEF PROCabs(a{}) : a.num = ABS(a.num) : ENDPROC + DEF PROCneg(a{}) : a.num = -a.num : ENDPROC + + DEF PROCadd(a{}, b{}) + LOCAL t : t = a.den * b.den + a.num = a.num * b.den + b.num * a.den + a.den = t + ENDPROC + + DEF PROCsub(a{}, b{}) + LOCAL t : t = a.den * b.den + a.num = a.num * b.den - b.num * a.den + a.den = t + ENDPROC + + DEF PROCmul(a{}, b{}) + a.num *= b.num : a.den *= b.den + ENDPROC + + DEF PROCdiv(a{}, b{}) + a.num *= b.den : a.den *= b.num + ENDPROC + + DEF FNeq(a{}, b{}) = a.num * b.den = b.num * a.den + DEF FNlt(a{}, b{}) = a.num * b.den < b.num * a.den + DEF FNgt(a{}, b{}) = a.num * b.den > b.num * a.den + DEF FNne(a{}, b{}) = a.num * b.den <> b.num * a.den + DEF FNle(a{}, b{}) = a.num * b.den <= b.num * a.den + DEF FNge(a{}, b{}) = a.num * b.den >= b.num * a.den + + DEF PROCnormalise(a{}) + LOCAL a, b, t + a = a.num : b = a.den + WHILE b <> 0 + t = a + a = b + b = t - b * INT(t / b) + ENDWHILE + a.num /= a : a.den /= a + IF a.den < 0 a.num *= -1 : a.den *= -1 + ENDPROC diff --git a/Task/Arithmetic-evaluation/BBC-BASIC/arithmetic-evaluation.bbc b/Task/Arithmetic-evaluation/BBC-BASIC/arithmetic-evaluation.bbc new file mode 100644 index 0000000000..04e9ce6be2 --- /dev/null +++ b/Task/Arithmetic-evaluation/BBC-BASIC/arithmetic-evaluation.bbc @@ -0,0 +1,58 @@ + Expr$ = "1 + 2 * (3 + (4 * 5 + 6 * 7 * 8) - 9) / 10" + PRINT "Input = " Expr$ + AST$ = FNast(Expr$) + PRINT "AST = " AST$ + PRINT "Value = " ;EVAL(AST$) + END + + DEF FNast(RETURN in$) + LOCAL ast$, oper$ + REPEAT + ast$ += FNast1(in$) + WHILE ASC(in$)=32 in$ = MID$(in$,2) : ENDWHILE + oper$ = LEFT$(in$,1) + IF oper$="+" OR oper$="-" THEN + ast$ += oper$ + in$ = MID$(in$,2) + ELSE + EXIT REPEAT + ENDIF + UNTIL FALSE + = "(" + ast$ + ")" + + DEF FNast1(RETURN in$) + LOCAL ast$, oper$ + REPEAT + ast$ += FNast2(in$) + WHILE ASC(in$)=32 in$ = MID$(in$,2) : ENDWHILE + oper$ = LEFT$(in$,1) + IF oper$="*" OR oper$="/" THEN + ast$ += oper$ + in$ = MID$(in$,2) + ELSE + EXIT REPEAT + ENDIF + UNTIL FALSE + = "(" + ast$ + ")" + + DEF FNast2(RETURN in$) + LOCAL ast$ + WHILE ASC(in$)=32 in$ = MID$(in$,2) : ENDWHILE + IF ASC(in$)<>40 THEN = FNnumber(in$) + in$ = MID$(in$,2) + ast$ = FNast(in$) + in$ = MID$(in$,2) + = ast$ + + DEF FNnumber(RETURN in$) + LOCAL ch$, num$ + REPEAT + ch$ = LEFT$(in$,1) + IF INSTR("0123456789.", ch$) THEN + num$ += ch$ + in$ = MID$(in$,2) + ELSE + EXIT REPEAT + ENDIF + UNTIL FALSE + = num$ diff --git a/Task/Arithmetic-geometric-mean/BBC-BASIC/arithmetic-geometric-mean.bbc b/Task/Arithmetic-geometric-mean/BBC-BASIC/arithmetic-geometric-mean.bbc new file mode 100644 index 0000000000..d3fcfbd21e --- /dev/null +++ b/Task/Arithmetic-geometric-mean/BBC-BASIC/arithmetic-geometric-mean.bbc @@ -0,0 +1,13 @@ + *FLOAT 64 + @% = &1010 + PRINT FNagm(1, 1/SQR(2)) + END + + DEF FNagm(a,g) + LOCAL ta + REPEAT + ta = a + a = (a+g)/2 + g = SQR(ta*g) + UNTIL a = ta + = a diff --git a/Task/Array-concatenation/BBC-BASIC/array-concatenation.bbc b/Task/Array-concatenation/BBC-BASIC/array-concatenation.bbc new file mode 100644 index 0000000000..f3e0a4a727 --- /dev/null +++ b/Task/Array-concatenation/BBC-BASIC/array-concatenation.bbc @@ -0,0 +1,19 @@ + DIM a(3), b(4) + a() = 1, 2, 3, 4 + b() = 5, 6, 7, 8, 9 + PROCconcat(a(), b(), c()) + + FOR i% = 0 TO DIM(c(),1) + PRINT c(i%) + NEXT + END + + DEF PROCconcat(a(), b(), RETURN c()) + LOCAL s%, na%, nb% + s% = ^a(1) - ^a(0) : REM Size of each array element + na% = DIM(a(),1)+1 : REM Number of elements in a() + nb% = DIM(b(),1)+1 : REM Number of elements in b() + DIM c(na%+nb%-1) + SYS "RtlMoveMemory", ^c(0), ^a(0), s%*na% + SYS "RtlMoveMemory", ^c(na%), ^b(0), s%*nb% + ENDPROC diff --git a/Task/Array-concatenation/Burlesque/array-concatenation.blq b/Task/Array-concatenation/Burlesque/array-concatenation.blq new file mode 100644 index 0000000000..bd1dd87536 --- /dev/null +++ b/Task/Array-concatenation/Burlesque/array-concatenation.blq @@ -0,0 +1,2 @@ +blsq ) {1 2 3}{4 5 6}_+ +{1 2 3 4 5 6} diff --git a/Task/Arrays/BASIC256/arrays.basic256 b/Task/Arrays/BASIC256/arrays.basic256 new file mode 100644 index 0000000000..8dd3878430 --- /dev/null +++ b/Task/Arrays/BASIC256/arrays.basic256 @@ -0,0 +1,29 @@ +# numeric array +dim numbers(10) +for t = 0 to 9 + numbers[t] = t + 1 +next t + +# string array +dim words$(10) +# assigning an array with a list +words$ = {"one","two","three","four","five","six","seven","eight","nine","ten"} + +gosub display + +# resize arrays (always preserves values if larger) +redim numbers(11) +redim words$(11) +numbers[10] = 11 +words$[10] = "eleven" +gosub display + +end + +display: +# display arrays +# using ? to get size of array +for t = 0 to numbers[?]-1 + print numbers[t] + "=" + words$[t] +next t +return diff --git a/Task/Arrays/BBC-BASIC/arrays.bbc b/Task/Arrays/BBC-BASIC/arrays.bbc new file mode 100644 index 0000000000..508e04a217 --- /dev/null +++ b/Task/Arrays/BBC-BASIC/arrays.bbc @@ -0,0 +1,17 @@ + REM Declare arrays, dimension is maximum index: + DIM array(6), array%(6), array$(6) + + REM Entire arrays may be assigned in one statement: + array() = 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7 + array%() = 0, 1, 2, 3, 4, 5, 6 + array$() = "Zero", "One", "Two", "Three", "Four", "Five", "Six" + + REM Or individual elements may be assigned: + array(2) = PI + array%(3) = RND + array$(4) = "Hello world!" + + REM Print out sample array elements: + PRINT array(2) TAB(16) array(3) TAB(32) array(4) + PRINT array%(2) TAB(16) array%(3) TAB(32) array%(4) + PRINT array$(2) TAB(16) array$(3) TAB(32) array$(4) diff --git a/Task/Arrays/Batch-File/arrays.bat b/Task/Arrays/Batch-File/arrays.bat new file mode 100644 index 0000000000..65f5836cc6 --- /dev/null +++ b/Task/Arrays/Batch-File/arrays.bat @@ -0,0 +1,24 @@ +::arrays.cmd +@echo off +setlocal ENABLEDELAYEDEXPANSION +set array.1=1 +set array.2=2 +set array.3=3 +set array.4=4 +for /L %%i in (1,1,4) do call :showit array.%%i !array.%%i! +set c=-27 +call :mkarray marry 5 6 7 8 +for /L %%i in (-27,1,-24) do call :showit "marry^&%%i" !marry^&%%i! +endlocal +goto :eof + +:mkarray +set %1^&%c%=%2 +set /a c += 1 +shift /2 +if "%2" neq "" goto :mkarray +goto :eof + +:showit +echo %1 = %2 +goto :eof diff --git a/Task/Assertions/BBC-BASIC/assertions.bbc b/Task/Assertions/BBC-BASIC/assertions.bbc new file mode 100644 index 0000000000..b1efc13fcc --- /dev/null +++ b/Task/Assertions/BBC-BASIC/assertions.bbc @@ -0,0 +1,6 @@ + PROCassert(a% = 42) + END + + DEF PROCassert(bool%) + IF NOT bool% THEN ERROR 100, "Assertion failed" + ENDPROC diff --git a/Task/Assertions/Brat/assertions.brat b/Task/Assertions/Brat/assertions.brat new file mode 100644 index 0000000000..465eabd971 --- /dev/null +++ b/Task/Assertions/Brat/assertions.brat @@ -0,0 +1,4 @@ +squish import :assert :assertions + +assert_equal 42 42 +assert_equal 13 42 #Raises an exception diff --git a/Task/Associative-array-Creation/BASIC256/associative-array-creation.basic256 b/Task/Associative-array-Creation/BASIC256/associative-array-creation.basic256 new file mode 100644 index 0000000000..b0aa4f5c47 --- /dev/null +++ b/Task/Associative-array-Creation/BASIC256/associative-array-creation.basic256 @@ -0,0 +1,106 @@ +global values$, keys$ +dim values$[1] +dim keys$[1] + +call updateKey("a","apple") +call updateKey("b","banana") +call updateKey("c","cucumber") + +gosub show + +print "I like to eat a " + getValue$("c") + " on my salad." + +call deleteKey("b") +call updateKey("c","carrot") +call updateKey("e","endive") +gosub show + +end + +show: +for t = 0 to countKeys()-1 + print getKeyByIndex$(t) + " " + getValueByIndex$(t) +next t +print +return + +subroutine updateKey(key$, value$) + # update or add an item + i=findKey(key$) + if i=-1 then + i = freeKey() + keys$[i] = key$ + end if + values$[i] = value$ +end subroutine + +subroutine deleteKey(key$) + # delete by clearing the key + i=findKey(key$) + if i<>-1 then + keys$[i] = "" + end if +end subroutine + +function freeKey() + # find index of a free element in the array + for n = 0 to keys$[?]-1 + if keys$[n]="" then return n + next n + redim keys$[n+1] + redim values$[n+1] + return n +end function + +function findKey(key$) + # return index or -1 if not found + for n = 0 to keys$[?]-1 + if key$=keys$[n] then return n + next n + return -1 +end function + +function getValue$(key$) + # return a value by the key or "" if not existing + i=findKey(key$) + if i=-1 then + return "" + end if + return values$[i] +end function + +function countKeys() + # return number of items + # remember to skip the empty keys (deleted ones) + k = 0 + for n = 0 to keys$[?] -1 + if keys$[n]<>"" then k++ + next n + return k +end function + +function getValueByIndex$(i) + # get a value by the index + # remember to skip the empty keys (deleted ones) + k = 0 + for n = 0 to keys$[?] -1 + if keys$[n]<>"" then + if k=i then return values$[k] + k++ + endif + next n + return "" +end function + +function getKeyByIndex$(i) + # get a key by the index + # remember to skip the empty keys (deleted ones) + k = 0 + for n = 0 to keys$[?] -1 + if keys$[n]<>"" then + if k=i then return keys$[k] + k++ + endif + next n + return "" +end function diff --git a/Task/Associative-array-Creation/BBC-BASIC/associative-array-creation.bbc b/Task/Associative-array-Creation/BBC-BASIC/associative-array-creation.bbc new file mode 100644 index 0000000000..3e5570f360 --- /dev/null +++ b/Task/Associative-array-Creation/BBC-BASIC/associative-array-creation.bbc @@ -0,0 +1,21 @@ + REM Store some values with their keys: + PROCputdict(mydict$, "FF0000", "red") + PROCputdict(mydict$, "00FF00", "green") + PROCputdict(mydict$, "0000FF", "blue") + + REM Retrieve some values using their keys: + PRINT FNgetdict(mydict$, "green") + PRINT FNgetdict(mydict$, "red") + END + + DEF PROCputdict(RETURN dict$, value$, key$) + IF dict$ = "" dict$ = CHR$(0) + dict$ += key$ + CHR$(1) + value$ + CHR$(0) + ENDPROC + + DEF FNgetdict(dict$, key$) + LOCAL I%, J% + I% = INSTR(dict$, CHR$(0) + key$ + CHR$(1)) + IF I% = 0 THEN = "" ELSE I% += LEN(key$) + 2 + J% = INSTR(dict$, CHR$(0), I%) + = MID$(dict$, I%, J% - I%) diff --git a/Task/Associative-array-Creation/Batch-File/associative-array-creation.bat b/Task/Associative-array-Creation/Batch-File/associative-array-creation.bat new file mode 100644 index 0000000000..43ce3e260f --- /dev/null +++ b/Task/Associative-array-Creation/Batch-File/associative-array-creation.bat @@ -0,0 +1,24 @@ +::assocarrays.cmd +@echo off +setlocal ENABLEDELAYEDEXPANSION +set array.dog=1 +set array.cat=2 +set array.wolf=3 +set array.cow=4 +for %%i in (dog cat wolf cow) do call :showit array.%%i !array.%%i! +set c=-27 +call :mkarray sicko flu 5 measles 6 mumps 7 bromodrosis 8 +for %%i in (flu measles mumps bromodrosis) do call :showit "sicko^&%%i" !sicko^&%%i! +endlocal +goto :eof + +:mkarray +set %1^&%2=%3 +shift /2 +shift /2 +if "%2" neq "" goto :mkarray +goto :eof + +:showit +echo %1 = %2 +goto :eof diff --git a/Task/Associative-array-Creation/Brat/associative-array-creation.brat b/Task/Associative-array-Creation/Brat/associative-array-creation.brat new file mode 100644 index 0000000000..097aeeb78f --- /dev/null +++ b/Task/Associative-array-Creation/Brat/associative-array-creation.brat @@ -0,0 +1,8 @@ +h = [:] #Empty hash + +h[:a] = 1 #Assign value +h[:b] = [1 2 3] #Assign another value + +h2 = [a: 1, b: [1 2 3], 10 : "ten"] #Initialized hash + +h2[:b][2] #Returns 3 diff --git a/Task/Associative-array-Iteration/BBC-BASIC/associative-array-iteration.bbc b/Task/Associative-array-Iteration/BBC-BASIC/associative-array-iteration.bbc new file mode 100644 index 0000000000..846e2f4225 --- /dev/null +++ b/Task/Associative-array-Iteration/BBC-BASIC/associative-array-iteration.bbc @@ -0,0 +1,26 @@ + REM Store some values with their keys: + PROCputdict(mydict$, "FF0000", "red") + PROCputdict(mydict$, "00FF00", "green") + PROCputdict(mydict$, "0000FF", "blue") + + REM Iterate through the dictionary: + i% = 1 + REPEAT + i% = FNdict(mydict$, i%, v$, k$) + PRINT v$, k$ + UNTIL i% = 0 + END + + DEF PROCputdict(RETURN dict$, value$, key$) + IF dict$ = "" dict$ = CHR$(0) + dict$ += key$ + CHR$(1) + value$ + CHR$(0) + ENDPROC + + DEF FNdict(dict$, I%, RETURN value$, RETURN key$) + LOCAL J%, K% + J% = INSTR(dict$, CHR$(1), I%) + K% = INSTR(dict$, CHR$(0), J%) + value$ = MID$(dict$, I%+1, J%-I%-1) + key$ = MID$(dict$, J%+1, K%-J%-1) + IF K% >= LEN(dict$) THEN K% = 0 + = K% diff --git a/Task/Associative-array-Iteration/Brat/associative-array-iteration.brat b/Task/Associative-array-Iteration/Brat/associative-array-iteration.brat new file mode 100644 index 0000000000..7d99434094 --- /dev/null +++ b/Task/Associative-array-Iteration/Brat/associative-array-iteration.brat @@ -0,0 +1,16 @@ +h = [ hello: 1 world: 2 :! : 3] + +#Iterate over key, value pairs +h.each { k, v | + p "Key: #{k} Value: #{v}" +} + +#Iterate over keys +h.each_key { k | + p "Key: #{k}" +} + +#Iterate over values +h.each_value { v | + p "Value: #{v}" +} diff --git a/Task/Atomic-updates/BBC-BASIC/atomic-updates.bbc b/Task/Atomic-updates/BBC-BASIC/atomic-updates.bbc new file mode 100644 index 0000000000..d40c297608 --- /dev/null +++ b/Task/Atomic-updates/BBC-BASIC/atomic-updates.bbc @@ -0,0 +1,52 @@ + INSTALL @lib$+"TIMERLIB" + + DIM Buckets%(100) + FOR i% = 1 TO 100 : Buckets%(i%) = RND(10) : NEXT + + tid0% = FN_ontimer(10, PROCdisplay, 1) + tid1% = FN_ontimer(11, PROCflatten, 1) + tid2% = FN_ontimer(12, PROCroughen, 1) + + ON ERROR PROCcleanup : REPORT : PRINT : END + ON CLOSE PROCcleanup : QUIT + + REPEAT + WAIT 0 + UNTIL FALSE + END + + DEF PROCdisplay + PRINT SUM(Buckets%()) " ", MOD(Buckets%()) + ENDPROC + + DEF PROCflatten + LOCAL d%, i%, j% + REPEAT + i% = RND(100) + j% = RND(100) + UNTIL i%<>j% + d% = Buckets%(i%) - Buckets%(j%) + PROCatomicupdate(Buckets%(i%), Buckets%(j%), d% DIV 4) + ENDPROC + + DEF PROCroughen + LOCAL i%, j% + REPEAT + i% = RND(100) + j% = RND(100) + UNTIL i%<>j% + PROCatomicupdate(Buckets%(i%), Buckets%(j%), RND(10)) + ENDPROC + + DEF PROCatomicupdate(RETURN src%, RETURN dst%, amt%) + IF amt% > src% amt% = src% + IF amt% < -dst% amt% = -dst% + src% -= amt% + dst% += amt% + ENDPROC + + DEF PROCcleanup + PROC_killtimer(tid0%) + PROC_killtimer(tid1%) + PROC_killtimer(tid2%) + ENDPROC diff --git a/Task/Average-loop-length/BBC-BASIC/average-loop-length.bbc b/Task/Average-loop-length/BBC-BASIC/average-loop-length.bbc new file mode 100644 index 0000000000..07d1f563ac --- /dev/null +++ b/Task/Average-loop-length/BBC-BASIC/average-loop-length.bbc @@ -0,0 +1,33 @@ + @% = &2040A + MAX_N = 20 + TIMES = 1000000 + + FOR n = 1 TO MAX_N + avg = FNtest(n, TIMES) + theory = FNanalytical(n) + diff = (avg / theory - 1) * 100 + PRINT STR$(n), avg, theory, diff "%" + NEXT + END + + DEF FNanalytical(n) + LOCAL i, s + FOR i = 1 TO n + s += FNfactorial(n) / n^i / FNfactorial(n-i) + NEXT + = s + + DEF FNtest(n, times) + LOCAL i, b, c, x + FOR i = 1 TO times + x = 1 : b = 0 + WHILE (b AND x) = 0 + c += 1 + b OR= x + x = 1 << (RND(n) - 1) + ENDWHILE + NEXT + = c / times + + DEF FNfactorial(n) + IF n=1 OR n=0 THEN =1 ELSE = n * FNfactorial(n-1) diff --git a/Task/Averages-Arithmetic-mean/BBC-BASIC/averages-arithmetic-mean.bbc b/Task/Averages-Arithmetic-mean/BBC-BASIC/averages-arithmetic-mean.bbc new file mode 100644 index 0000000000..e8c9d74ea1 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/BBC-BASIC/averages-arithmetic-mean.bbc @@ -0,0 +1,28 @@ + REM specific functions for the array/vector types + + REM Byte Array + DEF FN_Mean_Arithmetic&(n&()) + = SUM(n&()) / (DIM(n&(),1)+1) + + REM Integer Array + DEF FN_Mean_Arithmetic%(n%()) + = SUM(n%()) / (DIM(n%(),1)+1) + + REM Float 40 array + DEF FN_Mean_Arithmetic(n()) + = SUM(n()) / (DIM(n(),1)+1) + + REM A String array + DEF FN_Mean_Arithmetic$(n$()) + LOCAL I%, S%, sum, Q% + S% = DIM(n$(),1) + FOR I% = 0 TO S% + Q% = TRUE + ON ERROR LOCAL Q% = FALSE + IF Q% sum += EVAL(n$(I%)) + NEXT + = sum / (S%+1) + + REM Float 64 array + DEF FN_Mean_Arithmetic#(n#()) + = SUM(n#()) / (DIM(n#(),1)+1) diff --git a/Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-1.bracmat b/Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-1.bracmat new file mode 100644 index 0000000000..202354d2ce --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-1.bracmat @@ -0,0 +1,24 @@ +(mean1= + sum length n +. 0:?sum:?length + & whl + ' ( !arg:%?n ?arg + & 1+!length:?length + & !n+!sum:?sum + ) + & !sum*!length^-1 +); + +(mean2= + sum length n +. 0:?sum:?length + & !arg + : ? + ( #%@?n + & 1+!length:?length + & !n+!sum:?sum + & ~ + ) + ? + | !sum*!length^-1 +); diff --git a/Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-2.bracmat b/Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-2.bracmat new file mode 100644 index 0000000000..89d9ef7112 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Bracmat/averages-arithmetic-mean-2.bracmat @@ -0,0 +1,6 @@ +( :?test +& 1000000:?Length +& whl'(!Length+-1:?Length:>0&!Length !test:?test) +& out$mean1$!test +& out$mean2$!test +) diff --git a/Task/Averages-Arithmetic-mean/Brainf---/averages-arithmetic-mean.bf b/Task/Averages-Arithmetic-mean/Brainf---/averages-arithmetic-mean.bf new file mode 100644 index 0000000000..92dd39119f --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Brainf---/averages-arithmetic-mean.bf @@ -0,0 +1 @@ +>,[-<+>>+<],<[->-<]>[-->+<]>. diff --git a/Task/Averages-Arithmetic-mean/Brat/averages-arithmetic-mean.brat b/Task/Averages-Arithmetic-mean/Brat/averages-arithmetic-mean.brat new file mode 100644 index 0000000000..6a62a69cb7 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Brat/averages-arithmetic-mean.brat @@ -0,0 +1,5 @@ +mean = { list | + true? list.empty?, 0, { list.reduce(0, :+) / list.length } +} + +p mean 1.to 10 #Prints 5.5 diff --git a/Task/Averages-Arithmetic-mean/Burlesque/averages-arithmetic-mean.blq b/Task/Averages-Arithmetic-mean/Burlesque/averages-arithmetic-mean.blq new file mode 100644 index 0000000000..d6c3038797 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Burlesque/averages-arithmetic-mean.blq @@ -0,0 +1,4 @@ +blsq ) {1 2 2.718 3 3.142}av +2.372 +blsq ) {}av +NaN diff --git a/Task/Averages-Mean-angle/BBC-BASIC/averages-mean-angle.bbc b/Task/Averages-Mean-angle/BBC-BASIC/averages-mean-angle.bbc new file mode 100644 index 0000000000..a070c06b5c --- /dev/null +++ b/Task/Averages-Mean-angle/BBC-BASIC/averages-mean-angle.bbc @@ -0,0 +1,20 @@ + *FLOAT 64 + DIM angles(3) + angles() = 350,10 + PRINT FNmeanangle(angles(), 2) + angles() = 90,180,270,360 + PRINT FNmeanangle(angles(), 4) + angles() = 10,20,30 + PRINT FNmeanangle(angles(), 3) + END + + DEF FNmeanangle(angles(), N%) + LOCAL I%, sumsin, sumcos + FOR I% = 0 TO N%-1 + sumsin += SINRADangles(I%) + sumcos += COSRADangles(I%) + NEXT + = DEGFNatan2(sumsin, sumcos) + + DEF FNatan2(y,x) : ON ERROR LOCAL = SGN(y)*PI/2 + IF x>0 THEN = ATN(y/x) ELSE IF y>0 THEN = ATN(y/x)+PI ELSE = ATN(y/x)-PI diff --git a/Task/Averages-Median/BBC-BASIC/averages-median.bbc b/Task/Averages-Median/BBC-BASIC/averages-median.bbc new file mode 100644 index 0000000000..e8538172f0 --- /dev/null +++ b/Task/Averages-Median/BBC-BASIC/averages-median.bbc @@ -0,0 +1,16 @@ + INSTALL @lib$+"SORTLIB" + Sort% = FN_sortinit(0,0) + + DIM a(6), b(5) + a() = 4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2 + b() = 4.1, 7.2, 1.7, 9.3, 4.4, 3.2 + + PRINT "Median of a() is " ; FNmedian(a()) + PRINT "Median of b() is " ; FNmedian(b()) + END + + DEF FNmedian(a()) + LOCAL C% + C% = DIM(a(),1) + 1 + CALL Sort%, a(0) + = (a(C% DIV 2) + a((C%-1) DIV 2)) / 2 diff --git a/Task/Averages-Median/Bracmat/averages-median.bracmat b/Task/Averages-Median/Bracmat/averages-median.bracmat new file mode 100644 index 0000000000..d8a19b0c04 --- /dev/null +++ b/Task/Averages-Median/Bracmat/averages-median.bracmat @@ -0,0 +1,25 @@ +(median= + begin decimals end int list med med1 med2 num number +. 0:?list + & whl + ' ( @( !arg + : ? + ((%@:~" ":~",") ?:?number) + ((" "|",") ?arg|:?arg) + ) + & @( !number + : ( #?int "." [?begin #?decimals [?end + & !int+!decimals*10^(!begin+-1*!end):?num + | ?num + ) + ) + & (!num.)+!list:?list + ) + & !list:?+[?end + & ( !end*1/2:~/ + & !list:?+[!(=1/2*!end+-1)+(?med1.)+(?med2.)+? + & !med1*1/2+!med2*1/2:?med + | !list:?+[(div$(1/2*!end,1))+(?med.)+? + ) + & !med +); diff --git a/Task/Averages-Mode/BBC-BASIC/averages-mode.bbc b/Task/Averages-Mode/BBC-BASIC/averages-mode.bbc new file mode 100644 index 0000000000..e70c27599c --- /dev/null +++ b/Task/Averages-Mode/BBC-BASIC/averages-mode.bbc @@ -0,0 +1,33 @@ + DIM a(10), b(4) + a() = 1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17 + b() = 1, 2, 4, 4, 1 + + DIM modes(10) + PRINT "Mode(s) of a() = " ; + FOR i% = 1 TO FNmodes(a(), modes()) + PRINT ; modes(i%) " " ; + NEXT + PRINT + PRINT "Mode(s) of b() = " ; + FOR i% = 1 TO FNmodes(b(), modes()) + PRINT ; modes(i%) " " ; + NEXT + PRINT + END + + DEF FNmodes(a(), m()) + LOCAL I%, J%, N%, c%(), max% + N% = DIM(a(),1) + IF N% = 0 THEN m(1) = a(0) : = 1 + DIM c%(N%) + FOR I% = 0 TO N%-1 + FOR J% = I%+1 TO N% + IF a(I%) = a(J%) c%(I%) += 1 + NEXT + IF c%(I%) > max% max% = c%(I%) + NEXT I% + J% = 0 + FOR I% = 0 TO N% + IF c%(I%) = max% J% += 1 : m(J%) = a(I%) + NEXT + = J% diff --git a/Task/Averages-Pythagorean-means/BBC-BASIC/averages-pythagorean-means.bbc b/Task/Averages-Pythagorean-means/BBC-BASIC/averages-pythagorean-means.bbc new file mode 100644 index 0000000000..b7ab89c8a3 --- /dev/null +++ b/Task/Averages-Pythagorean-means/BBC-BASIC/averages-pythagorean-means.bbc @@ -0,0 +1,23 @@ + DIM a(9) + a() = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + PRINT "Arithmetic mean = " ; FNarithmeticmean(a()) + PRINT "Geometric mean = " ; FNgeometricmean(a()) + PRINT "Harmonic mean = " ; FNharmonicmean(a()) + END + + DEF FNarithmeticmean(a()) + = SUM(a()) / (DIM(a(),1)+1) + + DEF FNgeometricmean(a()) + LOCAL a, I% + a = 1 + FOR I% = 0 TO DIM(a(),1) + a *= a(I%) + NEXT + = a ^ (1/(DIM(a(),1)+1)) + + DEF FNharmonicmean(a()) + LOCAL b() + DIM b(DIM(a(),1)) + b() = 1/a() + = (DIM(a(),1)+1) / SUM(b()) diff --git a/Task/Averages-Root-mean-square/BBC-BASIC/averages-root-mean-square.bbc b/Task/Averages-Root-mean-square/BBC-BASIC/averages-root-mean-square.bbc new file mode 100644 index 0000000000..db57ea5109 --- /dev/null +++ b/Task/Averages-Root-mean-square/BBC-BASIC/averages-root-mean-square.bbc @@ -0,0 +1,7 @@ + DIM array(9) + array() = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + + PRINT FNrms(array()) + END + + DEF FNrms(a()) = MOD(a()) / SQR(DIM(a(),1)+1) diff --git a/Task/Averages-Simple-moving-average/BBC-BASIC/averages-simple-moving-average.bbc b/Task/Averages-Simple-moving-average/BBC-BASIC/averages-simple-moving-average.bbc new file mode 100644 index 0000000000..a14cb30d73 --- /dev/null +++ b/Task/Averages-Simple-moving-average/BBC-BASIC/averages-simple-moving-average.bbc @@ -0,0 +1,18 @@ + MAXPERIOD = 10 + FOR n = 1 TO 5 + PRINT "Number = ";n TAB(12) " SMA3 = ";FNsma(n,3) TAB(30) " SMA5 = ";FNsma(n,5) + NEXT + FOR n = 5 TO 1 STEP -1 + PRINT "Number = ";n TAB(12) " SMA3 = ";FNsma(n,3) TAB(30) " SMA5 = ";FNsma(n,5) + NEXT + END + + DEF FNsma(number, period%) + PRIVATE nums(), accum(), index%(), window%() + DIM nums(MAXPERIOD,MAXPERIOD), accum(MAXPERIOD) + DIM index%(MAXPERIOD), window%(MAXPERIOD) + accum(period%) += number - nums(period%,index%(period%)) + nums(period%,index%(period%)) = number + index%(period%) = (index%(period%) + 1) MOD period% + IF window%(period%)0 + & mod$(!someNumber.!N):?j + & div$(!someNumber.!N):?someNumber + & !S:?a [!j ?m [!N ?z + & !z !m !a:?S + ) + & !S + ) +& 0:?L +& whl + ' ( generate$!L:?S + & put$(str$(!S ":")) + & out + $ (!S:!bal&Balanced|"Not balanced") + & !L+1:<11:?L + ) +); diff --git a/Task/Balanced-brackets/Brat/balanced-brackets.brat b/Task/Balanced-brackets/Brat/balanced-brackets.brat new file mode 100644 index 0000000000..45065fdb72 --- /dev/null +++ b/Task/Balanced-brackets/Brat/balanced-brackets.brat @@ -0,0 +1,31 @@ +string.prototype.balanced? = { + brackets = [] + balanced = true + + my.dice.each_while { c | + true? c == "[" + { brackets << c } + { true? c == "]" + { last = brackets.pop + false? last == "[" + { balanced = false } + } + } + + balanced + } + + true? brackets.empty? + { balanced } + { false } +} + +generate_brackets = { n | (n.of("[") + n.of("]")).shuffle.join } + +1.to 10 { n | + test = generate_brackets n + + true? test.balanced? + { p "#{test} is balanced" } + { p "#{test} is not balanced" } +} diff --git a/Task/Best-shuffle/BBC-BASIC/best-shuffle.bbc b/Task/Best-shuffle/BBC-BASIC/best-shuffle.bbc new file mode 100644 index 0000000000..46132eb712 --- /dev/null +++ b/Task/Best-shuffle/BBC-BASIC/best-shuffle.bbc @@ -0,0 +1,30 @@ + a$ = "abracadabra" : b$ = FNshuffle(a$) : PRINT a$ " -> " b$ FNsame(a$,b$) + a$ = "seesaw" : b$ = FNshuffle(a$) : PRINT a$ " -> " b$ FNsame(a$,b$) + a$ = "elk" : b$ = FNshuffle(a$) : PRINT a$ " -> " b$ FNsame(a$,b$) + a$ = "grrrrrr" : b$ = FNshuffle(a$) : PRINT a$ " -> " b$ FNsame(a$,b$) + a$ = "up" : b$ = FNshuffle(a$) : PRINT a$ " -> " b$ FNsame(a$,b$) + a$ = "a" : b$ = FNshuffle(a$) : PRINT a$ " -> " b$ FNsame(a$,b$) + END + + DEF FNshuffle(s$) + LOCAL i%, j%, l%, s%, t%, t$ + t$ = s$ : s% = !^s$ : t% = !^t$ : l% = LEN(t$) + FOR i% = 0 TO l%-1 : SWAP t%?i%,t%?(RND(l%)-1) : NEXT + FOR i% = 0 TO l%-1 + FOR j% = 0 TO l%-1 + IF i%<>j% THEN + IF t%?i%<>s%?j% IF s%?i%<>t%?j% THEN + SWAP t%?i%,t%?j% + EXIT FOR + ENDIF + ENDIF + NEXT + NEXT i% + = t$ + + DEF FNsame(s$, t$) + LOCAL i%, n% + FOR i% = 1 TO LEN(s$) + IF MID$(s$,i%,1)=MID$(t$,i%,1) n% += 1 + NEXT + = " (" + STR$(n%) + ")" diff --git a/Task/Best-shuffle/Bracmat/best-shuffle-1.bracmat b/Task/Best-shuffle/Bracmat/best-shuffle-1.bracmat new file mode 100644 index 0000000000..5adbb993a8 --- /dev/null +++ b/Task/Best-shuffle/Bracmat/best-shuffle-1.bracmat @@ -0,0 +1,28 @@ + ( shuffle + = m car cdr todo a z count string + . !arg:(@(?:%?car ?cdr).?todo) + & !Count:?count + & ( @( !todo + : ?a + (%@:~!car:?m) + ( ?z + & shuffle$(!cdr.str$(!a !z)) + : (= 0 THEN + PRINT "The value "; secret% " was found at index "; index% + ELSE + PRINT "The value "; secret% " was not found" + ENDIF + END + + REM Search ordered array A%() for the value S% from index B% to T% + DEF FNwhere(A%(), S%, B%, T%) + LOCAL H% + H% = 2 + WHILE H%<(T%-B%) H% *= 2:ENDWHILE + H% /= 2 + REPEAT + IF (B%+H%)<=T% IF S%>=A%(B%+H%) B% += H% + H% /= 2 + UNTIL H%=0 + IF S%=A%(B%) THEN = B% ELSE = -1 diff --git a/Task/Binary-search/Brat/binary-search.brat b/Task/Binary-search/Brat/binary-search.brat new file mode 100644 index 0000000000..6d86f7d3f5 --- /dev/null +++ b/Task/Binary-search/Brat/binary-search.brat @@ -0,0 +1,31 @@ +binary_search = { search_array, value, low, high | + true? high < low + { null } + { + mid = ((low + high) / 2).to_i + true? search_array[mid] > value + { binary_search search_array, value, low, mid - 1 } + { true? search_array[mid] < value + { binary_search search_array, value, mid + 1, high } + { mid } + } + } +} + +#Populate array +numbers = [] +1000.times { i | numbers << random i } + +#Sort the array +numbers.sort! + +#Find a number +x = random 1000 + +p "Looking for #{x}" + +index = binary_search numbers, x, 0, numbers.length + +null? index + { p "Not found" } + { p "Found at index: #{index}" } diff --git a/Task/Binary-strings/BBC-BASIC/binary-strings.bbc b/Task/Binary-strings/BBC-BASIC/binary-strings.bbc new file mode 100644 index 0000000000..5f58be0751 --- /dev/null +++ b/Task/Binary-strings/BBC-BASIC/binary-strings.bbc @@ -0,0 +1,15 @@ + A$ = CHR$(0) + CHR$(1) + CHR$(254) + CHR$(255) : REM assignment + B$ = A$ : REM clone / copy + IF A$ = B$ THEN PRINT "Strings are equal" : REM comparison + IF A$ = "" THEN PRINT "String is empty" : REM Check if empty + A$ += CHR$(128) : REM Append a byte + S$ = MID$(A$, S%, L%) : REM Extract a substring + C$ = A$ + B$ : REM Join strings + + REM To replace every occurrence of a byte: + old$ = CHR$(1) + new$ = CHR$(5) + REPEAT + I% = INSTR(A$, old$) + IF I% MID$(A$, I%, 1) = new$ + UNTIL I% = 0 diff --git a/Task/Bitcoin-address-validation/0DESCRIPTION b/Task/Bitcoin-address-validation/0DESCRIPTION new file mode 100644 index 0000000000..45655b00a7 --- /dev/null +++ b/Task/Bitcoin-address-validation/0DESCRIPTION @@ -0,0 +1,22 @@ +Write a program that takes a [[wp:bitcoin|bitcoin address]] as argument, and checks whether or not this address is valid. + +A bitcoin address uses a base58 encoding, which uses an alphabet of the characters 0 .. 9, A ..Z, a .. z, but without the four characters 0, O, I and l. + +With this encoding, a bitcoin address encodes 25 bytes: +* the first byte is the version number, which will be zero for this task ; +* the next twenty bytes are a [[RIPEMD-160]] digest, but you don't have to know that for this task: you can consider them a pure arbitrary data ; +* the last four bytes are a checksum check. They are the first four bytes of a double [[SHA-256]] digest of the previous 21 bytes. + +To check the bitcoin address, you must read the first twenty-one bytes, compute the checksum, and check that it corresponds to the last four bytes. + +The program can either return a boolean value or throw an exception when not valid. + +You can use a digest library for [[SHA-256]]. + +Here is an example of a bitcoin address: + +1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i + +It does not belong to anyone. It is part of the test suite of the bitcoin software. You can change a few characters in this string and check that it will fail the test. + +''extra credit'': allow your code to deal with [http://bitcoin.stackexchange.com/questions/3059/what-is-a-compressed-bitcoin-key compressed keys] diff --git a/Task/Bitcoin-address-validation/C/bitcoin-address-validation.c b/Task/Bitcoin-address-validation/C/bitcoin-address-validation.c new file mode 100644 index 0000000000..11e7ce1e08 --- /dev/null +++ b/Task/Bitcoin-address-validation/C/bitcoin-address-validation.c @@ -0,0 +1,61 @@ +#include +#include +#include + +const char *coin_err; +#define bail(s) { coin_err = s; return 0; } + +int unbase58(const char *s, unsigned char *out) { + static const char *tmpl = "123456789" + "ABCDEFGHJKLMNPQRSTUVWXYZ" + "abcdefghijkmnopqrstuvwxyz"; + int i, j, c; + const char *p; + + memset(out, 0, 25); + for (i = 0; s[i]; i++) { + if (!(p = strchr(tmpl, s[i]))) + bail("bad char"); + + c = p - tmpl; + for (j = 25; j--; ) { + c += 58 * out[j]; + out[j] = c % 256; + c /= 256; + } + + if (c) bail("address too long"); + } + + return 1; +} + +int valid(const char *s) { + unsigned char dec[32], d1[SHA256_DIGEST_LENGTH], d2[SHA256_DIGEST_LENGTH]; + + coin_err = ""; + if (!unbase58(s, dec)) return 0; + + SHA256(SHA256(dec, 21, d1), SHA256_DIGEST_LENGTH, d2); + + if (memcmp(dec + 21, d2, 4)) + bail("bad digest"); + + return 1; +} + +int main (void) { + const char *s[] = { + "1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", + "1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nJ9", + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62I", + 0 }; + int i; + for (i = 0; s[i]; i++) { + int status = valid(s[i]); + printf("%s: %s\n", s[i], status ? "Ok" : coin_err); + } + + return 0; +} diff --git a/Task/Bitcoin-address-validation/Perl/bitcoin-address-validation.pl b/Task/Bitcoin-address-validation/Perl/bitcoin-address-validation.pl new file mode 100644 index 0000000000..ae82cdfa43 --- /dev/null +++ b/Task/Bitcoin-address-validation/Perl/bitcoin-address-validation.pl @@ -0,0 +1,26 @@ +my @b58 = qw{ + 1 2 3 4 5 6 7 8 9 + A B C D E F G H J K L M N P Q R S T U V W X Y Z + a b c d e f g h i j k m n o p q r s t u v w x y z +}; +my %b58 = map { $b58[$_] => $_ } 0 .. 57; + +sub unbase58 { + use integer; + my @out; + for my $c ( map { $b58{$_} } shift =~ /./g ) { + for (my $j = 25; $j--; ) { + $c += 58 * ($out[$j] // 0); + $out[$j] = $c % 256; + $c /= 256; + } + } + return @out; +} + +sub check_bitcoin_address { + use Digest::SHA qw(sha256); + my @byte = unbase58 shift; + die unless join('', map { chr } @byte[21..24]) eq + substr sha256(sha256 pack 'C*', @byte[0..20]), 0, 4; +} diff --git a/Task/Bitcoin-address-validation/Python/bitcoin-address-validation-1.py b/Task/Bitcoin-address-validation/Python/bitcoin-address-validation-1.py new file mode 100644 index 0000000000..ddbb4be08b --- /dev/null +++ b/Task/Bitcoin-address-validation/Python/bitcoin-address-validation-1.py @@ -0,0 +1,20 @@ +from hashlib import sha256 + +digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' + +def decode_base58(bc, length): + n = 0 + for char in bc: + n = n * 58 + digits58.index(char) + return n.to_bytes(length, 'big') + +def check_bc(bc): + bcbytes = decode_base58(bc, 25) + return bcbytes[-4:] == sha256(sha256(bcbytes[:-4]).digest()).digest()[:4] + +if __name__ == '__main__': + bc = '1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i' + assert check_bc(bc) + assert not check_bc( bc.replace('N', 'P', 1) ) + assert check_bc('1111111111111111111114oLvT2') + assert check_bc("17NdbrSGoUotzeGCcMMCqnFkEvLymoou9j") diff --git a/Task/Bitcoin-address-validation/Python/bitcoin-address-validation-2.py b/Task/Bitcoin-address-validation/Python/bitcoin-address-validation-2.py new file mode 100644 index 0000000000..da68d60c34 --- /dev/null +++ b/Task/Bitcoin-address-validation/Python/bitcoin-address-validation-2.py @@ -0,0 +1,6 @@ +>>> n = 2491969579123783355964723219455906992268673266682165637887 +>>> length = 25 +>>> list( reversed(range(length)) ) +[24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] +>>> assert n.to_bytes(length, 'big') == bytes( (n >> i*8) & 0xff for i in reversed(range(length))) +>>> diff --git a/Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-1.tcl b/Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-1.tcl new file mode 100644 index 0000000000..b47d509f4f --- /dev/null +++ b/Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-1.tcl @@ -0,0 +1,34 @@ +package require sha256 + +# Generate a large and boring piece of code to do the decoding of +# base58-encoded data. +apply {{} { + set chars "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" + set i -1 + foreach c [split $chars ""] { + lappend map $c "return -level 0 [incr i]" + } + lappend map default {return -code error "bad character \"$c\""} + proc base58decode str [string map [list @BODY@ [list $map]] { + set num 0 + set count [expr {ceil(log(58**[string length $str])/log(256))}] + foreach c [split $str {}] { + set num [expr {$num*58+[switch $c @BODY@]}] + } + for {set i 0} {$i < $count} {incr i} { + append result [binary format c [expr {$num & 255}]] + set num [expr {$num >> 8}] + } + return [string reverse $result] + }] +}} + +# How to check bitcoin address validity +proc bitcoin_addressValid {address} { + set a [base58decode $address] + set ck [sha2::sha256 -bin [sha2::sha256 -bin [string range $a 0 end-4]]] + if {[string range $a end-3 end] ne [string range $ck 0 3]} { + return -code error "signature does not match" + } + return "$address is ok" +} diff --git a/Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-2.tcl b/Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-2.tcl new file mode 100644 index 0000000000..8972b105b6 --- /dev/null +++ b/Task/Bitcoin-address-validation/Tcl/bitcoin-address-validation-2.tcl @@ -0,0 +1,2 @@ +puts [bitcoin_addressValid 1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9] +puts [bitcoin_addressValid 1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i] diff --git a/Task/Bitmap-B-zier-curves-Cubic/0DESCRIPTION b/Task/Bitmap-B-zier-curves-Cubic/0DESCRIPTION new file mode 100644 index 0000000000..478a5dcff3 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/0DESCRIPTION @@ -0,0 +1,2 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, and the draw_line function defined in [[Bresenham's_line_algorithm|this other one]], draw a '''cubic bezier curve''' +([[wp:Bezier_curves#Cubic_B.C3.A9zier_curves|definition on Wikipedia]]). diff --git a/Task/Bitmap-B-zier-curves-Cubic/1META.yaml b/Task/Bitmap-B-zier-curves-Cubic/1META.yaml new file mode 100644 index 0000000000..fb36ead2f0 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Raster graphics operations diff --git a/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic.alg b/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic.alg new file mode 100644 index 0000000000..7a8ad63b2d --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic.alg @@ -0,0 +1,34 @@ +PRAGMAT READ "Bresenhams_line_algorithm.a68" PRAGMAT; + +cubic bezier OF class image := + ( REF IMAGE picture, + POINT p1, p2, p3, p4, + PIXEL color, + UNION(INT, VOID) in n + )VOID: +BEGIN + INT n = (in n|(INT n):n|20); # default 20 # + [0:n]POINT points; + FOR i FROM LWB points TO UPB points DO + REAL t = i / n, + a = (1 - t)**3, + b = 3 * t * (1 - t)**2, + c = 3 * t**2 * (1 - t), + d = t**3; + x OF points [i] := ENTIER (0.5 + a * x OF p1 + b * x OF p2 + c * x OF p3 + d * x OF p4); + y OF points [i] := ENTIER (0.5 + a * y OF p1 + b * y OF p2 + c * y OF p3 + d * y OF p4) + OD; + FOR i FROM LWB points TO UPB points - 1 DO + (line OF class image)(picture, points (i), points (i + 1), color) + OD +END # cubic bezier #; + +# +The following test +# +IF test THEN + REF IMAGE x = INIT LOC[16,16]PIXEL; + (fill OF class image)(x, (white OF class image)); + (cubic bezier OF class image)(x, (16, 1), (1, 4), (3, 16), (15, 11), (black OF class image), EMPTY); + (print OF class image) (x) +FI diff --git a/Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-1.ada b/Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-1.ada new file mode 100644 index 0000000000..520ce6f248 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-1.ada @@ -0,0 +1,24 @@ +procedure Cubic_Bezier + ( Picture : in out Image; + P1, P2, P3, P4 : Point; + Color : Pixel; + N : Positive := 20 + ) is + Points : array (0..N) of Point; +begin + for I in Points'Range loop + declare + T : constant Float := Float (I) / Float (N); + A : constant Float := (1.0 - T)**3; + B : constant Float := 3.0 * T * (1.0 - T)**2; + C : constant Float := 3.0 * T**2 * (1.0 - T); + D : constant Float := T**3; + begin + Points (I).X := Positive (A * Float (P1.X) + B * Float (P2.X) + C * Float (P3.X) + D * Float (P4.X)); + Points (I).Y := Positive (A * Float (P1.Y) + B * Float (P2.Y) + C * Float (P3.Y) + D * Float (P4.Y)); + end; + end loop; + for I in Points'First..Points'Last - 1 loop + Line (Picture, Points (I), Points (I + 1), Color); + end loop; +end Cubic_Bezier; diff --git a/Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-2.ada b/Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-2.ada new file mode 100644 index 0000000000..7e2a86272d --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Ada/bitmap-b-zier-curves-cubic-2.ada @@ -0,0 +1,5 @@ + X : Image (1..16, 1..16); +begin + Fill (X, White); + Cubic_Bezier (X, (16, 1), (1, 4), (3, 16), (15, 11), Black); + Print (X); diff --git a/Task/Bitmap-B-zier-curves-Cubic/BBC-BASIC/bitmap-b-zier-curves-cubic.bbc b/Task/Bitmap-B-zier-curves-Cubic/BBC-BASIC/bitmap-b-zier-curves-cubic.bbc new file mode 100644 index 0000000000..dd1f75d675 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/BBC-BASIC/bitmap-b-zier-curves-cubic.bbc @@ -0,0 +1,52 @@ + Width% = 200 + Height% = 200 + + REM Set window size: + VDU 23,22,Width%;Height%;8,16,16,128 + + REM Draw cubic Bézier curve: + PROCbeziercubic(160,150, 10,120, 30,0, 150,50, 20, 0,0,0) + END + + DEF PROCbeziercubic(x1,y1,x2,y2,x3,y3,x4,y4,n%,r%,g%,b%) + LOCAL i%, t, t1, a, b, c, d, p{()} + DIM p{(n%) x%,y%} + + FOR i% = 0 TO n% + t = i% / n% + t1 = 1 - t + a = t1^3 + b = 3 * t * t1^2 + c = 3 * t^2 * t1 + d = t^3 + p{(i%)}.x% = INT(a * x1 + b * x2 + c * x3 + d * x4 + 0.5) + p{(i%)}.y% = INT(a * y1 + b * y2 + c * y3 + d * y4 + 0.5) + NEXT + + FOR i% = 0 TO n%-1 + PROCbresenham(p{(i%)}.x%,p{(i%)}.y%,p{(i%+1)}.x%,p{(i%+1)}.y%, \ + \ r%,g%,b%) + NEXT + ENDPROC + + DEF PROCbresenham(x1%,y1%,x2%,y2%,r%,g%,b%) + LOCAL dx%, dy%, sx%, sy%, e + dx% = ABS(x2% - x1%) : sx% = SGN(x2% - x1%) + dy% = ABS(y2% - y1%) : sy% = SGN(y2% - y1%) + IF dx% < dy% e = dx% / 2 ELSE e = dy% / 2 + REPEAT + PROCsetpixel(x1%,y1%,r%,g%,b%) + IF x1% = x2% IF y1% = y2% EXIT REPEAT + IF dx% > dy% THEN + x1% += sx% : e -= dy% : IF e < 0 e += dx% : y1% += sy% + ELSE + y1% += sy% : e -= dx% : IF e < 0 e += dy% : x1% += sx% + ENDIF + UNTIL FALSE + ENDPROC + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC diff --git a/Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-1.c b/Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-1.c new file mode 100644 index 0000000000..8585e046ed --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-1.c @@ -0,0 +1,9 @@ +void cubic_bezier( + image img, + unsigned int x1, unsigned int y1, + unsigned int x2, unsigned int y2, + unsigned int x3, unsigned int y3, + unsigned int x4, unsigned int y4, + color_component r, + color_component g, + color_component b ); diff --git a/Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-2.c b/Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-2.c new file mode 100644 index 0000000000..939c43a9ae --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/C/bitmap-b-zier-curves-cubic-2.c @@ -0,0 +1,54 @@ +#include + +/* number of segments for the curve */ +#define N_SEG 20 + +#define plot(x, y) put_pixel_clip(img, x, y, r, g, b) +#define line(x0,y0,x1,y1) draw_line(img, x0,y0,x1,y1, r,g,b) + +void cubic_bezier( + image img, + unsigned int x1, unsigned int y1, + unsigned int x2, unsigned int y2, + unsigned int x3, unsigned int y3, + unsigned int x4, unsigned int y4, + color_component r, + color_component g, + color_component b ) +{ + unsigned int i; + double pts[N_SEG+1][2]; + for (i=0; i <= N_SEG; ++i) + { + double t = (double)i / (double)N_SEG; + + double a = pow((1.0 - t), 3.0); + double b = 3.0 * t * pow((1.0 - t), 2.0); + double c = 3.0 * pow(t, 2.0) * (1.0 - t); + double d = pow(t, 3.0); + + double x = a * x1 + b * x2 + c * x3 + d * x4; + double y = a * y1 + b * y2 + c * y3 + d * y4; + pts[i][0] = x; + pts[i][1] = y; + } + +#if 0 + /* draw only points */ + for (i=0; i <= N_SEG; ++i) + { + plot( pts[i][0], + pts[i][1] ); + } +#else + /* draw segments */ + for (i=0; i < N_SEG; ++i) + { + int j = i + 1; + line( pts[i][0], pts[i][1], + pts[j][0], pts[j][1] ); + } +#endif +} +#undef plot +#undef line diff --git a/Task/Bitmap-B-zier-curves-Cubic/Fortran/bitmap-b-zier-curves-cubic.f b/Task/Bitmap-B-zier-curves-Cubic/Fortran/bitmap-b-zier-curves-cubic.f new file mode 100644 index 0000000000..4e7e6e6471 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Fortran/bitmap-b-zier-curves-cubic.f @@ -0,0 +1,27 @@ +subroutine cubic_bezier(img, p1, p2, p3, p4, color) + type(rgbimage), intent(inout) :: img + type(point), intent(in) :: p1, p2, p3, p4 + type(rgb), intent(in) :: color + + integer :: i, j + real :: pts(0:N_SEG,0:1), t, a, b, c, d, x, y + + do i = 0, N_SEG + t = real(i) / real(N_SEG) + a = (1.0 - t)**3.0 + b = 3.0 * t * (1.0 - t)**2.0 + c = 3.0 * (1.0 - t) * t**2.0 + d = t**3.0 + x = a * p1%x + b * p2%x + c * p3%x + d * p4%x + y = a * p1%y + b * p2%y + c * p3%y + d * p4%y + pts(i,0) = x + pts(i,1) = y + end do + + do i = 0, N_SEG-1 + j = i + 1 + call draw_line(img, point(pts(i,0), pts(i,1)), & + point(pts(j,0), pts(j,1)), color) + end do + +end subroutine cubic_bezier diff --git a/Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-1.go b/Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-1.go new file mode 100644 index 0000000000..ea76aecf3e --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-1.go @@ -0,0 +1,29 @@ +package raster + +const b3Seg = 30 + +func (b *Bitmap) Bézier3(x1, y1, x2, y2, x3, y3, x4, y4 int, p Pixel) { + var px, py [b3Seg + 1]int + fx1, fy1 := float64(x1), float64(y1) + fx2, fy2 := float64(x2), float64(y2) + fx3, fy3 := float64(x3), float64(y3) + fx4, fy4 := float64(x4), float64(y4) + for i := range px { + d := float64(i) / b3Seg + a := 1 - d + b, c := a * a, d * d + a, b, c, d = a*b, 3*b*d, 3*a*c, c*d + px[i] = int(a*fx1 + b*fx2 + c*fx3 + d*fx4) + py[i] = int(a*fy1 + b*fy2 + c*fy3 + d*fy4) + } + x0, y0 := px[0], py[0] + for i := 1; i <= b3Seg; i++ { + x1, y1 := px[i], py[i] + b.Line(x0, y0, x1, y1, p) + x0, y0 = x1, y1 + } +} + +func (b *Bitmap) Bézier3Rgb(x1, y1, x2, y2, x3, y3, x4, y4 int, c Rgb) { + b.Bézier3(x1, y1, x2, y2, x3, y3, x4, y4, c.Pixel()) +} diff --git a/Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-2.go b/Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-2.go new file mode 100644 index 0000000000..8f030a890f --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Go/bitmap-b-zier-curves-cubic-2.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "raster" +) + +func main() { + b := raster.NewBitmap(400, 300) + b.FillRgb(0xffefbf) + b.Bézier3Rgb(20, 200, 700, 50, -300, 50, 380, 150, raster.Rgb(0x3f8fef)) + if err := b.WritePpmFile("bez3.ppm"); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-1.m b/Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-1.m new file mode 100644 index 0000000000..7827b01829 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-1.m @@ -0,0 +1,30 @@ +function bezierCubic(obj,pixel_0,pixel_1,pixel_2,pixel_3,color,varargin) + + if( isempty(varargin) ) + resolution = 20; + else + resolution = varargin{1}; + end + + %Calculate time axis + time = (0:1/resolution:1)'; + timeMinus = 1-time; + + %The formula for the curve is expanded for clarity, the lack of + %loops is because its calculation has been vectorized + curve = (timeMinus).^3*pixel_0; %First term of polynomial + curve = curve + (3.*time.*timeMinus.^2)*pixel_1; %second term of polynomial + curve = curve + (3.*timeMinus.*time.^2)*pixel_2; %third term of polynomial + curve = curve + time.^3*pixel_3; %Fourth term of polynomial + + curve = round(curve); %round each of the points to the nearest integer + + %connect each of the points in the curve with a line using the + %Bresenham Line algorithm + for i = (1:length(curve)-1) + obj.bresenhamLine(curve(i,:),curve(i+1,:),color); + end + + assignin('caller',inputname(1),obj); %saves the changes to the object + +end diff --git a/Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-2.m b/Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-2.m new file mode 100644 index 0000000000..3c7843c7bb --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/MATLAB/bitmap-b-zier-curves-cubic-2.m @@ -0,0 +1,4 @@ +>> img = Bitmap(200,200); +>> img.fill([255 255 255]); +>> img.bezierCubic([160 10],[10 40],[30 160],[150 110],[255 0 0],110); +>> disp(img) diff --git a/Task/Bitmap-B-zier-curves-Cubic/PHP/bitmap-b-zier-curves-cubic.php b/Task/Bitmap-B-zier-curves-Cubic/PHP/bitmap-b-zier-curves-cubic.php new file mode 100644 index 0000000000..b34a589276 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/PHP/bitmap-b-zier-curves-cubic.php @@ -0,0 +1,29 @@ += 2} {incr i -1} { + set sum [expr {$sum * $i}] + } + return $sum +} + +proc x p {lindex $p 0} +proc y p {lindex $p 1} + +proc newbezier {n w} { + set size 400 + set bezier [newImage $size $size] + fill $bezier white + for {set i 1} {$i <= $n} {incr i} { + set point [list [expr {int($size*rand())}] [expr {int($size*rand())}]] + lappend points $point + drawCircle $bezier red $point 3 + } + puts $points + + drawBezier $bezier blue {*}$points + + $w configure -image $bezier +} + +set degree 4 ;# cubic bezier -- for quadratic, use 3 +label .img +button .new -command [list newbezier $degree .img] -text New +button .exit -command exit -text Exit +pack .new .img .exit -side top diff --git a/Task/Bitmap-B-zier-curves-Quadratic/0DESCRIPTION b/Task/Bitmap-B-zier-curves-Quadratic/0DESCRIPTION new file mode 100644 index 0000000000..748cd762eb --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/0DESCRIPTION @@ -0,0 +1,2 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, and the draw_line function defined in [[Bresenham's_line_algorithm|this one]], draw a ''quadratic bezier curve'' +([[wp:Bezier_curves#Quadratic_B.C3.A9zier_curves|definition on Wikipedia]]). diff --git a/Task/Bitmap-B-zier-curves-Quadratic/1META.yaml b/Task/Bitmap-B-zier-curves-Quadratic/1META.yaml new file mode 100644 index 0000000000..fb36ead2f0 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Raster graphics operations diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-1.ada b/Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-1.ada new file mode 100644 index 0000000000..8d3a3f83ce --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-1.ada @@ -0,0 +1,23 @@ +procedure Quadratic_Bezier + ( Picture : in out Image; + P1, P2, P3 : Point; + Color : Pixel; + N : Positive := 20 + ) is + Points : array (0..N) of Point; +begin + for I in Points'Range loop + declare + T : constant Float := Float (I) / Float (N); + A : constant Float := (1.0 - T)**2; + B : constant Float := 2.0 * T * (1.0 - T); + C : constant Float := T**2; + begin + Points (I).X := Positive (A * Float (P1.X) + B * Float (P2.X) + C * Float (P3.X)); + Points (I).Y := Positive (A * Float (P1.Y) + B * Float (P2.Y) + C * Float (P3.Y)); + end; + end loop; + for I in Points'First..Points'Last - 1 loop + Line (Picture, Points (I), Points (I + 1), Color); + end loop; +end Quadratic_Bezier; diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-2.ada b/Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-2.ada new file mode 100644 index 0000000000..1c346c9eaa --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Ada/bitmap-b-zier-curves-quadratic-2.ada @@ -0,0 +1,5 @@ + X : Image (1..16, 1..16); +begin + Fill (X, White); + Quadratic_Bezier (X, (8, 2), (13, 8), (2, 15), Black); + Print (X); diff --git a/Task/Bitmap-B-zier-curves-Quadratic/BBC-BASIC/bitmap-b-zier-curves-quadratic.bbc b/Task/Bitmap-B-zier-curves-Quadratic/BBC-BASIC/bitmap-b-zier-curves-quadratic.bbc new file mode 100644 index 0000000000..47484b8209 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/BBC-BASIC/bitmap-b-zier-curves-quadratic.bbc @@ -0,0 +1,51 @@ + Width% = 200 + Height% = 200 + + REM Set window size: + VDU 23,22,Width%;Height%;8,16,16,128 + + REM Draw quadratic Bézier curve: + PROCbezierquad(10,100, 250,270, 150,20, 20, 0,0,0) + END + + DEF PROCbezierquad(x1,y1,x2,y2,x3,y3,n%,r%,g%,b%) + LOCAL i%, t, t1, a, b, c, p{()} + DIM p{(n%) x%,y%} + + FOR i% = 0 TO n% + t = i% / n% + t1 = 1 - t + a = t1^2 + b = 2 * t * t1 + c = t^2 + p{(i%)}.x% = INT(a * x1 + b * x2 + c * x3 + 0.5) + p{(i%)}.y% = INT(a * y1 + b * y2 + c * y3 + 0.5) + NEXT + + FOR i% = 0 TO n%-1 + PROCbresenham(p{(i%)}.x%,p{(i%)}.y%,p{(i%+1)}.x%,p{(i%+1)}.y%, \ + \ r%,g%,b%) + NEXT + ENDPROC + + DEF PROCbresenham(x1%,y1%,x2%,y2%,r%,g%,b%) + LOCAL dx%, dy%, sx%, sy%, e + dx% = ABS(x2% - x1%) : sx% = SGN(x2% - x1%) + dy% = ABS(y2% - y1%) : sy% = SGN(y2% - y1%) + IF dx% < dy% e = dx% / 2 ELSE e = dy% / 2 + REPEAT + PROCsetpixel(x1%,y1%,r%,g%,b%) + IF x1% = x2% IF y1% = y2% EXIT REPEAT + IF dx% > dy% THEN + x1% += sx% : e -= dy% : IF e < 0 e += dx% : y1% += sy% + ELSE + y1% += sy% : e -= dx% : IF e < 0 e += dy% : x1% += sx% + ENDIF + UNTIL FALSE + ENDPROC + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC diff --git a/Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-1.c b/Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-1.c new file mode 100644 index 0000000000..9335a9bbf5 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-1.c @@ -0,0 +1,8 @@ +void quad_bezier( + image img, + unsigned int x1, unsigned int y1, + unsigned int x2, unsigned int y2, + unsigned int x3, unsigned int y3, + color_component r, + color_component g, + color_component b ); diff --git a/Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-2.c b/Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-2.c new file mode 100644 index 0000000000..359454cc33 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/C/bitmap-b-zier-curves-quadratic-2.c @@ -0,0 +1,50 @@ +#include + +/* number of segments for the curve */ +#define N_SEG 20 + +#define plot(x, y) put_pixel_clip(img, x, y, r, g, b) +#define line(x0,y0,x1,y1) draw_line(img, x0,y0,x1,y1, r,g,b) + +void quad_bezier( + image img, + unsigned int x1, unsigned int y1, + unsigned int x2, unsigned int y2, + unsigned int x3, unsigned int y3, + color_component r, + color_component g, + color_component b ) +{ + unsigned int i; + double pts[N_SEG+1][2]; + for (i=0; i <= N_SEG; ++i) + { + double t = (double)i / (double)N_SEG; + double a = pow((1.0 - t), 2.0); + double b = 2.0 * t * (1.0 - t); + double c = pow(t, 2.0); + double x = a * x1 + b * x2 + c * x3; + double y = a * y1 + b * y2 + c * y3; + pts[i][0] = x; + pts[i][1] = y; + } + +#if 0 + /* draw only points */ + for (i=0; i <= N_SEG; ++i) + { + plot( pts[i][0], + pts[i][1] ); + } +#else + /* draw segments */ + for (i=0; i < N_SEG; ++i) + { + int j = i + 1; + line( pts[i][0], pts[i][1], + pts[j][0], pts[j][1] ); + } +#endif +} +#undef plot +#undef line diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Fortran/bitmap-b-zier-curves-quadratic.f b/Task/Bitmap-B-zier-curves-Quadratic/Fortran/bitmap-b-zier-curves-quadratic.f new file mode 100644 index 0000000000..893a495796 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Fortran/bitmap-b-zier-curves-quadratic.f @@ -0,0 +1,26 @@ +subroutine quad_bezier(img, p1, p2, p3, color) + type(rgbimage), intent(inout) :: img + type(point), intent(in) :: p1, p2, p3 + type(rgb), intent(in) :: color + + integer :: i, j + real :: pts(0:N_SEG,0:1), t, a, b, c, x, y + + do i = 0, N_SEG + t = real(i) / real(N_SEG) + a = (1.0 - t)**2.0 + b = 2.0 * t * (1.0 - t) + c = t**2.0 + x = a * p1%x + b * p2%x + c * p3%x + y = a * p1%y + b * p2%y + c * p3%y + pts(i,0) = x + pts(i,1) = y + end do + + do i = 0, N_SEG-1 + j = i + 1 + call draw_line(img, point(pts(i,0), pts(i,1)), & + point(pts(j,0), pts(j,1)), color) + end do + +end subroutine quad_bezier diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-1.go b/Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-1.go new file mode 100644 index 0000000000..c5814790c6 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-1.go @@ -0,0 +1,27 @@ +package raster + +const b2Seg = 20 + +func (b *Bitmap) Bézier2(x1, y1, x2, y2, x3, y3 int, p Pixel) { + var px, py [b2Seg + 1]int + fx1, fy1 := float64(x1), float64(y1) + fx2, fy2 := float64(x2), float64(y2) + fx3, fy3 := float64(x3), float64(y3) + for i := range px { + c := float64(i) / b2Seg + a := 1 - c + a, b, c := a*a, 2 * c * a, c*c + px[i] = int(a*fx1 + b*fx2 + c*fx3) + py[i] = int(a*fy1 + b*fy2 + c*fy3) + } + x0, y0 := px[0], py[0] + for i := 1; i <= b2Seg; i++ { + x1, y1 := px[i], py[i] + b.Line(x0, y0, x1, y1, p) + x0, y0 = x1, y1 + } +} + +func (b *Bitmap) Bézier2Rgb(x1, y1, x2, y2, x3, y3 int, c Rgb) { + b.Bézier2(x1, y1, x2, y2, x3, y3, c.Pixel()) +} diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-2.go b/Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-2.go new file mode 100644 index 0000000000..94416ea268 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Go/bitmap-b-zier-curves-quadratic-2.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "raster" +) + +func main() { + b := raster.NewBitmap(400, 300) + b.FillRgb(0xdfffef) + b.Bézier2Rgb(20, 150, 500, -100, 300, 280, raster.Rgb(0x3f8fef)) + if err := b.WritePpmFile("bez2.ppm"); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Haskell/bitmap-b-zier-curves-quadratic.hs b/Task/Bitmap-B-zier-curves-Quadratic/Haskell/bitmap-b-zier-curves-quadratic.hs new file mode 100644 index 0000000000..8d6cbbeb27 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Haskell/bitmap-b-zier-curves-quadratic.hs @@ -0,0 +1,47 @@ +{-# LANGUAGE + FlexibleInstances, TypeSynonymInstances, + ViewPatterns #-} + +import Bitmap +import Bitmap.Line +import Control.Monad +import Control.Monad.ST + +type Point = (Double, Double) +fromPixel (Pixel (x, y)) = (toEnum x, toEnum y) +toPixel (x, y) = Pixel (round x, round y) + +pmap :: (Double -> Double) -> Point -> Point +pmap f (x, y) = (f x, f y) + +onCoordinates :: (Double -> Double -> Double) -> Point -> Point -> Point +onCoordinates f (xa, ya) (xb, yb) = (f xa xb, f ya yb) + +instance Num Point where + (+) = onCoordinates (+) + (-) = onCoordinates (-) + (*) = onCoordinates (*) + negate = pmap negate + abs = pmap abs + signum = pmap signum + fromInteger i = (i', i') + where i' = fromInteger i + +bézier :: Color c => + Image s c -> Pixel -> Pixel -> Pixel -> c -> Int -> + ST s () +bézier + i + (fromPixel -> p1) (fromPixel -> p2) (fromPixel -> p3) + c samples = + zipWithM_ f ts (tail ts) + where ts = map (/ top) [0 .. top] + where top = toEnum $ samples - 1 + curvePoint t = + pt (t' ^^ 2) p1 + + pt (2 * t * t') p2 + + pt (t ^^ 2) p3 + where t' = 1 - t + pt n p = pmap (*n) p + f (curvePoint -> p1) (curvePoint -> p2) = + line i (toPixel p1) (toPixel p2) c diff --git a/Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-1.m b/Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-1.m new file mode 100644 index 0000000000..e2aa20fddd --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-1.m @@ -0,0 +1,29 @@ +function bezierQuad(obj,pixel_0,pixel_1,pixel_2,color,varargin) + + if( isempty(varargin) ) + resolution = 20; + else + resolution = varargin{1}; + end + + %Calculate time axis + time = (0:1/resolution:1)'; + timeMinus = 1-time; + + %The formula for the curve is expanded for clarity, the lack of + %loops is because its calculation has been vectorized + curve = (timeMinus.^2)*pixel_0; %First term of polynomial + curve = curve + (2.*time.*timeMinus)*pixel_1; %second term of polynomial + curve = curve + (time.^2)*pixel_2; %third term of polynomial + + curve = round(curve); %round each of the points to the nearest integer + + %connect each of the points in the curve with a line using the + %Bresenham Line algorithm + for i = (1:length(curve)-1) + obj.bresenhamLine(curve(i,:),curve(i+1,:),color); + end + + assignin('caller',inputname(1),obj); %saves the changes to the object + +end diff --git a/Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-2.m b/Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-2.m new file mode 100644 index 0000000000..b81be3b528 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/MATLAB/bitmap-b-zier-curves-quadratic-2.m @@ -0,0 +1,4 @@ +>> img = Bitmap(400,300); +>> img.fill([223 255 239]); +>> img.bezierQuad([20 150],[500 -100],[300 280],[63 143 239],21); +>> disp(img) diff --git a/Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-1.l b/Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-1.l new file mode 100644 index 0000000000..386ba91332 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-1.l @@ -0,0 +1,11 @@ +(scl 6) + +(de quadBezier (Img N X1 Y1 X2 Y2 X3 Y3) + (let (R (* N N) X X1 Y Y1 DX 0 DY 0) + (for I N + (let (J (- N I) A (*/ 1.0 J J R) B (*/ 2.0 I J R) C (*/ 1.0 I I R)) + (brez Img X Y + (setq DX (- (+ (*/ A X1 1.0) (*/ B X2 1.0) (*/ C X3 1.0)) X)) + (setq DY (- (+ (*/ A Y1 1.0) (*/ B Y2 1.0) (*/ C Y3 1.0)) Y)) ) + (inc 'X DX) + (inc 'Y DY) ) ) ) ) diff --git a/Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-2.l b/Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-2.l new file mode 100644 index 0000000000..a7e02a9447 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/PicoLisp/bitmap-b-zier-curves-quadratic-2.l @@ -0,0 +1,8 @@ +(let Img (make (do 200 (link (need 300 0)))) # Create image 300 x 200 + (quadBezier Img 12 20 100 300 -80 260 180) + (out "img.pbm" # Write to bitmap file + (prinl "P1") + (prinl 300 " " 200) + (mapc prinl Img) ) ) + +(call 'display "img.pbm") diff --git a/Task/Bitmap-Bresenhams-line-algorithm/0DESCRIPTION b/Task/Bitmap-Bresenhams-line-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..9d3236572d --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/0DESCRIPTION @@ -0,0 +1 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster graphics images, draw a line given 2 points with the [[wp:Bresenham's_line_algorithm|Bresenham's algorithm]]. diff --git a/Task/Bitmap-Bresenhams-line-algorithm/1META.yaml b/Task/Bitmap-Bresenhams-line-algorithm/1META.yaml new file mode 100644 index 0000000000..c4801aa5b2 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Graphics algorithms +note: Raster graphics operations diff --git a/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg b/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg new file mode 100644 index 0000000000..44609d6819 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg @@ -0,0 +1,53 @@ +PRAGMAT READ "Basic_bitmap_storage.a68" PRAGMAT; + +line OF class image := (REF IMAGE picture, POINT start, stop, PIXEL color)VOID: +BEGIN + REAL dx = ABS (x OF stop - x OF start), + dy = ABS (y OF stop - y OF start); + REAL err; + POINT here := start, + step := (1, 1); + IF x OF start > x OF stop THEN + x OF step := -1 + FI; + IF y OF start > y OF stop THEN + y OF step := -1 + FI; + IF dx > dy THEN + err := dx / 2; + WHILE x OF here /= x OF stop DO + picture[x OF here, y OF here] := color; + err -:= dy; + IF err < 0 THEN + y OF here +:= y OF step; + err +:= dx + FI; + x OF here +:= x OF step + OD + ELSE + err := dy / 2; + WHILE y OF here /= y OF stop DO + picture[x OF here, y OF here] := color; + err -:= dx; + IF err < 0 THEN + x OF here +:= x OF step; + err +:= dy + FI; + y OF here +:= y OF step + OD + FI; + picture[x OF here, y OF here] := color # ensure dots to be drawn # +END # line #; + +### +The test program: +### +IF test THEN + REF IMAGE x = INIT LOC[1:16, 1:16]PIXEL; + (fill OF class image)(x, white OF class image); + (line OF class image)(x, ( 1, 8), ( 8,16), black OF class image); + (line OF class image)(x, ( 8,16), (16, 8), black OF class image); + (line OF class image)(x, (16, 8), ( 8, 1), black OF class image); + (line OF class image)(x, ( 8, 1), ( 1, 8), black OF class image); + (print OF class image)(x) +FI diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-1.ada b/Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-1.ada new file mode 100644 index 0000000000..ae513fcfc4 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-1.ada @@ -0,0 +1,40 @@ +procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is + DX : constant Float := abs Float (Stop.X - Start.X); + DY : constant Float := abs Float (Stop.Y - Start.Y); + Err : Float; + X : Positive := Start.X; + Y : Positive := Start.Y; + Step_X : Integer := 1; + Step_Y : Integer := 1; +begin + if Start.X > Stop.X then + Step_X := -1; + end if; + if Start.Y > Stop.Y then + Step_Y := -1; + end if; + if DX > DY then + Err := DX / 2.0; + while X /= Stop.X loop + Picture (X, Y) := Color; + Err := Err - DY; + if Err < 0.0 then + Y := Y + Step_Y; + Err := Err + DX; + end if; + X := X + Step_X; + end loop; + else + Err := DY / 2.0; + while Y /= Stop.Y loop + Picture (X, Y) := Color; + Err := Err - DX; + if Err < 0.0 then + X := X + Step_X; + Err := Err + DY; + end if; + Y := Y + Step_Y; + end loop; + end if; + Picture (X, Y) := Color; -- Ensure dots to be drawn +end Line; diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-2.ada b/Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-2.ada new file mode 100644 index 0000000000..9fa0a0abaf --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-2.ada @@ -0,0 +1,8 @@ + X : Image (1..16, 1..16); +begin + Fill (X, White); + Line (X, ( 1, 8), ( 8,16), Black); + Line (X, ( 8,16), (16, 8), Black); + Line (X, (16, 8), ( 8, 1), Black); + Line (X, ( 8, 1), ( 1, 8), Black); + Print (X); diff --git a/Task/Bitmap-Bresenhams-line-algorithm/AutoHotkey/bitmap-bresenhams-line-algorithm.ahk b/Task/Bitmap-Bresenhams-line-algorithm/AutoHotkey/bitmap-bresenhams-line-algorithm.ahk new file mode 100644 index 0000000000..13828790ed --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/AutoHotkey/bitmap-bresenhams-line-algorithm.ahk @@ -0,0 +1,19 @@ +Blue := Color(0,0,255) +White := Color(255,255,255) +Bitmap := Bitmap(100,100,Blue) ;create a 100*100 blue bitmap +Line(Bitmap,White,5,10,60,80) ;draw a white line from (5,10) to (60,80) +Bitmap.Write("Line.ppm") ;write the bitmap to file + +Line(ByRef Bitmap,ByRef Color,PosX1,PosY1,PosX2,PosY2) +{ + DeltaX := Abs(PosX2 - PosX1), DeltaY := -Abs(PosY2 - PosY1) ;calculate deltas + StepX := ((PosX1 < PosX2) ? 1 : -1), StepY := ((PosY1 < PosY2) ? 1 : -1) ;calculate steps + ErrorValue := DeltaX + DeltaY ;calculate error value + Loop ;loop over the pixel values + { + Bitmap[PosX1,PosX2] := Color + If (PosX1 = PosX2 && PosY1 = PosY2) + Break + Temp1 := ErrorValue << 1, ((Temp1 > DeltaY) ? (ErrorValue += DeltaY, PosX1 += StepX) : ""), ((Temp1 < DeltaX) ? (ErrorValue += DeltaX, PosY1 += StepY) : "") ;move forward + } +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/BBC-BASIC/bitmap-bresenhams-line-algorithm.bbc b/Task/Bitmap-Bresenhams-line-algorithm/BBC-BASIC/bitmap-bresenhams-line-algorithm.bbc new file mode 100644 index 0000000000..762777c9ba --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/BBC-BASIC/bitmap-bresenhams-line-algorithm.bbc @@ -0,0 +1,34 @@ + Width% = 200 + Height% = 200 + + REM Set window size: + VDU 23,22,Width%;Height%;8,16,16,128 + + REM Draw lines: + PROCbresenham(50,100,100,190,0,0,0) + PROCbresenham(100,190,150,100,0,0,0) + PROCbresenham(150,100,100,10,0,0,0) + PROCbresenham(100,10,50,100,0,0,0) + END + + DEF PROCbresenham(x1%,y1%,x2%,y2%,r%,g%,b%) + LOCAL dx%, dy%, sx%, sy%, e + dx% = ABS(x2% - x1%) : sx% = SGN(x2% - x1%) + dy% = ABS(y2% - y1%) : sy% = SGN(y2% - y1%) + IF dx% < dy% e = dx% / 2 ELSE e = dy% / 2 + REPEAT + PROCsetpixel(x1%,y1%,r%,g%,b%) + IF x1% = x2% IF y1% = y2% EXIT REPEAT + IF dx% > dy% THEN + x1% += sx% : e -= dy% : IF e < 0 e += dx% : y1% += sy% + ELSE + y1% += sy% : e -= dx% : IF e < 0 e += dy% : x1% += sx% + ENDIF + UNTIL FALSE + ENDPROC + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC diff --git a/Task/Bitmap-Bresenhams-line-algorithm/C/bitmap-bresenhams-line-algorithm.c b/Task/Bitmap-Bresenhams-line-algorithm/C/bitmap-bresenhams-line-algorithm.c new file mode 100644 index 0000000000..63e43fd179 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/C/bitmap-bresenhams-line-algorithm.c @@ -0,0 +1,14 @@ +void line(int x0, int y0, int x1, int y1) { + + int dx = abs(x1-x0), sx = x0dy ? dx : -dy)/2, e2; + + for(;;){ + setPixel(x0,y0); + if (x0==x1 && y0==y1) break; + e2 = err; + if (e2 >-dx) { err -= dy; x0 += sx; } + if (e2 < dy) { err += dx; y0 += sy; } + } +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Clojure/bitmap-bresenhams-line-algorithm.clj b/Task/Bitmap-Bresenhams-line-algorithm/Clojure/bitmap-bresenhams-line-algorithm.clj new file mode 100644 index 0000000000..62221139b7 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Clojure/bitmap-bresenhams-line-algorithm.clj @@ -0,0 +1,23 @@ +(defn draw-line + "Draw a line from x1,y1 to x2,y2 using Bresenham's, to a java BufferedImage in the colour of pixel." + [buffer x1 y1 x2 y2 pixel] + (let [dist-x (abs (- x1 x2)) + dist-y (abs (- y1 y2)) + steep (> dist-y dist-x)] + (let [[x1 y1 x2 y2] (if steep [y1 x1 y2 x2] [x1 y1 x2 y2])] + (let [[x1 y1 x2 y2] (if (> x1 x2) [x2 y2 x1 y1] [x1 y1 x2 y2])] + (let [delta-x (- x2 x1) + delta-y (abs (- y1 y2)) + y-step (if (< y1 y2) 1 -1)] + + (let [plot (if steep + #(.setRGB buffer (int %1) (int %2) pixel) + #(.setRGB buffer (int %2) (int %1) pixel))] + + (loop [x x1 y y1 error (floor delta-x 2) ] + (plot x y) + (if (< x x2) + ; Rather then rebind error, test that it is less than delta-y rather than zero + (if (< error delta-y) + (recur (inc x) (+ y y-step) (+ error (- delta-x delta-y))) + (recur (inc x) y (- error delta-y))))))))))) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-1.erl b/Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-1.erl new file mode 100644 index 0000000000..57c6a12054 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-1.erl @@ -0,0 +1,45 @@ +build_path({Sx, Sy}, {Tx, Ty}) -> + if + Tx < Sx -> StepX = -1; + true -> StepX = 1 + end, + if + Ty < Sy -> StepY = -1; + true -> StepY = 1 + end, + + Dx = abs((Tx-Sx)*2), + Dy = abs((Ty-Sy)*2), + + if + Dy > Dx -> Path = through_y({Sx, Sy}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, Dx*2-Dy, []); + true -> Path = through_x({Sx, Sy}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, Dy*2-Dx, []) + end, + + lists:reverse(Path). + +through_x({Tx, _}, {Tx, _}, _, _, _, P) -> P; +through_x({Sx, Sy}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F0, P) when F0 >= 0 -> + Ny = Sy + StepY, + F1 = F0 - Dx, + Nx = Sx + StepX, + F2 = F1 + Dy, + through_x({Nx, Ny}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F2, [{Nx, Ny}|P]); +through_x({Sx, Sy}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F0, P) when F0 < 0 -> + Ny = Sy, + Nx = Sx + StepX, + F2 = F0 + Dy, + through_x({Nx, Ny}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F2, [{Nx, Ny}|P]). + +through_y({_, Ty}, {_, Ty}, _, _, _, P) -> P; +through_y({Sx, Sy}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F0, P) when F0 >= 0 -> + Nx = Sx + StepX, + F1 = F0 - Dy, + Ny = Sy + StepY, + F2 = F1 + Dx, + through_y({Nx, Ny}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F2, [{Nx, Ny}|P]); +through_y({Sx, Sy}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F0, P) when F0 < 0 -> + Nx = Sx, + Ny = Sy + StepY, + F2 = F0 + Dx, + through_y({Nx, Ny}, {Tx, Ty}, {StepX, StepY}, {Dx, Dy}, F2, [{Nx, Ny}|P]). diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-2.erl b/Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-2.erl new file mode 100644 index 0000000000..c725b805c8 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Erlang/bitmap-bresenhams-line-algorithm-2.erl @@ -0,0 +1,30 @@ +line({X0, Y0}, {X1, Y1}) -> + SX = step(X0, X1), + SY = step(Y0, Y1), + DX = abs(X1 - X0), + DY = abs(Y1 - Y0), + Err = DX - DY, + line({X0, Y0}, {X1, Y1}, {SX, SY}, {DX, DY}, Err, []). + +line({X1, Y1}, {X1, Y1}, _, _, _, Acc) -> + lists:reverse([{X1, Y1} | Acc]); +line({X, Y}, {X1, Y1}, {SX, SY}, {DX, DY}, Err, Acc) -> + DE = 2 * Err, + {X0, Err0} = next_x(X, SX, DY, Err, DE), + {Y0, Err1} = next_y(Y, SY, DX, Err0, DE), + line({X0, Y0}, {X1, Y1}, {SX, SY}, {DX, DY}, Err1, [{X, Y} | Acc]). + +step(P0, P1) when P0 < P1 -> + 1; +step(_, _) -> + -1. + +next_x(X, SX, DY, E, DE) when DE > -DY -> + {X + SX, E - DY}; +next_x(X, _SX, _DY, E, _DE) -> + {X, E}. + +next_y(Y, SY, DX, E, DE) when DE < DX -> + {Y + SY, E + DX}; +next_y(Y, _SY, _DX, E, _DE) -> + {Y, E}. diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Forth/bitmap-bresenhams-line-algorithm.fth b/Task/Bitmap-Bresenhams-line-algorithm/Forth/bitmap-bresenhams-line-algorithm.fth new file mode 100644 index 0000000000..c45f02482e --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Forth/bitmap-bresenhams-line-algorithm.fth @@ -0,0 +1,48 @@ +defer steep \ noop or swap +defer ystep \ 1+ or 1- + +: line ( x0 y0 x1 y1 color bmp -- ) + { color bmp } + rot swap + ( x0 x1 y0 y1 ) + 2dup - abs >r + 2over - abs r> < + if ['] swap \ swap use of x and y + else 2swap ['] noop + then is steep + ( y0 y1 x0 x1 ) + 2dup > + if swap 2swap swap \ ensure x1 > x0 + else 2swap + then + ( x0 x1 y0 y1 ) + 2dup > + if ['] 1- + else ['] 1+ + then is ystep + over - abs { y deltay } + swap 2dup - dup { deltax } + 2/ rot 1+ rot + ( error x1+1 x0 ) + do color i y steep bmp b! + deltay - + dup 0< + if y ystep to y + deltax + + then + loop + drop ; + +5 5 bitmap value test +0 test bfill +1 0 4 1 red test line +4 1 3 4 red test line +3 4 0 3 red test line +0 3 1 0 red test line +test bshow cr + ** + * ** +* * +** * + ** +ok diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-1.f b/Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-1.f new file mode 100644 index 0000000000..8a785a436f --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-1.f @@ -0,0 +1,70 @@ +module RCImagePrimitive + use RCImageBasic + + implicit none + + type point + integer :: x, y + end type point + + private :: swapcoord + +contains + + subroutine swapcoord(p1, p2) + integer, intent(inout) :: p1, p2 + integer :: t + + t = p2 + p2 = p1 + p1 = t + end subroutine swapcoord + + subroutine draw_line(img, from, to, color) + type(rgbimage), intent(inout) :: img + type(point), intent(in) :: from, to + type(rgb), intent(in) :: color + + type(point) :: rfrom, rto + integer :: dx, dy, error, ystep, x, y + logical :: steep + + rfrom = from + rto = to + steep = (abs(rto%y - rfrom%y) > abs(rto%x - rfrom%x)) + if ( steep ) then + call swapcoord(rfrom%x, rfrom%y) + call swapcoord(rto%x, rto%y) + end if + if ( rfrom%x > rto%x ) then + call swapcoord(rfrom%x, rto%x) + call swapcoord(rfrom%y, rto%y) + end if + + dx = rto%x - rfrom%x + dy = abs(rto%y - rfrom%y) + error = dx / 2 + y = rfrom%y + + if ( rfrom%y < rto%y ) then + ystep = 1 + else + ystep = -1 + end if + + do x = rfrom%x, rto%x + if ( steep ) then + call put_pixel(img, y, x, color) + else + call put_pixel(img, x, y, color) + end if + error = error - dy + if ( error < 0 ) then + y = y + ystep + error = error + dx + end if + end do + + end subroutine draw_line + +end module RCImagePrimitive diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-2.f b/Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-2.f new file mode 100644 index 0000000000..f9973d82d7 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Fortran/bitmap-bresenhams-line-algorithm-2.f @@ -0,0 +1,27 @@ +program BasicImageTests + use RCImageBasic + use RCImageIO + use RCImagePrimitive + + implicit none + + type(rgbimage) :: animage + integer :: x, y + + call alloc_img(animage, 200, 200) + call fill_img(animage, rgb(255,255,255)) + + call draw_line(animage, point(0,0), point(199,199), rgb(0,0,0)) + + do y=0,219,20 + call draw_line(animage, point(0,0), point(199, y), & + rgb(0,0,0)) + end do + + open(unit=10, file='outputimage.ppm', status='new') + call output_ppm(10, animage) + close(10) + + call free_img(animage) + +end program BasicImageTests diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-1.go b/Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-1.go new file mode 100644 index 0000000000..c8a73678d1 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-1.go @@ -0,0 +1,46 @@ +package raster + +// Line draws line by Bresenham's algorithm. +func (b *Bitmap) Line(x0, y0, x1, y1 int, p Pixel) { + // implemented straight from WP pseudocode + dx := x1 - x0 + if dx < 0 { + dx = -dx + } + dy := y1 - y0 + if dy < 0 { + dy = -dy + } + var sx, sy int + if x0 < x1 { + sx = 1 + } else { + sx = -1 + } + if y0 < y1 { + sy = 1 + } else { + sy = -1 + } + err := dx - dy + + for { + b.SetPx(x0, y0, p) + if x0 == x1 && y0 == y1 { + break + } + e2 := 2 * err + if e2 > -dy { + err -= dy + x0 += sx + } + if e2 < dx { + err += dx + y0 += sy + } + } +} + +func (b *Bitmap) LineRgb(x0, y0, x1, y1 int, c Rgb) { + b.Line(x0, y0, x1, y1, c.Pixel()) +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-2.go b/Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-2.go new file mode 100644 index 0000000000..a96d5a1433 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Go/bitmap-bresenhams-line-algorithm-2.go @@ -0,0 +1,23 @@ +package main + +// Files required to build supporting package raster are found in: +// * This task (immediately above) +// * Bitmap +// * Write a PPM file + +import ( + "raster" + "fmt" +) + +func main() { + b := raster.NewBitmap(400, 300) + b.FillRgb(0xdfefff) + blue := raster.Rgb(0x8fcfff) + b.LineRgb(7, 12, 307, 122, blue) + b.LineRgb(177, 12, 127, 222, blue) + err := b.WritePpmFile("bresenham.ppm") + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Haskell/bitmap-bresenhams-line-algorithm.hs b/Task/Bitmap-Bresenhams-line-algorithm/Haskell/bitmap-bresenhams-line-algorithm.hs new file mode 100644 index 0000000000..ba2c2ae0ff --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Haskell/bitmap-bresenhams-line-algorithm.hs @@ -0,0 +1,33 @@ +module Bitmap.Line(line) where + +import Bitmap +import Control.Monad +import Control.Monad.ST +import qualified Data.STRef + +var = Data.STRef.newSTRef +get = Data.STRef.readSTRef +mutate = Data.STRef.modifySTRef + +line :: Color c => Image s c -> Pixel -> Pixel -> c -> ST s () +line i (Pixel (xa, ya)) (Pixel (xb, yb)) c = do + yV <- var y1 + errorV <- var $ deltax `div` 2 + forM_ [x1 .. x2] (\x -> do + y <- get yV + setPix i (Pixel $ if steep then (y, x) else (x, y)) c + mutate errorV $ subtract deltay + error <- get errorV + when (error < 0) (do + mutate yV (+ ystep) + mutate errorV (+ deltax))) + where steep = abs (yb - ya) > abs (xb - xa) + (xa', ya', xb', yb') = if steep + then (ya, xa, yb, xb) + else (xa, ya, xb, yb) + (x1, y1, x2, y2) = if xa' > xb' + then (xb', yb', xa', ya') + else (xa', ya', xb', yb') + deltax = x2 - x1 + deltay = abs $ y2 - y1 + ystep = if y1 < y2 then 1 else -1 diff --git a/Task/Bitmap-Bresenhams-line-algorithm/JavaScript/bitmap-bresenhams-line-algorithm.js b/Task/Bitmap-Bresenhams-line-algorithm/JavaScript/bitmap-bresenhams-line-algorithm.js new file mode 100644 index 0000000000..a0d9f8646f --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/JavaScript/bitmap-bresenhams-line-algorithm.js @@ -0,0 +1,14 @@ +function bline(x0, y0, x1, y1) { + + var dx = Math.abs(x1 - x0), sx = x0 < x1 ? 1 : -1; + var dy = Math.abs(y1 - y0), sy = y0 < y1 ? 1 : -1; + var err = (dx>dy ? dx : -dy)/2; + + while (true) { + setPixel(x0,y0); + if (x0 === x1 && y0 === y1) break; + var e2 = err; + if (e2 > -dx) { err -= dy; x0 += sx; } + if (e2 < dy) { err += dx; y0 += sy; } + } +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-1.m b/Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-1.m new file mode 100644 index 0000000000..41eff2a279 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-1.m @@ -0,0 +1,61 @@ +%screen = Bitmap object +%startPoint = [x0,y0] +%endPoint = [x1,y1] +%color = [red,green,blue] + +function bresenhamLine(screen,startPoint,endPoint,color) + + if( any(color > 255) ) + error 'RGB colors must be between 0 and 255'; + end + + %Check for vertical line, x0 == x1 + if( startPoint(1) == endPoint(1) ) + %Draw vertical line + for i = (startPoint(2):endPoint(2)) + setPixel(screen,[startPoint(1) i],color); + end + end + + %Simplified Bresenham algorithm + dx = abs(endPoint(1) - startPoint(1)); + dy = abs(endPoint(2) - startPoint(2)); + + if(startPoint(1) < endPoint(1)) + sx = 1; + else + sx = -1; + end + + if(startPoint(2) < endPoint(2)) + sy = 1; + else + sy = -1; + end + + err = dx - dy; + pixel = startPoint; + + while(true) + + screen.setPixel(pixel,color); %setPixel(x0,y0) + + if( pixel == endPoint ) + break; + end + + e2 = 2*err; + + if( e2 > -dy ) + err = err - dy; + pixel(1) = pixel(1) + sx; + end + + if( e2 < dx ) + err = err + dx; + pixel(2) = pixel(2) + sy; + end + end + + assignin('caller',inputname(1),screen); %saves the changes to the object +end diff --git a/Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-2.m b/Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-2.m new file mode 100644 index 0000000000..825e75beed --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/MATLAB/bitmap-bresenhams-line-algorithm-2.m @@ -0,0 +1,8 @@ +>> img = Bitmap(800,600); +>> img.bresenhamLine([400 550],[200 400],[255 255 255]); +>> img.bresenhamLine([400 550],[600 400],[255 255 255]); +>> img.bresenhamLine([200 400],[350 150],[255 255 255]); +>> img.bresenhamLine([600 400],[450 150],[255 255 255]); +>> img.bresenhamLine([350 150],[450 150],[255 255 255]); +>> img.bresenhamLine([400 550],[400 150],[255 255 255]); +>> disp(img) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Perl/bitmap-bresenhams-line-algorithm.pl b/Task/Bitmap-Bresenhams-line-algorithm/Perl/bitmap-bresenhams-line-algorithm.pl new file mode 100644 index 0000000000..488c1d918b --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Perl/bitmap-bresenhams-line-algorithm.pl @@ -0,0 +1,63 @@ +#! /usr/bin/perl +use strict; +use Image::Imlib2; + +sub my_draw_line +{ + my ( $img, $x0, $y0, $x1, $y1) = @_; + + my $steep = (abs($y1 - $y0) > abs($x1 - $x0)); + if ( $steep ) { + ( $y0, $x0 ) = ( $x0, $y0); + ( $y1, $x1 ) = ( $x1, $y1 ); + } + if ( $x0 > $x1 ) { + ( $x1, $x0 ) = ( $x0, $x1 ); + ( $y1, $y0 ) = ( $y0, $y1 ); + } + my $deltax = $x1 - $x0; + my $deltay = abs($y1 - $y0); + my $error = $deltax / 2; + my $ystep; + my $y = $y0; + my $x; + $ystep = ( $y0 < $y1 ) ? 1 : -1; + for( $x = $x0; $x <= $x1; $x += 1 ) { + if ( $steep ) { + $img->draw_point($y, $x); + } else { + $img->draw_point($x, $y); + } + $error -= $deltay; + if ( $error < 0 ) { + $y += $ystep; + $error += $deltax; + } + } +} + +# test +my $img = Image::Imlib2->new(160, 160); +$img->set_color(255, 255, 255, 255); # white +$img->fill_rectangle(0,0,160,160); + +$img->set_color(0,0,0,255); # black +my_draw_line($img, 10, 80, 80, 160); +my_draw_line($img, 80, 160, 160, 80); +my_draw_line($img, 160, 80, 80, 10); +my_draw_line($img, 80, 10, 10, 80); + +$img->save("test0.png"); + +# let's try the same using its internal algo +$img->set_color(255, 255, 255, 255); # white +$img->fill_rectangle(0,0,160,160); +$img->set_color(0,0,0,255); # black +$img->draw_line(10, 80, 80, 160); +$img->draw_line(80, 160, 160, 80); +$img->draw_line(160, 80, 80, 10); +$img->draw_line(80, 10, 10, 80); + +$img->save("test1.png"); + +exit 0; diff --git a/Task/Bitmap-Bresenhams-line-algorithm/PicoLisp/bitmap-bresenhams-line-algorithm.l b/Task/Bitmap-Bresenhams-line-algorithm/PicoLisp/bitmap-bresenhams-line-algorithm.l new file mode 100644 index 0000000000..23985dcdc9 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/PicoLisp/bitmap-bresenhams-line-algorithm.l @@ -0,0 +1,39 @@ +(de brez (Img X Y DX DY) + (let SX + (cond + ((=0 DX) 0) + ((gt0 DX) 1) + (T (setq DX (- DX)) -1) ) + (let SY + (cond + ((=0 DY) 0) + ((gt0 DY) 1) + (T (setq DY (- DY)) -1) ) + (if (>= DX DY) + (let E (- (* 2 DY) DX) + (do DX + (set (nth Img Y X) 1) + (when (ge0 E) + (inc 'Y SY) + (dec 'E (* 2 DX)) ) + (inc 'X SX) + (inc 'E (* 2 DY)) ) ) + (let E (- (* 2 DX) DY) + (do DY + (set (nth Img Y X) 1) + (when (ge0 E) + (inc 'X SX) + (dec 'E (* 2 DY)) ) + (inc 'Y SY) + (inc 'E (* 2 DX)) ) ) ) ) ) ) + +(let Img (make (do 90 (link (need 120 0)))) # Create image 120 x 90 + (brez Img 10 10 100 30) # Draw five lines + (brez Img 10 10 100 50) + (brez Img 10 10 100 70) + (brez Img 10 10 60 70) + (brez Img 10 10 20 70) + (out "img.pbm" # Write to bitmap file + (prinl "P1") + (prinl 120 " " 90) + (mapc prinl Img) ) ) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Python/bitmap-bresenhams-line-algorithm.py b/Task/Bitmap-Bresenhams-line-algorithm/Python/bitmap-bresenhams-line-algorithm.py new file mode 100644 index 0000000000..4c79cd1f0e --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Python/bitmap-bresenhams-line-algorithm.py @@ -0,0 +1,58 @@ +def line(self, x0, y0, x1, y1): + "Bresenham's line algorithm" + dx = abs(x1 - x0) + dy = abs(y1 - y0) + x, y = x0, y0 + sx = -1 if x0 > x1 else 1 + sy = -1 if y0 > y1 else 1 + if dx > dy: + err = dx / 2.0 + while x != x1: + self.set(x, y) + err -= dy + if err < 0: + y += sy + err += dx + x += sx + else: + err = dy / 2.0 + while y != y1: + self.set(x, y) + err -= dx + if err < 0: + x += sx + err += dy + y += sy + self.set(x, y) +Bitmap.line = line + +bitmap = Bitmap(17,17) +for points in ((1,8,8,16),(8,16,16,8),(16,8,8,1),(8,1,1,8)): + bitmap.line(*points) +bitmap.chardisplay() + +''' +The origin, 0,0; is the lower left, with x increasing to the right, +and Y increasing upwards. + +The chardisplay above produces the following output : ++-----------------+ +| @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @| +| @ @ | +| @ @ | +| @ @@ | +| @ @ | +| @ @ | +| @ @ | +| @ | +| | ++-----------------+ +''' diff --git a/Task/Bitmap-Bresenhams-line-algorithm/REXX/bitmap-bresenhams-line-algorithm.rexx b/Task/Bitmap-Bresenhams-line-algorithm/REXX/bitmap-bresenhams-line-algorithm.rexx new file mode 100644 index 0000000000..82bd2e10e4 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/REXX/bitmap-bresenhams-line-algorithm.rexx @@ -0,0 +1,64 @@ +/*REXX program plots/draws a line using the Bresenham's line algorithm. */ + +EoE = 1000 /*EOE = End Of Earth, er, plot. */ +image. = 'fa'x /*fill the array with middle-dots*/ +plotC = 'fe'x /*character used for plotting pts*/ + do j=-EoE to +EoE /*draw grid from lowest──>highest*/ + image.j.0 = '─' /*draw the horizontal axis. */ + image.0.j = '│' /* " " verical " */ + end /*j*/ +image.0.0='┼' /*"draw" the axis origin. */ +parse arg xi yi xf yf . /*allow specifying line-end pts. */ +if xi=='' | xi==',' then xi = -1 /*if not specified, use default. */ +if yi=='' | yi==',' then yi = -3 /* " " " " " */ +if xf=='' | xf==',' then xf = 6 /* " " " " " */ +if yf=='' | yf==',' then yf = 10 /* " " " " " */ +call draw_line xi, yi, xf, yf /*call subroutine and draw line. */ +call findMaxXY + do y=maxY by -1 to minY; aRow= + do x=minX to maxX + aRow=aRow || image.x.y + end /*x*/ + say aRow + end /*y*/ +exit +/*────────────────────────────────DRAW_LINE subroutine──────────────────*/ +draw_line: procedure expose image. plotC; error=0 +parse arg xi 1 x0, yi 1 y0 1 y, xf 1 x1, yf 1 y1 +steep= abs(y1-y0) > abs(x1-x0) +if steep then parse value x0 y0 x1 y1 with y0 x0 y1 x1 +if x0>x1 then parse value x0 x1 y0 y1 with x1 x0 y1 y0 + + if y0=.5 then do; y=y+yInc; error=error-1; end + end +return +/*────────────────────────────────FINDMAXXY subroutine──────────────────*/ +findMaxXY: extra=3 /*don't just show cropped plot. */ + do minX=-EoE to +EoE /*find min X in the plot field. */ + do y=-EoE to +EoE; if .isP(image.minX.y) then leave minX; end /*y*/ + end /*minX*/ + + do maxX=+EoE to -EoE by -1 /*find max X in the plot field. */ + do y=-EoE to +EoE; if .isP(image.maxX.y) then leave maxX; end /*y*/ + end /*maxX*/ + + do minY=-EoE to +EoE /*find min Y in the plot field. */ + do x=-EoE to +EoE; if .isP(image.x.minY) then leave minY; end /*x*/ + end /*minY*/ + + do maxY=+EoE to -EoE by -1 /*find max Y in the plot field. */ + do x=-EoE to +EoE; if .isP(image.X.maxy) then leave maxY; end /*x*/ + end /*maxY*/ + +minX=minX-extra*2; minY=minY-extra /*like showbiz, show a little more*/ +maxX=maxX+extra*2; maxY=maxY+extra /* " " " " " " */ +return /*go ye forth and show ye plot. */ +.isP: return pos(arg(1),plotC)\==0 diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Ruby/bitmap-bresenhams-line-algorithm.rb b/Task/Bitmap-Bresenhams-line-algorithm/Ruby/bitmap-bresenhams-line-algorithm.rb new file mode 100644 index 0000000000..d623f230ca --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Ruby/bitmap-bresenhams-line-algorithm.rb @@ -0,0 +1,48 @@ +Pixel = Struct.new(:x, :y) + +class Pixmap + + def draw_line(p1, p2, colour) + validate_pixel(p1.x, p2.y) + validate_pixel(p2.x, p2.y) + + x1, y1 = p1.x, p1.y + x2, y2 = p2.x, p2.y + + steep = (y2 - y1).abs > (x2 - x1).abs + + if steep + x1, y1 = y1, x1 + x2, y2 = y2, x2 + end + + if x1 > x2 + x1, x2 = x2, x1 + y1, y2 = y2, y1 + end + + deltax = x2 - x1 + deltay = (y2 - y1).abs + error = deltax / 2 + ystep = y1 < y2 ? 1 : -1 + + y = y1 + x1.upto(x2) do |x| + pixel = steep ? [y,x] : [x,y] + self[*pixel] = colour + error -= deltay + if error < 0 + y += ystep + error += deltax + end + end + end +end + +bitmap = Pixmap.new(500, 500) +bitmap.fill(RGBColour::BLUE) +10.step(430, 60) do |a| + bitmap.draw_line(Pixel[10, 10], Pixel[490,a], RGBColour::YELLOW) + bitmap.draw_line(Pixel[10, 10], Pixel[a,490], RGBColour::YELLOW) +end +bitmap.draw_line(Pixel[10, 10], Pixel[490,490], RGBColour::YELLOW) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Scala/bitmap-bresenhams-line-algorithm.scala b/Task/Bitmap-Bresenhams-line-algorithm/Scala/bitmap-bresenhams-line-algorithm.scala new file mode 100644 index 0000000000..d1903e7044 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Scala/bitmap-bresenhams-line-algorithm.scala @@ -0,0 +1,24 @@ +object BitmapOps { + def bresenham(bm:RgbBitmap, x0:Int, y0:Int, x1:Int, y1:Int, c:Color)={ + val dx=math.abs(x1-x0) + val sx=if (x0dy) dx else -dy)/2 + def next={ + val res=(x,y) + val e2=err; + if (e2 > -dx) {err-=dy; x+=sx} + if (e2 abs($x1 - $x0)}] + if {$steep} { + lassign [list $x0 $y0] y0 x0 + lassign [list $x1 $y1] y1 x1 + } + if {$x0 > $x1} { + lassign [list $x0 $x1] x1 x0 + lassign [list $y0 $y1] y1 y0 + } + set deltax [expr {$x1 - $x0}] + set deltay [expr {abs($y1 - $y0)}] + set error [expr {$deltax / 2}] + set ystep [expr {$y0 < $y1 ? 1 : -1}] + + for {set x $x0; set y $y0} {$x <= $x1} {incr x} { + setPixel $image $colour [expr {$steep ? [list $y $x] : [list $x $y]}] + incr error -$deltay + if {$error < 0} { + incr y $ystep + incr error $deltax + } + } +} + +# create the image and display it +set img [newImage 200 100] +label .l -image $img +pack .l + +fill $img black +drawLine $img yellow {20 20} {180 80} +drawLine $img yellow {180 20} {20 80} diff --git a/Task/Bitmap-Flood-fill/0DESCRIPTION b/Task/Bitmap-Flood-fill/0DESCRIPTION new file mode 100644 index 0000000000..27b9e7100d --- /dev/null +++ b/Task/Bitmap-Flood-fill/0DESCRIPTION @@ -0,0 +1,8 @@ +Implement a [[wp:flood fill|flood fill]]. + +A flood fill is a way of filling an area using ''color banks'' to define the contained area or a ''target color'' which "determines" the area (the ''valley'' that can be flooded; Wikipedia uses the term ''target color''). It works almost like a water flooding from a point towards the banks (or: inside the valley): if there's a hole in the banks, the flood is not contained and all the image (or all the "connected valleys") get filled. + +To accomplish the task, you need to implement just one of the possible algorithms (examples are on [[wp:flood fill|Wikipedia]]). Variations on the ''theme'' are allowed (e.g. adding a tolerance parameter or argument for color-matching of the ''banks'' or ''target'' color). + +[[Image:Unfilledcirc.png|128px|thumb|right]] +'''Testing''': the basic algorithm is not suitable for ''truecolor'' images; a possible test image is the one shown on the right box; you can try to fill the white area, or the black inner circle. diff --git a/Task/Bitmap-Flood-fill/1META.yaml b/Task/Bitmap-Flood-fill/1META.yaml new file mode 100644 index 0000000000..c4801aa5b2 --- /dev/null +++ b/Task/Bitmap-Flood-fill/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Graphics algorithms +note: Raster graphics operations diff --git a/Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-1.ada b/Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-1.ada new file mode 100644 index 0000000000..3ed634e0a2 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-1.ada @@ -0,0 +1,106 @@ +procedure Flood_Fill + ( Picture : in out Image; + From : Point; + Fill : Pixel; + Replace : Pixel; + Distance : Luminance := 20 + ) is + function Diff (A, B : Luminance) return Luminance is + pragma Inline (Diff); + begin + if A > B then + return A - B; + else + return B - A; + end if; + end Diff; + + function "-" (A, B : Pixel) return Luminance is + pragma Inline ("-"); + begin + return Luminance'Max (Luminance'Max (Diff (A.R, B.R), Diff (A.G, B.G)), Diff (A.B, B.B)); + end "-"; + procedure Column (From : Point); + procedure Row (From : Point); + + Visited : array (Picture'Range (1), Picture'Range (2)) of Boolean := + (others => (others => False)); + + procedure Column (From : Point) is + X1 : Positive := From.X; + X2 : Positive := From.X; + begin + Visited (From.X, From.Y) := True; + for X in reverse Picture'First (1)..From.X - 1 loop + exit when Visited (X, From.Y); + declare + Color : Pixel renames Picture (X, From.Y); + begin + Visited (X, From.Y) := True; + exit when Color - Replace > Distance; + Color := Fill; + X1 := X; + end; + end loop; + for X in From.X + 1..Picture'Last (1) loop + exit when Visited (X, From.Y); + declare + Color : Pixel renames Picture (X, From.Y); + begin + Visited (X, From.Y) := True; + exit when Color - Replace > Distance; + Color := Fill; + X2 := X; + end; + end loop; + for X in X1..From.X - 1 loop + Row ((X, From.Y)); + end loop; + for X in From.X + 1..X2 loop + Row ((X, From.Y)); + end loop; + end Column; + + procedure Row (From : Point) is + Y1 : Positive := From.Y; + Y2 : Positive := From.Y; + begin + Visited (From.X, From.Y) := True; + for Y in reverse Picture'First (2)..From.Y - 1 loop + exit when Visited (From.X, Y); + declare + Color : Pixel renames Picture (From.X, Y); + begin + Visited (From.X, Y) := True; + exit when Color - Replace > Distance; + Color := Fill; + Y1 := Y; + end; + end loop; + for Y in From.Y + 1..Picture'Last (2) loop + exit when Visited (From.X, Y); + declare + Color : Pixel renames Picture (From.X, Y); + begin + Visited (From.X, Y) := True; + exit when Color - Replace > Distance; + Color := Fill; + Y2 := Y; + end; + end loop; + for Y in Y1..From.Y - 1 loop + Column ((From.X, Y)); + end loop; + for Y in From.Y + 1..Y2 loop + Column ((From.X, Y)); + end loop; + end Row; + + Color : Pixel renames Picture (From.X, From.Y); +begin + if Color - Replace <= Distance then + Visited (From.X, From.Y) := True; + Color := Fill; + Column (From); + end if; +end Flood_Fill; diff --git a/Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-2.ada b/Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-2.ada new file mode 100644 index 0000000000..3c1295d8e5 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Ada/bitmap-flood-fill-2.ada @@ -0,0 +1,19 @@ +declare + File : File_Type; +begin + Open (File, In_File, "Unfilledcirc.ppm"); + declare + Picture : Image := Get_PPM (File); + begin + Close (File); + Flood_Fill + ( Picture => Picture, + From => (122, 30), + Fill => (255,0,0), + Replace => White + ); + Create (File, Out_File, "Filledcirc.ppm"); + Put_PPM (File, Picture); + Close (File); + end; +end; diff --git a/Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-1.ahk b/Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-1.ahk new file mode 100644 index 0000000000..be964e5579 --- /dev/null +++ b/Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-1.ahk @@ -0,0 +1,41 @@ +SetBatchLines, -1 +CoordMode, Mouse +CoordMode, Pixel +CapsLock:: +KeyWait, CapsLock +MouseGetPos, X, Y +PixelGetColor, color, X, Y +FloodFill(x, y, color, 0x000000, 1, "CapsLock") +MsgBox Done! +Return +FloodFill(x, y, target, replacement, mode=1, key="") +{ + If GetKeyState(key, "P") + Return + PixelGetColor, color, x, y + If (color <> target || color = replacement || target = replacement) + Return + VarSetCapacity(Rect, 16, 0) + NumPut(x, Rect, 0) + NumPut(y, Rect, 4) + NumPut(x+1, Rect, 8) + NumPut(y+1, Rect, 12) + hDC := DllCall("GetDC", UInt, 0) + hBrush := DllCall("CreateSolidBrush", UInt, replacement) + DllCall("FillRect", UInt, hDC, Str, Rect, UInt, hBrush) + DllCall("ReleaseDC", UInt, 0, UInt, hDC) + DllCall("DeleteObject", UInt, hBrush) + FloodFill(x+1, y, target, replacement, mode, key) + FloodFill(x-1, y, target, replacement, mode, key) + FloodFill(x, y+1, target, replacement, mode, key) + FloodFill(x, y-1, target, replacement, mode, key) + If (mode = 2 || mode = 4) + FloodFill(x, y, target, replacement, mode, key) + If (Mode = 3 || mode = 4) + { + FloodFill(x+1, y+1, target, replacement, key) + FloodFill(x-1, y+1, target, replacement, key) + FloodFill(x+1, y-1, target, replacement, key) + FloodFill(x-1, y-1, target, replacement, key) + } +} diff --git a/Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-2.ahk b/Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-2.ahk new file mode 100644 index 0000000000..9ff5334cf8 --- /dev/null +++ b/Task/Bitmap-Flood-fill/AutoHotkey/bitmap-flood-fill-2.ahk @@ -0,0 +1,55 @@ +#NoEnv +#SingleInstance, Force + + SetBatchLines, -1 + CoordMode, Mouse + CoordMode, Pixel +return + +CapsLock:: + KeyWait, CapsLock + MouseGetPos, X, Y + PixelGetColor, color, X, Y + FloodFill(x, y, color, 0x000000, 1, "Esc") + MsgBox Done! +Return + +FloodFill( 0x, 0y, target, replacement, mode=1, key="" ) +{ + VarSetCapacity(Rect, 16, 0) + hDC := DllCall("GetDC", UInt, 0) + hBrush := DllCall("CreateSolidBrush", UInt, replacement) + + l := 0 + while l >= 0 + { + if getkeystate(key, "P") + return + x := %l%x, y := %l%y + %l%p++ + p := %l%p + PixelGetColor, color, x, y + if (color = target) + { + NumPut(x, Rect, 0) + NumPut(y, Rect, 4) + NumPut(x+1, Rect, 8) + NumPut(y+1, Rect, 12) + DllCall("FillRect", UInt, hDC, Str, Rect, UInt, hBrush) + } + else if (p = 1) + { + %l%x := %l%y := %l%p := "", l-- + continue + } + if (p < 5) + ol := l++ + , %l%x := %ol%x + (p = 1 ? 1 : p = 2 ? -1 : 0) + , %l%y := %ol%y + (p = 3 ? 1 : p = 4 ? -1 : 0) + else + %l%x := %l%y := %l%p := "", l-- + } + + DllCall("ReleaseDC", UInt, 0, UInt, hDC) + DllCall("DeleteObject", UInt, hBrush) +} diff --git a/Task/Bitmap-Flood-fill/BBC-BASIC/bitmap-flood-fill.bbc b/Task/Bitmap-Flood-fill/BBC-BASIC/bitmap-flood-fill.bbc new file mode 100644 index 0000000000..4085cdb770 --- /dev/null +++ b/Task/Bitmap-Flood-fill/BBC-BASIC/bitmap-flood-fill.bbc @@ -0,0 +1,24 @@ + MODE 8 + GCOL 15 + CIRCLE FILL 640, 512, 500 + GCOL 0 + CIRCLE FILL 500, 600, 200 + GCOL 3 + PROCflood(600, 200, 15) + GCOL 4 + PROCflood(600, 700, 0) + END + + DEF PROCflood(X%, Y%, C%) + LOCAL L%, R% + IF POINT(X%,Y%) <> C% ENDPROC + L% = X% + R% = X% + WHILE POINT(L%-2,Y%) = C% : L% -= 2 : ENDWHILE + WHILE POINT(R%+2,Y%) = C% : R% += 2 : ENDWHILE + LINE L%,Y%,R%,Y% + FOR X% = L% TO R% STEP 2 + PROCflood(X%, Y%+2, C%) + PROCflood(X%, Y%-2, C%) + NEXT + ENDPROC diff --git a/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-1.c b/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-1.c new file mode 100644 index 0000000000..0416ee2bd4 --- /dev/null +++ b/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-1.c @@ -0,0 +1,106 @@ +// http://commons.wikimedia.org/wiki/File:Julia_immediate_basin_1_3.png + +unsigned int f(unsigned int _iX, unsigned int _iY) +/* + gives position of point (iX,iY) in 1D array ; uses also global variables + it does not check if index is good so memory error is possible +*/ +{return (_iX + (iYmax-_iY-1)*iXmax );} + + +int FillContour(int iXseed, int iYseed, unsigned char color, unsigned char _data[]) +{ + /* + fills contour with black border ( color = iJulia) using seed point inside contour + and horizontal lines + it starts from seed point, saves max right( iXmaxLocal) and max left ( iXminLocal) interior points of horizontal line, + in new line ( iY+1 or iY-1) it computes new interior point : iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2; + result is stored in _data array : 1D array of 1-bit colors ( shades of gray) + it does not check if index of _data array is good so memory error is possible + */ + + + int iX, /* seed integer coordinate */ + iY=iYseed, + /* most interior point of line iY */ + iXmidLocal=iXseed, + /* min and max of interior points of horizontal line iY */ + iXminLocal, + iXmaxLocal; + int i ; /* index of _data array */; + + + /* --------- move up --------------- */ + do{ + iX=iXmidLocal; + i =f(iX,iY); /* index of _data array */; + + /* move to right */ + while (_data[i]==iInterior) + { _data[i]=color; + iX+=1; + i=f(iX,iY); + } + iXmaxLocal=iX-1; + + /* move to left */ + iX=iXmidLocal-1; + i=f(iX,iY); + while (_data[i]==iInterior) + { _data[i]=color; + iX-=1; + i=f(iX,iY); + } + iXminLocal=iX+1; + + + iY+=1; /* move up */ + iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2; /* new iX inside contour */ + i=f(iXmidLocal,iY); /* index of _data array */; + if ( _data[i]==iJulia) break; /* it should not cross the border */ + + } while (iY */ +typedef struct { + color_component red, green, blue; +} rgb_color; +typedef rgb_color *rgb_color_p; + +void floodfill(image img, int px, int py, + rgb_color_p bankscolor, + rgb_color_p rcolor); diff --git a/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-3.c b/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-3.c new file mode 100644 index 0000000000..8e9134edf6 --- /dev/null +++ b/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-3.c @@ -0,0 +1,93 @@ +#include "imglib.h" + +typedef struct _ffill_node { + int px, py; + TAILQ_ENTRY(_ffill_node) nodes; +} _ffill_node_t; +TAILQ_HEAD(_ffill_queue_s, _ffill_node); +typedef struct _ffill_queue_s _ffill_queue; + +inline void _ffill_removehead(_ffill_queue *q) +{ + _ffill_node_t *n = q->tqh_first; + if ( n != NULL ) { + TAILQ_REMOVE(q, n, nodes); + free(n); + } +} + +inline void _ffill_enqueue(_ffill_queue *q, int px, int py) +{ + _ffill_node_t *node; + node = malloc(sizeof(_ffill_node_t)); + if ( node != NULL ) { + node->px = px; node->py = py; + TAILQ_INSERT_TAIL(q, node, nodes); + } +} + +inline double color_distance( rgb_color_p a, rgb_color_p b ) +{ + return sqrt( (double)(a->red - b->red)*(a->red - b->red) + + (double)(a->green - b->green)*(a->green - b->green) + + (double)(a->blue - b->blue)*(a->blue - b->blue) ) / (256.0*sqrt(3.0)); +} + +inline void _ffill_rgbcolor(image img, rgb_color_p tc, int px, int py) +{ + tc->red = GET_PIXEL(img, px, py)[0]; + tc->green = GET_PIXEL(img, px, py)[1]; + tc->blue = GET_PIXEL(img, px, py)[2]; +} + + +#define NSOE(X,Y) do { \ + if ( ((X)>=0)&&((Y)>=0) && ((X)width)&&((Y)height)) { \ + _ffill_rgbcolor(img, &thisnode, (X), (Y)); \ + if ( color_distance(&thisnode, bankscolor) > tolerance ) { \ + if (color_distance(&thisnode, rcolor) > 0.0) { \ + put_pixel_unsafe(img, (X), (Y), rcolor->red, \ + rcolor->green, \ + rcolor->blue); \ + _ffill_enqueue(&head, (X), (Y)); \ + pixelcount++; \ + } \ + } \ + } \ + } while(0) + + +unsigned int floodfill(image img, int px, int py, + rgb_color_p bankscolor, + rgb_color_p rcolor) +{ + _ffill_queue head; + rgb_color thisnode; + unsigned int pixelcount = 0; + double tolerance = 0.05; + + if ( (px < 0) || (py < 0) || (px >= img->width) || (py >= img->height) ) + return; + + TAILQ_INIT(&head); + + _ffill_rgbcolor(img, &thisnode, px, py); + if ( color_distance(&thisnode, bankscolor) <= tolerance ) return; + + _ffill_enqueue(&head, px, py); + while( head.tqh_first != NULL ) { + _ffill_node_t *n = head.tqh_first; + _ffill_rgbcolor(img, &thisnode, n->px, n->py); + if ( color_distance(&thisnode, bankscolor) > tolerance ) { + put_pixel_unsafe(img, n->px, n->py, rcolor->red, rcolor->green, rcolor->blue); + pixelcount++; + } + int tx = n->px, ty = n->py; + _ffill_removehead(&head); + NSOE(tx - 1, ty); + NSOE(tx + 1, ty); + NSOE(tx, ty - 1); + NSOE(tx, ty + 1); + } + return pixelcount; +} diff --git a/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-4.c b/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-4.c new file mode 100644 index 0000000000..b41de6f1bd --- /dev/null +++ b/Task/Bitmap-Flood-fill/C/bitmap-flood-fill-4.c @@ -0,0 +1,27 @@ +#include +#include +#include "imglib.h" + +int main(int argc, char **argv) +{ + image animage; + rgb_color ic; + rgb_color rc; + + if ( argc > 1 ) { + animage = read_image(argv[1]); + if ( animage != NULL ) { + ic.red = 255; /* = 0; */ + ic.green = 255; /* = 0; */ + ic.blue = 255; /* = 0; */ + rc.red = 0; + rc.green = 255; + rc.blue = 0; + floodfill(animage, 100, 100, &ic, &rc); + /* 150, 150 */ + print_jpg(animage, 90); + free(animage); + } + } + return 0; +} diff --git a/Task/Bitmap-Flood-fill/Forth/bitmap-flood-fill.fth b/Task/Bitmap-Flood-fill/Forth/bitmap-flood-fill.fth new file mode 100644 index 0000000000..a1f5b39614 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Forth/bitmap-flood-fill.fth @@ -0,0 +1,28 @@ +: third 2 pick ; +: 3dup third third third ; +: 4dup 2over 2over ; + +: flood ( color x y bmp -- ) + 3dup b@ >r ( R: color to fill ) + 4dup b! + third 0 > if + rot 1- -rot + 3dup b@ r@ = if recurse then + rot 1+ -rot + then + third 1+ over bwidth < if + rot 1+ -rot + 3dup b@ r@ = if recurse then + rot 1- -rot + then + over 0 > if + swap 1- swap + 3dup b@ r@ = if recurse then + swap 1+ swap + then + over 1+ over bheight < if + swap 1+ swap + 3dup b@ r@ = if recurse then + swap 1- swap + then + r> drop ; diff --git a/Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-1.f b/Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-1.f new file mode 100644 index 0000000000..eb429bba8f --- /dev/null +++ b/Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-1.f @@ -0,0 +1,106 @@ +module RCImageArea + use RCImageBasic + use RCImagePrimitive + implicit none + + real, parameter, private :: matchdistance = 0.2 + + private :: northsouth, eastwest + +contains + + subroutine northsouth(img, p0, tcolor, fcolor) + type(rgbimage), intent(inout) :: img + type(point), intent(in) :: p0 + type(rgb), intent(in) :: tcolor, fcolor + + integer :: npy, spy, y + type(rgb) :: pc + + npy = p0%y - 1 + do + if ( inside_image(img, p0%x, npy) ) then + call get_pixel(img, p0%x, npy, pc) + if ( ((pc .dist. tcolor) > matchdistance ) .or. ( pc == fcolor ) ) exit + else + exit + end if + npy = npy - 1 + end do + npy = npy + 1 + spy = p0%y + 1 + do + if ( inside_image(img, p0%x, spy) ) then + call get_pixel(img, p0%x, spy, pc) + if ( ((pc .dist. tcolor) > matchdistance ) .or. ( pc == fcolor ) ) exit + else + exit + end if + spy = spy + 1 + end do + spy = spy - 1 + call draw_line(img, point(p0%x, spy), point(p0%x, npy), fcolor) + + do y = min(spy, npy), max(spy, npy) + if ( y == p0%y ) cycle + call eastwest(img, point(p0%x, y), tcolor, fcolor) + end do + + end subroutine northsouth + + + subroutine eastwest(img, p0, tcolor, fcolor) + type(rgbimage), intent(inout) :: img + type(point), intent(in) :: p0 + type(rgb), intent(in) :: tcolor, fcolor + + integer :: npx, spx, x + type(rgb) :: pc + + npx = p0%x - 1 + do + if ( inside_image(img, npx, p0%y) ) then + call get_pixel(img, npx, p0%y, pc) + if ( ((pc .dist. tcolor) > matchdistance ) .or. ( pc == fcolor ) ) exit + else + exit + end if + npx = npx - 1 + end do + npx = npx + 1 + spx = p0%x + 1 + do + if ( inside_image(img, spx, p0%y) ) then + call get_pixel(img, spx, p0%y, pc) + if ( ((pc .dist. tcolor) > matchdistance ) .or. ( pc == fcolor ) ) exit + else + exit + end if + spx = spx + 1 + end do + spx = spx - 1 + call draw_line(img, point(spx, p0%y), point(npx, p0%y), fcolor) + + do x = min(spx, npx), max(spx, npx) + if ( x == p0%x ) cycle + call northsouth(img, point(x, p0%y), tcolor, fcolor) + end do + + end subroutine eastwest + + subroutine floodfill(img, p0, tcolor, fcolor) + type(rgbimage), intent(inout) :: img + type(point), intent(in) :: p0 + type(rgb), intent(in) :: tcolor, fcolor + + type(rgb) :: pcolor + + if ( .not. inside_image(img, p0%x, p0%y) ) return + call get_pixel(img, p0%x, p0%y, pcolor) + if ( (pcolor .dist. tcolor) > matchdistance ) return + + call northsouth(img, p0, tcolor, fcolor) + call eastwest(img, p0, tcolor, fcolor) + end subroutine floodfill + +end module RCImageArea diff --git a/Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-2.f b/Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-2.f new file mode 100644 index 0000000000..0f69039d8f --- /dev/null +++ b/Task/Bitmap-Flood-fill/Fortran/bitmap-flood-fill-2.f @@ -0,0 +1 @@ + call floodfill(animage, point(100,100), rgb(0,0,0), rgb(0,255,0)) diff --git a/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go b/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go new file mode 100644 index 0000000000..63044625af --- /dev/null +++ b/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go @@ -0,0 +1,17 @@ +package raster + +func (b *Bitmap) Flood(x, y int, repl Pixel) { + targ, _ := b.GetPx(x, y) + var ff func(x, y int) + ff = func(x, y int) { + p, ok := b.GetPx(x, y) + if ok && p.R == targ.R && p.G == targ.G && p.B == targ.B { + b.SetPx(x, y, repl) + ff(x-1, y) + ff(x+1, y) + ff(x, y-1) + ff(x, y+1) + } + } + ff(x, y) +} diff --git a/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go b/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go new file mode 100644 index 0000000000..0e3bb2afa6 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "raster" +) + +func main() { + b, err := raster.ReadPpmFile("Unfilledcirc.ppm") + if err != nil { + fmt.Println(err) + return + } + b.Flood(200, 200, raster.Pixel{127, 0, 0}) + err = b.WritePpmFile("flood.ppm") + if err != nil { + fmt.Println(err) + return + } +} diff --git a/Task/Bitmap-Flood-fill/Haskell/bitmap-flood-fill.hs b/Task/Bitmap-Flood-fill/Haskell/bitmap-flood-fill.hs new file mode 100644 index 0000000000..a0d70c3038 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Haskell/bitmap-flood-fill.hs @@ -0,0 +1,110 @@ +import Data.Array.ST +import Data.STRef +import Control.Monad +import Control.Monad.ST +import Bitmap + +-- Implementation of a stack in the ST monad +pushST :: STStack s a -> a -> ST s () +pushST s e = do + s2 <- readSTRef s + writeSTRef s (e : s2) + +popST :: STStack s a -> ST s (Stack a) +popST s = do + s2 <- readSTRef s + writeSTRef s $ tail s2 + return $ take 1 s2 + +isNotEmptySTStack :: STStack s a -> ST s Bool +isNotEmptySTStack s = do + s2 <- readSTRef s + return $ not $ null s2 + +emptySTStack :: ST s (STStack s a) +emptySTStack = newSTRef [] + +consumeSTStack :: STStack s a -> (a -> ST s ()) -> ST s () +consumeSTStack s f = do + check <- isNotEmptySTStack s + when check $ do + e <- popST s + f $ head e + consumeSTStack s f + +type Spanning s = STRef s (Bool, Bool) + +setSpanLeft :: Spanning s -> Bool -> ST s () +setSpanLeft s v = do + (_, r) <- readSTRef s + writeSTRef s (v, r) + +setSpanRight :: Spanning s -> Bool -> ST s () +setSpanRight s v = do + (l, _) <- readSTRef s + writeSTRef s (l, v) + +setSpanNone :: Spanning s -> ST s () +setSpanNone s = writeSTRef s (False, False) + +floodFillScanlineStack :: Color c => Image s c -> Pixel -> c -> ST s (Image s c) +floodFillScanlineStack b coords newC = do + stack <- emptySTStack -- new empty stack holding pixels to fill + spans <- newSTRef (False, False) -- keep track of spans in scanWhileX + fFSS b stack coords newC spans -- function loop + return b + where + fFSS b st c newC p = do + oldC <- getPix b c + unless (oldC == newC) $ do + pushST st c -- store the coordinates in the stack + (w, h) <- dimensions b + consumeSTStack st (scanWhileY b p oldC >=> + scanWhileX b st p oldC newC (w, h)) + + -- take a buffer, the span record, the color of the Color the fill is + -- started from, a coordinate from the stack, and returns the coord + -- of the next point to be filled in the same column + scanWhileY b p oldC coords@(Pixel (x, y)) = + if y >= 0 + then do + z <- getPix b coords + if z == oldC + then scanWhileY b p oldC (Pixel (x, y - 1)) + else do + setSpanNone p + return (Pixel (x, y + 1)) + else do + setSpanNone p + return (Pixel (x, y + 1)) + + -- take a buffer, a stack, a span record, the old and new color, the + -- height and width of the buffer, and a coordinate. + -- paint the point with the new color, check if the fill must expand + -- to the left or right or both, and store those coordinates in the + -- stack for subsequent filling + scanWhileX b st p oldC newC (w, h) coords@(Pixel (x, y)) = + when (y < h) $ do + z <- getPix b coords + when (z == oldC) $ do + setPix b coords newC + (spanLeft, spanRight) <- readSTRef p + when (not spanLeft && x > 0) $ do + z2 <- getPix b (Pixel (x - 1, y)) + when (z2 == oldC) $ do + pushST st (Pixel (x - 1, y)) + setSpanLeft p True + when (spanLeft && x > 0) $ do + z3 <- getPix b (Pixel (x - 1, y)) + when (z3 /= oldC) $ + setSpanLeft p False + when (not spanRight && x < (w - 1)) $ do + z4 <- getPix b (Pixel (x + 1, y)) + when (z4 == oldC) $ do + pushST st (Pixel (x + 1, y)) + setSpanRight p True + when (spanRight && x < (w - 1)) $ do + z5 <- getPix b (Pixel (x + 1, y)) + when (z5 /= oldC) $ + setSpanRight p False + scanWhileX b st p oldC newC (w, h) (Pixel (x, y + 1)) diff --git a/Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-1.java b/Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-1.java new file mode 100644 index 0000000000..e12d9267e3 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-1.java @@ -0,0 +1,42 @@ +import java.awt.Color; +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.util.Deque; +import java.util.LinkedList; + +public class FloodFill { + public void floodFill(BufferedImage image, Point node, Color targetColor, Color replacementColor) { + int width = image.getWidth(); + int height = image.getHeight(); + int target = targetColor.getRGB(); + int replacement = replacementColor.getRGB(); + if (target != replacement) { + Deque queue = new LinkedList(); + do { + int x = node.x; + int y = node.y; + while (x > 0 && image.getRGB(x - 1, y) == target) { + x--; + } + boolean spanUp = false; + boolean spanDown = false; + while (x < width && image.getRGB(x, y) == target) { + image.setRGB(x, y, replacement); + if (!spanUp && y > 0 && image.getRGB(x, y - 1) == target) { + queue.add(new Point(x, y - 1)); + spanUp = true; + } else if (spanUp && y > 0 && image.getRGB(x, y - 1) != target) { + spanUp = false; + } + if (!spanDown && y < height - 1 && image.getRGB(x, y + 1) == target) { + queue.add(new Point(x, y + 1)); + spanDown = true; + } else if (spanDown && y < height - 1 && image.getRGB(x, y + 1) != target) { + spanDown = false; + } + x++; + } + } while ((node = queue.pollFirst()) != null); + } + } +} diff --git a/Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-2.java b/Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-2.java new file mode 100644 index 0000000000..4f83bf8a32 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Java/bitmap-flood-fill-2.java @@ -0,0 +1,18 @@ +import java.io.IOException; +import java.awt.Color; +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; + +public class Test { + public Test() throws IOException { + BufferedImage image = ImageIO.read(new File("Unfilledcirc.png")); + new FloodFill().floodFill(image, new Point(50, 50), Color.WHITE, Color.RED); + ImageIO.write(image, "png", new File("output.png")); + } + + public static void main(String[] args) throws IOException { + new Test(); + } +} diff --git a/Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-1.pl b/Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-1.pl new file mode 100644 index 0000000000..294772f64d --- /dev/null +++ b/Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-1.pl @@ -0,0 +1,10 @@ +#! /usr/bin/perl + +use strict; +use Image::Imlib2; + +my $img = Image::Imlib2->load("Unfilledcirc.jpg"); +$img->set_color(0, 255, 0, 255); +$img->fill(100,100); +$img->save("filledcirc.jpg"); +exit 0; diff --git a/Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-2.pl b/Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-2.pl new file mode 100644 index 0000000000..049af58478 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Perl/bitmap-flood-fill-2.pl @@ -0,0 +1,48 @@ +use strict; +use Image::Imlib2; + +sub colordistance +{ + my ( $c1, $c2 ) = @_; + + my ( $r1, $g1, $b1 ) = @$c1; + my ( $r2, $g2, $b2 ) = @$c2; + return sqrt(( ($r1-$r2)**2 + ($g1-$g2)**2 + ($b1-$b2)**2 ))/(255.0*sqrt(3.0)); +} + +sub floodfill +{ + my ( $img, $x, $y, $r, $g, $b ) = @_; + my $distparameter = 0.2; + + my %visited = (); + my @queue = (); + + my @tcol = ( $r, $g, $b ); + my @col = $img->query_pixel($x, $y); + if ( colordistance(\@tcol, \@col) > $distparameter ) { return; } + push @queue, [$x, $y]; + while ( @queue ) { + my $pointref = shift(@queue); + ( $x, $y ) = @$pointref; + if ( ($x < 0) || ($y < 0) || ( $x >= $img->width ) || ( $y >= $img->height ) ) { next; } + if ( ! exists($visited{"$x,$y"}) ) { + @col = $img->query_pixel($x, $y); + if ( colordistance(\@tcol, \@col) <= $distparameter ) { + $img->draw_point($x, $y); + $visited{"$x,$y"} = 1; + push @queue, [$x+1, $y]; + push @queue, [$x-1, $y]; + push @queue, [$x, $y+1]; + push @queue, [$x, $y-1]; + } + } + } +} + +# usage example +my $img = Image::Imlib2->load("Unfilledcirc.jpg"); +$img->set_color(0,255,0,255); +floodfill($img, 100,100, 0, 0, 0); +$img->save("filledcirc1.jpg"); +exit 0; diff --git a/Task/Bitmap-Flood-fill/PicoLisp/bitmap-flood-fill.l b/Task/Bitmap-Flood-fill/PicoLisp/bitmap-flood-fill.l new file mode 100644 index 0000000000..5091ed7f3b --- /dev/null +++ b/Task/Bitmap-Flood-fill/PicoLisp/bitmap-flood-fill.l @@ -0,0 +1,10 @@ +(de ppmFloodFill (Ppm X Y Color) + (let Target (get Ppm Y X) + (recur (X Y) + (when (= Target (get Ppm Y X)) + (set (nth Ppm Y X) Color) + (recurse (dec X) Y) + (recurse (inc X) Y) + (recurse X (dec Y)) + (recurse X (inc Y)) ) ) ) + Ppm ) diff --git a/Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-1.py b/Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-1.py new file mode 100644 index 0000000000..1d383c025d --- /dev/null +++ b/Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-1.py @@ -0,0 +1,44 @@ +import Image +def FloodFill( fileName, initNode, targetColor, replaceColor ): + img = Image.open( fileName ) + pix = img.load() + xsize, ysize = img.size + Q = [] + if pix[ initNode[0], initNode[1] ] != targetColor: + return img + Q.append( initNode ) + while Q != []: + node = Q.pop(0) + if pix[ node[0], node[1] ] == targetColor: + W = list( node ) + if node[0] + 1 < xsize: + E = list( [ node[0] + 1, node[1] ] ) + else: + E = list( node ) + # Move west until color of node does not match targetColor + while pix[ W[0], W[1] ] == targetColor: + pix[ W[0], W[1] ] = replaceColor + if W[1] + 1 < ysize: + if pix[ W[0], W[1] + 1 ] == targetColor: + Q.append( [ W[0], W[1] + 1 ] ) + if W[1] - 1 >= 0: + if pix[ W[0], W[1] - 1 ] == targetColor: + Q.append( [ W[0], W[1] - 1 ] ) + if W[0] - 1 >= 0: + W[0] = W[0] - 1 + else: + break + # Move east until color of node does not match targetColor + while pix[ E[0], E[1] ] == targetColor: + pix[ E[0], E[1] ] = replaceColor + if E[1] + 1 < ysize: + if pix[ E[0], E[1] + 1 ] == targetColor: + Q.append( [ E[0], E[1] + 1 ] ) + if E[1] - 1 >= 0: + if pix[ E[0], E[1] - 1 ] == targetColor: + Q.append( [ E[0], E[1] -1 ] ) + if E[0] + 1 < xsize: + E[0] = E[0] + 1 + else: + break + return img diff --git a/Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-2.py b/Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-2.py new file mode 100644 index 0000000000..cee5b2a5b1 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Python/bitmap-flood-fill-2.py @@ -0,0 +1,7 @@ +# "FloodFillClean.png" is name of input file +# [55,55] the x,y coordinate where fill starts +# (0,0,0,255) the target colour being filled( black in this example ) +# (255,255,255,255) the final colour ( white in this case ) +img = FloodFill( "FloodFillClean.png", [55,55], (0,0,0,255), (255,255,255,255) ) +#The resulting image is saved as Filled.png +img.save( "Filled.png" ) diff --git a/Task/Bitmap-Flood-fill/Racket/bitmap-flood-fill.rkt b/Task/Bitmap-Flood-fill/Racket/bitmap-flood-fill.rkt new file mode 100644 index 0000000000..eaf8ba2982 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Racket/bitmap-flood-fill.rkt @@ -0,0 +1,82 @@ +#lang racket + +(require racket/draw) + +;; flood-fill: bitmap<%> number number color color -> void +;; An example of flood filling a bitmap. +;; +;; We'll use a raw, byte-oriented interface here for demonstration +;; purposes. Racket does provide get-pixel and set-pixel functions +;; which work on color% structures rather than bytes, but it's useful +;; to see that the byte approach works as well. +(define (flood-fill bm start-x start-y target-color replacement-color) + ;; The main loop. + ;; http://en.wikipedia.org/wiki/Flood_fill + (define (iter x y) + (when (and (in-bounds? x y) (target-color-at? x y)) + (replace-color-at! x y) + (iter (add1 x) y) + (iter (sub1 x) y) + (iter x (add1 y)) + (iter x (sub1 y)))) + + ;; With auxillary definitions below: + (define width (send bm get-width)) + (define height (send bm get-height)) + + (define buffer (make-bytes (* width height 4))) + (send bm get-argb-pixels 0 0 width height buffer) + + (define-values (target-red target-green target-blue) + (values (send target-color red) + (send target-color green) + (send target-color blue))) + + (define-values (replacement-red replacement-green replacement-blue) + (values (send replacement-color red) + (send replacement-color green) + (send replacement-color blue))) + + (define (offset-at x y) (* 4 (+ (* y width) x))) + + (define (target-color-at? x y) + (define offset (offset-at x y)) + (and (= (bytes-ref buffer (+ offset 1)) target-red) + (= (bytes-ref buffer (+ offset 2)) target-green) + (= (bytes-ref buffer (+ offset 3)) target-blue))) + + (define (replace-color-at! x y) + (define offset (offset-at x y)) + (bytes-set! buffer (+ offset 1) replacement-red) + (bytes-set! buffer (+ offset 2) replacement-green) + (bytes-set! buffer (+ offset 3) replacement-blue)) + + (define (in-bounds? x y) + (and (<= 0 x) (< x width) (<= 0 y) (< y height))) + + ;; Finally, let's do the fill, and then store the + ;; result back into the bitmap: + (iter start-x start-y) + (send bm set-argb-pixels 0 0 width height buffer)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Example: flood fill a hole shape. +(define bm (make-bitmap 100 100)) +(define dc (send bm make-dc)) + +;; We intentionally set the smoothing of the dc to +;; aligned so that there are no gaps in the shape for the +;; flood to leak through. +(send dc set-smoothing 'aligned) +(send dc draw-rectangle 10 10 80 80) +(send dc draw-rounded-rectangle 20 20 50 50) +;; In DrRacket, we can print the bm to look at it graphically, +;; before the flood fill: +bm + +(flood-fill bm 50 50 + (send the-color-database find-color "white") + (send the-color-database find-color "DarkSeaGreen")) +;; ... and after: +bm diff --git a/Task/Bitmap-Flood-fill/Ruby/bitmap-flood-fill.rb b/Task/Bitmap-Flood-fill/Ruby/bitmap-flood-fill.rb new file mode 100644 index 0000000000..738f983bfa --- /dev/null +++ b/Task/Bitmap-Flood-fill/Ruby/bitmap-flood-fill.rb @@ -0,0 +1,57 @@ +class RGBColour + def ==(a_colour) + values == a_colour.values + end +end + +class Queue < Array + alias_method :enqueue, :push + alias_method :dequeue, :shift +end + +class Pixmap + def flood_fill(pixel, new_colour) + current_colour = self[pixel.x, pixel.y] + queue = Queue.new + queue.enqueue(pixel) + until queue.empty? + p = queue.dequeue + if self[p.x, p.y] == current_colour + west = find_border(p, current_colour, :west) + east = find_border(p, current_colour, :east) + draw_line(west, east, new_colour) + q = west + while q.x <= east.x + [:north, :south].each do |direction| + n = neighbour(q, direction) + queue.enqueue(n) if self[n.x, n.y] == current_colour + end + q = neighbour(q, :east) + end + end + end + end + + def neighbour(pixel, direction) + case direction + when :north then Pixel[pixel.x, pixel.y - 1] + when :south then Pixel[pixel.x, pixel.y + 1] + when :east then Pixel[pixel.x + 1, pixel.y] + when :west then Pixel[pixel.x - 1, pixel.y] + end + end + + def find_border(pixel, colour, direction) + nextp = neighbour(pixel, direction) + while self[nextp.x, nextp.y] == colour + pixel = nextp + nextp = neighbour(pixel, direction) + end + pixel + end +end + +bitmap = Pixmap.new(300, 300) +bitmap.draw_circle(Pixel[149,149], 120, RGBColour::BLACK) +bitmap.draw_circle(Pixel[200,100], 40, RGBColour::BLACK) +bitmap.flood_fill(Pixel[140,160], RGBColour::BLUE) diff --git a/Task/Bitmap-Flood-fill/Tcl/bitmap-flood-fill.tcl b/Task/Bitmap-Flood-fill/Tcl/bitmap-flood-fill.tcl new file mode 100644 index 0000000000..a6efd22cc5 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Tcl/bitmap-flood-fill.tcl @@ -0,0 +1,74 @@ +package require Tcl 8.5 +package require Tk +package require struct::queue + +proc floodFill {img colour point} { + set new [colour2rgb $colour] + set old [getPixel $img $point] + struct::queue Q + Q put $point + while {[Q size] > 0} { + set p [Q get] + if {[getPixel $img $p] eq $old} { + set w [findBorder $img $p $old west] + set e [findBorder $img $p $old east] + drawLine $img $new $w $e + set q $w + while {[x $q] <= [x $e]} { + set n [neighbour $q north] + if {[getPixel $img $n] eq $old} {Q put $n} + set s [neighbour $q south] + if {[getPixel $img $s] eq $old} {Q put $s} + set q [neighbour $q east] + } + } + } + Q destroy +} + +proc findBorder {img p colour dir} { + set lookahead [neighbour $p $dir] + while {[getPixel $img $lookahead] eq $colour} { + set p $lookahead + set lookahead [neighbour $p $dir] + } + return $p +} + +proc x p {lindex $p 0} +proc y p {lindex $p 1} + +proc neighbour {p dir} { + lassign $p x y + switch -exact -- $dir { + west {return [list [incr x -1] $y]} + east {return [list [incr x] $y]} + north {return [list $x [incr y -1]]} + south {return [list $x [incr y]]} + } +} + +proc colour2rgb {color_name} { + foreach part [winfo rgb . $color_name] { + append colour [format %02x [expr {$part >> 8}]] + } + return #$colour +} + +set img [newImage 70 50] +fill $img white + +drawLine $img blue {0 0} {0 25} +drawLine $img blue {0 25} {35 25} +drawLine $img blue {35 25} {35 0} +drawLine $img blue {35 0} {0 0} +floodFill $img yellow {3 3} + +drawCircle $img black {35 25} 24 +drawCircle $img black {35 25} 10 +floodFill $img orange {34 5} +floodFill $img red {36 5} + +toplevel .flood +label .flood.l -image $img +pack .flood.l diff --git a/Task/Bitmap-Histogram/0DESCRIPTION b/Task/Bitmap-Histogram/0DESCRIPTION new file mode 100644 index 0000000000..1f92525219 --- /dev/null +++ b/Task/Bitmap-Histogram/0DESCRIPTION @@ -0,0 +1,10 @@ +Extend the basic bitmap storage defined [[Basic_bitmap_storage|on this page]] to support dealing with image histograms. The image histogram contains for each luminance the count of image pixels having this luminance. Choosing a histogram representation take care about the data type used for the counts. It must have range of at least 0..NxM, where N is the image width and M is the image height. + +'''Test task''' + +Histogram is useful for many image processing operations. As an example, use it to convert an image into black and white art. The method works as follows: +* Convert image to grayscale; +* Compute the histogram +* Find the median: defined as the luminance such that the image has an approximately equal number of pixels with lesser and greater luminance. +* Replace each pixel of luminance lesser than the median to black, and others to white. +Use [[read ppm file | read]]/[[write ppm file]], and [[grayscale image]] solutions. diff --git a/Task/Bitmap-Histogram/1META.yaml b/Task/Bitmap-Histogram/1META.yaml new file mode 100644 index 0000000000..58807afa1b --- /dev/null +++ b/Task/Bitmap-Histogram/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Image processing diff --git a/Task/Bitmap-Histogram/Ada/bitmap-histogram-1.ada b/Task/Bitmap-Histogram/Ada/bitmap-histogram-1.ada new file mode 100644 index 0000000000..34aea24b09 --- /dev/null +++ b/Task/Bitmap-Histogram/Ada/bitmap-histogram-1.ada @@ -0,0 +1,17 @@ +type Pixel_Count is mod 2**64; +type Histogram is array (Luminance) of Pixel_Count; + +function Get_Histogram (Picture : Grayscale_Image) return Histogram is + Result : Histogram := (others => 0); +begin + for I in Picture'Range (1) loop + for J in Picture'Range (2) loop + declare + Count : Pixel_Count renames Result (Picture (I, J)); + begin + Count := Count + 1; + end; + end loop; + end loop; + return Result; +end Get_Histogram; diff --git a/Task/Bitmap-Histogram/Ada/bitmap-histogram-2.ada b/Task/Bitmap-Histogram/Ada/bitmap-histogram-2.ada new file mode 100644 index 0000000000..2a0092b9c2 --- /dev/null +++ b/Task/Bitmap-Histogram/Ada/bitmap-histogram-2.ada @@ -0,0 +1,17 @@ +function Median (H : Histogram) return Luminance is + From : Luminance := Luminance'First; + To : Luminance := Luminance'Last; + Left : Pixel_Count := H (From); + Right : Pixel_Count := H (To); +begin + while From /= To loop + if Left < Right then + From := From + 1; + Left := Left + H (From); + else + To := To - 1; + Right := Right + H (To); + end if; + end loop; + return From; +end Median; diff --git a/Task/Bitmap-Histogram/Ada/bitmap-histogram-3.ada b/Task/Bitmap-Histogram/Ada/bitmap-histogram-3.ada new file mode 100644 index 0000000000..684e132fe5 --- /dev/null +++ b/Task/Bitmap-Histogram/Ada/bitmap-histogram-3.ada @@ -0,0 +1,22 @@ + F1, F2 : File_Type; +begin + Open (F1, In_File, "city.ppm"); + declare + X : Image := Get_PPM (F1); + Y : Grayscale_Image := Grayscale (X); + T : Luminance := Median (Get_Histogram (Y)); + begin + Close (F1); + Create (F2, Out_File, "city_art.ppm"); + for I in Y'Range (1) loop + for J in Y'Range (2) loop + if Y (I, J) < T then + X (I, J) := Black; + else + X (I, J) := White; + end if; + end loop; + end loop; + Put_PPM (F2, X); + end; + Close (F2); diff --git a/Task/Bitmap-Histogram/BBC-BASIC/bitmap-histogram.bbc b/Task/Bitmap-Histogram/BBC-BASIC/bitmap-histogram.bbc new file mode 100644 index 0000000000..b524e393ed --- /dev/null +++ b/Task/Bitmap-Histogram/BBC-BASIC/bitmap-histogram.bbc @@ -0,0 +1,59 @@ + INSTALL @lib$+"SORTLIB" + Sort% = FN_sortinit(0,0) + + Width% = 200 + Height% = 200 + + VDU 23,22,Width%;Height%;8,16,16,128 + *display c:\lenagrey + + DIM hist%(255), idx%(255) + FOR i% = 0 TO 255 : idx%(i%) = i% : NEXT + + REM Build histogram: + FOR y% = 0 TO Height%-1 + FOR x% = 0 TO Width%-1 + l% = FNgetpixel(x%,y%) AND &FF + hist%(l%) += 1 + NEXT + NEXT y% + + REM Sort histogram: + C% = 256 + CALL Sort%, hist%(0), idx%(0) + + REM Find median: + total% = SUM(hist%()) + half% = 0 + FOR i% = 0 TO 255 + half% += hist%(i%) + IF half% >= total%/2 THEN + median% = idx%(i%) + EXIT FOR + ENDIF + NEXT + + REM Display black & white version: + FOR y% = 0 TO Height%-1 + FOR x% = 0 TO Width%-1 + l% = FNgetpixel(x%,y%) AND &FF + IF l% > median% THEN + PROCsetpixel(x%,y%,255,255,255) + ELSE + PROCsetpixel(x%,y%,0,0,0) + ENDIF + NEXT + NEXT y% + END + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC + + DEF FNgetpixel(x%,y%) + LOCAL col% + col% = TINT(x%*2,y%*2) + SWAP ?^col%,?(^col%+2) + = col% diff --git a/Task/Bitmap-Histogram/C/bitmap-histogram-1.c b/Task/Bitmap-Histogram/C/bitmap-histogram-1.c new file mode 100644 index 0000000000..bd3dd11854 --- /dev/null +++ b/Task/Bitmap-Histogram/C/bitmap-histogram-1.c @@ -0,0 +1,7 @@ +typedef unsigned int histogram_t; +typedef histogram_t *histogram; + +#define GET_LUM(IMG, X, Y) ( (IMG)->buf[ (Y) * (IMG)->width + (X)][0] ) + +histogram get_histogram(grayimage im); +luminance histogram_median(histogram h); diff --git a/Task/Bitmap-Histogram/C/bitmap-histogram-2.c b/Task/Bitmap-Histogram/C/bitmap-histogram-2.c new file mode 100644 index 0000000000..b29ca11b0d --- /dev/null +++ b/Task/Bitmap-Histogram/C/bitmap-histogram-2.c @@ -0,0 +1,20 @@ +histogram get_histogram(grayimage im) +{ + histogram t; + unsigned int x, y; + + if ( im == NULL ) return NULL; + t = malloc( sizeof(histogram_t)*256 ); + memset(t, 0, sizeof(histogram_t)*256 ); + if (t!=NULL) + { + for(x=0; x < im->width; x++ ) + { + for(y=0; y < im->height; y++ ) + { + t[ GET_LUM(im, x, y) ]++; + } + } + } + return t; +} diff --git a/Task/Bitmap-Histogram/C/bitmap-histogram-3.c b/Task/Bitmap-Histogram/C/bitmap-histogram-3.c new file mode 100644 index 0000000000..7589248031 --- /dev/null +++ b/Task/Bitmap-Histogram/C/bitmap-histogram-3.c @@ -0,0 +1,19 @@ +luminance histogram_median(histogram h) +{ + luminance From, To; + unsigned int Left, Right; + + From = 0; To = (1 << (8*sizeof(luminance)))-1; + Left = h[From]; Right = h[To]; + + while( From != To ) + { + if ( Left < Right ) + { + From++; Left += h[From]; + } else { + To--; Right += h[To]; + } + } + return From; +} diff --git a/Task/Bitmap-Histogram/C/bitmap-histogram-4.c b/Task/Bitmap-Histogram/C/bitmap-histogram-4.c new file mode 100644 index 0000000000..c778aa764a --- /dev/null +++ b/Task/Bitmap-Histogram/C/bitmap-histogram-4.c @@ -0,0 +1,50 @@ +#include +#include +#include "imglib.h" + +/* usage example */ + +#define BLACK 0,0,0 +#define WHITE 255,255,255 + +int main(int argc, char **argv) +{ + image color_img; + grayimage g_img; + histogram h; + luminance T; + unsigned int x, y; + + if ( argc < 2 ) + { + fprintf(stderr, "histogram FILE\n"); + exit(1); + } + color_img = read_image(argv[1]); + if ( color_img == NULL ) exit(1); + g_img = tograyscale(color_img); + h = get_histogram(g_img); + if ( h != NULL ) + { + T = histogram_median(h); + + for(x=0; x < g_img->width; x++) + { + for(y=0; y < g_img->height; y++) + { + if ( GET_LUM(g_img,x,y) < T ) + { + put_pixel_unsafe(color_img, x, y, BLACK); + } else { + put_pixel_unsafe(color_img, x, y, WHITE); + } + } + } + output_ppm(stdout, color_img); + /* print_jpg(color_img, 90); */ + free(h); + } + + free_img((image)g_img); + free_img(color_img); +} diff --git a/Task/Bitmap-Histogram/Forth/bitmap-histogram.fth b/Task/Bitmap-Histogram/Forth/bitmap-histogram.fth new file mode 100644 index 0000000000..ee25d481d2 --- /dev/null +++ b/Task/Bitmap-Histogram/Forth/bitmap-histogram.fth @@ -0,0 +1,4 @@ +: histogram ( array gmp -- ) + over 256 cells erase + dup bdim * over bdata + swap bdata + do 1 over i c@ cells + +! loop drop ; diff --git a/Task/Bitmap-Histogram/Fortran/bitmap-histogram-1.f b/Task/Bitmap-Histogram/Fortran/bitmap-histogram-1.f new file mode 100644 index 0000000000..5032351d06 --- /dev/null +++ b/Task/Bitmap-Histogram/Fortran/bitmap-histogram-1.f @@ -0,0 +1,40 @@ +module RCImageProcess + use RCImageBasic + implicit none +contains + + subroutine get_histogram(img, histogram) + type(scimage), intent(in) :: img + integer, dimension(0:255), intent(out) :: histogram + + integer :: i + + histogram = 0 + do i = 0,255 + histogram(i) = sum(img%channel, img%channel == i) + end do + end subroutine get_histogram + + function histogram_median(histogram) + integer, dimension(0:255), intent(in) :: histogram + integer :: histogram_median + + integer :: from, to, left, right + + from = 0 + to = 255 + left = histogram(from) + right = histogram(to) + do while ( from /= to ) + if ( left < right ) then + from = from + 1 + left = left + histogram(from) + else + to = to - 1 + right = right + histogram(to) + end if + end do + histogram_median = from + end function histogram_median + +end module RCImageProcess diff --git a/Task/Bitmap-Histogram/Fortran/bitmap-histogram-2.f b/Task/Bitmap-Histogram/Fortran/bitmap-histogram-2.f new file mode 100644 index 0000000000..3295fa5248 --- /dev/null +++ b/Task/Bitmap-Histogram/Fortran/bitmap-histogram-2.f @@ -0,0 +1,42 @@ +program BasicImageTests + use RCImageBasic + use RCImageIO + use RCImageProcess + + implicit none + + type(rgbimage) :: animage + type(scimage) :: gray + integer, dimension(0:255) :: histo + integer :: ml + + open(unit=10, file='lenna.ppm', action='read', status='old') + call read_ppm(10, animage) + close(10) + + call init_img(gray) + ! or + ! call alloc_img(gray, animage%width, animage%height) + + gray = animage + + call get_histogram(gray, histo) + ml = histogram_median(histo) + where ( gray%channel >= ml ) + animage%red = 255 + animage%green = 255 + animage%blue = 255 + elsewhere + animage%red = 0 + animage%green = 0 + animage%blue = 0 + end where + + open(unit=10, file='elaborated.ppm', action='write') + call output_ppm(10, animage) + close(10) + + call free_img(animage) + call free_img(gray) + +end program BasicImageTests diff --git a/Task/Bitmap-Histogram/Go/bitmap-histogram-1.go b/Task/Bitmap-Histogram/Go/bitmap-histogram-1.go new file mode 100644 index 0000000000..f5deb719cf --- /dev/null +++ b/Task/Bitmap-Histogram/Go/bitmap-histogram-1.go @@ -0,0 +1,24 @@ +package raster + +import "math" + +func (g *Grmap) Histogram(bins int) []int { + if bins <= 0 { + bins = g.cols + } + h := make([]int, bins) + for _, p := range g.px { + h[int(p)*(bins-1)/math.MaxUint16]++ + } + return h +} + +func (g *Grmap) Threshold(t uint16) { + for i, p := range g.px { + if p < t { + g.px[i] = 0 + } else { + g.px[i] = math.MaxUint16 + } + } +} diff --git a/Task/Bitmap-Histogram/Go/bitmap-histogram-2.go b/Task/Bitmap-Histogram/Go/bitmap-histogram-2.go new file mode 100644 index 0000000000..37e0e2e161 --- /dev/null +++ b/Task/Bitmap-Histogram/Go/bitmap-histogram-2.go @@ -0,0 +1,45 @@ +package main + +// Files required to build supporting package raster are found in: +// * This task (immediately above) +// * Bitmap +// * Grayscale image +// * Read a PPM file +// * Write a PPM file + +import ( + "raster" + "fmt" + "math" +) + +func main() { + // (A file with this name is output by the Go solution to the task + // "Bitmap/Read an image through a pipe," but of course any 8-bit + // P6 PPM file should work.) + b, err := raster.ReadPpmFile("pipein.ppm") + if err != nil { + fmt.Println(err) + return + } + g := b.Grmap() + h := g.Histogram(0) + // compute median + lb, ub := 0, len(h)-1 + var lSum, uSum int + for lb <= ub { + if lSum+h[lb] < uSum+h[ub] { + lSum += h[lb] + lb++ + } else { + uSum += h[ub] + ub-- + } + } + // apply threshold and write output file + g.Threshold(uint16(ub * math.MaxUint16 / len(h))) + err = g.Bitmap().WritePpmFile("threshold.ppm") + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-Histogram/Haskell/bitmap-histogram-1.hs b/Task/Bitmap-Histogram/Haskell/bitmap-histogram-1.hs new file mode 100644 index 0000000000..cf203c638f --- /dev/null +++ b/Task/Bitmap-Histogram/Haskell/bitmap-histogram-1.hs @@ -0,0 +1,32 @@ +module Bitmap.BW(module Bitmap.BW) where + +import Bitmap +import Control.Monad.ST + +newtype BW = BW Bool deriving (Eq, Ord) + +instance Color BW where + luminance (BW False) = 0 + luminance _ = 255 + black = BW False + white = BW True + toNetpbm [] = "" + toNetpbm l = init (concatMap f line) ++ "\n" ++ toNetpbm rest + where (line, rest) = splitAt 35 l + f (BW False) = "1 " + f _ = "0 " + fromNetpbm = map f + where f 1 = black + f _ = white + netpbmMagicNumber _ = "P1" + netpbmMaxval _ = "" + +toBWImage :: Color c => Image s c -> ST s (Image s BW) +toBWImage = toBWImage' 128 + +toBWImage' :: Color c => Int -> Image s c -> ST s (Image s BW) +{- The first argument gives the darkest luminance assigned +to white. -} +toBWImage' darkestWhite = mapImage $ f . luminance + where f x | x < darkestWhite = black + | otherwise = white diff --git a/Task/Bitmap-Histogram/Haskell/bitmap-histogram-2.hs b/Task/Bitmap-Histogram/Haskell/bitmap-histogram-2.hs new file mode 100644 index 0000000000..0d3c59d549 --- /dev/null +++ b/Task/Bitmap-Histogram/Haskell/bitmap-histogram-2.hs @@ -0,0 +1,27 @@ +import Bitmap +import Bitmap.RGB +import Bitmap.BW +import Bitmap.Netpbm +import Control.Monad.ST +import Data.Array + +main = do + i <- readNetpbm "original.ppm" :: IO (Image RealWorld RGB) + writeNetpbm "bw.pbm" =<< stToIO (do + h <- histogram i + toBWImage' (medianIndex h) i) + +histogram :: Color c => Image s c -> ST s [Int] +histogram = liftM f . getPixels where + f = elems . accumArray (+) 0 (0, 255) . map (\i -> (luminance i, 1)) + +medianIndex :: [Int] -> Int +{- Given a list l, finds the index i that minimizes + abs $ sum (take i l) - sum (drop i l) -} +medianIndex l = result + where (result, _, _, _, _) = + iterate f (0, 0, 0, l, reverse l) !! (length l - 1) + f (n, left, right, lL@(l : ls), rL@(r : rs)) = + if left < right + then (n + 1, left + l, right, ls, rL) + else (n, left, right + r, lL, rs) diff --git a/Task/Bitmap-Histogram/Lua/bitmap-histogram.lua b/Task/Bitmap-Histogram/Lua/bitmap-histogram.lua new file mode 100644 index 0000000000..1fa7b0cd4e --- /dev/null +++ b/Task/Bitmap-Histogram/Lua/bitmap-histogram.lua @@ -0,0 +1,52 @@ +function Histogram( image ) + local size_x, size_y = #image, #image[1] + + local histo = {} + for i = 0, 255 do + histo[i] = 0 + end + + for i = 1, size_x do + for j = 1, size_y do + histo[ image[i][j] ] = histo[ image[i][j] ] + 1 + end + end + + return histo +end + +function FindMedian( histogram ) + local sum_l, sum_r = 0, 0 + local left, right = 0, 255 + + repeat + if sum_l < sum_r then + sum_l = sum_l + histogram[left] + left = left + 1 + else + sum_r = sum_r + histogram[right] + right = right - 1 + end + until left == right + + return left +end + + +bitmap = Read_PPM( "inputimage.ppm" ) +gray_im = ConvertToGrayscaleImage( bitmap ) +histogram = Histogram( gray_im ) +median = FindMedian( histogram ) + +for i = 1, #gray_im do + for j = 1, #gray_im[1] do + if gray_im[i][j] < median then + gray_im[i][j] = 0 + else + gray_im[i][j] = 255 + end + end +end + +bitmap = ConvertToColorImage( gray_im ) +Write_PPM( "outputimage.ppm", bitmap ) diff --git a/Task/Bitmap-Histogram/PHP/bitmap-histogram.php b/Task/Bitmap-Histogram/PHP/bitmap-histogram.php new file mode 100644 index 0000000000..631623d041 --- /dev/null +++ b/Task/Bitmap-Histogram/PHP/bitmap-histogram.php @@ -0,0 +1,54 @@ +define('src_name', 'input.jpg'); // source image +define('dest_name', 'output.jpg'); // destination image + +$img = imagecreatefromjpeg(src_name); // read image + +if(empty($img)){ + echo 'Image could not be loaded!'; + exit; +} + +$black = imagecolorallocate($img, 0, 0, 0); +$white = imagecolorallocate($img, 255, 255, 255); +$width = imagesx($img); +$height = imagesy($img); + +$array_lum = array(); // for storage of luminosity of each pixel +$sum_lum = 0; // total sum of luminosity +$average_lum = 0; // average luminosity of whole image + +for($x = 0; $x < $width; $x++){ + for($y = 0; $y < $height; $y++){ + // read pixel value + $color = imagecolorat($img, $x, $y); + $r = ($color >> 16) & 0xFF; + $g = ($color >> 8) & 0xFF; + $b = $color & 0xFF; + // save pixel luminosity in temporary array + $array_lum[$x][$y] = ($r + $g + $b); + // add pixel luminosity to sum + $sum_lum += $array_lum[$x][$y]; + } +} + +// calculate average luminosity +$average_lum = $sum_lum / ($width * $height); + +for($x = 0; $x < $width; $x++){ + for($y = 0; $y < $height; $y++){ + // pixel is brighter than average -> set white + // else -> set black + if($array_lum[$x][$y] > $average_lum){ + imagesetpixel($img, $x, $y, $white); + } + else{ + imagesetpixel($img, $x, $y, $black); + } + } +} +// save black and white image to dest_name +imagejpeg($img, dest_name); + +if(!file_exists(dest_name)){ + echo 'Image not saved! Check permission!'; +} diff --git a/Task/Bitmap-Histogram/PicoLisp/bitmap-histogram.l b/Task/Bitmap-Histogram/PicoLisp/bitmap-histogram.l new file mode 100644 index 0000000000..d52dc62234 --- /dev/null +++ b/Task/Bitmap-Histogram/PicoLisp/bitmap-histogram.l @@ -0,0 +1,6 @@ +(de histogram (Pgm) + (let H (need 256 0) + (for L Pgm + (for G L + (inc (nth H (inc G))) ) ) + H ) ) diff --git a/Task/Bitmap-Histogram/Ruby/bitmap-histogram.rb b/Task/Bitmap-Histogram/Ruby/bitmap-histogram.rb new file mode 100644 index 0000000000..c0decbdfff --- /dev/null +++ b/Task/Bitmap-Histogram/Ruby/bitmap-histogram.rb @@ -0,0 +1,41 @@ +class Pixmap + def histogram + histogram = Hash.new(0) + @height.times do |y| + @width.times do |x| + histogram[self[x,y].luminosity] += 1 + end + end + histogram + end + + def to_blackandwhite + hist = histogram + + # find the median luminosity + median = nil + sum = 0 + hist.keys.sort.each do |lum| + sum += hist[lum] + if sum > @height * @width / 2 + median = lum + break + end + end + + # create the black and white image + bw = self.class.new(@width, @height) + @height.times do |y| + @width.times do |x| + bw[x,y] = self[x,y].luminosity < median ? RGBColour::BLACK : RGBColour::WHITE + end + end + bw + end + + def save_as_blackandwhite(filename) + to_blackandwhite.save(filename) + end +end + +Pixmap.open('file.ppm').save_as_blackandwhite('file_bw.ppm') diff --git a/Task/Bitmap-Histogram/Scala/bitmap-histogram-1.scala b/Task/Bitmap-Histogram/Scala/bitmap-histogram-1.scala new file mode 100644 index 0000000000..4646774d80 --- /dev/null +++ b/Task/Bitmap-Histogram/Scala/bitmap-histogram-1.scala @@ -0,0 +1,32 @@ +object BitmapOps { + def histogram(bm:RgbBitmap)={ + val hist=new Array[Int](255) + for(x <- 0 until bm.width; y <- 0 until bm.height; l=luminosity(bm.getPixel(x,y))) + hist(l)+=1 + hist + } + + def histogram_median(hist:Array[Int])={ + var from=0 + var to=hist.size-1 + var left=hist(from) + var right=hist(to) + + while(from!=to){ + if (leftthreshold) c2 else c1) + image + } +} diff --git a/Task/Bitmap-Histogram/Scala/bitmap-histogram-2.scala b/Task/Bitmap-Histogram/Scala/bitmap-histogram-2.scala new file mode 100644 index 0000000000..e3486b5cd7 --- /dev/null +++ b/Task/Bitmap-Histogram/Scala/bitmap-histogram-2.scala @@ -0,0 +1,11 @@ +val img=Pixmap.load("image.ppm").get +val hist=BitmapOps.histogram(img) +val mid=BitmapOps.histogram_median(hist); + +val mainframe=new MainFrame(){ + title="Test" + visible=true + contents=new Label(){ + icon=new ImageIcon(BitmapOps.monochrom(img, mid).image) + } +} diff --git a/Task/Bitmap-Histogram/Tcl/bitmap-histogram.tcl b/Task/Bitmap-Histogram/Tcl/bitmap-histogram.tcl new file mode 100644 index 0000000000..bf3e01c311 --- /dev/null +++ b/Task/Bitmap-Histogram/Tcl/bitmap-histogram.tcl @@ -0,0 +1,50 @@ +package require Tcl 8.5 +package require Tk + +proc convert_to_blackandwhite {filename} { + set img [image create photo] + readPPM $img $filename + grayscale $img + set hist [histogram $img] + set median [median $img $hist] + blackandwhite $img $median + output_ppm $img bw_$filename +} + +proc histogram {image} { + set hist [dict create] + for {set x 0} {$x < [image width $image]} {incr x} { + for {set y 0} {$y < [image height $image]} {incr y} { + dict incr hist [luminance {*}[$image get $x $y]] + } + } + return $hist +} + +proc luminance {r g b} { + expr { + int(0.2126*$r + 0.7152*$g + 0.0722*$b) + } +} + +proc median {img hist} { + set sum [expr {[image width $img] * [image height $img]}] + set total 0 + foreach luminance [lsort -integer [dict keys $hist]] { + incr total [dict get $hist $luminance] + if {$total > $sum / 2} break + } + return $luminance +} + +proc blackandwhite {image median} { + for {set x 0} {$x < [image width $image]} {incr x} { + for {set y 0} {$y < [image height $image]} {incr y} { + if {[luminance {*}[$image get $x $y]] < $median} { + $image put black -to $x $y + } else { + $image put white -to $x $y + } + } + } +} diff --git a/Task/Bitmap-Midpoint-circle-algorithm/0DESCRIPTION b/Task/Bitmap-Midpoint-circle-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..fda28f160d --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/0DESCRIPTION @@ -0,0 +1,2 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, write an implementation of the '''midpoint circle algorithm''' (also known as '''Bresenham's circle algorithm''').
+([[wp:Midpoint_circle_algorithm|definition on Wikipedia]]). diff --git a/Task/Bitmap-Midpoint-circle-algorithm/1META.yaml b/Task/Bitmap-Midpoint-circle-algorithm/1META.yaml new file mode 100644 index 0000000000..fb36ead2f0 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Raster graphics operations diff --git a/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm.alg b/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm.alg new file mode 100644 index 0000000000..e1702ecccf --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm.alg @@ -0,0 +1,46 @@ +PRAGMAT READ "Basic_bitmap_storage.a68" PRAGMAT; + +circle OF class image := + ( REF IMAGE picture, + POINT center, + INT radius, + PIXEL color + )VOID: +BEGIN + INT f := 1 - radius, + POINT ddf := (0, -2 * radius), + df := (0, radius); + picture [x OF center, y OF center + radius] := + picture [x OF center, y OF center - radius] := + picture [x OF center + radius, y OF center] := + picture [x OF center - radius, y OF center] := color; + WHILE x OF df < y OF df DO + IF f >= 0 THEN + y OF df -:= 1; + y OF ddf +:= 2; + f +:= y OF ddf + FI; + x OF df +:= 1; + x OF ddf +:= 2; + f +:= x OF ddf + 1; + picture [x OF center + x OF df, y OF center + y OF df] := + picture [x OF center - x OF df, y OF center + y OF df] := + picture [x OF center + x OF df, y OF center - y OF df] := + picture [x OF center - x OF df, y OF center - y OF df] := + picture [x OF center + y OF df, y OF center + x OF df] := + picture [x OF center - y OF df, y OF center + x OF df] := + picture [x OF center + y OF df, y OF center - x OF df] := + picture [x OF center - y OF df, y OF center - x OF df] := color + OD +END # circle #; + +# +The following illustrates use: +# + +IF test THEN + REF IMAGE x = INIT LOC [1:16, 1:16] PIXEL; + (fill OF class image)(x, (white OF class image)); + (circle OF class image)(x, (8, 8), 5, (black OF class image)); + (print OF class image)(x) +FI diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-1.ada b/Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-1.ada new file mode 100644 index 0000000000..c6f1f9c0e7 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-1.ada @@ -0,0 +1,35 @@ +procedure Circle + ( Picture : in out Image; + Center : Point; + Radius : Natural; + Color : Pixel + ) is + F : Integer := 1 - Radius; + ddF_X : Integer := 0; + ddF_Y : Integer := -2 * Radius; + X : Integer := 0; + Y : Integer := Radius; +begin + Picture (Center.X, Center.Y + Radius) := Color; + Picture (Center.X, Center.Y - Radius) := Color; + Picture (Center.X + Radius, Center.Y) := Color; + Picture (Center.X - Radius, Center.Y) := Color; + while X < Y loop + if F >= 0 then + Y := Y - 1; + ddF_Y := ddF_Y + 2; + F := F + ddF_Y; + end if; + X := X + 1; + ddF_X := ddF_X + 2; + F := F + ddF_X + 1; + Picture (Center.X + X, Center.Y + Y) := Color; + Picture (Center.X - X, Center.Y + Y) := Color; + Picture (Center.X + X, Center.Y - Y) := Color; + Picture (Center.X - X, Center.Y - Y) := Color; + Picture (Center.X + Y, Center.Y + X) := Color; + Picture (Center.X - Y, Center.Y + X) := Color; + Picture (Center.X + Y, Center.Y - X) := Color; + Picture (Center.X - Y, Center.Y - X) := Color; + end loop; +end Circle; diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-2.ada b/Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-2.ada new file mode 100644 index 0000000000..2965984410 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Ada/bitmap-midpoint-circle-algorithm-2.ada @@ -0,0 +1,5 @@ + X : Image (1..16, 1..16); +begin + Fill (X, White); + Circle (X, (8, 8), 5, Black); + Print (X); diff --git a/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-1.bbc b/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-1.bbc new file mode 100644 index 0000000000..49d715efaf --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-1.bbc @@ -0,0 +1,43 @@ + Width% = 200 + Height% = 200 + + REM Set window size: + VDU 23,22,Width%;Height%;8,16,16,128 + + REM Draw circles: + PROCcircle(100,100,40, 0,0,0) + PROCcircle(100,100,80, 255,0,0) + END + + DEF PROCcircle(cx%,cy%,r%,R%,G%,B%) + LOCAL f%, x%, y%, ddx%, ddy% + f% = 1 - r% : y% = r% : ddy% = - 2*r% + PROCsetpixel(cx%, cy%+r%, R%,G%,B%) + PROCsetpixel(cx%, cy%-r%, R%,G%,B%) + PROCsetpixel(cx%+r%, cy%, R%,G%,B%) + PROCsetpixel(cx%-r%, cy%, R%,G%,B%) + WHILE x% < y% + IF f% >= 0 THEN + y% -= 1 + ddy% += 2 + f% += ddy% + ENDIF + x% += 1 + ddx% += 2 + f% += ddx% + 1 + PROCsetpixel(cx%+x%, cy%+y%, R%,G%,B%) + PROCsetpixel(cx%-x%, cy%+y%, R%,G%,B%) + PROCsetpixel(cx%+x%, cy%-y%, R%,G%,B%) + PROCsetpixel(cx%-x%, cy%-y%, R%,G%,B%) + PROCsetpixel(cx%+y%, cy%+x%, R%,G%,B%) + PROCsetpixel(cx%-y%, cy%+x%, R%,G%,B%) + PROCsetpixel(cx%+y%, cy%-x%, R%,G%,B%) + PROCsetpixel(cx%-y%, cy%-x%, R%,G%,B%) + ENDWHILE + ENDPROC + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC diff --git a/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-2.bbc b/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-2.bbc new file mode 100644 index 0000000000..64549269b1 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-2.bbc @@ -0,0 +1,8 @@ +void raster_circle( + image img, + unsigned int x0, + unsigned int y0, + unsigned int radius, + color_component r, + color_component g, + color_component b ); diff --git a/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-3.bbc b/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-3.bbc new file mode 100644 index 0000000000..7e58cf1b3f --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/BBC-BASIC/bitmap-midpoint-circle-algorithm-3.bbc @@ -0,0 +1,44 @@ +#define plot(x, y) put_pixel_clip(img, x, y, r, g, b) + +void raster_circle( + image img, + unsigned int x0, + unsigned int y0, + unsigned int radius, + color_component r, + color_component g, + color_component b ) +{ + int f = 1 - radius; + int ddF_x = 0; + int ddF_y = -2 * radius; + int x = 0; + int y = radius; + + plot(x0, y0 + radius); + plot(x0, y0 - radius); + plot(x0 + radius, y0); + plot(x0 - radius, y0); + + while(x < y) + { + if(f >= 0) + { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x + 1; + plot(x0 + x, y0 + y); + plot(x0 - x, y0 + y); + plot(x0 + x, y0 - y); + plot(x0 - x, y0 - y); + plot(x0 + y, y0 + x); + plot(x0 - y, y0 + x); + plot(x0 + y, y0 - x); + plot(x0 - y, y0 - x); + } +} +#undef plot diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Forth/bitmap-midpoint-circle-algorithm.fth b/Task/Bitmap-Midpoint-circle-algorithm/Forth/bitmap-midpoint-circle-algorithm.fth new file mode 100644 index 0000000000..6508c2f3e9 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Forth/bitmap-midpoint-circle-algorithm.fth @@ -0,0 +1,29 @@ +: circle { x y r color bmp -- } + 1 r - 0 r 2* negate 0 r { f ddx ddy dx dy } + color x y r + bmp b! + color x y r - bmp b! + color x r + y bmp b! + color x r - y bmp b! + begin dx dy < while + f 0< 0= if + dy 1- to dy + ddy 2 + dup to ddy + f + to f + then + dx 1+ to dx + ddx 2 + dup to ddx + f 1+ + to f + color x dx + y dy + bmp b! + color x dx - y dy + bmp b! + color x dx + y dy - bmp b! + color x dx - y dy - bmp b! + color x dy + y dx + bmp b! + color x dy - y dx + bmp b! + color x dy + y dx - bmp b! + color x dy - y dx - bmp b! + repeat ; + +12 12 bitmap value test +0 test bfill +6 6 5 blue test circle +test bshow cr diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-1.f b/Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-1.f new file mode 100644 index 0000000000..6343a5c48a --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-1.f @@ -0,0 +1,5 @@ +interface draw_circle + module procedure draw_circle_sc, draw_circle_rgb +end interface + +private :: plot, draw_circle_toch diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-2.f b/Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-2.f new file mode 100644 index 0000000000..4498d2ee6e --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Fortran/bitmap-midpoint-circle-algorithm-2.f @@ -0,0 +1,74 @@ +subroutine plot(ch, p, v) + integer, dimension(:,:), intent(out) :: ch + type(point), intent(in) :: p + integer, intent(in) :: v + + integer :: cx, cy + ! I've kept the default 1-based array, but top-left corner pixel + ! is labelled as (0,0). + cx = p%x + 1 + cy = p%y + 1 + + if ( (cx > 0) .and. (cx <= ubound(ch,1)) .and. & + (cy > 0) .and. (cy <= ubound(ch,2)) ) then + ch(cx,cy) = v + end if +end subroutine plot + +subroutine draw_circle_toch(ch, c, radius, v) + integer, dimension(:,:), intent(out) :: ch + type(point), intent(in) :: c + integer, intent(in) :: radius, v + + integer :: f, ddf_x, ddf_y, x, y + + f = 1 - radius + ddf_x = 0 + ddf_y = -2 * radius + x = 0 + y = radius + + call plot(ch, point(c%x, c%y + radius), v) + call plot(ch, point(c%x, c%y - radius), v) + call plot(ch, point(c%x + radius, c%y), v) + call plot(ch, point(c%x - radius, c%y), v) + + do while ( x < y ) + if ( f >= 0 ) then + y = y - 1 + ddf_y = ddf_y + 2 + f = f + ddf_y + end if + x = x + 1 + ddf_x = ddf_x + 2 + f = f + ddf_x + 1 + call plot(ch, point(c%x + x, c%y + y), v) + call plot(ch, point(c%x - x, c%y + y), v) + call plot(ch, point(c%x + x, c%y - y), v) + call plot(ch, point(c%x - x, c%y - y), v) + call plot(ch, point(c%x + y, c%y + x), v) + call plot(ch, point(c%x - y, c%y + x), v) + call plot(ch, point(c%x + y, c%y - x), v) + call plot(ch, point(c%x - y, c%y - x), v) + end do + +end subroutine draw_circle_toch + +subroutine draw_circle_rgb(img, c, radius, color) + type(rgbimage), intent(out) :: img + type(point), intent(in) :: c + integer, intent(in) :: radius + type(rgb), intent(in) :: color + + call draw_circle_toch(img%red, c, radius, color%red) + call draw_circle_toch(img%green, c, radius, color%green) + call draw_circle_toch(img%blue, c, radius, color%blue) +end subroutine draw_circle_rgb + +subroutine draw_circle_sc(img, c, radius, lum) + type(scimage), intent(out) :: img + type(point), intent(in) :: c + integer, intent(in) :: radius, lum + + call draw_circle_toch(img%channel, c, radius, lum) +end subroutine draw_circle_sc diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-1.go b/Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-1.go new file mode 100644 index 0000000000..448f5b6103 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-1.go @@ -0,0 +1,36 @@ +package raster + +// Circle plots a circle with center x, y and radius r. +// Limiting behavior: +// r < 0 plots no pixels. +// r = 0 plots a single pixel at x, y. +// r = 1 plots four pixels in a diamond shape around the center pixel at x, y. +func (b *Bitmap) Circle(x, y, r int, p Pixel) { + if r < 0 { + return + } + // Bresenham algorithm + x1, y1, err := -r, 0, 2-2*r + for { + b.SetPx(x-x1, y+y1, p) + b.SetPx(x-y1, y-x1, p) + b.SetPx(x+x1, y-y1, p) + b.SetPx(x+y1, y+x1, p) + r = err + if r > x1 { + x1++ + err += x1*2 + 1 + } + if r <= y1 { + y1++ + err += y1*2 + 1 + } + if x1 >= 0 { + break + } + } +} + +func (b *Bitmap) CircleRgb(x, y, r int, c Rgb) { + b.Circle(x, y, r, c.Pixel()) +} diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-2.go b/Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-2.go new file mode 100644 index 0000000000..ffceb1810b --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Go/bitmap-midpoint-circle-algorithm-2.go @@ -0,0 +1,21 @@ +package main + +// Files required to build supporting package raster are found in: +// * This task (immediately above) +// * Bitmap +// * Write a PPM file + +import ( + "raster" + "fmt" +) + +func main() { + b := raster.NewBitmap(400, 300) + b.FillRgb(0xffdf20) // yellow + // large circle, demonstrating clipping to image boundaries + b.CircleRgb(300, 249, 200, 0xff2020) // red + if err := b.WritePpmFile("circle.ppm"); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-1.hs b/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-1.hs new file mode 100644 index 0000000000..5e531e7b22 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-1.hs @@ -0,0 +1,28 @@ +module Circle where + +import Data.List + +type Point = (Int, Int) + +-- Takes the center of the circle and radius, and returns the circle points +generateCirclePoints :: Point -> Int -> [Point] +generateCirclePoints (x0, y0) radius + -- Four initial points, plus the generated points + = (x0, y0 + radius) : (x0, y0 - radius) : (x0 + radius, y0) : (x0 - radius, y0) : points + where + -- Creates the (x, y) octet offsets, then maps them to absolute points in all octets. + points = concatMap generatePoints $ unfoldr step initialValues + generatePoints (x, y) + = [(xop x0 x', yop y0 y') | (x', y') <- [(x, y), (y, x)], xop <- [(+), (-)], yop <- [(+), (-)]] + + -- The initial values for the loop + initialValues = (1 - radius, 1, (-2) * radius, 0, radius) + + -- One step of the loop. The loop itself stops at Nothing. + step (f, ddf_x, ddf_y, x, y) | x >= y = Nothing + | otherwise = Just ((x', y'), (f', ddf_x', ddf_y', x', y')) + where + (f', ddf_y', y') | f >= 0 = (f + ddf_y' + ddf_x', ddf_y + 2, y - 1) + | otherwise = (f + ddf_x, ddf_y, y) + ddf_x' = ddf_x + 2 + x' = x + 1 diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-2.hs b/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-2.hs new file mode 100644 index 0000000000..8ac05272f4 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-2.hs @@ -0,0 +1,31 @@ +module CircleArrayExample where + +import Circle + +-- A surface is just a 2d array of characters for the purposes of this example +type Colour = Char +type Surface = Array (Int, Int) Colour + +-- Returns a surface of the given width and height filled with the colour +blankSurface :: Int -> Int -> Colour -> Surface +blankSurface width height filler = listArray bounds (repeat filler) + where + bounds = ((0, 0), (width - 1, height - 1)) + +-- Generic plotting function. Plots points onto a surface with the given colour. +plotPoints :: Surface -> Colour -> [Point] -> Surface +plotPoints surface colour points = surface // zip points (repeat colour) + +-- Draws a circle of the given colour on the surface given a center and radius +drawCircle :: Surface -> Colour -> Point -> Int -> Surface +drawCircle surface colour center radius + = plotPoints surface colour (generateCirclePoints center radius) + +-- Converts a surface to a string +showSurface image = unlines [[image ! (x, y) | x <- xRange] | y <- yRange] + where + ((xLow, yLow), (xHigh, yHigh)) = bounds image + (xRange, yRange) = ([xLow..xHigh], [yLow..yHigh]) + +-- Converts a surface to a string and prints it +printSurface = putStrLn . showSurface diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-3.hs b/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-3.hs new file mode 100644 index 0000000000..403aaf4169 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Haskell/bitmap-midpoint-circle-algorithm-3.hs @@ -0,0 +1,11 @@ +module CircleBitmapExample where + +import Circle +import Bitmap +import Control.Monad.ST + +drawCircle :: (Color c) => Image s c -> c -> Point -> Int -> ST s (Image s c) +drawCircle image colour center radius = do + let pixels = map Pixel (generateCirclePoints center radius) + forM_ pixels $ \pixel -> setPix image pixel colour + return image diff --git a/Task/Bitmap-Midpoint-circle-algorithm/PicoLisp/bitmap-midpoint-circle-algorithm.l b/Task/Bitmap-Midpoint-circle-algorithm/PicoLisp/bitmap-midpoint-circle-algorithm.l new file mode 100644 index 0000000000..ecda35f2c9 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/PicoLisp/bitmap-midpoint-circle-algorithm.l @@ -0,0 +1,27 @@ +(de midPtCircle (Img CX CY Rad) + (let (F (- 1 Rad) DdFx 0 DdFy (* -2 Rad) X 0 Y Rad) + (set (nth Img (+ CY Rad) CX) 1) + (set (nth Img (- CY Rad) CX) 1) + (set (nth Img CY (+ CX Rad)) 1) + (set (nth Img CY (- CX Rad)) 1) + (while (> Y X) + (when (ge0 F) + (dec 'Y) + (inc 'F (inc 'DdFy 2)) ) + (inc 'X) + (inc 'F (inc (inc 'DdFx 2))) + (set (nth Img (+ CY Y) (+ CX X)) 1) + (set (nth Img (+ CY Y) (- CX X)) 1) + (set (nth Img (- CY Y) (+ CX X)) 1) + (set (nth Img (- CY Y) (- CX X)) 1) + (set (nth Img (+ CY X) (+ CX Y)) 1) + (set (nth Img (+ CY X) (- CX Y)) 1) + (set (nth Img (- CY X) (+ CX Y)) 1) + (set (nth Img (- CY X) (- CX Y)) 1) ) ) ) + +(let Img (make (do 120 (link (need 120 0)))) # Create image 120 x 120 + (midPtCircle Img 60 60 50) # Draw circle + (out "img.pbm" # Write to bitmap file + (prinl "P1") + (prinl 120 " " 120) + (mapc prinl Img) ) ) diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Python/bitmap-midpoint-circle-algorithm.py b/Task/Bitmap-Midpoint-circle-algorithm/Python/bitmap-midpoint-circle-algorithm.py new file mode 100644 index 0000000000..8fa1170988 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Python/bitmap-midpoint-circle-algorithm.py @@ -0,0 +1,67 @@ +def circle(self, x0, y0, radius, colour=black): + f = 1 - radius + ddf_x = 1 + ddf_y = -2 * radius + x = 0 + y = radius + self.set(x0, y0 + radius, colour) + self.set(x0, y0 - radius, colour) + self.set(x0 + radius, y0, colour) + self.set(x0 - radius, y0, colour) + + while x < y: + if f >= 0: + y -= 1 + ddf_y += 2 + f += ddf_y + x += 1 + ddf_x += 2 + f += ddf_x + self.set(x0 + x, y0 + y, colour) + self.set(x0 - x, y0 + y, colour) + self.set(x0 + x, y0 - y, colour) + self.set(x0 - x, y0 - y, colour) + self.set(x0 + y, y0 + x, colour) + self.set(x0 - y, y0 + x, colour) + self.set(x0 + y, y0 - x, colour) + self.set(x0 - y, y0 - x, colour) +Bitmap.circle = circle + +bitmap = Bitmap(25,25) +bitmap.circle(x0=12, y0=12, radius=12) +bitmap.chardisplay() + +''' +The origin, 0,0; is the lower left, with x increasing to the right, +and Y increasing upwards. + +The program above produces the following display : + ++-------------------------+ +| @@@@@@@ | +| @@ @@ | +| @@ @@ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +|@ @| +|@ @| +|@ @| +|@ @| +|@ @| +|@ @| +|@ @| +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @ @ | +| @@ @@ | +| @@ @@ | +| @@@@@@@ | ++-------------------------+ +''' diff --git a/Task/Bitmap-Midpoint-circle-algorithm/REXX/bitmap-midpoint-circle-algorithm.rexx b/Task/Bitmap-Midpoint-circle-algorithm/REXX/bitmap-midpoint-circle-algorithm.rexx new file mode 100644 index 0000000000..f4c78b8ba1 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/REXX/bitmap-midpoint-circle-algorithm.rexx @@ -0,0 +1,49 @@ +/*REXX pgm plots 3 circles using midpoint/Bresenham's circle algorithm. */ + EoE = 200 /*EOE = End Of Earth, er, plot. */ +image. = 'fa'x /*fill the array with middle-dots*/ +pChar = '*' + do j=-EoE to +EoE /*draw grid from lowest──>highest*/ + image.j.0 = '─' /*draw the horizontal axis. */ + image.0.j = '│' /* " " verical " */ + end /*j*/ +image.0.0='┼' /*"draw" the axis origin. */ +minX=0; maxX=0 +minY=0; maxY=0 +call draw_circle 0, 0, 8, '#' +call draw_circle 0, 0, 11, '$' +call draw_circle 0, 0, 19, '@' +border=2 +minX=minX-border*2; maxX=maxX+border*2 +minY=minY-border ; maxY=maxY+border + do y=maxY by -1 to minY; aRow= + do x=minX to maxX + aRow=aRow || image.x.y + end /*x*/ + say aRow + end /*y*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────────DRAW_CIRCLE subroutine─────────────*/ +draw_circle: procedure expose image. minX maxX minY maxY +parse arg xx, yy, r, point; f=1-r; ddfx=1; ddfy=-2*r; y=r +_=yy+r; image.xx._='*' +_=xx+r; image._.yy='*' +_=yy-r; image.xx._='*' +_=xx-r; image._.yy='*' + do x=0 while x=0 then do; y=y-1; ddfy=ddfy+2; f=f+ddfy; end + ddfx=ddfx+2; f=f+ddfx + x_=xx+x; y_=yy+y; call plotXY x_, y_, point + x_=xx+y; y_=yy+x; call plotXY x_, y_, point + x_=xx+y; y_=yy-x; call plotXY x_, y_, point + x_=xx+x; y_=yy-y; call plotXY x_, y_, point + x_=xx-x; y_=yy-y; call plotXY x_, y_, point + x_=xx-y; y_=yy-x; call plotXY x_, y_, point + x_=xx-y; y_=yy+x; call plotXY x_, y_, point + x_=xx-x; y_=yy+y; call plotXY x_, y_, point + end /*x*/ +return +/*──────────────────────────────────PLOTXY subroutine───────────────────*/ +plotXY: procedure expose image. minX maxX minY maxY; parse arg xx, yy, p +image.xx.yy=p; minX=min(minX,xx); maxX=max(maxX,xx) + minY=min(minY,yy); maxY=max(maxY,yy) +return diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Ruby/bitmap-midpoint-circle-algorithm.rb b/Task/Bitmap-Midpoint-circle-algorithm/Ruby/bitmap-midpoint-circle-algorithm.rb new file mode 100644 index 0000000000..4b64bb3636 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Ruby/bitmap-midpoint-circle-algorithm.rb @@ -0,0 +1,39 @@ +Pixel = Struct.new(:x, :y) + +class Pixmap + def draw_circle(pixel, radius, colour) + validate_pixel(pixel.x, pixel.y) + + self[pixel.x, pixel.y + radius] = colour + self[pixel.x, pixel.y - radius] = colour + self[pixel.x + radius, pixel.y] = colour + self[pixel.x - radius, pixel.y] = colour + + f = 1 - radius + ddF_x = 1 + ddF_y = -2 * radius + x = 0 + y = radius + while x < y + if f >= 0 + y -= 1 + ddF_y += 2 + f += ddF_y + end + x += 1 + ddF_x += 2 + f += ddF_x + self[pixel.x + x, pixel.y + y] = colour + self[pixel.x + x, pixel.y - y] = colour + self[pixel.x - x, pixel.y + y] = colour + self[pixel.x - x, pixel.y - y] = colour + self[pixel.x + y, pixel.y + x] = colour + self[pixel.x + y, pixel.y - x] = colour + self[pixel.x - y, pixel.y + x] = colour + self[pixel.x - y, pixel.y - x] = colour + end + end +end + +bitmap = Pixmap.new(30, 30) +bitmap.draw_circle(Pixel[14,14], 12, RGBColour::BLACK) diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Scala/bitmap-midpoint-circle-algorithm.scala b/Task/Bitmap-Midpoint-circle-algorithm/Scala/bitmap-midpoint-circle-algorithm.scala new file mode 100644 index 0000000000..a9a9542002 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Scala/bitmap-midpoint-circle-algorithm.scala @@ -0,0 +1,36 @@ +object BitmapOps { + def midpoint(bm:RgbBitmap, x0:Int, y0:Int, radius:Int, c:Color)={ + var f=1-radius + var ddF_x=1 + var ddF_y= -2*radius + var x=0 + var y=radius + + bm.setPixel(x0, y0+radius, c) + bm.setPixel(x0, y0-radius, c) + bm.setPixel(x0+radius, y0, c) + bm.setPixel(x0-radius, y0, c) + + while(x < y) + { + if(f >= 0) + { + y-=1 + ddF_y+=2 + f+=ddF_y + } + x+=1 + ddF_x+=2 + f+=ddF_x + + bm.setPixel(x0+x, y0+y, c) + bm.setPixel(x0-x, y0+y, c) + bm.setPixel(x0+x, y0-y, c) + bm.setPixel(x0-x, y0-y, c) + bm.setPixel(x0+y, y0+x, c) + bm.setPixel(x0-y, y0+x, c) + bm.setPixel(x0+y, y0-x, c) + bm.setPixel(x0-y, y0-x, c) + } + } +} diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Tcl/bitmap-midpoint-circle-algorithm.tcl b/Task/Bitmap-Midpoint-circle-algorithm/Tcl/bitmap-midpoint-circle-algorithm.tcl new file mode 100644 index 0000000000..2f43425e66 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Tcl/bitmap-midpoint-circle-algorithm.tcl @@ -0,0 +1,48 @@ +package require Tcl 8.5 +package require Tk + +proc drawCircle {image colour point radius} { + lassign $point x0 y0 + + setPixel $image $colour [list $x0 [expr {$y0 + $radius}]] + setPixel $image $colour [list $x0 [expr {$y0 - $radius}]] + setPixel $image $colour [list [expr {$x0 + $radius}] $y0] + setPixel $image $colour [list [expr {$x0 - $radius}] $y0] + + set f [expr {1 - $radius}] + set ddF_x 1 + set ddF_y [expr {-2 * $radius}] + set x 0 + set y $radius + + while {$x < $y} { + assert {$ddF_x == 2 * $x + 1} + assert {$ddF_y == -2 * $y} + assert {$f == $x*$x + $y*$y - $radius*$radius + 2*$x - $y + 1} + if {$f >= 0} { + incr y -1 + incr ddF_y 2 + incr f $ddF_y + } + incr x + incr ddF_x 2 + incr f $ddF_x + setPixel $image $colour [list [expr {$x0 + $x}] [expr {$y0 + $y}]] + setPixel $image $colour [list [expr {$x0 - $x}] [expr {$y0 + $y}]] + setPixel $image $colour [list [expr {$x0 + $x}] [expr {$y0 - $y}]] + setPixel $image $colour [list [expr {$x0 - $x}] [expr {$y0 - $y}]] + setPixel $image $colour [list [expr {$x0 + $y}] [expr {$y0 + $x}]] + setPixel $image $colour [list [expr {$x0 - $y}] [expr {$y0 + $x}]] + setPixel $image $colour [list [expr {$x0 + $y}] [expr {$y0 - $x}]] + setPixel $image $colour [list [expr {$x0 - $y}] [expr {$y0 - $x}]] + + } +} + +# create the image and display it +set img [newImage 200 100] +label .l -image $img +pack .l + +fill $img black +drawCircle $img blue {100 50} 49 diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/0DESCRIPTION b/Task/Bitmap-PPM-conversion-through-a-pipe/0DESCRIPTION new file mode 100644 index 0000000000..ef6ad3da73 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/0DESCRIPTION @@ -0,0 +1,3 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, delegate writing a JPEG file through a '''pipe''' using the output_ppm function defined [[Write_ppm_file|on this other page]]. + +There are various utilities that can be used for this task, for example: '''cjpeg''' (package ''"jpeg-progs"'' on Linux), '''ppmtojpeg''' (package ''"netpbm"'' on Linux), '''convert''' (from ''ImageMagick'', multi-platform). diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/1META.yaml b/Task/Bitmap-PPM-conversion-through-a-pipe/1META.yaml new file mode 100644 index 0000000000..fb36ead2f0 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Raster graphics operations diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-1.c b/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-1.c new file mode 100644 index 0000000000..e1e2b2889f --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-1.c @@ -0,0 +1,2 @@ +/* interface */ +void print_jpg(image img, int qual); diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-2.c b/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-2.c new file mode 100644 index 0000000000..204f4bf6da --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-2.c @@ -0,0 +1,17 @@ +#define MAXCMDBUF 100 +void print_jpg(image img, int qual) +{ + char buf[MAXCMDBUF]; + unsigned int n; + FILE *pipe; + + snprintf(buf, MAXCMDBUF, "convert ppm:- -quality %d jpg:-", qual); + pipe = popen(buf, "w"); + if ( pipe != NULL ) + { + fprintf(pipe, "P6\n%d %d\n255\n", img->width, img->height); + n = img->width * img->height; + fwrite(img->buf, sizeof(pixel), n, pipe); + pclose(pipe); + } +} diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-3.c b/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-3.c new file mode 100644 index 0000000000..8a215d6731 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/C/bitmap-ppm-conversion-through-a-pipe-3.c @@ -0,0 +1,12 @@ +#include "imglib.h" + +int main() +{ + image img; + + img = alloc_img(100,100); + fill_img(img, 50, 20, 200); + draw_line(img, 0, 0, 80, 80, 255, 0, 0); + print_jpg(img, 75); + free_img(img); +} diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-1.go b/Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-1.go new file mode 100644 index 0000000000..08a2664e3e --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-1.go @@ -0,0 +1,59 @@ +package main + +// Files required to build supporting package raster are found in: +// * Bitmap +// * Write a PPM file + +import ( + "fmt" + "math/rand" + "os/exec" + "raster" +) + +func main() { + b := raster.NewBitmap(400, 300) + // a little extravagant, this draws a design of dots and lines + b.FillRgb(0xc08040) + for i := 0; i < 2000; i++ { + b.SetPxRgb(rand.Intn(400), rand.Intn(300), 0x804020) + } + for x := 0; x < 400; x++ { + for y := 240; y < 245; y++ { + b.SetPxRgb(x, y, 0x804020) + } + for y := 260; y < 265; y++ { + b.SetPxRgb(x, y, 0x804020) + } + } + for y := 0; y < 300; y++ { + for x := 80; x < 85; x++ { + b.SetPxRgb(x, y, 0x804020) + } + for x := 95; x < 100; x++ { + b.SetPxRgb(x, y, 0x804020) + } + } + + // pipe logic + c := exec.Command("cjpeg", "-outfile", "pipeout.jpg") + pipe, err := c.StdinPipe() + if err != nil { + fmt.Println(err) + return + } + err = c.Start() + if err != nil { + fmt.Println(err) + return + } + err = b.WritePpmTo(pipe) + if err != nil { + fmt.Println(err) + return + } + err = pipe.Close() + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-2.go b/Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-2.go new file mode 100644 index 0000000000..c4ad95af34 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/Go/bitmap-ppm-conversion-through-a-pipe-2.go @@ -0,0 +1,15 @@ +let print_jpeg ~img ?(quality=96) () = + let cmd = Printf.sprintf "cjpeg -quality %d" quality in + (* + let cmd = Printf.sprintf "ppmtojpeg -quality %d" quality in + let cmd = Printf.sprintf "convert ppm:- -quality %d jpg:-" quality in + *) + let ic, oc = Unix.open_process cmd in + output_ppm ~img ~oc; + try + while true do + let c = input_char ic in + print_char c + done + with End_of_file -> () +;; diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/PicoLisp/bitmap-ppm-conversion-through-a-pipe.l b/Task/Bitmap-PPM-conversion-through-a-pipe/PicoLisp/bitmap-ppm-conversion-through-a-pipe.l new file mode 100644 index 0000000000..8bf8e97c76 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/PicoLisp/bitmap-ppm-conversion-through-a-pipe.l @@ -0,0 +1,11 @@ +# Create an empty image of 120 x 90 pixels +(setq *Ppm (make (do 90 (link (need 120))))) + +# Fill background with green color +(ppmFill *Ppm 0 255 0) + +# Draw a diagonal line +(for I 80 (ppmSetPixel *Ppm I I 0 0 0)) + +# Write to "img.jpg" through a pipe +(ppmWrite *Ppm '("convert" "-" "img.jpg")) diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/Ruby/bitmap-ppm-conversion-through-a-pipe.rb b/Task/Bitmap-PPM-conversion-through-a-pipe/Ruby/bitmap-ppm-conversion-through-a-pipe.rb new file mode 100644 index 0000000000..32a076bd8c --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/Ruby/bitmap-ppm-conversion-through-a-pipe.rb @@ -0,0 +1,39 @@ +class Pixmap + PIXMAP_FORMATS = ["P3", "P6"] # implemented output formats + PIXMAP_BINARY_FORMATS = ["P6"] # implemented output formats which are binary + + def write_ppm(ios, format="P6") + if not PIXMAP_FORMATS.include?(format) + raise NotImplementedError, "pixmap format #{format} has not been implemented" + end + ios.puts format, "#{@width} #{@height}", "255" + ios.binmode if PIXMAP_BINARY_FORMATS.include?(format) + @height.times do |y| + @width.times do |x| + case format + when "P3" then ios.print @data[x][y].values.join(" "),"\n" + when "P6" then ios.print @data[x][y].values.pack('C3') + end + end + end + end + + def save(filename, opts={:format=>"P6"}) + File.open(filename, 'w') do |f| + write_ppm(f, opts[:format]) + end + end + + def print(opts={:format=>"P6"}) + write_ppm($stdout, opts[:format]) + end + + def save_as_jpeg(filename, quality=75) + pipe = IO.popen("convert ppm:- -quality #{quality} jpg:#{filename}", 'w') + write_ppm(pipe) + pipe.close + end +end + +image = Pixmap.open('file.ppm') +image.save_as_jpeg('file.jpg') diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-1.tcl b/Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-1.tcl new file mode 100644 index 0000000000..58b95a34a7 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-1.tcl @@ -0,0 +1,8 @@ +package require Tk + +proc output_jpeg {image filename {quality 75}} { + set f [open |[list convert ppm:- -quality $quality jpg:- > $filename] w] + fconfigure $f -translation binary + puts -nonewline $f [$image data -format ppm] + close $f +} diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-2.tcl b/Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-2.tcl new file mode 100644 index 0000000000..3fb86c1903 --- /dev/null +++ b/Task/Bitmap-PPM-conversion-through-a-pipe/Tcl/bitmap-ppm-conversion-through-a-pipe-2.tcl @@ -0,0 +1,8 @@ +package require Tk +package require img::jpeg + +proc output_jpeg {image filename} { + $image write $filename -format jpeg +} +set img [image create photo -filename filename.ppm] +output_jpeg $img filename.jpg diff --git a/Task/Bitmap-Read-a-PPM-file/0DESCRIPTION b/Task/Bitmap-Read-a-PPM-file/0DESCRIPTION new file mode 100644 index 0000000000..297d35d7ba --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/0DESCRIPTION @@ -0,0 +1,4 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, read an image from a PPM file (binary P6 prefered). +(Read [[wp:Netpbm_format|the definition of PPM file]] on Wikipedia.) + +'''Task''': Use [[write ppm file]] solution and [[grayscale image]] solution with this one in order to convert a color image to grayscale one. diff --git a/Task/Bitmap-Read-a-PPM-file/1META.yaml b/Task/Bitmap-Read-a-PPM-file/1META.yaml new file mode 100644 index 0000000000..5ef921559d --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Input Output +note: Raster graphics operations diff --git a/Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-1.ada b/Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-1.ada new file mode 100644 index 0000000000..f65e4e307b --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-1.ada @@ -0,0 +1,70 @@ +with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; +with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; + +function Get_PPM (File : File_Type) return Image is + use Ada.Characters.Latin_1; + use Ada.Integer_Text_IO; + + function Get_Line return String is -- Skips comments + Byte : Character; + Buffer : String (1..80); + begin + loop + for I in Buffer'Range loop + Character'Read (Stream (File), Byte); + if Byte = LF then + exit when Buffer (1) = '#'; + return Buffer (1..I - 1); + end if; + Buffer (I) := Byte; + end loop; + if Buffer (1) /= '#' then + raise Data_Error; + end if; + end loop; + end Get_Line; + + Height : Integer; + Width : Integer; +begin + if Get_Line /= "P6" then + raise Data_Error; + end if; + declare + Line : String := Get_Line; + Start : Integer := Line'First; + Last : Positive; + begin + Get (Line, Width, Last); Start := Start + Last; + Get (Line (Start..Line'Last), Height, Last); Start := Start + Last; + if Start <= Line'Last then + raise Data_Error; + end if; + if Width < 1 or else Height < 1 then + raise Data_Error; + end if; + end; + if Get_Line /= "255" then + raise Data_Error; + end if; + declare + Result : Image (1..Height, 1..Width); + Buffer : String (1..Width * 3); + Index : Positive; + begin + for I in Result'Range (1) loop + String'Read (Stream (File), Buffer); + Index := Buffer'First; + for J in Result'Range (2) loop + Result (I, J) := + ( R => Luminance (Character'Pos (Buffer (Index))), + G => Luminance (Character'Pos (Buffer (Index + 1))), + B => Luminance (Character'Pos (Buffer (Index + 2))) + ); + Index := Index + 3; + end loop; + end loop; + return Result; + end; +end Get_PPM; diff --git a/Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-2.ada b/Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-2.ada new file mode 100644 index 0000000000..2c362394f4 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Ada/bitmap-read-a-ppm-file-2.ada @@ -0,0 +1,9 @@ +declare + F1, F2 : File_Type; +begin + Open (F1, In_File, "city.ppm"); + Create (F2, Out_File, "city_grayscale.ppm"); + Put_PPM (F2, Color (Grayscale (Get_PPM (F1)))); + Close (F1); + Close (F2); +end; diff --git a/Task/Bitmap-Read-a-PPM-file/AutoHotkey/bitmap-read-a-ppm-file.ahk b/Task/Bitmap-Read-a-PPM-file/AutoHotkey/bitmap-read-a-ppm-file.ahk new file mode 100644 index 0000000000..13ce33a881 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/AutoHotkey/bitmap-read-a-ppm-file.ahk @@ -0,0 +1,57 @@ +img := ppm_read("lena50.ppm") ; +x := img[4,4] ; get pixel(4,4) +y := img[24,24] ; get pixel(24,24) +msgbox % x.rgb() " " y.rgb() +img.write("lena50copy.ppm") +return + +ppm_read(filename, ppmo=0) ; only ppm6 files supported +{ +if !ppmo ; if image not already in memory, read from filename + fileread, ppmo, % filename + + index := 1 + pos := 1 + + loop, parse, ppmo, `n, `r + { + if (substr(A_LoopField, 1, 1) == "#") + continue +loop, +{ + if !pos := regexmatch(ppmo, "\d+", pixel, pos) +break + bitmap%A_Index% := pixel + if (index == 4) + Break + pos := regexmatch(ppmo, "\s", x, pos) + index ++ +} + } + + type := bitmap1 + width := bitmap2 + height := bitmap3 + maxcolor := bitmap4 + bitmap := Bitmap(width, height, color(0,0,0)) + index := 1 + i := 1 + j := 1 + bits := pos +loop % width * height + { + bitmap[i, j, "r"] := numget(ppmo, 3 * A_Index + bits, "uchar") + bitmap[i, j, "g"] := numget(ppmo, 3 * A_Index + bits + 1, "uchar") + bitmap[i, j, "b"] := numget(ppmo, 3 * A_Index + bits + 2, "uchar") + + if (j == width) +{ + j := 1 + i += 1 +} + else + j++ +} + return bitmap + } +#include bitmap_storage.ahk ; from http://rosettacode.org/wiki/Basic_bitmap_storage/AutoHotkey diff --git a/Task/Bitmap-Read-a-PPM-file/BBC-BASIC/bitmap-read-a-ppm-file.bbc b/Task/Bitmap-Read-a-PPM-file/BBC-BASIC/bitmap-read-a-ppm-file.bbc new file mode 100644 index 0000000000..c78246a173 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/BBC-BASIC/bitmap-read-a-ppm-file.bbc @@ -0,0 +1,30 @@ + f% = OPENIN("c:\lena.ppm") + IF f%=0 ERROR 100, "Failed to open input file" + + IF GET$#f% <> "P6" ERROR 101, "File is not in P6 format" + REPEAT + in$ = GET$#f% + UNTIL LEFT$(in$,1) <> "#" + size$ = in$ + max$ = GET$#f% + + Width% = VAL(size$) + space% = INSTR(size$, " ") + Height% = VALMID$(size$, space%) + + VDU 23,22,Width%;Height%;8,16,16,128 + + FOR y% = Height%-1 TO 0 STEP -1 + FOR x% = 0 TO Width%-1 + r% = BGET#f% : g% = BGET#f% : b% = BGET#f% + l% = INT(0.3*r% + 0.59*g% + 0.11*b% + 0.5) + PROCsetpixel(x%,y%,l%,l%,l%) + NEXT + NEXT y% + END + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC diff --git a/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-1.c b/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-1.c new file mode 100644 index 0000000000..f64ec0a808 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-1.c @@ -0,0 +1 @@ +image get_ppm(FILE *pf); diff --git a/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-2.c b/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-2.c new file mode 100644 index 0000000000..c0fa2287cf --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-2.c @@ -0,0 +1,38 @@ +#include "imglib.h" + +#define PPMREADBUFLEN 256 +image get_ppm(FILE *pf) +{ + char buf[PPMREADBUFLEN], *t; + image img; + unsigned int w, h, d; + int r; + + if (pf == NULL) return NULL; + t = fgets(buf, PPMREADBUFLEN, pf); + /* the code fails if the white space following "P6" is not '\n' */ + if ( (t == NULL) || ( strncmp(buf, "P6\n", 3) != 0 ) ) return NULL; + do + { /* Px formats can have # comments after first line */ + t = fgets(buf, PPMREADBUFLEN, pf); + if ( t == NULL ) return NULL; + } while ( strncmp(buf, "#", 1) == 0 ); + r = sscanf(buf, "%u %u", &w, &h); + if ( r < 2 ) return NULL; + + r = fscanf(pf, "%u", &d); + if ( (r < 1) || ( d != 255 ) ) return NULL; + fseek(pf, 1, SEEK_CUR); /* skip one byte, should be whitespace */ + + img = alloc_img(w, h); + if ( img != NULL ) + { + size_t rd = fread(img->buf, sizeof(pixel), w*h, pf); + if ( rd < w*h ) + { + free_img(img); + return NULL; + } + return img; + } +} diff --git a/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-3.c b/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-3.c new file mode 100644 index 0000000000..406256c5c8 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/C/bitmap-read-a-ppm-file-3.c @@ -0,0 +1,16 @@ +#include +#include "imglib.h" + +int main() +{ + image source; + grayimage idest; + + source = get_ppm(stdin); + idest = tograyscale(source); + free_img(source); + source = tocolor(idest); + output_ppm(stdout, source); + free_img(source); free_img((image)idest); + return 0; +} diff --git a/Task/Bitmap-Read-a-PPM-file/Forth/bitmap-read-a-ppm-file.fth b/Task/Bitmap-Read-a-PPM-file/Forth/bitmap-read-a-ppm-file.fth new file mode 100644 index 0000000000..20b30e7793 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Forth/bitmap-read-a-ppm-file.fth @@ -0,0 +1,38 @@ +: read-ppm { fid -- bmp } + pad dup 80 fid read-line throw 0= abort" Partial line" + s" P6" compare abort" Only P6 supported." + pad dup 80 fid read-line throw 0= abort" Partial line" + 0. 2swap >number + 1 /string \ skip space + 0. 2swap >number + 2drop drop nip ( w h ) + bitmap { bmp } + pad dup 80 fid read-line throw 0= abort" Partial line" + s" 255" compare abort" Only 8-bits per color channel supported" + 0 pad ! + bmp bdim + 0 do + dup 0 do + pad 3 fid read-file throw + 3 - abort" Not enough pixel data in file" + pad @ i j bmp b! + loop + loop drop + bmp ; + +\ testing round-trip +4 3 bitmap value test +red test bfill +green 1 2 test b! + +s" red.ppm" w/o create-file throw +test over write-ppm +close-file throw + +s" red.ppm" r/o open-file throw +dup read-ppm value test2 +close-file throw + +: bsize ( bmp -- len ) bdim * pixels bdata ; + +test dup bsize test2 dup bsize compare . \ 0 if identical diff --git a/Task/Bitmap-Read-a-PPM-file/Fortran/bitmap-read-a-ppm-file.f b/Task/Bitmap-Read-a-PPM-file/Fortran/bitmap-read-a-ppm-file.f new file mode 100644 index 0000000000..57c418d1d4 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Fortran/bitmap-read-a-ppm-file.f @@ -0,0 +1,42 @@ +subroutine read_ppm(u, img) + integer, intent(in) :: u + type(rgbimage), intent(out) :: img + integer :: i, j, ncol, cc + character(2) :: sign + character :: ccode + + img%width = 0 + img%height = 0 + nullify(img%red) + nullify(img%green) + nullify(img%blue) + + read(u, '(A2)') sign + read(u, *) img%width, img%height + read(u, *) ncol + + write(0,*) sign + write(0,*) img%width, img%height + write(0,*) ncol + + if ( ncol /= 255 ) return + + call alloc_img(img, img%width, img%height) + + if ( valid_image(img) ) then + do j=1, img%height + do i=1, img%width + read(u, '(A1)', advance='no', iostat=status) ccode + cc = iachar(ccode) + img%red(i,j) = cc + read(u, '(A1)', advance='no', iostat=status) ccode + cc = iachar(ccode) + img%green(i,j) = cc + read(u, '(A1)', advance='no', iostat=status) ccode + cc = iachar(ccode) + img%blue(i,j) = cc + end do + end do + end if + +end subroutine read_ppm diff --git a/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-1.go b/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-1.go new file mode 100644 index 0000000000..340389412f --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-1.go @@ -0,0 +1,68 @@ +package raster + +import ( + "errors" + "io" + "io/ioutil" + "os" + "regexp" + "strconv" +) + +// ReadFrom constructs a Bitmap object from an io.Reader. +func ReadPpmFrom(r io.Reader) (b *Bitmap, err error) { + var all []byte + all, err = ioutil.ReadAll(r) + if err != nil { + return + } + bss := rxHeader.FindSubmatch(all) + if bss == nil { + return nil, errors.New("unrecognized ppm header") + } + x, _ := strconv.Atoi(string(bss[3])) + y, _ := strconv.Atoi(string(bss[6])) + maxval, _ := strconv.Atoi(string(bss[9])) + if maxval > 255 { + return nil, errors.New("16 bit ppm not supported") + } + allCmts := append(append(append(bss[1], bss[4]...), bss[7]...), bss[10]...) + b = NewBitmap(x, y) + b.Comments = rxComment.FindAllString(string(allCmts), -1) + b3 := all[len(bss[0]):] + var n1 int + for i := range b.px { + b.px[i].R = byte(int(b3[n1]) * 255 / maxval) + b.px[i].G = byte(int(b3[n1+1]) * 255 / maxval) + b.px[i].B = byte(int(b3[n1+2]) * 255 / maxval) + n1 += 3 + } + return +} + +const ( + // single whitespace character + ws = "[ \n\r\t\v\f]" + // isolated comment + cmt = "#[^\n\r]*" + // comment sub expression + cmts = "(" + ws + "*" + cmt + "[\n\r])" + // number with leading comments + num = "(" + cmts + "+" + ws + "*|" + ws + "+)([0-9]+)" +) + +var rxHeader = regexp.MustCompile("^P6" + num + num + num + + "(" + cmts + "*" + ")" + ws) +var rxComment = regexp.MustCompile(cmt) + +// ReadFile writes binary P6 format PPM from the specified filename. +func ReadPpmFile(fn string) (b *Bitmap, err error) { + var f *os.File + if f, err = os.Open(fn); err != nil { + return + } + if b, err = ReadPpmFrom(f); err != nil { + return + } + return b, f.Close() +} diff --git a/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-2.go b/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-2.go new file mode 100644 index 0000000000..a865433538 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-2.go @@ -0,0 +1,28 @@ +package main + +// Files required to build supporting package raster are found in: +// * This task (immediately above) +// * Bitmap +// * Grayscale image +// * Write a PPM file + +import ( + "raster" + "fmt" +) + +func main() { + // (A file with this name is output by the Go solution to the task + // "Bitmap/Read an image through a pipe," but of course any 8-bit + // P6 PPM file should work.) + b, err := raster.ReadPpmFile("pipein.ppm") + if err != nil { + fmt.Println(err) + return + } + b = b.Grmap().Bitmap() + err = b.WritePpmFile("grayscale.ppm") + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-1.hs b/Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-1.hs new file mode 100644 index 0000000000..f377397242 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-1.hs @@ -0,0 +1,12 @@ +import Bitmap +import Bitmap.RGB +import Bitmap.Gray +import Bitmap.Netpbm + +import Control.Monad +import Control.Monad.ST + +main = + (readNetpbm "original.ppm" :: IO (Image RealWorld RGB)) >>= + stToIO . toGrayImage >>= + writeNetpbm "new.pgm" diff --git a/Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-2.hs b/Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-2.hs new file mode 100644 index 0000000000..35a98c4ad7 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Haskell/bitmap-read-a-ppm-file-2.hs @@ -0,0 +1,4 @@ +main = + (readNetpbm "original.ppm" :: IO (Image RealWorld RGB)) >>= + stToIO . (toRGBImage <=< toGrayImage) >>= + writeNetpbm "new.ppm" diff --git a/Task/Bitmap-Read-a-PPM-file/Lua/bitmap-read-a-ppm-file.lua b/Task/Bitmap-Read-a-PPM-file/Lua/bitmap-read-a-ppm-file.lua new file mode 100644 index 0000000000..25de75c8bf --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Lua/bitmap-read-a-ppm-file.lua @@ -0,0 +1,34 @@ +function Read_PPM( filename ) + local fp = io.open( filename, "rb" ) + if fp == nil then return nil end + + local data = fp:read( "*line" ) + if data ~= "P6" then return nil end + + repeat + data = fp:read( "*line" ) + until string.find( data, "#" ) == nil + + local image = {} + local size_x, size_y + + size_x = string.match( data, "%d+" ) + size_y = string.match( data, "%s%d+" ) + + data = fp:read( "*line" ) + if tonumber(data) ~= 255 then return nil end + + for i = 1, size_x do + image[i] = {} + end + + for j = 1, size_y do + for i = 1, size_x do + image[i][j] = { string.byte( fp:read(1) ), string.byte( fp:read(1) ), string.byte( fp:read(1) ) } + end + end + + fp:close() + + return image +end diff --git a/Task/Bitmap-Read-a-PPM-file/Perl/bitmap-read-a-ppm-file.pl b/Task/Bitmap-Read-a-PPM-file/Perl/bitmap-read-a-ppm-file.pl new file mode 100644 index 0000000000..e9d309cd59 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Perl/bitmap-read-a-ppm-file.pl @@ -0,0 +1,14 @@ +#! /usr/bin/perl + +use strict; +use Image::Imlib2; + +my $img = Image::Imlib2->load("out0.ppm"); + +# let's do something with it now +$img->set_color(255, 255, 255, 255); +$img->draw_line(0,0, $img->width,$img->height); +$img->image_set_format("png"); +$img->save("out1.png"); + +exit 0; diff --git a/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-1.l b/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-1.l new file mode 100644 index 0000000000..3bf00e9f73 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-1.l @@ -0,0 +1,18 @@ +(de ppmRead (File) + (in File + (unless (and `(hex "5036") (rd 2)) # P6 + (quit "Wrong file format" File) ) + (rd 1) + (let (DX 0 DY 0 Max 0 C) + (while (>= 9 (setq C (- (rd 1) `(char "0"))) 0) + (setq DX (+ (* 10 DX) C)) ) + (while (>= 9 (setq C (- (rd 1) `(char "0"))) 0) + (setq DY (+ (* 10 DY) C)) ) + (while (>= 9 (setq C (- (rd 1) `(char "0"))) 0) + (setq Max (+ (* 10 Max) C)) ) + (prog1 + (make (do DY (link (need DX)))) + (for Y @ + (map + '((X) (set X (list (rd 1) (rd 1) (rd 1)))) + Y ) ) ) ) ) ) diff --git a/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-2.l b/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-2.l new file mode 100644 index 0000000000..093d985327 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-2.l @@ -0,0 +1 @@ +(pgmWrite (ppm->pgm (ppmRead "img.ppm")) "img.pgm") diff --git a/Task/Bitmap-Read-a-PPM-file/Python/bitmap-read-a-ppm-file.py b/Task/Bitmap-Read-a-PPM-file/Python/bitmap-read-a-ppm-file.py new file mode 100644 index 0000000000..91ef1d34f6 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Python/bitmap-read-a-ppm-file.py @@ -0,0 +1,69 @@ +# With help from http://netpbm.sourceforge.net/doc/ppm.html + +# String masquerading as ppm file (version P3) +import io + +ppmtxt = '''P3 +# feep.ppm +4 4 +15 + 0 0 0 0 0 0 0 0 0 15 0 15 + 0 0 0 0 15 7 0 0 0 0 0 0 + 0 0 0 0 0 0 0 15 7 0 0 0 +15 0 15 0 0 0 0 0 0 0 0 0 +''' + + +def tokenize(f): + for line in f: + if line[0] != '#': + for t in line.split(): + yield t + +def ppmp3tobitmap(f): + t = tokenize(f) + nexttoken = lambda : next(t) + assert 'P3' == nexttoken(), 'Wrong filetype' + width, height, maxval = (int(nexttoken()) for i in range(3)) + bitmap = Bitmap(width, height, Colour(0, 0, 0)) + for h in range(height-1, -1, -1): + for w in range(0, width): + bitmap.set(w, h, Colour( *(int(nexttoken()) for i in range(3)))) + + return bitmap + +print('Original Colour PPM file') +print(ppmtxt) +ppmfile = io.StringIO(ppmtxt) +bitmap = ppmp3tobitmap(ppmfile) +print('Grey PPM:') +bitmap.togreyscale() +ppmfileout = io.StringIO('') +bitmap.writeppmp3(ppmfileout) +print(ppmfileout.getvalue()) + + +''' +The print statements above produce the following output: + +Original Colour PPM file +P3 +# feep.ppm +4 4 +15 + 0 0 0 0 0 0 0 0 0 15 0 15 + 0 0 0 0 15 7 0 0 0 0 0 0 + 0 0 0 0 0 0 0 15 7 0 0 0 +15 0 15 0 0 0 0 0 0 0 0 0 + +Grey PPM: +P3 +# generated from Bitmap.writeppmp3 +4 4 +11 + 0 0 0 0 0 0 0 0 0 4 4 4 + 0 0 0 11 11 11 0 0 0 0 0 0 + 0 0 0 0 0 0 11 11 11 0 0 0 + 4 4 4 0 0 0 0 0 0 0 0 0 + +''' diff --git a/Task/Bitmap-Read-a-PPM-file/Ruby/bitmap-read-a-ppm-file.rb b/Task/Bitmap-Read-a-PPM-file/Ruby/bitmap-read-a-ppm-file.rb new file mode 100644 index 0000000000..480860c30e --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Ruby/bitmap-read-a-ppm-file.rb @@ -0,0 +1,33 @@ +class Pixmap + # 'open' is a class method + def self.open(filename) + bitmap = nil + File.open(filename, 'r') do |f| + header = [f.gets.chomp, f.gets.chomp, f.gets.chomp] + width, height = header[1].split.map {|n| n.to_i } + if header[0] != 'P6' or header[2] != '255' or width < 1 or height < 1 + raise StandardError, "file '#{filename}' does not start with the expected header" + end + f.binmode + bitmap = self.new(width, height) + height.times do |y| + width.times do |x| + # read 3 bytes + red, green, blue = f.read(3).unpack('C3') + bitmap[x,y] = RGBColour.new(red, green, blue) + end + end + end + bitmap + end +end + +# create an image: a green cross on a blue background +colour_bitmap = Pixmap.new(20, 30) +colour_bitmap.fill(RGBColour::BLUE) +colour_bitmap.height.times {|y| [9,10,11].each {|x| colour_bitmap[x,y]=RGBColour::GREEN}} +colour_bitmap.width.times {|x| [14,15,16].each {|y| colour_bitmap[x,y]=RGBColour::GREEN}} +colour_bitmap.save('testcross.ppm') + +# then, convert to grayscale +Pixmap.open('testcross.ppm').to_grayscale!.save('testgray.ppm') diff --git a/Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-1.scala b/Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-1.scala new file mode 100644 index 0000000000..672dee049f --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-1.scala @@ -0,0 +1,46 @@ +import scala.io._ +import scala.swing._ +import java.io._ +import java.awt.Color +import javax.swing.ImageIcon + +object Pixmap { + private case class PpmHeader(format:String, width:Int, height:Int, maxColor:Int) + + def load(filename:String):Option[RgbBitmap]={ + implicit val in=new BufferedInputStream(new FileInputStream(filename)) + val header=readHeader + if(header.format=="P6") + { + val bm=new RgbBitmap(header.width, header.height); + for(y <- 0 until bm.height; x <- 0 until bm.width; c=readColor) + bm.setPixel(x, y, c) + return Some(bm) + } + None + } + + private def readHeader(implicit in:InputStream)={ + var format=readLine + + var line=readLine + while(line.startsWith("#")) //skip comments + line=readLine + + val parts=line.split("\\s") + val width=parts(0).toInt + val height=parts(1).toInt + val maxColor=readLine.toInt + + new PpmHeader(format, width, height, maxColor) + } + + private def readColor(implicit in:InputStream)=new Color(in.read, in.read, in.read) + + private def readLine(implicit in:InputStream)={ + var out="" + var b=in.read + while(b!=0xA){out+=b.toChar; b=in.read} + out + } +} diff --git a/Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-2.scala b/Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-2.scala new file mode 100644 index 0000000000..c275ec7e76 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Scala/bitmap-read-a-ppm-file-2.scala @@ -0,0 +1,15 @@ +object PixmapTest { + def main(args: Array[String]): Unit = { + val img=Pixmap.load("image.ppm").get + val grayImg=BitmapOps.grayscale(img); + Pixmap.save(grayImg, "image_gray.ppm") + + val mainframe=new MainFrame(){ + title="Test" + visible=true + contents=new Label(){ + icon=new ImageIcon(grayImg.image) + } + } + } +} diff --git a/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-1.tcl b/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-1.tcl new file mode 100644 index 0000000000..3d19965d7a --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-1.tcl @@ -0,0 +1,5 @@ +package require Tk + +proc readPPM {image file} { + $image read $file -format ppm +} diff --git a/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-2.tcl b/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-2.tcl new file mode 100644 index 0000000000..f548496704 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-2.tcl @@ -0,0 +1,21 @@ +package require Tk + +proc grayscaleFile {filename {newFilename ""}} { + set buffer [image create photo] + if {$newFilename eq ""} {set newFilename $filename} + try { + $buffer read $filename -format ppm + set w [image width $buffer] + set h [image height $buffer] + for {set x 0} {$x<$w} {incr x} { + for {set y 0} {$y<$h} {incr y} { + lassign [$buffer get $x $y] r g b + set l [expr {int(0.2126*$r + 0.7152*$g + 0.0722*$b)}] + $buffer put [format "#%02x%02x%02x" $l $l $l] -to $x $y + } + } + $buffer write $newFilename -format ppm + } finally { + image delete $buffer + } +} diff --git a/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-3.tcl b/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-3.tcl new file mode 100644 index 0000000000..ad1e1a0716 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Tcl/bitmap-read-a-ppm-file-3.tcl @@ -0,0 +1,12 @@ +package require Tk + +proc grayscaleFile {filename {newFilename ""}} { + set buffer [image create photo] + if {$newFilename eq ""} {set newFilename $filename} + try { + $buffer read $filename -format ppm + $buffer write $newFilename -format ppm -grayscale + } finally { + image delete $buffer + } +} diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/0DESCRIPTION b/Task/Bitmap-Read-an-image-through-a-pipe/0DESCRIPTION new file mode 100644 index 0000000000..aadd7a8a73 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/0DESCRIPTION @@ -0,0 +1 @@ +This task is the ''opposite'' of the [[PPM conversion through a pipe]]. In this task, using a delegate tool (like '''cjpeg''', one of the netpbm package, or '''convert''' of the ImageMagick package) we read an image file and load it into the data storage type [[Basic bitmap storage|defined here]]. We can also use the code from [[Read ppm file]], so that we can use PPM format like a (natural) bridge between the foreign image format and our simple data storage. diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/1META.yaml b/Task/Bitmap-Read-an-image-through-a-pipe/1META.yaml new file mode 100644 index 0000000000..5ef921559d --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Input Output +note: Raster graphics operations diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/AutoHotkey/bitmap-read-an-image-through-a-pipe.ahk b/Task/Bitmap-Read-an-image-through-a-pipe/AutoHotkey/bitmap-read-an-image-through-a-pipe.ahk new file mode 100644 index 0000000000..a26103f733 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/AutoHotkey/bitmap-read-an-image-through-a-pipe.ahk @@ -0,0 +1,60 @@ +ppm := Run("cmd.exe /c convert lena50.jpg ppm:-") + ; pipe in from imagemagick +img := ppm_read("", ppm) ; +x := img[4,4] ; get pixel(4,4) +y := img[24,24] ; get pixel(24,24) +msgbox % x.rgb() " " y.rgb() +img.write("lena50copy.ppm") +return + +ppm_read(filename, ppmo=0) ; only ppm6 files supported +{ +if !ppmo ; if image not already in memory, read from filename + fileread, ppmo, % filename + + index := 1 + pos := 1 + + loop, parse, ppmo, `n, `r + { + if (substr(A_LoopField, 1, 1) == "#") + continue +loop, +{ + if !pos := regexmatch(ppmo, "\d+", pixel, pos) +break + bitmap%A_Index% := pixel + if (index == 4) + Break + pos := regexmatch(ppmo, "\s", x, pos) + index ++ +} + } + + type := bitmap1 + width := bitmap2 + height := bitmap3 + maxcolor := bitmap4 + bitmap := Bitmap(width, height, color(0,0,0)) + index := 1 + i := 1 + j := 1 + bits := pos +loop % width * height + { + bitmap[i, j, "r"] := numget(ppmo, 3 * A_Index + bits, "uchar") + bitmap[i, j, "g"] := numget(ppmo, 3 * A_Index + bits + 1, "uchar") + bitmap[i, j, "b"] := numget(ppmo, 3 * A_Index + bits + 2, "uchar") + + if (j == width) +{ + j := 1 + i += 1 +} + else + j++ +} + return bitmap + } +#include bitmap_storage.ahk ; from http://rosettacode.org/wiki/Basic_bitmap_storage/AutoHotkey +#include run.ahk ; http://www.autohotkey.com/forum/viewtopic.php?t=16823 diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-1.c b/Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-1.c new file mode 100644 index 0000000000..0ee3ce3794 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-1.c @@ -0,0 +1 @@ +image read_image(const char *name); diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-2.c b/Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-2.c new file mode 100644 index 0000000000..84b9cbe056 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/C/bitmap-read-an-image-through-a-pipe-2.c @@ -0,0 +1,28 @@ +#include "imglib.h" + +#define MAXCMDBUF 100 +#define MAXFILENAMELEN 256 +#define MAXFULLCMDBUF (MAXCMDBUF + MAXFILENAMELEN) +image read_image(const char *name) +{ + FILE *pipe; + char buf[MAXFULLCMDBUF]; + image im; + + FILE *test = fopen(name, "r"); + if ( test == NULL ) { + fprintf(stderr, "cannot open file %s\n", name); + return NULL; + } + fclose(test); + + snprintf(buf, MAXFULLCMDBUF, "convert \"%s\" ppm:-", name); + pipe = popen(buf, "r"); + if ( pipe != NULL ) + { + im = get_ppm(pipe); + pclose(pipe); + return im; + } + return NULL; +} diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/Go/bitmap-read-an-image-through-a-pipe.go b/Task/Bitmap-Read-an-image-through-a-pipe/Go/bitmap-read-an-image-through-a-pipe.go new file mode 100644 index 0000000000..1848b4216c --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/Go/bitmap-read-an-image-through-a-pipe.go @@ -0,0 +1,38 @@ +package main + +// Files required to build supporting package raster are found in: +// * Bitmap +// * Read a PPM file +// * Write a PPM file + +import ( + "fmt" + "os/exec" + "raster" +) + +func main() { + // (A file with this name is output by the Go solution to the task + // "Bitmap/PPM conversion through a pipe," but of course any handy + // jpeg should work.) + c := exec.Command("djpeg", "pipeout.jpg") + pipe, err := c.StdoutPipe() + if err != nil { + fmt.Println(err) + return + } + err = c.Start() + if err != nil { + fmt.Println(err) + return + } + b, err := raster.ReadPpmFrom(pipe) + if err != nil { + fmt.Println(err) + return + } + err = b.WritePpmFile("pipein.ppm") + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/PicoLisp/bitmap-read-an-image-through-a-pipe.l b/Task/Bitmap-Read-an-image-through-a-pipe/PicoLisp/bitmap-read-an-image-through-a-pipe.l new file mode 100644 index 0000000000..8869bbb010 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/PicoLisp/bitmap-read-an-image-through-a-pipe.l @@ -0,0 +1 @@ +(setq *Ppm (ppmRead '("convert" "img.jpg" "ppm:-"))) diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/Ruby/bitmap-read-an-image-through-a-pipe.rb b/Task/Bitmap-Read-an-image-through-a-pipe/Ruby/bitmap-read-an-image-through-a-pipe.rb new file mode 100644 index 0000000000..f8e1bd24d9 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/Ruby/bitmap-read-an-image-through-a-pipe.rb @@ -0,0 +1,40 @@ +class Pixmap + def self.read_ppm(ios) + format = ios.gets.chomp + width, height = ios.gets.chomp.split.map {|n| n.to_i } + max_colour = ios.gets.chomp + + if (not PIXMAP_FORMATS.include?(format)) or + width < 1 or height < 1 or + max_colour != '255' + then + ios.close + raise StandardError, "file '#{filename}' does not start with the expected header" + end + ios.binmode if PIXMAP_BINARY_FORMATS.include?(format) + + bitmap = self.new(width, height) + height.times do |y| + width.times do |x| + # read 3 bytes + red, green, blue = case format + when 'P3' then ios.gets.chomp.split + when 'P6' then ios.read(3).unpack('C3') + end + bitmap[x,y] = RGBColour.new(red, green, blue) + end + end + ios.close + bitmap + end + + def self.open(filename) + read_ppm(File.open(filename, 'r')) + end + + def self.open_from_jpeg(filename) + read_ppm(IO.popen("convert jpg:#{filename} ppm:-", 'r')) + end +end + +bitmap = Pixmap.open_from_jpeg('file.jpg') diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/Tcl/bitmap-read-an-image-through-a-pipe.tcl b/Task/Bitmap-Read-an-image-through-a-pipe/Tcl/bitmap-read-an-image-through-a-pipe.tcl new file mode 100644 index 0000000000..ad42c05e10 --- /dev/null +++ b/Task/Bitmap-Read-an-image-through-a-pipe/Tcl/bitmap-read-an-image-through-a-pipe.tcl @@ -0,0 +1,10 @@ +package require Tk + +proc magickalReadImage {bufferImage fileName} { + set f [open |[list convert [file normalize $fileName] ppm:-] "rb"] + try { + $bufferImage put [read $f] -format ppm + } finally { + close $f + } +} diff --git a/Task/Bitmap-Write-a-PPM-file/0DESCRIPTION b/Task/Bitmap-Write-a-PPM-file/0DESCRIPTION new file mode 100644 index 0000000000..6977f97b72 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/0DESCRIPTION @@ -0,0 +1,2 @@ +Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, write the image to a PPM file (binary P6 prefered).
+(Read [[wp:Netpbm_format|the definition of PPM file]] on Wikipedia.) diff --git a/Task/Bitmap-Write-a-PPM-file/1META.yaml b/Task/Bitmap-Write-a-PPM-file/1META.yaml new file mode 100644 index 0000000000..5ef921559d --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Input Output +note: Raster graphics operations 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 new file mode 100644 index 0000000000..8eb4b7a790 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Ada/bitmap-write-a-ppm-file.ada @@ -0,0 +1,26 @@ +with Ada.Characters.Latin_1; +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; + +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)); + Buffer : String (1..Picture'Length (2) * 3); + Color : Pixel; + Index : Positive; +begin + String'Write (Stream (File), "P6" & LF); + String'Write (Stream (File), Size (2..Size'Last) & LF); + String'Write (Stream (File), "255" & LF); + for I in Picture'Range (1) loop + Index := Buffer'First; + for J in Picture'Range (2) loop + Color := Picture (I, J); + Buffer (Index) := Character'Val (Color.R); + Buffer (Index + 1) := Character'Val (Color.G); + Buffer (Index + 2) := Character'Val (Color.B); + Index := Index + 3; + end loop; + String'Write (Stream (File), Buffer); + end loop; + Character'Write (Stream (File), LF); +end Put_PPM; diff --git a/Task/Bitmap-Write-a-PPM-file/AutoHotkey/bitmap-write-a-ppm-file.ahk b/Task/Bitmap-Write-a-PPM-file/AutoHotkey/bitmap-write-a-ppm-file.ahk new file mode 100644 index 0000000000..c29e043386 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/AutoHotkey/bitmap-write-a-ppm-file.ahk @@ -0,0 +1,31 @@ +cyan := color(0,255,255) ; r,g,b +cyanppm := Bitmap(10, 10, cyan) ; width, height, background-color +Bitmap_write_ppm3(cyanppm, "cyan.ppm") +run, cyan.ppm +return + +#include bitmap_storage.ahk ; see basic bitmap storage task + +Bitmap_write_ppm3(bitmap, filename) +{ +file := FileOpen(filename, 0x11) ; utf-8, write +file.seek(0,0) ; overwrite BOM created with fileopen() +file.write("P3`n" ; `n = \n in ahk +. bitmap.width . " " . bitmap.height . "`n" +. "255`n") + loop % bitmap.height + { + height := A_Index + loop % bitmap.width + { + width := A_Index + color := bitmap[height, width] + file.Write(color.R . " ") + file.Write(color.G . " ") + file.Write(color.B . " ") + } + file.write("`n") + } + file.close() + return 0 +} diff --git a/Task/Bitmap-Write-a-PPM-file/BBC-BASIC/bitmap-write-a-ppm-file.bbc b/Task/Bitmap-Write-a-PPM-file/BBC-BASIC/bitmap-write-a-ppm-file.bbc new file mode 100644 index 0000000000..ae8959667e --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/BBC-BASIC/bitmap-write-a-ppm-file.bbc @@ -0,0 +1,30 @@ + Width% = 200 + Height% = 200 + + VDU 23,22,Width%;Height%;8,16,16,128 + *display c:\lena + + f% = OPENOUT("c:\lena.ppm") + IF f%=0 ERROR 100, "Failed to open output file" + BPUT #f%, "P6" + BPUT #f%, "# Created using BBC BASIC" + BPUT #f%, STR$(Width%) + " " +STR$(Height%) + BPUT #f%, "255" + + FOR y% = Height%-1 TO 0 STEP -1 + FOR x% = 0 TO Width%-1 + rgb% = FNgetpixel(x%,y%) + BPUT #f%, rgb% >> 16 + BPUT #f%, (rgb% >> 8) AND &FF + BPUT #f%, rgb% AND &FF + NEXT + NEXT y% + CLOSE#f% + + END + + DEF FNgetpixel(x%,y%) + LOCAL col% + col% = TINT(x%*2,y%*2) + SWAP ?^col%,?(^col%+2) + = col% diff --git a/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-1.c b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-1.c new file mode 100644 index 0000000000..354d3bb255 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-1.c @@ -0,0 +1,23 @@ +#include +#include + +int main(void) +{ + const int dimx = 800, dimy = 800; + int i, j; + FILE *fp = fopen("first.ppm", "wb"); /* b - binary mode */ + (void) fprintf(fp, "P6\n%d %d\n255\n", dimx, dimy); + for (j = 0; j < dimy; ++j) + { + for (i = 0; i < dimx; ++i) + { + static unsigned char color[3]; + color[0] = i % 256; /* red */ + color[1] = j % 256; /* green */ + color[2] = (i * j) % 256; /* blue */ + (void) fwrite(color, 1, 3, fp); + } + } + (void) fclose(fp); + return EXIT_SUCCESS; +} diff --git a/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-2.c b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-2.c new file mode 100644 index 0000000000..281da7c057 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-2.c @@ -0,0 +1,36 @@ +#include + +int main() +{ + const char *filename = "n.pgm"; + int x, y; + /* size of the image */ + const int x_max = 100; /* width */ + const int y_max = 100; /* height */ + /* 2D array for colors (shades of gray) */ + unsigned char data[y_max][x_max]; + /* color component is coded from 0 to 255 ; it is 8 bit color file */ + const int MaxColorComponentValue = 255; + FILE * fp; + /* comment should start with # */ + const char *comment = "# this is my new binary pgm file"; + + /* fill the data array */ + for (y = 0; y < y_max; ++y) { + for (x = 0; x < x_max; ++x) { + data[y][x] = (x + y) & 255; + } + } + + /* write the whole data array to ppm file in one step */ + /* create new file, give it a name and open it in binary mode */ + fp = fopen(filename, "wb"); + /* write header to the file */ + fprintf(fp, "P5\n %s\n %d\n %d\n %d\n", comment, x_max, y_max, + MaxColorComponentValue); + /* write image data bytes to the file */ + fwrite(data, sizeof(data), 1, fp); + fclose(fp); + printf("OK - file %s saved\n", filename); + return 0; +} diff --git a/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-3.c b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-3.c new file mode 100644 index 0000000000..f3dd9cca24 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-3.c @@ -0,0 +1 @@ +void output_ppm(FILE *fd, image img); diff --git a/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-4.c b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-4.c new file mode 100644 index 0000000000..4c0a304b32 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/C/bitmap-write-a-ppm-file-4.c @@ -0,0 +1,10 @@ +#include "imglib.h" + +void output_ppm(FILE *fd, image img) +{ + unsigned int n; + (void) fprintf(fd, "P6\n%d %d\n255\n", img->width, img->height); + n = img->width * img->height; + (void) fwrite(img->buf, sizeof(pixel), n, fd); + (void) fflush(fd); +} diff --git a/Task/Bitmap-Write-a-PPM-file/Forth/bitmap-write-a-ppm-file.fth b/Task/Bitmap-Write-a-PPM-file/Forth/bitmap-write-a-ppm-file.fth new file mode 100644 index 0000000000..2a666818c1 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Forth/bitmap-write-a-ppm-file.fth @@ -0,0 +1,14 @@ +: write-ppm { bmp fid -- } + s" P6" fid write-line throw + bmp bdim swap + 0 <# bl hold #s #> fid write-file throw + 0 <# #s #> fid write-line throw + s" 255" fid write-line throw + bmp bdata bmp bdim * pixels + bounds do + i 3 fid write-file throw + pixel +loop ; + +s" red.ppm" w/o create-file throw +test over write-ppm +close-file throw diff --git a/Task/Bitmap-Write-a-PPM-file/Fortran/bitmap-write-a-ppm-file.f b/Task/Bitmap-Write-a-PPM-file/Fortran/bitmap-write-a-ppm-file.f new file mode 100644 index 0000000000..dc8c4e522d --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Fortran/bitmap-write-a-ppm-file.f @@ -0,0 +1,26 @@ +module RCImageIO + use RCImageBasic + + implicit none + +contains + + subroutine output_ppm(u, img) + integer, intent(in) :: u + type(rgbimage), intent(in) :: img + integer :: i, j + + write(u, '(A2)') 'P6' + write(u, '(I0,'' '',I0)') img%width, img%height + write(u, '(A)') '255' + + do j=1, img%height + do i=1, img%width + write(u, '(3A1)', advance='no') achar(img%red(i,j)), achar(img%green(i,j)), & + achar(img%blue(i,j)) + end do + end do + + end subroutine output_ppm + +end module RCImageIO diff --git a/Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-1.go b/Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-1.go new file mode 100644 index 0000000000..fcdc8e98c5 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-1.go @@ -0,0 +1,54 @@ +package raster + +import ( + "fmt" + "io" + "os" +) + +// WriteTo outputs 8-bit P6 PPM format to an io.Writer. +func (b *Bitmap) WritePpmTo(w io.Writer) (err error) { + // magic number + if _, err = fmt.Fprintln(w, "P6"); err != nil { + return + } + + // comments + for _, c := range b.Comments { + if _, err = fmt.Fprintln(w, c); err != nil { + return + } + } + + // x, y, depth + _, err = fmt.Fprintf(w, "%d %d\n255\n", b.cols, b.rows) + if err != nil { + return + } + + // raster data in a single write + b3 := make([]byte, 3*len(b.px)) + n1 := 0 + for _, px := range b.px { + b3[n1] = px.R + b3[n1+1] = px.G + b3[n1+2] = px.B + n1 += 3 + } + if _, err = w.Write(b3); err != nil { + return + } + return +} + +// WriteFile writes to the specified filename. +func (b *Bitmap) WritePpmFile(fn string) (err error) { + var f *os.File + if f, err = os.Create(fn); err != nil { + return + } + if err = b.WritePpmTo(f); err != nil { + return + } + return f.Close() +} diff --git a/Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-2.go b/Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-2.go new file mode 100644 index 0000000000..e581bfb4a2 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Go/bitmap-write-a-ppm-file-2.go @@ -0,0 +1,19 @@ +package main + +// Files required to build supporting package raster are found in: +// * This task (immediately above) +// * Bitmap task + +import ( + "raster" + "fmt" +) + +func main() { + b := raster.NewBitmap(400, 300) + b.FillRgb(0x240008) // a dark red + err := b.WritePpmFile("write.ppm") + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Bitmap-Write-a-PPM-file/Haskell/bitmap-write-a-ppm-file.hs b/Task/Bitmap-Write-a-PPM-file/Haskell/bitmap-write-a-ppm-file.hs new file mode 100644 index 0000000000..982788c974 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Haskell/bitmap-write-a-ppm-file.hs @@ -0,0 +1,50 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +module Bitmap.Netpbm(readNetpbm, writeNetpbm) where + +import Bitmap +import Data.Char +import System.IO +import Control.Monad +import Control.Monad.ST +import Data.Array.ST + +nil :: a +nil = undefined + +readNetpbm :: forall c. Color c => FilePath -> IO (Image RealWorld c) +readNetpbm path = do + let die = fail "readNetpbm: bad format" + ppm <- readFile path + let (s, rest) = splitAt 2 ppm + unless (s == magicNumber) die + let getNum :: String -> IO (Int, String) + getNum ppm = do + let (s, rest) = span isDigit $ skipBlanks ppm + when (null s) die + return (read s, rest) + (width, rest) <- getNum rest + (height, rest) <- getNum rest + (_, c : rest) <- + if getMaxval then getNum rest else return (nil, rest) + unless (isSpace c) die + i <- stToIO $ listImage width height $ + fromNetpbm $ map fromEnum rest + return i + where skipBlanks = + dropWhile isSpace . + until ((/= '#') . head) (tail . dropWhile (/= '\n')) . + dropWhile isSpace + magicNumber = netpbmMagicNumber (nil :: c) + getMaxval = not $ null $ netpbmMaxval (nil :: c) + +writeNetpbm :: forall c. Color c => FilePath -> Image RealWorld c -> IO () +writeNetpbm path i = withFile path WriteMode $ \h -> do + (width, height) <- stToIO $ dimensions i + let w = hPutStrLn h + w $ magicNumber + w $ show width ++ " " ++ show height + unless (null maxval) (w maxval) + stToIO (getPixels i) >>= hPutStr h . toNetpbm + where magicNumber = netpbmMagicNumber (nil :: c) + maxval = netpbmMaxval (nil :: c) diff --git a/Task/Bitmap-Write-a-PPM-file/Lua/bitmap-write-a-ppm-file.lua b/Task/Bitmap-Write-a-PPM-file/Lua/bitmap-write-a-ppm-file.lua new file mode 100644 index 0000000000..80af035b15 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Lua/bitmap-write-a-ppm-file.lua @@ -0,0 +1,106 @@ +-- helper function, simulates PHP's array_fill function +local array_fill = function(vbegin, vend, value) + local t = {} + for i=vbegin, vend do + t[i] = value + end + return t +end + +Bitmap = {} +Bitmap.__index = Bitmap + +function Bitmap.new(width, height) + local self = {} + setmetatable(self, Bitmap) + local white = array_fill(0, width, {255, 255, 255}) + self.data = array_fill(0, height, white) + self.width = width + self.height = height + return self +end + +function Bitmap:writeRawPixel(file, c) + local dt + dt = string.format("%c", c) + file:write(dt) +end + +function Bitmap:writeComment(fh, ...) + local strings = {...} + local str = "" + local result + for _, s in pairs(strings) do + str = str .. tostring(s) + end + result = string.format("# %s\n", str) + fh:write(result) +end + +function Bitmap:writeP6(filename) + local fh = io.open(filename, 'w') + if not fh then + error(string.format("failed to open %q for writing", filename)) + else + fh:write(string.format("P6 %d %d 255\n", self.width, self.height)) + self:writeComment(fh, "automatically generated at ", os.date()) + for _, row in pairs(self.data) do + for _, pixel in pairs(row) do + self:writeRawPixel(fh, pixel[1]) + self:writeRawPixel(fh, pixel[2]) + self:writeRawPixel(fh, pixel[3]) + end + end + end +end + +function Bitmap:fill(x, y, width, heigth, color) + width = (width == nil) and self.width or width + height = (height == nil) and self.height or height + width = width + x + height = height + y + for i=y, height do + for j=x, width do + self:setPixel(j, i, color) + end + end +end + +function Bitmap:setPixel(x, y, color) + if x >= self.width then + --error("x is bigger than self.width!") + return false + elseif x < 0 then + --error("x is smaller than 0!") + return false + elseif y >= self.height then + --error("y is bigger than self.height!") + return false + elseif y < 0 then + --error("y is smaller than 0!") + return false + end + self.data[y][x] = color + return true +end + +function example_colorful_stripes() + local w = 260*2 + local h = 260*2 + local b = Bitmap.new(w, h) + --b:fill(2, 2, 18, 18, {240,240,240}) + b:setPixel(0, 15, {255,68,0}) + for i=1, w do + for j=1, h do + b:setPixel(i, j, { + (i + j * 8) % 256, + (j + (255 * i)) % 256, + (i * j) % 256 + } + ); + end + end + return b +end + +example_colorful_stripes():writeP6('p6.ppm') diff --git a/Task/Bitmap-Write-a-PPM-file/PHP/bitmap-write-a-ppm-file.php b/Task/Bitmap-Write-a-PPM-file/PHP/bitmap-write-a-ppm-file.php new file mode 100644 index 0000000000..2d21a30caa --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/PHP/bitmap-write-a-ppm-file.php @@ -0,0 +1,52 @@ +class Bitmap { + public $data; + public $w; + public $h; + public function __construct($w = 16, $h = 16){ + $white = array_fill(0, $w, array(255,255,255)); + $this->data = array_fill(0, $h, $white); + $this->w = $w; + $this->h = $h; + } + //Fills a rectangle, or the whole image with black by default + public function fill($x = 0, $y = 0, $w = null, $h = null, $color = array(0,0,0)){ + if (is_null($w)) $w = $this->w; + if (is_null($h)) $h = $this->h; + $w += $x; + $h += $y; + for ($i = $y; $i < $h; $i++){ + for ($j = $x; $j < $w; $j++){ + $this->setPixel($j, $i, $color); + } + } + } + public function setPixel($x, $y, $color = array(0,0,0)){ + if ($x >= $this->w) return false; + if ($x < 0) return false; + if ($y >= $this->h) return false; + if ($y < 0) return false; + $this->data[$y][$x] = $color; + } + public function getPixel($x, $y){ + return $this->data[$y][$x]; + } + public function writeP6($filename){ + $fh = fopen($filename, 'w'); + if (!$fh) return false; + fputs($fh, "P6 {$this->w} {$this->h} 255\n"); + foreach ($this->data as $row){ + foreach($row as $pixel){ + fputs($fh, pack('C', $pixel[0])); + fputs($fh, pack('C', $pixel[1])); + fputs($fh, pack('C', $pixel[2])); + } + } + fclose($fh); + } +} + +$b = new Bitmap(16,16); +$b->fill(); +$b->fill(2, 2, 18, 18, array(240,240,240)); +$b->setPixel(0, 15, array(255,0,0)); +$b->writeP6('p6.ppm'); diff --git a/Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-1.pl b/Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-1.pl new file mode 100644 index 0000000000..36a6280fa6 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-1.pl @@ -0,0 +1,14 @@ +#! /usr/bin/perl + +use strict; +use Image::Imlib2; + +my $img = Image::Imlib2->new(100,100); +$img->set_color(100,200,0, 255); +$img->fill_rectangle(0,0,100,100); + +$img->save("out0.ppm"); +$img->save("out0.jpg"); +$img->save("out0.png"); + +exit 0; diff --git a/Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-2.pl b/Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-2.pl new file mode 100644 index 0000000000..c1575b215d --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Perl/bitmap-write-a-ppm-file-2.pl @@ -0,0 +1 @@ +$img->image_set_format("jpeg"); # or png, tiff, ppm ... diff --git a/Task/Bitmap-Write-a-PPM-file/PicoLisp/bitmap-write-a-ppm-file.l b/Task/Bitmap-Write-a-PPM-file/PicoLisp/bitmap-write-a-ppm-file.l new file mode 100644 index 0000000000..e506c2af91 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/PicoLisp/bitmap-write-a-ppm-file.l @@ -0,0 +1,6 @@ +(de ppmWrite (Ppm File) + (out File + (prinl "P6") + (prinl (length (car Ppm)) " " (length Ppm)) + (prinl 255) + (for Y Ppm (for X Y (apply wr X))) ) ) diff --git a/Task/Bitmap-Write-a-PPM-file/Python/bitmap-write-a-ppm-file.py b/Task/Bitmap-Write-a-PPM-file/Python/bitmap-write-a-ppm-file.py new file mode 100644 index 0000000000..f76860c026 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Python/bitmap-write-a-ppm-file.py @@ -0,0 +1,62 @@ +# String masquerading as ppm file (version P3) +import io +ppmfileout = io.StringIO('') + +def writeppmp3(self, f): + self.writeppm(f, ppmformat='P3') + +def writeppm(self, f, ppmformat='P6'): + assert ppmformat in ['P3', 'P6'], 'Format wrong' + magic = ppmformat + '\n' + comment = '# generated from Bitmap.writeppm\n' + maxval = max(max(max(bit) for bit in row) for row in self.map) + assert ppmformat == 'P3' or 0 <= maxval < 256, 'R,G,B must fit in a byte' + if ppmformat == 'P6': + fwrite = lambda s: f.write(bytes(s, 'UTF-8')) + maxval = 255 + else: + fwrite = f.write + numsize=len(str(maxval)) + fwrite(magic) + fwrite(comment) + fwrite('%i %i\n%i\n' % (self.width, self.height, maxval)) + for h in range(self.height-1, -1, -1): + for w in range(self.width): + r, g, b = self.get(w, h) + if ppmformat == 'P3': + fwrite(' %*i %*i %*i' % (numsize, r, numsize, g, numsize, b)) + else: + fwrite('%c%c%c' % (r, g, b)) + if ppmformat == 'P3': + fwrite('\n') + +Bitmap.writeppmp3 = writeppmp3 +Bitmap.writeppm = writeppm + +# Draw something simple +bitmap = Bitmap(4, 4, black) +bitmap.fillrect(1, 0, 1, 2, white) +bitmap.set(3, 3, Colour(127, 0, 63)) +# Write to the open 'file' handle +bitmap.writeppmp3(ppmfileout) +# Whats in the generated PPM file +print(ppmfileout.getvalue()) + +''' +The print statement above produces the following output : + +P3 +# generated from Bitmap.writeppmp3 +4 4 +255 + 0 0 0 0 0 0 0 0 0 127 0 63 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 255 255 255 0 0 0 0 0 0 + 0 0 0 255 255 255 0 0 0 0 0 0 + +''' + +# Write a P6 file +ppmfileout = open('tmp.ppm', 'wb') +bitmap.writeppm(ppmfileout) +ppmfileout.close() diff --git a/Task/Bitmap-Write-a-PPM-file/R/bitmap-write-a-ppm-file.r b/Task/Bitmap-Write-a-PPM-file/R/bitmap-write-a-ppm-file.r new file mode 100644 index 0000000000..97f5e7f164 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/R/bitmap-write-a-ppm-file.r @@ -0,0 +1,6 @@ +# View the existing code in the library +library(pixmap) +pixmap::write.pnm + +#Usage +write.pnm(theimage, filename) diff --git a/Task/Bitmap-Write-a-PPM-file/REXX/bitmap-write-a-ppm-file.rexx b/Task/Bitmap-Write-a-PPM-file/REXX/bitmap-write-a-ppm-file.rexx new file mode 100644 index 0000000000..a484e1be8d --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/REXX/bitmap-write-a-ppm-file.rexx @@ -0,0 +1,17 @@ +/*REXX program to write a PPM formatted image file, P6 (binary). */ +oFID = 'IMAGE.PPM' /*name of the output file. */ +green = '00 ff 00'x +image. = green /*define all IMAGE RGB's to green*/ + width = 20 /*define the width of IMAGE. */ +height = 20 /* " " height " " */ + sep = '9'x +call put 'P6'width||sep||height||sep||255||sep /*write header info.*/ + + do j =1 for width + do k=1 for height + call put image.j.k /*write IMAGE, 3 bytes at a time.*/ + end /*k*/ + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────subroutines──────────────────────*/ +put: call charout oFID,arg(1); return /*write out character(s) to file.*/ diff --git a/Task/Bitmap-Write-a-PPM-file/Ruby/bitmap-write-a-ppm-file.rb b/Task/Bitmap-Write-a-PPM-file/Ruby/bitmap-write-a-ppm-file.rb new file mode 100644 index 0000000000..c83d49dd3c --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Ruby/bitmap-write-a-ppm-file.rb @@ -0,0 +1,20 @@ +class RGBColour + def values + [@red, @green, @blue] + end +end + +class Pixmap + def save(filename) + File.open(filename, 'w') do |f| + f.puts "P6", "#{@width} #{@height}", "255" + f.binmode + @height.times do |y| + @width.times do |x| + f.print @data[x][y].values.pack('C3') + end + end + end + end + alias_method :write, :save +end diff --git a/Task/Bitmap-Write-a-PPM-file/Scala/bitmap-write-a-ppm-file.scala b/Task/Bitmap-Write-a-PPM-file/Scala/bitmap-write-a-ppm-file.scala new file mode 100644 index 0000000000..ead9068c32 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Scala/bitmap-write-a-ppm-file.scala @@ -0,0 +1,13 @@ +object Pixmap { + def save(bm:RgbBitmap, filename:String)={ + val out=new DataOutputStream(new FileOutputStream(filename)) + + out.writeBytes("P6\u000a%d %d\u000a%d\u000a".format(bm.width, bm.height, 255)) + + for(y <- 0 until bm.height; x <- 0 until bm.width; c=bm.getPixel(x, y)){ + out.writeByte(c.getRed) + out.writeByte(c.getGreen) + out.writeByte(c.getBlue) + } + } +} diff --git a/Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-1.ss b/Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-1.ss new file mode 100644 index 0000000000..c4b44e0048 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-1.ss @@ -0,0 +1,22 @@ +(define (write-ppm image file) + (define (write-image image) + (define (write-row row) + (define (write-colour colour) + (if (not (null? colour)) + (begin (write-char (integer->char (car colour))) + (write-colour (cdr colour))))) + (if (not (null? row)) + (begin (write-colour (car row)) (write-row (cdr row))))) + (if (not (null? image)) + (begin (write-row (car image)) (write-image (cdr image))))) + (with-output-to-file file + (lambda () + (begin (display "P6") + (newline) + (display (length (car image))) + (display " ") + (display (length image)) + (newline) + (display 255) + (newline) + (write-image image))))) diff --git a/Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-2.ss b/Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-2.ss new file mode 100644 index 0000000000..290f9ed301 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Scheme/bitmap-write-a-ppm-file-2.ss @@ -0,0 +1,4 @@ +(define image (make-image 800 600)) +(image-fill! image *black*) +(image-set! image 400 300 *blue*) +(write-ppm image "out.ppm") diff --git a/Task/Bitmap-Write-a-PPM-file/Tcl/bitmap-write-a-ppm-file.tcl b/Task/Bitmap-Write-a-PPM-file/Tcl/bitmap-write-a-ppm-file.tcl new file mode 100644 index 0000000000..58257de53d --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Tcl/bitmap-write-a-ppm-file.tcl @@ -0,0 +1,19 @@ +package require Tk + +proc output_ppm {image filename} { + $image write $filename -format ppm +} + +set img [newImage 150 150] +fill $img red +setPixel $img green 40 40 +output_ppm $img filename.ppm + +# check the file format: +set fh [open filename.ppm] +puts [gets $fh] ;# ==> P6 +puts [gets $fh] ;# ==> 150 150 +puts [gets $fh] ;# ==> 255 +binary scan [read $fh 3] c3 pixel +foreach colour $pixel {puts [expr {$colour & 0xff}]} ;# ==> 255 \n 0 \n 0 \n +close $fh diff --git a/Task/Bitmap/0DESCRIPTION b/Task/Bitmap/0DESCRIPTION new file mode 100644 index 0000000000..2f3738413b --- /dev/null +++ b/Task/Bitmap/0DESCRIPTION @@ -0,0 +1,10 @@ +Show a basic storage type to handle a simple RGB raster graphics image, and some primitive associated functions. + +If possible provide a function to allocate an uninitialised image, given its width and height, and provide 3 additional functions: +* one to fill an image with a plain RGB color, +* one to set a given pixel with a color, +* one to get the color of a pixel. + +(If there are specificities about the storage or the allocation, explain those.) + +''These functions are used as a base for the articles in the category [[Raster_graphics_operations|raster graphics operations]], and a basic output function to check the results is available in the article [[write ppm file]].'' diff --git a/Task/Bitmap/1META.yaml b/Task/Bitmap/1META.yaml new file mode 100644 index 0000000000..fb36ead2f0 --- /dev/null +++ b/Task/Bitmap/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Raster graphics operations diff --git a/Task/Bitmap/ALGOL-68/bitmap.alg b/Task/Bitmap/ALGOL-68/bitmap.alg new file mode 100644 index 0000000000..63e56e7f21 --- /dev/null +++ b/Task/Bitmap/ALGOL-68/bitmap.alg @@ -0,0 +1,54 @@ +MODE PIXEL = STRUCT(#SHORT# BITS red,green,blue); +MODE POINT = STRUCT(INT x,y); + +MODE IMAGE = [0,0]PIXEL; # instance attributes # + +MODE CLASSIMAGE = STRUCT ( # class attributes # + PIXEL black, red, green, blue, white, + PROC (REF IMAGE)REF IMAGE init, + PROC (REF IMAGE, PIXEL)VOID fill, + PROC (REF IMAGE)VOID print, +# virtual: # + REF PROC (REF IMAGE, POINT, POINT, PIXEL)VOID line, + REF PROC (REF IMAGE, POINT, INT, PIXEL)VOID circle, + REF PROC (REF IMAGE, POINT, POINT, POINT, POINT, PIXEL, UNION(INT, VOID))VOID cubic bezier +); + +CLASSIMAGE class image = ( + # black = # (#SHORTEN# 16r00, #SHORTEN# 16r00, #SHORTEN# 16r00), + # red = # (#SHORTEN# 16rff, #SHORTEN# 16r00, #SHORTEN# 16r00), + # green = # (#SHORTEN# 16r00, #SHORTEN# 16rff, #SHORTEN# 16r00), + # blue = # (#SHORTEN# 16r00, #SHORTEN# 16r00, #SHORTEN# 16rff), + # white = # (#SHORTEN# 16rff, #SHORTEN# 16rff, #SHORTEN# 16rff), + # PROC init = # (REF IMAGE self)REF IMAGE: + BEGIN + (fill OF class image)(self, black OF class image); + self + END, + + # PROC fill = # (REF IMAGE self, PIXEL color)VOID: + FOR x FROM 1 LWB self TO 1 UPB self DO + FOR y FROM 2 LWB self TO 2 UPB self DO + self[x,y] := color + OD + OD, + # PROC print = # (REF IMAGE self)VOID: + printf(($n(UPB self)(3(16r2d))l$, self)), +# virtual: # + # REF PROC line = # LOC PROC (REF IMAGE, POINT, POINT, PIXEL)VOID, + # REF PROC circle = # LOC PROC (REF IMAGE, POINT, INT, PIXEL)VOID, + # REF PROC cubic bezier = # LOC PROC (REF IMAGE, POINT, POINT, POINT, POINT, PIXEL, UNION(INT, VOID))VOID +); + +OP CLASSOF = (IMAGE image)CLASSIMAGE: class image; +OP INIT = (REF IMAGE image)REF IMAGE: (init OF (CLASSOF image))(image); + +BOOL test = TRUE; +IF test THEN +### +The test program +### + REF IMAGE x := INIT LOC[1:16, 1:16]PIXEL; + (fill OF class image) (x, white OF class image); + (print OF class image) (x) +FI diff --git a/Task/Bitmap/Ada/bitmap-1.ada b/Task/Bitmap/Ada/bitmap-1.ada new file mode 100644 index 0000000000..c6845cbb41 --- /dev/null +++ b/Task/Bitmap/Ada/bitmap-1.ada @@ -0,0 +1,17 @@ +package Bitmap_Store is + type Luminance is mod 2**8; + type Pixel is record + R, G, B : Luminance; + end record; + Black : constant Pixel := (others => 0); + White : constant Pixel := (others => 255); + type Image is array (Positive range <>, Positive range <>) of Pixel; + + procedure Fill (Picture : in out Image; Color : Pixel); + + procedure Print (Picture : Image); + + type Point is record + X, Y : Positive; + end record; +end Bitmap_Store; diff --git a/Task/Bitmap/Ada/bitmap-2.ada b/Task/Bitmap/Ada/bitmap-2.ada new file mode 100644 index 0000000000..d552d497d1 --- /dev/null +++ b/Task/Bitmap/Ada/bitmap-2.ada @@ -0,0 +1,28 @@ +with Ada.Text_IO; use Ada.Text_IO; + +package body Bitmap_Store is + + procedure Fill (Picture : in out Image; Color : Pixel) is + begin + for I in Picture'Range (1) loop + for J in Picture'Range (2) loop + Picture (I, J) := Color; + end loop; + end loop; + end Fill; + + procedure Print (Picture : Image) is + begin + for I in Picture'Range (1) loop + for J in Picture'Range (2) loop + if Picture (I, J) = White then + Put (' '); + else + Put ('H'); + end if; + end loop; + New_Line; + end loop; + end Print; + +end Bitmap_Store; diff --git a/Task/Bitmap/Ada/bitmap-3.ada b/Task/Bitmap/Ada/bitmap-3.ada new file mode 100644 index 0000000000..440209b31c --- /dev/null +++ b/Task/Bitmap/Ada/bitmap-3.ada @@ -0,0 +1,7 @@ +use Bitmap_Store; with Bitmap_Store; + ... + X : Image (1..64, 1..64); +begin + Fill (X, (255, 255, 255)); + X (1, 2) := (R => 255, others => 0); + X (3, 4) := X (1, 2); diff --git a/Task/Bitmap/AutoHotkey/bitmap.ahk b/Task/Bitmap/AutoHotkey/bitmap.ahk new file mode 100644 index 0000000000..791a7d7bc8 --- /dev/null +++ b/Task/Bitmap/AutoHotkey/bitmap.ahk @@ -0,0 +1,93 @@ +test: +blue := color(0,0,255) ; rgb +cyan := color(0,255,255) +blue_square := Bitmap(10, 10, blue) +cyanppm := Bitmap(10, 10, cyan) +x := blue_square[4,4] ; get pixel(4,4) +msgbox % "blue: 4,4,R,G,B, RGB: " x.R ", " x.G ", " x.B ", " x.rgb() +blue_square[4,4] := cyan ; set pixel(4,4) +x := blue_square[4,4] ; get pixel(4,4) +blue_square.write("blue.ppm") +return + +Bitmap(width = 1, height = 1, background = 0) +{ +global black +black := color(0,0,0) +if !background +background := black + + static BitmapType + if !BitmapType + BitmapType + := Object("fill", "Bitmap_Fill" + ,"write", "Bitmap_write_ppm3") + + img := Object("width", width + ,"height", height + , "base" , BitmapType) + + img._SetCapacity(height) ; an array of rows + img.fill(background) +Return img +} + + +Bitmap_Fill(bitmap, color) +{ +r := color.r +g := color.g +b := color.b + loop % bitmap.height + { + height := A_Index + loop % bitmap.width + { + width := A_Index + bitmap[height, width] := color(r, g, b) + } + } + return bitmap +} + +Bitmap_write_ppm3(bitmap, filename) +{ +file := FileOpen(filename, 0x11) ; utf-8, write +file.seek(0,0) +file.write("P3`n" +. bitmap.width . " " . bitmap.height . "`n" +. "255`n") + loop % bitmap.height + { + height := A_Index + loop % bitmap.width + { + width := A_Index + color := bitmap[height, width] + file.Write(color.R . " ") + file.Write(color.G . " ") + file.Write(color.B . " ") + } + file.write("`n") + } + file.close() + return 0 +} + +Color(r, g, b) +{ + static ColorType + if !ColorType + ColorType + := Object("rgb" , "Color_rgb") + + return Object("r" , r, "g", g, "b", b + , "base" , ColorType) + + ; return Object("r" , r, "g", g, "b", b, "rgb", "Color_rgb") +} + +Color_rgb(clr) +{ +return clr.R << 16 | clr.G << 8 | clr.B +} diff --git a/Task/Bitmap/BASIC256/bitmap.basic256 b/Task/Bitmap/BASIC256/bitmap.basic256 new file mode 100644 index 0000000000..6a126e615a --- /dev/null +++ b/Task/Bitmap/BASIC256/bitmap.basic256 @@ -0,0 +1,18 @@ +graphsize 30,30 +call fill(rgb(255,0,0)) +call setpixel(10,10,rgb(0,255,255)) +print "pixel 10,10 is " + pixel(10,10) +print "pixel 20,20 is " + pixel(20,10) + +imgsave "BASIC256_bitmap.png" +end + +subroutine fill(c) +color c +rect 0,0,graphwidth, graphheight +end subroutine + +subroutine setpixel(x,y,c) +color c +plot x,y +end subroutine diff --git a/Task/Bitmap/BBC-BASIC/bitmap.bbc b/Task/Bitmap/BBC-BASIC/bitmap.bbc new file mode 100644 index 0000000000..553007d371 --- /dev/null +++ b/Task/Bitmap/BBC-BASIC/bitmap.bbc @@ -0,0 +1,34 @@ + Width% = 200 + Height% = 200 + + REM Set window size: + VDU 23,22,Width%;Height%;8,16,16,128 + + REM Fill with an RGB colour: + PROCfill(100,150,200) + + REM Set a pixel: + PROCsetpixel(100,100,255,255,0) + + REM Get a pixel: + rgb% = FNgetpixel(100,100) + PRINT RIGHT$("00000" + STR$~rgb%, 6) + END + + DEF PROCfill(r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1+128 + CLG + ENDPROC + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC + + DEF FNgetpixel(x%,y%) + LOCAL col% + col% = TINT(x%*2,y%*2) + SWAP ?^col%,?(^col%+2) + = col% diff --git a/Task/Bitmap/C/bitmap-1.c b/Task/Bitmap/C/bitmap-1.c new file mode 100644 index 0000000000..44b484cea5 --- /dev/null +++ b/Task/Bitmap/C/bitmap-1.c @@ -0,0 +1,41 @@ +#ifndef _IMGLIB_0 +#define _IMGLIB_0 + +#include +#include +#include +#include +#include +#include + +typedef unsigned char color_component; +typedef color_component pixel[3]; +typedef struct { + unsigned int width; + unsigned int height; + pixel * buf; +} image_t; +typedef image_t * image; + +image alloc_img(unsigned int width, unsigned int height); +void free_img(image); +void fill_img(image img, + color_component r, + color_component g, + color_component b ); +void put_pixel_unsafe( + image img, + unsigned int x, + unsigned int y, + color_component r, + color_component g, + color_component b ); +void put_pixel_clip( + image img, + unsigned int x, + unsigned int y, + color_component r, + color_component g, + color_component b ); +#define GET_PIXEL(IMG, X, Y) (IMG->buf[ ((Y) * IMG->width + (X)) ]) +#endif diff --git a/Task/Bitmap/C/bitmap-2.c b/Task/Bitmap/C/bitmap-2.c new file mode 100644 index 0000000000..22756034b3 --- /dev/null +++ b/Task/Bitmap/C/bitmap-2.c @@ -0,0 +1,58 @@ +image alloc_img(unsigned int width, unsigned int height) +{ + image img; + img = malloc(sizeof(image_t)); + img->buf = malloc(width * height * sizeof(pixel)); + img->width = width; + img->height = height; + return img; +} + +void free_img(image img) +{ + free(img->buf); + free(img); +} + +void fill_img( + image img, + color_component r, + color_component g, + color_component b ) +{ + unsigned int i, n; + n = img->width * img->height; + for (i=0; i < n; ++i) + { + img->buf[i][0] = r; + img->buf[i][1] = g; + img->buf[i][2] = b; + } +} + +void put_pixel_unsafe( + image img, + unsigned int x, + unsigned int y, + color_component r, + color_component g, + color_component b ) +{ + unsigned int ofs; + ofs = (y * img->width) + x; + img->buf[ofs][0] = r; + img->buf[ofs][1] = g; + img->buf[ofs][2] = b; +} + +void put_pixel_clip( + image img, + unsigned int x, + unsigned int y, + color_component r, + color_component g, + color_component b ) +{ + if (x < img->width && y < img->height) + put_pixel_unsafe(img, x, y, r, g, b); +} diff --git a/Task/Bitmap/Clojure/bitmap.clj b/Task/Bitmap/Clojure/bitmap.clj new file mode 100644 index 0000000000..b447f4462c --- /dev/null +++ b/Task/Bitmap/Clojure/bitmap.clj @@ -0,0 +1,16 @@ +(import '[java.awt Color Graphics Image] + '[java.awt.image BufferedImage]) + +(defn blank-bitmap [width height] + (BufferedImage. width height BufferedImage/TYPE_3BYTE_BGR)) + +(defn fill [image color] + (doto (.getGraphics image) + (.setColor color) + (.fillRect 0 0 (.getWidth image) (.getHeight image)))) + +(defn set-pixel [image x y color] + (.setRGB image x y (.getRGB color))) + +(defn get-pixel [image x y] + (Color. (.getRGB image x y))) diff --git a/Task/Bitmap/Forth/bitmap.fth b/Task/Bitmap/Forth/bitmap.fth new file mode 100644 index 0000000000..0836af0314 --- /dev/null +++ b/Task/Bitmap/Forth/bitmap.fth @@ -0,0 +1,44 @@ +hex +0000ff constant red +00ff00 constant green +ff0000 constant blue +decimal + +1 cells constant pixel +: pixels cells ; + +: bdim ( bmp -- w h ) 2@ ; +: bheight ( bmp -- h ) @ ; +: bwidth ( bmp -- w ) bdim drop ; +: bdata ( bmp -- addr ) 2 cells + ; + +: bitmap ( w h -- bmp ) + 2dup * pixels bdata allocate throw + dup >r 2! r> ; + +: bfill ( pixel bmp -- ) + dup bdata swap bdim * pixels + bounds do + dup i ! + pixel +loop + drop ; + +: bxy ( x y bmp -- addr ) + dup >r bwidth * + pixels r> bdata + ; + +: b@ ( x y bmp -- pixel ) bxy @ ; +: b! ( pixel x y bmp -- ) bxy ! ; + +: bshow ( bmp -- ) + hex + dup bdim + 0 do cr + dup 0 do + over i j rot b@ if [char] * else bl then emit \ 7 u.r + loop + loop + 2drop decimal ; + +4 3 bitmap value test +red test bfill +test bshow cr diff --git a/Task/Bitmap/Go/bitmap.go b/Task/Bitmap/Go/bitmap.go new file mode 100644 index 0000000000..056324df86 --- /dev/null +++ b/Task/Bitmap/Go/bitmap.go @@ -0,0 +1,120 @@ +// Raster package used with a number of RC tasks. +// +// For each task, documentation in package main source will list this +// file and others that are necessary to build a raster package with +// sufficient functionality for the task. To build a working program, +// build a raster package from the files listed, install the package, +// and then compile and link the package main that completes the task. +// +// Alternatively, files in the raster package can be combined as desired +// to build a package that meets the needs of multiple tasks. +package raster + +// Rgb is a 24 bit color value represented with a 32 bit int +// in the conventional way. This is expected to be convenient +// for the programmer in many cases. +type Rgb int32 + +// Pixel has r, g, and b as separate fields. This is used as +// the in-memory representation of a bitmap. +type Pixel struct { + R, G, B byte +} + +// Pixel returns a new Pixel from a Rgb value +func (c Rgb) Pixel() Pixel { + return Pixel{R: byte(c >> 16), G: byte(c >> 8), B: byte(c)} +} + +// Rgb returns a single Rgb value computed from rgb fields of a Pixel +// of a Pixel. +func (p Pixel) Rgb() Rgb { + return Rgb(p.R)<<16 | Rgb(p.G)<<8 | Rgb(p.B) +} + +// Bitmap is the in-memory representation, or image storage type of a bitmap. +// Zero value for type is a valid zero-size bitmap. +// The only exported field is Comments. Remaining fields have interdepencies +// that are managed by package code and so should not be directly accessed +// from outside the package. +type Bitmap struct { + Comments []string + rows, cols int + px []Pixel // all pixels as a single slice, row major order + pxRow [][]Pixel // rows of pixels as slices of px +} + +const creator = "# Creator: Rosetta Code http://rosettacode.org/" + +// New is a Bitmap "constructor." Parameters x and y are extents. +// That is, the new bitmap will have x columns and y rows. +func NewBitmap(x, y int) (b *Bitmap) { + b = &Bitmap{ + Comments: []string{creator}, + rows: y, // named fields here to prevent possible mix-ups. + cols: x, + px: make([]Pixel, x*y), + pxRow: make([][]Pixel, y), + } + // Note rows of pixels are not allocated separately. + // Rather the whole bitmap is allocted in one chunk as px. + // This simplifies allocation and maintains locality. + x0, x1 := 0, x + for i := range b.pxRow { + b.pxRow[i] = b.px[x0:x1] // slice operation. does no allocation. + x0, x1 = x1, x1+x + } + return b +} + +// Extent returns bitmap dimensions. +func (b *Bitmap) Extent() (cols, rows int) { + return b.cols, b.rows +} + +// Fill entire bitmap with solid color. +func (b *Bitmap) Fill(p Pixel) { + for i := range b.px { + b.px[i] = p + } +} + +func (b *Bitmap) FillRgb(c Rgb) { + b.Fill(c.Pixel()) +} + +// Set a single pixel color value. +// Clips to bitmap boundaries. +// Returns true if pixel was set, false if clipped. +func (b *Bitmap) SetPx(x, y int, p Pixel) bool { + defer func() { recover() }() + b.pxRow[y][x] = p + return true +} + +func (b *Bitmap) SetPxRgb(x, y int, c Rgb) bool { + return b.SetPx(x, y, c.Pixel()) +} + +// Note: Clipping to bitmap boundaries is needed for program correctness +// but is otherwise not required by the task. It is implemented with the +// combination of pxRow and the deferred recover. SetPx, GetPx return the +// clipping result as a way for higher level graphics functions to track +// plotting and clipping status. As this is not required by tasks though, +// it is generally not implemented. + +// Get a single pixel color value. +// Returns pixel and ok=true if coordinates are within bitmap boundaries. +// Returns ok=false if coordinates are outside bitmap boundaries. +func (b *Bitmap) GetPx(x, y int) (p Pixel, ok bool) { + defer func() { recover() }() + return b.pxRow[y][x], true +} + +func (b *Bitmap) GetPxRgb(x, y int) (Rgb, bool) { + p, ok := b.GetPx(x, y) + if !ok { + return 0, false + } + return p.Rgb(), true +} diff --git a/Task/Bitmap/Haskell/bitmap-1.hs b/Task/Bitmap/Haskell/bitmap-1.hs new file mode 100644 index 0000000000..6cc9bcd4f2 --- /dev/null +++ b/Task/Bitmap/Haskell/bitmap-1.hs @@ -0,0 +1,77 @@ +module Bitmap(module Bitmap) where + +import Control.Monad +import Control.Monad.ST +import Data.Array.ST + +newtype Pixel = Pixel (Int, Int) deriving Eq + +instance Ord Pixel where + compare (Pixel (x1, y1)) (Pixel (x2, y2)) = + case compare y1 y2 of + EQ -> compare x1 x2 + v -> v + +instance Ix Pixel where +{- This instance differs from the one for (Int, Int) in that +the ordering of indices is + (0,0), (1,0), (2,0), (0,1), (1,1), (2,1) +instead of + (0,0), (0,1), (1,0), (1,1), (2,0), (2,1). -} + range (Pixel (xa, ya), Pixel (xz, yz)) = + [Pixel (x, y) | y <- [ya .. yz], x <- [xa .. xz]] + index (Pixel (xa, ya), Pixel (xz, _)) (Pixel (xi, yi)) = + (yi - ya)*(xz - xa + 1) + (xi - xa) + inRange (Pixel (xa, ya), Pixel (xz, yz)) (Pixel (xi, yi)) = + not $ xi < xa || xi > xz || yi < ya || yi > yz + rangeSize (Pixel (xa, ya), Pixel (xz, yz)) = + (xz - xa + 1) * (yz - ya + 1) + +instance Show Pixel where + show (Pixel p) = show p + +class Ord c => Color c where + luminance :: c -> Int + -- The Int should be in the range [0 .. 255]. + black, white :: c + toNetpbm :: [c] -> String + fromNetpbm :: [Int] -> [c] + netpbmMagicNumber, netpbmMaxval :: c -> String + {- The argument to these two functions is ignored; the + parameter is only for typechecking. -} + +newtype Color c => Image s c = Image (STArray s Pixel c) + +image :: Color c => Int -> Int -> c -> ST s (Image s c) +{- Creates a new image with the given width and height, filled +with the given color. -} +image w h = liftM Image . + newArray (Pixel (0, 0), Pixel (w - 1, h - 1)) + +listImage :: Color c => Int -> Int -> [c] -> ST s (Image s c) +{- Creates a new image with the given width and height, with +each pixel set to the corresponding element of the given list. -} +listImage w h = liftM Image . + newListArray (Pixel (0, 0), Pixel (w - 1, h - 1)) + +dimensions :: Color c => Image s c -> ST s (Int, Int) +dimensions (Image i) = do + (_, Pixel (x, y)) <- getBounds i + return (x + 1, y + 1) + +getPix :: Color c => Image s c -> Pixel -> ST s c +getPix (Image i) = readArray i + +getPixels :: Color c => Image s c -> ST s [c] +getPixels (Image i) = getElems i + +setPix :: Color c => Image s c -> Pixel -> c -> ST s () +setPix (Image i) = writeArray i + +fill :: Color c => Image s c -> c -> ST s () +fill (Image i) c = getBounds i >>= mapM_ f . range + where f p = writeArray i p c + +mapImage :: (Color c, Color c') => + (c -> c') -> Image s c -> ST s (Image s c') +mapImage f (Image i) = liftM Image $ mapArray f i diff --git a/Task/Bitmap/Haskell/bitmap-2.hs b/Task/Bitmap/Haskell/bitmap-2.hs new file mode 100644 index 0000000000..8559d555bf --- /dev/null +++ b/Task/Bitmap/Haskell/bitmap-2.hs @@ -0,0 +1,23 @@ +module Bitmap.RGB(module Bitmap.RGB) where + +import Bitmap +import Control.Monad.ST + +newtype RGB = RGB (Int, Int, Int) deriving (Eq, Ord) + +instance Color RGB where + luminance (RGB (r, g, b)) = round x + where x = 0.2126*r' + 0.7152*g' + 0.0722*b' + (r', g', b') = (toEnum r, toEnum g, toEnum b) + black = RGB (0, 0, 0) + white = RGB (255, 255, 255) + toNetpbm = concatMap f + where f (RGB (r, g, b)) = [toEnum r, toEnum g, toEnum b] + fromNetpbm [] = [] + fromNetpbm (r : g : b : rest) = RGB (r, g, b) : fromNetpbm rest + netpbmMagicNumber _ = "P6" + netpbmMaxval _ = "255" + +toRGBImage :: Color c => Image s c -> ST s (Image s RGB) +toRGBImage = mapImage $ f . luminance + where f x = RGB (x, x, x) diff --git a/Task/Bitmap/Java/bitmap-1.java b/Task/Bitmap/Java/bitmap-1.java new file mode 100644 index 0000000000..5ba6fe42e3 --- /dev/null +++ b/Task/Bitmap/Java/bitmap-1.java @@ -0,0 +1,36 @@ +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; + +public class BasicBitmapStorage +{ + private BufferedImage image; + + public BasicBitmapStorage(final int width, final int height) + { + image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); + } + + public void fill(final Color c) + { + Graphics g = image.getGraphics(); + g.setColor(c); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); + } + + public void setPixel(final int x, final int y, final Color c) + { + image.setRGB(x, y, c.getRGB()); + } + + public Color getPixel(final int x, final int y) + { + return new Color(image.getRGB(x, y)); + } + + public Image getImage() + { + return image; + } +} diff --git a/Task/Bitmap/Java/bitmap-2.java b/Task/Bitmap/Java/bitmap-2.java new file mode 100644 index 0000000000..9f647f775a --- /dev/null +++ b/Task/Bitmap/Java/bitmap-2.java @@ -0,0 +1,19 @@ +import java.awt.Color; +import junit.framework.TestCase; + +public class BasicBitmapStorageTest extends TestCase +{ + public static final int WIDTH = 640, HEIGHT = 480; + + BasicBitmapStorage bbs = new BasicBitmapStorage(WIDTH, HEIGHT); + + public void testHappy() + { + bbs.fill(Color.cyan); + bbs.setPixel(WIDTH / 2, HEIGHT / 2, Color.BLACK); + Color c1 = bbs.getPixel(WIDTH / 2, HEIGHT / 2); + Color c2 = bbs.getPixel(20, 20); + assertEquals(Color.BLACK, c1); + assertEquals(Color.CYAN, c2); + } +} diff --git a/Task/Bitmap/Lua/bitmap-1.lua b/Task/Bitmap/Lua/bitmap-1.lua new file mode 100644 index 0000000000..76b2c22516 --- /dev/null +++ b/Task/Bitmap/Lua/bitmap-1.lua @@ -0,0 +1,22 @@ +function Allocate_Bitmap( width, height ) + local bitmap = {} + for i = 1, width do + bitmap[i] = {} + for j = 1, height do + bitmap[i][j] = {} + end + end + return bitmap +end + +function Fill_Bitmap( bitmap, color ) + for i = 1, #bitmap do + for j = 1, #bitmap[1] do + bitmap[i][j] = color + end + end +end + +function Get_Pixel( bitmap, x, y ) + return bitmap[x][y] +end diff --git a/Task/Bitmap/Lua/bitmap-2.lua b/Task/Bitmap/Lua/bitmap-2.lua new file mode 100644 index 0000000000..bf39f9f715 --- /dev/null +++ b/Task/Bitmap/Lua/bitmap-2.lua @@ -0,0 +1,4 @@ +bitmap = Allocate_Bitmap( 100, 50 ) +Fill_Bitmap( bitmap, { 15, 200, 80 } ) +pixel = Get_Pixel( bitmap, 20, 25 ) +print( pixel[1], pixel[2], pixel[3] ) diff --git a/Task/Bitmap/MATLAB/bitmap-1.m b/Task/Bitmap/MATLAB/bitmap-1.m new file mode 100644 index 0000000000..84bbea3747 --- /dev/null +++ b/Task/Bitmap/MATLAB/bitmap-1.m @@ -0,0 +1,159 @@ +%Bitmap class +% +%Implements a class to manage bitmap images without the need for the +%various conversion and display functions +% +%Available functions: +% +%fill(obj,color) +%setPixel(obj,pixel,color) +%getPixel(obj,pixel,[optional: color channel]) +%display(obj) +%disp(obj) +%plot(obj) +%image(obj) +%save(obj) +%open(obj) + +classdef Bitmap + + %% Public Properties + properties + + %Channel arrays + red; + green; + blue; + + end + + %% Public Methods + methods + + %Creates image and defaults it to black + function obj = Bitmap(width,height) + obj.red = zeros(height,width,'uint8'); + obj.green = zeros(height,width,'uint8'); + obj.blue = zeros(height,width,'uint8'); + end % End Bitmap Constructor + + %Fill the image with a specified color + %color = [red green blue] max for each is 255 + function fill(obj,color) + obj.red(:,:) = color(1); + obj.green(:,:) = color(2); + obj.blue(:,:) = color(3); + assignin('caller',inputname(1),obj); %saves the changes to the object + end + + %Set a pixel to a specified color + %pixel = [x y] + %color = [red green blue] + function setPixel(obj,pixel,color) + obj.red(pixel(2),pixel(1)) = color(1); + obj.green(pixel(2),pixel(1)) = color(2); + obj.blue(pixel(2),pixel(1)) = color(3); + assignin('caller',inputname(1),obj); %saves the changes to the object + end + + %Get pixel color + %pixel = [x y] + %varargin can be: + % no input for all channels + % 'r' or 'red' for red channel + % 'g' or 'green' for green channel + % 'b' or 'blue' for blue channel + function color = getPixel(obj,pixel,varargin) + + if( ~isempty(varargin) ) + switch (varargin{1}) + case {'r','red'} + color = obj.red(pixel(2),pixel(1)); + case {'g','green'} + color = obj.red(pixel(2),pixel(1)); + case {'b','blue'} + color = obj.red(pixel(2),pixel(1)); + end + else + color = [obj.red(pixel(2),pixel(1)) obj.green(pixel(2),pixel(1)) obj.blue(pixel(2),pixel(1))]; + end + + end + + %Display the image + %varargin can be: + % no input for all channels + % 'r' or 'red' for red channel + % 'g' or 'green' for green channel + % 'b' or 'blue' for blue channel + function display(obj,varargin) + + if( ~isempty(varargin) ) + switch (varargin{1}) + case {'r','red'} + image(obj.red) + case {'g','green'} + image(obj.green) + case {'b','blue'} + image(obj.blue) + end + + colormap bone; + else + bitmap = cat(3,obj.red,obj.green,obj.blue); + image(bitmap); + end + end + + %Overload several commonly used display functions + function disp(obj,varargin) + display(obj,varargin{:}); + end + + function plot(obj,varargin) + display(obj,varargin{:}); + end + + function image(obj,varargin) + display(obj,varargin{:}); + end + + %Saves the image + function save(obj) + + %Open file dialogue + [fileName,pathName,success] = uiputfile({'*.bmp','Bitmap Image (*.bmp)'},'Save Bitmap As'); + + if( not(success == 0) ) + imwrite(cat(3,obj.red,obj.green,obj.blue),[pathName fileName],'bmp'); %Write image file to disk + disp('Save Complete'); + end + end + + %Opens an image and overwrites what is currently stored + function success = open(obj) + + %Open file dialogue + [fileName,pathName,success] = uigetfile({'*.bmp','Bitmap Image (*.bmp)'},'Open Bitmap '); + + if( not(success == 0) ) + + channels = imread([pathName fileName], 'bmp'); %returns color indexed data + + %Store each channel + obj.red = channels(:,:,1); + obj.green = channels(:,:,2); + obj.blue = channels(:,:,3); + + assignin('caller',inputname(1),obj); %saves the changes to the object + success = true; + return + else + success = false; + return + end + end + + + end %methods +end %classdef diff --git a/Task/Bitmap/MATLAB/bitmap-2.m b/Task/Bitmap/MATLAB/bitmap-2.m new file mode 100644 index 0000000000..59ab9c3a7c --- /dev/null +++ b/Task/Bitmap/MATLAB/bitmap-2.m @@ -0,0 +1,18 @@ +>> img = Bitmap(20,30); +>> img.fill([30 30 150]); +>> img.setPixel([10 15],[20 130 66]); +>> disp(img) +>> img.getPixel([10 15]) + +ans = + + 20 130 66 + +>> img.getPixel([10 15],'red') + +ans = + + 20 + +>> img.save() +Save Complete diff --git a/Task/Bitmap/PHP/bitmap.php b/Task/Bitmap/PHP/bitmap.php new file mode 100644 index 0000000000..6abf193674 --- /dev/null +++ b/Task/Bitmap/PHP/bitmap.php @@ -0,0 +1,39 @@ +class Bitmap { + public $data; + public $w; + public $h; + public function __construct($w = 16, $h = 16){ + $white = array_fill(0, $w, array(255,255,255)); + $this->data = array_fill(0, $h, $white); + $this->w = $w; + $this->h = $h; + } + //Fills a rectangle, or the whole image with black by default + public function fill($x = 0, $y = 0, $w = null, $h = null, $color = array(0,0,0)){ + if (is_null($w)) $w = $this->w; + if (is_null($h)) $h = $this->h; + $w += $x; + $h += $y; + for ($i = $y; $i < $h; $i++){ + for ($j = $x; $j < $w; $j++){ + $this->setPixel($j, $i, $color); + } + } + } + public function setPixel($x, $y, $color = array(0,0,0)){ + if ($x >= $this->w) return false; + if ($x < 0) return false; + if ($y >= $this->h) return false; + if ($y < 0) return false; + $this->data[$y][$x] = $color; + } + public function getPixel($x, $y){ + return $this->data[$y][$x]; + } +} + +$b = new Bitmap(16,16); +$b->fill(); +$b->fill(2, 2, 18, 18, array(240,240,240)); +$b->setPixel(0, 15, array(255,0,0)); +print_r($b->getPixel(3,3)); //(240,240,240) diff --git a/Task/Bitmap/Perl/bitmap.pl b/Task/Bitmap/Perl/bitmap.pl new file mode 100644 index 0000000000..36c3041905 --- /dev/null +++ b/Task/Bitmap/Perl/bitmap.pl @@ -0,0 +1,27 @@ +#! /usr/bin/perl + +use strict; + +use Image::Imlib2; + +# create the "canvas" +my $img = Image::Imlib2->new(200,200); + +# fill with a plain RGB(A) color +$img->set_color(255, 0, 0, 255); +$img->fill_rectangle(0,0, 200, 200); + +# set a pixel to green (at 40,40) +$img->set_color(0, 255, 0, 255); +$img->draw_point(40,40); + +# "get" pixel rgb(a) +my ($red, $green, $blue, $alpha) = $img->query_pixel(40,40); +undef $img; + +# another way of creating a canvas with a bg colour (or from +# an existing "raw" data) +my $col = pack("CCCC", 255, 255, 0, 0); # a, r, g, b +my $img = Image::Imlib2->new_using_data(200, 200, $col x (200 * 200)); + +exit 0; diff --git a/Task/Bitmap/PicoLisp/bitmap.l b/Task/Bitmap/PicoLisp/bitmap.l new file mode 100644 index 0000000000..26722937c2 --- /dev/null +++ b/Task/Bitmap/PicoLisp/bitmap.l @@ -0,0 +1,17 @@ +# Create an empty image of 120 x 90 pixels +(setq *Ppm (make (do 90 (link (need 120))))) + +# Fill an image with a given color +(de ppmFill (Ppm R G B) + (for Y Ppm + (map + '((X) (set X (list R G B))) + Y ) ) ) + +# Set pixel with a color +(de ppmSetPixel (Ppm X Y R G B) + (set (nth Ppm Y X) (list R G B)) ) + +# Get the color of a pixel +(de ppmGetPixel (Ppm X Y) + (get Ppm Y X) ) diff --git a/Task/Bitmap/R/bitmap.r b/Task/Bitmap/R/bitmap.r new file mode 100644 index 0000000000..fbeceb765f --- /dev/null +++ b/Task/Bitmap/R/bitmap.r @@ -0,0 +1,19 @@ +# See the class definitions and constructors with, e.g. +getClass("pixmapIndexed", package=pixmap) +pixmapIndexed + +# Image with all one colour +plot(p1 <- pixmapIndexed(matrix(0, nrow=3, ncol=4), col="red")) + +# Image with one pixel specified +cols <- rep("blue", 12); cols[7] <- "red" +plot(p2 <- pixmapIndexed(matrix(1:12, nrow=3, ncol=4), col=cols)) + +# Retrieve colour of a pixel +getcol <- function(pm, i, j) +{ + pmcol <- pm@col + dim(pmcol) <- dim(pm@index) + pmcol[i,j] +} +getcol(p2, 3, 4) #red diff --git a/Task/Bitmap/REXX/bitmap.rexx b/Task/Bitmap/REXX/bitmap.rexx new file mode 100644 index 0000000000..19b3aa3a38 --- /dev/null +++ b/Task/Bitmap/REXX/bitmap.rexx @@ -0,0 +1,35 @@ +/*REXX program shows how to handle a simple RGB raster graphics image. */ +image.='00 00 00'x /*set entire array to hex zeroes.*/ + +red='00000000 00000000 11111111'b /*define a red value. */ +image.=red /*set the entire array to red. */ + +blue='11111111 00000000 00000000'b /*define a blue value. */ +blue='ff 00 00'x /*another way to define blue. */ +image.10.40=blue /*set a particular pixel. */ + +x=20 +y=50 +aPIXcolor=image.x.y /*obtain the color of a pixel. */ +hexv=c2x(aPixcolor) /*get the binary value of 20,50. */ +binv=x2b(hexv) /*get the binary value of 20,50. */ + +say 'pixel' x","y '=' binv /*show the binary value of 20,50 */ +bin3v=left(binv,8) substr(binv,9,8) right(binv,8) +say 'pixel' x","y '=' bin3v /*show again, but with spaces. */ + +say 'pixel' x","y '=' hexv /*show again, but in hexadecimal.*/ +hex3v=left(hexv,2) substr(hexv,3,2) right(hexv,2) +say 'pixel' x","y '=' hex3v /*show again, but with spaces. */ + +RGB= /*start with a clean slate. */ +xSize=500 /*size of the X axis. */ +YSize=800 /* " " " Y " */ + + do x=1 to xSize + do y=1 to Ysize + RGB=RGM || image.x.y /*build RBG one pixel at a time.*/ + end /*y*/ + end /*x*/ + +return RGM /*return the RGB image to invoker*/ diff --git a/Task/Bitmap/Racket/bitmap.rkt b/Task/Bitmap/Racket/bitmap.rkt new file mode 100644 index 0000000000..6fbb9c76e3 --- /dev/null +++ b/Task/Bitmap/Racket/bitmap.rkt @@ -0,0 +1,41 @@ +#lang racket + +;; The racket/draw libraries provide imperative drawing functions. +;; http://docs.racket-lang.org/draw/index.html +(require racket/draw) + +;; To create an image with width and height, use the make-bitmap +;; function. + +;; For example, let's make a small image here: +(define bm (make-bitmap 640 480)) + +;; We use a drawing context handle, a "dc", to operate on the bitmap. +(define dc (send bm make-dc)) + +;; We can fill the bitmap with a color by using a combination of +;; setting the background, and clearing. +(send dc set-background (make-object color% 0 0 0)) ;; Color it black. +(send dc clear) + +;; Let's set a few pixels to a greenish color with set-pixel: +(define aquamarine (send the-color-database find-color "aquamarine")) +(for ([i 480]) + (send dc set-pixel i i aquamarine)) + +;; We can get at the color of a bitmap pixel by using the get-pixel +;; method. However, it may be faster to use get-argb-pixels if we +;; need a block of the pixels. Let's use get-argb-pixels and look +;; at a row starting at (0, 42) +(define buffer (make-bytes (* 480 4))) ;; alpha, red, green, blue +(send dc get-argb-pixels 0 42 480 1 buffer) + +;; We can inspect the buffer +(bytes-ref buffer 0) ;; and see that the first pixel's alpha is 255, +(bytes-ref buffer 1) ;; and the red, green, and blue components are 0. +(bytes-ref buffer 2) +(bytes-ref buffer 3) + +;; If we are using DrRacket, we can just print the bm as a toplevel expression +;; to view the final image: +bm diff --git a/Task/Bitmap/Ruby/bitmap.rb b/Task/Bitmap/Ruby/bitmap.rb new file mode 100644 index 0000000000..4e2977662f --- /dev/null +++ b/Task/Bitmap/Ruby/bitmap.rb @@ -0,0 +1,49 @@ +class RGBColour + def initialize(red, green, blue) + unless red.between?(0,255) and green.between?(0,255) and blue.between?(0,255) + raise ArgumentError, "invalid RGB parameters: #{[red, green, blue].inspect}" + end + @red, @green, @blue = red, green, blue + end + attr_reader :red, :green, :blue + alias_method :r, :red + alias_method :g, :green + alias_method :b, :blue + + RED = RGBColour.new(255,0,0) + GREEN = RGBColour.new(0,255,0) + BLUE = RGBColour.new(0,0,255) + BLACK = RGBColour.new(0,0,0) + WHITE = RGBColour.new(255,255,255) +end + +class Pixmap + def initialize(width, height) + @width = width + @height = height + @data = fill(RGBColour::WHITE) + end + attr_reader :width, :height + + def fill(colour) + @data = Array.new(@width) {Array.new(@height, colour)} + end + + def validate_pixel(x,y) + unless x.between?(0, @width-1) and y.between?(0, @height-1) + raise ArgumentError, "requested pixel (#{x}, #{y}) is outside dimensions of this bitmap" + end + end + + def [](x,y) + validate_pixel(x,y) + @data[x][y] + end + alias_method :get_pixel, :[] + + def []=(x,y,colour) + validate_pixel(x,y) + @data[x][y] = colour + end + alias_method :set_pixel, :[]= +end diff --git a/Task/Bitmap/Scala/bitmap-1.scala b/Task/Bitmap/Scala/bitmap-1.scala new file mode 100644 index 0000000000..b665725ea3 --- /dev/null +++ b/Task/Bitmap/Scala/bitmap-1.scala @@ -0,0 +1,15 @@ +import java.awt.image.BufferedImage +import java.awt.Color + +class RgbBitmap(val width:Int, val height:Int) { + val image=new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR) + + def fill(c:Color)={ + val g=image.getGraphics() + g.setColor(c) + g.fillRect(0, 0, width, height) + } + + def setPixel(x:Int, y:Int, c:Color)=image.setRGB(x, y, c.getRGB()) + def getPixel(x:Int, y:Int)=new Color(image.getRGB(x, y)) +} diff --git a/Task/Bitmap/Scala/bitmap-2.scala b/Task/Bitmap/Scala/bitmap-2.scala new file mode 100644 index 0000000000..e782a2f4bd --- /dev/null +++ b/Task/Bitmap/Scala/bitmap-2.scala @@ -0,0 +1,8 @@ +val img=new RgbBitmap(50, 50); +img.fill(Color.CYAN) +img.setPixel(5, 5, Color.BLUE) + +assert(img.getPixel(1,1)==Color.CYAN) +assert(img.getPixel(5,5)==Color.BLUE) +assert(img.width==50) +assert(img.height==50) diff --git a/Task/Bitmap/Scheme/bitmap-1.ss b/Task/Bitmap/Scheme/bitmap-1.ss new file mode 100644 index 0000000000..8f7307830b --- /dev/null +++ b/Task/Bitmap/Scheme/bitmap-1.ss @@ -0,0 +1,18 @@ +(define (make-list length object) + (if (= length 0) + (list) + (cons object (make-list (- length 1) object)))) + +(define (list-fill! list object) + (if (not (null? list)) + (begin (set-car! list object) (list-fill! (cdr list) object)))) + +(define (list-set! list element object) + (if (= element 1) + (set-car! list object) + (list-set! (cdr list) (- element 1) object))) + +(define (list-get list element) + (if (= element 1) + (car list) + (list-get (cdr list) (- element 1)))) diff --git a/Task/Bitmap/Scheme/bitmap-2.ss b/Task/Bitmap/Scheme/bitmap-2.ss new file mode 100644 index 0000000000..ff95b98f26 --- /dev/null +++ b/Task/Bitmap/Scheme/bitmap-2.ss @@ -0,0 +1,14 @@ +(define (make-image columns rows) + (if (= rows 0) + (list) + (cons (make-list columns (list)) (make-image columns (- rows 1))))) + +(define (image-fill! image colour) + (if (not (null? image)) + (begin (list-fill! (car image) colour) (image-fill! (cdr image) colour)))) + +(define (image-set! image column row colour) + (list-set! (list-get image row) column colour)) + +(define (image-get image column row) + (list-get (list-get image row) column)) diff --git a/Task/Bitmap/Scheme/bitmap-3.ss b/Task/Bitmap/Scheme/bitmap-3.ss new file mode 100644 index 0000000000..78ab16cfc8 --- /dev/null +++ b/Task/Bitmap/Scheme/bitmap-3.ss @@ -0,0 +1,5 @@ +(define *black* (list 0 0 0)) +(define *white* (list 255 255 255)) +(define *red* (list 255 0 0)) +(define *green* (list 0 255 0)) +(define *blue* (list 0 0 255)) diff --git a/Task/Bitmap/Scheme/bitmap-4.ss b/Task/Bitmap/Scheme/bitmap-4.ss new file mode 100644 index 0000000000..9791e242bc --- /dev/null +++ b/Task/Bitmap/Scheme/bitmap-4.ss @@ -0,0 +1,5 @@ +(define image (make-image 3 2)) +(image-fill! image *black*) +(image-set! image 2 1 *blue*) +(display image) +(newline) diff --git a/Task/Bitmap/Scheme/bitmap-5.ss b/Task/Bitmap/Scheme/bitmap-5.ss new file mode 100644 index 0000000000..c8c1af2a77 --- /dev/null +++ b/Task/Bitmap/Scheme/bitmap-5.ss @@ -0,0 +1 @@ +(((0 0 0) (0 0 255) (0 0 0)) ((0 0 0) (0 0 0) (0 0 0))) diff --git a/Task/Bitmap/Tcl/bitmap.tcl b/Task/Bitmap/Tcl/bitmap.tcl new file mode 100644 index 0000000000..3724a0bbe1 --- /dev/null +++ b/Task/Bitmap/Tcl/bitmap.tcl @@ -0,0 +1,30 @@ +package require Tcl 8.5 +package require Tk +namespace path ::tcl::mathfunc ;# for [max] function + +proc newImage {width height} { + return [image create photo -width $width -height $height] +} +proc fill {image colour} { + $image put $colour -to 0 0 [$image cget -width] [$image cget -height] +} +proc setPixel {image colour point} { + lassign $point x y + $image put $colour -to [max 0 $x] [max 0 $y] +} +proc getPixel {image point} { + lassign $point x y + # [$img get] returns a list: {r g b}; this proc should return a colour value + format {#%02x%02x%02x} {*}[$image get $x $y] +} + +# create the image and display it +set img [newImage 150 150] +label .l -image $img +pack .l + +fill $img red + +setPixel $img green {40 40} + +set rbg [getPixel $img {40 40}] diff --git a/Task/Bitwise-IO/0DESCRIPTION b/Task/Bitwise-IO/0DESCRIPTION new file mode 100644 index 0000000000..4f596552b5 --- /dev/null +++ b/Task/Bitwise-IO/0DESCRIPTION @@ -0,0 +1,22 @@ +The aim of this task is to write functions (or create a class if your +language is Object Oriented and you prefer) for reading and writing sequences of +bits. While the output of a asciiprint "STRING" is the ASCII byte sequence +"S", "T", "R", "I", "N", "G", the output of a "print" of the bits sequence +0101011101010 (13 bits) must be 0101011101010; real I/O is performed always +''quantized'' by byte (avoiding endianness issues and relying on underlying +buffering for performance), therefore you must obtain as output the bytes +0101 0111 0101 0'''000''' (bold bits are padding bits), i.e. in hexadecimal 57 50. + +As test, you can implement a '''rough''' (e.g. don't care about error handling or +other issues) compression/decompression program for ASCII sequences +of bytes, i.e. bytes for which the most significant bit is always unused, so that you can write +seven bits instead of eight (each 8 bytes of input, we write 7 bytes of output). + +These bit oriented I/O functions can be used to implement compressors and +decompressors; e.g. Dynamic and Static Huffman encodings use variable length +bits sequences, while LZW (see [[LZW compression]]) use fixed or variable ''words'' +nine (or more) bits long. + +* Limits in the maximum number of bits that can be written/read in a single read/write operation are allowed. + +* Errors handling is not mandatory diff --git a/Task/Bitwise-IO/ALGOL-68/bitwise-io.alg b/Task/Bitwise-IO/ALGOL-68/bitwise-io.alg new file mode 100644 index 0000000000..9fb40cdde7 --- /dev/null +++ b/Task/Bitwise-IO/ALGOL-68/bitwise-io.alg @@ -0,0 +1,131 @@ +# NIBBLEs are of any width, eg 1-bit OR 4-bits etc. # +MODE NIBBLE = STRUCT(INT width, BITS bits); + +PRIO << = 8, >> = 8; # define C style shift opertors # +OP << = (BITS bits, INT shift)BITS: bits SHL shift; +OP >> = (BITS bits, INT shift)BITS: bits SHR shift; + +# define nibble opertors for left/right shift and append # +OP << = (NIBBLE nibble, INT shift)NIBBLE: + (width OF nibble + shift, bits OF nibble << shift); + +OP >> = (NIBBLE nibble, INT shift)NIBBLE: + (width OF nibble - shift, bits OF nibble >> shift); + +OP +:= = (REF NIBBLE lhs, NIBBLE rhs)REF NIBBLE: ( + BITS rhs mask := BIN(ABS(2r1 << width OF rhs)-1); + lhs := ( width OF lhs + width OF rhs, bits OF lhs << width OF rhs OR bits OF rhs AND rhs mask) +); + +# define MODEs for generating NIBBLE streams and yielding NIBBLEs # +MODE YIELDNIBBLE = PROC(NIBBLE)VOID; +MODE GENNIBBLE = PROC(YIELDNIBBLE)VOID; + +PROC gen resize nibble = ( + INT out width, + GENNIBBLE gen nibble, + YIELDNIBBLE yield +)VOID:( + NIBBLE buf := (0, 2r0), out; + BITS out mask := BIN(ABS(2r1 << out width)-1); +# FOR NIBBLE nibble IN # gen nibble( # ) DO # +## (NIBBLE in nibble)VOID:( + buf +:= in nibble; + WHILE width OF buf >= out width DO + out := buf >> ( width OF buf - out width); + width OF buf -:= out width; # trim 'out' from buf # + yield((out width, bits OF out AND out mask)) + OD +# OD # )) +); + +# Routines for joining strings and generating a stream of nibbles # + +PROC gen nibble from 7bit chars = (STRING string, YIELDNIBBLE yield)VOID: + FOR key FROM LWB string TO UPB string DO yield((7, BIN ABS string[key])) OD; + +PROC gen nibble from 8bit chars = (STRING string, YIELDNIBBLE yield)VOID: + FOR key FROM LWB string TO UPB string DO yield((8,BIN ABS string[key])) OD; + +PROC gen join = ([]STRING strings, STRING new line, YIELDNIBBLE yield)VOID: + FOR key FROM LWB strings TO UPB strings DO + gen nibble from 8bit chars(strings[key]+new line, yield) + OD; + +# Two tables for uuencoding 6bits in printable ASCII chacters # + +[0:63]CHAR encode uue 6bit:= # [0:63] => CHAR64 # + "`!""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"[@0]; + +[0:255]BITS decode uue 6bit; # CHAR64 => [0:63] # + FOR key FROM LWB encode uue 6bit TO UPB encode uue 6bit DO + decode uue 6bit[ABS encode uue 6bit[key]] := BIN key + OD; + decode uue 6bit[ABS " "] := 2r0; # extra # + +# Some basic examples # + +PROC example uudecode nibble stream = VOID:( + + []STRING encoded uue 6bit hello world = ( + ":&5L;&\L('=O6]U('1O9&%Y""D=O;V1B>64L(&=O;V1B>64L(&=O", + ";V1B>64@""@``" + ); + + PROC gen join hello world = (YIELDNIBBLE yield)VOID: + # FOR NIBBLE nibble IN # gen join(encoded uue 6bit hello world, "", # ) DO # + ## (NIBBLE nibble)VOID:( + yield((6, decode uue 6bit[ABS bits OF nibble])) + # OD # )); + + print(("Decode uue 6bit NIBBLEs into 8bit CHARs:", new line)); + +# FOR NIBBLE nibble IN # gen resize nibble(8, gen join hello world, # ) DO ( # +## (NIBBLE nibble)VOID:( + print(REPR ABS bits OF nibble) +# OD # )) +); + +PROC example uuencode nibble stream = VOID: ( + []STRING hello world = ( + "hello, world", + "Hello, world!", + "Goodbye, cruel world", + "I'm leaving you today", + "Goodbye, goodbye, goodbye " + ); + + PROC gen join hello world = (YIELDNIBBLE yield)VOID: + gen join(hello world, REPR ABS 8r12, yield); # 8r12 = ASCII new line # + + print((new line, "Encode 8bit CHARs into uue 6bit NIBBLEs:", new line)); + INT count := 0; +# FOR NIBBLE nibble IN # gen resize nibble(6, gen join hello world, # ) DO ( # +## (NIBBLE nibble)VOID:( + print(encode uue 6bit[ABS bits OF nibble]); + count+:=1; + IF count MOD 60 = 0 THEN print(newline) FI +# OD # )); + print(new line); print(new line) +); + +PROC example compress 7bit chars = VOID: ( + STRING example 7bit string = "STRING & ABACUS"; + + print(("Convert 7bit ASCII CHARS to a 1bit stream: ",new line, + example 7bit string + " => ")); + + PROC gen example 7bit string = (YIELDNIBBLE yield)VOID: + gen nibble from 7bit chars(example 7bit string,yield); + +# FOR NIBBLE nibble IN # gen resize nibble(1, gen example 7bit string, # ) DO ( # +## (NIBBLE nibble)VOID: ( + print(whole(ABS bits OF nibble,0)) +# OD # )); + print(new line) +); + +example uudecode nibble stream; +example uuencode nibble stream; +example compress 7bit chars diff --git a/Task/Bitwise-IO/Ada/bitwise-io-1.ada b/Task/Bitwise-IO/Ada/bitwise-io-1.ada new file mode 100644 index 0000000000..f91b32ddf9 --- /dev/null +++ b/Task/Bitwise-IO/Ada/bitwise-io-1.ada @@ -0,0 +1,20 @@ +with Ada.Streams; use Ada.Streams; +with Ada.Finalization; + +package Bit_Streams is + type Bit is range 0..1; + type Bit_Array is array (Positive range <>) of Bit; + type Bit_Stream (Channel : not null access Root_Stream_Type'Class) is limited private; + procedure Read (Stream : in out Bit_Stream; Data : out Bit_Array); + procedure Write (Stream : in out Bit_Stream; Data : Bit_Array); +private + type Bit_Stream (Channel : not null access Root_Stream_Type'Class) is + new Ada.Finalization.Limited_Controlled with + record + Read_Count : Natural := 0; + Write_Count : Natural := 0; + Input : Stream_Element_Array (1..1); + Output : Stream_Element_Array (1..1); + end record; + overriding procedure Finalize (Stream : in out Bit_Stream); +end Bit_Streams; diff --git a/Task/Bitwise-IO/Ada/bitwise-io-2.ada b/Task/Bitwise-IO/Ada/bitwise-io-2.ada new file mode 100644 index 0000000000..0468988655 --- /dev/null +++ b/Task/Bitwise-IO/Ada/bitwise-io-2.ada @@ -0,0 +1,33 @@ +package body Bit_Streams is + procedure Finalize (Stream : in out Bit_Stream) is + begin + if Stream.Write_Count > 0 then + Stream.Output (1) := Stream.Output (1) * 2**(Stream_Element'Size - Stream.Write_Count); + Stream.Channel.Write (Stream.Output); + end if; + end Finalize; + procedure Read (Stream : in out Bit_Stream; Data : out Bit_Array) is + Last : Stream_Element_Offset; + begin + for Index in Data'Range loop + if Stream.Read_Count = 0 then + Stream.Channel.Read (Stream.Input, Last); + Stream.Read_Count := Stream_Element'Size; + end if; + Data (Index) := Bit (Stream.Input (1) / 2**(Stream_Element'Size - 1)); + Stream.Input (1) := Stream.Input (1) * 2; + Stream.Read_Count := Stream.Read_Count - 1; + end loop; + end Read; + procedure Write (Stream : in out Bit_Stream; Data : Bit_Array) is + begin + for Index in Data'Range loop + if Stream.Write_Count = Stream_Element'Size then + Stream.Channel.Write (Stream.Output); + Stream.Write_Count := 0; + end if; + Stream.Output (1) := Stream.Output (1) * 2 or Stream_Element (Data (Index)); + Stream.Write_Count := Stream.Write_Count + 1; + end loop; + end Write; +end Bit_Streams; diff --git a/Task/Bitwise-IO/Ada/bitwise-io-3.ada b/Task/Bitwise-IO/Ada/bitwise-io-3.ada new file mode 100644 index 0000000000..cb24a23e41 --- /dev/null +++ b/Task/Bitwise-IO/Ada/bitwise-io-3.ada @@ -0,0 +1,33 @@ +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; +with Bit_Streams; use Bit_Streams; + +procedure Test_Bit_Streams is + File : File_Type; + ABACUS : Bit_Array := + ( 1,0,0,0,0,0,1, -- A, big endian + 1,0,0,0,0,1,0, -- B + 1,0,0,0,0,0,1, -- A + 1,0,0,0,0,1,1, -- C + 1,0,1,0,1,0,1, -- U + 1,0,1,0,0,1,1 -- S + ); + Data : Bit_Array (ABACUS'Range); +begin + Create (File, Out_File, "abacus.dat"); + declare + Bits : Bit_Stream (Stream (File)); + begin + Write (Bits, ABACUS); + end; + Close (File); + Open (File, In_File, "abacus.dat"); + declare + Bits : Bit_Stream (Stream (File)); + begin + Read (Bits, Data); + end; + Close (File); + if Data /= ABACUS then + raise Data_Error; + end if; +end Test_Bit_Streams; diff --git a/Task/Bitwise-IO/BBC-BASIC/bitwise-io.bbc b/Task/Bitwise-IO/BBC-BASIC/bitwise-io.bbc new file mode 100644 index 0000000000..491a97fcaa --- /dev/null +++ b/Task/Bitwise-IO/BBC-BASIC/bitwise-io.bbc @@ -0,0 +1,43 @@ + file$ = @tmp$ + "bitwise.tmp" + test$ = "Hello, world!" + + REM Write to file, 7 bits per character: + file% = OPENOUT(file$) + FOR i% = 1 TO LEN(test$) + PROCwritebits(file%, ASCMID$(test$,i%), 7) + NEXT + PROCwritebits(file%, 0, 0) + CLOSE #file% + + REM Read from file, 7 bits per character: + file% = OPENIN(file$) + REPEAT + ch% = FNreadbits(file%, 7) + VDU ch% + UNTIL ch% = 0 + PRINT + CLOSE #file% + END + + REM Write n% bits from b% to file f% (n% = 0 to flush): + DEF PROCwritebits(f%, b%, n%) + PRIVATE a%, c% + IF n% = 0 BPUT #f%,a% : a% = 0 : c% = 0 + WHILE n% + IF c% = 8 BPUT #f%,a% : a% = 0 : c% = 0 + n% -= 1 + c% += 1 + IF b% AND 1 << n% THEN a% OR= 1 << (8 - c%) + ENDWHILE + ENDPROC + + REM Read n% bits from file f%: + DEF FNreadbits(f%, n%) + PRIVATE a%, c% : LOCAL v% + WHILE n% + IF c% = 0 a% = BGET#f% : c% = 8 + n% -= 1 + c% -= 1 + v% = v% << 1 OR (a% >> c%) AND 1 + ENDWHILE + = v% diff --git a/Task/Bitwise-IO/C/bitwise-io.c b/Task/Bitwise-IO/C/bitwise-io.c new file mode 100644 index 0000000000..310bb7664c --- /dev/null +++ b/Task/Bitwise-IO/C/bitwise-io.c @@ -0,0 +1,114 @@ +#include +#include +#include +#include + +typedef uint8_t byte; +typedef struct { + FILE *fp; + uint32_t accu; + int bits; +} bit_io_t, *bit_filter; + +bit_filter b_attach(FILE *f) +{ + bit_filter b = malloc(sizeof(bit_io_t)); + b->bits = b->accu = 0; + b->fp = f; + return b; +} + +void b_write(byte *buf, size_t n_bits, size_t shift, bit_filter bf) +{ + uint32_t accu = bf->accu; + int bits = bf->bits; + + buf += shift / 8; + shift %= 8; + + while (n_bits || bits >= 8) { + while (bits >= 8) { + bits -= 8; + fputc(accu >> bits, bf->fp); + accu &= (1 << bits) - 1; + } + while (bits < 8 && n_bits) { + accu = (accu << 1) | (((128 >> shift) & *buf) >> (7 - shift)); + --n_bits; + bits++; + if (++shift == 8) { + shift = 0; + buf++; + } + } + } + bf->accu = accu; + bf->bits = bits; +} + +size_t b_read(byte *buf, size_t n_bits, size_t shift, bit_filter bf) +{ + uint32_t accu = bf->accu; + int bits = bf->bits; + int mask, i = 0; + + buf += shift / 8; + shift %= 8; + + while (n_bits) { + while (bits && n_bits) { + mask = 128 >> shift; + if (accu & (1 << (bits - 1))) *buf |= mask; + else *buf &= ~mask; + + n_bits--; + bits--; + + if (++shift >= 8) { + shift = 0; + buf++; + } + } + if (!n_bits) break; + accu = (accu << 8) | fgetc(bf->fp); + bits += 8; + } + bf->accu = accu; + bf->bits = bits; + + return i; +} + +void b_detach(bit_filter bf) +{ + if (bf->bits) { + bf->accu <<= 8 - bf->bits; + fputc(bf->accu, bf->fp); + } + free(bf); +} + +int main() +{ + unsigned char s[] = "abcdefghijk"; + unsigned char s2[11] = {0}; + int i; + + FILE *f = fopen("test.bin", "wb"); + bit_filter b = b_attach(f); + /* for each byte in s, write 7 bits skipping 1 */ + for (i = 0; i < 10; i++) b_write(s + i, 7, 1, b); + b_detach(b); + fclose(f); + + /* read 7 bits and expand to each byte of s2 skipping 1 bit */ + f = fopen("test.bin", "rb"); + b = b_attach(f); + for (i = 0; i < 10; i++) b_read(s2 + i, 7, 1, b); + b_detach(b); + fclose(f); + + printf("%10s\n", s2); /* should be the same first 10 bytes as in s */ + + return 0; +} diff --git a/Task/Bitwise-IO/Forth/bitwise-io.fth b/Task/Bitwise-IO/Forth/bitwise-io.fth new file mode 100644 index 0000000000..4ad47069f8 --- /dev/null +++ b/Task/Bitwise-IO/Forth/bitwise-io.fth @@ -0,0 +1,21 @@ +\ writing + +: init-write ( -- b m ) 0 128 ; + +: flush-bits ( b m -- 0 128 ) drop emit init-write ; + +: ?flush-bits ( b m -- b' m' ) dup 128 < if flush-bits then ; + +: write-bit ( b m f -- b' m' ) + if tuck or swap then + 2/ dup 0= if flush-bits then ; + +\ reading + +: init-read ( -- b m ) key 128 ; + +: eof? ( b m -- b m f ) dup if false else key? 0= then ; + +: read-bit ( b m -- b' m' f ) + dup 0= if 2drop init-read then + 2dup and swap 2/ swap ; diff --git a/Task/Bitwise-IO/Haskell/bitwise-io.hs b/Task/Bitwise-IO/Haskell/bitwise-io.hs new file mode 100644 index 0000000000..91ce782a0b --- /dev/null +++ b/Task/Bitwise-IO/Haskell/bitwise-io.hs @@ -0,0 +1,30 @@ +import Data.List +import Data.Char +import Control.Monad +import Control.Arrow +import System.Environment + +int2bin :: Int -> [Int] +int2bin = unfoldr(\x -> if x==0 then Nothing + else Just (uncurry(flip(,)) (divMod x 2))) + +bin2int :: [Int] -> Int +bin2int = foldr ((.(2 *)).(+)) 0 + +bitReader = map (chr.bin2int). takeWhile(not.null). unfoldr(Just. splitAt 7) + . (take =<< (7 *) . (`div` 7) . length) + +bitWriter xs = tt ++ z00 where + tt = concatMap (take 7.(++repeat 0).int2bin.ord) xs + z00 = replicate (length xs `mod` 8) 0 + +main = do + (xs:_) <- getArgs + let bits = bitWriter xs + + putStrLn "Text to compress:" + putStrLn $ '\t' : xs + putStrLn $ "Uncompressed text length is " ++ show (length xs) + putStrLn $ "Compressed text has " ++ show (length bits `div` 8) ++ " bytes." + putStrLn "Read and decompress:" + putStrLn $ '\t' : bitReader bits diff --git a/Task/Bitwise-IO/Perl/bitwise-io-1.pl b/Task/Bitwise-IO/Perl/bitwise-io-1.pl new file mode 100644 index 0000000000..ba8a2e2f21 --- /dev/null +++ b/Task/Bitwise-IO/Perl/bitwise-io-1.pl @@ -0,0 +1,44 @@ +#! /usr/bin/perl + +use strict; + +# $buffer = write_bits(*STDOUT, $buffer, $number, $bits) +sub write_bits( $$$$ ) +{ + my ($out, $l, $num, $q) = @_; + $l .= substr(unpack("B*", pack("N", $num)), + -$q); + if ( (length($l) > 8) ) { + my $left = substr($l, 8); + print $out pack("B8", $l); + $l = $left; + } + return $l; +} + +# flush_bits(*STDOUT, $buffer) +sub flush_bits( $$ ) +{ + my ($out, $b) = @_; + print $out pack("B*", $b); +} + +# ($val, $buf) = read_bits(*STDIN, $buf, $n) +sub read_bits( $$$ ) +{ + my ( $in, $b, $n ) = @_; + # we put a limit in the number of bits we can read + # with one shot; this should mirror the limit of the max + # integer value perl can hold + if ( $n > 32 ) { return 0; } + while ( length($b) < $n ) { + my $v; + my $red = read($in, $v, 1); + if ( $red < 1 ) { return ( 0, -1 ); } + $b .= substr(unpack("B*", $v), -8); + } + my $bits = "0" x ( 32-$n ) . substr($b, 0, $n); + my $val = unpack("N", pack("B32", $bits)); + $b = substr($b, $n); + return ($val, $b); +} diff --git a/Task/Bitwise-IO/Perl/bitwise-io-2.pl b/Task/Bitwise-IO/Perl/bitwise-io-2.pl new file mode 100644 index 0000000000..02c07fa403 --- /dev/null +++ b/Task/Bitwise-IO/Perl/bitwise-io-2.pl @@ -0,0 +1,6 @@ +my $buf = ""; +my $c; +while( read(*STDIN, $c, 1) > 0 ) { + $buf = write_bits(*STDOUT, $buf, unpack("C1", $c), 7); +} +flush_bits(*STDOUT, $buf); diff --git a/Task/Bitwise-IO/Perl/bitwise-io-3.pl b/Task/Bitwise-IO/Perl/bitwise-io-3.pl new file mode 100644 index 0000000000..c1110a0f4f --- /dev/null +++ b/Task/Bitwise-IO/Perl/bitwise-io-3.pl @@ -0,0 +1,7 @@ +my $buf = ""; +my $v; +while(1) { + ( $v, $buf ) = read_bits(*STDIN, $buf, 7); + last if ($buf < 0); + print pack("C1", $v); +} diff --git a/Task/Bitwise-IO/PicoLisp/bitwise-io-1.l b/Task/Bitwise-IO/PicoLisp/bitwise-io-1.l new file mode 100644 index 0000000000..aa140e021b --- /dev/null +++ b/Task/Bitwise-IO/PicoLisp/bitwise-io-1.l @@ -0,0 +1,22 @@ +(de write7bitwise (Lst) + (let (Bits 0 Byte) + (for N Lst + (if (=0 Bits) + (setq Bits 7 Byte (* 2 N)) + (wr (| Byte (>> (dec 'Bits) N))) + (setq Byte (>> (- Bits 8) N)) ) ) + (unless (=0 Bits) + (wr Byte) ) ) ) + +(de read7bitwise () + (make + (let (Bits 0 Byte) + (while (rd 1) + (let N @ + (link + (if (=0 Bits) + (>> (one Bits) N) + (| Byte (>> (inc 'Bits) N)) ) ) + (setq Byte (& 127 (>> (- Bits 7) N))) ) ) + (when (= 7 Bits) + (link Byte) ) ) ) ) diff --git a/Task/Bitwise-IO/PicoLisp/bitwise-io-2.l b/Task/Bitwise-IO/PicoLisp/bitwise-io-2.l new file mode 100644 index 0000000000..05f256e59f --- /dev/null +++ b/Task/Bitwise-IO/PicoLisp/bitwise-io-2.l @@ -0,0 +1,11 @@ +(out 'a (write7bitwise (127 0 127 0 127 0 127 0 127))) +(hd 'a) +(in 'a (println (read7bitwise))) + +(out 'a (write7bitwise (0 127 0 127 0 127 0 127 0))) +(hd 'a) +(in 'a (println (read7bitwise))) + +(out 'a (write7bitwise (mapcar char (chop "STRING")))) +(hd 'a) +(println (mapcar char (in 'a (read7bitwise)))) diff --git a/Task/Bitwise-IO/Python/bitwise-io-1.py b/Task/Bitwise-IO/Python/bitwise-io-1.py new file mode 100644 index 0000000000..31d155993f --- /dev/null +++ b/Task/Bitwise-IO/Python/bitwise-io-1.py @@ -0,0 +1,51 @@ +class BitWriter: + def __init__(self, f): + self.accumulator = 0 + self.bcount = 0 + self.out = f + + def __del__(self): + self.flush() + + def writebit(self, bit): + if self.bcount == 8 : + self.flush() + if bit > 0: + self.accumulator |= (1 << (7-self.bcount)) + self.bcount += 1 + + def writebits(self, bits, n): + while n > 0: + self.writebit( bits & (1 << (n-1)) ) + n -= 1 + + def flush(self): + self.out.write(chr(self.accumulator)) + self.accumulator = 0 + self.bcount = 0 + + +class BitReader: + def __init__(self, f): + self.input = f + self.accumulator = 0 + self.bcount = 0 + self.read = 0 + + def readbit(self): + if self.bcount == 0 : + a = self.input.read(1) + if ( len(a) > 0 ): + self.accumulator = ord(a) + self.bcount = 8 + self.read = len(a) + rv = ( self.accumulator & ( 1 << (self.bcount-1) ) ) >> (self.bcount-1) + self.bcount -= 1 + return rv + + def readbits(self, n): + v = 0 + while n > 0: + v = (v << 1) | self.readbit() + n -= 1 + return v diff --git a/Task/Bitwise-IO/Python/bitwise-io-2.py b/Task/Bitwise-IO/Python/bitwise-io-2.py new file mode 100644 index 0000000000..48ac05572d --- /dev/null +++ b/Task/Bitwise-IO/Python/bitwise-io-2.py @@ -0,0 +1,9 @@ +#! /usr/bin/env python +import sys +import bitio + +o = bitio.BitWriter(sys.stdout) +c = sys.stdin.read(1) +while len(c) > 0: + o.writebits(ord(c), 7) + c = sys.stdin.read(1) diff --git a/Task/Bitwise-IO/Python/bitwise-io-3.py b/Task/Bitwise-IO/Python/bitwise-io-3.py new file mode 100644 index 0000000000..c0675c0b90 --- /dev/null +++ b/Task/Bitwise-IO/Python/bitwise-io-3.py @@ -0,0 +1,10 @@ +#! /usr/bin/env python +import sys +import bitio + +r = bitio.BitReader(sys.stdin) +while True: + x = r.readbits(7) + if ( r.read == 0 ): + break + sys.stdout.write(chr(x)) diff --git a/Task/Bitwise-IO/REXX/bitwise-io.rexx b/Task/Bitwise-IO/REXX/bitwise-io.rexx new file mode 100644 index 0000000000..c11d22610a --- /dev/null +++ b/Task/Bitwise-IO/REXX/bitwise-io.rexx @@ -0,0 +1,26 @@ +/* REXX **************************************************************** +* 01.11.2012 Walter Pachl +***********************************************************************/ +s='STRING' /* Test input */ +Say 's='s +ol='' /* initialize target */ +Do While s<>'' /* loop through input */ + Parse Var s c +1 s /* pick a character */ + cx=c2x(c) /* convert to hex */ + cb=x2b(cx) /* convert to bits */ + ol=ol||substr(cb,2) /* append to target */ + End +l=length(ol) /* current length */ +lm=l//8 +ol=ol||copies('0',8-lm) /* pad to multiple of 8 */ +pd=copies(' ',l)||copies('0',8-lm) +Say 'b='ol /* show target */ +Say ' 'pd 'padding' +r='' /* initialize result */ +Do While length(ol)>6 /* loop through target */ + Parse Var ol b +7 ol /* pick 7 bits */ + b='0'||b /* add a leading '0' */ + x=b2x(b) /* convert to hex */ + r=r||x2c(x) /* convert to character */ + End /* and append to result */ +Say 'r='r /* show result */ diff --git a/Task/Bitwise-IO/Ruby/bitwise-io.rb b/Task/Bitwise-IO/Ruby/bitwise-io.rb new file mode 100644 index 0000000000..7fe2f64781 --- /dev/null +++ b/Task/Bitwise-IO/Ruby/bitwise-io.rb @@ -0,0 +1,35 @@ +def crunch(ascii) + bitstring = ascii.bytes.collect {|b| "%07b" % b}.join + [bitstring].pack("B*") +end + +def expand(binary) + bitstring = binary.unpack("B*")[0] + bitstring.scan(/[01]{7}/).collect {|b| b.to_i(2).chr}.join +end + +original = "This is an ascii string that will be crunched, written, read and expanded." +puts "my ascii string is #{original.length} bytes" + +filename = "crunched.out" + +# write the compressed data +File.open(filename, "w") do |fh| + fh.binmode + fh.print crunch(original) +end + +filesize = File.size(filename) +puts "the file containing the crunched text is #{filesize} bytes" + +# read and expand +expanded = File.open(filename, "r") do |fh| + fh.binmode + expand(fh.read) +end + +if original == expanded + puts "success" +else + puts "fail!" +end diff --git a/Task/Bitwise-IO/Tcl/bitwise-io.tcl b/Task/Bitwise-IO/Tcl/bitwise-io.tcl new file mode 100644 index 0000000000..0ab9dda5a5 --- /dev/null +++ b/Task/Bitwise-IO/Tcl/bitwise-io.tcl @@ -0,0 +1,48 @@ +package require Tcl 8.5 + +proc crunch {ascii} { + binary scan $ascii B* bitstring + # crunch: remove the extraneous leading 0 bit + regsub -all {0(.{7})} $bitstring {\1} 7bitstring + set padded "$7bitstring[string repeat 0 [expr {8 - [string length $7bitstring]%8}]]" + return [binary format B* $padded] +} + +proc expand {binary} { + binary scan $binary B* padded + # expand the 7 bit segments with their leading 0 bit + set bitstring "0[join [regexp -inline -all {.{7}} $padded] 0]" + return [binary format B* $bitstring] +} + +proc crunch_and_write {ascii filename} { + set fh [open $filename w] + fconfigure $fh -translation binary + puts -nonewline $fh [crunch $ascii] + close $fh +} + +proc read_and_expand {filename} { + set fh [open $filename r] + fconfigure $fh -translation binary + set input [read $fh [file size $filename]] + close $fh + return [expand $input] +} + +set original "This is an ascii string that will be crunched, written, read and expanded." +puts "my ascii string is [string length $original] bytes" + +set filename crunched.out +crunch_and_write $original $filename + +set filesize [file size $filename] +puts "the file containing the crunched text is $filesize bytes" + +set expanded [read_and_expand $filename] + +if {$original eq $expanded} { + puts "the expanded string is the same as the original" +} else { + error "not the same" +} diff --git a/Task/Bitwise-operations/0DESCRIPTION b/Task/Bitwise-operations/0DESCRIPTION new file mode 100644 index 0000000000..68465d1ea8 --- /dev/null +++ b/Task/Bitwise-operations/0DESCRIPTION @@ -0,0 +1 @@ +{{basic data operation}}Write a routine to perform a bitwise AND, OR, and XOR on two integers, a bitwise NOT on the first integer, a left shift, right shift, right arithmetic shift, left rotate, and right rotate. All shifts and rotates should be done on the first integer with a shift/rotate amount of the second integer. If any operation is not available in your language, note it. diff --git a/Task/Bitwise-operations/1META.yaml b/Task/Bitwise-operations/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Bitwise-operations/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Bitwise-operations/ACL2/bitwise-operations.acl2 b/Task/Bitwise-operations/ACL2/bitwise-operations.acl2 new file mode 100644 index 0000000000..1aca3eec2a --- /dev/null +++ b/Task/Bitwise-operations/ACL2/bitwise-operations.acl2 @@ -0,0 +1,7 @@ +(defun bitwise (a b) + (list (logand a b) + (logior a b) + (logxor a b) + (lognot a) + (ash a b) + (ash a (- b)))) diff --git a/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg b/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg new file mode 100644 index 0000000000..7fdf9b8d88 --- /dev/null +++ b/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg @@ -0,0 +1,64 @@ +main:( + + PRIO SLC = 8, SRC = 8; # SLC and SRC are not built in, define and overload them here # + OP SLC = (BITS b, INT rotate) BITS: b SHL rotate OR b SHR ( bits width - rotate ); + OP SRC = (BITS b, INT rotate) BITS: b SHR rotate OR b SHL ( bits width - rotate ); + # SRC and SRL are non-standard, but versions are built in to ALGOL 68R's standard prelude # + + PRIO XOR = 2; + OP XOR = (BITS p, q) BITS: p AND NOT q OR NOT p AND q; + # XOR is non-standard, but a version is built in to ALGOL 68G's standard prelude # + + # ALGOL 68 has 5 different ways of representing a BINary BITS - Bases: 2, 4, 8, 16 and flip/flop # + FORMAT b5 = $"2r"2r32d," 4r"4r16d," 8r"8r11d," 16r"16r8d," "gl$; + OP BBBBB = (BITS b)[]BITS: (b,b,b,b,b); + + PROC bitwise = (BITS a, BITS b, INT shift)VOID: + ( + printf(( + $" bits shorths: "gxgl$, bits shorths, "1 plus the number of extra SHORT BITS types", + $" bits lengths: "gxgl$, bits lengths, "1 plus the number of extra LONG BITS types", + $" max bits: "gl$, max bits, + $" long max bits: "gl$, long max bits, + $" long long max bits: "gl$, long long max bits, + $" bits width: "gxgl$, bits width, "The number of CHAR required to display BITS", + $" long bits width: "gxgl$, long bits width, "The number of CHAR required to display LONG BITS", + $" long long bits width: "gxgl$, long long bits width, "The number of CHAR required to display LONG LONG BITS", + $" bytes shorths: "gxgl$, bytes shorths, "1 plus the number of extra SHORT BYTES types", + $" bytes lengths: "gxgl$, bits lengths, "1 plus the number of extra LONG BYTES types", + $" bytes width: "gxgl$, bytes width, "The number of CHAR required to display BYTES", + $" long bytes width: "gxgl$, long bytes width, "The number of CHAR required to display LONG BYTES" + )); + + printf(($" a: "f(b5)$, BBBBB a)); + printf(($" b: "f(b5)$, BBBBB b)); + printf(($" a AND b: "f(b5)$, BBBBB(a AND b))); + printf(($" a OR b: "f(b5)$, BBBBB(a OR b))); + printf(($" a XOR b: "f(b5)$, BBBBB(a XOR b))); + printf(($" NOT b: "f(b5)$, BBBBB NOT a)); + printf(($" a SHL "d": "f(b5)$, shift, BBBBB(a SHL shift))); + printf(($" a SHR "d": "f(b5)$, shift, BBBBB(a SHR shift))); + + printf(($" a SLC "d": "f(b5)$, shift, BBBBB(a SLC shift))); + printf(($" a SRC "d": "f(b5)$, shift, BBBBB(a SRC shift))) +COMMENT with original ALGOL 68 character set; + printf(($" a AND b: "f(b5)$, BBBBB(a ∧ b))); + printf(($" a OR b: "f(b5)$, BBBBB(a ∨ b))); + printf(($" NOT b: "f(b5)$, BBBBB ¬ a)); + printf(($" a SHL "d": "f(b5)$, shift, BBBBB(a ↑ shift))); + printf(($" a SHR "d": "f(b5)$, shift, BBBBB(a ↓ shift))); +Also: + printf(($" a AND b: "f(b5)$, BBBBB(a /\ b))); + printf(($" a OR b: "f(b5)$, BBBBB(a \/ b))); +COMMENT + ); + + bitwise(BIN 255, BIN 170, 5) +# or using alternate representations for 255 and 170 in BITS # +CO + bitwise(2r11111111,2r10101010,5); + bitwise(4r3333,4r2222,5); + bitwise(8r377,8r252,5); + bitwise(16rff,16raa,5) +END CO +) diff --git a/Task/Bitwise-operations/ALGOL-68/bitwise-operations-2.alg b/Task/Bitwise-operations/ALGOL-68/bitwise-operations-2.alg new file mode 100644 index 0000000000..9f17ce40f0 --- /dev/null +++ b/Task/Bitwise-operations/ALGOL-68/bitwise-operations-2.alg @@ -0,0 +1,13 @@ +# unpack (widen) some data back into an a BOOL array # +INT i := 170; +BITS j := BIN i; +[bits width]BOOL k := j; + +printf(($g", 8r"8r4d", "8(g)l$, i, j, k[bits width-8+1:])); + +# now pack some data back into an INT # +k[bits width-8+1:] := (FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE); +j := bits pack(k); +i := ABS j; + +printf(($g", 8r"8r4d", "8(g)l$, i, j, k[bits width-8+1:])) diff --git a/Task/Bitwise-operations/AWK/bitwise-operations.awk b/Task/Bitwise-operations/AWK/bitwise-operations.awk new file mode 100644 index 0000000000..0a92a1e294 --- /dev/null +++ b/Task/Bitwise-operations/AWK/bitwise-operations.awk @@ -0,0 +1,10 @@ +BEGIN { + n = 11 + p = 1 + print n " or " p " = " or(n,p) + print n " and " p " = " and(n,p) + print n " xor " p " = " xor(n,p) + print n " << " p " = " lshift(n, p) # left shift + print n " >> " p " = " rshift(n, p) # right shift + printf "not %d = 0x%x\n", n, compl(n) # bitwise complement +} diff --git a/Task/Bitwise-operations/ActionScript/bitwise-operations.as b/Task/Bitwise-operations/ActionScript/bitwise-operations.as new file mode 100644 index 0000000000..da55f338ca --- /dev/null +++ b/Task/Bitwise-operations/ActionScript/bitwise-operations.as @@ -0,0 +1,10 @@ +function bitwise(a:int, b:int):void +{ + trace("And: ", a & b); + trace("Or: ", a | b); + trace("Xor: ", a ^ b); + trace("Not: ", ~a); + trace("Left Shift: ", a << b); + trace("Right Shift(Arithmetic): ", a >> b); + trace("Right Shift(Logical): ", a >>> b); +} diff --git a/Task/Bitwise-operations/Ada/bitwise-operations.ada b/Task/Bitwise-operations/Ada/bitwise-operations.ada new file mode 100644 index 0000000000..234963a93c --- /dev/null +++ b/Task/Bitwise-operations/Ada/bitwise-operations.ada @@ -0,0 +1,24 @@ +with Ada.Text_Io; use Ada.Text_Io; +with Interfaces; use Interfaces; + + procedure Bitwise is + subtype Byte is Unsigned_8; + package Byte_Io is new Ada.Text_Io.Modular_Io(Byte); + + A : Byte := 255; + B : Byte := 170; + X : Byte := 128; + N : Natural := 1; + + begin + Put_Line("A and B = "); Byte_Io.Put(Item => A and B, Base => 2); + Put_Line("A or B = "); Byte_IO.Put(Item => A or B, Base => 2); + Put_Line("A xor B = "); Byte_Io.Put(Item => A xor B, Base => 2); + Put_Line("Not A = "); Byte_IO.Put(Item => not A, Base => 2); + New_Line(2); + Put_Line(Unsigned_8'Image(Shift_Left(X, N))); -- Left shift + Put_Line(Unsigned_8'Image(Shift_Right(X, N))); -- Right shift + Put_Line(Unsigned_8'Image(Shift_Right_Arithmetic(X, N))); -- Right Shift Arithmetic + Put_Line(Unsigned_8'Image(Rotate_Left(X, N))); -- Left rotate + Put_Line(Unsigned_8'Image(Rotate_Right(X, N))); -- Right rotate + end bitwise; diff --git a/Task/Bitwise-operations/Aikido/bitwise-operations.aikido b/Task/Bitwise-operations/Aikido/bitwise-operations.aikido new file mode 100644 index 0000000000..d1469e894a --- /dev/null +++ b/Task/Bitwise-operations/Aikido/bitwise-operations.aikido @@ -0,0 +1,9 @@ +function bitwise(a, b){ + println("a AND b: " + (a & b)) + println("a OR b: "+ (a | b)) + println("a XOR b: "+ (a ^ b)) + println("NOT a: " + ~a) + println("a << b: " + (a << b)) // left shift + println("a >> b: " + (a >> b)) // arithmetic right shift + println("a >>> b: " + (a >>> b)) // logical right shift +} diff --git a/Task/Bitwise-operations/AutoHotkey/bitwise-operations.ahk b/Task/Bitwise-operations/AutoHotkey/bitwise-operations.ahk new file mode 100644 index 0000000000..3250eab2e6 --- /dev/null +++ b/Task/Bitwise-operations/AutoHotkey/bitwise-operations.ahk @@ -0,0 +1,10 @@ +bitwise(3, 4) +bitwise(a, b) +{ + MsgBox % "a and b: " . a & b + MsgBox % "a or b: " . a | b + MsgBox % "a xor b: " . a ^ b + MsgBox % "not a: " . ~a ; treated as unsigned integer + MsgBox % "a << b: " . a << b ; left shift + MsgBox % "a >> b: " . a >> b ; arithmetic right shift +} diff --git a/Task/Bitwise-operations/BASIC/bitwise-operations-1.bas b/Task/Bitwise-operations/BASIC/bitwise-operations-1.bas new file mode 100644 index 0000000000..570751a295 --- /dev/null +++ b/Task/Bitwise-operations/BASIC/bitwise-operations-1.bas @@ -0,0 +1,6 @@ +SUB bitwise (a, b) + PRINT a AND b + PRINT a OR b + PRINT a XOR b + PRINT NOT a +END SUB diff --git a/Task/Bitwise-operations/BASIC/bitwise-operations-2.bas b/Task/Bitwise-operations/BASIC/bitwise-operations-2.bas new file mode 100644 index 0000000000..439e69c500 --- /dev/null +++ b/Task/Bitwise-operations/BASIC/bitwise-operations-2.bas @@ -0,0 +1,12 @@ +SUB bitwise (a AS Integer, b AS Integer) + DIM u AS UInteger + + PRINT "a AND b = "; a AND b + PRINT "a OR b = "; a OR b + PRINT "a XOR b = "; a XOR b + PRINT "NOT a = "; NOT a + PRINT "a SHL b = "; a SHL b + PRINT "a SHR b (arithmetic) = "; a SHR b + u = a + PRINT "a SHR b (logical) = "; u SHR b +END SUB diff --git a/Task/Bitwise-operations/BASIC256/bitwise-operations.basic256 b/Task/Bitwise-operations/BASIC256/bitwise-operations.basic256 new file mode 100644 index 0000000000..c270bfcc40 --- /dev/null +++ b/Task/Bitwise-operations/BASIC256/bitwise-operations.basic256 @@ -0,0 +1,8 @@ +# bitwise operators - floating point numbers will be cast to integer +a = 0b00010001 +b = 0b11110000 +print a +print int(a * 2) # right shift (multiply by 2) +print a \ 2 # left shift (integer divide by 2) +print a | b # bitwise or on two integer values +print a & b # bitwise or on two integer values diff --git a/Task/Bitwise-operations/BBC-BASIC/bitwise-operations.bbc b/Task/Bitwise-operations/BBC-BASIC/bitwise-operations.bbc new file mode 100644 index 0000000000..94e47491aa --- /dev/null +++ b/Task/Bitwise-operations/BBC-BASIC/bitwise-operations.bbc @@ -0,0 +1,12 @@ + number1% = &89ABCDEF + number2% = 8 + + PRINT ~ number1% AND number2% : REM bitwise AND + PRINT ~ number1% OR number2% : REM bitwise OR + PRINT ~ number1% EOR number2% : REM bitwise exclusive-OR + PRINT ~ NOT number1% : REM bitwise NOT + PRINT ~ number1% << number2% : REM left shift + PRINT ~ number1% >>> number2% : REM right shift (logical) + PRINT ~ number1% >> number2% : REM right shift (arithmetic) + PRINT ~ (number1% << number2%) OR (number1% >>> (32-number2%)) : REM left rotate + PRINT ~ (number1% >>> number2%) OR (number1% << (32-number2%)) : REM right rotate diff --git a/Task/Bitwise-operations/Batch-File/bitwise-operations.bat b/Task/Bitwise-operations/Batch-File/bitwise-operations.bat new file mode 100644 index 0000000000..39cbe90480 --- /dev/null +++ b/Task/Bitwise-operations/Batch-File/bitwise-operations.bat @@ -0,0 +1,73 @@ +@echo off +setlocal +set /a "a=%~1, b=%~2" +call :num2bin %a% aStr +call :num2bin %b% bStr + +::AND +set /a "val=a&b" +call :display "%a% AND %b%" %val% %aStr% %bStr% + +::OR +set /a "val=a|b" +call :display "%a% OR %b%" %val% %aStr% %bStr% + +::XOR +set /a "val=a^b" +call :display "%a% XOR %b%" %val% %aStr% %bStr% + +::NOT +set /a "val=~a" +call :display "NOT %a%" %val% %aStr% + +::LEFT SHIFT +set /a "val=a<>b" +call :display "%a% Arithmetic Right Shift %b%" %val% %aStr% + +::The remaining operations do not have native support +::The implementations use additional operators +:: %% = mod +:: ! = logical negation where !(zero)=1 and !(non-zero)=0 +:: * = multiplication +:: - = subtraction + +::LOGICAL RIGHT SHIFT (No native support) +set /a "val=(a>>b)&~((0x80000000>>b-1)*!!b)" +call :display "%a% Logical Right Shift %b%" %val% %aStr% + +::ROTATE LEFT (No native support) +set /a "val=(a<>32-b%%32)&~((0x80000000>>31-b%%32)*!!(32-b%%32))" +call :display "%a% Rotate Left %b%" %val% %aStr% + +::ROTATE RIGHT (No native support) +set /a "val=(a<<32-b%%32) | (a>>b%%32)&~((0x80000000>>b%%32-1)*!!(b%%32)) " +call :display "%a% Rotate Right %b%" %val% %aStr% + +exit /b + + +:display op result aStr [bStr] +echo( +echo %~1 = %2 +echo %3 +if "%4" neq "" echo %4 +call :num2bin %2 +exit /b + + +:num2bin IntVal [RtnVar] + setlocal enableDelayedExpansion + set n=%~1 + set rtn= + for /l %%b in (0,1,31) do ( + set /a "d=n&1, n>>=1" + set rtn=!d!!rtn! + ) + (endlocal & rem -- return values + if "%~2" neq "" (set %~2=%rtn%) else echo %rtn% + ) +exit /b diff --git a/Task/Bitwise-operations/C/bitwise-operations-1.c b/Task/Bitwise-operations/C/bitwise-operations-1.c new file mode 100644 index 0000000000..664aaf03b5 --- /dev/null +++ b/Task/Bitwise-operations/C/bitwise-operations-1.c @@ -0,0 +1,14 @@ +void bitwise(int a, int b) +{ + printf("a and b: %d\n", a & b); + printf("a or b: %d\n", a | b); + printf("a xor b: %d\n", a ^ b); + printf("not a: %d\n", ~a); + printf("a << n: %d\n", a << b); /* left shift */ + printf("a >> n: %d\n", a >> b); /* on most platforms: arithmetic right shift */ + /* convert the signed integer into unsigned, so it will perform logical shift */ + unsigned int c = a; + printf("c >> b: %d\n", c >> b); /* logical right shift */ + /* there are no rotation operators in C */ + return 0; +} diff --git a/Task/Bitwise-operations/C/bitwise-operations-2.c b/Task/Bitwise-operations/C/bitwise-operations-2.c new file mode 100644 index 0000000000..9087b538f2 --- /dev/null +++ b/Task/Bitwise-operations/C/bitwise-operations-2.c @@ -0,0 +1,5 @@ +/* rotate x to the right by s bits */ +unsigned int rotr(unsigned int x, unsigned int s) +{ + return (x >> s) | (x << 32 - s); +} diff --git a/Task/Bitwise-operations/C/bitwise-operations-3.c b/Task/Bitwise-operations/C/bitwise-operations-3.c new file mode 100644 index 0000000000..49f7c43a5a --- /dev/null +++ b/Task/Bitwise-operations/C/bitwise-operations-3.c @@ -0,0 +1,5 @@ +rotr: + movl 4(%esp), %eax ; arg1: x + movl 8(%esp), %ecx ; arg2: s + rorl %cl, %eax ; right rotate x by s + ret diff --git a/Task/Bitwise-operations/Clojure/bitwise-operations.clj b/Task/Bitwise-operations/Clojure/bitwise-operations.clj new file mode 100644 index 0000000000..2e26388d4d --- /dev/null +++ b/Task/Bitwise-operations/Clojure/bitwise-operations.clj @@ -0,0 +1,7 @@ +(bit-and x y) +(bit-or x y) +(bit-xor x y) +(bit-not x) +(bit-shift-left x n) +(bit-shift-right x n) +;;There is no built-in for rotation. diff --git a/Task/Bitwise-operations/CoffeeScript/bitwise-operations-1.coffee b/Task/Bitwise-operations/CoffeeScript/bitwise-operations-1.coffee new file mode 100644 index 0000000000..b282be13a9 --- /dev/null +++ b/Task/Bitwise-operations/CoffeeScript/bitwise-operations-1.coffee @@ -0,0 +1,12 @@ +f = (a, b) -> + p "and", a & b + p "or", a | b + p "xor", a ^ b + p "not", ~a + p "<<", a << b + p ">>", a >> b + # no rotation shifts that I know of + +p = (label, n) -> console.log label, n + +f(10,2) diff --git a/Task/Bitwise-operations/CoffeeScript/bitwise-operations-2.coffee b/Task/Bitwise-operations/CoffeeScript/bitwise-operations-2.coffee new file mode 100644 index 0000000000..0fc8876869 --- /dev/null +++ b/Task/Bitwise-operations/CoffeeScript/bitwise-operations-2.coffee @@ -0,0 +1,7 @@ +> coffee foo.coffee +and 2 +or 10 +xor 8 +not -11 +<< 40 +>> 2 diff --git a/Task/Bitwise-operations/Erlang/bitwise-operations-1.erl b/Task/Bitwise-operations/Erlang/bitwise-operations-1.erl new file mode 100644 index 0000000000..cf7a896b2f --- /dev/null +++ b/Task/Bitwise-operations/Erlang/bitwise-operations-1.erl @@ -0,0 +1,13 @@ +-module(bitwise_operations). + +-export([test/0]). + +test() -> + A = 255, + B = 170, + io:format("~p band ~p = ~p\n",[A,B,A band B]), + io:format("~p bor ~p = ~p\n",[A,B,A bor B]), + io:format("~p bxor ~p = ~p\n",[A,B,A bxor B]), + io:format("not ~p = ~p\n",[A,bnot A]), + io:format("~p bsl ~p = ~p\n",[A,B,A bsl B]), + io:format("~p bsr ~p = ~p\n",[A,B,A bsr B]). diff --git a/Task/Bitwise-operations/Erlang/bitwise-operations-2.erl b/Task/Bitwise-operations/Erlang/bitwise-operations-2.erl new file mode 100644 index 0000000000..02684b7b84 --- /dev/null +++ b/Task/Bitwise-operations/Erlang/bitwise-operations-2.erl @@ -0,0 +1,6 @@ +255 band 170 = 170 +255 bor 170 = 255 +255 bxor 170 = 85 +not 255 = -256 +255 bsl 170 = 381627307539845370001346183518875822092557105621893120 +255 bsr 170 = 0 diff --git a/Task/Bitwise-operations/Forth/bitwise-operations.fth b/Task/Bitwise-operations/Forth/bitwise-operations.fth new file mode 100644 index 0000000000..682df1dc64 --- /dev/null +++ b/Task/Bitwise-operations/Forth/bitwise-operations.fth @@ -0,0 +1,11 @@ +: arshift 0 ?do 2/ loop ; \ 2/ is an arithmetic shift right by one bit (2* shifts left one bit) +: bitwise ( a b -- ) + cr ." a = " over . ." b = " dup . + cr ." a and b = " 2dup and . + cr ." a or b = " 2dup or . + cr ." a xor b = " 2dup xor . + cr ." not a = " over invert . + cr ." a shl b = " 2dup lshift . + cr ." a shr b = " 2dup rshift . + cr ." a ashr b = " 2dup arshift . + 2drop ; diff --git a/Task/Bitwise-operations/Fortran/bitwise-operations-1.f b/Task/Bitwise-operations/Fortran/bitwise-operations-1.f new file mode 100644 index 0000000000..b33d23ac19 --- /dev/null +++ b/Task/Bitwise-operations/Fortran/bitwise-operations-1.f @@ -0,0 +1,27 @@ +integer :: i, j = -1, k = 42 +logical :: a + +i = bit_size(j) ! returns the number of bits in the given INTEGER variable + +! bitwise boolean operations on integers +i = iand(k, j) ! returns bitwise AND of K and J +i = ior(k, j) ! returns bitwise OR of K and J +i = ieor(k, j) ! returns bitwise EXCLUSIVE OR of K and J +i = not(j) ! returns bitwise NOT of J + +! single-bit integer/logical operations (bit positions are zero-based) +a = btest(i, 4) ! returns logical .TRUE. if bit position 4 of I is 1, .FALSE. if 0 +i = ibclr(k, 8) ! returns value of K with 8th bit position "cleared" (set to 0) +i = ibset(k, 13) ! returns value of K with 13th bit position "set" (set to 1) + +! multi-bit integer operations +i = ishft(k, j) ! returns value of K shifted by J bit positions, with ZERO fill + ! (right shift if J < 0 and left shift if J > 0). +i = ishftc(k, j) ! returns value of K shifted CIRCULARLY by J bit positions + ! (right circular shift if J < 0 and left if J > 0) +i = ishftc(k, j, 20) ! returns value as before except that ONLY the 20 lowest order + ! (rightmost) bits are circularly shifted +i = ibits(k, 7, 8) ! extracts 8 contiguous bits from K starting at position 7 and + ! returns them as the rightmost bits of an otherwise + ! zero-filled integer. For non-negative K this is + ! arithmetically equivalent to: MOD((K / 2**7), 2**8) diff --git a/Task/Bitwise-operations/Fortran/bitwise-operations-2.f b/Task/Bitwise-operations/Fortran/bitwise-operations-2.f new file mode 100644 index 0000000000..74dbd6f5e8 --- /dev/null +++ b/Task/Bitwise-operations/Fortran/bitwise-operations-2.f @@ -0,0 +1 @@ + call mvbits(k, 2, 4, j, 0) ! copy a sequence of 4 bits from k starting at bit 2 into j starting at bit 0 diff --git a/Task/Bitwise-operations/Go/bitwise-operations.go b/Task/Bitwise-operations/Go/bitwise-operations.go new file mode 100644 index 0000000000..343a41caa4 --- /dev/null +++ b/Task/Bitwise-operations/Go/bitwise-operations.go @@ -0,0 +1,45 @@ +package main + +import "fmt" + +func bitwise(a, b int16) (and, or, xor, not, shl, shr, ras, rol, ror int16) { + // the first four are easy + and = a & b + or = a | b + xor = a ^ b + not = ^a + + // for all shifts, the right operand (shift distance) must be unsigned. + // use abs(b) for a non-negative value. + if b < 0 { + b = -b + } + ub := uint(b) + + shl = a << ub + // for right shifts, if the left operand is unsigned, Go performs + // a logical shift; if signed, an arithmetic shift. + shr = int16(uint16(a) >> ub) + ras = a >> ub + + // rotates + rol = a << ub | int16(uint16(a) >> (16-ub)) + ror = int16(uint16(a) >> ub) | a << (16-ub) + return +} + +func main() { + var a, b int16 = -460, 6 + and, or, xor, not, shl, shr, ras, rol, ror := bitwise(a, b) + fmt.Printf("a: %016b\n", uint16(a)) + fmt.Printf("b: %016b\n", uint16(b)) + fmt.Printf("and: %016b\n", uint16(and)) + fmt.Printf("or: %016b\n", uint16(or)) + fmt.Printf("xor: %016b\n", uint16(xor)) + fmt.Printf("not: %016b\n", uint16(not)) + fmt.Printf("shl: %016b\n", uint16(shl)) + fmt.Printf("shr: %016b\n", uint16(shr)) + fmt.Printf("ras: %016b\n", uint16(ras)) + fmt.Printf("rol: %016b\n", uint16(rol)) + fmt.Printf("ror: %016b\n", uint16(ror)) +} diff --git a/Task/Bitwise-operations/Haskell/bitwise-operations.hs b/Task/Bitwise-operations/Haskell/bitwise-operations.hs new file mode 100644 index 0000000000..3e0939f3f3 --- /dev/null +++ b/Task/Bitwise-operations/Haskell/bitwise-operations.hs @@ -0,0 +1,18 @@ +import Data.Bits + +bitwise :: Int -> Int -> IO () +bitwise a b = do + print $ a .&. b + print $ a .|. b + print $ a `xor` b + print $ complement a + print $ shiftL a b -- left shift + print $ shiftR a b -- arithmetic right shift + print $ shift a b -- You can also use the "unified" shift function; positive is for left shift, negative is for right shift + print $ shift a (-b) + print $ rotateL a b -- rotate left + print $ rotateR a b -- rotate right + print $ rotate a b -- You can also use the "unified" rotate function; positive is for left rotate, negative is for right rotate + print $ rotate a (-b) + +main = bitwise 255 170 diff --git a/Task/Bitwise-operations/Java/bitwise-operations-1.java b/Task/Bitwise-operations/Java/bitwise-operations-1.java new file mode 100644 index 0000000000..dafad1ee1f --- /dev/null +++ b/Task/Bitwise-operations/Java/bitwise-operations-1.java @@ -0,0 +1,11 @@ +public static void bitwise(int a, int b){ + System.out.println("a AND b: " + (a & b)); + System.out.println("a OR b: "+ (a | b)); + System.out.println("a XOR b: "+ (a ^ b)); + System.out.println("NOT a: " + ~a); + System.out.println("a << b: " + (a << b)); // left shift + System.out.println("a >> b: " + (a >> b)); // arithmetic right shift + System.out.println("a >>> b: " + (a >>> b)); // logical right shift + System.out.println("a rol b: " + Integer.rotateLeft(a, b)); //rotate left, Java 1.5+ + System.out.println("a ror b: " + Integer.rotateRight(a, b)); //rotate right, Java 1.5+ +} diff --git a/Task/Bitwise-operations/Java/bitwise-operations-2.java b/Task/Bitwise-operations/Java/bitwise-operations-2.java new file mode 100644 index 0000000000..92a8240e56 --- /dev/null +++ b/Task/Bitwise-operations/Java/bitwise-operations-2.java @@ -0,0 +1,4 @@ +a <<= 3; +a = a << 3; +a *= 8; //2 * 2 * 2 = 8 +a = a * 8; diff --git a/Task/Bitwise-operations/JavaScript/bitwise-operations.js b/Task/Bitwise-operations/JavaScript/bitwise-operations.js new file mode 100644 index 0000000000..b94f1e718b --- /dev/null +++ b/Task/Bitwise-operations/JavaScript/bitwise-operations.js @@ -0,0 +1,9 @@ +function bitwise(a, b){ + alert("a AND b: " + (a & b)); + alert("a OR b: "+ (a | b)); + alert("a XOR b: "+ (a ^ b)); + alert("NOT a: " + ~a); + alert("a << b: " + (a << b)); // left shift + alert("a >> b: " + (a >> b)); // arithmetic right shift + alert("a >>> b: " + (a >>> b)); // logical right shift +} diff --git a/Task/Bitwise-operations/Lua/bitwise-operations.lua b/Task/Bitwise-operations/Lua/bitwise-operations.lua new file mode 100644 index 0000000000..018db4d1eb --- /dev/null +++ b/Task/Bitwise-operations/Lua/bitwise-operations.lua @@ -0,0 +1,65 @@ +local bit = require"bit" + +local vb = { + 0, 1, -1, 2, -2, 0x12345678, 0x87654321, + 0x33333333, 0x77777777, 0x55aa55aa, 0xaa55aa55, + 0x7fffffff, 0x80000000, 0xffffffff +} + +local function cksum(name, s, r) + local z = 0 + for i=1,#s do z = (z + string.byte(s, i)*i) % 2147483629 end + if z ~= r then + error("bit."..name.." test failed (got "..z..", expected "..r..")", 0) + end +end + +local function check_unop(name, r) + local f = bit[name] + local s = "" + if pcall(f) or pcall(f, "z") or pcall(f, true) then + error("bit."..name.." fails to detect argument errors", 0) + end + for _,x in ipairs(vb) do s = s..","..tostring(f(x)) end + cksum(name, s, r) +end + +local function check_binop(name, r) + local f = bit[name] + local s = "" + if pcall(f) or pcall(f, "z") or pcall(f, true) then + error("bit."..name.." fails to detect argument errors", 0) + end + for _,x in ipairs(vb) do + for _,y in ipairs(vb) do s = s..","..tostring(f(x, y)) end + end + cksum(name, s, r) +end + +local function check_binop_range(name, r, yb, ye) + local f = bit[name] + local s = "" + if pcall(f) or pcall(f, "z") or pcall(f, true) or pcall(f, 1, true) then + error("bit."..name.." fails to detect argument errors", 0) + end + for _,x in ipairs(vb) do + for y=yb,ye do s = s..","..tostring(f(x, y)) end + end + cksum(name, s, r) +end + +local function check_shift(name, r) + check_binop_range(name, r, 0, 31) +end + +-- Minimal sanity checks. +assert(0x7fffffff == 2147483647, "broken hex literals") +assert(0xffffffff == -1 or 0xffffffff == 2^32-1, "broken hex literals") +assert(tostring(-1) == "-1", "broken tostring()") +assert(tostring(0xffffffff) == "-1" or tostring(0xffffffff) == "4294967295", "broken tostring()") + +-- Basic argument processing. +assert(bit.tobit(1) == 1) +assert(bit.band(1) == 1) +assert(bit.bxor(1,2) == 3) +assert(bit.bor(1,2,4,8,16,32,64,128) == 255) diff --git a/Task/Bitwise-operations/MATLAB/bitwise-operations-1.m b/Task/Bitwise-operations/MATLAB/bitwise-operations-1.m new file mode 100644 index 0000000000..74a8a9be2b --- /dev/null +++ b/Task/Bitwise-operations/MATLAB/bitwise-operations-1.m @@ -0,0 +1,9 @@ +function bitwiseOps(a,b) + + disp(sprintf('%d and %d = %d', [a b bitand(a,b)])); + disp(sprintf('%d or %d = %d', [a b bitor(a,b)])); + disp(sprintf('%d xor %d = %d', [a b bitxor(a,b)])); + disp(sprintf('%d << %d = %d', [a b bitshift(a,b)])); + disp(sprintf('%d >> %d = %d', [a b bitshift(a,-b)])); + +end diff --git a/Task/Bitwise-operations/MATLAB/bitwise-operations-2.m b/Task/Bitwise-operations/MATLAB/bitwise-operations-2.m new file mode 100644 index 0000000000..a6e7ef123e --- /dev/null +++ b/Task/Bitwise-operations/MATLAB/bitwise-operations-2.m @@ -0,0 +1,6 @@ +>> bitwiseOps(255,2) +255 and 2 = 2 +255 or 2 = 255 +255 xor 2 = 253 +255 << 2 = 1020 +255 >> 2 = 63 diff --git a/Task/Bitwise-operations/PHP/bitwise-operations.php b/Task/Bitwise-operations/PHP/bitwise-operations.php new file mode 100644 index 0000000000..58bbadb916 --- /dev/null +++ b/Task/Bitwise-operations/PHP/bitwise-operations.php @@ -0,0 +1,9 @@ +function bitwise($a, $b) +{ + echo '$a AND $b: ', $a & $b, "\n"; + echo '$a OR $b: ', $a | $b, "\n"; + echo '$a XOR $b: ', $a ^ $b, "\n"; + echo 'NOT $a: ', ~$a, "\n"; + echo '$a << $b: ', $a << $b, "\n"; // left shift + echo '$a >> $b: ', $a >> $b, "\n"; // arithmetic right shift +} diff --git a/Task/Bitwise-operations/Perl/bitwise-operations.pl b/Task/Bitwise-operations/Perl/bitwise-operations.pl new file mode 100644 index 0000000000..449a4327f8 --- /dev/null +++ b/Task/Bitwise-operations/Perl/bitwise-operations.pl @@ -0,0 +1,15 @@ +use integer; + +sub bitwise($$) { + ($a, $b) = @_; + print 'a and b: '. ($a & $b) ."\n"; + print 'a or b: '. ($a | $b) ."\n"; + print 'a xor b: '. ($a ^ $b) ."\n"; + print 'not a: '. (~$a) ."\n"; + print 'a >> b: ', $a >> $b, "\n"; # logical right shift + + use integer; # "use integer" enables bitwise operations to return signed ints + print "after use integer:\n"; + print 'a << b: ', $a << $b, "\n"; # left shift + print 'a >> b: ', $a >> $b, "\n"; # arithmetic right shift +} diff --git a/Task/Bitwise-operations/PicoLisp/bitwise-operations-1.l b/Task/Bitwise-operations/PicoLisp/bitwise-operations-1.l new file mode 100644 index 0000000000..22629a2951 --- /dev/null +++ b/Task/Bitwise-operations/PicoLisp/bitwise-operations-1.l @@ -0,0 +1,5 @@ +: (& 6 3) +-> 2 + +: (& 7 3 1) +-> 1 diff --git a/Task/Bitwise-operations/PicoLisp/bitwise-operations-2.l b/Task/Bitwise-operations/PicoLisp/bitwise-operations-2.l new file mode 100644 index 0000000000..e410540ba8 --- /dev/null +++ b/Task/Bitwise-operations/PicoLisp/bitwise-operations-2.l @@ -0,0 +1,8 @@ +: (bit? 1 2) +-> NIL + +: (bit? 6 3) +-> NIL + +: (bit? 6 15 255) +-> 6 diff --git a/Task/Bitwise-operations/PicoLisp/bitwise-operations-3.l b/Task/Bitwise-operations/PicoLisp/bitwise-operations-3.l new file mode 100644 index 0000000000..d2c1115e72 --- /dev/null +++ b/Task/Bitwise-operations/PicoLisp/bitwise-operations-3.l @@ -0,0 +1,5 @@ +: (| 1 2) +-> 3 + +: (| 1 2 4 8) +-> 15 diff --git a/Task/Bitwise-operations/PicoLisp/bitwise-operations-4.l b/Task/Bitwise-operations/PicoLisp/bitwise-operations-4.l new file mode 100644 index 0000000000..a0d955783e --- /dev/null +++ b/Task/Bitwise-operations/PicoLisp/bitwise-operations-4.l @@ -0,0 +1,5 @@ +: (x| 2 7) +-> 5 + +: (x| 2 7 1) +-> 4 diff --git a/Task/Bitwise-operations/PicoLisp/bitwise-operations-5.l b/Task/Bitwise-operations/PicoLisp/bitwise-operations-5.l new file mode 100644 index 0000000000..d9d0860ea2 --- /dev/null +++ b/Task/Bitwise-operations/PicoLisp/bitwise-operations-5.l @@ -0,0 +1,11 @@ +: (>> 1 8) +-> 4 + +: (>> 3 16) +-> 2 + +: (>> -3 16) +-> 128 + +: (>> -1 -16) +-> -32 diff --git a/Task/Bitwise-operations/Python/bitwise-operations-1.py b/Task/Bitwise-operations/Python/bitwise-operations-1.py new file mode 100644 index 0000000000..0a98cf4f75 --- /dev/null +++ b/Task/Bitwise-operations/Python/bitwise-operations-1.py @@ -0,0 +1,7 @@ +def bitwise(a, b): + print 'a and b:', a & b + print 'a or b:', a | b + print 'a xor b:', a ^ b + print 'not a:', ~a + print 'a << b:', a << b # left shift + print 'a >> b:', a >> b # arithmetic right shift diff --git a/Task/Bitwise-operations/Python/bitwise-operations-2.py b/Task/Bitwise-operations/Python/bitwise-operations-2.py new file mode 100644 index 0000000000..bef5ed1549 --- /dev/null +++ b/Task/Bitwise-operations/Python/bitwise-operations-2.py @@ -0,0 +1,8 @@ +# 8-bit bounded shift: +x = x << n & 0xff +# ditto for 16 bit: +x = x << n & 0xffff +# ... and 32-bit: +x = x << n & 0xffffffff +# ... and 64-bit: +x = x << n & 0xffffffffffffffff diff --git a/Task/Bitwise-operations/Python/bitwise-operations-3.py b/Task/Bitwise-operations/Python/bitwise-operations-3.py new file mode 100644 index 0000000000..3e36249c2a --- /dev/null +++ b/Task/Bitwise-operations/Python/bitwise-operations-3.py @@ -0,0 +1,41 @@ +def bitstr(n, width=None): + """return the binary representation of n as a string and + optionally zero-fill (pad) it to a given length + """ + result = list() + while n: + result.append(str(n%2)) + n = int(n/2) + if (width is not None) and len(result) < width: + result.extend(['0'] * (width - len(result))) + result.reverse() + return ''.join(result) + +def mask(n): + """Return a bitmask of length n (suitable for masking against an + int to coerce the size to a given length) + """ + if n >= 0: + return 2**n - 1 + else: + return 0 + +def rol(n, rotations=1, width=8): + """Return a given number of bitwise left rotations of an integer n, + for a given bit field width. + """ + rotations %= width + if rotations < 1: + return n + n &= mask(width) ## Should it be an error to truncate here? + return ((n << rotations) & mask(width)) | (n >> (width - rotations)) + +def ror(n, rotations=1, width=8): + """Return a given number of bitwise right rotations of an integer n, + for a given bit field width. + """ + rotations %= width + if rotations < 1: + return n + n &= mask(width) + return (n >> rotations) | ((n << (width - rotations)) & mask(width)) diff --git a/Task/Bitwise-operations/R/bitwise-operations-1.r b/Task/Bitwise-operations/R/bitwise-operations-1.r new file mode 100644 index 0000000000..c06010d175 --- /dev/null +++ b/Task/Bitwise-operations/R/bitwise-operations-1.r @@ -0,0 +1,5 @@ +a <- as.hexmode(35) +b <- as.hexmode(42) +as.integer(a & b) # 34 +as.integer(a | b) # 43 +as.integer(xor(a, b)) # 9 diff --git a/Task/Bitwise-operations/R/bitwise-operations-2.r b/Task/Bitwise-operations/R/bitwise-operations-2.r new file mode 100644 index 0000000000..d12f4fa24e --- /dev/null +++ b/Task/Bitwise-operations/R/bitwise-operations-2.r @@ -0,0 +1,13 @@ +intToLogicalBits <- function(intx) as.logical(intToBits(intx)) +logicalBitsToInt <- function(lb) as.integer(sum((2^(0:31))[lb])) +"%AND%" <- function(x, y) +{ + logicalBitsToInt(intToLogicalBits(x) & intToLogicalBits(y)) +} +"%OR%" <- function(x, y) +{ + logicalBitsToInt(intToLogicalBits(x) | intToLogicalBits(y)) +} + +35 %AND% 42 # 34 +35 %OR% 42 # 42 diff --git a/Task/Bitwise-operations/R/bitwise-operations-3.r b/Task/Bitwise-operations/R/bitwise-operations-3.r new file mode 100644 index 0000000000..ff6227fa41 --- /dev/null +++ b/Task/Bitwise-operations/R/bitwise-operations-3.r @@ -0,0 +1,8 @@ +library(bitops) +bitAnd(35, 42) # 34 +bitOr(35, 42) # 43 +bitXor(35, 42) # 9 +bitFlip(35, bitWidth=8) # 220 +bitShiftL(35, 1) # 70 +bitShiftR(35, 1) # 17 +# Note that no bit rotation is provided in this package diff --git a/Task/Bitwise-operations/R/bitwise-operations-4.r b/Task/Bitwise-operations/R/bitwise-operations-4.r new file mode 100644 index 0000000000..fa339f8c4a --- /dev/null +++ b/Task/Bitwise-operations/R/bitwise-operations-4.r @@ -0,0 +1,14 @@ +# As one can see from +getDLLRegisteredRoutines(getLoadedDLLs()$base) +# R knows functions bitwiseAnd, bitwiseOr, bitwiseXor and bitwiseNot. +# Here is how to call them (see ?.Call for the calling mechanism): + +.Call("bitwiseOr", as.integer(12), as.integer(10)) +.Call("bitwiseXor", as.integer(12), as.integer(10)) +.Call("bitwiseAnd", as.integer(12), as.integer(10)) +.Call("bitwiseNot", as.integer(12)) + +# It would be easy to embed these calls in R functions, for better readability +# Also, it's possible to call these functions on integer vectors: + +.Call("bitwiseOr", c(5L, 2L), c(3L, 8L)) diff --git a/Task/Bitwise-operations/REXX/bitwise-operations.rexx b/Task/Bitwise-operations/REXX/bitwise-operations.rexx new file mode 100644 index 0000000000..5590015605 --- /dev/null +++ b/Task/Bitwise-operations/REXX/bitwise-operations.rexx @@ -0,0 +1,35 @@ +/*REXX program performs bitwise operations on integers: & | && ¬ «L »R */ +numeric digits 1000 /*be able to handle bit integers.*/ + +say center('decimal',9) center("value",9) center('bits',50) +say copies('─',9) copies('─',9) copies('─',50) + +a = 21 ; call show a , 'A' /* show & tell A */ +b = 3 ; call show b , 'B' /* show & tell B */ + + call show bAnd(a,b) , 'A & B' /* and */ + call show bOr( a,b) , 'A | B' /* or */ + call show bXOr(a,b) , 'A && B' /* xor */ + call show bNot(a) , '¬ A' /* not */ + call show bShiftL(a,b) , 'A [«B]' /* shift left */ + call show bShiftR(a,b) , 'A [»B]' /* shirt right */ + + /*┌───────────────────────────────────────────────────────────────┐ + │ Since REXX stores numbers (indeed, all values) as characters, │ + │ it makes no sense to "rotate" a value, since there aren't any │ + │ boundries for the value. I.E.: there isn't any 32─bit word │ + │ "container" or "cell" (for instance) to store an integer. │ + └───────────────────────────────────────────────────────────────┘*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +show: procedure; parse arg x,t; say right(x,9) center(t,9) right(d2b(x),50); return +d2b: return x2b(d2x(arg(1))) +0 /*some REXXes have the D2B bif.*/ +b2d: return x2d(b2x(arg(1))) /*some REXXes have the B2D bif.*/ +bNot: return b2d(translate(d2b(arg(1)), 10, 01)) +0 /*+0≡normalize.*/ +bShiftL: return (b2d(d2b(arg(1)) || copies(0, arg(2)))) +0 +bAnd: procedure; parse arg x,y; return c2d(bitand(d2c(x), d2c(y))) +bOr: procedure; parse arg x,y; return c2d(bitor( d2c(x), d2c(y))) +bXor: procedure; parse arg x,y; return c2d(bitxor(d2c(x), d2c(y))) + +bShiftR: procedure; parse arg x,y; $=substr(reverse(d2b(x)), y+1) + if $=='' then $=0; return b2d(reverse($)) diff --git a/Task/Bitwise-operations/Racket/bitwise-operations.rkt b/Task/Bitwise-operations/Racket/bitwise-operations.rkt new file mode 100644 index 0000000000..4626a61fb6 --- /dev/null +++ b/Task/Bitwise-operations/Racket/bitwise-operations.rkt @@ -0,0 +1,9 @@ +#lang racket +(define a 255) +(define b 5) +(list (bitwise-and a b) + (bitwise-ior a b) + (bitwise-xor a b) + (bitwise-not a) + (arithmetic-shift a b) ; left shift + (arithmetic-shift a (- b))) ; right shift diff --git a/Task/Bitwise-operations/Ruby/bitwise-operations.rb b/Task/Bitwise-operations/Ruby/bitwise-operations.rb new file mode 100644 index 0000000000..fd303787af --- /dev/null +++ b/Task/Bitwise-operations/Ruby/bitwise-operations.rb @@ -0,0 +1,8 @@ +def bitwise(a, b) + puts "a and b: #{a & b}" + puts "a or b: #{a | b}" + puts "a xor b: #{a ^ b}" + puts "not a: #{~a}" + puts "a << b: #{a << b}" # left shift + puts "a >> b: #{a >> b}" # arithmetic right shift +end diff --git a/Task/Bitwise-operations/Scala/bitwise-operations.scala b/Task/Bitwise-operations/Scala/bitwise-operations.scala new file mode 100644 index 0000000000..97faa06ebc --- /dev/null +++ b/Task/Bitwise-operations/Scala/bitwise-operations.scala @@ -0,0 +1,11 @@ +def bitwise(a: Int, b: Int) { + println("a and b: " + (a & b)) + println("a or b: " + (a | b)) + println("a xor b: " + (a ^ b)) + println("not a: " + (~a)) + println("a << b: " + (a << b)) // left shift + println("a >> b: " + (a >> b)) // arithmetic right shift + println("a >>> b: " + (a >>> b)) // unsigned right shift + println("a rot b: " + Integer.rotateLeft(a, b)) // Rotate Left + println("a rol b: " + Integer.rotateRight(a, b)) // Rotate Right +} diff --git a/Task/Bitwise-operations/Scheme/bitwise-operations-1.ss b/Task/Bitwise-operations/Scheme/bitwise-operations-1.ss new file mode 100644 index 0000000000..7d373deade --- /dev/null +++ b/Task/Bitwise-operations/Scheme/bitwise-operations-1.ss @@ -0,0 +1,13 @@ +(define (bitwise a b) + (display (bitwise-and a b)) + (newline) + (display (bitwise-ior a b)) + (newline) + (display (bitwise-xor a b)) + (newline) + (display (bitwise-not a)) + (newline) + (display (bitwise-arithmetic-shift-right a b)) + (newline)) + +(bitwise 255 5) diff --git a/Task/Bitwise-operations/Scheme/bitwise-operations-2.ss b/Task/Bitwise-operations/Scheme/bitwise-operations-2.ss new file mode 100644 index 0000000000..c586f5a30a --- /dev/null +++ b/Task/Bitwise-operations/Scheme/bitwise-operations-2.ss @@ -0,0 +1,5 @@ +5 +255 +250 +-256 +7 diff --git a/Task/Bitwise-operations/Smalltalk/bitwise-operations-1.st b/Task/Bitwise-operations/Smalltalk/bitwise-operations-1.st new file mode 100644 index 0000000000..3180d7c4b9 --- /dev/null +++ b/Task/Bitwise-operations/Smalltalk/bitwise-operations-1.st @@ -0,0 +1,10 @@ +| testBitFunc | +testBitFunc := [ :a :b | + ('%1 and %2 is %3' % { a. b. (a bitAnd: b) }) displayNl. + ('%1 or %2 is %3' % { a. b. (a bitOr: b) }) displayNl. + ('%1 xor %2 is %3' % { a. b. (a bitXor: b) }) displayNl. + ('not %1 is %2' % { a. (a bitInvert) }) displayNl. + ('%1 left shift %2 is %3' % { a. b. (a bitShift: b) }) displayNl. + ('%1 right shift %2 is %3' % { a. b. (a bitShift: (b negated)) }) displayNl. + ]. +testBitFunc value: 16r7F value: 4 . diff --git a/Task/Bitwise-operations/Smalltalk/bitwise-operations-2.st b/Task/Bitwise-operations/Smalltalk/bitwise-operations-2.st new file mode 100644 index 0000000000..f319cd40bc --- /dev/null +++ b/Task/Bitwise-operations/Smalltalk/bitwise-operations-2.st @@ -0,0 +1,8 @@ +(a bitClear: b) "mask out bits" +(a bitAt: index) "retrieve a bit (bit-index, one-based)" +(a setBit: index) "set a bit (bit-index)" +(a clearBit: index) "clear a bit (bit-index)" +(a invertBit: index) "invert a bit (bit index)" +lowBit "find the index of the lowest one-bit; zero if none" +highBit "find the index of the highest one-bit; zero if none" +bitCount "count the one-bits" diff --git a/Task/Bitwise-operations/Tcl/bitwise-operations-1.tcl b/Task/Bitwise-operations/Tcl/bitwise-operations-1.tcl new file mode 100644 index 0000000000..c7b13c3124 --- /dev/null +++ b/Task/Bitwise-operations/Tcl/bitwise-operations-1.tcl @@ -0,0 +1,8 @@ +proc bitwise {a b} { + puts [format "a and b: %#08x" [expr {$a & $b}]] + puts [format "a or b: %#08x" [expr {$a | $b}]] + puts [format "a xor b: %#08x" [expr {$a ^ $b}]] + puts [format "not a: %#08x" [expr {~$a}]] + puts [format "a << b: %#08x" [expr {$a << $b}]] + puts [format "a >> b: %#08x" [expr {$a >> $b}]] +} diff --git a/Task/Bitwise-operations/Tcl/bitwise-operations-2.tcl b/Task/Bitwise-operations/Tcl/bitwise-operations-2.tcl new file mode 100644 index 0000000000..0e4cdece3d --- /dev/null +++ b/Task/Bitwise-operations/Tcl/bitwise-operations-2.tcl @@ -0,0 +1,13 @@ +proc bitwiseUnsupported {a b} { + set bits 0xFFFFFFFF + # Force interpretation as a 32-bit unsigned value + puts [format "a ArithRightShift b: %#08x" [expr {($a & $bits) >> $b}]] + puts [format "a RotateRight b: %#08x" [expr { + (($a >> $b) & ($bits >> $b)) | + (($a << (32-$b)) & ($bits ^ ($bits >> $b))) + }]] + puts [format "a RotateLeft b: %#08x" [expr { + (($a << $b) & $bits & ($bits << $b)) | + (($a >> (32-$b)) & ($bits ^ ($bits << $b))) + }]] +} diff --git a/Task/Boolean-values/0DESCRIPTION b/Task/Boolean-values/0DESCRIPTION new file mode 100644 index 0000000000..15155b6115 --- /dev/null +++ b/Task/Boolean-values/0DESCRIPTION @@ -0,0 +1,4 @@ +Show how to represent the boolean states "true" and "false" in a language. If other objects represent "true" or "false" in conditionals, note it. + +;Cf. +* [[Logical operations]] diff --git a/Task/Boolean-values/1META.yaml b/Task/Boolean-values/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Boolean-values/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Boolean-values/ALGOL-68/boolean-values.alg b/Task/Boolean-values/ALGOL-68/boolean-values.alg new file mode 100644 index 0000000000..33cb65d9c2 --- /dev/null +++ b/Task/Boolean-values/ALGOL-68/boolean-values.alg @@ -0,0 +1,30 @@ +BOOL f = FALSE, t = TRUE; +[]BOOL ft = (f, t); +STRING or = " or "; +FOR key TO UPB ft DO + BOOL val = ft[key]; + UNION(VOID, INT) void = (val|666|EMPTY); + REF STRING ref = (val|HEAP STRING|NIL); + INT int = ABS val; + REAL real = ABS val; + COMPL compl = ABS val; + BITS bits = BIN ABS val; # or bitspack(val); # + BYTES bytes = bytes pack((val|"?"|null char)*bytes width); + CHAR char = (val|"?"|null char); + STRING string = (val|"?"|""); + + print((((val | "TRUE" | "FALSE" ), ": ", val, or, (val|flip|flop), new line))); + print((" void: ", " => ", (void|(VOID):FALSE|TRUE), new line)); + print((" ref: ", " => ", ref ISNT REF STRING(NIL), new line)); + print((" int: ", int , " => ", int /= 0, new line)); + print((" real: ", real , " => ", real /= 0, new line)); + print((" compl: ", compl , " => ", compl /= 0, new line)); + print((" bits: ", bits , " => ", ABS bits /= 0, or, bits /= 2r0, or, + bits width ELEM bits, or, []BOOL(bits)[bits width], new line)); + print((" bytes: """, STRING(bytes) , """ => ", 1 ELEM bytes /= null char, or, + STRING(bytes) /= null char*bytes width, or, + STRING(bytes)[1] /= null char, new line)); + print((" char: """, char , """ => ", ABS char /= 0 , or, char /= null char, new line)); + print(("string: """, string , """ => ", string /= "", or, UPB string /= 0, new line)); + print((new line)) +OD diff --git a/Task/Boolean-values/AWK/boolean-values.awk b/Task/Boolean-values/AWK/boolean-values.awk new file mode 100644 index 0000000000..5aa0b9bb67 --- /dev/null +++ b/Task/Boolean-values/AWK/boolean-values.awk @@ -0,0 +1,18 @@ +BEGIN { + # Do not put quotes round the numeric values, or the tests will fail + a = 1 # True + b = 0 # False + + # Boolean evaluations + if (a) { print "first test a is true" } # This should print + if (b) { print "second test b is true" } # This should not print + if (!a) { print "third test a is false" } # This should not print + if (!b) { print "forth test b is false" } # This should print + + # Boolean evaluation using comparison against zero + if (a == 0) { print "fifth test a is false" } # This should not print + if (b == 0) { print "sixth test b is false" } # This should print + if (a != 0) { print "seventh test a is true" } # This should print + if (b != 0) { print "eighth test b is true" } # This should not print + + } diff --git a/Task/Boolean-values/Ada/boolean-values.ada b/Task/Boolean-values/Ada/boolean-values.ada new file mode 100644 index 0000000000..9316e2af11 --- /dev/null +++ b/Task/Boolean-values/Ada/boolean-values.ada @@ -0,0 +1 @@ + type Boolean is (False, True); diff --git a/Task/Boolean-values/BASIC/boolean-values.bas b/Task/Boolean-values/BASIC/boolean-values.bas new file mode 100644 index 0000000000..9821581e5b --- /dev/null +++ b/Task/Boolean-values/BASIC/boolean-values.bas @@ -0,0 +1,11 @@ +10 LET A%=0 +20 LET B%=NOT(A%) +30 PRINT "THIS VERSION OF BASIC USES" +40 PRINT B%; " AS ITS TRUE VALUE" +50 IF A% THEN PRINT "TEST ONE DOES NOT PRINT" +60 IF B% THEN PRINT "TEST TWO DOES PRINT" +70 IF A%=0 THEN PRINT "TEST THREE (FALSE BY COMPARISON) DOES PRINT" +80 IF B%=0 THEN PRINT "TEST FOUR (FALSE BY COMPARISON) DOES NOT PRINT" +90 IF A%<>0 THEN PRINT "TEST FIVE (TRUE BY COMPARISON) DOES NOT PRINT" +100 IF B%<>0 THEN PRINT "TEST SIX (TRUE BY COMPARISON) DOES PRINT" +110 END diff --git a/Task/Boolean-values/BASIC256/boolean-values.basic256 b/Task/Boolean-values/BASIC256/boolean-values.basic256 new file mode 100644 index 0000000000..e299af2704 --- /dev/null +++ b/Task/Boolean-values/BASIC256/boolean-values.basic256 @@ -0,0 +1,7 @@ +' BASIC256 used numbers to represent true and false +' values. Zero is false and anything else is true. +' The built in constants true and false exist +' and represent one and zero respectively. + +print false +print true diff --git a/Task/Boolean-values/BBC-BASIC/boolean-values.bbc b/Task/Boolean-values/BBC-BASIC/boolean-values.bbc new file mode 100644 index 0000000000..4985897c22 --- /dev/null +++ b/Task/Boolean-values/BBC-BASIC/boolean-values.bbc @@ -0,0 +1,5 @@ + REM BBC BASIC uses integers to represent Booleans; the keywords + REM FALSE and TRUE equate to 0 and -1 (&FFFFFFFF) respectively: + + PRINT FALSE + PRINT TRUE diff --git a/Task/Boolean-values/CoffeeScript/boolean-values.coffee b/Task/Boolean-values/CoffeeScript/boolean-values.coffee new file mode 100644 index 0000000000..e13e42285b --- /dev/null +++ b/Task/Boolean-values/CoffeeScript/boolean-values.coffee @@ -0,0 +1,28 @@ +h1 = {foo: "bar"} +h2 = {foo: "bar"} + +true_expressions = [ + true + 1 + h1? # because h1 is defined above + not false + !false + [] + {} + 1 + 1 == 2 + 1 == 1 # simple value equality + true or false +] + +false_expressions = [ + false + not true + undeclared_variable? + 0 + '' + null + undefined + h1 == h2 # despite having same key/values + 1 == "1" # different types + false and true +] diff --git a/Task/Boolean-values/Erlang/boolean-values.erl b/Task/Boolean-values/Erlang/boolean-values.erl new file mode 100644 index 0000000000..aa30052703 --- /dev/null +++ b/Task/Boolean-values/Erlang/boolean-values.erl @@ -0,0 +1,6 @@ +1> 1 < 2. +true +2> 1 < 1. +false +3> 0 == false. +false diff --git a/Task/Boolean-values/Forth/boolean-values.fth b/Task/Boolean-values/Forth/boolean-values.fth new file mode 100644 index 0000000000..ce7dc4254d --- /dev/null +++ b/Task/Boolean-values/Forth/boolean-values.fth @@ -0,0 +1,2 @@ +TRUE . \ -1 +FALSE . \ 0 diff --git a/Task/Boolean-values/Haskell/boolean-values.hs b/Task/Boolean-values/Haskell/boolean-values.hs new file mode 100644 index 0000000000..61f9cddfe2 --- /dev/null +++ b/Task/Boolean-values/Haskell/boolean-values.hs @@ -0,0 +1 @@ +data Bool = False | True deriving (Eq, Ord, Enum, Read, Show, Bounded) diff --git a/Task/Boolean-values/Lua/boolean-values.lua b/Task/Boolean-values/Lua/boolean-values.lua new file mode 100644 index 0000000000..08369ff5d7 --- /dev/null +++ b/Task/Boolean-values/Lua/boolean-values.lua @@ -0,0 +1,6 @@ +if 0 then print "0" end -- This prints +if "" then print"empty string" end -- This prints +if {} then print"empty table" end -- This prints +if nil then print"this won't print" end +if true then print"true" end +if false then print"false" end -- This does not print diff --git a/Task/Boolean-values/MATLAB/boolean-values.m b/Task/Boolean-values/MATLAB/boolean-values.m new file mode 100644 index 0000000000..bc99cc5bce --- /dev/null +++ b/Task/Boolean-values/MATLAB/boolean-values.m @@ -0,0 +1,35 @@ +>> islogical(true) + +ans = + + 1 + +>> islogical(false) + +ans = + + 1 + +>> islogical(logical(1)) + +ans = + + 1 + +>> islogical(logical(0)) + +ans = + + 1 + +>> islogical(1) + +ans = + + 0 + +>> islogical(0) + +ans = + + 0 diff --git a/Task/Boolean-values/Perl/boolean-values-1.pl b/Task/Boolean-values/Perl/boolean-values-1.pl new file mode 100644 index 0000000000..119db1039d --- /dev/null +++ b/Task/Boolean-values/Perl/boolean-values-1.pl @@ -0,0 +1,2 @@ +my $x = 0.0; +my $true_or_false = $x ? 'true' : 'false'; # false diff --git a/Task/Boolean-values/Perl/boolean-values-2.pl b/Task/Boolean-values/Perl/boolean-values-2.pl new file mode 100644 index 0000000000..be17eb4a2a --- /dev/null +++ b/Task/Boolean-values/Perl/boolean-values-2.pl @@ -0,0 +1,10 @@ +my $x = 1; # true + +my $true_or_false; + +if ($x) { + $true_or_false = 'true'; +} +else { + $true_or_false = 'false'; +} diff --git a/Task/Boolean-values/Perl/boolean-values-3.pl b/Task/Boolean-values/Perl/boolean-values-3.pl new file mode 100644 index 0000000000..e2071d15a9 --- /dev/null +++ b/Task/Boolean-values/Perl/boolean-values-3.pl @@ -0,0 +1,5 @@ +print (7 && 2); # 2, rather than 1(true) +print (2 && 7); # 7, rather than 1(true) +print (7 xor 2); # empty string, rather than 0(false) +print ('apples' && 'pears'); # pears, rather than 1(true) +print ('apples' xor 'pears'); # empty string, rather than 0(false) diff --git a/Task/Boolean-values/Perl/boolean-values-4.pl b/Task/Boolean-values/Perl/boolean-values-4.pl new file mode 100644 index 0000000000..38fd1dfe62 --- /dev/null +++ b/Task/Boolean-values/Perl/boolean-values-4.pl @@ -0,0 +1,5 @@ +# This does not work +# true and false are not special so will be treated as bareword strings +if (true) { print "true is true\n" }; # This prints +if (false) { print "false is true\n" }; # So does this +if (spongebob) { print "spongebob is true\n" }; # A bareword string diff --git a/Task/Boolean-values/Python/boolean-values.py b/Task/Boolean-values/Python/boolean-values.py new file mode 100644 index 0000000000..557698da99 --- /dev/null +++ b/Task/Boolean-values/Python/boolean-values.py @@ -0,0 +1,39 @@ +>>> True +True +>>> not True +False +>>> # As numbers +>>> False + 0 +0 +>>> True + 0 +1 +>>> False + 0j +0j +>>> True * 3.141 +3.141 +>>> # Numbers as booleans +>>> not 0 +True +>>> not not 0 +False +>>> not 1234 +False +>>> bool(0.0) +False +>>> bool(0j) +False +>>> bool(1+2j) +True +>>> # Collections as booleans +>>> bool([]) +False +>>> bool([None]) +True +>>> 'I contain something' if (None,) else 'I am empty' +'I contain something' +>>> bool({}) +False +>>> bool("") +False +>>> bool("False") +True diff --git a/Task/Boolean-values/REXX/boolean-values-1.rexx b/Task/Boolean-values/REXX/boolean-values-1.rexx new file mode 100644 index 0000000000..87a141ecc3 --- /dev/null +++ b/Task/Boolean-values/REXX/boolean-values-1.rexx @@ -0,0 +1,2 @@ + true = 1 +false = 0 diff --git a/Task/Boolean-values/REXX/boolean-values-2.rexx b/Task/Boolean-values/REXX/boolean-values-2.rexx new file mode 100644 index 0000000000..7c4e0a9f93 --- /dev/null +++ b/Task/Boolean-values/REXX/boolean-values-2.rexx @@ -0,0 +1,2 @@ +true = (1=1) +false = (1=0) diff --git a/Task/Boolean-values/REXX/boolean-values-3.rexx b/Task/Boolean-values/REXX/boolean-values-3.rexx new file mode 100644 index 0000000000..aaf059b473 --- /dev/null +++ b/Task/Boolean-values/REXX/boolean-values-3.rexx @@ -0,0 +1,2 @@ +true = (1==1) +false = (1==0) diff --git a/Task/Boolean-values/REXX/boolean-values-4.rexx b/Task/Boolean-values/REXX/boolean-values-4.rexx new file mode 100644 index 0000000000..b08ac88397 --- /dev/null +++ b/Task/Boolean-values/REXX/boolean-values-4.rexx @@ -0,0 +1,2 @@ +true = (1==1) +false = \true diff --git a/Task/Boolean-values/REXX/boolean-values-5.rexx b/Task/Boolean-values/REXX/boolean-values-5.rexx new file mode 100644 index 0000000000..67ebdd4601 --- /dev/null +++ b/Task/Boolean-values/REXX/boolean-values-5.rexx @@ -0,0 +1 @@ +false = ¬true diff --git a/Task/Boolean-values/REXX/boolean-values-6.rexx b/Task/Boolean-values/REXX/boolean-values-6.rexx new file mode 100644 index 0000000000..b20fa2b8d8 --- /dev/null +++ b/Task/Boolean-values/REXX/boolean-values-6.rexx @@ -0,0 +1,4 @@ +true = 1984 = 1984 +false = 'war' = 'peace' +false = 'freedom' = 'slavery' +false = 'ignorance' = 'strength' diff --git a/Task/Boolean-values/Racket/boolean-values.rkt b/Task/Boolean-values/Racket/boolean-values.rkt new file mode 100644 index 0000000000..01387671f1 --- /dev/null +++ b/Task/Boolean-values/Racket/boolean-values.rkt @@ -0,0 +1,3 @@ +(cond ([(< 4 3) 'apple] + ['bloggle 'pear] + [else 'nectarine]) diff --git a/Task/Boolean-values/SNUSP/boolean-values.snusp b/Task/Boolean-values/SNUSP/boolean-values.snusp new file mode 100644 index 0000000000..9becbfae64 --- /dev/null +++ b/Task/Boolean-values/SNUSP/boolean-values.snusp @@ -0,0 +1,2 @@ +$!/?\=false= + =true=# + \-/ diff --git a/Task/Boolean-values/Sather/boolean-values.sa b/Task/Boolean-values/Sather/boolean-values.sa new file mode 100644 index 0000000000..621410a1b9 --- /dev/null +++ b/Task/Boolean-values/Sather/boolean-values.sa @@ -0,0 +1,7 @@ +v:BOOL := true; -- ok +i:INT := 1; +v := 1; -- wrong +if i then ... end; -- wrong: if requires a bool! +-- BUT +v := 1.bool; -- ok +if i.bool then ... end; -- ok diff --git a/Task/Boolean-values/Tcl/boolean-values-1.tcl b/Task/Boolean-values/Tcl/boolean-values-1.tcl new file mode 100644 index 0000000000..a56abc64db --- /dev/null +++ b/Task/Boolean-values/Tcl/boolean-values-1.tcl @@ -0,0 +1,2 @@ +% if {""} then {puts true} else {puts false} +expected boolean value but got "" diff --git a/Task/Boolean-values/Tcl/boolean-values-2.tcl b/Task/Boolean-values/Tcl/boolean-values-2.tcl new file mode 100644 index 0000000000..5404b078c9 --- /dev/null +++ b/Task/Boolean-values/Tcl/boolean-values-2.tcl @@ -0,0 +1 @@ +if {[string is false -strict $string]} ... diff --git a/Task/Box-the-compass/0DESCRIPTION b/Task/Box-the-compass/0DESCRIPTION new file mode 100644 index 0000000000..3e75f32e50 --- /dev/null +++ b/Task/Box-the-compass/0DESCRIPTION @@ -0,0 +1,21 @@ +Avast me hearties! + +There be many a [http://www.talklikeapirate.com/howto.html land lubber] that knows [http://oxforddictionaries.com/view/entry/m_en_gb0550020#m_en_gb0550020 naught] of the pirate ways and gives direction by degree! +They know not how to [[wp:Boxing the compass|box the compass]]! + +'''Task description''' + +# Create a function that takes a heading in degrees and returns the correct 32-point compass heading. +# Use the function to print and display a table of Index, Compass point, and Degree; rather like the corresponding columns from, the first table of the [[wp:Boxing the compass|wikipedia article]], but use only the following 33 headings as input: +:[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, 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38]. (They should give the same order of points but are spread throughout the ranges of acceptance). + +;Notes; +* The headings and indices can be calculated from this pseudocode: +
for i in 0..32 inclusive:
+    heading = i * 11.25
+    case i %3:
+      if 1: heading += 5.62; break
+      if 2: heading -= 5.62; break
+    end
+    index = ( i mod 32) + 1
+* The column of indices can be thought of as an enumeration of the thirty two cardinal points (see [[Talk:Box the compass#Direction, index, and angle|talk page]]).. diff --git a/Task/Box-the-compass/ALGOL-68/box-the-compass.alg b/Task/Box-the-compass/ALGOL-68/box-the-compass.alg new file mode 100644 index 0000000000..82ef984f76 --- /dev/null +++ b/Task/Box-the-compass/ALGOL-68/box-the-compass.alg @@ -0,0 +1,96 @@ +#!/usr/local/bin/a68g --script # + +[]STRING + long by nesw = (" by ", "North", "East", "South", "West"), + short by nesw = ("b", "N", "E", "S", "W"); + +MODE MINUTES = REAL; # minutes type # +INT last minute=360*60; +INT point width=last minute OVER 32; + +PROC direction name = (REAL direction in minutes, []STRING locale directions)STRING: ( + + STRING by = locale directions[1]; + []STRING nesw = locale directions[@-1]; + + PRIO MASK = 7; # same PRIOrity as * and / # + OP MASK = (INT n, BITS lower)INT: ABS (BIN n AND NOT lower), + DECAP = (STRING s)STRING: IF UPB s > 1 THEN REPR (ABS s[1]-ABS "A"+ABS "a")+s[2:] ELSE s FI; + + PROC point name = (INT in point)STRING: ( + + INT point = in point MOD 32 # 32 points of a compass #; + IF point MOD 8 = 0 THEN +# name the principle point: eg. N, E, S or W # + nesw[point OVER 8] + + ELIF point MOD 4 = 0 THEN +# name the half: eg. NE, SE, SW or NW # + point name((point+8)MASK 2r1111)+DECAP point name(point MASK 2r1111 + 8) + + ELIF point MOD 2 = 0 THEN +# name the quarter: eg. N-NE, E-NE, E-SE, S-SE, S-SW, W-SW, W-NW or N-NW # + point name((point+4)MASK 2r111)+"-"+point name(point MASK 2r111 + 4) + + ELSE # Name the sixteenth point: # +# eg. NbE,NEbN,NEbE,EbN,EbS,SEbE,SEbS,SbE,SbW,SWbS,SWbW,WbS,WbN,NWbW,NWbN,NbW # + INT opp point = point OVER 8 + ABS NOT ODD (point OVER 2); + point name((point+2)MASK 2r11)+ by +nesw(opp point MOD 4) + FI + ); + point name(ROUND(direction in minutes/point width)) +); + +PROC traditional name = (MINUTES minutes)STRING: ( + INT degrees = ROUND(minutes / 60); + degrees=0 |"Tramontana" |: + degrees=45 |"Greco or Bora" |: + degrees=90 |"Levante" |: + degrees=135|"Sirocco" |: + degrees=180|"Ostro" |: + degrees=225|"Libeccio" |: + degrees=270|"Poniente or Zephyrus"|: + degrees=315|"Mistral" |: + degrees=360|"Tramontana" |"" +); + +# First generate the test set results # +test:( + printf($"Test:"l$); + FOR i FROM 0 TO 32 DO + REAL heading = i * 11.25 + + CASE i MOD 3 IN + +5.62, + -5.62 + OUT 0 + ESAC; + INT index = ( i MOD 32) + 1; + printf(($zd" ", g23k, zzd.zzl$, index , direction name(heading*60, long by nesw), heading)) + OD +); + +table:( + OP OVER = (REAL r, INT base)INT: ENTIER ABS r OVER base, + MOD = (REAL r, INT base)REAL: ( INT i = ENTIER r; i MOD base + r - i); + + printf( + $l"Table:"l + " #|Compass point"22k"|Abbr|Traditional wind point| Lowest°′ | Middle°′ | Highest°′"l$ + ); + + OP DEGMIN = (REAL minutes)STRUCT(INT d, REAL m): (minutes MOD last minute OVER 60, minutes MOD 60); + + FOR point FROM 1 TO 32 DO + REAL centre = (point-1) * point width; + REAL from = centre - point width/2, + to = centre + point width/2-1/120; + printf(( + $g(-2)"|"$, point, + $g$, direction name(centre, long by nesw), + $22k"|"g$, direction name(centre, short by nesw), + $27k"|"g$, traditional name(centre), + $50k$, $"|"g(-3)"°", dd.dd"′"$, DEGMIN from, DEGMIN centre, DEGMIN to, + $l$ + )) + OD +) diff --git a/Task/Box-the-compass/AWK/box-the-compass.awk b/Task/Box-the-compass/AWK/box-the-compass.awk new file mode 100644 index 0000000000..e27d31fcb3 --- /dev/null +++ b/Task/Box-the-compass/AWK/box-the-compass.awk @@ -0,0 +1,18 @@ +#!/usr/bin/awk -f +BEGIN { + split("N NbE NNE NEbN NE NEbE ENE EbN E EbS ESE SEbE SE SEbS SSE SbE S SbW SSW SWbS SW SWbW WSW WbS W WbN WNW NWbW NW NWbN NNW NbW",A," "); +} + +function ceil(x) { + y = int(x) + return y < x ? y + 1 : y +} + +function compassbox(d) { + return ceil( ( (d + 360 / 64) % 360) * 32 / 360); +} + +{ + box = compassbox($1); + printf "%6.2f : %2d\t%s\n",$1,box,A[box]; +} diff --git a/Task/Box-the-compass/Ada/box-the-compass.ada b/Task/Box-the-compass/Ada/box-the-compass.ada new file mode 100644 index 0000000000..6396c3b50b --- /dev/null +++ b/Task/Box-the-compass/Ada/box-the-compass.ada @@ -0,0 +1,66 @@ +with Ada.Text_IO; + +procedure Box_The_Compass is + + type Degrees is digits 5 range 0.00 .. 359.99; + type Index_Type is mod 32; + + function Long_Name(Short: String) return String is + + function Char_To_Name(Char: Character) return String is + begin + case Char is + when 'N' | 'n' => return Char & "orth"; + when 'S' | 's' => return Char & "outh"; + when 'E' | 'e' => return Char & "ast"; + when 'W' | 'w' => return Char & "est"; + when 'b' => return " by "; + when '-' => return "-"; + when others => raise Constraint_Error; + end case; + end Char_To_Name; + + begin + if Short'Length = 0 or else Short(Short'First)=' ' then + return ""; + else + return Char_To_Name(Short(Short'First)) + & Long_Name(Short(Short'First+1 .. Short'Last)); + end if; + end Long_Name; + + procedure Put_Line(Angle: Degrees) is + + function Index(D: Degrees) return Index_Type is + begin + return Index_Type(Integer(Degrees'Rounding(D/11.25)) mod 32); + end Index; + + I: Integer := Integer(Index(Angle))+1; + package DIO is new Ada.Text_IO.Float_IO(Degrees); + Abbr: constant array(Index_Type) of String(1 .. 4) + := ("N ", "Nbe ", "N-ne", "Nebn", "Ne ", "Nebe", "E-ne", "Ebn ", + "E ", "Ebs ", "E-se", "Sebe", "Se ", "Sebs", "S-se", "Sbe ", + "S ", "Sbw ", "S-sw", "Swbs", "Sw ", "Swbw", "W-sw", "Wbs ", + "W ", "Wbn ", "W-nw", "Nwbw", "Nw ", "Nwbn", "N-nw", "Nbw "); + + begin + DIO.Put(Angle, Fore => 3, Aft => 2, Exp => 0); -- format "zzx.xx" + Ada.Text_IO.Put(" |"); + if I <= 9 then + Ada.Text_IO.Put(" "); + end if; + Ada.Text_IO.Put_Line(" " & Integer'Image(I) & " | " + & Long_Name(Abbr(Index(Angle)))); + end Put_Line; + + Difference: constant array(0..2) of Degrees'Base + := (0=> 0.0, 1=> +5.62, 2=> - 5.62); + +begin + Ada.Text_IO.Put_Line(" angle | box | compass point"); + Ada.Text_IO.Put_Line(" ---------------------------------"); + for I in 0 .. 32 loop + Put_Line(Degrees(Degrees'Base(I) * 11.25 + Difference(I mod 3))); + end loop; +end Box_The_Compass; diff --git a/Task/Box-the-compass/AutoHotkey/box-the-compass.ahk b/Task/Box-the-compass/AutoHotkey/box-the-compass.ahk new file mode 100644 index 0000000000..45e04ad1dd --- /dev/null +++ b/Task/Box-the-compass/AutoHotkey/box-the-compass.ahk @@ -0,0 +1,39 @@ +get_Index(angle){ + return Mod(floor(angle / 11.25 +0.5), 32) + 1 +} + +get_Abbr_From_Index(i){ + static points + := [ "N", "NbE", "NNE", "NEbN", "NE", "NEbE", "ENE", "EbN" + ,"E", "EbS", "ESE", "SEbE", "SE", "SEbS", "SSE", "SbE" + ,"S", "SbW", "SSW", "SWbS", "SW", "SWbW", "WSW", "WbS" + ,"W", "WbN", "WNW", "NWbW", "NW", "NWbN", "NNW", "NbW" ] + return points[i] +} + +Build_Name_From_Abbr(a){ + Loop Parse, a + { + i := A_Index + if ((i = 2) && (SubStr(a, i, 1) != "b") && (StrLen(a) == 3)) + retval .= "-" + retval .= {N: "north", S: "south", E: "east" + , W: "west" , b: " by "}[A_LoopField] + } + return Chr(Asc(SubStr(retval, 1, 1))-32) . SubStr(retval, 2) +} + +; test + +headings:= [0.00, 16.87, 16.88, 33.75, 50.62, 50.63, 67.50, 84.37, 84.38, 101.25 + , 118.12, 118.13, 135.00, 151.87, 151.88, 168.75, 185.62, 185.63 + , 202.50, 219.37, 219.38, 236.25, 253.12, 253.13, 270.00, 286.87 + , 286.88, 303.75, 320.62, 320.63, 337.50, 354.37, 354.38] +For n, a in headings +{ + i := get_Index(a) + out .= SubStr(" " i, -1) " " + . SubStr(Build_Name_From_Abbr(get_Abbr_From_Index(i)) + . " ", 1, 24) . SubStr(" " a, -5) . "`r`n" ; +} +clipboard := out diff --git a/Task/Box-the-compass/AutoIt/box-the-compass.autoit b/Task/Box-the-compass/AutoIt/box-the-compass.autoit new file mode 100644 index 0000000000..7049c0455f --- /dev/null +++ b/Task/Box-the-compass/AutoIt/box-the-compass.autoit @@ -0,0 +1,18 @@ +Local $avArray[33] = [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, 286.87, 286.88, _ + 303.75, 320.62, 320.63, 337.5, 354.37, 354.38] + +For $i = 0 To UBound($avArray) - 1 + Boxing_the_compass($avArray[$i]) +Next + +Func Boxing_the_compass($Degree) + Local $namearray[33] = ["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", "South", _ + "South by west", "South-southwest", "Southwest by south", "Southwest", "Southwest by west", "West-southwest", _ + "West by south", "West", "West by north", "West-northwest", "Northwest by west", "Northwest", "Northwest by north", _ + "North-northwest", "North by west", "North"] + ConsoleWrite(StringFormat("%-2s", Mod(Floor($Degree / 11.25 + 0.5), 32)) & " : " & _ + StringFormat("%-20s", $namearray[Mod(Floor($Degree / 11.25 + 0.5), 32)]) & " : " & $Degree & @CRLF) +EndFunc ;==>Boxing_the_compass diff --git a/Task/Box-the-compass/BBC-BASIC/box-the-compass.bbc b/Task/Box-the-compass/BBC-BASIC/box-the-compass.bbc new file mode 100644 index 0000000000..f8473374dd --- /dev/null +++ b/Task/Box-the-compass/BBC-BASIC/box-the-compass.bbc @@ -0,0 +1,27 @@ + DIM bearing(32) + bearing() = 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, 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38 + + FOR i% = 0 TO 32 + box% = FNcompassbox(bearing(i%), compass$) + PRINT ; bearing(i%), ; box%, compass$ + NEXT + END + + DEF FNcompassbox(bearing, RETURN box$) + LOCAL pt% + pt% = INT(bearing / 360 * 32 + 0.5) MOD 32 + box$ = FNpt(pt%) + LEFT$(box$,1) = CHR$(ASC(LEFT$(box$,1))-32) + = pt% + 1 + + DEF FNpt(pt%) + LOCAL pt$() : DIM pt$(3) + IF pt% AND 1 THEN = FNpt((pt% + 1) AND 28) + " by " + \ + \ FNpt(((2 - (pt% AND 2)) * 4) + pt% AND 24) + IF pt% AND 2 THEN = FNpt((pt% + 2) AND 24) + "-" + FNpt((pt% OR 4) AND 28) + IF pt% AND 4 THEN = FNpt((pt% + 8) AND 16) + FNpt((pt% OR 8) AND 24) + pt$() = "north", "east", "south", "west" + = pt$(pt% DIV 8) diff --git a/Task/Box-the-compass/C/box-the-compass.c b/Task/Box-the-compass/C/box-the-compass.c new file mode 100644 index 0000000000..2fddb6e1a0 --- /dev/null +++ b/Task/Box-the-compass/C/box-the-compass.c @@ -0,0 +1,53 @@ +#include + +int main() +{ + int i, j; + double degrees[] = { 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, 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, + 354.37, 354.38 }; + const char * names = "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 " + "South " + "South by west " + "South-southwest " + "Southwest by south " + "Southwest " + "Southwest by west " + "West-southwest " + "West by south " + "West " + "West by north " + "West-northwest " + "Northwest by west " + "Northwest " + "Northwest by north " + "North-northwest " + "North by west " + "North "; + + for (i = 0; i < 33; i++) { + j = .5 + degrees[i] * 32 / 360; + + printf("%2d %.22s %6.2f\n", (j % 32) + 1, names + (j % 32) * 22, + degrees[i]); + } + + return 0; +} diff --git a/Task/Box-the-compass/Clojure/box-the-compass.clj b/Task/Box-the-compass/Clojure/box-the-compass.clj new file mode 100644 index 0000000000..1c099ce5e2 --- /dev/null +++ b/Task/Box-the-compass/Clojure/box-the-compass.clj @@ -0,0 +1,26 @@ +(ns boxing-the-compass + (:use [clojure.string :only [capitalize]])) + +(def headings + (for [i (range 0 (inc 32))] + (let [heading (* i 11.25)] + (case (mod i 3) + 1 (+ heading 5.62) + 2 (- heading 5.62) + heading)))) + +(defn angle2compass + [angle] + (let [dirs ["N" "NbE" "N-NE" "NEbN" "NE" "NEbE" "E-NE" "EbN" + "E" "EbS" "E-SE" "SEbE" "SE" "SEbS" "S-SE" "SbE" + "S" "SbW" "S-SW" "SWbS" "SW" "SWbW" "W-SW" "WbS" + "W" "WbN" "W-NW" "NWbW" "NW" "NWbN" "N-NW" "NbW"] + unpack {\N "north" \E "east" \W "west" \S "south" \b " by " \- "-"} + sep (/ 360 (count dirs)) + dir (int (/ (mod (+ angle (/ sep 2)) 360) sep))] + (capitalize (apply str (map unpack (dirs dir)))))) + +(print + (apply str (map-indexed #(format "%2s %-18s %7.2f\n" + (inc (mod %1 32)) (angle2compass %2) %2) + headings))) diff --git a/Task/Box-the-compass/Fortran/box-the-compass.f b/Task/Box-the-compass/Fortran/box-the-compass.f new file mode 100644 index 0000000000..c94eab24a9 --- /dev/null +++ b/Task/Box-the-compass/Fortran/box-the-compass.f @@ -0,0 +1,38 @@ +Program Compass + implicit none + + integer :: i, ind + real :: heading + + do i = 0, 32 + heading = i * 11.25 + if (mod(i, 3) == 1) then + heading = heading + 5.62 + else if (mod(i, 3) == 2) then + heading = heading - 5.62 + end if + ind = mod(i, 32) + 1 + write(*, "(i2, a20, f8.2)") ind, compasspoint(heading), heading + end do + +contains + +function compasspoint(h) + character(18) :: compasspoint + character(18) :: points(32) = (/ "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 ", "South ", "South by west ", "South-southwest ", & + "Southwest by south", "Southwest ", "Southwest by west ", "West-southwest ", & + "West by south ", "West ", "West by north ", "West-northwest ", & + "Northwest by west ", "Northwest ", "Northwest by north", "North-northwest ", & + "North by west " /) + real, intent(in) :: h + real :: x + + x = h / 11.25 + 1.5 + if (x >= 33.0) x = x - 32.0 + compasspoint = points(int(x)) +end function compasspoint +end program Compass diff --git a/Task/Box-the-compass/Go/box-the-compass.go b/Task/Box-the-compass/Go/box-the-compass.go new file mode 100644 index 0000000000..e7ff3785bf --- /dev/null +++ b/Task/Box-the-compass/Go/box-the-compass.go @@ -0,0 +1,67 @@ +package main + +import "fmt" + +// function required by task +func degrees2compasspoint(h float32) string { + return compassPoint[cpx(h)] +} + +// cpx returns integer index from 0 to 31 corresponding to compass point. +// input heading h is in degrees. Note this index is a zero-based index +// suitable for indexing into the table of printable compass points, +// and is not the same as the index specified to be printed in the output. +func cpx(h float32) int { + x := int(h/11.25+.5) % 32 + if x < 0 { + x += 32 + } + return x +} + +// printable compass points +var compassPoint = []string{ + "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", + "South", + "South by west", + "South-southwest", + "Southwest by south", + "Southwest", + "Southwest by west", + "West-southwest", + "West by south", + "West", + "West by north", + "West-northwest", + "Northwest by west", + "Northwest", + "Northwest by north", + "North-northwest", + "North by west", +} + +func main() { + fmt.Println("Index Compass point Degree") + for i, h := range []float32{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, + 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38} { + index := i%32 + 1 // printable index computed per pseudocode + fmt.Printf("%4d %-19s %7.2f°\n", index, degrees2compasspoint(h), h) + } +} diff --git a/Task/Box-the-compass/Haskell/box-the-compass.hs b/Task/Box-the-compass/Haskell/box-the-compass.hs new file mode 100644 index 0000000000..55dc5f70c6 --- /dev/null +++ b/Task/Box-the-compass/Haskell/box-the-compass.hs @@ -0,0 +1,25 @@ +import Data.Char +import Data.Maybe +import Text.Printf + +dirs = ["N", "NbE", "N-NE", "NEbN", "NE", "NEbE", "E-NE", "EbN", + "E", "EbS", "E-SE", "SEbE", "SE", "SEbS", "S-SE", "SbE", + "S", "SbW", "S-SW", "SWbS", "SW", "SWbW", "W-SW", "WbS", + "W", "WbN", "W-NW", "NWbW", "NW", "NWbN", "N-NW", "NbW"] + +-- Given an index between 0 and 31 return the corresponding compass point name. +pointName = capitalize . concatMap (fromMaybe "?" . fromChar) . (dirs !!) + where fromChar c = lookup c [('N', "north"), ('S', "south"), ('E', "east"), + ('W', "west"), ('b', " by "), ('-', "-")] + capitalize (c:cs) = toUpper c : cs + +-- Convert degrees to a compass point index between 0 and 31. +pointIndex d = (round (d*1000) + 5625) `mod` 360000 `div` 11250 + +printPointName d = let deg = read d :: Double + idx = pointIndex deg + in printf "%2d %-18s %6.2f°\n" (idx+1) (pointName idx) deg + +main = do + input <- getContents + mapM_ printPointName $ lines input diff --git a/Task/Box-the-compass/Java/box-the-compass.java b/Task/Box-the-compass/Java/box-the-compass.java new file mode 100644 index 0000000000..5ebd5d022a --- /dev/null +++ b/Task/Box-the-compass/Java/box-the-compass.java @@ -0,0 +1,49 @@ +public class BoxingTheCompass{ + private static String[] points = new String[32]; + + public static void main(String[] args){ + buildPoints(); + + double heading = 0; + + for(int i = 0; i<= 32;i++){ + heading = i * 11.25; + switch(i % 3){ + case 1: + heading += 5.62; + break; + case 2: + heading -= 5.62; + break; + default: + } + + System.out.printf("%s\t%18s\t%s°\n",(i % 32) + 1, initialUpper(getPoint(heading)), heading); + } + } + + private static void buildPoints(){ + String[] cardinal = {"north", "east", "south", "west"}; + String[] pointDesc = {"1", "1 by 2", "1-C", "C by 1", "C", "C by 2", "2-C", "2 by 1"}; + + String str1, str2, strC; + + for(int i = 0;i <= 3;i++){ + str1 = cardinal[i]; + str2 = cardinal[(i + 1) % 4]; + strC = (str1.equals("north") || str1.equals("south")) ? (str1 + str2): (str2 + str1); + for(int j = 0;j <= 7;j++){ + points[i * 8 + j] = pointDesc[j].replace("1", str1).replace("2", str2).replace("C", strC); + } + } + } + + private static String initialUpper(String s){ + return s.substring(0, 1).toUpperCase() + s.substring(1); + } + + private static String getPoint(double degrees){ + double testD = (degrees / 11.25) + 0.5; + return points[(int)Math.floor(testD % 32)]; + } +} diff --git a/Task/Box-the-compass/JavaScript/box-the-compass.js b/Task/Box-the-compass/JavaScript/box-the-compass.js new file mode 100644 index 0000000000..7ec9f2a9ca --- /dev/null +++ b/Task/Box-the-compass/JavaScript/box-the-compass.js @@ -0,0 +1,45 @@ +function createRow(i, point, heading) { + var tr = document.createElement('tr'), + td; + + td = document.createElement('td'); + td.appendChild(document.createTextNode(i)); + tr.appendChild(td); + + td = document.createElement('td'); + point = point.substr(0, 1).toUpperCase() + point.substr(1); + td.appendChild(document.createTextNode(point)); + tr.appendChild(td); + + td = document.createElement('td'); + td.appendChild(document.createTextNode(heading)); + tr.appendChild(td); + + return tr; +} + +function getPoint(i) { + var j = i % 8, + i = Math.floor(i / 8) % 4, + cardinal = ['north', 'east', 'south', 'west'], + pointDesc = ['1', '1 by 2', '1-C', 'C by 1', 'C', 'C by 2', '2-C', '2 by 1'], + str1, str2, strC; + + str1 = cardinal[i]; + str2 = cardinal[(i + 1) % 4]; + strC = (str1 === 'north' || str1 === 'south') ? str1 + str2 : str2 + str1; + return pointDesc[j].replace('1', str1).replace('2', str2).replace('C', strC); +} + +var i, + heading, + table = document.createElement('table'), + tbody = document.createElement('tbody'), + tr; +for (i = 0; i <= 32; i += 1) { + heading = i * 11.25 + [0, 5.62, -5.62][i % 3]; + tr = createRow(i % 32 + 1, getPoint(i), heading + '°'); + tbody.appendChild(tr); +} +table.appendChild(tbody); +document.body.appendChild(table); diff --git a/Task/Box-the-compass/Lua/box-the-compass.lua b/Task/Box-the-compass/Lua/box-the-compass.lua new file mode 100644 index 0000000000..fbd4a23e47 --- /dev/null +++ b/Task/Box-the-compass/Lua/box-the-compass.lua @@ -0,0 +1,49 @@ +-- List of abbreviated compass point labels +compass_points = { "N", "NbE", "N-NE", "NEbN", "NE", "NEbE", "E-NE", "EbN", + "E", "EbS", "E-SE", "SEbE", "SE", "SEbS", "S-SE", "SbE", + "S", "SbW", "S-SW", "SWbS", "SW", "SWbW", "W-SW", "WbS", + "W", "WbN", "W-NW", "NWbW", "NW", "NWbN", "N-NW", "NbW" } + +-- List of angles to test +test_angles = { 0.00, 16.87, 16.88, 33.75, 50.62, 50.63, 67.50, + 84.37, 84.38, 101.25, 118.12, 118.13, 135.00, 151.87, + 151.88, 168.75, 185.62, 185.63, 202.50, 219.37, 219.38, + 236.25, 253.12, 253.13, 270.00, 286.87, 286.88, 303.75, + 320.62, 320.63, 337.50, 354.37, 354.38 } + + +-- capitalize a string +function capitalize(s) + return s:sub(1,1):upper() .. s:sub(2) +end + +-- convert compass point abbreviation to full text of label +function expand_point(abbr) + for from, to in pairs( { N="north", E="east", S="south", W="west", + b=" by " }) do + abbr = abbr:gsub(from, to) + end + return capitalize(abbr) +end + +-- modulus function that returns 1..N instead of 0..N-1 +function adjusted_modulo(n, d) + return 1 + (n - 1) % d +end + +-- convert a compass angle from degrees into a box index (1..32) +function compass_point(degrees) + degrees = degrees % 360 + return adjusted_modulo(1 + math.floor( (degrees+5.625) / 11.25), 32) +end + +-- Now output the table of test data +header_format = "%-7s | %-18s | %s" +row_format = "%7.2f | %-18s | %2d" +print(header_format:format("Degrees", "Closest Point", "Index")) +for i, angle in ipairs(test_angles) do + index = compass_point(angle) + abbr = compass_points[index] + label = expand_point(abbr) + print(row_format:format(angle, label, index)) +end diff --git a/Task/Box-the-compass/MATLAB/box-the-compass.m b/Task/Box-the-compass/MATLAB/box-the-compass.m new file mode 100644 index 0000000000..4d8cf9e00f --- /dev/null +++ b/Task/Box-the-compass/MATLAB/box-the-compass.m @@ -0,0 +1,3 @@ +function b = compassbox(d) + b = ceil(mod(d+360/64,360)*32/360); +end; diff --git a/Task/Box-the-compass/Perl/box-the-compass-1.pl b/Task/Box-the-compass/Perl/box-the-compass-1.pl new file mode 100644 index 0000000000..0908b83cc5 --- /dev/null +++ b/Task/Box-the-compass/Perl/box-the-compass-1.pl @@ -0,0 +1,45 @@ +use utf8; + +my @names = ( + "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", + "South", + "South by west", + "South-southwest", + "Southwest by south", + "Southwest", + "Southwest by west", + "West-southwest", + "West by south", + "West", + "West by north", + "West-northwest", + "Northwest by west", + "Northwest", + "Northwest by north", + "North-northwest", + "North by west", +); +my @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, + 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38); + +for (@angles) { + my $i = int(($_ * 32 / 360) + .5) % 32; + printf "%3d %18s %6.2f°\n", $i + 1, $names[$i], $_; +} diff --git a/Task/Box-the-compass/Perl/box-the-compass-2.pl b/Task/Box-the-compass/Perl/box-the-compass-2.pl new file mode 100644 index 0000000000..f9e5009e5c --- /dev/null +++ b/Task/Box-the-compass/Perl/box-the-compass-2.pl @@ -0,0 +1,33 @@ + 1 North 0.00° + 2 North by east 16.87° + 3 North-northeast 16.88° + 4 Northeast by north 33.75° + 5 Northeast 50.62° + 6 Northeast by east 50.63° + 7 East-northeast 67.50° + 8 East by north 84.37° + 9 East 84.38° + 10 East by south 101.25° + 11 East-southeast 118.12° + 12 Southeast by east 118.13° + 13 Southeast 135.00° + 14 Southeast by south 151.87° + 15 South-southeast 151.88° + 16 South by east 168.75° + 17 South 185.62° + 18 South by west 185.63° + 19 South-southwest 202.50° + 20 Southwest by south 219.37° + 21 Southwest 219.38° + 22 Southwest by west 236.25° + 23 West-southwest 253.12° + 24 West by south 253.13° + 25 West 270.00° + 26 West by north 286.87° + 27 West-northwest 286.88° + 28 Northwest by west 303.75° + 29 Northwest 320.62° + 30 Northwest by north 320.63° + 31 North-northwest 337.50° + 32 North by west 354.37° + 1 North 354.38° diff --git a/Task/Box-the-compass/PicoLisp/box-the-compass.l b/Task/Box-the-compass/PicoLisp/box-the-compass.l new file mode 100644 index 0000000000..4301066063 --- /dev/null +++ b/Task/Box-the-compass/PicoLisp/box-the-compass.l @@ -0,0 +1,34 @@ +(scl 3) + +(setq *Compass # Build lookup table + (let H -16.875 + (mapcar + '((Str) + (cons + (inc 'H 11.25) # Heading in degrees + (pack # Compass point + (replace (chop Str) + "N" "north" + "E" "east" + "S" "south" + "W" "west" + "b" " by " ) ) ) ) + '("N" "NbE" "N-NE" "NEbN" "NE" "NEbE" "E-NE" "EbN" + "E" "EbS" "E-SE" "SEbE" "SE" "SEbS" "S-SE" "SbE" + "S" "SbW" "S-SW" "SWbS" "SW" "SWbW" "W-SW" "WbS" + "W" "WbN" "W-NW" "NWbW" "NW" "NWbN" "N-NW" "NbW" + "N" ) ) ) ) + +(de heading (Deg) + (rank (% Deg 360.00) *Compass) ) + +(for I (range 0 32) + (let H (* I 11.25) + (case (% I 3) + (1 (inc 'H 5.62)) + (2 (dec 'H 5.62)) ) + (tab (3 1 -18 8) + (inc (% I 32)) + NIL + (cdr (heading H)) + (round H 2) ) ) ) diff --git a/Task/Box-the-compass/Prolog/box-the-compass-1.pro b/Task/Box-the-compass/Prolog/box-the-compass-1.pro new file mode 100644 index 0000000000..d26a2e96de --- /dev/null +++ b/Task/Box-the-compass/Prolog/box-the-compass-1.pro @@ -0,0 +1,37 @@ +compassangle(1, 'North',n, 0.00). +compassangle(2, 'North by east', nbe, 11.25). +compassangle(3, 'North-northeast', nne,22.50). +compassangle(4, 'Northeast by north', nebn,33.75). +compassangle(5, 'Northeast', ne,45.00). +compassangle(6, 'Norteast by east', nebe,56.25). +compassangle(7, 'East-northeast', ene,67.50). +compassangle(8, 'East by North', ebn,78.75). +compassangle(9, 'East', e,90.00). +compassangle(10, 'East by south', ebs, 101.25). +compassangle(11, 'East-southeast', ese,112.50). +compassangle(12, 'Southeast by east', sebe, 123.75). +compassangle(13, 'Southeast', se, 135.00). +compassangle(14, 'Southeast by south', sebs, 146.25). +compassangle(15, 'South-southeast',sse, 157.50). +compassangle(16, 'South by east', sbe, 168.75). +compassangle(17, 'South', s, 180.00). +compassangle(18, 'South by west', sbw, 191.25). +compassangle(19, 'South-southwest', ssw, 202.50). +compassangle(20, 'Southwest by south', swbs, 213.75). +compassangle(21, 'Southwest', sw, 225.00). +compassangle(22, 'Southwest by west', swbw, 236.25). +compassangle(23, 'West-southwest', wsw, 247.50). +compassangle(24, 'West by south', wbs, 258.75). +compassangle(25, 'West', w, 270.00). +compassangle(26, 'West by north', wbn, 281.25). +compassangle(27, 'West-northwest', wnw, 292.50). +compassangle(28, 'Northwest by west', nwbw, 303.75). +compassangle(29, 'Northwest', nw, 315.00). +compassangle(30, 'Northwest by north', nwbn, 326.25). +compassangle(31, 'North-northwest', nnw, 337.50). +compassangle(32, 'North by west', nbw, 348.75). +compassangle(1, 'North', n, 360.00). +compassangle(Index , Name, Heading, Angle) :- nonvar(Angle), resolveindex(Angle, Index), + compassangle(Index,Name, Heading, _). + +resolveindex(Angle, Index) :- N is Angle / 11.25 + 0.5, I is floor(N),Index is (I mod 32) + 1. diff --git a/Task/Box-the-compass/Prolog/box-the-compass-2.pro b/Task/Box-the-compass/Prolog/box-the-compass-2.pro new file mode 100644 index 0000000000..8612c64ebc --- /dev/null +++ b/Task/Box-the-compass/Prolog/box-the-compass-2.pro @@ -0,0 +1,7 @@ +printTableRow(Angle) :- compassangle(Index, Name, _, Angle), + write(Index), write(' '), + write(Name), write(' '), + write(Angle). + +printTable([X|Xs]) :- printTableRow(X), nl, printTable(Xs),!. +printTable([]). diff --git a/Task/Box-the-compass/Prolog/box-the-compass-3.pro b/Task/Box-the-compass/Prolog/box-the-compass-3.pro new file mode 100644 index 0000000000..0bce6d621e --- /dev/null +++ b/Task/Box-the-compass/Prolog/box-the-compass-3.pro @@ -0,0 +1,36 @@ +?- printTable([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, 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38]). +1 North 0.0 +2 North by east 16.87 +3 North-northeast 16.88 +4 Northeast by north 33.75 +5 Northeast 50.62 +6 Norteast by east 50.63 +7 East-northeast 67.5 +8 East by North 84.37 +9 East 84.38 +10 East by south 101.25 +11 East-southeast 118.12 +12 Southeast by east 118.13 +13 Southeast 135.0 +14 Southeast by south 151.87 +15 South-southeast 151.88 +16 South by east 168.75 +17 South 185.62 +18 South by west 185.63 +19 South-southwest 202.5 +20 Southwest by south 219.37 +21 Southwest 219.38 +22 Southwest by west 236.25 +23 West-southwest 253.12 +24 West by south 253.13 +25 West 270.0 +26 West by north 286.87 +27 West-northwest 286.88 +28 Northwest by west 303.75 +29 Northwest 320.62 +30 Northwest by north 320.63 +31 North-northwest 337.5 +32 North by west 354.37 +1 North 354.38 +true. diff --git a/Task/Box-the-compass/Python/box-the-compass.py b/Task/Box-the-compass/Python/box-the-compass.py new file mode 100644 index 0000000000..5d00619e22 --- /dev/null +++ b/Task/Box-the-compass/Python/box-the-compass.py @@ -0,0 +1,25 @@ +majors = 'north east south west'.split() +majors *= 2 # no need for modulo later +quarter1 = 'N,N by E,N-NE,NE by N,NE,NE by E,E-NE,E by N'.split(',') +quarter2 = [p.replace('NE','EN') for p in quarter1] + +def degrees2compasspoint(d): + d = (d % 360) + 360/64 + majorindex, minor = divmod(d, 90.) + majorindex = int(majorindex) + minorindex = int( (minor*4) // 45 ) + p1, p2 = majors[majorindex: majorindex+2] + if p1 in {'north', 'south'}: + q = quarter1 + else: + q = quarter2 + return q[minorindex].replace('N', p1).replace('E', p2).capitalize() + +if __name__ == '__main__': + for i in range(33): + d = i * 11.25 + m = i % 3 + if m == 1: d += 5.62 + elif m == 2: d -= 5.62 + n = i % 32 + 1 + print( '%2i %-18s %7.2f°' % (n, degrees2compasspoint(d), d) ) diff --git a/Task/Box-the-compass/REXX/box-the-compass.rexx b/Task/Box-the-compass/REXX/box-the-compass.rexx new file mode 100644 index 0000000000..817957c82a --- /dev/null +++ b/Task/Box-the-compass/REXX/box-the-compass.rexx @@ -0,0 +1,32 @@ +/*REXX program boxes the compass (from º headings ───> 32 point set). */ + +headings=0 16.87 16.88 33.75 50.62 50.63 67.5 84.37 84.38 101.25 118.12, + 118.13 135 151.87 151.88 168.75 185.62 185.63 202.5 219.37, + 219.38 236.25 253.12 253.13 270 286.87 286.88 303.75 320.62, + 320.63 337.5 354.37 354.38 /*some sample compass headings. */ + +points='n nbe n-ne nebn ne nebe e-ne ebn e ebs e-se sebe se sebs s-se sbe', + 's sbw s-sw swbs sw swbw w-sw wbs w wbn w-nw nwbw nw nwbn n-nw nbw' + +dirs='north south east west' +@ebcdic= 1=='f1'x +if @ebcdic then degSym='a1'x + else degSym='f8'x /*although, 'a7'x looks better, */ + /*see line 1 (above).*/ +say right(degSym'heading',30) center('compass heading',20) +say right( '────────',30) copies('─' ,20) + + do j=1 for words(headings) + x=word(headings,j) + say right(format(x,,2)degSym,30-1) ' ' boxHeading(x) + end /*j*/ +exit +/*─────────────────────────────────────BOXHEADING subroutine────────────*/ +boxHeading: _=arg(1)//360; if _<0 then _=360-_ /*normalize the heading.*/ +_=word(points,trunc(max(1,(_/11.25+1.5)//33))) + do k=1 for words(dirs); d=word(dirs,k) + _=changestr(left(d,1),_,d) + end /*k*/ +return changestr('b',_," by ") + /*next statement is ignored. */ +return upper(changestr('b',_," by "),1) /*capitalizes the 1st letter.*/ diff --git a/Task/Box-the-compass/Racket/box-the-compass.rkt b/Task/Box-the-compass/Racket/box-the-compass.rkt new file mode 100644 index 0000000000..075df9bc77 --- /dev/null +++ b/Task/Box-the-compass/Racket/box-the-compass.rkt @@ -0,0 +1,55 @@ +#lang racket + +;;; Generate the headings and boxes +(define (i->heading/box i) + (values (let ((heading (* i #e11.25))) + (case (modulo i 3) + ((1) (+ heading #e5.62)) + ((2) (- heading #e5.62)) + (else heading))) + (add1 (modulo i 32)))) +(define-values (headings-list box-list) + (for/lists (h-lst i-lst) ((i (in-range 0 (add1 32)))) + (i->heading/box i))) + +(define box-names + (list "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" "South" "South by west" "South-southwest" + "Southwest by south" "Southwest" "Southwest by west" + "West-southwest" "West by south" "West" "West by north" "West-northwest" + "Northwest by west" "Northwest" "Northwest by north" "North-northwest" + "North by west")) + +(define (heading->box h) + (let* ((n-boxes (length box-names)) + (box-width (/ 360 n-boxes))) + (add1 (modulo (ceiling (- (/ h box-width) 1/2)) n-boxes)))) + +;;; displays a single row of the table, can also be used for titles +(define (display-row b a p) + (printf "~a | ~a | ~a~%" + (~a b #:width 2 #:align 'right) + (~a a #:width 6 #:align 'right) + (~a p))) + +;;; display the table +(display-row "#" "Angle" "Point") +(displayln "---+--------+-------------------") +(for ((heading headings-list)) + (let* ((box-number (heading->box heading))) + ;; by coincidence, default value of the second argument to + ;; real->decimal-string "decimal-digits" is 2,... just what we want! + (display-row box-number + (real->decimal-string heading) + (list-ref box-names (sub1 box-number))))) + +(module+ test + (require rackunit) + ;;; unit test heading->box (the business end of the implementation) + (check-= (heading->box 354.38) 1 0) + (check-= (heading->box 5.62) 1 0) + (check-= (heading->box 5.63) 2 0) + (check-= (heading->box 16.87) 2 0)) diff --git a/Task/Box-the-compass/Ruby/box-the-compass-1.rb b/Task/Box-the-compass/Ruby/box-the-compass-1.rb new file mode 100644 index 0000000000..55bb2f06eb --- /dev/null +++ b/Task/Box-the-compass/Ruby/box-the-compass-1.rb @@ -0,0 +1,16 @@ +h = [] +["north", "east", "south", "west", "north"].each_cons(2) do |a, b| + c = if ["north", "south"].include? a then "#{a}#{b}" else "#{b}#{a}" end + h << a + h << "#{a} by #{b}" + h << "#{a}-#{c}" + h << "#{c} by #{a}" + h << "#{c}" + h << "#{c} by #{b}" + h << "#{b}-#{c}" + h << "#{b} by #{a}" +end + +puts "Headings = {" +h.each_with_index { |n, i| puts " #{i+1} => #{n.inspect}," } +puts "}" diff --git a/Task/Box-the-compass/Ruby/box-the-compass-2.rb b/Task/Box-the-compass/Ruby/box-the-compass-2.rb new file mode 100644 index 0000000000..a4dea84762 --- /dev/null +++ b/Task/Box-the-compass/Ruby/box-the-compass-2.rb @@ -0,0 +1,53 @@ +Headings = { + 1 => "north", + 2 => "north by east", + 3 => "north-northeast", + 4 => "northeast by north", + 5 => "northeast", + 6 => "northeast by east", + 7 => "east-northeast", + 8 => "east by north", + 9 => "east", + 10 => "east by south", + 11 => "east-southeast", + 12 => "southeast by east", + 13 => "southeast", + 14 => "southeast by south", + 15 => "south-southeast", + 16 => "south by east", + 17 => "south", + 18 => "south by west", + 19 => "south-southwest", + 20 => "southwest by south", + 21 => "southwest", + 22 => "southwest by west", + 23 => "west-southwest", + 24 => "west by south", + 25 => "west", + 26 => "west by north", + 27 => "west-northwest", + 28 => "northwest by west", + 29 => "northwest", + 30 => "northwest by north", + 31 => "north-northwest", + 32 => "north by west", +} + +# Finds the 32-point compass heading nearest _degrees_, and +# returns an array of the index and name. +# +# p heading(60) +# # => [6, "northeast by east"] +# +def heading(degrees) + i = degrees.quo(360).*(32).round.%(32).+(1) + [i, Headings[i]] +end + +# an array of angles, in degrees +angles = (0..32).map { |i| i * 11.25 + [0, 5.62, -5.62][i % 3] } + +angles.each do |degrees| + index, name = heading degrees + printf "%2d %20s %6.2f\n", index, name.center(20), degrees +end diff --git a/Task/Box-the-compass/Scala/box-the-compass.scala b/Task/Box-the-compass/Scala/box-the-compass.scala new file mode 100644 index 0000000000..e4ca8f4f22 --- /dev/null +++ b/Task/Box-the-compass/Scala/box-the-compass.scala @@ -0,0 +1,22 @@ +object BoxingTheCompass extends App { + val cardinal = List("north", "east", "south", "west") + val pointDesc = List("1", "1 by 2", "1-C", "C by 1", "C", "C by 2", "2-C", "2 by 1") + + val pointDeg: Int => Double = i => { + val fswitch: Int => Int = i => i match {case 1 => 1; case 2 => -1; case _ => 0} + i*11.25+fswitch(i%3)*5.62 + } + + val deg2ind: Double => Int = deg => (deg*32/360+.5).toInt%32+1 + + val pointName: Int => String = ind => { + val i = ind - 1 + val str1 = cardinal(i%32/8) + val str2 = cardinal((i%32/8+1)%4) + val strC = if ((str1 == "north") || (str1 == "south")) str1+str2 else str2+str1 + pointDesc(i%32%8).replace("1", str1).replace("2", str2).replace("C", strC).capitalize + } + + (0 to 32).map(i=>Triple(pointDeg(i),deg2ind(pointDeg(i)),pointName(deg2ind(pointDeg(i))))) + .map{t=>(printf("%s\t%18s\t%s°\n",t._2,t._3,t._1))} +} diff --git a/Task/Box-the-compass/Tcl/box-the-compass.tcl b/Task/Box-the-compass/Tcl/box-the-compass.tcl new file mode 100644 index 0000000000..77ca375205 --- /dev/null +++ b/Task/Box-the-compass/Tcl/box-the-compass.tcl @@ -0,0 +1,27 @@ +proc angle2compass {angle} { + set dirs { + N NbE N-NE NEbN NE NEbE E-NE EbN E EbS E-SE SEbE SE SEbS S-SE SbE + S SbW S-SW SWbS SW SWbW W-SW WbS W WbN W-NW NWbW NW NWbN N-NW NbW + } + set unpack {N "north" E "east" W "west" S "south" b " by "} + + # Compute the width of each compass segment + set sep [expr {360.0 / [llength $dirs]}] + + # Work out which segment contains the compass angle + set dir [expr {round((fmod($angle + $sep/2, 360) - $sep/2) / $sep)}] + + # Convert to a named direction, capitalized as in the wikipedia article + return [string totitle [string map $unpack [lindex $dirs $dir]]] +} + +# Box the compass, using the variable generation algorithm described +for {set i 0} {$i < 33} {incr i} { + set heading [expr {$i * 11.25}] + if {$i % 3 == 1} {set heading [expr {$heading + 5.62}]} + if {$i % 3 == 2} {set heading [expr {$heading - 5.62}]} + set index [expr {$i % 32 + 1}] + + # Pretty-print the results of converting an angle to a compass heading + puts [format "%2i %-18s %7.2f°" $index [angle2compass $heading] $heading] +} diff --git a/Task/Break-OO-privacy/0DESCRIPTION b/Task/Break-OO-privacy/0DESCRIPTION new file mode 100644 index 0000000000..751f03af42 --- /dev/null +++ b/Task/Break-OO-privacy/0DESCRIPTION @@ -0,0 +1,3 @@ +Show how to access private or protected members of a class in an object-oriented language from outside an instance of the class, without calling non-private or non-protected members of the class as a proxy. The intent is to show how a debugger, serializer, or other meta-programming tool might access information that is barred by normal access methods to the object but can nevertheless be accessed from within the language by some provided escape hatch or reflection mechanism. The intent is specifically not to demonstrate heroic measures such as peeking and poking raw memory. + +Note that cheating on your type system is almost universally regarded as unidiomatic at best, and poor programming practice at worst. Nonetheless, if your language intentionally maintains a double-standard for OO privacy, here's where you can show it off. diff --git a/Task/Break-OO-privacy/Ada/break-oo-privacy-1.ada b/Task/Break-OO-privacy/Ada/break-oo-privacy-1.ada new file mode 100644 index 0000000000..996fc9276b --- /dev/null +++ b/Task/Break-OO-privacy/Ada/break-oo-privacy-1.ada @@ -0,0 +1,10 @@ +package OO_Privacy is + + type Confidential_Stuff is tagged private; + subtype Password_Type is String(1 .. 8); + +private + type Confidential_Stuff is tagged record + Password: Password_Type := "default!"; -- the "secret" + end record; +end OO_Privacy; diff --git a/Task/Break-OO-privacy/Ada/break-oo-privacy-2.ada b/Task/Break-OO-privacy/Ada/break-oo-privacy-2.ada new file mode 100644 index 0000000000..216ce7c3e8 --- /dev/null +++ b/Task/Break-OO-privacy/Ada/break-oo-privacy-2.ada @@ -0,0 +1,16 @@ +with OO_Privacy, Ada.Unchecked_Conversion, Ada.Text_IO; + +procedure OO_Break_Privacy is + + type Hacker_Stuff is tagged record + Password: OO_Privacy.Password_Type := "?unknown"; + end record; + + function Hack is new Ada.Unchecked_Conversion + (Source => OO_Privacy.Confidential_Stuff, Target => Hacker_Stuff); + + C: OO_Privacy.Confidential_Stuff; -- which password is hidden inside C? + +begin + Ada.Text_IO.Put_Line("The secret password is """ & Hack(C).Password & """"); +end OO_Break_Privacy; diff --git a/Task/Break-OO-privacy/Java/break-oo-privacy.java b/Task/Break-OO-privacy/Java/break-oo-privacy.java new file mode 100644 index 0000000000..7199e95572 --- /dev/null +++ b/Task/Break-OO-privacy/Java/break-oo-privacy.java @@ -0,0 +1,29 @@ +import java.lang.reflect.*; + +class Example { + private String _name; + public Example(String name) { _name = name; } + public String toString() { return "Hello, I am " + _name; } +} + +public class BreakPrivacy { + public static final void main(String[] args) throws Exception { + Example foo = new Example("Eric"); + + for (Field f : Example.class.getDeclaredFields()) { + if (f.getName().equals("_name")) { + // make it accessible + f.setAccessible(true); + + // get private field + System.out.println(f.get(foo)); + + // set private field + f.set(foo, "Edith"); + System.out.println(foo); + + break; + } + } + } +} diff --git a/Task/Break-OO-privacy/PHP/break-oo-privacy-1.php b/Task/Break-OO-privacy/PHP/break-oo-privacy-1.php new file mode 100644 index 0000000000..55fa4ec6b7 --- /dev/null +++ b/Task/Break-OO-privacy/PHP/break-oo-privacy-1.php @@ -0,0 +1,19 @@ +getProperty('foo'); +$rp->setAccessible(true); +var_dump($rp->getValue($fragile)); +$rp->setValue($fragile, 'haxxorz!'); +var_dump($rp->getValue($fragile)); +var_dump($fragile); diff --git a/Task/Break-OO-privacy/PicoLisp/break-oo-privacy-1.l b/Task/Break-OO-privacy/PicoLisp/break-oo-privacy-1.l new file mode 100644 index 0000000000..a554003dcd --- /dev/null +++ b/Task/Break-OO-privacy/PicoLisp/break-oo-privacy-1.l @@ -0,0 +1,12 @@ +(class +Example) +# "_name" + +(dm T (Name) + (=: "_name" Name) ) + +(dm string> () + (pack "Hello, I am " (: "_name")) ) + +(====) # Close transient scope + +(setq Foo (new '(+Example) "Eric")) diff --git a/Task/Break-OO-privacy/PicoLisp/break-oo-privacy-2.l b/Task/Break-OO-privacy/PicoLisp/break-oo-privacy-2.l new file mode 100644 index 0000000000..a5217ca4dc --- /dev/null +++ b/Task/Break-OO-privacy/PicoLisp/break-oo-privacy-2.l @@ -0,0 +1,20 @@ +: (string> Foo) # Access via method call +-> "Hello, I am Eric" + +: (get Foo '"_name") # Direct access doesn't work +-> NIL + +: (get Foo (loc "_name" +Example)) # Locating the transient symbol works +-> "Eric" + +: (put Foo (loc "_name" +Example) "Edith") +-> "Edith" + +: (string> Foo) # Ditto +-> "Hello, I am Edith" + +: (get Foo '"_name") +-> NIL + +: (get Foo (loc "_name" +Example)) +-> "Edith" diff --git a/Task/Break-OO-privacy/Python/break-oo-privacy.py b/Task/Break-OO-privacy/Python/break-oo-privacy.py new file mode 100644 index 0000000000..2ea5dc7828 --- /dev/null +++ b/Task/Break-OO-privacy/Python/break-oo-privacy.py @@ -0,0 +1,16 @@ +>>> class MyClassName: + __private = 123 + non_private = __private * 2 + + +>>> mine = MyClassName() +>>> mine.non_private +246 +>>> mine.__private +Traceback (most recent call last): + File "", line 1, in + mine.__private +AttributeError: 'MyClassName' object has no attribute '__private' +>>> mine._MyClassName__private +123 +>>> diff --git a/Task/Break-OO-privacy/Ruby/break-oo-privacy.rb b/Task/Break-OO-privacy/Ruby/break-oo-privacy.rb new file mode 100644 index 0000000000..1be585dd15 --- /dev/null +++ b/Task/Break-OO-privacy/Ruby/break-oo-privacy.rb @@ -0,0 +1,15 @@ +>> class Example +>> private +>> def name +>> "secret" +>> end +>> end +=> nil +>> example = Example.new +=> # +>> example.name +NoMethodError: private method `name' called for # + from (irb):10 + from :0 +>> example.send(:name) +=> "secret" diff --git a/Task/Break-OO-privacy/Tcl/break-oo-privacy.tcl b/Task/Break-OO-privacy/Tcl/break-oo-privacy.tcl new file mode 100644 index 0000000000..86f52dae6d --- /dev/null +++ b/Task/Break-OO-privacy/Tcl/break-oo-privacy.tcl @@ -0,0 +1,11 @@ +package require Tcl 8.6 + +oo::class create Example { + variable name + constructor n {set name $n} + method print {} {puts "Hello, I am $name"} +} +set e [Example new "Eric"] +$e print +set [info object namespace $e]::name "Edith" +$e print diff --git a/Task/Bulls-and-cows-Player/0DESCRIPTION b/Task/Bulls-and-cows-Player/0DESCRIPTION new file mode 100644 index 0000000000..67901ab1d9 --- /dev/null +++ b/Task/Bulls-and-cows-Player/0DESCRIPTION @@ -0,0 +1,9 @@ +The task is to write a ''player'' of the [[Bulls and cows|Bulls and Cows game]], rather than a scorer. The player should give intermediate answers that respect the scores to previous attempts. + +One method is to generate a list of all possible numbers that could be the answer, then to prune the list by keeping only those numbers that would give an equivalent score to how your last guess was scored. Your next guess can be any number from the pruned list.
+Either you guess correctly or run out of numbers to guess, which indicates a problem with the scoring. + +;Cf, +* [[Bulls and cows]] +* [[Guess the number]] +* [[Guess the number/With Feedback (Player)]] diff --git a/Task/Bulls-and-cows-Player/1META.yaml b/Task/Bulls-and-cows-Player/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/Bulls-and-cows-Player/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games 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 new file mode 100644 index 0000000000..4034dfea1c --- /dev/null +++ b/Task/Bulls-and-cows-Player/Ada/bulls-and-cows-player.ada @@ -0,0 +1,210 @@ +with Ada.Text_IO; +with Ada.Containers.Vectors; +with Ada.Numerics.Discrete_Random; + +procedure Bulls_Player is + + -- package for In-/Output of natural numbers + package Nat_IO is new Ada.Text_IO.Integer_IO (Natural); + + -- for comparing length of the vectors + use type Ada.Containers.Count_Type; + + -- number of digits + Guessing_Length : constant := 4; + + -- digit has to be from 1 to 9 + type Digit is range 1 .. 9; + -- a sequence has specified length of digits + type Sequence is array (1 .. Guessing_Length) of Digit; + + -- data structure to store the possible answers + package Sequence_Vectors is new Ada.Containers.Vectors + (Element_Type => Sequence, + Index_Type => Positive); + + -- check if sequence contains each digit only once + function Is_Valid (S : Sequence) return Boolean is + Appeared : array (Digit) of Boolean := (others => False); + begin + for I in S'Range loop + if Appeared (S (I)) then + return False; + end if; + Appeared (S (I)) := True; + end loop; + return True; + end Is_Valid; + + -- calculate all possible sequences and store them in the vector + procedure Fill_Pool (Pool : in out Sequence_Vectors.Vector) is + Finished : exception; + -- count the sequence up by one + function Next (S : Sequence) return Sequence is + Result : Sequence := S; + Index : Positive := S'Last; + begin + loop + -- overflow at a position causes next position to increase + if Result (Index) = Digit'Last then + Result (Index) := Digit'First; + -- overflow at maximum position + -- we have processed all possible values + if Index = Result'First then + raise Finished; + end if; + Index := Index - 1; + else + Result (Index) := Result (Index) + 1; + return Result; + end if; + end loop; + end Next; + X : Sequence := (others => 1); + begin + loop + -- append all valid values + if Is_Valid (X) then + Pool.Append (X); + end if; + X := Next (X); + end loop; + exception + when Finished => + -- the exception tells us that we have added all possible values + -- simply return and do nothing. + null; + end Fill_Pool; + + -- generate a random index from the pool + function Random_Index (Pool : Sequence_Vectors.Vector) return Positive is + subtype Possible_Indexes is Positive range + Pool.First_Index .. Pool.Last_Index; + package Index_Random is new Ada.Numerics.Discrete_Random + (Possible_Indexes); + Index_Gen : Index_Random.Generator; + begin + Index_Random.Reset (Index_Gen); + return Index_Random.Random (Index_Gen); + end Random_Index; + + -- get the answer from the player, simple validity tests + procedure Get_Answer (S : Sequence; Bulls, Cows : out Natural) is + Valid : Boolean := False; + begin + Bulls := 0; + Cows := 0; + while not Valid loop + -- output the sequence + Ada.Text_IO.Put ("How is the score for:"); + for I in S'Range loop + Ada.Text_IO.Put (Digit'Image (S (I))); + end loop; + Ada.Text_IO.New_Line; + begin + Ada.Text_IO.Put ("Bulls:"); + Nat_IO.Get (Bulls); + Ada.Text_IO.Put ("Cows:"); + Nat_IO.Get (Cows); + if Bulls + Cows <= Guessing_Length then + Valid := True; + else + Ada.Text_IO.Put_Line ("Invalid answer, try again."); + end if; + exception + when others => + null; + end; + end loop; + end Get_Answer; + + -- remove all sequences that wouldn't give an equivalent score + procedure Strip + (V : in out Sequence_Vectors.Vector; + S : Sequence; + Bulls, Cows : Natural) + 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; + begin + for I in Testant'Range loop + for J in S'Range loop + if Testant (I) = S (J) then + -- same digit at same position: Bull! + if I = J then + Bull_Score := Bull_Score + 1; + else + Cow_Score := Cow_Score + 1; + end if; + end if; + end loop; + end loop; + return Cow_Score /= Cows or else Bull_Score /= Bulls; + end Has_To_Be_Removed; + begin + for Index in reverse V.First_Index .. V.Last_Index loop + if Has_To_Be_Removed (Index) then + V.Delete (Index); + end if; + end loop; + end Strip; + + -- main routine + procedure Solve is + All_Sequences : Sequence_Vectors.Vector; + Test_Index : Positive; + Test_Sequence : Sequence; + Bulls, Cows : Natural; + begin + -- generate all possible sequences + Fill_Pool (All_Sequences); + loop + -- pick at random + Test_Index := Random_Index (All_Sequences); + Test_Sequence := All_Sequences.Element (Test_Index); + -- ask player + Get_Answer (Test_Sequence, Bulls, Cows); + -- hooray, we have it! + exit when Bulls = 4; + All_Sequences.Delete (Test_Index); + Strip (All_Sequences, Test_Sequence, Bulls, Cows); + exit when All_Sequences.Length <= 1; + end loop; + if All_Sequences.Length = 0 then + -- oops, shouldn't happen + Ada.Text_IO.Put_Line + ("I give up, there has to be a bug in" & + "your scoring or in my algorithm."); + else + if All_Sequences.Length = 1 then + Ada.Text_IO.Put ("The sequence you thought has to be:"); + Test_Sequence := All_Sequences.First_Element; + else + Ada.Text_IO.Put ("The sequence you thought of was:"); + end if; + for I in Test_Sequence'Range loop + Ada.Text_IO.Put (Digit'Image (Test_Sequence (I))); + end loop; + end if; + end Solve; + +begin + -- output blah blah + Ada.Text_IO.Put_Line ("Bulls and Cows, Your turn!"); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line + ("Think of a sequence of" & + Integer'Image (Guessing_Length) & + " different digits."); + Ada.Text_IO.Put_Line ("I will try to guess it. For each correctly placed"); + Ada.Text_IO.Put_Line ("digit I score 1 Bull. For each digit that is on"); + Ada.Text_IO.Put_Line ("the wrong place I score 1 Cow. After each guess"); + Ada.Text_IO.Put_Line ("you tell me my score."); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("Let's start."); + Ada.Text_IO.New_Line; + -- solve the puzzle + Solve; +end Bulls_Player; diff --git a/Task/Bulls-and-cows-Player/BBC-BASIC/bulls-and-cows-player.bbc b/Task/Bulls-and-cows-Player/BBC-BASIC/bulls-and-cows-player.bbc new file mode 100644 index 0000000000..03abf98b05 --- /dev/null +++ b/Task/Bulls-and-cows-Player/BBC-BASIC/bulls-and-cows-player.bbc @@ -0,0 +1,58 @@ + secret$ = "" + REPEAT + c$ = CHR$(&30 + RND(9)) + IF INSTR(secret$, c$) = 0 secret$ += c$ + UNTIL LEN(secret$) = 4 + + FOR i% = 1234 TO 9876 + possible$ += STR$(i%) + NEXT + + PRINT "Guess a four-digit number with no digit used twice." + guesses% = 0 + REPEAT + + IF LEN(possible$) = 4 THEN + guess$ = possible$ + ELSE + guess$ = MID$(possible$, 4*RND(LEN(possible$) / 4) - 3, 4) + ENDIF + + PRINT '"Computer guesses " guess$ + guesses% += 1 + + IF guess$ = secret$ PRINT "Correctly guessed after "; guesses% " guesses!" : END + + PROCcount(secret$, guess$, bulls%, cows%) + PRINT "giving " ;bulls% " bull(s) and " ;cows% " cow(s)." + + i% = 1 + REPEAT + temp$ = MID$(possible$, i%, 4) + PROCcount(temp$, guess$, testbulls%, testcows%) + IF bulls%=testbulls% IF cows%=testcows% THEN + i% += 4 + ELSE + possible$ = LEFT$(possible$, i%-1) + MID$(possible$, i%+4) + ENDIF + UNTIL i% > LEN(possible$) + + IF INSTR(possible$, secret$) = 0 STOP + + UNTIL FALSE + END + + DEF PROCcount(secret$, guess$, RETURN bulls%, RETURN cows%) + LOCAL i%, c$ + bulls% = 0 + cows% = 0 + FOR i% = 1 TO 4 + c$ = MID$(secret$, i%, 1) + IF MID$(guess$, i%, 1) = c$ THEN + bulls% += 1 + ELSE IF INSTR(guess$, c$) THEN + cows% += 1 + ENDIF + ENDIF + NEXT i% + ENDPROC diff --git a/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-1.c b/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-1.c new file mode 100644 index 0000000000..578b4d4731 --- /dev/null +++ b/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-1.c @@ -0,0 +1,102 @@ +#include +#include +#include +#include + +char *list; +const char *line = "--------+--------------------\n"; +int len = 0; + +int irand(int n) +{ + int r, rand_max = RAND_MAX - (RAND_MAX % n); + do { r = rand(); } while(r >= rand_max); + return r / (rand_max / n); +} + +char* get_digits(int n, char *ret) +{ + int i, j; + char d[] = "123456789"; + + for (i = 0; i < n; i++) { + j = irand(9 - i); + ret[i] = d[i + j]; + if (j) d[i + j] = d[i], d[i] = ret[i]; + } + return ret; +} + +#define MASK(x) (1 << (x - '1')) +int score(const char *digits, const char *guess, int *cow) +{ + int i, bits = 0, bull = *cow = 0; + + for (i = 0; guess[i] != '\0'; i++) + if (guess[i] != digits[i]) + bits |= MASK(digits[i]); + else ++bull; + + while (i--) *cow += ((bits & MASK(guess[i])) != 0); + + return bull; +} + +void pick(int n, int got, int marker, char *buf) +{ + int i, bits = 1; + if (got >= n) + strcpy(list + (n + 1) * len++, buf); + else + for (i = 0; i < 9; i++, bits *= 2) { + if ((marker & bits)) continue; + buf[got] = i + '1'; + pick(n, got + 1, marker | bits, buf); + } +} + +void filter(const char *buf, int n, int bull, int cow) +{ + int i = 0, c; + char *ptr = list; + + while (i < len) { + if (score(ptr, buf, &c) != bull || c != cow) + strcpy(ptr, list + --len * (n + 1)); + else + ptr += n + 1, i++; + } +} + +void game(const char *tgt, char *buf) +{ + int i, p, bull, cow, n = strlen(tgt); + + for (i = 0, p = 1; i < n && (p *= 9 - i); i++); + list = malloc(p * (n + 1)); + + pick(n, 0, 0, buf); + for (p = 1, bull = 0; n - bull; p++) { + strcpy(buf, list + (n + 1) * irand(len)); + bull = score(tgt, buf, &cow); + + printf("Guess %2d| %s (from: %d)\n" + "Score | %d bull, %d cow\n%s", + p, buf, len, bull, cow, line); + + filter(buf, n, bull, cow); + } +} + +int main(int c, char **v) +{ + int n = c > 1 ? atoi(v[1]) : 4; + + char secret[10] = "", answer[10] = ""; + srand(time(0)); + + printf("%sSecret | %s\n%s", line, get_digits(n, secret), line); + game(secret, answer); + + return 0; +} diff --git a/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-2.c b/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-2.c new file mode 100644 index 0000000000..688d32a078 --- /dev/null +++ b/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-2.c @@ -0,0 +1,15 @@ +--------+-------------------- +Secret | 5437 +--------+-------------------- +Guess 1| 7198 (from: 3024) +Score | 0 bull, 1 cow +--------+-------------------- +Guess 2| 2386 (from: 720) +Score | 0 bull, 1 cow +--------+-------------------- +Guess 3| 5743 (from: 122) +Score | 1 bull, 3 cow +--------+-------------------- +Guess 4| 5437 (from: 5) +Score | 4 bull, 0 cow +--------+-------------------- diff --git a/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-3.c b/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-3.c new file mode 100644 index 0000000000..d97d75f9a4 --- /dev/null +++ b/Task/Bulls-and-cows-Player/C/bulls-and-cows-player-3.c @@ -0,0 +1,36 @@ +--------+-------------------- +Secret | 758214936 +--------+-------------------- +Guess 1| 245863197 (from: 362880) +Score | 0 bull, 9 cow +--------+-------------------- +Guess 2| 964715382 (from: 133496) +Score | 1 bull, 8 cow +--------+-------------------- +Guess 3| 614927853 (from: 48722) +Score | 0 bull, 9 cow +--------+-------------------- +Guess 4| 567391248 (from: 15926) +Score | 0 bull, 9 cow +--------+-------------------- +Guess 5| 839174562 (from: 4473) +Score | 1 bull, 8 cow +--------+-------------------- +Guess 6| 489635721 (from: 1503) +Score | 0 bull, 9 cow +--------+-------------------- +Guess 7| 723156984 (from: 317) +Score | 2 bull, 7 cow +--------+-------------------- +Guess 8| 953278614 (from: 89) +Score | 2 bull, 7 cow +--------+-------------------- +Guess 9| 321479685 (from: 24) +Score | 0 bull, 9 cow +--------+-------------------- +Guess 10| 893752416 (from: 4) +Score | 1 bull, 8 cow +--------+-------------------- +Guess 11| 758214936 (from: 1) +Score | 9 bull, 0 cow +--------+-------------------- diff --git a/Task/Bulls-and-cows-Player/Fortran/bulls-and-cows-player.f b/Task/Bulls-and-cows-Player/Fortran/bulls-and-cows-player.f new file mode 100644 index 0000000000..e294172f07 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Fortran/bulls-and-cows-player.f @@ -0,0 +1,109 @@ +module Player + implicit none + +contains + +subroutine Init(candidates) + integer, intent(in out) :: candidates(:) + integer :: a, b, c, d, n + + n = 0 +thousands: do a = 1, 9 +hundreds: do b = 1, 9 +tens: do c = 1, 9 +units: do d = 1, 9 + if (b == a) cycle hundreds + if (c == b .or. c == a) cycle tens + if (d == c .or. d == b .or. d == a) cycle units + n = n + 1 + candidates(n) = a*1000 + b*100 + c*10 + d + end do units + end do tens + end do hundreds + end do thousands + +end subroutine init + +subroutine Evaluate(bulls, cows, guess, candidates) + integer, intent(in) :: bulls, cows, guess + integer, intent(in out) :: candidates(:) + integer :: b, c, s, i, j + character(4) :: n1, n2 + + write(n1, "(i4)") guess + do i = 1, size(candidates) + if (candidates(i) == 0) cycle + b = 0 + c = 0 + write(n2, "(i4)") candidates(i) + do j = 1, 4 + s = index(n1, n2(j:j)) + if(s /= 0) then + if(s == j) then + b = b + 1 + else + c = c + 1 + end if + end if + end do + if(.not.(b == bulls .and. c == cows)) candidates(i) = 0 + end do +end subroutine Evaluate + +function Nextguess(candidates) + integer :: Nextguess + integer, intent(in out) :: candidates(:) + integer :: i + + nextguess = 0 + do i = 1, size(candidates) + if(candidates(i) /= 0) then + nextguess = candidates(i) + candidates(i) = 0 + return + end if + end do +end function +end module Player + +program Bulls_Cows + use Player + implicit none + + integer :: bulls, cows, initial, guess + integer :: candidates(3024) = 0 + real :: rnum + +! Fill candidates array with all possible number combinations + call Init(candidates) + +! Random initial guess + call random_seed + call random_number(rnum) + initial = 3024 * rnum + 1 + guess = candidates(initial) + candidates(initial) = 0 + + do + write(*, "(a, i4)") "My guess is ", guess + write(*, "(a)", advance = "no") "Please score number of Bulls and Cows: " + read*, bulls, cows + write(*,*) + if (bulls == 4) then + write(*, "(a)") "Solved!" + exit + end if + +! We haven't found the solution yet so evaluate the remaining candidates +! and eliminate those that do not match the previous score given + call Evaluate(bulls, cows, guess, candidates) + +! Get the next guess from the candidates that are left + guess = Nextguess(candidates) + if(guess == 0) then +! If we get here then no solution is achievable from the scores given or the program is bugged + write(*, "(a)") "Sorry! I can't find a solution. Possible mistake in the scoring" + exit + end if + end do +end program diff --git a/Task/Bulls-and-cows-Player/Go/bulls-and-cows-player.go b/Task/Bulls-and-cows-Player/Go/bulls-and-cows-player.go new file mode 100644 index 0000000000..3c2922b703 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Go/bulls-and-cows-player.go @@ -0,0 +1,96 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +func main() { + fmt.Println(`Cows and bulls/player +You think of four digit number of unique digits in the range 1 to 9. +I guess. You score my guess: + A correct digit but not in the correct place is a cow. + A correct digit in the correct place is a bull. +You give my score as two numbers separated with a space.`) + + // generate possible patterns, store in map + m := make(map[string]int) + var g func([]byte, int) + g = func(digits []byte, fixed int) { + if fixed == 4 { + m[string(digits[:4])] = 0 + return + } + for i := fixed; i < len(digits); i++ { + digits[fixed], digits[i] = digits[i], digits[fixed] + g(digits, fixed+1) + digits[fixed], digits[i] = digits[i], digits[fixed] + } + } + g([]byte("123456789"), 0) + + // guess/score/eliminate loop + for in := bufio.NewReader(os.Stdin);; { + // pick a value, ie, guess + var guess string + for guess = range m { + delete(m, guess) + break + } + + // get and parse score + var c, b uint + for ;; fmt.Println("Score guess as two numbers: cows bulls") { + fmt.Printf("My guess: %s. Score? (c b) ", guess) + score, err := in.ReadString('\n') + if err != nil { + fmt.Println("\nSo, bye.") + return + } + s2 := strings.Fields(score) + if len(s2) == 2 { + c2, err := strconv.ParseUint(s2[0], 10, 0) + if err == nil && c2 <= 4 { + b2, err := strconv.ParseUint(s2[1], 10, 0) + if err == nil && c2+b2 <= 4 { + c = uint(c2) + b = uint(b2) + break + } + } + } + } + + // check for win + if b == 4 { + fmt.Println("I did it. :)") + return + } + + // eliminate patterns with non-matching scores + for pat := range m { + var cows, bulls uint + for ig, cg := range guess { + switch strings.IndexRune(pat, cg) { + case -1: + default: // I just think cows should go first + cows++ + case ig: + bulls++ + } + } + if cows != c || bulls != b { + delete(m, pat) + } + } + + // check for inconsistency + if len(m) == 0 { + fmt.Println("Oops, check scoring.") + return + } + } +} diff --git a/Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-1.hs b/Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-1.hs new file mode 100644 index 0000000000..c9a0255e24 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-1.hs @@ -0,0 +1,33 @@ +import Data.List +import Control.Monad +import System.Random (randomRIO) +import Data.Char(digitToInt) + +combinationsOf 0 _ = [[]] +combinationsOf _ [] = [] +combinationsOf k (x:xs) = map (x:) (combinationsOf (k-1) xs) ++ combinationsOf k xs + +player = do + let ps = concatMap permutations $ combinationsOf 4 ['1'..'9'] + play ps where + + play ps = + if null ps then + putStrLn "Unable to find a solution" + else do i <- randomRIO(0,length ps - 1) + let p = ps!!i :: String + putStrLn ("My guess is " ++ p) >> putStrLn "How many bulls and cows?" + input <- takeInput + let bc = input ::[Int] + ps' = filter((==sum bc).length. filter id. map (flip elem p)) + $ filter((==head bc).length. filter id. zipWith (==) p) ps + if length ps' == 1 then putStrLn $ "The answer is " ++ head ps' + else play ps' + + takeInput = do + inp <- getLine + let ui = map digitToInt $ take 2 $ filter(`elem` ['0'..'4']) inp + if sum ui > 4 || length ui /= 2 then + do putStrLn "Wrong input. Try again" + takeInput + else return ui diff --git a/Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-2.hs b/Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-2.hs new file mode 100644 index 0000000000..e7fe0042e7 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Haskell/bulls-and-cows-player-2.hs @@ -0,0 +1,14 @@ +*Main> player +My guess is 4923 +How many bulls and cows? +2 2 +My guess is 3924 +How many bulls and cows? +1 3 +My guess is 4329 +How many bulls and cows? +1 3 +My guess is 4932 +How many bulls and cows? +4 0 +The answer is 4932 diff --git a/Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-1.pl b/Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-1.pl new file mode 100644 index 0000000000..1a11ed2d98 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-1.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +use warnings; +use strict; +use v5.10; + +# Build a list of all possible solutions. The regular expression weeds +# out numbers containing zeroes or repeated digits. See how Perl +# automatically converts numbers to strings for us, just because we +# use them as if they were strings: +my @candidates = grep {not /0 | (\d) .* \1 /x} 1234 .. 9876; + +# Repeatedly prompt for input until the user supplies a reasonable score. +# The regex validates the user's input and then returns two numbers, +# $+{BULLS} and $+{COWS}. + +sub read_score($) { + (my $guess) = @_; + + for (;;) { + say "My guess: $guess (from ", 0+@candidates, " possibilities)"; + if (<> =~ / ^ \h* (? \d) \h* (? \d) \h* $ /x and + $+{BULLS} + $+{COWS} <= 4) { + return ($+{BULLS}, $+{COWS}); + } + + say "Please specify the number of bulls and the number of cows"; + } +} + +sub score_correct($$$$) { + my ($a, $b, $bulls, $cows) = @_; + + # Count the positions at which the digits match: + my $exact = () = grep {substr($a, $_, 1) eq substr($b, $_, 1)} 0 .. 3; + + # Cross-match all digits in $a against all digits in $b, using a regex + # (specifically, a character class) instead of an explicit loop: + my $loose = () = $a =~ /[$b]/g; + + return $bulls == $exact && $cows == $loose - $exact; +} + +do { + # Pick a number, display it, get the score, and discard candidates + # that don't match the score: + my $guess = @candidates[rand @candidates]; + my ($bulls, $cows) = read_score $guess; + @candidates = grep {score_correct $_, $guess, $bulls, $cows} @candidates; +} while (@candidates > 1); + +say(@candidates? + "Your secret number is @candidates": + "I think you made a mistake with your scoring"); diff --git a/Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-2.pl b/Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-2.pl new file mode 100644 index 0000000000..24f58cf247 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Perl/bulls-and-cows-player-2.pl @@ -0,0 +1,11 @@ +msl@64Lucid:~/perl$ ./bulls-and-cows +My guess: 1869 (from 3024 possibilities) +1 0 +My guess: 3265 (from 240 possibilities) +0 2 +My guess: 7853 (from 66 possibilities) +1 2 +My guess: 7539 (from 7 possibilities) +0 3 +Your secret number is 1357 +msl@64Lucid:~/perl$ diff --git a/Task/Bulls-and-cows-Player/PicoLisp/bulls-and-cows-player.l b/Task/Bulls-and-cows-Player/PicoLisp/bulls-and-cows-player.l new file mode 100644 index 0000000000..9cd3ad279d --- /dev/null +++ b/Task/Bulls-and-cows-Player/PicoLisp/bulls-and-cows-player.l @@ -0,0 +1,19 @@ +(load "@lib/simul.l") + +(de bullsAndCows () + (let Choices (shuffle (mapcan permute (subsets 4 (range 1 9)))) + (use (Guess Bulls Cows) + (loop + (prinl "Guessing " (setq Guess (pop 'Choices))) + (prin "How many bulls and cows? ") + (setq Bulls (read) Cows (read)) + (setq Choices + (filter + '((C) + (let B (cnt = Guess C) + (and + (= Bulls B) + (= Cows (- (length (sect Guess C)) B)) ) ) ) + Choices ) ) + (NIL Choices "No matching solution") + (NIL (cdr Choices) (pack "The answer is " (car Choices))) ) ) ) ) diff --git a/Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-1.pro b/Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-1.pro new file mode 100644 index 0000000000..cd7a55deac --- /dev/null +++ b/Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-1.pro @@ -0,0 +1,132 @@ +:- module('ia.pl', [tirage/1]). +:- use_module(library(clpfd)). + +% to store the previous guesses and the answers +:- dynamic guess/2. + +% parameters of the engine + +% length of the guess +proposition(4). + +% Numbers of digits +% 0 -> 8 +digits(8). + + +% tirage(-) +tirage(Ms) :- + % are there previous guesses ? + ( bagof([P, R], guess(P,R), Propositions) + -> tirage(Propositions, Ms) + ; % First try + tirage_1(Ms)), + !. + +% tirage_1(-) +% We choose the first Len numbers +tirage_1(L):- + proposition(Len), + Max is Len-1, + numlist(0, Max, L). + + +% tirage(+,-) +tirage(L, Ms) :- + proposition(Len), + length(Ms, Len), + + digits(Digits), + + % The guess continas only this numbers + Ms ins 0..Digits, + all_different(Ms), + + % post the constraints + maplist(placees(Ms), L), + + % compute a possible solution + label(Ms). + +% placees(+, +]) +placees(Sol, [Prop, [BP, MP]]) :- + V #= 0, + + % compute the numbers of digits in good places + compte_bien_placees(Sol, Prop, V, BP1), + BP1 #= BP, + + % compute the numbers of digits inbad places + compte_mal_placees(Sol, Prop, 0, V, MP1), + MP1 #= MP. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% compte_mal_placees(+, +, +, +, -). +% @arg1 : guess to create +% @arg2 : guess already used +% @arg3 : range of the first digit of the previuos arg +% @arg4 : current counter of the digit in bad places +% @arg5 : final counter of the digit in bad places +% +% +compte_mal_placees(_, [], _, MP, MP). + +compte_mal_placees(Sol, [H | T], N, MPC, MPF) :- + compte_une_mal_placee(H, N, Sol, 0, 0, VF), + MPC1 #= MPC + VF, + N1 is N+1, + compte_mal_placees(Sol, T, N1, MPC1, MPF). + + +% Here we check one digit of an already done guess +% compte_une_mal_placee(+, +, +, +, -). +% @arg1 : the digit +% @arg2 : range of this digit +% @arg3 : guess to create +% we check each digit of this guess +% @arg4 : range of the digit of this guess +% @arg5 : current counter of the digit in bad places +% @arg6 : final counter of the digit in bad places +% +compte_une_mal_placee(_H, _N, [], _, TT, TT). + +% digit in the same range, continue +compte_une_mal_placee(H, NH, [_H1 | T], NH, TTC, TTF) :- + NH1 is NH + 1, !, + compte_une_mal_placee(H, NH, T, NH1, TTC, TTF). + +% same digit in different places +% increment the counter and continue continue +compte_une_mal_placee(H, NH, [H1 | T], NH1, TTC, TTF) :- + H #= H1, + NH \= NH1, + NH2 is NH1 + 1, + TTC1 #= TTC + 1, + compte_une_mal_placee(H, NH, T, NH2, TTC1, TTF). + +compte_une_mal_placee(H, NH, [H1 | T], NH1, TTC, TTF) :- + H #\= H1, + NH2 is NH1 + 1, + compte_une_mal_placee(H, NH, T, NH2, TTC, TTF). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% compte_bien_placees(+, +, +, -) +% @arg1 : guess to create +% @arg2 : previous guess +% @arg3 : current counter of the digit in good places +% @arg4 : final counter of the digit in good places +% +% +compte_bien_placees([], [], MP, MP). + +compte_bien_placees([H | T], [H1 | T1], MPC, MPF) :- + H #= H1, + MPC1 #= MPC + 1, + compte_bien_placees(T, T1, MPC1, MPF). + +compte_bien_placees([H | T], [H1 | T1], MPC, MPF) :- + H #\= H1, + compte_bien_placees(T, T1, MPC, MPF). diff --git a/Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-2.pro b/Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-2.pro new file mode 100644 index 0000000000..4c7789bddf --- /dev/null +++ b/Task/Bulls-and-cows-Player/Prolog/bulls-and-cows-player-2.pro @@ -0,0 +1,21 @@ +bulls_and_cows :- + retractall('ia.pl':guess(_,_)), + retractall(coups(_)), + assert(coups(1)), + + repeat, + ( tirage(Ms) + -> maplist(add_1, Ms, Ms1), + atomic_list_concat(Ms1, Guess), + retract(coups(Coup)), + Coup_1 is Coup + 1, + assert(coups(Coup_1)), + format('~w My guess ~w~n', [Coup, Guess]), + write('Bulls : '), read(Bulls), + write('Cows : '), read(Cows), nl, + assert('ia.pl':guess(Ms, [Bulls, Cows])), + Bulls = 4 + ; writeln('Sorry, I can''t find a solution !'), true). + +add_1(X, Y) :- + Y is X + 1. diff --git a/Task/Bulls-and-cows-Player/Python/bulls-and-cows-player.py b/Task/Bulls-and-cows-Player/Python/bulls-and-cows-player.py new file mode 100644 index 0000000000..99d20e215a --- /dev/null +++ b/Task/Bulls-and-cows-Player/Python/bulls-and-cows-player.py @@ -0,0 +1,55 @@ +from itertools import permutations +from random import shuffle + +try: + raw_input +except: + raw_input = input +try: + from itertools import izip +except: + izip = zip + +digits = '123456789' +size = 4 + +def parse_score(score): + score = score.strip().split(',') + return tuple(int(s.strip()) for s in score) + +def scorecalc(guess, chosen): + bulls = cows = 0 + for g,c in izip(guess, chosen): + if g == c: + bulls += 1 + elif g in chosen: + cows += 1 + return bulls, cows + +choices = list(permutations(digits, size)) +shuffle(choices) +answers = [] +scores = [] + +print ("Playing Bulls & Cows with %i unique digits\n" % size) + +while True: + ans = choices[0] + answers.append(ans) + #print ("(Narrowed to %i possibilities)" % len(choices)) + score = raw_input("Guess %2i is %*s. Answer (Bulls, cows)? " + % (len(answers), size, ''.join(ans))) + score = parse_score(score) + scores.append(score) + #print("Bulls: %i, Cows: %i" % score) + found = score == (size, 0) + if found: + print ("Ye-haw!") + break + choices = [c for c in choices if scorecalc(c, ans) == score] + if not choices: + print ("Bad scoring? nothing fits those scores you gave:") + print (' ' + + '\n '.join("%s -> %s" % (''.join(an),sc) + for an,sc in izip(answers, scores))) + break diff --git a/Task/Bulls-and-cows-Player/Ruby/bulls-and-cows-player.rb b/Task/Bulls-and-cows-Player/Ruby/bulls-and-cows-player.rb new file mode 100644 index 0000000000..eae18d3cfa --- /dev/null +++ b/Task/Bulls-and-cows-Player/Ruby/bulls-and-cows-player.rb @@ -0,0 +1,28 @@ +size = 4 +scores = [] +guesses = [] +puts "Playing Bulls & Cows with #{size} unique digits." +possible_guesses = ('1'..'9').to_a.permutation(size).to_a.shuffle + +while + guesses << current_guess = possible_guesses.pop + print "Guess #{guesses.size} is #{current_guess.join}. Answer (bulls,cows)? " + scores << score = gets.split(',').map(&:to_i) + + # handle win + break (puts "Yeah!") if score == [size,0] + + # filter possible guesses + possible_guesses.select! do |pos_guess| + bulls = pos_guess.zip(current_guess).count{|digit_pair| digit_pair[0] == digit_pair[1]} + cows = pos_guess.count{|digit| current_guess.include?( digit )} - bulls + [bulls, cows] == score + end + + # handle 'no possible guesses left' + if possible_guesses.empty? then + puts "Error in scoring?" + guesses.zip(scores).each{|g, (b, c)| puts "#{g.join} => bulls #{b} cows #{c}"} + break + end +end diff --git a/Task/Bulls-and-cows-Player/Tcl/bulls-and-cows-player.tcl b/Task/Bulls-and-cows-Player/Tcl/bulls-and-cows-player.tcl new file mode 100644 index 0000000000..40f4fb3cbd --- /dev/null +++ b/Task/Bulls-and-cows-Player/Tcl/bulls-and-cows-player.tcl @@ -0,0 +1,52 @@ +package require struct::list +package require struct::set + +proc scorecalc {guess chosen} { + set bulls 0 + set cows 0 + foreach g $guess c $chosen { + if {$g eq $c} { + incr bulls + } elseif {$g in $chosen} { + incr cows + } + } + return [list $bulls $cows] +} + +# Allow override on command line +set size [expr {$argc ? int($argv) : 4}] + +set choices {} +struct::list foreachperm p [split 123456789 ""] { + struct::set include choices [lrange $p 1 $size] +} +set answers {} +set scores {} + +puts "Playing Bulls & Cows with $size unique digits\n" +fconfigure stdout -buffering none +while 1 { + set ans [lindex $choices [expr {int(rand()*[llength $choices])}]] + lappend answers $ans + puts -nonewline \ + "Guess [llength $answers] is [join $ans {}]. Answer (Bulls, cows)? " + set score [scan [gets stdin] %d,%d] + lappend scores $score + if {$score eq {$size 0}} { + puts "Ye-haw!" + break + } + foreach c $choices[set choices {}] { + if {[scorecalc $c $ans] eq $score} { + lappend choices $c + } + } + if {![llength $choices]} { + puts "Bad scoring? nothing fits those scores you gave:" + foreach a $answers s $scores { + puts " [join $a {}] -> ([lindex $s 0], [lindex $s 1])" + } + break + } +} diff --git a/Task/Bulls-and-cows/BBC-BASIC/bulls-and-cows.bbc b/Task/Bulls-and-cows/BBC-BASIC/bulls-and-cows.bbc new file mode 100644 index 0000000000..e67d866837 --- /dev/null +++ b/Task/Bulls-and-cows/BBC-BASIC/bulls-and-cows.bbc @@ -0,0 +1,32 @@ + secret$ = "" + REPEAT + c$ = CHR$(&30 + RND(9)) + IF INSTR(secret$, c$) = 0 secret$ += c$ + UNTIL LEN(secret$) = 4 + + PRINT "Guess a four-digit number with no digit used twice."' + guesses% = 0 + REPEAT + + REPEAT + INPUT "Enter your guess: " guess$ + IF LEN(guess$) <> 4 PRINT "Must be a four-digit number" + UNTIL LEN(guess$) = 4 + guesses% += 1 + + IF guess$ = secret$ PRINT "You won after "; guesses% " guesses!" : END + + bulls% = 0 + cows% = 0 + FOR i% = 1 TO 4 + c$ = MID$(secret$, i%, 1) + IF MID$(guess$, i%, 1) = c$ THEN + bulls% += 1 + ELSE IF INSTR(guess$, c$) THEN + cows% += 1 + ENDIF + ENDIF + NEXT i% + PRINT "You got " ;bulls% " bull(s) and " ;cows% " cow(s)." + + UNTIL FALSE diff --git a/Task/Bulls-and-cows/Brat/bulls-and-cows.brat b/Task/Bulls-and-cows/Brat/bulls-and-cows.brat new file mode 100644 index 0000000000..8621de4496 --- /dev/null +++ b/Task/Bulls-and-cows/Brat/bulls-and-cows.brat @@ -0,0 +1,39 @@ +secret_length = 4 + +secret = [1 2 3 4 5 6 7 8 9].shuffle.pop secret_length + +score = { guess | + cows = 0 + bulls = 0 + + guess.each_with_index { digit, index | + true? digit == secret[index] + { bulls = bulls + 1 } + { true? secret.include?(digit) + { cows = cows + 1 } + } + } + + [cows: cows, bulls: bulls] +} + +won = false +guesses = 1 + +p "I have chosen a number with four unique digits from 1 through 9. Can you guess it?" + +while { not won } + { + print "Guess #{guesses}: " + guess = g.strip.dice.map { d | d.to_i } + + when { guess == secret } { p "You won in #{guesses} guesses!"; won = true } + { guess.include?(0) || guess.include?(null) } { p "Your guess should only include digits 1 through 9." } + { guess.length != secret.length } { p "Your guess was not the correct length. The number has exactly #{secret.length} digits." } + { guess.unique.length != secret.length } { p "Each digit should only appear once in your guess." } + { true } { + result = score guess + p "Score: #{result[:bulls]} bulls, #{result[:cows]} cows." + guesses = guesses + 1 + } + } diff --git a/Task/Caesar-cipher/BBC-BASIC/caesar-cipher.bbc b/Task/Caesar-cipher/BBC-BASIC/caesar-cipher.bbc new file mode 100644 index 0000000000..923cbc9602 --- /dev/null +++ b/Task/Caesar-cipher/BBC-BASIC/caesar-cipher.bbc @@ -0,0 +1,22 @@ + plaintext$ = "Pack my box with five dozen liquor jugs" + PRINT plaintext$ + + key% = RND(25) + cyphertext$ = FNcaesar(plaintext$, key%) + PRINT cyphertext$ + + decyphered$ = FNcaesar(cyphertext$, 26-key%) + PRINT decyphered$ + + END + + DEF FNcaesar(text$, key%) + LOCAL I%, C% + FOR I% = 1 TO LEN(text$) + C% = ASC(MID$(text$,I%)) + IF (C% AND &1F) >= 1 AND (C% AND &1F) <= 26 THEN + C% = (C% AND &E0) OR (((C% AND &1F) + key% - 1) MOD 26 + 1) + MID$(text$, I%, 1) = CHR$(C%) + ENDIF + NEXT + = text$ diff --git a/Task/Calendar/BBC-BASIC/calendar.bbc b/Task/Calendar/BBC-BASIC/calendar.bbc new file mode 100644 index 0000000000..2da9609ac4 --- /dev/null +++ b/Task/Calendar/BBC-BASIC/calendar.bbc @@ -0,0 +1,35 @@ + INSTALL @lib$+"DATELIB" + VDU 23,22,640;570;8,15,16,128 + + year% = 1969 + PRINT TAB(38); year% + DIM dom%(2), mjd%(2), dim%(2) + + FOR day% = 1 TO 7 + days$ += LEFT$(FN_date$(FN_mjd(day%, 1, 1905), "ddd"), 2) + " " + NEXT + + FOR month% = 1 TO 10 STEP 3 + PRINT + FOR col% = 0 TO 2 + mjd%(col%) = FN_mjd(1, month% + col%, year%) + month$ = FN_date$(mjd%(col%), "MMMM") + PRINT TAB(col%*24 + 16 - LEN(month$)/2) month$; + NEXT + FOR col% = 0 TO 2 + PRINT TAB(col%*24 + 6) days$; + dim%(col%) = FN_dim(month% + col%, year%) + NEXT + dom%() = 1 + col% = 0 + REPEAT + dow% = FN_dow(mjd%(col%)) + IF dom%(col%)<=dim%(col%) THEN + PRINT TAB(col%*24 + dow%*3 + 6); dom%(col%); + dom%(col%) += 1 + mjd%(col%) += 1 + ENDIF + IF dow%=6 OR dom%(col%)>dim%(col%) col% = (col% + 1) MOD 3 + UNTIL dom%(0)>dim%(0) AND dom%(1)>dim%(1) AND dom%(2)>dim%(2) + PRINT + NEXT diff --git a/Task/Check-that-file-exists/BBC-BASIC/check-that-file-exists.bbc b/Task/Check-that-file-exists/BBC-BASIC/check-that-file-exists.bbc new file mode 100644 index 0000000000..fb59416a7b --- /dev/null +++ b/Task/Check-that-file-exists/BBC-BASIC/check-that-file-exists.bbc @@ -0,0 +1,23 @@ + test% = OPENIN("input.txt") + IF test% THEN + CLOSE #test% + PRINT "File input.txt exists" + ENDIF + + test% = OPENIN("\input.txt") + IF test% THEN + CLOSE #test% + PRINT "File \input.txt exists" + ENDIF + + test% = OPENIN("docs\NUL") + IF test% THEN + CLOSE #test% + PRINT "Directory docs exists" + ENDIF + + test% = OPENIN("\docs\NUL") + IF test% THEN + CLOSE #test% + PRINT "Directory \docs exists" + ENDIF diff --git a/Task/Check-that-file-exists/Batch-File/check-that-file-exists.bat b/Task/Check-that-file-exists/Batch-File/check-that-file-exists.bat new file mode 100644 index 0000000000..ce56d77dd2 --- /dev/null +++ b/Task/Check-that-file-exists/Batch-File/check-that-file-exists.bat @@ -0,0 +1,4 @@ +if exist input.txt echo The following file called input.txt exists. +if exist \input.txt echo The following file called \input.txt exists. +if exist docs echo The following directory called docs exists. +if exist \docs\ echo The following directory called \docs\ exists. diff --git a/Task/Checkpoint-synchronization/BBC-BASIC/checkpoint-synchronization.bbc b/Task/Checkpoint-synchronization/BBC-BASIC/checkpoint-synchronization.bbc new file mode 100644 index 0000000000..58b1306e7f --- /dev/null +++ b/Task/Checkpoint-synchronization/BBC-BASIC/checkpoint-synchronization.bbc @@ -0,0 +1,59 @@ + INSTALL @lib$+"TIMERLIB" + nWorkers% = 3 + DIM tID%(nWorkers%) + + tID%(1) = FN_ontimer(10, PROCworker1, 1) + tID%(2) = FN_ontimer(11, PROCworker2, 1) + tID%(3) = FN_ontimer(12, PROCworker3, 1) + + DEF PROCworker1 : PROCtask(1) : ENDPROC + DEF PROCworker2 : PROCtask(2) : ENDPROC + DEF PROCworker3 : PROCtask(3) : ENDPROC + + ON ERROR PROCcleanup : REPORT : PRINT : END + ON CLOSE PROCcleanup : QUIT + + REPEAT + WAIT 0 + UNTIL FALSE + END + + DEF PROCtask(worker%) + PRIVATE cnt%() + DIM cnt%(nWorkers%) + CASE cnt%(worker%) OF + WHEN 0: + cnt%(worker%) = RND(30) + PRINT "Worker "; worker% " starting (" ;cnt%(worker%) " ticks)" + WHEN -1: + OTHERWISE: + cnt%(worker%) -= 1 + IF cnt%(worker%) = 0 THEN + PRINT "Worker "; worker% " ready and waiting" + cnt%(worker%) = -1 + PROCcheckpoint + cnt%(worker%) = 0 + ENDIF + ENDCASE + ENDPROC + + DEF PROCcheckpoint + PRIVATE checked%, sync% + IF checked% = 0 sync% = FALSE + checked% += 1 + WHILE NOT sync% + WAIT 0 + IF checked% = nWorkers% THEN + sync% = TRUE + PRINT "--Sync Point--" + ENDIF + ENDWHILE + checked% -= 1 + ENDPROC + + DEF PROCcleanup + LOCAL I% + FOR I% = 1 TO nWorkers% + PROC_killtimer(tID%(I%)) + NEXT + ENDPROC diff --git a/Task/Classes/BBC-BASIC/classes.bbc b/Task/Classes/BBC-BASIC/classes.bbc new file mode 100644 index 0000000000..27546bbe31 --- /dev/null +++ b/Task/Classes/BBC-BASIC/classes.bbc @@ -0,0 +1,18 @@ + INSTALL @lib$+"CLASSLIB" + + REM Declare the class: + DIM MyClass{variable, @constructor, _method} + DEF MyClass.@constructor MyClass.variable = PI : ENDPROC + DEF MyClass._method = MyClass.variable ^ 2 + + REM Register the class: + PROC_class(MyClass{}) + + REM Instantiate the class: + PROC_new(myclass{}, MyClass{}) + + REM Call the method: + PRINT FN(myclass._method) + + REM Discard the instance: + PROC_discard(myclass{}) diff --git a/Task/Closest-pair-problem/BBC-BASIC/closest-pair-problem.bbc b/Task/Closest-pair-problem/BBC-BASIC/closest-pair-problem.bbc new file mode 100644 index 0000000000..b3ac75f765 --- /dev/null +++ b/Task/Closest-pair-problem/BBC-BASIC/closest-pair-problem.bbc @@ -0,0 +1,26 @@ + DIM x(9), y(9) + + FOR I% = 0 TO 9 + READ x(I%), y(I%) + NEXT + + min = 1E30 + FOR I% = 0 TO 8 + FOR J% = I%+1 TO 9 + dsq = (x(I%) - x(J%))^2 + (y(I%) - y(J%))^2 + IF dsq < min min = dsq : mini% = I% : minj% = J% + NEXT + NEXT I% + PRINT "Closest pair is ";mini% " and ";minj% " at distance "; SQR(min) + END + + DATA 0.654682, 0.925557 + DATA 0.409382, 0.619391 + DATA 0.891663, 0.888594 + DATA 0.716629, 0.996200 + DATA 0.477721, 0.946355 + DATA 0.925092, 0.818220 + DATA 0.624291, 0.142924 + DATA 0.211332, 0.221507 + DATA 0.293786, 0.691701 + DATA 0.839186, 0.728260 diff --git a/Task/Collections/BBC-BASIC/collections-1.bbc b/Task/Collections/BBC-BASIC/collections-1.bbc new file mode 100644 index 0000000000..a41d719f40 --- /dev/null +++ b/Task/Collections/BBC-BASIC/collections-1.bbc @@ -0,0 +1,3 @@ + DIM text$(1) + text$(0) = "Hello " + text$(1) = "world!" diff --git a/Task/Collections/BBC-BASIC/collections-2.bbc b/Task/Collections/BBC-BASIC/collections-2.bbc new file mode 100644 index 0000000000..fd66cdc628 --- /dev/null +++ b/Task/Collections/BBC-BASIC/collections-2.bbc @@ -0,0 +1,5 @@ + DIM collection{(1) name$, year%} + collection{(0)}.name$ = "Richard" + collection{(0)}.year% = 1952 + collection{(1)}.name$ = "Sue" + collection{(1)}.year% = 1950 diff --git a/Task/Collections/BBC-BASIC/collections-3.bbc b/Task/Collections/BBC-BASIC/collections-3.bbc new file mode 100644 index 0000000000..5d7f6cdd1b --- /dev/null +++ b/Task/Collections/BBC-BASIC/collections-3.bbc @@ -0,0 +1,24 @@ + DIM node{name$, year%, link%} + list% = 0 + PROCadd(list%, node{}, "Richard", 1952) + PROCadd(list%, node{}, "Sue", 1950) + PROClist(list%, node{}) + END + + DEF PROCadd(RETURN l%, c{}, n$, y%) + LOCAL p% + DIM p% DIM(c{})-1 + !(^c{}+4) = p% + c.name$ = n$ + c.year% = y% + c.link% = l% + l% = p% + ENDPROC + + DEF PROClist(l%, c{}) + WHILE l% + !(^c{}+4) = l% + PRINT c.name$, c.year% + l% = c.link% + ENDWHILE + ENDPROC diff --git a/Task/Color-of-a-screen-pixel/BBC-BASIC/color-of-a-screen-pixel.bbc b/Task/Color-of-a-screen-pixel/BBC-BASIC/color-of-a-screen-pixel.bbc new file mode 100644 index 0000000000..b66f8534df --- /dev/null +++ b/Task/Color-of-a-screen-pixel/BBC-BASIC/color-of-a-screen-pixel.bbc @@ -0,0 +1,2 @@ + palette_index% = POINT(x%, y%) + RGB24b_colour% = TINT(x%, y%) diff --git a/Task/Comments/BBC-BASIC/comments.bbc b/Task/Comments/BBC-BASIC/comments.bbc new file mode 100644 index 0000000000..307e32b2c4 --- /dev/null +++ b/Task/Comments/BBC-BASIC/comments.bbc @@ -0,0 +1,2 @@ + REM This is a comment which is ignored by the compiler + *| This is a comment which is compiled but ignored at run time diff --git a/Task/Comments/Batch-File/comments-1.bat b/Task/Comments/Batch-File/comments-1.bat new file mode 100644 index 0000000000..77af79a259 --- /dev/null +++ b/Task/Comments/Batch-File/comments-1.bat @@ -0,0 +1 @@ +rem Single-line comment. diff --git a/Task/Comments/Batch-File/comments-2.bat b/Task/Comments/Batch-File/comments-2.bat new file mode 100644 index 0000000000..86f1456b74 --- /dev/null +++ b/Task/Comments/Batch-File/comments-2.bat @@ -0,0 +1,2 @@ +:: Another option, though unsupported and known +:: to fail in some cases. Best avoided. diff --git a/Task/Comments/Blast/comments.blast b/Task/Comments/Blast/comments.blast new file mode 100644 index 0000000000..5b8e71fcd6 --- /dev/null +++ b/Task/Comments/Blast/comments.blast @@ -0,0 +1 @@ +# A hash symbol at the beginning of a line marks the line as a comment diff --git a/Task/Comments/Brainf---/comments.bf b/Task/Comments/Brainf---/comments.bf new file mode 100644 index 0000000000..3ff6063990 --- /dev/null +++ b/Task/Comments/Brainf---/comments.bf @@ -0,0 +1 @@ +This is a comment diff --git a/Task/Comments/Brat/comments.brat b/Task/Comments/Brat/comments.brat new file mode 100644 index 0000000000..a4ebc602df --- /dev/null +++ b/Task/Comments/Brat/comments.brat @@ -0,0 +1,5 @@ +# Single line comment + +#* Multi + Line + Comment *# diff --git a/Task/Comments/Brlcad/comments.brlcad b/Task/Comments/Brlcad/comments.brlcad new file mode 100644 index 0000000000..c2a9822b9e --- /dev/null +++ b/Task/Comments/Brlcad/comments.brlcad @@ -0,0 +1,2 @@ + # Comments in mget scripts are prefixed with a hash symbol + ls # comments may appear at the end of a line diff --git a/Task/Comments/Burlesque/comments-1.blq b/Task/Comments/Burlesque/comments-1.blq new file mode 100644 index 0000000000..f89264b91b --- /dev/null +++ b/Task/Comments/Burlesque/comments-1.blq @@ -0,0 +1 @@ +"I'm sort of a comment"vv diff --git a/Task/Comments/Burlesque/comments-2.blq b/Task/Comments/Burlesque/comments-2.blq new file mode 100644 index 0000000000..81dc8e0957 --- /dev/null +++ b/Task/Comments/Burlesque/comments-2.blq @@ -0,0 +1,3 @@ +"I'm a +very long comment spanning +over several lines"vv diff --git a/Task/Death-Star/Brlcad/death-star.brlcad b/Task/Death-Star/Brlcad/death-star.brlcad new file mode 100644 index 0000000000..7cb55735f2 --- /dev/null +++ b/Task/Death-Star/Brlcad/death-star.brlcad @@ -0,0 +1,26 @@ +# We need a database to hold the objects +opendb deathstar.g y + +# We will be measuring in kilometers +units km + +# Create a sphere of radius 60km centred at the origin +in sph1.s sph 0 0 0 60 + +# We will be subtracting an overlapping sphere with a radius of 40km +# The resultant hole will be smaller than this, because we only +# only catch the edge +in sph2.s sph 0 90 0 40 + +# Create a region named deathstar.r which consists of big minus small sphere +r deathstar.r u sph1.s - sph2.s + +# We will use a plastic material texture with rgb colour 224,224,224 +# with specular lighting value of 0.1 and no inheritance +mater deathstar.r "plastic sp=0.1" 224 224 224 0 + +# Clear the wireframe display and draw the deathstar +B deathstar.r + +# We now trigger the raytracer to see our finished product +rt diff --git a/Task/Delete-a-file/BBC-BASIC/delete-a-file-1.bbc b/Task/Delete-a-file/BBC-BASIC/delete-a-file-1.bbc new file mode 100644 index 0000000000..eabc17a1e7 --- /dev/null +++ b/Task/Delete-a-file/BBC-BASIC/delete-a-file-1.bbc @@ -0,0 +1,4 @@ + *DELETE input.txt + *DELETE \input.txt + *RMDIR docs + *RMDIR \docs diff --git a/Task/Delete-a-file/BBC-BASIC/delete-a-file-2.bbc b/Task/Delete-a-file/BBC-BASIC/delete-a-file-2.bbc new file mode 100644 index 0000000000..d843cea9e6 --- /dev/null +++ b/Task/Delete-a-file/BBC-BASIC/delete-a-file-2.bbc @@ -0,0 +1,2 @@ + OSCLI "DELETE " + file$ + OSCLI "RMDIR " + dir$ diff --git a/Task/Delete-a-file/Batch-File/delete-a-file.bat b/Task/Delete-a-file/Batch-File/delete-a-file.bat new file mode 100644 index 0000000000..e19048a25a --- /dev/null +++ b/Task/Delete-a-file/Batch-File/delete-a-file.bat @@ -0,0 +1,5 @@ +del input.txt +rd /s /q docs + +del \input.txt +rd /s /q \docs diff --git a/Task/Detect-division-by-zero/BBC-BASIC/detect-division-by-zero.bbc b/Task/Detect-division-by-zero/BBC-BASIC/detect-division-by-zero.bbc new file mode 100644 index 0000000000..b4ac40401e --- /dev/null +++ b/Task/Detect-division-by-zero/BBC-BASIC/detect-division-by-zero.bbc @@ -0,0 +1,19 @@ + PROCdivide(-44, 0) + PROCdivide(-44, 5) + PROCdivide(0, 5) + PROCdivide(5, 0) + END + + DEF PROCdivide(numerator, denominator) + ON ERROR LOCAL IF FALSE THEN + REM 'Try' clause: + PRINT numerator / denominator + ELSE + REM 'Catch' clause: + CASE ERR OF + WHEN 18: PRINT "Division by zero" + WHEN 20: PRINT "Number too big" + OTHERWISE RESTORE LOCAL : ERROR ERR, REPORT$ + ENDCASE + ENDIF + ENDPROC diff --git a/Task/Determine-if-a-string-is-numeric/BBC-BASIC/determine-if-a-string-is-numeric.bbc b/Task/Determine-if-a-string-is-numeric/BBC-BASIC/determine-if-a-string-is-numeric.bbc new file mode 100644 index 0000000000..3f335a7964 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/BBC-BASIC/determine-if-a-string-is-numeric.bbc @@ -0,0 +1,19 @@ + REPEAT + READ N$ + IF FN_isanumber(N$) THEN + PRINT "'" N$ "' is a number" + ELSE + PRINT "'" N$ "' is NOT a number" + ENDIF + UNTIL N$ = "end" + END + + DATA "PI", "0123", "-0123", "12.30", "-12.30", "123!", "0" + DATA "0.0", ".123", "-.123", "12E3", "12E-3", "12+3", "end" + + DEF FN_isanumber(A$) + ON ERROR LOCAL = FALSE + IF EVAL("(" + A$ + ")") <> VAL(A$) THEN = FALSE + IF VAL(A$) <> 0 THEN = TRUE + IF LEFT$(A$,1) = "0" THEN = TRUE + = FALSE diff --git a/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-1.bracmat b/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-1.bracmat new file mode 100644 index 0000000000..0edd659211 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-1.bracmat @@ -0,0 +1,11 @@ +43257349578692:/ + F + +260780243875083/35587980:/ + S + +247/30:~/# + F + +80000000000:~/# + S diff --git a/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-2.bracmat b/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-2.bracmat new file mode 100644 index 0000000000..672283035d --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-2.bracmat @@ -0,0 +1,29 @@ +@("1.000-4E-10":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + F + +@("1.0004E-54328":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("-464641.0004E-54328":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("1/2.0004E-10":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + F + +@("1357E-10":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("1357e0":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("13579":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("1.246":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("0.0":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S + +@("0.0000":~/# (|"." (|? 0|`) (|~/#:>0)) (|(E|e) ~/#)) + S diff --git a/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-3.bracmat b/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-3.bracmat new file mode 100644 index 0000000000..103473b1a4 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Bracmat/determine-if-a-string-is-numeric-3.bracmat @@ -0,0 +1,35 @@ +(float2fraction= + integerPart decimalPart d1 dn exp sign +. @( !arg + : ~/#?integerPart + ( &0:?decimalPart:?d1:?dn + | "." + [?d1 + (|? 0|`) + ( &0:?decimalPart + | ~/#?decimalPart:>0 + ) + [?dn + ) + ( &0:?exp + | (E|e) ~/#?exp + ) + ) + & ( !integerPart*(-1:?sign):>0:?integerPart + | 1:?sign + ) + & !sign*(!integerPart+!decimalPart*10^(!d1+-1*!dn))*10^!exp +); + +( out$float2fraction$"1.2" +& out$float2fraction$"1.02" +& out$float2fraction$"1.01" +& out$float2fraction$"10.01" +& out$float2fraction$"10.01e10" +& out$float2fraction$"10.01e1" +& out$float2fraction$"10.01e2" +& out$float2fraction$"10.01e-2" +& out$float2fraction$"-10.01e-2" +& out$float2fraction$"-10e-2" +& out$float2fraction$"0.000" +); diff --git a/Task/Determine-if-a-string-is-numeric/Burlesque/determine-if-a-string-is-numeric.blq b/Task/Determine-if-a-string-is-numeric/Burlesque/determine-if-a-string-is-numeric.blq new file mode 100644 index 0000000000..80912116f2 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Burlesque/determine-if-a-string-is-numeric.blq @@ -0,0 +1 @@ +ps^^-]to{"Int""Double"}\/~[\/L[1==?* diff --git a/Task/Entropy/Burlesque/entropy.blq b/Task/Entropy/Burlesque/entropy.blq new file mode 100644 index 0000000000..5746359db6 --- /dev/null +++ b/Task/Entropy/Burlesque/entropy.blq @@ -0,0 +1,2 @@ +blsq ) "1223334444"F:u[vv^^{1\/?/2\/LG}m[?*++ +1.8464393446710157 diff --git a/Task/FizzBuzz/BBC-BASIC/fizzbuzz.bbc b/Task/FizzBuzz/BBC-BASIC/fizzbuzz.bbc new file mode 100644 index 0000000000..e2723d4492 --- /dev/null +++ b/Task/FizzBuzz/BBC-BASIC/fizzbuzz.bbc @@ -0,0 +1,8 @@ + FOR number% = 1 TO 100 + CASE TRUE OF + WHEN number% MOD 15 = 0: PRINT "FizzBuzz" + WHEN number% MOD 3 = 0: PRINT "Fizz" + WHEN number% MOD 5 = 0: PRINT "Buzz" + OTHERWISE: PRINT ; number% + ENDCASE + NEXT number% diff --git a/Task/FizzBuzz/Batch-File/fizzbuzz-1.bat b/Task/FizzBuzz/Batch-File/fizzbuzz-1.bat new file mode 100644 index 0000000000..8df0f500ce --- /dev/null +++ b/Task/FizzBuzz/Batch-File/fizzbuzz-1.bat @@ -0,0 +1,24 @@ +@echo off +for /L %%i in (1,1,100) do call :tester %%i +goto :eof + +:tester +set /a test = %1 %% 15 +if %test% NEQ 0 goto :NotFizzBuzz +echo FizzBuzz +goto :eof + +:NotFizzBuzz +set /a test = %1 %% 5 +if %test% NEQ 0 goto :NotBuzz +echo Buzz +goto :eof + +:NotBuzz +set /a test = %1 %% 3 +if %test% NEQ 0 goto :NotFizz +echo Fizz +goto :eof + +:NotFizz +echo %1 diff --git a/Task/FizzBuzz/Batch-File/fizzbuzz-2.bat b/Task/FizzBuzz/Batch-File/fizzbuzz-2.bat new file mode 100644 index 0000000000..f70a3296a4 --- /dev/null +++ b/Task/FizzBuzz/Batch-File/fizzbuzz-2.bat @@ -0,0 +1,28 @@ +@echo off +set n=1 +:loop +call :tester %n% +set /a n += 1 +if %n% LSS 101 goto loop +goto :eof + +:tester +set /a test = %1 %% 15 +if %test% NEQ 0 goto :NotFizzBuzz +echo FizzBuzz +goto :eof + +:NotFizzBuzz +set /a test = %1 %% 5 +if %test% NEQ 0 goto :NotBuzz +echo Buzz +goto :eof + +:NotBuzz +set /a test = %1 %% 3 +if %test% NEQ 0 goto :NotFizz +echo Fizz +goto :eof + +:NotFizz +echo %1 diff --git a/Task/FizzBuzz/Boo/fizzbuzz.boo b/Task/FizzBuzz/Boo/fizzbuzz.boo new file mode 100644 index 0000000000..f874029e84 --- /dev/null +++ b/Task/FizzBuzz/Boo/fizzbuzz.boo @@ -0,0 +1,12 @@ +def fizzbuzz(size): + for i in range(1, size): + if i%15 == 0: + print 'FizzBuzz' + elif i%5 == 0: + print 'Buzz' + elif i%3 == 0: + print 'Fizz' + else: + print i + +fizzbuzz(101) diff --git a/Task/FizzBuzz/Bracmat/fizzbuzz-1.bracmat b/Task/FizzBuzz/Bracmat/fizzbuzz-1.bracmat new file mode 100644 index 0000000000..263b073f8e --- /dev/null +++ b/Task/FizzBuzz/Bracmat/fizzbuzz-1.bracmat @@ -0,0 +1 @@ +0:?i&whl'(1+!i:<101:?i&out$(mod$(!i.3):0&(mod$(!i.5):0&FizzBuzz|Fizz)|mod$(!i.5):0&Buzz|!i)) diff --git a/Task/FizzBuzz/Bracmat/fizzbuzz-2.bracmat b/Task/FizzBuzz/Bracmat/fizzbuzz-2.bracmat new file mode 100644 index 0000000000..ba6a30a0f9 --- /dev/null +++ b/Task/FizzBuzz/Bracmat/fizzbuzz-2.bracmat @@ -0,0 +1,12 @@ + 0:?i +& whl + ' ( 1+!i:<101:?i + & out + $ ( mod$(!i.3):0 + & ( mod$(!i.5):0&FizzBuzz + | Fizz + ) + | mod$(!i.5):0&Buzz + | !i + ) + ) diff --git a/Task/FizzBuzz/Brainf---/fizzbuzz.bf b/Task/FizzBuzz/Brainf---/fizzbuzz.bf new file mode 100644 index 0000000000..55763f5e35 --- /dev/null +++ b/Task/FizzBuzz/Brainf---/fizzbuzz.bf @@ -0,0 +1,156 @@ +FizzBuzz + +Memory: + Zero + Zero + Counter 1 + Counter 2 + + Zero + ASCIIDigit 3 + ASCIIDigit 2 + ASCIIDigit 1 + + Zero + Digit 3 + Digit 2 + Digit 1 + + CopyPlace + Mod 3 + Mod 5 + PrintNumber + + TmpFlag + +Counters for the loop +++++++++++[>++++++++++[>+>+<<-]<-] + +Number representation in ASCII +>>>> +++++++++ ++++++++ ++++++++ ++++++++ ++++++++ ++++++++ [>+>+>+<<<-] +<<<< + +>> +[ + Do hundret times: + + Decrement counter + ->-> + + Increment Number + > >>+> + > >>+> + <<<< + <<<< + + Check for Overflow + ++++++++++ + >>> >>>> + >++++++++++< + [-<<< <<<<->>>> >>> >-<] + ++++++++++ + <<< <<<< + + Restore the digit + [->>>> >>>-<<< <<<<] + >>>> [-]+ >>>>[<<<< - >>>>[-]]<<<< <<<< + + If there is an overflow + >>>>[ + <<<< + + >>>----------> >>>----------<+<< <<+<< + + Check for Overflow + ++++++++++ + >> >>>> + >>++++++++++<< + [-<< <<<<->>>> >> >>-<<] + ++++++++++ + << <<<< + + Restore the digit + [->>>> >>-<< <<<<] + >>>> [-]+ >>>>[<<<< - >>>>[-]]<<<< <<<< + + If there (again) is an overflow + >>>>[ + <<<< + >>---------->> >>----------<+< <<<+< + + >>>> + [-] + ]<<<< + + >>>> + [-] + ]<<<< + + >>>> >>>> + + Set if to print the number + >>>[-]+<<< + + Handle the Mod 3 counter + [-]+++ + + >>>>[-]+<<<< + >+[-<->]+++< + [->->>>[-]<<<<] + >>>>[ + <[-]> + + [-] + Print "Fizz" + ++++++++ ++++++++ ++++++++ ++++++++ + ++++++++ ++++++++ ++++++++ ++++++++ + ++++++. + + ++++++++ ++++++++ ++++++++ ++++++++ + +++. + + ++++++++ ++++++++ +.. + + [-] + <<<--->>> + ]<<<< + + Handle the Mod 5 counter + [-]+++++ + + >>>>[-]+<<<< + >>+[-<<->>]+++++<< + [->>->>[-]<<<<] + >>>>[ + <[-]> + + [-] + Print "Buzz" + ++++++++ ++++++++ ++++++++ ++++++++ + ++++++++ ++++++++ ++++++++ ++++++++ + ++. + + ++++++++ ++++++++ ++++++++ ++++++++ + ++++++++ ++++++++ +++. + + +++++.. + + [-] + <<----->> + ]<<<< + + Check if to print the number (Leading zeros) + >>>[ + <<< <<<< <<<< + >.>.>.<<< + >>> >>>> >>>> + [-] + ]<<< + + <<<< <<<< + + Print New Line + <<<<[-]++++ ++++ ++++ +.---.[-]>> +] +<< diff --git a/Task/FizzBuzz/Brat/fizzbuzz.brat b/Task/FizzBuzz/Brat/fizzbuzz.brat new file mode 100644 index 0000000000..0d6cabf5e4 --- /dev/null +++ b/Task/FizzBuzz/Brat/fizzbuzz.brat @@ -0,0 +1,11 @@ +1.to 100 { n | + true? n % 15 == 0 + { p "FizzBuzz" } + { true? n % 3 == 0 + { p "Fizz" } + { true? n % 5 == 0 + { p "Buzz" } + { p n } + } + } + } diff --git a/Task/Forest-fire/BASIC256/forest-fire.basic256 b/Task/Forest-fire/BASIC256/forest-fire.basic256 new file mode 100644 index 0000000000..316e7df8c4 --- /dev/null +++ b/Task/Forest-fire/BASIC256/forest-fire.basic256 @@ -0,0 +1,38 @@ +N = 150 : M = 150 : P = 0.03 : F = 0.00003 + +dim f(N+2,M+2) # 1 tree, 0 empty, 2 fire +dim fn(N+2,M+2) +graphsize N,M +fastgraphics + +for x = 1 to N + for y = 1 to M + if rand<0.5 then f[x,y] = 1 + next y +next x + +while True + for x = 1 to N + for y = 1 to M + if not f[x,y] and rand

RND(1) THEN + new&(x%,y%) = 1 + GCOL 2 + PLOT 4*x%,4*y% + ENDIF + WHEN 1: + IF f > RND(1) OR old&(x%-1,y%)=2 OR old&(x%+1,y%)=2 OR \ + \ old&(x%-1,y%-1)=2 OR old&(x%,y%-1)=2 OR old&(x%+1,y%-1)=2 OR \ + \ old&(x%-1,y%+1)=2 OR old&(x%,y%+1)=2 OR old&(x%+1,y%+1)=2 THEN + new&(x%,y%) = 2 + GCOL 1 + PLOT 4*x%,4*y% + ENDIF + WHEN 2: + new&(x%,y%) = 0 + GCOL 15 + PLOT 4*x%,4*y% + ENDCASE + NEXT + NEXT x% + old&() = new&() + UNTIL FALSE diff --git a/Task/Infinity/BBC-BASIC/infinity.bbc b/Task/Infinity/BBC-BASIC/infinity.bbc new file mode 100644 index 0000000000..8d78ba71b3 --- /dev/null +++ b/Task/Infinity/BBC-BASIC/infinity.bbc @@ -0,0 +1,19 @@ + *FLOAT 64 + PRINT FNinfinity + END + + DEF FNinfinity + LOCAL supported%, maxpos, prev, inct + supported% = TRUE + ON ERROR LOCAL supported% = FALSE + IF supported% THEN = 1/0 + RESTORE ERROR + inct = 1E10 + REPEAT + prev = maxpos + inct *= 2 + ON ERROR LOCAL inct /= 2 + maxpos += inct + RESTORE ERROR + UNTIL maxpos = prev + = maxpos diff --git a/Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-1.bbc b/Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-1.bbc new file mode 100644 index 0000000000..73c45c0ca2 --- /dev/null +++ b/Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-1.bbc @@ -0,0 +1,12 @@ + cards% = 52 + DIM pack%(cards%) + FOR I% = 1 TO cards% + pack%(I%) = I% + NEXT I% + FOR N% = cards% TO 2 STEP -1 + SWAP pack%(N%),pack%(RND(N%)) + NEXT N% + FOR I% = 1 TO cards% + PRINT pack%(I%); + NEXT I% + PRINT diff --git a/Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-2.bbc b/Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-2.bbc new file mode 100644 index 0000000000..53957954f7 --- /dev/null +++ b/Task/Knuth-shuffle/BBC-BASIC/knuth-shuffle-2.bbc @@ -0,0 +1,44 @@ +seed = 1 /* seed of the random number generator */ +scale = 0 + +/* Random number from 0 to 32767. */ +define rand() { + /* Formula (from POSIX) for random numbers of low quality. */ + seed = (seed * 1103515245 + 12345) % 4294967296 + return ((seed / 65536) % 32768) +} + +/* Shuffle the first _count_ elements of shuffle[]. */ +define shuffle(count) { + auto b, i, j, t + + i = count + while (i > 0) { + /* j = random number in [0, i) */ + b = 32768 % i /* want rand() >= b */ + while (1) { + j = rand() + if (j >= b) break + } + j = j % i + + /* decrement i, swap shuffle[i] and shuffle[j] */ + t = shuffle[--i] + shuffle[i] = shuffle[j] + shuffle[j] = t + } +} + +/* Test program. */ +define print_array(count) { + auto i + for (i = 0; i < count - 1; i++) print shuffle[i], ", " + print shuffle[i], "\n" +} + +for (i = 0; i < 10; i++) shuffle[i] = 11 * (i + 1) +"Original array: "; trash = print_array(10) + +trash = shuffle(10) +"Shuffled array: "; trash = print_array(10) +quit diff --git a/Task/Knuth-shuffle/Brat/knuth-shuffle.brat b/Task/Knuth-shuffle/Brat/knuth-shuffle.brat new file mode 100644 index 0000000000..45f4c317f8 --- /dev/null +++ b/Task/Knuth-shuffle/Brat/knuth-shuffle.brat @@ -0,0 +1,12 @@ +shuffle = { a | + (a.length - 1).to 1 { i | + random_index = random(0, i) + temp = a[i] + a[i] = a[random_index] + a[random_index] = temp + } + + a +} + +p shuffle [1 2 3 4 5 6 7] diff --git a/Task/Narcissist/BBC-BASIC/narcissist.bbc b/Task/Narcissist/BBC-BASIC/narcissist.bbc new file mode 100644 index 0000000000..5360962001 --- /dev/null +++ b/Task/Narcissist/BBC-BASIC/narcissist.bbc @@ -0,0 +1 @@ +INPUT a$:PRINT -(a$=$(PAGE+34)+$(PAGE+33)):REM INPUT a$:PRINT -(a$=$(PAGE+34)+$(PAGE+33)):REM diff --git a/Task/Ordered-words/BBC-BASIC/ordered-words.bbc b/Task/Ordered-words/BBC-BASIC/ordered-words.bbc new file mode 100644 index 0000000000..b6144c5016 --- /dev/null +++ b/Task/Ordered-words/BBC-BASIC/ordered-words.bbc @@ -0,0 +1,19 @@ + dict% = OPENIN("unixdict.txt") + IF dict%=0 ERROR 100, "Failed to open dictionary file" + + max% = 2 + REPEAT + A$ = GET$#dict% + IF LENA$ >= max% THEN + i% = 0 + REPEAT i% += 1 + UNTIL ASCMID$(A$,i%) > ASCMID$(A$,i%+1) + IF i% = LENA$ THEN + IF i% > max% max% = i% : list$ = "" + list$ += A$ + CHR$13 + CHR$10 + ENDIF + ENDIF + UNTIL EOF#dict% + CLOSE #dict% + PRINT list$ + END diff --git a/Task/Ordered-words/Bracmat/ordered-words.bracmat b/Task/Ordered-words/Bracmat/ordered-words.bracmat new file mode 100644 index 0000000000..a4368adea9 --- /dev/null +++ b/Task/Ordered-words/Bracmat/ordered-words.bracmat @@ -0,0 +1,25 @@ + ( orderedWords + = bow result longestLength word character + . 0:?bow + & :?result + & 0:?longestLength + & @( get$(!arg,STR) + : ? + ( [!bow %?word \n [?bow ? + & @( !word + : ( ? %@?character <%@!character ? + | ? + ( [!longestLength + & !word !result:?result + | [>!longestLength:[?longestLength + & !word:?result + | + ) + ) + ) + & ~` + ) + ) + | !result + ) +& orderedWords$"unixdict.txt" diff --git a/Task/Ordered-words/Burlesque/ordered-words.blq b/Task/Ordered-words/Burlesque/ordered-words.blq new file mode 100644 index 0000000000..ffa0993634 --- /dev/null +++ b/Task/Ordered-words/Burlesque/ordered-words.blq @@ -0,0 +1 @@ +ln{so}f[^^{L[}>mL[bx(==)[+(L[)+]f[uN diff --git a/Task/Pi/BASIC256/pi.basic256 b/Task/Pi/BASIC256/pi.basic256 new file mode 100644 index 0000000000..a2c2e2b3ce --- /dev/null +++ b/Task/Pi/BASIC256/pi.basic256 @@ -0,0 +1,59 @@ +cls + +n =1000 +len = 10*n \ 4 +needdecimal = true +dim a(len) +nines = 0 +predigit = 0 # {First predigit is a 0} + +for j = 1 to len + a[j-1] = 2 # {Start with 2s} +next j + +for j = 1 to n + q = 0 + for i = len to 1 step -1 + # {Work backwards} + x = 10*a[i-1] + q*i + a[i-1] = x % (2*i - 1) + q = x \ (2*i - 1) + next i + a[0] = q % 10 + q = q \ 10 + if q = 9 then + nines = nines + 1 + else + if q = 10 then + d = predigit+1: gosub outputd + if nines > 0 then + for k = 1 to nines + d = 0: gosub outputd + next k + end if + predigit = 0 + nines = 0 + else + d = predigit: gosub outputd + predigit = q + if nines <> 0 then + for k = 1 to nines + d = 9: gosub outputd + next k + nines = 0 + end if + end if + end if +next j +print predigit +end + +outputd: +if needdecimal then + if d = 0 then return + print d + "."; + needdecimal = false +else + print d; +end if +return diff --git a/Task/Pi/BBC-BASIC/pi-1.bbc b/Task/Pi/BBC-BASIC/pi-1.bbc new file mode 100644 index 0000000000..8fc5fe6c14 --- /dev/null +++ b/Task/Pi/BBC-BASIC/pi-1.bbc @@ -0,0 +1,23 @@ + WIDTH 80 + M% = (HIMEM-END-1000) / 4 + DIM B%(M%) + FOR I% = 0 TO M% : B%(I%) = 20 : NEXT + E% = 0 + L% = 2 + FOR C% = M% TO 14 STEP -7 + D% = 0 + A% = C%*2-1 + FOR P% = C% TO 1 STEP -1 + D% = D%*P% + B%(P%)*&64 + B%(P%) = D% MOD A% + D% DIV= A% + A% -= 2 + NEXT + CASE TRUE OF + WHEN D% = 99: E% = E% * 100 + D% : L% += 2 + WHEN C% = M%: PRINT ;(D% DIV 100) / 10; : E% = D% MOD 100 + OTHERWISE: + PRINT RIGHT$(STRING$(L%,"0") + STR$(E% + D% DIV 100),L%); + E% = D% MOD 100 : L% = 2 + ENDCASE + NEXT diff --git a/Task/Pi/BBC-BASIC/pi-2.bbc b/Task/Pi/BBC-BASIC/pi-2.bbc new file mode 100644 index 0000000000..4bfd050641 --- /dev/null +++ b/Task/Pi/BBC-BASIC/pi-2.bbc @@ -0,0 +1,23 @@ + DIM P% 32 + [OPT 2 :.pidig mov ebp,eax :.pi1 imul edx,ecx : mov eax,[ebx+ecx*4] + imul eax,100 : add eax,edx : cdq : div ebp : mov [ebx+ecx*4],edx + mov edx,eax : sub ebp,2 : loop pi1 : mov eax,edx : ret :] + + WIDTH 80 + M% = (HIMEM-END-1000) / 4 + DIM B%(M%) : B% = ^B%(0) + FOR I% = 0 TO M% : B%(I%) = 20 : NEXT + E% = 0 + L% = 2 + FOR C% = M% TO 14 STEP -7 + D% = 0 + A% = C%*2-1 + D% = USR(pidig) + CASE TRUE OF + WHEN D% = 99: E% = E% * 100 + D% : L% += 2 + WHEN C% = M%: PRINT ;(D% DIV 100) / 10; : E% = D% MOD 100 + OTHERWISE: + PRINT RIGHT$(STRING$(L%,"0") + STR$(E% + D% DIV 100),L%); + E% = D% MOD 100 : L% = 2 + ENDCASE + NEXT diff --git a/Task/Pi/Bracmat/pi.bracmat b/Task/Pi/Bracmat/pi.bracmat new file mode 100644 index 0000000000..9679749d1a --- /dev/null +++ b/Task/Pi/Bracmat/pi.bracmat @@ -0,0 +1,29 @@ + ( pi + = f,q r t k n l,first + . !arg:((=?f),?q,?r,?t,?k,?n,?l) + & yes:?first + & whl + ' ( 4*!q+!r+-1*!t+-1*!n*!t:<0 + & f$!n + & ( !first:yes + & f$"." + & no:?first + | + ) + & "compute and update variables for next cycle" + & 10*(!r+-1*!n*!t):?nr + & div$(10*(3*!q+!r).!t)+-10*!n:?n + & !q*10:?q + & !nr:?r + | "compute and update variables for next cycle" + & (2*!q+!r)*!l:?nr + & div$(!q*(7*!k+2)+!r*!l.!t*!l):?nn + & !q*!k:?q + & !t*!l:?t + & !l+2:?l + & !k+1:?k + & !nn:?n + & !nr:?r + ) + ) +& pi$((=.put$!arg),1,0,1,1,3,3) diff --git a/Task/Quine/BBC-BASIC/quine-1.bbc b/Task/Quine/BBC-BASIC/quine-1.bbc new file mode 100644 index 0000000000..2a347f4029 --- /dev/null +++ b/Task/Quine/BBC-BASIC/quine-1.bbc @@ -0,0 +1 @@ + PRINT $(PAGE+22)$(PAGE+21):REM PRINT $(PAGE+22)$(PAGE+21):REM diff --git a/Task/Quine/BBC-BASIC/quine-2.bbc b/Task/Quine/BBC-BASIC/quine-2.bbc new file mode 100644 index 0000000000..914a4fa333 --- /dev/null +++ b/Task/Quine/BBC-BASIC/quine-2.bbc @@ -0,0 +1 @@ + PRINT $(PAGE+23)$(PAGE+22):REM PRINT $(PAGE+23)$(PAGE+22):REM diff --git a/Task/Quine/Batch-File/quine-1.bat b/Task/Quine/Batch-File/quine-1.bat new file mode 100644 index 0000000000..d4ddde9b87 --- /dev/null +++ b/Task/Quine/Batch-File/quine-1.bat @@ -0,0 +1 @@ +@type %0 diff --git a/Task/Quine/Batch-File/quine-2.bat b/Task/Quine/Batch-File/quine-2.bat new file mode 100644 index 0000000000..959c8f05c5 --- /dev/null +++ b/Task/Quine/Batch-File/quine-2.bat @@ -0,0 +1 @@ +@type "%~f0" diff --git a/Task/Quine/Bracmat/quine-1.bracmat b/Task/Quine/Bracmat/quine-1.bracmat new file mode 100644 index 0000000000..8e3f99af3b --- /dev/null +++ b/Task/Quine/Bracmat/quine-1.bracmat @@ -0,0 +1,2 @@ +(quine= +.lst$quine); diff --git a/Task/Quine/Bracmat/quine-2.bracmat b/Task/Quine/Bracmat/quine-2.bracmat new file mode 100644 index 0000000000..196c7a4767 --- /dev/null +++ b/Task/Quine/Bracmat/quine-2.bracmat @@ -0,0 +1 @@ +quine$ diff --git a/Task/Quine/Brainf---/quine.bf b/Task/Quine/Brainf---/quine.bf new file mode 100644 index 0000000000..cad6151345 --- /dev/null +++ b/Task/Quine/Brainf---/quine.bf @@ -0,0 +1,7 @@ +->+>+++>>+>++>+>+++>>+>++>>>+>+>+>++>+>>>>+++>+>>++>+>+++>>++>++>>+>>+>++>++>+>>>>+++>+>>>>++>++>>>>+>>++>+>+++>>>++>>++++++>>+>>++> ++>>>>+++>>+++++>>+>+++>>>++>>++>>+>>++>+>+++>>>++>>+++++++++++++>>+>>++>+>+++>+>+++>>>++>>++++>>+>>++>+>>>>+++>>+++++>>>>++>>>>+>+>+ ++>>+++>+>>>>+++>+>>>>+++>+>>>>+++>>++>++>+>+++>+>++>++>>>>>>++>+>+++>>>>>+++>>>++>+>+++>+>+>++>>>>>>++>>>+>>>++>+>>>>+++>+>>>+>>++>+ +>++++++++++++++++++>>>>+>+>>>+>>++>+>+++>>>++>>++++++++>>+>>++>+>>>>+++>>++++++>>>+>++>>+++>+>+>++>+>+++>>>>>+++>>>+>+>>++>+>+++>>>+ ++>>++++++++>>+>>++>+>>>>+++>>++++>>+>+++>>>>>>++>+>+++>>+>++>>>>+>+>++>+>>>>+++>>+++>>>+[[->>+<<]<+]+++++[->+++++++++<]>.[+]>> +[<<+++++++[->+++++++++<]>-.------------------->-[-<.<+>>]<[+]<+>>>]<<<[-[-[-[>>+<++++++[->+++++<]]>++++++++++++++<]>+++<]++++++ +[->+++++++<]>+<<<-[->>>++<<<]>[->>.<<]<<] diff --git a/Task/Quine/Burlesque/quine.blq b/Task/Quine/Burlesque/quine.blq new file mode 100644 index 0000000000..8aa00492e7 --- /dev/null +++ b/Task/Quine/Burlesque/quine.blq @@ -0,0 +1,2 @@ +blsq ) "I'm a quine." +"I'm a quine." diff --git a/Task/Search-a-list/BBC-BASIC/search-a-list.bbc b/Task/Search-a-list/BBC-BASIC/search-a-list.bbc new file mode 100644 index 0000000000..dc522591a0 --- /dev/null +++ b/Task/Search-a-list/BBC-BASIC/search-a-list.bbc @@ -0,0 +1,21 @@ + DIM haystack$(27) + haystack$() = "alpha","bravo","charlie","delta","echo","foxtrot","golf", \ + \ "hotel","india","juliet","kilo","lima","mike","needle", \ + \ "november","oscar","papa","quebec","romeo","sierra","tango", \ + \ "needle","uniform","victor","whisky","x-ray","yankee","zulu" + + needle$ = "needle" + maxindex% = DIM(haystack$(), 1) + + FOR index% = 0 TO maxindex% + IF needle$ = haystack$(index%) EXIT FOR + NEXT + IF index% <= maxindex% THEN + PRINT "First found at index "; index% + FOR last% = maxindex% TO 0 STEP -1 + IF needle$ = haystack$(last%) EXIT FOR + NEXT + IF last%<>index% PRINT "Last found at index "; last% + ELSE + ERROR 100, "Not found" + ENDIF diff --git a/Task/Search-a-list/Burlesque/search-a-list-1.blq b/Task/Search-a-list/Burlesque/search-a-list-1.blq new file mode 100644 index 0000000000..3a78ecfadb --- /dev/null +++ b/Task/Search-a-list/Burlesque/search-a-list-1.blq @@ -0,0 +1,2 @@ +blsq ) {"Zig" "Zag" "Wally" "Bush" "Ronald" "Bush"}"Bush"Fi +3 diff --git a/Task/Search-a-list/Burlesque/search-a-list-2.blq b/Task/Search-a-list/Burlesque/search-a-list-2.blq new file mode 100644 index 0000000000..8ee45e8358 --- /dev/null +++ b/Task/Search-a-list/Burlesque/search-a-list-2.blq @@ -0,0 +1,2 @@ +blsq ) {"Zig" "Zag" "Wally" "Bush" "Ronald" "Bush"}{"Bush"==}fI +{3 5}