diff --git a/.gitignore b/.gitignore index 80f7631497..26ab3c8d09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ -/*.ys /Cache/ /Meta/ /rosettacode.log -/entry -/pick -/random-clojure-task -/.clj-kondo/ -/.lsp/ diff --git a/Conf/alias.yaml b/Conf/alias.yaml deleted file mode 100644 index ded3b20bda..0000000000 --- a/Conf/alias.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Language name aliases: -lang: - antlang : ant - bash : unix shell - c# : c sharp - c_sharp : c sharp - euler math toolbox : euler - f# : f sharp - free pascal : free pascal/lazarus - f_sharp : f sharp - lazarus : free pascal/lazarus - oberon-2 : oberon diff --git a/Conf/lang.yaml b/Conf/lang.yaml index 72c972e3d8..1012822548 100644 --- a/Conf/lang.yaml +++ b/Conf/lang.yaml @@ -4,7 +4,6 @@ 360 Assembly: '.360' 4D: .4d 4DOS Batch: .4dos -4ME: .4me 6502 Assembly: '.6502' 68000 Assembly: '.68000' 6800 Assembly: '.6800' @@ -17,25 +16,21 @@ A+: .a+ AArch64 Assembly: .aarch64 ABAP: .abap -ABC: .abc ACL2: .acl2 -Acornsoft Lisp: .lisp Action!: .action ActionScript: .as Acurity Architect: .acurity -Ada: .adb -Adina: .adina -Agda2: .agda2 +Ada: .ada Agda: .agda +Agda2: .agda2 Agena: .agena AHDL: .ahdl -AIDED NATURAL LANGUAGE: .aided Aikido: .aikido Aime: .aime Algae: .algae +ALGOL: .alg ALGOL 60: .alg ALGOL 68: .alg -ALGOL: .alg ALGOL-M: .alg ALGOL W: .alg Alice ML: .alice @@ -53,7 +48,6 @@ Anyways: .anyways Apex: .apex APL: .apl App Inventor: .app -Apple: .apple AppleScript: .applescript Applesoft BASIC: .basic Application Master: .app @@ -63,8 +57,6 @@ Arbre: .arbre Arc: .arc Arendelle: .arendelle Argile: .argile -Aria: .aria -ArkScript: .ark ARM Assembly: .arm ArnoldC: .arnoldc Arturo: .arturo @@ -74,38 +66,35 @@ ASP: .asp AspectC++: .acpp AspectJ: .aspectj ASP.Net: .asp -Assembly: .asm +Assembly: .as AssemblyScript: .asmscript Astro: .astro Asymptote: .asymptote Atari BASIC: .basic ATS: .ats AutoHotkey: .ahk -Autohotkey V2: .ahk -AutoHotKey V2: .ahk -AutoIt: .au3 -AutoLISP: .lsp +AutoIt: .autoit +AutoLISP: .l Avail: .avail AWK: .awk Axe: .axe Axiom: .axiom Axum: .axum Ayrch: .ayrch +B: .b B4J: .b4j B4X: .b4x Babel: .pb -BabyCobol: .cobol BaCon: .bacon Bait: .bait Ballerina: .ballerina Bas: .bas +BASIC: .basic Basic09: .basic BASIC256: .basic -BASIC: .basic Batari Basic: .basic Batch File: .bat Battlestar: .battlestar -B: .b BBC BASIC: .basic Bc: .bc BCPL: .bcpl @@ -113,7 +102,6 @@ Beads: .beads Beef: .beef Beeswax: .beeswax Befunge: .bf -Berkeley Logo: .logo Beta: .beta Biferno: .biferno Binary Lambda Calculus: .blc @@ -135,37 +123,31 @@ Bracmat: .bracmat Brainf***: .bf Brat: .brat Brlcad: .brlcad -Bruijn: .bruijn Burlesque: .blq +C++: .cpp +C: .c C0H: .c0h C1R: .c1r C2: .c2 C3: .c3 CafeOBJ: .cafeobj -Calc: .calc -Calcscript: .calc Caml: .caml Casio BASIC: .basic Cat: .cat CB80: .cb80 -CBASIC: .basic -C: .c C++/CLI: .cpp -C++: .cpp Cduce: .cduce Cecil: .cecil Ceylon: .ceylon CFEngine: .cfengine -Chapel: .chpl +Chapel: .chapel Chef: .chef -Cherrycake: .cherrycake Chipmunk Basic: .basic CHR: .chr ChucK: .chuck Cilk++: .cilk++ Cilk: .cilk Cind: .cind -CJam: .cjam Clarion: .clarion Clay: .clay Clean: .clean @@ -176,7 +158,7 @@ CLIPS: .clips Clojure: .clj CLU: .clu CMake: .cmake -COBOL: .cob +COBOL: .cobol Cobra: .cobra Coco: .coco Coconut: .coconut @@ -189,19 +171,18 @@ Common Lisp: .lisp Component Pascal: .pas Computer/zero Assembly: .0asm ContextFree: .cf -Convex: .convex Coq: .coq Corescript: .core Cowgol: .cowgol Crack: .crack Craft Basic: .basic Creative Basic: .basic -Crystal: .cr +Crystal: .crystal C sharp: .cs C Shell: .csh Cubescript: .cube Curry: .curry -Curto: .curto +D: .d Dafny: .dafny Dao: .dao Dart: .dart @@ -210,9 +191,8 @@ DataWeave: .dw DBL: .dbl Dc: .dc DCL: .dcl -D: .d DDNC: .ddnc -Delphi: .pas +Delphi: .delphi Deluge: .deluge DeviousYarn: .dy DIBOL-11: .dibol-11 @@ -224,23 +204,18 @@ DMS: .dms Dodo0: .dodo0 Draco: .draco Dragon: .dragon -Dragonstone: .dragonstone -DreamBerd: .dreamberd -Dt: .dt -DuckDB: .duckdb DUP: .dup DWScript: .dw Dyalect: .dyalect Dylan: .dylan Dylan.NET: .dylan +E: .e EasyLang: .easy EC: .ec EchoLisp: .l ECL: .ecl Ecstasy: .ecstasy -Ed: .ed EDSAC order code: .edsac -E: .e Eero: .eero Efene: .efene Egel: .egel @@ -253,10 +228,10 @@ Elan: .elan ElastiC: .elastic Elena: .elena Elisa: .elisa -Elixir: .ex +Elixir: .elixir ELLA: .ella Elm: .elm -Emacs Lisp: .el +Emacs Lisp: .l EMal: .emal Emojicode: .emojicode Enguage: .enguage @@ -267,29 +242,27 @@ ERRE: .erre Es: .es ESQL: .esql Euler: .euler -Euphoria: .eu -Evaldraw: .evaldraw +Euphoria: .euphoria Excel: .excel Explore: .explore Extended BrainF***: .ebf -Extended Color BASIC: .basic Ezhil: .ezhil +F: .f Factor: .factor Falcon: .falcon 'FALSE': .false -Fancy: .fancy Fan: .fan +Fancy: .fancy Fantom: .fantom FAUST: .faust FBSL: .fbsl -FeatureC++: .cpp Fe: .fe +FeatureC++: .cpp Felix: .felix Fennel: .fennel Ferite: .ferite Fermat: .fermat Fexl: .fexl -F: .f Fhidwfe: .fhidwfe Fish: .fish FLORA-2: .flora2 @@ -303,6 +276,7 @@ FP: .fp FPI: .fpi FreeBASIC: .basic FreeMat: .freemat +Free Pascal: .pas Free Pascal/Lazarus: .pas Frege: .frege Friendly interactive shell: .fish @@ -310,10 +284,8 @@ Frink: .frink FRISC Assembly: .frisc F Sharp: .fs FTCBASIC: .basic -FuncSug: .funcsug FunL: .funl Furor: .furor -FurryScript: .furryscript Futhark: .futhark FutureBasic: .basic FUZE BASIC: .basic @@ -333,17 +305,15 @@ GFA Basic: .basic G-fu: .gfu Glagol: .glagol GLBasic: .basic -Gleam: .gleam Glee: .glee Global Script: .global GlovePIE: .glovepie GLSL: .glsl GML: .gml Gnuplot: .gnuplot -Goaldi: .goaldi -Goboscript: .gobo Go!: .go Go: .go +Goaldi: .goaldi Golfscript: .golf Golo: .golo Goo: .goo @@ -360,7 +330,7 @@ Halon: .halon Harbour: .harbour Hare: .hare Haskell: .hs -Haxe: .hx +Haxe: .haxe Heron: .heron Hexiscript: .hexi HicEst: .hicest @@ -368,22 +338,19 @@ HLA: .hla HolyC: .holyc Hoon: .hoon Hope: .hope -Hopper: .hopper HPPPL: .hpppl HQ9+: .hq9+ Huginn: .huginn Hy: .hy HyperTalk: .ht +I: .i Icon: .icon IDL: .idl Idris: .idris -I: .i -Imp77: .imp77 Inform 6: '.inf' Inform 7: '.inf' Informix 4GL: .4gl Inko: .inko -Insitux: .insitux Integer BASIC: .basic Intercal: .ical Io: .io @@ -393,19 +360,18 @@ Iptscrae: .iptscrae Isabelle: .isabelle IS-BASIC: .basic IWBASIC: .basic +J: .j Jabaco: .jabaco Jack: .jack Jacquard Loom: .jacquard -Jactl: .jactl Jakt: .jakt JAMES II/Rule-based Cellular Automata: .james Janet: .janet -JavaFX Script: .javafx Java: .java +JavaFX Script: .javafx JavaScript: .js JCL: .jcl Jinja: .jinja -J: .j JoCaml: .jocaml JOVIAL: .jovial Joy: .joy @@ -414,34 +380,31 @@ JScript.NET: .jscript JSE: .jse Jsish: .jsish JudoScript: .judo -Julia: .jl +Julia: .julia +K: .k Kabap: .kabap Kamailio Script: .kamailio -Kantalo: .kantalo KAP: .kap Kaya: .kaya Keg: .keg KeyList Databasing: .keylist Kite: .kite Kitten: .kitten -K: .k KL1: .kl1 Klingphix: .klingphix Klong: .klong Koka: .koka -Komodo: .komodo KonsolScript: .konsol -Kotlin: .kts +Kotlin: .kotlin KQL: .kql Ksh: .ksh +L++: .l++ LabVIEW: .labview -Labyrinth: .labyrinth Lambda Prolog: .pro Lambdatalk: .lambdatalk -Lang5: .lang5 Lang: .lang +Lang5: .lang5 Langur: .langur -Lapyst: .lapyst Lasso: .lasso LAST: .last LaTeX: .tex @@ -467,7 +430,6 @@ Little: .little Little Man Computer: .lmc LiveCode: .livecode LiveScript: .live -L++: .l++ LLP: .llp LLVM: .llvm Lobster: .lobster @@ -480,8 +442,8 @@ Lolli: .lolli Lotus 123 Macro Scripting: .lotus123 LotusScript: .lotus Lout: .lout -LSE64: .lse64 LSE: .lse +LSE64: .lse64 LSL: .lsl LSTS: .lsts Lua: .lua @@ -495,15 +457,12 @@ M2000 Interpreter: .m2000 M4: .m4 M680x0: .m680x0 MACRO-11: .macro11 -Macsyma: .macsyma MAD: .mad Make: .make Malbolge: .malbolge MANOOL: .manool Maple: .maple MAPPER: .mapper -MariaDB: .sql -Mastermind: .mastermind Mathcad: .mathcad MathCortex: .mathcortex Mathematica: .math @@ -521,34 +480,29 @@ Mercury: .mercury Metafont: .metafont Metapost: .metapost MGS: .mgs -Mia: .mia Microsoft Small Basic: .basic +Min: .min MINIL: .minil Minimal BASIC: .basic MiniScript: .mini MiniZinc: .minizinc -Min: .min MIPS Assembly: .mips Mirah: .mirah Miranda: .miranda MIRC Scripting Language: .mirc Mirelle: .mirelle +ML: .ml ML/I: .mli MLite: .mlite -ML: .ml MMIX: .mmix -Mn: .mn Modula-2: .mod2 Modula-3: .mod3 -Mojo: .mojo Mond: .mond Monicelli: .monicelli Monkey: .monkey Monte: .monte MontiLang: .monti MOO: .moo -MoonBit: .moonbit -MoonRock: .moonrock MoonScript: .moon Morfa: .morfa Mosaic: .mosaic @@ -587,36 +541,31 @@ Nit: .nit Niue: .niue Nix: .nix NLP++: .nlp++ -Nom: .num NOWUT: .nowut NQP: .nqp NS-HUBASIC: .basic NSIS: .nsis N/t/roff: .ntroff -Nu: .nu Nutt: .nutt Nyquist: .nyquist -OASYS Assembler: .oasys OASYS: .oasys -Oberon-07: .oberon +OASYS Assembler: .oasys Oberon: .oberon +Oberon-2: .oberon Objeck: .objeck ObjectIcon: .oi Objective-C: .m -Object Pascal Implementations: .pas Object Pascal: .pas -OCaml: .ml +OCaml: .ocaml Occam: .occam Octave: .octave Odin: .odin Oforth: .fth Ol: .ol Omega: .omega -OmniMark: .xom Onyx: .onyx -Onyx (wasm): .onyx -OOCalc: .oocalc OOC: .ooc +OOCalc: .oocalc OoRexx: .rexx Opa: .opa OpenC++: .openc++ @@ -632,12 +581,10 @@ Oz: .oz Palo Alto Tiny BASIC: .basic Panda: .panda Panoramic: .panoramic -ParaCL: .paracl Pare: .pare PARI/GP: .parigp -PascalABC.NET: .pas Pascal: .pas -Pascal-P: .pas +PascalABC.NET: .pas PASM: .pasm PDP-11 Assembly: .pdp11 Pebble: .pebble @@ -646,16 +593,15 @@ Pentium Assembly: .pentium PeopleCode: .peoplecode PepsiScript: .pepsi Peri: .peri +Perl: .pl Perl5i: .p5i Perl 6: .pl6 -Perl: .pl Peylang: .peylang -Phixmonti: .phixmonti Phix: .phix +Phixmonti: .phixmonti PHL: .phl PHP: .php Picat: .picat -Pico-8: .pico8 PicoLisp: .l Pict: .pict Piet: .piet @@ -668,13 +614,12 @@ Plain English: .plain PlainTeX: .tex Plan: .plan PL/B: .plb -PL/I-80: .pli PL/I: .pli +PL/I-80: .pli PL/M: .plm PL/pgSQL: .sql PL/SQL: .sql PLUS: .plus -Pluto: .pluto PLZ/SYS: .plz Pointless: .pointless Polyglot: .polyglot @@ -687,58 +632,55 @@ POV-Ray: .povray PowerBASIC: .basic Powerbuilder: .powerbuilder PowerPC Assembly: .ppc -PowerShell: .ps1 +PowerShell: .psh PPL: .ppl Processing: .processing Processing Python mode: .processing-py Processing.R: .processing-r ProDOS: .dos -Prog8: .prog8 -ProgressBASIC: .basic Prolog: .pro PROMAL: .promal PSQL: .psql +Pure: .pure PureBasic: .basic Pure Data: .puredata -Pure: .pure Purity: .purity -Pyret: .arr +Pyret: .pyret Python: .py +Q: .q QB64: .qb64 QBasic: .basic Qi: .qi .QL: .ql QL SuperBASIC: .basic Qore: .qore -Q: .q Quackery: .quackery QuakeC: .c QuickBASIC: .basic Quill: .quill Quite BASIC: .basic Quorum: .quorum +R: .r +Ra: .ra Racket: .rkt Raku: .raku RapidQ: .rapidq Rapira: .rapira -Ra: .ra Rascal: .rascal RASEL: .rasel RATFOR: .ratfor Raven: .raven REALbasic: .basic -Reason: .re -Rebol: .rebol +Reason: .reason REBOL: .rebol Red: .red Reduce: .reduce Refal: .refal Relation: .relation -ReScript: .res +ReScript: .re Retro: .retro Revolution: .rev REXX: .rexx -Rhombus: .rhombus Rhope: .rhope Rhovas: .rhovas Ring: .ring @@ -747,30 +689,26 @@ RLaB: .rlab RLSL: .rlsl Robotic: .robotic Rockstar: .rockstar -Rocq: .rocq -Roc: .roc -RPGIV: .rpgiv RPG: .rpg -RPL/2: .rpl2 +RPGIV: .rpgiv RPL: .rpl -R: .r +RPL/2: .rpl2 RTL/2: .rtl2 RTSL: .rtsl Rubylog: .rubylog Ruby: .rb Run BASIC: .basic -Rust: .rs -Rye: .rye +Rust: .rust +S++: .s++ Sage: .sage Salmon: .salmon -SapbotVM: .sapbot -SASL: .sasl SAS: .sas +SASL: .sasl Sass/SCSS: .sass Sather: .sa S-BASIC: .basic Scala: .scala -Scheme: .scm +Scheme: .ss Scilab: .scilab Scratch: .scratch ScratchScript: .scratch @@ -782,15 +720,14 @@ Seed7: .seed7 Self: .self SenseTalk: .sensetalk SequenceL: .sequencel +SETL: .setl Setl4: .setl4 Set lang: .set -SETL: .setl Shale: .shale SheerPower 4GL: .4gl Shen: .shen Shiny: .shiny Sidef: .sidef -SIL: .sil SimpleCode: .simplecode SimpleLang: .simple SIMPOL: .simpol @@ -807,8 +744,8 @@ Smalltalk: .st Smart BASIC: .basic SMEQL: .smeql SmileBASIC: .basic -SNOBOL4: .sno Snobol: .sno +SNOBOL4: .sno SNUSP: .snusp Soar: .soar Soda: .soda @@ -816,22 +753,20 @@ SoneKing Assembly: .soneking SPAD: .spad SPARC Assembly: .sparc SparForte: .sparforte -Sparkling: .sparkling SPARK: .spark +Sparkling: .sparkling Spin: .spin SPL: .spl SPSS: .spss -SQL PL: .sql SQL: .sql +SQL PL: .sql Squirrel: .nut -S++: .s++ SSEM: .ssem Standard ML: .ml Star: .star Stata: .stata Stax: .stax StreamIt: .streamit -Stringle: .stringle Suneido: .suneido Superbase BASIC: .basic SuperCollider: .sc @@ -845,15 +780,14 @@ SystemVerilog: .v TailDot: .taildot Tailspin: .tailspin TAL: .tal -TAV: .tav Tbas: .tbas Tcl: .tcl TechBASIC: .basic Teco: .teco TeLa: .tela Tern: .tern -Terraform: .terraform Terra: .terra +Terraform: .terraform TestML: .tml Thistle: .thistle Thyrd: .thyrd @@ -861,7 +795,6 @@ TI-57: .ti57 TI-83 BASIC: .basic TI-83 Hex Assembly: .asm TI-89 BASIC: .basic -TI BASIC: .basic Tiny BASIC: .basic Tiny Craft Basic: .basic TIS-100: .tis100 @@ -878,7 +811,6 @@ Transact-SQL: .sql Transd: .transd TransFORTH: .fth Trith: .trith -TRS-80 BASIC: .basic True BASIC: .basic TSE SAL: .tse Turbo-Basic XL: .basic @@ -890,34 +822,32 @@ TXR: .txr Typed Racket: .rkt TypeScript: .ts UC++: .uc++ -Uiua: .uiua Ultimate++: .ultimate++ Unicon: .unicon Uniface: .uniface -Unison: .u +Unison: .unison UnixPipes: .up UNIX Shell: .sh Unlambda: .unlambda -Ursalang: .ursa -Ursala: .ursala Ursa: .ursa +Ursala: .ursala UScript: .u UserRPL: .rpl UTFool: .utfool -Uxntal: .uxnatl +V: .v Vala: .vala Vale: .vale VAX Assembly: .vax VB6: .vb6 VBA: .vba -VBScript: .vbs +VBScript: .vb Vedit macro language: .vedit Verbexx: .verbexx Verilog: .v -VHDL: .vhd +VHDL: .vhdl Vim Script: .vim -Visual Basic .NET: .vb Visual Basic: .vb +Visual Basic .NET: .vb Visual FoxPro: .fvp Visual Objects: .vobj Visual Prolog: .pro @@ -926,10 +856,7 @@ Vorpal: .vorpal Vox: .vox VRML: .vrml VTL-2: .vtl-2 -V: .v V (Vlang): .v -Vyxal: .vyxal -Waduzitdo: .waduzitdo Wart: .wart WDTE: .wdte WebAssembly: .wasm @@ -951,32 +878,31 @@ XBase: .xbase XBasic: .basic XBS: .xbs XEec: .xeec -XLISP: .l XL: .xl +XLISP: .l Xojo: .xojo XPath 2.0: .xpath XPL0: .xpl0 XProc: .xproc XProfan: .xprofan XQuery: .xquery -X-script: .x +XS: .xs +XSLT: .xslt XSLT 1.0: .xslt XSLT 2.0: .xslt -XSLT: .xslt -XS: .xs XTalk: .xtalk XUL: .xul +Ya: .ya Yabasic: .basic Yacas: .yacas YAMLScript: .ys -Ya: .ya Yorick: .yorick Z80 Assembly: .z80 ZED: .zed Zig: .zig Zkl: .zkl -Zoea Visual: .zoea Zoea: .zoea +Zoea Visual: .zoea Zonnon: .zonnon Zoomscript: .zoom ZPL: .zpl diff --git a/Lang/11l/Bioinformatics-base-count b/Lang/11l/Bioinformatics-base-count new file mode 120000 index 0000000000..d8c9e2572d --- /dev/null +++ b/Lang/11l/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/11l \ No newline at end of file diff --git a/Lang/11l/Comments b/Lang/11l/Comments new file mode 120000 index 0000000000..3585963399 --- /dev/null +++ b/Lang/11l/Comments @@ -0,0 +1 @@ +../../Task/Comments/11l \ No newline at end of file diff --git a/Lang/11l/List-comprehensions b/Lang/11l/List-comprehensions new file mode 120000 index 0000000000..f4de0b78ad --- /dev/null +++ b/Lang/11l/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/11l \ No newline at end of file diff --git a/Lang/11l/Meissel-Mertens-constant b/Lang/11l/Meissel-Mertens-constant new file mode 120000 index 0000000000..908ef16ca2 --- /dev/null +++ b/Lang/11l/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/11l \ No newline at end of file diff --git a/Lang/11l/Miller-Rabin-primality-test b/Lang/11l/Miller-Rabin-primality-test new file mode 120000 index 0000000000..cec9772a16 --- /dev/null +++ b/Lang/11l/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/11l \ No newline at end of file diff --git a/Lang/11l/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/11l/Selectively-replace-multiple-instances-of-a-character-within-a-string deleted file mode 120000 index fd76e458f8..0000000000 --- a/Lang/11l/Selectively-replace-multiple-instances-of-a-character-within-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/11l \ No newline at end of file diff --git a/Lang/11l/Set-right-adjacent-bits b/Lang/11l/Set-right-adjacent-bits deleted file mode 120000 index 8aa56e4c7e..0000000000 --- a/Lang/11l/Set-right-adjacent-bits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-right-adjacent-bits/11l \ No newline at end of file diff --git a/Lang/11l/Sorting-Algorithms-Circle-Sort b/Lang/11l/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..38059f4dea --- /dev/null +++ b/Lang/11l/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/11l \ No newline at end of file diff --git a/Lang/4D/00-LANG.txt b/Lang/4D/00-LANG.txt index 8c8b507919..d591e6be7f 100644 --- a/Lang/4D/00-LANG.txt +++ b/Lang/4D/00-LANG.txt @@ -1,6 +1,3 @@ -{{stub}} -{{language|4D -|site=https://us.4d.com/ -}}{{IDE}}'''4D''' (or '''4th Dimension''') is a database management system and [[:Category:Integrated Development Environments|integrated development environment]] authored by Laurent Ribardière in 1984. +{{stub}}{{language|4D}}{{IDE}}'''4D''' (or '''4th Dimension''') is a database management system and [[:Category:Integrated Development Environments|integrated development environment]] authored by Laurent Ribardière in 1984. ==Citations== *[[wp:4th_Dimension_%28Software%29|Wikipedia:4th Dimension (Software)]] \ No newline at end of file diff --git a/Lang/4ME/00-LANG.txt b/Lang/4ME/00-LANG.txt deleted file mode 100644 index d297ba9483..0000000000 --- a/Lang/4ME/00-LANG.txt +++ /dev/null @@ -1,7 +0,0 @@ -{{language|4ME -|site=https://thevitebsk.github.io/4ME.by/}} -4ME is a programing language created by [[User:Gaham]] implemented in 04.07.2024 MSK -==See Also== -* [https://esolangs.org/wiki/4ME 4ME in Esolangs.org] -* [https://github.com/Thevitebsk/4me/ Github repo] -[[Category:Programming paradigm/Concatenative]] \ No newline at end of file diff --git a/Lang/4ME/00-META.yaml b/Lang/4ME/00-META.yaml deleted file mode 100644 index f0031de2c3..0000000000 --- a/Lang/4ME/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:4ME diff --git a/Lang/6502-Assembly/00-LANG.txt b/Lang/6502-Assembly/00-LANG.txt index 1273acfa02..a7fa28ad34 100644 --- a/Lang/6502-Assembly/00-LANG.txt +++ b/Lang/6502-Assembly/00-LANG.txt @@ -131,29 +131,6 @@ This flag is set if the BRK command was executed. The BRK basically * Set with: BRK * Cleared with: RTI * There are no branches associated with this command. - -This flag is used only for differentiating a BRK from an hardware IRQ -IRQ: - STA saveAccumulator ; save accumulator - PLA ; get flags - STA saveFlags ; save flags - AND #$10 ; check "break" flag - BNE IRQ_fromBreak ; if(break flag set){ goto IRQ_fromBreak; } - JMP IRQ_fromHardware ; else{ goto IRQ_fromInterrupt; } -IRQ_fromBreak: - LDA saveFlags ; load flags from temp address - PHA ; restore flags to stack - LDA saveAccumulator ; restore accumulator - ;... - RTI ; return from interrupt - -IRQ_fromInterrupt: - LDA saveFlags ; load flags from temp address - PHA ; restore flags to stack - LDA saveAccumulator ; restore accumulator - ;... - RTI ; return from interrupt -

===Decimal=== diff --git a/Lang/6502-Assembly/N-queens-problem b/Lang/6502-Assembly/N-queens-problem deleted file mode 120000 index 6cb6d9c259..0000000000 --- a/Lang/6502-Assembly/N-queens-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/N-queens-problem/6502-Assembly \ No newline at end of file diff --git a/Lang/68000-Assembly/00-LANG.txt b/Lang/68000-Assembly/00-LANG.txt index 245cbaaea5..cfd37d0eae 100644 --- a/Lang/68000-Assembly/00-LANG.txt +++ b/Lang/68000-Assembly/00-LANG.txt @@ -3,36 +3,31 @@ {{language}} 68000 assembly is the assembly language used for the Motorola 68000, or commonly known as the 68K. It should not be confused with the 6800 (which predates it). The Motorola 68000 is a big-endian processor with full 32-bit capabilities (despite most systems that use it being considered 16-bit.) It was used in many computers such as the Amiga or the Canon Cat, as well as game consoles such as the Sega Genesis and Neo Geo. + ==Architecture Overview== ===Big-Endian=== The 68000, unlike most processors of its era, is big-endian. This means that bytes are stored from left to right. The example below illustrates this concept: - -MOVE.L #$12345678,$100000 ;store the hexadecimal numeral #$12345678 at memory address $100000 - +MOVE.L #$12345678,$100000 ;store the hexadecimal numeral #$12345678 at memory address $100000 -
 ;hexdump of $100000:
 ;$100000 = $12
 ;$100001 = $34
 ;$100002 = $56
-;$100003 = $78
-
+;$100003 = $78
On a little-endian processor such as in [[x86 Assembly]], the order of the bytes would be reversed, i.e.: -
-;hexdump of $100000
+;hexdump of $100000
 ;$100000 = $78
 ;$100001 = $56
 ;$100002 = $34
-;$100003 = $12
-
+;$100003 = $12 -The main difference is that if you wanted to access this value as a byte or word it would be at a different address, whereas with a little endian architecture it is at the same address. +This difference isn't usually relevant in the majority of situations, so don't concern yourself too much. It's much more important when doing [[6502 Assembly]] where registers are smaller than the address space. ===Notation Conventions=== How you write the source code depends on your assembler and the syntax it uses. This page is written using Motorola syntax but there is also Milo syntax which has different conventions. -How you go about defining numbers or text in your code varies wildly between assemblers. +How you go about defining numbers or text in your code varies wildly between assemblers. I'm using VASM and these are the rules I have to follow, but your assembler may be different. * A number with a # in front represents a constant, literal value. For example, the 3 in MOVE.B #3,D0 represents the number 3. @@ -50,88 +45,72 @@ How you go about defining numbers or text in your code varies wildly between ass * The operand before the comma is the "source", and the operand after is the "destination." For example, MOVE.L D3,D2 takes the value in D3 and stores it into D2, not the other way around. This is the opposite of x86 and ARM, which have the source on the right and the destination on the left. -Data blocks, on the other hand, begin with DC.B, DC.W, or DC.L and each represents a constant numeric value. You do NOT prefix these with # to signify them as constants (doing so will cause an error on most assemblers). However, you can use the $ or % modifiers to denote hexadecimal or binary. + +Data blocks, on the other hand, begin with DC.B, DC.W, or DC.L and each represents a constant numeric value. Strangely, you do NOT prefix these with # to signify them as constants (doing so will cause an error on most assemblers). However, you can use the $ or % modifiers to denote hexadecimal or binary. Keep in mind that there is no requirement to use hexadecimal, decimal, or binary in your source code. It all gets converted to binary anyway. However, it is recommended to use the notation that is appropriate for how your data is meant to be interpreted, for readability purposes. ===Data Registers=== There are eight 32-bit data registers on the 68000, numbered D0-D7. As the name implies, these are designed to hold data. Much like in [[ARM Assembly]], each one is identical in terms of which commands it can use. A command that can be used for D0 can be used for any other D-register. - -MOVE.B #$FF,D0 ;move the hexadecimal value 0xFF into the bottom byte of D0. -ADD.W #$8000,D4 ;add hexadecimal 0x8000 to the value stored in D4. - +MOVE.B #$FF,D0 ;move the hexadecimal value 0xFF into the bottom byte of D0. +ADD.W #$8000,D4 ;add hexadecimal 0x8000 to the value stored in D4. ===Address Registers=== There are eight of these as well, numbered A0-A7. A7 is reserved as the stack pointer, and is commonly referenced as SP in assemblers. The others are free to use for any purpose. Although these registers are 32-bit, the 68000's address space is 24-bit (ranges from 0x000000 to 0xFFFFFF), so the leftmost byte is ignored. You can do simple math involving these registers but more complicated commands like multiply or divide can only be used with data registers. Address registers are used to contain addresses and extract the values stored within. ====Loading From Memory==== - -MOVEA.L #$200000,A2 ;usually these are loaded from a label. +MOVEA.L #$200000,A2 ;usually these are loaded from a label. ;The hex dump of address $200000: 44 55 66 77 MOVE.L #$00000000,D0 MOVE.B (A2),D0 ;load the byte stored at $200000 into D0. D0 = #$00000044 MOVE.W (A2),D0 ;load the word stored at $200000 into D0. D0 = #$00004455 MOVE.L (A2),D0 ;load the long stored at $200000 into D0. D0 = #$44556677 -MOVE.L D2,(A5) ;store the contents of D2 into the memory address pointed to by A5. - +MOVE.L D2,(A5) ;store the contents of D2 into the memory address pointed to by A5. + Note that it's also possible to transfer values to/from memory directly, without involving address registers at all. For constant memory locations, this is fine. However, the real strength of the address registers is in their pre-decrement and post-increment modes, which constant memory locations cannot use. - -MOVE.L ($00FF0000),D0 +MOVE.L ($00FF0000),D0 MOVE.W D1,($00FFFFFE) -MOVE.W ($00FF0000),($00FF1000) - +MOVE.W ($00FF0000),($00FF1000) The use of parentheses is not required on most assemblers, but can be used as a reminder to someone reading your code that these represent the values stored at the specified memory locations rather than literal numbers. ====Post-Increment==== The post-increment mode is specified by adding a + to the end of parentheses. This means that after the command is done, the address stored in the address register (not the value stored at that address) is increased by the byte length of the command (1 for .B, 2 for .W, 4 for .L). - -MOVEA.L #$00240000,A4 ;load the address $240000 into A4 +MOVEA.L #$00240000,A4 ;load the address $240000 into A4 MOVE.W (A4)+,D0 ;move the word stored at $240000 into D0, then increment to #$240002 MOVE.L (A4)+,D1 ;move the long stored at $240000 into D1, then increment to #$240006 -MOVE.L (SP)+,D3 ;pop the top value of the stack into D3 - +MOVE.L (SP)+,D3 ;pop the top value of the stack into D3 ====Pre-Decrement==== The pre-decrement mode is specified by typing a - before the parentheses. This means that before the command is done, the address stored in the address register is decreased by the byte length of the command. -MOVEA.L #$0024000A,A4 ;load the address $24000A into A4 +MOVEA.L #$0024000A,A4 ;load the address $24000A into A4 MOVE.W -(A4),D0 ;move the word stored at $240008 into D0 MOVE.L -(A4),D1 ;move the long stored at $240004 into D1 -MOVE.L D2,-(SP) ;push the contents of D2 onto the stack +MOVE.L D2,-(SP) ;push the contents of D2 onto the stack ====Address Offsets==== A memory address can be offset by a data register, an immediate value, or both. If a data register is used, only the bottom 2 bytes are considered. In either case, the contents of the data register and/or the immediate value are added to the value stored in the address register, and the value is read from that address at the specified length. The offsets are applied during the calculation only; the actual contents in the address register after the move are unchanged. Using a post-increment or pre-decrement with this addressing mode will only update the address by the specified length, not by the offsets. - -MOVE.B (4,A0,D0),D1 ;The byte at A0+D0+4 is loaded into D1. - - +MOVE.B (4,A0,D0),D1 ;The byte at A0+D0+4 is loaded into D1. It's possible to use the same data register as the offset and the destination. This does not cause any problems whatsoever, as the data register offset is "locked in" before the move, and is only updated after the command fully executes. Using the same command again immediately afterwards will offset based on the new value of that register. - -MOVE.W (6,A0,D0),D0 ;The word at A0+D0+6 is read, then loaded into D0. - - +MOVE.W (6,A0,D0),D0 ;The word at A0+D0+6 is read, then loaded into D0. A very important note is that when using this method with words and longs, the resulting address must be even! Otherwise the CPU will crash. For MOVE.B it doesn't matter. ====Effective Address==== A calculated offset can be saved to an address register with the LEA command, which stands for "Load Effective Address." [[x86 Assembly]] also has this command, and it serves the same purpose. The syntax for it can be a bit misleading depending on your assembler. - -LEA myData,A0 ;load the effective address of myData into A0 +LEA myData,A0 ;load the effective address of myData into A0 LEA (4,A0),A1 ;load into A1 the effective address A0+4. This looks like a dereference operation but it is not! -MOVE.W (A1),D1 ;dereference A1, loading the value it points to into D1. - +MOVE.W (A1),D1 ;dereference A1, loading the value it points to into D1. This can get confusing, especially if you have tables of pointers. Just remember that LEA cannot dereference an address. If you don't want to store the effective address in an address register, you can use PEA (push effective address) to put it onto the stack instead. - -LEA myData,A0 ;load the effective address of myData into A0 -PEA (4,A0) ;store the effective address of A0+4 onto the stack. - +LEA myData,A0 ;load the effective address of myData into A0 +PEA (4,A0) ;store the effective address of A0+4 onto the stack. ====The Stack==== The 68000's stack is commonly referred to as SP but it is also address register A7. This register is handled differently than the other address registers when pushing bytes onto the stack. A byte value pushed onto the stack will be padded to the right. The stack needs to pad byte-length data so that it can stay word-aligned at all times. Otherwise the CPU would crash as soon as you tried to use the stack for anything other than a byte! @@ -145,48 +124,48 @@ The 68000 can work with 8-bit, 16-bit, or 32-bit values. Some commands only work If you don't specify a length with your command, it usually defaults to word length, but ultimately it depends on the command you are using. (Some commands cannot be used at word length.) Bytes and words moved into a register are always stored on the right-hand side. For example: - -MOVE.L #$FFFFFFFF,D7 +MOVE.L #$FFFFFFFF,D7 MOVE.B #$00,D7 ;D7 contains #$FFFFFF00 -MOVE.W #$2222,D7 ;D7 contains #$FFFF2222 - +MOVE.W #$2222,D7 ;D7 contains #$FFFF2222 As you can see, the rest of the register is unchanged. (On the ARM, it would turn to zeroes.) This is very important to remember. If your code is doing something unexpected it might be due to the "old" value of the register corrupting another function. If the given constant is smaller than the length provided, the value is padded to the left with zeroes. - -MOVE.W #$FF,D3 ;D3 = #$xxxx00FF, where x is the previous value of D3. -MOVE.L #0,D3 ;D3 = #$00000000 - +MOVE.W #$FF,D3 ;D3 = #$xxxx00FF, where x is the previous value of D3. +MOVE.L #0,D3 ;D3 = #$00000000 Loading immediate values into address registers is different. You can only move words or longer into address registers, and if you move a word, the value is sign-extended. This means that if the top nibble of the word is 8 or greater, the value gets padded to the left with Fs, and is padded with zeroes if the top nibble is 7 or less. If you're adding a constant value less than 7FFF to an address, it's usually safe to use the word length operation, which takes less bytes to encode than the long length version. - -MOVEA.W #$8000,A4 ;A4 = #$FFFF8000. Remember the top byte is ignored so this is the same as #$00FF8000. -MOVEA.W #$7FFF,A3 ;A3 = #$00007FFF - +MOVEA.W #$8000,A4 ;A4 = #$FFFF8000. Remember the top byte is ignored so this is the same as #$00FF8000. +MOVEA.W #$7FFF,A3 ;A3 = #$00007FFF ==The Flags== The flags are stored in the Condition Code Register, also known as the CCR. The 68000 has no built-in commands like CLC for clearing/setting individual flags. Rather, you can alter them directly with MOVE,AND,OR, and EOR. Unfortunately, this means you'll have to remember which bits represent which flags. Or, if your assembler supports macros, you can define a macro that handles this for you. The flags update automatically after most operations, and take into consideration the operand sizes when doing so. Check out this example: - + MOVE.L #$12FF,D0 ADD.B #1,D0 - + Since we used ADD.B, D0 now contains $1200, and the extend, carry, and zero flags are all set. Had we done ADD.W, we would get $1300 in D0 with none of those flags set. The flags are based on what the actual instruction "sees", not the entire register at all times. * X: The eXtend flag is bit 4 of the CCR, and is similar to the carry flag. It gets set and cleared often for the same reasons and is used with the ADDX, SUBX, NEGX, ROXL, and ROXR commands. Why the 68000 has both this and the carry flag, I still don't know. + * N: The negative flag is bit 3 of the CCR, and is set when the last operation resulted in a "negative" value. What constitutes a negative value depends on the size of the last operation - for .B instructions, $80-$FF. For .W instructions, $8000-$FFFF, and for .L instructions, $80000000-$FFFFFFFF. + * Z: The zero flag is bit 2 of the CCR and works like you would expect - it's set whenever an operation results in zero. Unlike x86 Assembly, this also includes moving 0 directly into a register, clearing a register or memory with CLR, etc. + * V: The overflow flag is bit 1 of the CCR. It is set whenever a math operation results in a value crossing the $7F-$80 boundary. (Wraparound from 00 to FF doesn't count as overflow, but it does set the carry flag.) + * C: The carry flag is bit 0 of the CCR. It is set when a math operation results in a carry or borrow. Rolling over from FF to 00, or a 1 getting "pushed out" via a bit shift or rotate, set the carry flag. When using CMP, the carry flag determines the unsigned magnitude comparison. Carry set is less than, carry clear is greater than or equal. + + In truth, the flags are a 16-bit register, of which the CCR is just the "low half". The SR (status register) is the full 16-bit register. There are a few additional flags in the upper half, which are used by the operating system. You can read these but for the most part you won't need to write to them. @@ -210,15 +189,13 @@ The 68000 supports 7 different interrupts, often called IRQs or Interrupt Reques ==Alignment== The 68000 can only read or write words and longs at even addresses. Doing so at an odd address will result in the CPU crashing. (Note that reading byte data will not cause a crash regardless of whether it's located at an odd or even address.) This isn't usually a problem, but it can be if the programmer is not careful with the way their data is organized. Consider the following example: - -TestData: +TestData: DC.B $02 DC.W $0345 LEA TestData,A0 ;load effective address of TestData into A0. MOVE.B (A0)+,D0 ;load $02 into D0, increment A0 by 1 -MOVE.W (A0)+,D1 ;this crashes the CPU since A0 is now odd - +MOVE.W (A0)+,D1 ;this crashes the CPU since A0 is now odd How was it known that the address was odd at the second instruction? Simple. All instructions take an even number of bytes to encode. So there are only a few ways improper alignment can occur: * An odd value is loaded into an address register. @@ -228,23 +205,18 @@ How was it known that the address was odd at the second instruction? Simple. All If the programmer is smart with the way they encode byte-length data they can avoid this problem entirely with little effort. One way is to separate byte-length data into its own table. - -ByteData: +ByteData: DC.B $20,$40,$60,$80 WordData: -DC.W $1000,$2000,$3000,$4000 - +DC.W $1000,$2000,$3000,$4000 Another way is to pad the data with an extra byte, so that there is an even number of entries in the table. This becomes impractical with large data tables, so the EVEN directive can be placed after a series of bytes. If the byte count is odd, EVEN will pad the data with an extra byte. If it's already even, the EVEN command is ignored. This saves you the trouble of having to count a long series of bytes without worrying about wasting space. - -MyString: DC.B "HELLO WORLD 12345678900000",0 -EVEN ;some assemblers require this to be on its own line - +MyString: DC.B "HELLO WORLD 12345678900000",0 +EVEN ;some assemblers require this to be on its own line A third way is to perform a "dummy read." This is when a value is read from an address using pre-decrement or post-increment, with the sole purpose of moving the pointer, and the value being read is of zero interest. This method lets you work with mixed data types in the same table, but it requires the programmer to know in advance where the byte-length data begins and ends. - -TestData: +TestData: DC.B $02,$03,$04 DC.W $0345 @@ -255,8 +227,7 @@ MOVE.B (A0)+,(A1)+ ;copy $04 to a new memory location ;if we did MOVE.W (A0)+,(A1)+ now we'd crash. First we need to adjust the pointers. MOVE.B (A0)+,D7 ;dummy read to D7. Now A0 is word aligned. MOVE.B (A1)+,D7 ;dummy read to D7. Now A1 is word aligned. -MOVE.W (A0)+,(A1)+ ;copy $0345 to a new memory location - +MOVE.W (A0)+,(A1)+ ;copy $0345 to a new memory location Using ADDA.L #1,A0 and ADDA.L #1,A1 would have worked also, instead of the dummy read. The 68000 gives the programmer a lot of different ways to do a task. diff --git a/Lang/68000-Assembly/Musical-scale b/Lang/68000-Assembly/Musical-scale deleted file mode 120000 index 0a23b13b4e..0000000000 --- a/Lang/68000-Assembly/Musical-scale +++ /dev/null @@ -1 +0,0 @@ -../../Task/Musical-scale/68000-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Align-columns b/Lang/8080-Assembly/Align-columns deleted file mode 120000 index d9134cb487..0000000000 --- a/Lang/8080-Assembly/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Display-a-linear-combination b/Lang/8080-Assembly/Display-a-linear-combination deleted file mode 120000 index 5e499be357..0000000000 --- a/Lang/8080-Assembly/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Idiomatically-determine-all-the-lowercase-and-uppercase-letters b/Lang/8080-Assembly/Idiomatically-determine-all-the-lowercase-and-uppercase-letters deleted file mode 120000 index 9a4e5be197..0000000000 --- a/Lang/8080-Assembly/Idiomatically-determine-all-the-lowercase-and-uppercase-letters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Integer-comparison b/Lang/8080-Assembly/Integer-comparison deleted file mode 120000 index e48c1e8ea4..0000000000 --- a/Lang/8080-Assembly/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Loops-Infinite b/Lang/8080-Assembly/Loops-Infinite deleted file mode 120000 index f6336ebca0..0000000000 --- a/Lang/8080-Assembly/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/McNuggets-problem b/Lang/8080-Assembly/McNuggets-problem deleted file mode 120000 index 69d7be7c03..0000000000 --- a/Lang/8080-Assembly/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Ordered-words b/Lang/8080-Assembly/Ordered-words deleted file mode 120000 index eee238f68d..0000000000 --- a/Lang/8080-Assembly/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Repeat-a-string b/Lang/8080-Assembly/Repeat-a-string deleted file mode 120000 index 8f626bb358..0000000000 --- a/Lang/8080-Assembly/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Run-length-encoding b/Lang/8080-Assembly/Run-length-encoding deleted file mode 120000 index bc3ed9076c..0000000000 --- a/Lang/8080-Assembly/Run-length-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/Run-length-encoding/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Sieve-of-Eratosthenes b/Lang/8080-Assembly/Sieve-of-Eratosthenes deleted file mode 120000 index ddc8441b98..0000000000 --- a/Lang/8080-Assembly/Sieve-of-Eratosthenes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Eratosthenes/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Square-but-not-cube b/Lang/8080-Assembly/Square-but-not-cube deleted file mode 120000 index e8de867485..0000000000 --- a/Lang/8080-Assembly/Square-but-not-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-but-not-cube/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Twos-complement b/Lang/8080-Assembly/Twos-complement deleted file mode 120000 index 86928fcdc9..0000000000 --- a/Lang/8080-Assembly/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/8080-Assembly \ No newline at end of file diff --git a/Lang/8080-Assembly/Zeckendorf-number-representation b/Lang/8080-Assembly/Zeckendorf-number-representation deleted file mode 120000 index b0569b898c..0000000000 --- a/Lang/8080-Assembly/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/8080-Assembly \ No newline at end of file diff --git a/Lang/8086-Assembly/00-LANG.txt b/Lang/8086-Assembly/00-LANG.txt index 9120d12d87..7cf10761fa 100644 --- a/Lang/8086-Assembly/00-LANG.txt +++ b/Lang/8086-Assembly/00-LANG.txt @@ -4,13 +4,13 @@ ===Segmented Memory=== The 8086 uses a segmented memory model, similar to the Super Nintendo Entertainment System. Unlike banked memory models used in the Commodore 64 and late NES games, segment addresses are held in segment registers. These segment registers are 16 bit and get left-shifted by 4 and added to the pointer register of interest to determine the memory address to look up. The 8086 has four in total, but only the DS and ES registers can be used by the programmer. (The other two work with the stack pointer and instruction pointer, and are loaded for you.) On the 8086, you can only load segment registers with the value in a data register, or with the POP command. So first you must load a segment into a data register, THEN into a segment register. -;This is NOT valid code! +;This is NOT valid code! mov ds, @data ;you're trying to move the data segment location directly into DS. You can't! ;This is the proper way: mov ax, @data ;I chose AX but I could have used BX, CX, or DX. -mov ds, ax ;load DS with the data segment. +mov ds, ax ;load DS with the data segment. It's important to remember the subtle distinction between a ''segment'' and a ''segment register.'' Your program might have labeled ''segments'' such as .data and .code, but in order to properly read from/write to these sections you'll need to load their memory locations into ''segment registers.'' @@ -18,17 +18,17 @@ It's important to remember the subtle distinction between a ''segment'' and a '' There are four data registers: AX, BX, CX, and DX. While most commands can use any of them, some only work with particular data registers. System calls in particular are very specific about which registers can be used for what. On [[MS-DOS]], the AX register is used for selecting the desired interrupt to use with the INT command. Each data register is 16-bit, but has two eight bit halves ending in H or L, e.g. AH, AL. Instructions can be executed using the whole register or just half of it. -mov ax, 1000h ;move 1000h into AX, or equivalently, move 10h into AH and 00h into AL. +mov ax, 1000h ;move 1000h into AX, or equivalently, move 10h into AH and 00h into AL. Moving a value smaller than 16 bits into ?X is the same as moving it into ?L, and moving 0 into ?H. (? represents the data register of your choice. They are all the same in this regard.) -mov ax,0030h +mov ax,0030h ;is the same as: mov al, 30h -mov ah, 0h +mov ah, 0h Commands that alter the contents of a single register will not affect the other half. -mov ax,00FFh -inc al +mov ax,00FFh +inc al If we had executed INC AX, then AX would have been incremented to 0x100. Since we only incremented AL, only AL was incremented in this case, and AH '''still equals 0x00!''' Generally speaking, the 8086's registers serve the following purposes: @@ -42,24 +42,24 @@ When writing to or reading from consecutive sections of memory, it is helpful to The syntax for offsetting an index register will vary depending on your assembler. Many assemblers will often accept multiple different ways of writing it, and it comes down to personal preference. -mov si, offset MyArray +mov si, offset MyArray mov bx,2 mov al,[bx+si] ;loads decimal 30 into AL MyArray: -byte 10,20,30,40,50 +byte 10,20,30,40,50 ===The Stack=== As with [[Z80 Assembly]], you can't push 8-bit registers onto the stack. For data registers, you have to push/pop both halves. -;This is valid code. +;This is valid code. push ax push bx pop bx pop ax -;This is NOT valid code. +;This is NOT valid code. push ah push al push bh @@ -69,14 +69,14 @@ push bl pop bl pop bh pop al -pop ah +pop ah As with all processors that use a stack, if you push one or more registers and want to restore the backed-up values correctly, you must pop them in the reverse order. You can pop them out of order on purpose to swap registers around. In fact, this is a quick way to move the segment from DS into ES, or vice-versa: -push DS -pop ES ;you can't do "mov es, ds" but you can do this! +push DS +pop ES ;you can't do "mov es, ds" but you can do this! The proper way to use the stack to preserve registers: - + call foo mov ax,4C00h @@ -91,7 +91,7 @@ push cx pop cx pop bx pop ax -ret +ret If one of the push/pop commands in the routine above were missing, the RET instruction would not properly return to where it came from. As long as you pop at the end the same number of registers you pushed at the start, the stack is "balanced" and your return instruction will return correctly. This is because RET is actually POP IP (IP being the instruction pointer, which you can think of as what "line" of code the CPU is on.) The CPU assumes the top of the stack is the correct place to return to, but has no way of actually verifying it. If the function you just wrote causes the CPU to crash or jump to a completely different part of the code, there's a good chance you might have forgotten to balance the stack properly. @@ -107,40 +107,40 @@ One other caveat to mention: On early IBM PCs and compatibles, the 8087 was not ===Looping Constructs=== The 8086 has a lot more of these than most CPUs. The most obvious one is LOOP, which will subtract 1 from CX, then jump back to a specified label if CX is nonzero after the subtraction. If CX becomes zero after subtracting 1, then no jump will occur and the instruction pointer simply moves to the next instruction. -mov cx,0100h ;set the loop counter's starting value. This must be outside the loop, otherwise you'll loop forever! +mov cx,0100h ;set the loop counter's starting value. This must be outside the loop, otherwise you'll loop forever! foo: ;; your code that you want to loop goes here -loop foo +loop foo It's important not to alter CX inside the loop. It's easy to make a mistake like this if you're in a hurry: -foobar: +foobar: mov cx,1000h ;your code goes here -loop foobar +loop foobar It may not be obvious at first but the above loop will never end. CX decrements to 0x0FFF with the LOOP instruction but the mov cx,1000h was mistakenly placed ''inside'' the loop, resetting the loop counter back to 0x1000, which means no progress is really being made. The correct way to do this is to set the starting loop counter '''outside''' the loop, like so: -mov cx,1000h +mov cx,1000h foobar: ;your code goes here -loop foobar +loop foobar Sometimes you'll have to change CX during a loop, like if you want to do bit shifts with a shift amount other than 1, for example. There's a simple fix - use the stack to stash and retrieve the loop counter. -mov cx,0100h +mov cx,0100h foo: push cx mov cl,2 ror ax,cl ;starting with the 80186 you don't need CL for bit shifting. pop cx -loop foo +loop foo By using PUSH CX and POP CX, you can temporarily use CX for something else, as long as you restore it before the LOOP instruction. You can use other registers as loop counters as well, but not with the LOOP instruction - it's hardcoded to only work with CX. But you can do this: -mov dx,0100h +mov dx,0100h baz: ;your code goes here dec dx @@ -148,7 +148,7 @@ jnz baz ; A minor note for advanced programmers: ; If you're expecting the flags to be in a particular state based on the loop body, tough luck! ; They'll only reflect the decrement of DX from 1 to 0 at this point in the code. -; LOOP doesn't change the flags, which makes it more useful for loops meant to compare things. +; LOOP doesn't change the flags, which makes it more useful for loops meant to compare things. Another frequently used looping construct is REP. REP can be combined with certain instructions to repeat that instruction until CX equals zero. However, unlike LOOP, which can be used to repeat a block of instructions, REP can only repeat one. It doesn't work on all instructions, only the "string" instructions which operate on a block of memory. Typically these include MOVSB, LODSB, STOSB, CMPSB, and SCASB (each has a variant that ends in W instead of B, for 16-bit data.) There are also REPZ and REPNZ, which stand for "Repeat if Zero" and "Repeat if Nonzero" respectively. These two only work properly with CMPSB and SCASB, as MOVSB, LODSB, STOSB do not affect the flags. (The CPU doesn't detect whether CX equals zero using the flags, as the flags never reflect this equality to zero like you would expect.) diff --git a/Lang/8th/Angle-difference-between-two-bearings b/Lang/8th/Angle-difference-between-two-bearings deleted file mode 120000 index 9cc882831f..0000000000 --- a/Lang/8th/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/8th \ No newline at end of file diff --git a/Lang/8th/Environment-variables b/Lang/8th/Environment-variables deleted file mode 120000 index f15e7e1793..0000000000 --- a/Lang/8th/Environment-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Environment-variables/8th \ No newline at end of file diff --git a/Lang/8th/Factorial b/Lang/8th/Factorial deleted file mode 120000 index dde7e52e98..0000000000 --- a/Lang/8th/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/8th \ No newline at end of file diff --git a/Lang/AArch64-Assembly/ADFGVX-cipher b/Lang/AArch64-Assembly/ADFGVX-cipher deleted file mode 120000 index 7d98e5eba8..0000000000 --- a/Lang/AArch64-Assembly/ADFGVX-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/ADFGVX-cipher/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Averages-Median b/Lang/AArch64-Assembly/Averages-Median deleted file mode 120000 index ae6afbd2a3..0000000000 --- a/Lang/AArch64-Assembly/Averages-Median +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Median/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Best-shuffle b/Lang/AArch64-Assembly/Best-shuffle deleted file mode 120000 index a0951b5654..0000000000 --- a/Lang/AArch64-Assembly/Best-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Best-shuffle/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Bifid-cipher b/Lang/AArch64-Assembly/Bifid-cipher deleted file mode 120000 index 57b7c95a81..0000000000 --- a/Lang/AArch64-Assembly/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Binary-strings b/Lang/AArch64-Assembly/Binary-strings deleted file mode 120000 index 09d5581057..0000000000 --- a/Lang/AArch64-Assembly/Binary-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-strings/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Caesar-cipher b/Lang/AArch64-Assembly/Caesar-cipher deleted file mode 120000 index 8586c46410..0000000000 --- a/Lang/AArch64-Assembly/Caesar-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Caesar-cipher/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Calculating-the-value-of-e b/Lang/AArch64-Assembly/Calculating-the-value-of-e deleted file mode 120000 index 6be0e9e4dd..0000000000 --- a/Lang/AArch64-Assembly/Calculating-the-value-of-e +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calculating-the-value-of-e/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Comma-quibbling b/Lang/AArch64-Assembly/Comma-quibbling deleted file mode 120000 index 09eae1e29d..0000000000 --- a/Lang/AArch64-Assembly/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Command-line-arguments b/Lang/AArch64-Assembly/Command-line-arguments deleted file mode 120000 index d0fecfd5c5..0000000000 --- a/Lang/AArch64-Assembly/Command-line-arguments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Command-line-arguments/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Compound-data-type b/Lang/AArch64-Assembly/Compound-data-type deleted file mode 120000 index 5e69c433e8..0000000000 --- a/Lang/AArch64-Assembly/Compound-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compound-data-type/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Conways-Game-of-Life b/Lang/AArch64-Assembly/Conways-Game-of-Life deleted file mode 120000 index 048d5e56cd..0000000000 --- a/Lang/AArch64-Assembly/Conways-Game-of-Life +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conways-Game-of-Life/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Count-occurrences-of-a-substring b/Lang/AArch64-Assembly/Count-occurrences-of-a-substring deleted file mode 120000 index 5199f80ebc..0000000000 --- a/Lang/AArch64-Assembly/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Create-an-HTML-table b/Lang/AArch64-Assembly/Create-an-HTML-table deleted file mode 120000 index 53d9451773..0000000000 --- a/Lang/AArch64-Assembly/Create-an-HTML-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-an-HTML-table/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Determine-sentence-type b/Lang/AArch64-Assembly/Determine-sentence-type deleted file mode 120000 index 9e5de0c792..0000000000 --- a/Lang/AArch64-Assembly/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Environment-variables b/Lang/AArch64-Assembly/Environment-variables deleted file mode 120000 index bf37f1b011..0000000000 --- a/Lang/AArch64-Assembly/Environment-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Environment-variables/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Fibonacci-n-step-number-sequences b/Lang/AArch64-Assembly/Fibonacci-n-step-number-sequences deleted file mode 120000 index 27c6d5155d..0000000000 --- a/Lang/AArch64-Assembly/Fibonacci-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-n-step-number-sequences/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Fibonacci-sequence b/Lang/AArch64-Assembly/Fibonacci-sequence deleted file mode 120000 index 1b2a811917..0000000000 --- a/Lang/AArch64-Assembly/Fibonacci-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-sequence/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Filter b/Lang/AArch64-Assembly/Filter deleted file mode 120000 index d64eba35c1..0000000000 --- a/Lang/AArch64-Assembly/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Halt-and-catch-fire b/Lang/AArch64-Assembly/Halt-and-catch-fire deleted file mode 120000 index fcd91d9797..0000000000 --- a/Lang/AArch64-Assembly/Halt-and-catch-fire +++ /dev/null @@ -1 +0,0 @@ -../../Task/Halt-and-catch-fire/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Hash-from-two-arrays b/Lang/AArch64-Assembly/Hash-from-two-arrays deleted file mode 120000 index 8f4af92c06..0000000000 --- a/Lang/AArch64-Assembly/Hash-from-two-arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hash-from-two-arrays/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Hofstadter-Q-sequence b/Lang/AArch64-Assembly/Hofstadter-Q-sequence deleted file mode 120000 index 249eb0836e..0000000000 --- a/Lang/AArch64-Assembly/Hofstadter-Q-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hofstadter-Q-sequence/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Jewels-and-stones b/Lang/AArch64-Assembly/Jewels-and-stones deleted file mode 120000 index 0605fcd226..0000000000 --- a/Lang/AArch64-Assembly/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/K-d-tree b/Lang/AArch64-Assembly/K-d-tree deleted file mode 120000 index bbee299c41..0000000000 --- a/Lang/AArch64-Assembly/K-d-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/K-d-tree/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/AArch64-Assembly/Keyboard-input-Obtain-a-Y-or-N-response deleted file mode 120000 index ea8bafc85e..0000000000 --- a/Lang/AArch64-Assembly/Keyboard-input-Obtain-a-Y-or-N-response +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Obtain-a-Y-or-N-response/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Leonardo-numbers b/Lang/AArch64-Assembly/Leonardo-numbers deleted file mode 120000 index c954cc6b34..0000000000 --- a/Lang/AArch64-Assembly/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Letter-frequency b/Lang/AArch64-Assembly/Letter-frequency deleted file mode 120000 index c225fbca5f..0000000000 --- a/Lang/AArch64-Assembly/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Logical-operations b/Lang/AArch64-Assembly/Logical-operations deleted file mode 120000 index c765c862aa..0000000000 --- a/Lang/AArch64-Assembly/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Machine-code b/Lang/AArch64-Assembly/Machine-code deleted file mode 120000 index 0510df24d2..0000000000 --- a/Lang/AArch64-Assembly/Machine-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Machine-code/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Magic-8-ball b/Lang/AArch64-Assembly/Magic-8-ball deleted file mode 120000 index 1c232e0832..0000000000 --- a/Lang/AArch64-Assembly/Magic-8-ball +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-8-ball/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Mandelbrot-set b/Lang/AArch64-Assembly/Mandelbrot-set deleted file mode 120000 index 8e4411d4d0..0000000000 --- a/Lang/AArch64-Assembly/Mandelbrot-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mandelbrot-set/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Menu b/Lang/AArch64-Assembly/Menu deleted file mode 120000 index 5b0688a2c5..0000000000 --- a/Lang/AArch64-Assembly/Menu +++ /dev/null @@ -1 +0,0 @@ -../../Task/Menu/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Phrase-reversals b/Lang/AArch64-Assembly/Phrase-reversals deleted file mode 120000 index 65751e913c..0000000000 --- a/Lang/AArch64-Assembly/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Pi b/Lang/AArch64-Assembly/Pi deleted file mode 120000 index 34be149f2d..0000000000 --- a/Lang/AArch64-Assembly/Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pi/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Quickselect-algorithm b/Lang/AArch64-Assembly/Quickselect-algorithm deleted file mode 120000 index 44e60cf3ef..0000000000 --- a/Lang/AArch64-Assembly/Quickselect-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quickselect-algorithm/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Read-a-configuration-file b/Lang/AArch64-Assembly/Read-a-configuration-file deleted file mode 120000 index 869fc1989f..0000000000 --- a/Lang/AArch64-Assembly/Read-a-configuration-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-configuration-file/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Repeat-a-string b/Lang/AArch64-Assembly/Repeat-a-string deleted file mode 120000 index c83eefd8df..0000000000 --- a/Lang/AArch64-Assembly/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Reverse-words-in-a-string b/Lang/AArch64-Assembly/Reverse-words-in-a-string deleted file mode 120000 index 2f40f86595..0000000000 --- a/Lang/AArch64-Assembly/Reverse-words-in-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-words-in-a-string/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Rot-13 b/Lang/AArch64-Assembly/Rot-13 deleted file mode 120000 index 61abc02e49..0000000000 --- a/Lang/AArch64-Assembly/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Sort-disjoint-sublist b/Lang/AArch64-Assembly/Sort-disjoint-sublist deleted file mode 120000 index af0be59923..0000000000 --- a/Lang/AArch64-Assembly/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Sorting-Algorithms-Circle-Sort b/Lang/AArch64-Assembly/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..6922a69550 --- /dev/null +++ b/Lang/AArch64-Assembly/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/String-case b/Lang/AArch64-Assembly/String-case deleted file mode 120000 index ec1194b1f0..0000000000 --- a/Lang/AArch64-Assembly/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Strip-block-comments b/Lang/AArch64-Assembly/Strip-block-comments deleted file mode 120000 index 4a2741cf35..0000000000 --- a/Lang/AArch64-Assembly/Strip-block-comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-block-comments/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Strip-comments-from-a-string b/Lang/AArch64-Assembly/Strip-comments-from-a-string deleted file mode 120000 index 1e7fb59c48..0000000000 --- a/Lang/AArch64-Assembly/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Strip-whitespace-from-a-string-Top-and-tail b/Lang/AArch64-Assembly/Strip-whitespace-from-a-string-Top-and-tail deleted file mode 120000 index 115198d3ea..0000000000 --- a/Lang/AArch64-Assembly/Strip-whitespace-from-a-string-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-whitespace-from-a-string-Top-and-tail/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Substitution-cipher b/Lang/AArch64-Assembly/Substitution-cipher deleted file mode 120000 index 05b1886853..0000000000 --- a/Lang/AArch64-Assembly/Substitution-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substitution-cipher/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Twos-complement b/Lang/AArch64-Assembly/Twos-complement deleted file mode 120000 index 92454eff57..0000000000 --- a/Lang/AArch64-Assembly/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Update-a-configuration-file b/Lang/AArch64-Assembly/Update-a-configuration-file deleted file mode 120000 index c28afd01b6..0000000000 --- a/Lang/AArch64-Assembly/Update-a-configuration-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Update-a-configuration-file/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Vigen-re-cipher b/Lang/AArch64-Assembly/Vigen-re-cipher deleted file mode 120000 index 02254d1d9a..0000000000 --- a/Lang/AArch64-Assembly/Vigen-re-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vigen-re-cipher/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Vigen-re-cipher-Cryptanalysis b/Lang/AArch64-Assembly/Vigen-re-cipher-Cryptanalysis deleted file mode 120000 index cc7f7e2227..0000000000 --- a/Lang/AArch64-Assembly/Vigen-re-cipher-Cryptanalysis +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vigen-re-cipher-Cryptanalysis/AArch64-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Visualize-a-tree b/Lang/AArch64-Assembly/Visualize-a-tree deleted file mode 120000 index a3e4c5223f..0000000000 --- a/Lang/AArch64-Assembly/Visualize-a-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/Visualize-a-tree/AArch64-Assembly \ No newline at end of file diff --git a/Lang/ABAP/00-LANG.txt b/Lang/ABAP/00-LANG.txt index 819bd4cbc5..446b44c265 100644 --- a/Lang/ABAP/00-LANG.txt +++ b/Lang/ABAP/00-LANG.txt @@ -1,14 +1,2 @@ -{{stub}}{{language -|site=http://www.sdn.sap.com/irj/sdn/abap -|safety=safe -|strength=strong -|compat=nominative -|checking=static -|tags=abap}} -ABAP (Advanced Business Application Programming) is a programming language developed by the german software vendor SAP. It is mainly used to build high performance business applications. - -==Citation== -*[https://en.wikipedia.org/wiki/ABAP] - -[[Category:Programming paradigm/Object-oriented]] -[[Category:Programming paradigm/Imperative]] \ No newline at end of file +{{stub}}{{language|site=http://www.sdn.sap.com/irj/sdn/abap}} +ABAP (Advanced Business Application Programming) is a programming language developed by the german software vendor SAP. It is mainly used to build high performance business applications. \ No newline at end of file diff --git a/Lang/ABC/00-LANG.txt b/Lang/ABC/00-LANG.txt deleted file mode 100644 index 115426b099..0000000000 --- a/Lang/ABC/00-LANG.txt +++ /dev/null @@ -1,18 +0,0 @@ -{{language -|exec=interpreted -|site=https://homepages.cwi.nl/~steven/abc/ -|strength=strong -|safety=safe -|express=implicit -|checking=dynamic -|parampass=value, reference -|gc=yes}}{{language programming paradigm|Dynamic}}{{language programming paradigm|Imperative}} - -'''ABC''' is a programming language and development environment developed for teaching purposes at the National Research Institute for Mathematics and Computer Science in the Netherlands in the late 80s. It was meant to be a replacement for BASIC in teaching programming to students. The language was meant to be used interactively. Instead of traditional source files, the environment uses workspaces, though the UNIX version does have (rather minimal) script support. Function definitions and global variables persist from session to session without the user having to explicitly save or load them. The environment furthermore includes autocompletion and a syntax-aware editor. There is no supported way to access the underlying OS or file system directly. The tight integration between the language implementation and the IDE turned out to be a barrier to expansion, and the language was largely abandoned in the early 90s. - -There is an unfortunate bug in the official interpreter: it switches to the alternate terminal screen even when running a non-interactive script, resulting in the output being invisible. A workaround is to specify a terminal type that does not support it, e.g. TERM=vt100 abc script.abc. - -==References== - -* [https://homepages.cwi.nl/~steven/abc/ Official homepage] -* [[wp:ABC_(programming_language)|ABC on Wikipedia]] \ No newline at end of file diff --git a/Lang/ABC/00-META.yaml b/Lang/ABC/00-META.yaml deleted file mode 100644 index 967764ae5a..0000000000 --- a/Lang/ABC/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:ABC diff --git a/Lang/ABC/100-doors b/Lang/ABC/100-doors deleted file mode 120000 index aa28ef076f..0000000000 --- a/Lang/ABC/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/ABC \ No newline at end of file diff --git a/Lang/ABC/100-prisoners b/Lang/ABC/100-prisoners deleted file mode 120000 index 8788c6225a..0000000000 --- a/Lang/ABC/100-prisoners +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-prisoners/ABC \ No newline at end of file diff --git a/Lang/ABC/99-bottles-of-beer b/Lang/ABC/99-bottles-of-beer deleted file mode 120000 index a68c0a17d5..0000000000 --- a/Lang/ABC/99-bottles-of-beer +++ /dev/null @@ -1 +0,0 @@ -../../Task/99-bottles-of-beer/ABC \ No newline at end of file diff --git a/Lang/ABC/ABC-problem b/Lang/ABC/ABC-problem deleted file mode 120000 index 925929a8aa..0000000000 --- a/Lang/ABC/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/ABC \ No newline at end of file diff --git a/Lang/ABC/Abundant-deficient-and-perfect-number-classifications b/Lang/ABC/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index 7990ee28e5..0000000000 --- a/Lang/ABC/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/ABC \ No newline at end of file diff --git a/Lang/ABC/Ackermann-function b/Lang/ABC/Ackermann-function deleted file mode 120000 index 6fc443bd8e..0000000000 --- a/Lang/ABC/Ackermann-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ackermann-function/ABC \ No newline at end of file diff --git a/Lang/ABC/Additive-primes b/Lang/ABC/Additive-primes deleted file mode 120000 index d085a6bcbd..0000000000 --- a/Lang/ABC/Additive-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Additive-primes/ABC \ No newline at end of file diff --git a/Lang/ABC/Amicable-pairs b/Lang/ABC/Amicable-pairs deleted file mode 120000 index 144f4590ee..0000000000 --- a/Lang/ABC/Amicable-pairs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amicable-pairs/ABC \ No newline at end of file diff --git a/Lang/ABC/Arithmetic-derivative b/Lang/ABC/Arithmetic-derivative deleted file mode 120000 index 4225078056..0000000000 --- a/Lang/ABC/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/ABC \ No newline at end of file diff --git a/Lang/ABC/Attractive-numbers b/Lang/ABC/Attractive-numbers deleted file mode 120000 index c59a0c88ac..0000000000 --- a/Lang/ABC/Attractive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Attractive-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Benfords-law b/Lang/ABC/Benfords-law deleted file mode 120000 index f24a94d25a..0000000000 --- a/Lang/ABC/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/ABC \ No newline at end of file diff --git a/Lang/ABC/Bulls-and-cows b/Lang/ABC/Bulls-and-cows deleted file mode 120000 index fdc423bf64..0000000000 --- a/Lang/ABC/Bulls-and-cows +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bulls-and-cows/ABC \ No newline at end of file diff --git a/Lang/ABC/Casting-out-nines b/Lang/ABC/Casting-out-nines deleted file mode 120000 index 9c27786e27..0000000000 --- a/Lang/ABC/Casting-out-nines +++ /dev/null @@ -1 +0,0 @@ -../../Task/Casting-out-nines/ABC \ No newline at end of file diff --git a/Lang/ABC/Comma-quibbling b/Lang/ABC/Comma-quibbling deleted file mode 120000 index f67b3a793a..0000000000 --- a/Lang/ABC/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/ABC \ No newline at end of file diff --git a/Lang/ABC/Department-numbers b/Lang/ABC/Department-numbers deleted file mode 120000 index e903532bc7..0000000000 --- a/Lang/ABC/Department-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Department-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Evolutionary-algorithm b/Lang/ABC/Evolutionary-algorithm deleted file mode 120000 index d5319b5c74..0000000000 --- a/Lang/ABC/Evolutionary-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evolutionary-algorithm/ABC \ No newline at end of file diff --git a/Lang/ABC/FizzBuzz b/Lang/ABC/FizzBuzz deleted file mode 120000 index e507dc5bb8..0000000000 --- a/Lang/ABC/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/ABC \ No newline at end of file diff --git a/Lang/ABC/Floyds-triangle b/Lang/ABC/Floyds-triangle deleted file mode 120000 index b0745131ab..0000000000 --- a/Lang/ABC/Floyds-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyds-triangle/ABC \ No newline at end of file diff --git a/Lang/ABC/Giuga-numbers b/Lang/ABC/Giuga-numbers deleted file mode 120000 index 4e8c5ed3a1..0000000000 --- a/Lang/ABC/Giuga-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Giuga-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Hailstone-sequence b/Lang/ABC/Hailstone-sequence deleted file mode 120000 index 22e4b3a8d2..0000000000 --- a/Lang/ABC/Hailstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hailstone-sequence/ABC \ No newline at end of file diff --git a/Lang/ABC/Happy-numbers b/Lang/ABC/Happy-numbers deleted file mode 120000 index ffdb78b473..0000000000 --- a/Lang/ABC/Happy-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Happy-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Harshad-or-Niven-series b/Lang/ABC/Harshad-or-Niven-series deleted file mode 120000 index c460a71d92..0000000000 --- a/Lang/ABC/Harshad-or-Niven-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harshad-or-Niven-series/ABC \ No newline at end of file diff --git a/Lang/ABC/Hofstadter-Figure-Figure-sequences b/Lang/ABC/Hofstadter-Figure-Figure-sequences deleted file mode 120000 index e400cd4b2d..0000000000 --- a/Lang/ABC/Hofstadter-Figure-Figure-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hofstadter-Figure-Figure-sequences/ABC \ No newline at end of file diff --git a/Lang/ABC/ISBN13-check-digit b/Lang/ABC/ISBN13-check-digit deleted file mode 120000 index 466684d948..0000000000 --- a/Lang/ABC/ISBN13-check-digit +++ /dev/null @@ -1 +0,0 @@ -../../Task/ISBN13-check-digit/ABC \ No newline at end of file diff --git a/Lang/ABC/Jewels-and-stones b/Lang/ABC/Jewels-and-stones deleted file mode 120000 index 2a5e2026f3..0000000000 --- a/Lang/ABC/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/ABC \ No newline at end of file diff --git a/Lang/ABC/Lah-numbers b/Lang/ABC/Lah-numbers deleted file mode 120000 index 264201bfe1..0000000000 --- a/Lang/ABC/Lah-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Lah-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Look-and-say-sequence b/Lang/ABC/Look-and-say-sequence deleted file mode 120000 index 68b9661932..0000000000 --- a/Lang/ABC/Look-and-say-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Look-and-say-sequence/ABC \ No newline at end of file diff --git a/Lang/ABC/McNuggets-problem b/Lang/ABC/McNuggets-problem deleted file mode 120000 index 95e79a5323..0000000000 --- a/Lang/ABC/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/ABC \ No newline at end of file diff --git a/Lang/ABC/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/ABC/Minimum-multiple-of-m-where-digital-sum-equals-m deleted file mode 120000 index 6ff647f8c0..0000000000 --- a/Lang/ABC/Minimum-multiple-of-m-where-digital-sum-equals-m +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/ABC \ No newline at end of file diff --git a/Lang/ABC/Munchausen-numbers b/Lang/ABC/Munchausen-numbers deleted file mode 120000 index e52466affe..0000000000 --- a/Lang/ABC/Munchausen-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munchausen-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Mutual-recursion b/Lang/ABC/Mutual-recursion deleted file mode 120000 index 7c52c1cb81..0000000000 --- a/Lang/ABC/Mutual-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mutual-recursion/ABC \ No newline at end of file diff --git a/Lang/ABC/Population-count b/Lang/ABC/Population-count deleted file mode 120000 index 6bd44c7e1e..0000000000 --- a/Lang/ABC/Population-count +++ /dev/null @@ -1 +0,0 @@ -../../Task/Population-count/ABC \ No newline at end of file diff --git a/Lang/ABC/Primality-by-trial-division b/Lang/ABC/Primality-by-trial-division deleted file mode 120000 index 811bc718a5..0000000000 --- a/Lang/ABC/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/ABC \ No newline at end of file diff --git a/Lang/ABC/Rep-string b/Lang/ABC/Rep-string deleted file mode 120000 index 23f495d764..0000000000 --- a/Lang/ABC/Rep-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rep-string/ABC \ No newline at end of file diff --git a/Lang/ABC/Sequence-of-non-squares b/Lang/ABC/Sequence-of-non-squares deleted file mode 120000 index 0a7560127a..0000000000 --- a/Lang/ABC/Sequence-of-non-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-non-squares/ABC \ No newline at end of file diff --git a/Lang/ABC/Sieve-of-Eratosthenes b/Lang/ABC/Sieve-of-Eratosthenes deleted file mode 120000 index 83a8ebdf80..0000000000 --- a/Lang/ABC/Sieve-of-Eratosthenes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Eratosthenes/ABC \ No newline at end of file diff --git a/Lang/ABC/Smith-numbers b/Lang/ABC/Smith-numbers deleted file mode 120000 index ce68a2f99a..0000000000 --- a/Lang/ABC/Smith-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smith-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Square-but-not-cube b/Lang/ABC/Square-but-not-cube deleted file mode 120000 index 23a046e711..0000000000 --- a/Lang/ABC/Square-but-not-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-but-not-cube/ABC \ No newline at end of file diff --git a/Lang/ABC/Strip-a-set-of-characters-from-a-string b/Lang/ABC/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index c29767f86b..0000000000 --- a/Lang/ABC/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/ABC \ No newline at end of file diff --git a/Lang/ABC/Towers-of-Hanoi b/Lang/ABC/Towers-of-Hanoi deleted file mode 120000 index 37fe93f842..0000000000 --- a/Lang/ABC/Towers-of-Hanoi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Towers-of-Hanoi/ABC \ No newline at end of file diff --git a/Lang/ABC/Van-Eck-sequence b/Lang/ABC/Van-Eck-sequence deleted file mode 120000 index 6661779e7c..0000000000 --- a/Lang/ABC/Van-Eck-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-Eck-sequence/ABC \ No newline at end of file diff --git a/Lang/ABC/Zeckendorf-number-representation b/Lang/ABC/Zeckendorf-number-representation deleted file mode 120000 index 8384d29a12..0000000000 --- a/Lang/ABC/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/ABC \ No newline at end of file diff --git a/Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt b/Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt deleted file mode 100644 index c25a056976..0000000000 --- a/Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt +++ /dev/null @@ -1 +0,0 @@ -{{stub}}{{language|Ayrch}} \ No newline at end of file diff --git a/Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml b/Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml deleted file mode 100644 index 8395003e03..0000000000 --- a/Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:AIDED_NATURAL_LANGUAGE diff --git a/Lang/ALGOL-60/00-LANG.txt b/Lang/ALGOL-60/00-LANG.txt index 2f04de0a7d..725689b57a 100644 --- a/Lang/ALGOL-60/00-LANG.txt +++ b/Lang/ALGOL-60/00-LANG.txt @@ -16,9 +16,4 @@ gcc hello.c -lalgol -lm -o hello *[[wp:ALGOL 60|ALGOL 60 on Wikipedia]] *[[ALGOL 68]] *[[ALGOL W]] -*[[Simula]] - -==External links== -* [http://algol60.org algol60.org] -* [https://softwarepreservation.computerhistory.org/ALGOL/ History of ALGOL] Includes links to documentation (e.g. reports) -* [https://www.masswerk.at/algol60/report.htm Revised Report on the Algorithmic Language Algol 60] (HTML) \ No newline at end of file +*[[Simula]] \ No newline at end of file diff --git a/Lang/ALGOL-60/100-doors b/Lang/ALGOL-60/100-doors new file mode 120000 index 0000000000..9bbf6f9b11 --- /dev/null +++ b/Lang/ALGOL-60/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Additive-primes b/Lang/ALGOL-60/Additive-primes deleted file mode 120000 index 360a570784..0000000000 --- a/Lang/ALGOL-60/Additive-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Additive-primes/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Anti-primes b/Lang/ALGOL-60/Anti-primes deleted file mode 120000 index 6d19745d0e..0000000000 --- a/Lang/ALGOL-60/Anti-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anti-primes/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Even-or-odd b/Lang/ALGOL-60/Even-or-odd deleted file mode 120000 index 13baeccf6c..0000000000 --- a/Lang/ALGOL-60/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Factorial b/Lang/ALGOL-60/Factorial new file mode 120000 index 0000000000..67b243e1d0 --- /dev/null +++ b/Lang/ALGOL-60/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Harmonic-series b/Lang/ALGOL-60/Harmonic-series deleted file mode 120000 index a1eefb4086..0000000000 --- a/Lang/ALGOL-60/Harmonic-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harmonic-series/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Horners-rule-for-polynomial-evaluation b/Lang/ALGOL-60/Horners-rule-for-polynomial-evaluation deleted file mode 120000 index 2a520e0e7c..0000000000 --- a/Lang/ALGOL-60/Horners-rule-for-polynomial-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horners-rule-for-polynomial-evaluation/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Integer-comparison b/Lang/ALGOL-60/Integer-comparison deleted file mode 120000 index 54a6736fa3..0000000000 --- a/Lang/ALGOL-60/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Largest-proper-divisor-of-n b/Lang/ALGOL-60/Largest-proper-divisor-of-n deleted file mode 120000 index bd5f1adbca..0000000000 --- a/Lang/ALGOL-60/Largest-proper-divisor-of-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-proper-divisor-of-n/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Loops-Increment-loop-index-within-loop-body b/Lang/ALGOL-60/Loops-Increment-loop-index-within-loop-body deleted file mode 120000 index b6ef8c8c0c..0000000000 --- a/Lang/ALGOL-60/Loops-Increment-loop-index-within-loop-body +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Increment-loop-index-within-loop-body/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Nth-root b/Lang/ALGOL-60/Nth-root deleted file mode 120000 index 3032f52453..0000000000 --- a/Lang/ALGOL-60/Nth-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth-root/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Prime-decomposition b/Lang/ALGOL-60/Prime-decomposition deleted file mode 120000 index cd5f625ac0..0000000000 --- a/Lang/ALGOL-60/Prime-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-decomposition/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Proper-divisors b/Lang/ALGOL-60/Proper-divisors deleted file mode 120000 index 7bb12e66dd..0000000000 --- a/Lang/ALGOL-60/Proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Proper-divisors/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Semiprime b/Lang/ALGOL-60/Semiprime deleted file mode 120000 index 0981557b93..0000000000 --- a/Lang/ALGOL-60/Semiprime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semiprime/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Sequence-of-primes-by-trial-division b/Lang/ALGOL-60/Sequence-of-primes-by-trial-division deleted file mode 120000 index b95a2ebdcc..0000000000 --- a/Lang/ALGOL-60/Sequence-of-primes-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-primes-by-trial-division/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Square-free-integers b/Lang/ALGOL-60/Square-free-integers deleted file mode 120000 index caff91a536..0000000000 --- a/Lang/ALGOL-60/Square-free-integers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-free-integers/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Sum-multiples-of-3-and-5 b/Lang/ALGOL-60/Sum-multiples-of-3-and-5 deleted file mode 120000 index f733e89a1f..0000000000 --- a/Lang/ALGOL-60/Sum-multiples-of-3-and-5 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-multiples-of-3-and-5/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Sum-of-a-series b/Lang/ALGOL-60/Sum-of-a-series deleted file mode 120000 index 48b6d3380c..0000000000 --- a/Lang/ALGOL-60/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Tau-function b/Lang/ALGOL-60/Tau-function deleted file mode 120000 index 5e48edf00f..0000000000 --- a/Lang/ALGOL-60/Tau-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-function/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-60/Tau-number b/Lang/ALGOL-60/Tau-number deleted file mode 120000 index a054d3d6bb..0000000000 --- a/Lang/ALGOL-60/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-68/00-LANG.txt b/Lang/ALGOL-68/00-LANG.txt index 0415892136..f23a20030d 100644 --- a/Lang/ALGOL-68/00-LANG.txt +++ b/Lang/ALGOL-68/00-LANG.txt @@ -41,7 +41,7 @@ A syntax chart is available [http://www.softwarepreservation.org/projects/ALGOL/ * [http://www.linkedin.com/groups/Algol68-2333923 Algol68 group at linkedin] - includes various famous compiler composers.
'''Books available online''': -* [https://algol68genie.nl/ Algol 68G Manual - By Marcel van der Veer] Includes the Revised Report +* [http://jmvdveer.home.xs4all.nl/en.algol-68-genie.html Algol 68G Manual - By Marcel van der Veer] Includes the Revised Report * [http://www.softwarepreservation.org/projects/ALGOL/book/pame.2008.a4.pdf/view Programming Algol 68 Made Easy - by Sian Mountbatten (on softwarepreservation.org)] * [http://www.softwarepreservation.org/projects/ALGOL/book/Lindsey_van_der_Meulen-IItA68-Revised.pdf/view Informal Introduction to Algol 68 - by C. H. Lindsey & S. V. Van der Meulen (on softwarepreservation.org)] - if you prefer (and find) a hardcopy, be sure to get the 1977 edition. Highly recomended! @@ -59,7 +59,7 @@ A syntax chart is available [http://www.softwarepreservation.org/projects/ALGOL/ ** AND 50th Birthday '''ALGOL 58'''. * 23rd August 2009 - [http://sourceforge.net/projects/algol68/files/ algol68g-1.18.0-9h] released * 20th December 2009 - Happy 51st/41st Birthdays with [[Hamming_numbers#ALGOL_68|Hamming numbers]] - the 200th '''ALGOL 68''' code contribution on rosettacode.org! -** This time code was by [[User:Algol68g|Marcel van der Veer]], author of [https://algol68genie.nl Algol 68 Genie] +** This time code was by [[User:Algol68g|Marcel van der Veer]], author of [http://www.xs4all.nl/~jmvdveer/algol.html Algol 68 Genie] * 25th October 2011 - [[User:Jejones3141|Jejones3141]] added [[Soundex#ALGOL_68|Soundex]] - the 300th '''ALGOL 68''' code specimen. == Revisions == @@ -67,12 +67,203 @@ A syntax chart is available [http://www.softwarepreservation.org/projects/ALGOL/ *Oct. 1968: Penultimate Draft Report on the Algorithmic Language ALGOL 68 - Chapters 1-9 - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster. *Dec. 1968: Report on the Algorithmic Language ALGOL 68 - Offprint from Numerische Mathematik, 14, 79-218 (1969); Springer-Verlag. - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster. *Sep 1973: Revised Report on the Algorithmic Language Algol 68 - Springer-Verlag 1976 - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster, M. Sintzoff, C.H. Lindsey, L.G.L.T. Meertens and R.G. Fisker. -==Coding style of samples, alphabets and stropping== -See [[ALGOL 68 Representation]]. +==Coding style of samples== +Click "Expand" for more details. +
+
+ +Many of the code samples provided here have a leading main:( and a matching ) at the end. These are not actually required in the language, but are included so as to highlight the main routine. + +On some compilers, it may be necessary to include appropriate "job cards" +or preludes in order for the programs to compile successfully. Hopefully +not too much else is required. Examples: +{|border="1" style="border-collapse: collapse; border: 5px double grey;" align="center" +|| Brief Algol68 +|| Algol68 as in rosettacode +|| Actual ELLA Algol 68RS code +|- +|| + print(("Hello, world!",new line)) +|| + main:( + print(("Hello, world!",new line)) + ) +|| + PROGRAM helloworld CONTEXT VOID + USE standard + BEGIN + print(("Hello, world!", new line)) + END + FINISH +|} +

'''Examples of different program representations''' +

+At the time when ALGOL 68 was defined some predominant computers had +24 or 36 bit words, with 6 bit character sets. Hence it was desirable that +ALGOL 68 should be able to run on machines with only uppercase. +The official spec provided for different representations of the same +program. Quote stropping (enclosing the bold words in single quotes) +and Point stropping (preceeding the bold words with a dot) +were used. A variant of Point stropping called RES stropping was also defined. +In RES stropping some language-defined bold words are not preceded by a dot. +A pragmatic comment may have been required to indicate which +stropping convention was to be used, as in some of the examples below. +Upper stropping (representing the bold words by upper case and +non-bold words in lower case) was introduced by Algol 68R. Upper stropping +is used by Algol 68RS and is one of the options for Algol 68G. +Rutgers ALGOL 68 uses quote stropping. Most of the samples +on Rosetta Code use Upper stropping. +Examples (pragmatic comments to set the stropping regime not shown): +{|border="1" style="border-collapse: collapse; border: 2px double grey;" align="left" +|| Algol68 as typically published + '''mode''' '''xint''' = '''int'''; + '''xint''' sum sq:=0; + '''for''' i '''while''' + sum sq≠70×70 + '''do''' + sum sq+:=i↑2 + '''od''' +|| QUOTE stropping (similar to wiki) + 'mode' 'xint' = 'int'; + 'xint' sum sq:=0; + 'for' i 'while' + sum sq≠70×70 + 'do' + sum sq+:=i↑2 + 'od' +|| POINT stropping + .MODE .XINT = .INT; + .XINT SUM SQ:=0; + .FOR I .WHILE + SUM SQ .NE 70*70 + .DO + SUM SQ .PLUSAB I .UP 2 + .OD +|| RES stropping + mode .xint = int; + .xint sum sq:=0; + for i while + sum sq≠70×70 + do + sum sq+:=i↑2 + od +|| Upper stropping + MODE XINT = INT; + XINT sum sq:=0; + FOR i WHILE + sum sq /= 70*70 + DO + sum sq PLUSAB i UP 2 + OD +|} + +
== Coercion (casting) == -ALGOL 68 has a hierarchy of contexts which determine which kind of coercions are available at a particular point in the program.
-See [[:Category:ALGOL_68_Coercions|ALGOL 68 Coercions]] for more details. +ALGOL 68 has a hierarchy of contexts which determine which kind of coercions are available at a particular point in the program. +
+Click "Expand" for more details. +
+
+ +These contexts are: +{|class="wikitable" +!rowspan=2| N
+a
+m
+e +!rowspan=2| Context location +!colspan=5| Coercions available in this context +!rowspan=2| Coercion examples +|- +|bgcolor=aaaaff|Soft +|bgcolor=aaeeaa|Weak +|bgcolor=ffee99|Meek +|bgcolor=ffcc99|Firm +|bgcolor=ffcccc|Strong +|- +!S
+t
+r
+o
+n
+g +||Right hand side of: +* Identity-declarations, as "~" in: REAL x = ~ +* Initialisations, as "~" in: REAL x := ~ +Also: +* Actual-parameters of calls, as "~" in:PROC: sin(~) +* Enclosed clauses of casts, as "~" in: REAL(~) +* Units of routine-texts +* Statements yielding VOID +* All parts (but one) of a balanced clause +* One side of an identity relation, as "~" in: ~ IS ~ +|bgcolor=aaaaff rowspan=4 width="50px"| deproc- eduring +|bgcolor=aaeeaa rowspan=3 width="50px"| all '''soft''' then weak deref- erencing +|bgcolor=ffee99 rowspan=2 width="50px"| all '''weak''' then deref- erencing +|bgcolor=ffcc99 rowspan=1 width="50px"| all '''meek''' then uniting +|bgcolor=ffcccc width="50px"| all '''firm''' then widening, rowing and voiding +|colspan=1 bgcolor=ffcccc| +Widening occurs if there is no loss of precision. For example: An INT will be coerced to a REAL, and a REAL will be coerced to a LONG REAL. But not vice-versa. Examples: +INT to LONG INT +INT to REAL +REAL to COMPL +BITS to []BOOL +BYTES to STRING +A variable can also be coerced (rowed) to an array of length 1. + +For example: +INT to [1]INT +REAL to [1]REAL etc +|- +!F
+i
+r
+m +|| +*Operands of formulas as "~" in:OP: ~ * ~ +*Parameters of transput calls +|colspan=3 bgcolor=ffcc99| Example: +UNION(INT,REAL) var := 1 +|- +!M
+e
+e
+k +|| +* Trimscripts (yielding INT) +* Enquiries: e.g. as "~" in the following +IF ~ THEN ... FI and +FROM ~ BY ~ TO ~ WHILE ~ DO ... OD etc +* Primaries of calls (e.g. sin in sin(x)) +|colspan=4 bgcolor=ffee99|Examples: +REF REF BOOL to BOOL +REF REF REF INT to INT +|- +!W
+e
+a
+k +|| +* Primaries of slices, as in "~" in: ~[1:99] +* Secondaries of selections, as "~" in: value OF ~ +|colspan=5 bgcolor=aaeeaa|Examples: +REF BOOL to REF BOOL +REF REF INT to REF INT +REF REF REF REAL to REF REAL +REF REF REF REF STRUCT to REF STRUCT +|- +!S
+o
+f
+t +|| The LHS of assignments, as "~" in: ~ := ... +|colspan=6 bgcolor=aaaaff| Example: +* deproceduring of: PROC REAL random: e.g. random +|} +For more details about Primaries and Secondaries refer to [[Operator_precedence#ALGOL_68|Operator precedence]]. + +
==See also== *[[Web 68]] @@ -82,22 +273,12 @@ See [[:Category:ALGOL_68_Coercions|ALGOL 68 Coercions]] for more details. * [[Action!]] * [[Agena]] * [[Draco]] -* [[RTL/2]] * [https://en.wikipedia.org/wiki/S3_(programming_language) S3 for ICL 2900] == Library code used in Rosetta Code samples == -* [[ALGOL_68/prelude|Various (including the standard prelude)]] -* -* [[:Category:ALGOL_68-bits|bit-manipulation related]] -* [[:Category:ALGOL_68-files|File related]] -* [[:Category:ALGOL_68-l-system|L-System related]] -* [[:Category:ALGOL_68-primes|Prime related]] -* [[:Category:ALGOL_68-rows|Row (array) related]] -* [[:Category:ALGOL_68-sort|Sorting related]] - -== Tools == -[[Syntax_highlighting_using_Mediawiki_formatting#ALGOL 68|Format an upper-stropped Algol 68 source with Mediawiki markup]]
-[[Compiler/Simple_file_inclusion_pre_processor#ALGOL 68|Implement ''read'' and ''include'' pragmatic-comments for compilers that don't support file inclusion]] +[https://rosettacode.org/wiki/Category:ALGOL_68-primes Prime related] +
+[https://rosettacode.org/wiki/Category:ALGOL_68-rows Row (array) related] {{language programming paradigm|Concurrent}} {{language programming paradigm|Imperative}} \ No newline at end of file diff --git a/Lang/ALGOL-68/100-doors b/Lang/ALGOL-68/100-doors new file mode 120000 index 0000000000..a57790f750 --- /dev/null +++ b/Lang/ALGOL-68/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/100-prisoners b/Lang/ALGOL-68/100-prisoners deleted file mode 120000 index f6c4da597a..0000000000 --- a/Lang/ALGOL-68/100-prisoners +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-prisoners/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/21-game b/Lang/ALGOL-68/21-game deleted file mode 120000 index 76ba9066d7..0000000000 --- a/Lang/ALGOL-68/21-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/21-game/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/24-game b/Lang/ALGOL-68/24-game deleted file mode 120000 index 509307eab2..0000000000 --- a/Lang/ALGOL-68/24-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/24-game/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/9-billion-names-of-God-the-integer b/Lang/ALGOL-68/9-billion-names-of-God-the-integer deleted file mode 120000 index 01c632e0dd..0000000000 --- a/Lang/ALGOL-68/9-billion-names-of-God-the-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/9-billion-names-of-God-the-integer/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Abelian-sandpile-model b/Lang/ALGOL-68/Abelian-sandpile-model deleted file mode 120000 index 01bbfb3c77..0000000000 --- a/Lang/ALGOL-68/Abelian-sandpile-model +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Angle-difference-between-two-bearings b/Lang/ALGOL-68/Angle-difference-between-two-bearings deleted file mode 120000 index 78582e775d..0000000000 --- a/Lang/ALGOL-68/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Angles-geometric-normalization-and-conversion b/Lang/ALGOL-68/Angles-geometric-normalization-and-conversion deleted file mode 120000 index e25f8337e6..0000000000 --- a/Lang/ALGOL-68/Angles-geometric-normalization-and-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angles-geometric-normalization-and-conversion/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Archimedean-spiral b/Lang/ALGOL-68/Archimedean-spiral deleted file mode 120000 index 64c4988ade..0000000000 --- a/Lang/ALGOL-68/Archimedean-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Archimedean-spiral/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Arithmetic-derivative b/Lang/ALGOL-68/Arithmetic-derivative deleted file mode 120000 index 73196718b1..0000000000 --- a/Lang/ALGOL-68/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Arithmetic-geometric-mean-Calculate-Pi b/Lang/ALGOL-68/Arithmetic-geometric-mean-Calculate-Pi deleted file mode 120000 index 1c8bcda555..0000000000 --- a/Lang/ALGOL-68/Arithmetic-geometric-mean-Calculate-Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean-Calculate-Pi/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Averages-Mean-time-of-day b/Lang/ALGOL-68/Averages-Mean-time-of-day deleted file mode 120000 index e97106ed2d..0000000000 --- a/Lang/ALGOL-68/Averages-Mean-time-of-day +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-time-of-day/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bifid-cipher b/Lang/ALGOL-68/Bifid-cipher deleted file mode 120000 index 5e9da259ac..0000000000 --- a/Lang/ALGOL-68/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bioinformatics-base-count b/Lang/ALGOL-68/Bioinformatics-base-count new file mode 120000 index 0000000000..cb9d66b55c --- /dev/null +++ b/Lang/ALGOL-68/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Biorhythms b/Lang/ALGOL-68/Biorhythms deleted file mode 120000 index b15056dfc9..0000000000 --- a/Lang/ALGOL-68/Biorhythms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Biorhythms/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bitmap-B-zier-curves-Quadratic b/Lang/ALGOL-68/Bitmap-B-zier-curves-Quadratic deleted file mode 120000 index 30ab56c310..0000000000 --- a/Lang/ALGOL-68/Bitmap-B-zier-curves-Quadratic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-B-zier-curves-Quadratic/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Bulls-and-cows-Player b/Lang/ALGOL-68/Bulls-and-cows-Player deleted file mode 120000 index 6ce927089c..0000000000 --- a/Lang/ALGOL-68/Bulls-and-cows-Player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bulls-and-cows-Player/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Burrows-Wheeler-transform b/Lang/ALGOL-68/Burrows-Wheeler-transform deleted file mode 120000 index 203e0e501f..0000000000 --- a/Lang/ALGOL-68/Burrows-Wheeler-transform +++ /dev/null @@ -1 +0,0 @@ -../../Task/Burrows-Wheeler-transform/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Chaocipher b/Lang/ALGOL-68/Chaocipher deleted file mode 120000 index 1d4c0173db..0000000000 --- a/Lang/ALGOL-68/Chaocipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaocipher/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Chernicks-Carmichael-numbers b/Lang/ALGOL-68/Chernicks-Carmichael-numbers deleted file mode 120000 index ebdbb0354b..0000000000 --- a/Lang/ALGOL-68/Chernicks-Carmichael-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chernicks-Carmichael-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Cheryls-birthday b/Lang/ALGOL-68/Cheryls-birthday deleted file mode 120000 index 4a39e22573..0000000000 --- a/Lang/ALGOL-68/Cheryls-birthday +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cheryls-birthday/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Chinese-remainder-theorem b/Lang/ALGOL-68/Chinese-remainder-theorem deleted file mode 120000 index 5c42550649..0000000000 --- a/Lang/ALGOL-68/Chinese-remainder-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chinese-remainder-theorem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Cistercian-numerals b/Lang/ALGOL-68/Cistercian-numerals deleted file mode 120000 index 1a20b26b09..0000000000 --- a/Lang/ALGOL-68/Cistercian-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cistercian-numerals/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Convex-hull b/Lang/ALGOL-68/Convex-hull deleted file mode 120000 index 6ded12cc5d..0000000000 --- a/Lang/ALGOL-68/Convex-hull +++ /dev/null @@ -1 +0,0 @@ -../../Task/Convex-hull/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Date-manipulation b/Lang/ALGOL-68/Date-manipulation deleted file mode 120000 index 700d602cf1..0000000000 --- a/Lang/ALGOL-68/Date-manipulation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Date-manipulation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/De-Bruijn-sequences b/Lang/ALGOL-68/De-Bruijn-sequences deleted file mode 120000 index 1c1a7f459e..0000000000 --- a/Lang/ALGOL-68/De-Bruijn-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/De-Bruijn-sequences/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Death-Star b/Lang/ALGOL-68/Death-Star deleted file mode 120000 index 71a96e0b37..0000000000 --- a/Lang/ALGOL-68/Death-Star +++ /dev/null @@ -1 +0,0 @@ -../../Task/Death-Star/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Demings-funnel b/Lang/ALGOL-68/Demings-funnel deleted file mode 120000 index c30e5a173e..0000000000 --- a/Lang/ALGOL-68/Demings-funnel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Demings-funnel/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Determinant-and-permanent b/Lang/ALGOL-68/Determinant-and-permanent deleted file mode 120000 index e8a753594d..0000000000 --- a/Lang/ALGOL-68/Determinant-and-permanent +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determinant-and-permanent/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Determine-if-two-triangles-overlap b/Lang/ALGOL-68/Determine-if-two-triangles-overlap deleted file mode 120000 index 7543dc4fab..0000000000 --- a/Lang/ALGOL-68/Determine-if-two-triangles-overlap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-two-triangles-overlap/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Dice-game-probabilities b/Lang/ALGOL-68/Dice-game-probabilities deleted file mode 120000 index 9b1e59ee7b..0000000000 --- a/Lang/ALGOL-68/Dice-game-probabilities +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dice-game-probabilities/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Display-an-outline-as-a-nested-table b/Lang/ALGOL-68/Display-an-outline-as-a-nested-table deleted file mode 120000 index 41ea472cc8..0000000000 --- a/Lang/ALGOL-68/Display-an-outline-as-a-nested-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-an-outline-as-a-nested-table/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series b/Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series deleted file mode 120000 index 242e3aeb60..0000000000 --- a/Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Distribution-of-0-digits-in-factorial-series/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Diversity-prediction-theorem b/Lang/ALGOL-68/Diversity-prediction-theorem deleted file mode 120000 index d2ff7024e1..0000000000 --- a/Lang/ALGOL-68/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Draw-a-cuboid b/Lang/ALGOL-68/Draw-a-cuboid deleted file mode 120000 index 3102af7fc7..0000000000 --- a/Lang/ALGOL-68/Draw-a-cuboid +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-cuboid/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Dynamic-variable-names b/Lang/ALGOL-68/Dynamic-variable-names deleted file mode 120000 index eae667a38d..0000000000 --- a/Lang/ALGOL-68/Dynamic-variable-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dynamic-variable-names/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Eban-numbers b/Lang/ALGOL-68/Eban-numbers deleted file mode 120000 index fa85ff0e58..0000000000 --- a/Lang/ALGOL-68/Eban-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eban-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Elementary-cellular-automaton-Random-number-generator b/Lang/ALGOL-68/Elementary-cellular-automaton-Random-number-generator deleted file mode 120000 index a4aed0fa0e..0000000000 --- a/Lang/ALGOL-68/Elementary-cellular-automaton-Random-number-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Elementary-cellular-automaton-Random-number-generator/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Elliptic-curve-arithmetic b/Lang/ALGOL-68/Elliptic-curve-arithmetic deleted file mode 120000 index 88681d69e9..0000000000 --- a/Lang/ALGOL-68/Elliptic-curve-arithmetic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Elliptic-curve-arithmetic/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Equal-prime-and-composite-sums b/Lang/ALGOL-68/Equal-prime-and-composite-sums deleted file mode 120000 index 7f8271d85e..0000000000 --- a/Lang/ALGOL-68/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/FASTA-format b/Lang/ALGOL-68/FASTA-format deleted file mode 120000 index 6951549e47..0000000000 --- a/Lang/ALGOL-68/FASTA-format +++ /dev/null @@ -1 +0,0 @@ -../../Task/FASTA-format/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Factorial b/Lang/ALGOL-68/Factorial new file mode 120000 index 0000000000..b406800839 --- /dev/null +++ b/Lang/ALGOL-68/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Factorial-base-numbers-indexing-permutations-of-a-collection b/Lang/ALGOL-68/Factorial-base-numbers-indexing-permutations-of-a-collection deleted file mode 120000 index ab36c72f12..0000000000 --- a/Lang/ALGOL-68/Factorial-base-numbers-indexing-permutations-of-a-collection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-base-numbers-indexing-permutations-of-a-collection/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Faulhabers-triangle b/Lang/ALGOL-68/Faulhabers-triangle deleted file mode 120000 index 902d8dc449..0000000000 --- a/Lang/ALGOL-68/Faulhabers-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Faulhabers-triangle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Fermat-numbers b/Lang/ALGOL-68/Fermat-numbers deleted file mode 120000 index a0269ca31a..0000000000 --- a/Lang/ALGOL-68/Fermat-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fermat-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Floyd-Warshall-algorithm b/Lang/ALGOL-68/Floyd-Warshall-algorithm deleted file mode 120000 index 704f4ca44e..0000000000 --- a/Lang/ALGOL-68/Floyd-Warshall-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyd-Warshall-algorithm/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Fortunate-numbers b/Lang/ALGOL-68/Fortunate-numbers deleted file mode 120000 index c6ecf1ee17..0000000000 --- a/Lang/ALGOL-68/Fortunate-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fortunate-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Four-is-magic b/Lang/ALGOL-68/Four-is-magic deleted file mode 120000 index 007db868ed..0000000000 --- a/Lang/ALGOL-68/Four-is-magic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Four-is-magic/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/IBAN b/Lang/ALGOL-68/IBAN deleted file mode 120000 index 08ea01a928..0000000000 --- a/Lang/ALGOL-68/IBAN +++ /dev/null @@ -1 +0,0 @@ -../../Task/IBAN/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Jacobi-symbol b/Lang/ALGOL-68/Jacobi-symbol deleted file mode 120000 index 6ad192d3e6..0000000000 --- a/Lang/ALGOL-68/Jacobi-symbol +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobi-symbol/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Jaro-similarity b/Lang/ALGOL-68/Jaro-similarity deleted file mode 120000 index 0255b5f0fa..0000000000 --- a/Lang/ALGOL-68/Jaro-similarity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jaro-similarity/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Jordan-P-lya-numbers b/Lang/ALGOL-68/Jordan-P-lya-numbers deleted file mode 120000 index 6750737d48..0000000000 --- a/Lang/ALGOL-68/Jordan-P-lya-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jordan-P-lya-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Juggler-sequence b/Lang/ALGOL-68/Juggler-sequence deleted file mode 120000 index 2c24c77bfb..0000000000 --- a/Lang/ALGOL-68/Juggler-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Juggler-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Knapsack-problem-0-1 b/Lang/ALGOL-68/Knapsack-problem-0-1 deleted file mode 120000 index 38cd6f2ecb..0000000000 --- a/Lang/ALGOL-68/Knapsack-problem-0-1 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-0-1/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Knapsack-problem-Continuous b/Lang/ALGOL-68/Knapsack-problem-Continuous deleted file mode 120000 index f49865cc46..0000000000 --- a/Lang/ALGOL-68/Knapsack-problem-Continuous +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-Continuous/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Koch-curve b/Lang/ALGOL-68/Koch-curve deleted file mode 120000 index 1a27265644..0000000000 --- a/Lang/ALGOL-68/Koch-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Koch-curve/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Kronecker-product-based-fractals b/Lang/ALGOL-68/Kronecker-product-based-fractals deleted file mode 120000 index 7531f0ec6e..0000000000 --- a/Lang/ALGOL-68/Kronecker-product-based-fractals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kronecker-product-based-fractals/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/LU-decomposition b/Lang/ALGOL-68/LU-decomposition deleted file mode 120000 index 3453e9548a..0000000000 --- a/Lang/ALGOL-68/LU-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/LU-decomposition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Legendre-prime-counting-function b/Lang/ALGOL-68/Legendre-prime-counting-function deleted file mode 120000 index f71f764e65..0000000000 --- a/Lang/ALGOL-68/Legendre-prime-counting-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Legendre-prime-counting-function/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Logistic-curve-fitting-in-epidemiology b/Lang/ALGOL-68/Logistic-curve-fitting-in-epidemiology deleted file mode 120000 index 508ef46a64..0000000000 --- a/Lang/ALGOL-68/Logistic-curve-fitting-in-epidemiology +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logistic-curve-fitting-in-epidemiology/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Long-primes b/Lang/ALGOL-68/Long-primes deleted file mode 120000 index 5932549f9d..0000000000 --- a/Lang/ALGOL-68/Long-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-primes/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Longest-increasing-subsequence b/Lang/ALGOL-68/Longest-increasing-subsequence deleted file mode 120000 index a09c83eed3..0000000000 --- a/Lang/ALGOL-68/Longest-increasing-subsequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-increasing-subsequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Magic-squares-of-singly-even-order b/Lang/ALGOL-68/Magic-squares-of-singly-even-order deleted file mode 120000 index 25b7aec11a..0000000000 --- a/Lang/ALGOL-68/Magic-squares-of-singly-even-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-singly-even-order/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Mayan-numerals b/Lang/ALGOL-68/Mayan-numerals deleted file mode 120000 index 901b0eac41..0000000000 --- a/Lang/ALGOL-68/Mayan-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mayan-numerals/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Meissel-Mertens-constant b/Lang/ALGOL-68/Meissel-Mertens-constant new file mode 120000 index 0000000000..e7b400c689 --- /dev/null +++ b/Lang/ALGOL-68/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Miller-Rabin-primality-test b/Lang/ALGOL-68/Miller-Rabin-primality-test new file mode 120000 index 0000000000..c0a1c115c4 --- /dev/null +++ b/Lang/ALGOL-68/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Modified-random-distribution b/Lang/ALGOL-68/Modified-random-distribution deleted file mode 120000 index 1858012a62..0000000000 --- a/Lang/ALGOL-68/Modified-random-distribution +++ /dev/null @@ -1 +0,0 @@ -../../Task/Modified-random-distribution/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Next-highest-int-from-digits b/Lang/ALGOL-68/Next-highest-int-from-digits deleted file mode 120000 index 7e6acab659..0000000000 --- a/Lang/ALGOL-68/Next-highest-int-from-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Next-highest-int-from-digits/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Number-reversal-game b/Lang/ALGOL-68/Number-reversal-game deleted file mode 120000 index 243202f9d2..0000000000 --- a/Lang/ALGOL-68/Number-reversal-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Number-reversal-game/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/ALGOL-68/Numbers-which-are-not-the-sum-of-distinct-squares deleted file mode 120000 index b879b4a5c6..0000000000 --- a/Lang/ALGOL-68/Numbers-which-are-not-the-sum-of-distinct-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Partition-an-integer-x-into-n-primes b/Lang/ALGOL-68/Partition-an-integer-x-into-n-primes deleted file mode 120000 index a393060101..0000000000 --- a/Lang/ALGOL-68/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Partition-function-P b/Lang/ALGOL-68/Partition-function-P deleted file mode 120000 index 98f6538801..0000000000 --- a/Lang/ALGOL-68/Partition-function-P +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-function-P/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Peano-curve b/Lang/ALGOL-68/Peano-curve deleted file mode 120000 index 7ad831ac36..0000000000 --- a/Lang/ALGOL-68/Peano-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Peano-curve/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pell-numbers b/Lang/ALGOL-68/Pell-numbers deleted file mode 120000 index 1815b001cf..0000000000 --- a/Lang/ALGOL-68/Pell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pell-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pentagram b/Lang/ALGOL-68/Pentagram deleted file mode 120000 index 7ab101a89e..0000000000 --- a/Lang/ALGOL-68/Pentagram +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pentagram/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Perlin-noise b/Lang/ALGOL-68/Perlin-noise deleted file mode 120000 index 8bd6981103..0000000000 --- a/Lang/ALGOL-68/Perlin-noise +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perlin-noise/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Permutation-test b/Lang/ALGOL-68/Permutation-test deleted file mode 120000 index 1a8b7f20df..0000000000 --- a/Lang/ALGOL-68/Permutation-test +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutation-test/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pisano-period b/Lang/ALGOL-68/Pisano-period deleted file mode 120000 index b012a168d9..0000000000 --- a/Lang/ALGOL-68/Pisano-period +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pisano-period/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Polynomial-long-division b/Lang/ALGOL-68/Polynomial-long-division deleted file mode 120000 index 792b97252e..0000000000 --- a/Lang/ALGOL-68/Polynomial-long-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Polynomial-long-division/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Primes---allocate-descendants-to-their-ancestors b/Lang/ALGOL-68/Primes---allocate-descendants-to-their-ancestors deleted file mode 120000 index 9bf6ed3e36..0000000000 --- a/Lang/ALGOL-68/Primes---allocate-descendants-to-their-ancestors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primes---allocate-descendants-to-their-ancestors/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Problem-of-Apollonius b/Lang/ALGOL-68/Problem-of-Apollonius deleted file mode 120000 index 51b4085ef1..0000000000 --- a/Lang/ALGOL-68/Problem-of-Apollonius +++ /dev/null @@ -1 +0,0 @@ -../../Task/Problem-of-Apollonius/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pythagoras-tree b/Lang/ALGOL-68/Pythagoras-tree deleted file mode 120000 index 8c304d8b68..0000000000 --- a/Lang/ALGOL-68/Pythagoras-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagoras-tree/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pythagorean-triples b/Lang/ALGOL-68/Pythagorean-triples deleted file mode 120000 index 8c48c48b1b..0000000000 --- a/Lang/ALGOL-68/Pythagorean-triples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagorean-triples/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Quaternion-type b/Lang/ALGOL-68/Quaternion-type new file mode 120000 index 0000000000..9934ee409f --- /dev/null +++ b/Lang/ALGOL-68/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Quoting-constructs b/Lang/ALGOL-68/Quoting-constructs deleted file mode 120000 index 7f6defd772..0000000000 --- a/Lang/ALGOL-68/Quoting-constructs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quoting-constructs/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Radical-of-an-integer b/Lang/ALGOL-68/Radical-of-an-integer deleted file mode 120000 index 18632fce6e..0000000000 --- a/Lang/ALGOL-68/Radical-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Radical-of-an-integer/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Ramanujans-constant b/Lang/ALGOL-68/Ramanujans-constant deleted file mode 120000 index 7fce932657..0000000000 --- a/Lang/ALGOL-68/Ramanujans-constant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ramanujans-constant/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Ramer-Douglas-Peucker-line-simplification b/Lang/ALGOL-68/Ramer-Douglas-Peucker-line-simplification deleted file mode 120000 index b719791f41..0000000000 --- a/Lang/ALGOL-68/Ramer-Douglas-Peucker-line-simplification +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ramer-Douglas-Peucker-line-simplification/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Range-consolidation b/Lang/ALGOL-68/Range-consolidation deleted file mode 120000 index 51b0e5d75e..0000000000 --- a/Lang/ALGOL-68/Range-consolidation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-consolidation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Ray-casting-algorithm b/Lang/ALGOL-68/Ray-casting-algorithm deleted file mode 120000 index 2c4b411219..0000000000 --- a/Lang/ALGOL-68/Ray-casting-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ray-casting-algorithm/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sailors-coconuts-and-a-monkey-problem b/Lang/ALGOL-68/Sailors-coconuts-and-a-monkey-problem deleted file mode 120000 index c84573878e..0000000000 --- a/Lang/ALGOL-68/Sailors-coconuts-and-a-monkey-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sailors-coconuts-and-a-monkey-problem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sequence:-nth-number-with-exactly-n-divisors b/Lang/ALGOL-68/Sequence:-nth-number-with-exactly-n-divisors deleted file mode 120000 index 02fc9fe7df..0000000000 --- a/Lang/ALGOL-68/Sequence:-nth-number-with-exactly-n-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence:-nth-number-with-exactly-n-divisors/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sierpinski-arrowhead-curve b/Lang/ALGOL-68/Sierpinski-arrowhead-curve deleted file mode 120000 index 3f487dc4fa..0000000000 --- a/Lang/ALGOL-68/Sierpinski-arrowhead-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-arrowhead-curve/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sierpinski-square-curve b/Lang/ALGOL-68/Sierpinski-square-curve deleted file mode 120000 index 7aaf7e1567..0000000000 --- a/Lang/ALGOL-68/Sierpinski-square-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-square-curve/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sierpinski-triangle-Graphical b/Lang/ALGOL-68/Sierpinski-triangle-Graphical deleted file mode 120000 index c561698ad4..0000000000 --- a/Lang/ALGOL-68/Sierpinski-triangle-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-triangle-Graphical/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sleeping-Beauty-problem b/Lang/ALGOL-68/Sleeping-Beauty-problem deleted file mode 120000 index b5873d4f8d..0000000000 --- a/Lang/ALGOL-68/Sleeping-Beauty-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleeping-Beauty-problem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k b/Lang/ALGOL-68/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k deleted file mode 120000 index a96279cee7..0000000000 --- a/Lang/ALGOL-68/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Solve-a-Hidato-puzzle b/Lang/ALGOL-68/Solve-a-Hidato-puzzle deleted file mode 120000 index 228ccf6bb3..0000000000 --- a/Lang/ALGOL-68/Solve-a-Hidato-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Hidato-puzzle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Solve-a-Numbrix-puzzle b/Lang/ALGOL-68/Solve-a-Numbrix-puzzle deleted file mode 120000 index 14e9e80e97..0000000000 --- a/Lang/ALGOL-68/Solve-a-Numbrix-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Numbrix-puzzle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Solve-the-no-connection-puzzle b/Lang/ALGOL-68/Solve-the-no-connection-puzzle deleted file mode 120000 index 0ffda5f1f9..0000000000 --- a/Lang/ALGOL-68/Solve-the-no-connection-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-the-no-connection-puzzle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sort-disjoint-sublist b/Lang/ALGOL-68/Sort-disjoint-sublist deleted file mode 120000 index be15a7cde3..0000000000 --- a/Lang/ALGOL-68/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sort-numbers-lexicographically b/Lang/ALGOL-68/Sort-numbers-lexicographically deleted file mode 120000 index 7da8e72755..0000000000 --- a/Lang/ALGOL-68/Sort-numbers-lexicographically +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-numbers-lexicographically/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Square-form-factorization b/Lang/ALGOL-68/Square-form-factorization deleted file mode 120000 index 2759455513..0000000000 --- a/Lang/ALGOL-68/Square-form-factorization +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-form-factorization/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Substitution-cipher b/Lang/ALGOL-68/Substitution-cipher deleted file mode 120000 index b8b9dd702a..0000000000 --- a/Lang/ALGOL-68/Substitution-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substitution-cipher/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Subtractive-generator b/Lang/ALGOL-68/Subtractive-generator deleted file mode 120000 index f90071e31a..0000000000 --- a/Lang/ALGOL-68/Subtractive-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Subtractive-generator/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sum-and-product-puzzle b/Lang/ALGOL-68/Sum-and-product-puzzle deleted file mode 120000 index 18865c2c45..0000000000 --- a/Lang/ALGOL-68/Sum-and-product-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-and-product-puzzle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Super-d-numbers b/Lang/ALGOL-68/Super-d-numbers deleted file mode 120000 index f050b2afa7..0000000000 --- a/Lang/ALGOL-68/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Take-notes-on-the-command-line b/Lang/ALGOL-68/Take-notes-on-the-command-line deleted file mode 120000 index f0f896e58b..0000000000 --- a/Lang/ALGOL-68/Take-notes-on-the-command-line +++ /dev/null @@ -1 +0,0 @@ -../../Task/Take-notes-on-the-command-line/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Text-processing-2 b/Lang/ALGOL-68/Text-processing-2 deleted file mode 120000 index 124fe3bf6c..0000000000 --- a/Lang/ALGOL-68/Text-processing-2 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Text-processing-2/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Total-circles-area b/Lang/ALGOL-68/Total-circles-area deleted file mode 120000 index b2c70ca7c7..0000000000 --- a/Lang/ALGOL-68/Total-circles-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Total-circles-area/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Verhoeff-algorithm b/Lang/ALGOL-68/Verhoeff-algorithm deleted file mode 120000 index 7cabb86204..0000000000 --- a/Lang/ALGOL-68/Verhoeff-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Verhoeff-algorithm/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Vogels-approximation-method b/Lang/ALGOL-68/Vogels-approximation-method deleted file mode 120000 index 9c09f3c2a5..0000000000 --- a/Lang/ALGOL-68/Vogels-approximation-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vogels-approximation-method/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Wasteful-equidigital-and-frugal-numbers b/Lang/ALGOL-68/Wasteful-equidigital-and-frugal-numbers deleted file mode 120000 index 6de9ddaea1..0000000000 --- a/Lang/ALGOL-68/Wasteful-equidigital-and-frugal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wasteful-equidigital-and-frugal-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Word-wheel b/Lang/ALGOL-68/Word-wheel deleted file mode 120000 index ab6aaa99f7..0000000000 --- a/Lang/ALGOL-68/Word-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-wheel/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-M/Additive-primes b/Lang/ALGOL-M/Additive-primes deleted file mode 120000 index 974f9484e7..0000000000 --- a/Lang/ALGOL-M/Additive-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Additive-primes/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-M/Case-sensitivity-of-identifiers b/Lang/ALGOL-M/Case-sensitivity-of-identifiers deleted file mode 120000 index 3e61bd6e7f..0000000000 --- a/Lang/ALGOL-M/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-M/Create-a-two-dimensional-array-at-runtime b/Lang/ALGOL-M/Create-a-two-dimensional-array-at-runtime deleted file mode 120000 index 87ccfbe67e..0000000000 --- a/Lang/ALGOL-M/Create-a-two-dimensional-array-at-runtime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-a-two-dimensional-array-at-runtime/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-M/Exponentiation-order b/Lang/ALGOL-M/Exponentiation-order deleted file mode 120000 index b37e574b53..0000000000 --- a/Lang/ALGOL-M/Exponentiation-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-order/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-M/Integer-comparison b/Lang/ALGOL-M/Integer-comparison deleted file mode 120000 index 1066ff383c..0000000000 --- a/Lang/ALGOL-M/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-M/Integer-overflow b/Lang/ALGOL-M/Integer-overflow deleted file mode 120000 index a7f3c63fee..0000000000 --- a/Lang/ALGOL-M/Integer-overflow +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-overflow/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-M/Semiprime b/Lang/ALGOL-M/Semiprime deleted file mode 120000 index 9bc2a5e1b8..0000000000 --- a/Lang/ALGOL-M/Semiprime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semiprime/ALGOL-M \ No newline at end of file diff --git a/Lang/ALGOL-W/00-LANG.txt b/Lang/ALGOL-W/00-LANG.txt index f0f11b51d0..7d04034cdb 100644 --- a/Lang/ALGOL-W/00-LANG.txt +++ b/Lang/ALGOL-W/00-LANG.txt @@ -7,17 +7,26 @@ |checking=both |tags=algolw |LCT=yes}} -Algol W was designed as a successor to [[wp:Algol 60|Algol 60]], closely based on A +Algol W is a successor to [[wp:Algol 60|Algol 60]] closely based on A Contribution to the Development of ALGOL by [[wp:Niklaus Wirth|Niklaus Wirth]] and [[wp:C.A.R. Hoare|C. A. R. Hoare]]. It includes dynamically allocated records, string handling, complex numbers and a standard I/O -system. A description of the Algol W Language as at 1972 can be found at [https://bitsavers.org/pdf/stanford/cs_techReports/STAN-CS-71-230_Algol_W_Reference_Manual_Feb72.pdf Algol W Reference Manual 1972 on bitsavers.org] +system. A copy of the Algol W Language Description can be found on Karl +Kleine's [http://www.fh-jena.de/~kleine/history/history.html Historic Documents in Computer Science] page. [http://everything2.com/title/Algol%2520W Dabcanboulet's Algol W @ Everything2] page contains an excellent history and tutorial. -==To do== -[[Tasks not implemented in ALGOL W]] +[http://tiddly-pom.com/~glyn/ Awe] is a new compiler for the Algol W +language. It is a complete implementation of the language described in +the [https://tiddly-pom.com/~glyn/algolw.pdf Algol W Language Description, June 1972]. Awe should be able to +compile code intended for the [[wp:OS/360|OS/360]] Algol W compilers +with little or no modification. See the Awe manual for more details. + +Awe correctly compiles Tony Marsland's computer [[wp:chess|chess]] player +[http://webdocs.cs.ualberta.ca/~tony/Public/Awit-Wita-ComputerChess/ Awit] +and Hendrik Boom's [http://mtn-host.prjek.net/projects/a68h/ A68H] +[[Algol 68]] compiler. ==See also== *[[wp:ALGOL_W|Algol W on Wikipedia]] diff --git a/Lang/ALGOL-W/100-doors b/Lang/ALGOL-W/100-doors new file mode 120000 index 0000000000..954c02976a --- /dev/null +++ b/Lang/ALGOL-W/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Amicable-pairs b/Lang/ALGOL-W/Amicable-pairs deleted file mode 120000 index eb00d630bb..0000000000 --- a/Lang/ALGOL-W/Amicable-pairs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amicable-pairs/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Angles-geometric-normalization-and-conversion b/Lang/ALGOL-W/Angles-geometric-normalization-and-conversion deleted file mode 120000 index 84598a2a10..0000000000 --- a/Lang/ALGOL-W/Angles-geometric-normalization-and-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angles-geometric-normalization-and-conversion/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Arithmetic-Integer b/Lang/ALGOL-W/Arithmetic-Integer new file mode 120000 index 0000000000..de259d015a --- /dev/null +++ b/Lang/ALGOL-W/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Arithmetic-derivative b/Lang/ALGOL-W/Arithmetic-derivative deleted file mode 120000 index a3db59a4a9..0000000000 --- a/Lang/ALGOL-W/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Arithmetic-geometric-mean-Calculate-Pi b/Lang/ALGOL-W/Arithmetic-geometric-mean-Calculate-Pi deleted file mode 120000 index 0fd6c8a97f..0000000000 --- a/Lang/ALGOL-W/Arithmetic-geometric-mean-Calculate-Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean-Calculate-Pi/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Ascending-primes b/Lang/ALGOL-W/Ascending-primes deleted file mode 120000 index 06be81c726..0000000000 --- a/Lang/ALGOL-W/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Bell-numbers b/Lang/ALGOL-W/Bell-numbers deleted file mode 120000 index 07e4520258..0000000000 --- a/Lang/ALGOL-W/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Calculating-the-value-of-e b/Lang/ALGOL-W/Calculating-the-value-of-e deleted file mode 120000 index 0bccb15458..0000000000 --- a/Lang/ALGOL-W/Calculating-the-value-of-e +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calculating-the-value-of-e/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Copy-a-string b/Lang/ALGOL-W/Copy-a-string new file mode 120000 index 0000000000..4a449ab936 --- /dev/null +++ b/Lang/ALGOL-W/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Count-in-factors b/Lang/ALGOL-W/Count-in-factors deleted file mode 120000 index a14f8ef196..0000000000 --- a/Lang/ALGOL-W/Count-in-factors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-in-factors/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Deceptive-numbers b/Lang/ALGOL-W/Deceptive-numbers deleted file mode 120000 index a1723c19f5..0000000000 --- a/Lang/ALGOL-W/Deceptive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deceptive-numbers/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Descending-primes b/Lang/ALGOL-W/Descending-primes deleted file mode 120000 index eb1b26cbcd..0000000000 --- a/Lang/ALGOL-W/Descending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Descending-primes/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Equal-prime-and-composite-sums b/Lang/ALGOL-W/Equal-prime-and-composite-sums deleted file mode 120000 index 54c76175f4..0000000000 --- a/Lang/ALGOL-W/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Euclid-Mullin-sequence b/Lang/ALGOL-W/Euclid-Mullin-sequence deleted file mode 120000 index 31033b3496..0000000000 --- a/Lang/ALGOL-W/Euclid-Mullin-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euclid-Mullin-sequence/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Eulers-constant-0.5772... b/Lang/ALGOL-W/Eulers-constant-0.5772... deleted file mode 120000 index 809de9e1fd..0000000000 --- a/Lang/ALGOL-W/Eulers-constant-0.5772... +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-constant-0.5772.../ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Eulers-identity b/Lang/ALGOL-W/Eulers-identity deleted file mode 120000 index cda4a96c63..0000000000 --- a/Lang/ALGOL-W/Eulers-identity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-identity/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Factorial b/Lang/ALGOL-W/Factorial new file mode 120000 index 0000000000..01c77fb141 --- /dev/null +++ b/Lang/ALGOL-W/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Factorial-primes b/Lang/ALGOL-W/Factorial-primes deleted file mode 120000 index d855b375f0..0000000000 --- a/Lang/ALGOL-W/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Find-the-intersection-of-two-lines b/Lang/ALGOL-W/Find-the-intersection-of-two-lines deleted file mode 120000 index 0514984ef6..0000000000 --- a/Lang/ALGOL-W/Find-the-intersection-of-two-lines +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-intersection-of-two-lines/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Integer-comparison b/Lang/ALGOL-W/Integer-comparison new file mode 120000 index 0000000000..b056aab0f7 --- /dev/null +++ b/Lang/ALGOL-W/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Jacobi-symbol b/Lang/ALGOL-W/Jacobi-symbol deleted file mode 120000 index 9d2230fbff..0000000000 --- a/Lang/ALGOL-W/Jacobi-symbol +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobi-symbol/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Jordan-P-lya-numbers b/Lang/ALGOL-W/Jordan-P-lya-numbers deleted file mode 120000 index 6e24b686d2..0000000000 --- a/Lang/ALGOL-W/Jordan-P-lya-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jordan-P-lya-numbers/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Knapsack-problem-Continuous b/Lang/ALGOL-W/Knapsack-problem-Continuous deleted file mode 120000 index fba28c1695..0000000000 --- a/Lang/ALGOL-W/Knapsack-problem-Continuous +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-Continuous/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/McNuggets-problem b/Lang/ALGOL-W/McNuggets-problem deleted file mode 120000 index 74213b63b7..0000000000 --- a/Lang/ALGOL-W/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Mian-Chowla-sequence b/Lang/ALGOL-W/Mian-Chowla-sequence deleted file mode 120000 index ef2068107d..0000000000 --- a/Lang/ALGOL-W/Mian-Chowla-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mian-Chowla-sequence/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/ALGOL-W/Numbers-which-are-not-the-sum-of-distinct-squares deleted file mode 120000 index d2256bcafe..0000000000 --- a/Lang/ALGOL-W/Numbers-which-are-not-the-sum-of-distinct-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors b/Lang/ALGOL-W/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors deleted file mode 120000 index 19db81f6ed..0000000000 --- a/Lang/ALGOL-W/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Numbers-with-equal-rises-and-falls b/Lang/ALGOL-W/Numbers-with-equal-rises-and-falls deleted file mode 120000 index da06043b47..0000000000 --- a/Lang/ALGOL-W/Numbers-with-equal-rises-and-falls +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-with-equal-rises-and-falls/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Pell-numbers b/Lang/ALGOL-W/Pell-numbers deleted file mode 120000 index e4ac5c7f0d..0000000000 --- a/Lang/ALGOL-W/Pell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pell-numbers/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method b/Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method deleted file mode 120000 index e6f0e36a5b..0000000000 --- a/Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Middle-square-method/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Quaternion-type b/Lang/ALGOL-W/Quaternion-type new file mode 120000 index 0000000000..9f1593930d --- /dev/null +++ b/Lang/ALGOL-W/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Sierpinski-square-curve b/Lang/ALGOL-W/Sierpinski-square-curve deleted file mode 120000 index c787c64cbf..0000000000 --- a/Lang/ALGOL-W/Sierpinski-square-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-square-curve/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Sleeping-Beauty-problem b/Lang/ALGOL-W/Sleeping-Beauty-problem deleted file mode 120000 index 2a0e8b6707..0000000000 --- a/Lang/ALGOL-W/Sleeping-Beauty-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleeping-Beauty-problem/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Square-but-not-cube b/Lang/ALGOL-W/Square-but-not-cube deleted file mode 120000 index 4f2dc4fb68..0000000000 --- a/Lang/ALGOL-W/Square-but-not-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-but-not-cube/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Square-free-integers b/Lang/ALGOL-W/Square-free-integers deleted file mode 120000 index c98b8e474a..0000000000 --- a/Lang/ALGOL-W/Square-free-integers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-free-integers/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Tau-number b/Lang/ALGOL-W/Tau-number deleted file mode 120000 index 8bde57a739..0000000000 --- a/Lang/ALGOL-W/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Temperature-conversion b/Lang/ALGOL-W/Temperature-conversion deleted file mode 120000 index fa3a68b9d1..0000000000 --- a/Lang/ALGOL-W/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/The-sieve-of-Sundaram b/Lang/ALGOL-W/The-sieve-of-Sundaram deleted file mode 120000 index f0d3b0894c..0000000000 --- a/Lang/ALGOL-W/The-sieve-of-Sundaram +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-sieve-of-Sundaram/ALGOL-W \ No newline at end of file diff --git a/Lang/ANSI-BASIC/00-LANG.txt b/Lang/ANSI-BASIC/00-LANG.txt index 9ae71a4883..ad9d3273cb 100644 --- a/Lang/ANSI-BASIC/00-LANG.txt +++ b/Lang/ANSI-BASIC/00-LANG.txt @@ -2,17 +2,8 @@ |tags=basic}}{{language programming paradigm|Imperative}} {{Implementation|BASIC}} -'''ANSI BASIC''' ('''Full BASIC''') is a standard for the [[BASIC]] programming language. It is specified in ANSI X3.113-1987 ("Programming Languages Full BASIC"). The same standard was specified in INCITS/ISO/IEC 10279-1991 ("Information Technology – Programming Languages – Full BASIC"). The standard is called "Full BASIC" to distinguish it from [[Minimal BASIC]] which is another standard established by ANSI, ISO, and ECMA. +'''ANSI BASIC''' is a standard for the [[BASIC]] programming language. It is specified in ANSI X3.113-1987 ("Programming Languages Full BASIC"). The same standard was specified in INCITS/ISO/IEC 10279-1991 ("Information Technology – Programming Languages – Full BASIC"). The standard is called "Full BASIC" to distinguish it from [[Minimal BASIC]] which is another standard established by ANSI, ISO, and ECMA. ECMA, in ECMA-116 (1986), defined a subset of the ANSI BASIC Standard, ANSI X3.113-198X. The specification is divided into three parts: ECMA BASIC-1, ECMA BASIC-2, and ECMA Graphics Module. ECMA Standard is fully upward compatible with corresponding implementations of the ANSI Standard. -== Main features == -* MAT keywords for matrix manipulation -* Optional use of decimal [[floating point]] (''radix 10'') to improve numerical presentation. - -== Implementations == -* [[True BASIC]] -* [[Decimal BASIC]] -* [http://www.moria.de/~michael/bas/ Bas] - [[Category:Standards]] \ No newline at end of file diff --git a/Lang/ANSI-BASIC/100-doors b/Lang/ANSI-BASIC/100-doors deleted file mode 120000 index bd1164e9d1..0000000000 --- a/Lang/ANSI-BASIC/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/AKS-test-for-primes b/Lang/ANSI-BASIC/AKS-test-for-primes deleted file mode 120000 index 4668d2783c..0000000000 --- a/Lang/ANSI-BASIC/AKS-test-for-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/AKS-test-for-primes/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Abundant-deficient-and-perfect-number-classifications b/Lang/ANSI-BASIC/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index c6e6a91dca..0000000000 --- a/Lang/ANSI-BASIC/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Abundant-odd-numbers b/Lang/ANSI-BASIC/Abundant-odd-numbers deleted file mode 120000 index 655c1f21d6..0000000000 --- a/Lang/ANSI-BASIC/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Angle-difference-between-two-bearings b/Lang/ANSI-BASIC/Angle-difference-between-two-bearings deleted file mode 120000 index de48f860b4..0000000000 --- a/Lang/ANSI-BASIC/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Arithmetic-numbers b/Lang/ANSI-BASIC/Arithmetic-numbers deleted file mode 120000 index db92ceb262..0000000000 --- a/Lang/ANSI-BASIC/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Babbage-problem b/Lang/ANSI-BASIC/Babbage-problem deleted file mode 120000 index 8ef3bfe458..0000000000 --- a/Lang/ANSI-BASIC/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Bell-numbers b/Lang/ANSI-BASIC/Bell-numbers deleted file mode 120000 index ce789dbea6..0000000000 --- a/Lang/ANSI-BASIC/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Brazilian-numbers b/Lang/ANSI-BASIC/Brazilian-numbers deleted file mode 120000 index b5ea63630e..0000000000 --- a/Lang/ANSI-BASIC/Brazilian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brazilian-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/CUSIP b/Lang/ANSI-BASIC/CUSIP deleted file mode 120000 index fc24eb8330..0000000000 --- a/Lang/ANSI-BASIC/CUSIP +++ /dev/null @@ -1 +0,0 @@ -../../Task/CUSIP/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Catalan-numbers b/Lang/ANSI-BASIC/Catalan-numbers deleted file mode 120000 index 9c5cfe1b71..0000000000 --- a/Lang/ANSI-BASIC/Catalan-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Cumulative-standard-deviation b/Lang/ANSI-BASIC/Cumulative-standard-deviation deleted file mode 120000 index 1d8fe68648..0000000000 --- a/Lang/ANSI-BASIC/Cumulative-standard-deviation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cumulative-standard-deviation/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Damm-algorithm b/Lang/ANSI-BASIC/Damm-algorithm deleted file mode 120000 index e4b39fdaa1..0000000000 --- a/Lang/ANSI-BASIC/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Day-of-the-week b/Lang/ANSI-BASIC/Day-of-the-week deleted file mode 120000 index 8ccffe667c..0000000000 --- a/Lang/ANSI-BASIC/Day-of-the-week +++ /dev/null @@ -1 +0,0 @@ -../../Task/Day-of-the-week/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Department-numbers b/Lang/ANSI-BASIC/Department-numbers deleted file mode 120000 index 44a9633eba..0000000000 --- a/Lang/ANSI-BASIC/Department-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Department-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Determine-if-a-string-is-collapsible b/Lang/ANSI-BASIC/Determine-if-a-string-is-collapsible deleted file mode 120000 index 47a87c627a..0000000000 --- a/Lang/ANSI-BASIC/Determine-if-a-string-is-collapsible +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-collapsible/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Dot-product b/Lang/ANSI-BASIC/Dot-product deleted file mode 120000 index 22c1437095..0000000000 --- a/Lang/ANSI-BASIC/Dot-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dot-product/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Dragon-curve b/Lang/ANSI-BASIC/Dragon-curve deleted file mode 120000 index 1650355f05..0000000000 --- a/Lang/ANSI-BASIC/Dragon-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dragon-curve/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Dutch-national-flag-problem b/Lang/ANSI-BASIC/Dutch-national-flag-problem deleted file mode 120000 index 96adf147fe..0000000000 --- a/Lang/ANSI-BASIC/Dutch-national-flag-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dutch-national-flag-problem/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Egyptian-division b/Lang/ANSI-BASIC/Egyptian-division deleted file mode 120000 index 6f37fbca47..0000000000 --- a/Lang/ANSI-BASIC/Egyptian-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Egyptian-division/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Equilibrium-index b/Lang/ANSI-BASIC/Equilibrium-index deleted file mode 120000 index 4273670f14..0000000000 --- a/Lang/ANSI-BASIC/Equilibrium-index +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equilibrium-index/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Ethiopian-multiplication b/Lang/ANSI-BASIC/Ethiopian-multiplication deleted file mode 120000 index 0687e83f8a..0000000000 --- a/Lang/ANSI-BASIC/Ethiopian-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ethiopian-multiplication/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Factors-of-an-integer b/Lang/ANSI-BASIC/Factors-of-an-integer deleted file mode 120000 index 187d81b94b..0000000000 --- a/Lang/ANSI-BASIC/Factors-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factors-of-an-integer/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Fibonacci-sequence b/Lang/ANSI-BASIC/Fibonacci-sequence deleted file mode 120000 index 7c7a1193ff..0000000000 --- a/Lang/ANSI-BASIC/Fibonacci-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-sequence/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Formatted-numeric-output b/Lang/ANSI-BASIC/Formatted-numeric-output deleted file mode 120000 index e876b7e939..0000000000 --- a/Lang/ANSI-BASIC/Formatted-numeric-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Formatted-numeric-output/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Function-definition b/Lang/ANSI-BASIC/Function-definition deleted file mode 120000 index c45352eba7..0000000000 --- a/Lang/ANSI-BASIC/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Generate-lower-case-ASCII-alphabet b/Lang/ANSI-BASIC/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index 26bc617302..0000000000 --- a/Lang/ANSI-BASIC/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Horizontal-sundial-calculations b/Lang/ANSI-BASIC/Horizontal-sundial-calculations deleted file mode 120000 index 9ac1ff4a6b..0000000000 --- a/Lang/ANSI-BASIC/Horizontal-sundial-calculations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horizontal-sundial-calculations/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Horners-rule-for-polynomial-evaluation b/Lang/ANSI-BASIC/Horners-rule-for-polynomial-evaluation deleted file mode 120000 index 4c6423e8e1..0000000000 --- a/Lang/ANSI-BASIC/Horners-rule-for-polynomial-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horners-rule-for-polynomial-evaluation/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Langtons-ant b/Lang/ANSI-BASIC/Langtons-ant deleted file mode 120000 index c0944407d4..0000000000 --- a/Lang/ANSI-BASIC/Langtons-ant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Langtons-ant/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Largest-proper-divisor-of-n b/Lang/ANSI-BASIC/Largest-proper-divisor-of-n deleted file mode 120000 index e505793222..0000000000 --- a/Lang/ANSI-BASIC/Largest-proper-divisor-of-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-proper-divisor-of-n/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Leap-year b/Lang/ANSI-BASIC/Leap-year deleted file mode 120000 index d8f2cec2bd..0000000000 --- a/Lang/ANSI-BASIC/Leap-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leap-year/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Leonardo-numbers b/Lang/ANSI-BASIC/Leonardo-numbers deleted file mode 120000 index eeb51e71aa..0000000000 --- a/Lang/ANSI-BASIC/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Levenshtein-distance b/Lang/ANSI-BASIC/Levenshtein-distance deleted file mode 120000 index 92b553d536..0000000000 --- a/Lang/ANSI-BASIC/Levenshtein-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Long-year b/Lang/ANSI-BASIC/Long-year deleted file mode 120000 index ca5898e1c7..0000000000 --- a/Lang/ANSI-BASIC/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Loops-Do-while b/Lang/ANSI-BASIC/Loops-Do-while deleted file mode 120000 index 998c0b9f8a..0000000000 --- a/Lang/ANSI-BASIC/Loops-Do-while +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Do-while/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Luhn-test-of-credit-card-numbers b/Lang/ANSI-BASIC/Luhn-test-of-credit-card-numbers deleted file mode 120000 index 5e8c5fe6dd..0000000000 --- a/Lang/ANSI-BASIC/Luhn-test-of-credit-card-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Luhn-test-of-credit-card-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/M-bius-function b/Lang/ANSI-BASIC/M-bius-function deleted file mode 120000 index f786d2b99e..0000000000 --- a/Lang/ANSI-BASIC/M-bius-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/M-bius-function/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Magic-constant b/Lang/ANSI-BASIC/Magic-constant deleted file mode 120000 index 7d2184182c..0000000000 --- a/Lang/ANSI-BASIC/Magic-constant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-constant/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Map-range b/Lang/ANSI-BASIC/Map-range deleted file mode 120000 index 829dfc3a26..0000000000 --- a/Lang/ANSI-BASIC/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Mayan-numerals b/Lang/ANSI-BASIC/Mayan-numerals deleted file mode 120000 index daef520f79..0000000000 --- a/Lang/ANSI-BASIC/Mayan-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mayan-numerals/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Monty-Hall-problem b/Lang/ANSI-BASIC/Monty-Hall-problem deleted file mode 120000 index 8f9a29cbcc..0000000000 --- a/Lang/ANSI-BASIC/Monty-Hall-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monty-Hall-problem/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Nth b/Lang/ANSI-BASIC/Nth deleted file mode 120000 index 83517d5111..0000000000 --- a/Lang/ANSI-BASIC/Nth +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Nth-root b/Lang/ANSI-BASIC/Nth-root deleted file mode 120000 index 089f4d872e..0000000000 --- a/Lang/ANSI-BASIC/Nth-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth-root/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Old-Russian-measure-of-length b/Lang/ANSI-BASIC/Old-Russian-measure-of-length deleted file mode 120000 index 81f64cd54c..0000000000 --- a/Lang/ANSI-BASIC/Old-Russian-measure-of-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Old-Russian-measure-of-length/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Periodic-table b/Lang/ANSI-BASIC/Periodic-table deleted file mode 120000 index b9e95e6595..0000000000 --- a/Lang/ANSI-BASIC/Periodic-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Periodic-table/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Prime-decomposition b/Lang/ANSI-BASIC/Prime-decomposition deleted file mode 120000 index 0d416fe46e..0000000000 --- a/Lang/ANSI-BASIC/Prime-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-decomposition/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Random-numbers b/Lang/ANSI-BASIC/Random-numbers deleted file mode 120000 index 1de5221db0..0000000000 --- a/Lang/ANSI-BASIC/Random-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Real-constants-and-functions b/Lang/ANSI-BASIC/Real-constants-and-functions deleted file mode 120000 index 02cced5726..0000000000 --- a/Lang/ANSI-BASIC/Real-constants-and-functions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Real-constants-and-functions/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Remove-duplicate-elements b/Lang/ANSI-BASIC/Remove-duplicate-elements deleted file mode 120000 index 76d3035dcb..0000000000 --- a/Lang/ANSI-BASIC/Remove-duplicate-elements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Remove-duplicate-elements/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Repeat-a-string b/Lang/ANSI-BASIC/Repeat-a-string deleted file mode 120000 index 018a40d1b5..0000000000 --- a/Lang/ANSI-BASIC/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Rot-13 b/Lang/ANSI-BASIC/Rot-13 deleted file mode 120000 index 6dadbcd391..0000000000 --- a/Lang/ANSI-BASIC/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Semiprime b/Lang/ANSI-BASIC/Semiprime deleted file mode 120000 index e0427579b2..0000000000 --- a/Lang/ANSI-BASIC/Semiprime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semiprime/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Shoelace-formula-for-polygonal-area b/Lang/ANSI-BASIC/Shoelace-formula-for-polygonal-area deleted file mode 120000 index 63de3b564e..0000000000 --- a/Lang/ANSI-BASIC/Shoelace-formula-for-polygonal-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shoelace-formula-for-polygonal-area/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Sorting-algorithms-Quicksort b/Lang/ANSI-BASIC/Sorting-algorithms-Quicksort deleted file mode 120000 index acf4c89afe..0000000000 --- a/Lang/ANSI-BASIC/Sorting-algorithms-Quicksort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Quicksort/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Square-free-integers b/Lang/ANSI-BASIC/Square-free-integers deleted file mode 120000 index 90f8c4cba3..0000000000 --- a/Lang/ANSI-BASIC/Square-free-integers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-free-integers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Statistics-Basic b/Lang/ANSI-BASIC/Statistics-Basic deleted file mode 120000 index 11c8fbb1d2..0000000000 --- a/Lang/ANSI-BASIC/Statistics-Basic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Basic/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Statistics-Normal-distribution b/Lang/ANSI-BASIC/Statistics-Normal-distribution deleted file mode 120000 index 674b0ba86f..0000000000 --- a/Lang/ANSI-BASIC/Statistics-Normal-distribution +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Normal-distribution/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/String-length b/Lang/ANSI-BASIC/String-length deleted file mode 120000 index 7ad71b1ccb..0000000000 --- a/Lang/ANSI-BASIC/String-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-length/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Tau-number b/Lang/ANSI-BASIC/Tau-number deleted file mode 120000 index bfebf263eb..0000000000 --- a/Lang/ANSI-BASIC/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Temperature-conversion b/Lang/ANSI-BASIC/Temperature-conversion deleted file mode 120000 index af167d778a..0000000000 --- a/Lang/ANSI-BASIC/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Trabb-Pardo-Knuth-algorithm b/Lang/ANSI-BASIC/Trabb-Pardo-Knuth-algorithm deleted file mode 120000 index a19f987c84..0000000000 --- a/Lang/ANSI-BASIC/Trabb-Pardo-Knuth-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Trabb-Pardo-Knuth-algorithm/ANSI-BASIC \ No newline at end of file diff --git a/Lang/APL/ADFGVX-cipher b/Lang/APL/ADFGVX-cipher deleted file mode 120000 index ab764adced..0000000000 --- a/Lang/APL/ADFGVX-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/ADFGVX-cipher/APL \ No newline at end of file diff --git a/Lang/APL/Abelian-sandpile-model b/Lang/APL/Abelian-sandpile-model deleted file mode 120000 index 346a055fbc..0000000000 --- a/Lang/APL/Abelian-sandpile-model +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model/APL \ No newline at end of file diff --git a/Lang/APL/Align-columns b/Lang/APL/Align-columns deleted file mode 120000 index b966dedf04..0000000000 --- a/Lang/APL/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/APL \ No newline at end of file diff --git a/Lang/APL/Arithmetic-derivative b/Lang/APL/Arithmetic-derivative deleted file mode 120000 index c5dd2fd89b..0000000000 --- a/Lang/APL/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/APL \ No newline at end of file diff --git a/Lang/APL/Arithmetic-numbers b/Lang/APL/Arithmetic-numbers deleted file mode 120000 index 6e1869f653..0000000000 --- a/Lang/APL/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/APL \ No newline at end of file diff --git a/Lang/APL/Benfords-law b/Lang/APL/Benfords-law deleted file mode 120000 index e194573832..0000000000 --- a/Lang/APL/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/APL \ No newline at end of file diff --git a/Lang/APL/Bioinformatics-base-count b/Lang/APL/Bioinformatics-base-count new file mode 120000 index 0000000000..f9e2de8949 --- /dev/null +++ b/Lang/APL/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/APL \ No newline at end of file diff --git a/Lang/APL/Chinese-zodiac b/Lang/APL/Chinese-zodiac deleted file mode 120000 index 34bffed454..0000000000 --- a/Lang/APL/Chinese-zodiac +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chinese-zodiac/APL \ No newline at end of file diff --git a/Lang/APL/Combinations b/Lang/APL/Combinations deleted file mode 120000 index b1574b8996..0000000000 --- a/Lang/APL/Combinations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations/APL \ No newline at end of file diff --git a/Lang/APL/Display-a-linear-combination b/Lang/APL/Display-a-linear-combination deleted file mode 120000 index 0e1867473a..0000000000 --- a/Lang/APL/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/APL \ No newline at end of file diff --git a/Lang/APL/Duffinian-numbers b/Lang/APL/Duffinian-numbers deleted file mode 120000 index da1810e24a..0000000000 --- a/Lang/APL/Duffinian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Duffinian-numbers/APL \ No newline at end of file diff --git a/Lang/APL/Floyds-triangle b/Lang/APL/Floyds-triangle deleted file mode 120000 index ba13d02d17..0000000000 --- a/Lang/APL/Floyds-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyds-triangle/APL \ No newline at end of file diff --git a/Lang/APL/Hex-words b/Lang/APL/Hex-words deleted file mode 120000 index 7a46a08841..0000000000 --- a/Lang/APL/Hex-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hex-words/APL \ No newline at end of file diff --git a/Lang/APL/Longest-common-substring b/Lang/APL/Longest-common-substring deleted file mode 120000 index dd75194fe4..0000000000 --- a/Lang/APL/Longest-common-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-common-substring/APL \ No newline at end of file diff --git a/Lang/APL/Loops-Infinite b/Lang/APL/Loops-Infinite deleted file mode 120000 index 0f3ec957d2..0000000000 --- a/Lang/APL/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/APL \ No newline at end of file diff --git a/Lang/APL/Monte-Carlo-methods b/Lang/APL/Monte-Carlo-methods deleted file mode 120000 index 2cf831a11c..0000000000 --- a/Lang/APL/Monte-Carlo-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monte-Carlo-methods/APL \ No newline at end of file diff --git a/Lang/APL/Move-to-front-algorithm b/Lang/APL/Move-to-front-algorithm deleted file mode 120000 index bce8e1d67b..0000000000 --- a/Lang/APL/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/APL \ No newline at end of file diff --git a/Lang/APL/Partition-an-integer-x-into-n-primes b/Lang/APL/Partition-an-integer-x-into-n-primes deleted file mode 120000 index 6a32dc9f66..0000000000 --- a/Lang/APL/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/APL \ No newline at end of file diff --git a/Lang/APL/Pisano-period b/Lang/APL/Pisano-period deleted file mode 120000 index d81ff37307..0000000000 --- a/Lang/APL/Pisano-period +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pisano-period/APL \ No newline at end of file diff --git a/Lang/APL/Set-consolidation b/Lang/APL/Set-consolidation deleted file mode 120000 index 56b2446a2d..0000000000 --- a/Lang/APL/Set-consolidation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-consolidation/APL \ No newline at end of file diff --git a/Lang/APL/Sort-a-list-of-object-identifiers b/Lang/APL/Sort-a-list-of-object-identifiers deleted file mode 120000 index 400cb9fc60..0000000000 --- a/Lang/APL/Sort-a-list-of-object-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-a-list-of-object-identifiers/APL \ No newline at end of file diff --git a/Lang/APL/Strip-comments-from-a-string b/Lang/APL/Strip-comments-from-a-string deleted file mode 120000 index ff78e120aa..0000000000 --- a/Lang/APL/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/APL \ No newline at end of file diff --git a/Lang/APL/The-Twelve-Days-of-Christmas b/Lang/APL/The-Twelve-Days-of-Christmas deleted file mode 120000 index 2bb4434d11..0000000000 --- a/Lang/APL/The-Twelve-Days-of-Christmas +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-Twelve-Days-of-Christmas/APL \ No newline at end of file diff --git a/Lang/APL/Tic-tac-toe b/Lang/APL/Tic-tac-toe deleted file mode 120000 index 58bb681d1c..0000000000 --- a/Lang/APL/Tic-tac-toe +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tic-tac-toe/APL \ No newline at end of file diff --git a/Lang/APL/Word-ladder b/Lang/APL/Word-ladder deleted file mode 120000 index 6de9f38d51..0000000000 --- a/Lang/APL/Word-ladder +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-ladder/APL \ No newline at end of file diff --git a/Lang/APL/Zeckendorf-number-representation b/Lang/APL/Zeckendorf-number-representation deleted file mode 120000 index e25cdfa21a..0000000000 --- a/Lang/APL/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/APL \ No newline at end of file diff --git a/Lang/ARM-Assembly/00-LANG.txt b/Lang/ARM-Assembly/00-LANG.txt index 273ed5e757..4c41d124d7 100644 --- a/Lang/ARM-Assembly/00-LANG.txt +++ b/Lang/ARM-Assembly/00-LANG.txt @@ -4,9 +4,9 @@ The ARM architecture is widely used on mobile phones and tablets. It falls under ===Instruction Size=== Every instruction that the ARM can execute is 32 bits. While other processors can have variable length instructions, the ARM does not. This means that the ARM doesn't need to parse where an instruction begins and ends, which makes it run very fast. What you might not expect is that this 32-bit instruction size includes both the actual instruction and the operands! Let's take a look at a [[Z80 Assembly]] instruction and compare it to an ARM instruction. -LD HL,&8040 ;bytecode is 0x21 0x40 0x80 +LD HL,&8040 ;bytecode is 0x21 0x40 0x80 -mov r4,#0x04000000 ;bytecode is 0xE3A04301 +mov r4,#0x04000000 ;bytecode is 0xE3A04301 So where did the 0x04000000 go? It's actually been compressed and fit within those 4 bytes you saw earlier. The ARM is very good at decompressing it, since it's been shrunk to an 8-bit number that can be rotated by an even number of bits. Unfortunately, this compression method is a double-edged sword - some 32-bit numbers can't be compressed this way, and thus many instructions can't work with them! @@ -18,73 +18,72 @@ Registers are much more flexible than immediate operands. Unlike immediate opera Getting an address in a register can be achieved with the MOV command, but there are limitations to that which will be explained in detail later. It's more reliable to use ADR which loads a nearby address into a register. This address has to be within a certain distance from the current program counter or it can't be loaded, so it's not a reliable way to load from the heap on many machines. It's mostly intended for loading from nearby read-only data, such as text strings or stored immediates (more on that later). When you type ADR R0,LABEL, the assembler will convert this to MOV R0,PC,#N, where N is the difference between the current program counter value and the label you specified. LDR can be used in a similar fashion to ADR but there is a subtle distinction between the two. Assume that the section below is assembled starting at memory address 0x04000000: -DataBlock: +DataBlock: .long 0xDEADBEEF ;VASM uses .long for 32-bit data and .word for 16-bit data. Your assembler will probably use .word for 32 bit and .long 0xFFFFFFFF ; .hword for 16-bit. MyCode: adr r0, DataBlock ;loads the value 0x04000000 into R0 + ldr r1, DataBlock ;loads the value 0xDEADBEEF into R1 + adr r2, DataBlock+4 ;loads the value 0x04000004 into R2 -ldr r3, DataBlock+4 ;loads the value 0xFFFFFFFF into R3 - + +ldr r3, DataBlock+4 ;loads the value 0xFFFFFFFF into R3 As you can see, ADR only gives you the memory location of a value in memory, where LDR loads ''from'' that memory location. + ===Data Addressing using LDR and STR=== Unlike its "cousin," the Motorola 68000 (which isn't really related but has a somewhat similar design), the ARM cannot directly write immediate values to memory. Those values must be contained in registers first. Unlike the 68000, the ARM has no "address registers." Rather, enclosing a register name in square brackets turns its value into a reference to a memory location. You'll need to load that memory location's numeric "value" as a constant first. Then you can read from it with LDR and write to it with STR. Not only can you read from a given address, you can also adjust how you read from it, and what you do before or after the read. -RAM_ADDRESS: +RAM_ADDRESS: .long 0 ;for simplicity we'll assume that this can actually be written to. Represents a placeholder for 32-bit data. ;Your assembler's syntax may be different. + .long 0 ;another placeholder for 32-bit data MyCode: adr R2,RAM_Address ;get the address of a nearby place to store values. MOV R0,#0x12345678 ;the value to store. -STR R0,[R2] ;store 0x12345678 into the first 32-bit slot. - +STR R0,[R2] ;store 0x12345678 into the first 32-bit slot. This is the basic way to store into memory, but there are other options, such as offsetting and post-increment. -RAM_ADDRESS: +RAM_ADDRESS: .long 0 .long 0 ;we'll store here this time. MyCode: adr R2,RAM_Address ;point R2 to the first storage slot MOV R0,#0x12345678 -STR R0,[R2,#4] ;store into the SECOND slot. R2 still points to the first slot - the #4 is added to R2 only temporarily. - +STR R0,[R2,#4] ;store into the SECOND slot. R2 still points to the first slot - the #4 is added to R2 only temporarily. There's a limit on the size of an immediate value used to offset when loading/storing. You can also use a register as an offset, whose value will be added to the address. -RAM_AREA: +RAM_AREA: .space 64,0 ;64 bytes of ram ;assume that R2 contains the address of "RAM_AREA" MyCode: MOV R0,#0x12345678 MOV R1,#20 -STR R0,[R2,R1] ;equivalent of "STR R0,[R2,#20]" - +STR R0,[R2,R1] ;equivalent of "STR R0,[R2,#20]" Now let's say you wanted to actually alter the pointer to R2, so that it remains pointing to where you offset it to after the store or load. That's an option you have - all you have to do is type "!" after the brackets. This is called "pre-increment" or "pre-indexing." -RAM_ADDRESS: +RAM_ADDRESS: .long 0 .long 0 ;we'll store here this time, and we want R2 to still be pointing here after we write to it. MyCode: adr R2,RAM_Address ;point R2 to the first storage slot MOV R0,#0x12345678 -STR R0,[R2,#4]! ;store into the SECOND slot. R2 also points to the second slot now, even after this instruction has concluded. - +STR R0,[R2,#4]! ;store into the SECOND slot. R2 also points to the second slot now, even after this instruction has concluded. Here, the offset is performed ''before'' the storage operation. What if you want to offset afterwards? That would be useful for reading in a data stream. Good news - you can do that simply by having the offset value or register '''outside''' the brackets. This is called "post-increment" or "post-indexing." Unlike pre-indexing, these changes to the pointer are not temporary. -LDR R0,[R1],#4 ;load the 32-bit value stored at memory location R1 into R0, THEN add 4 to R1. This offset remains even after this - ; instruction is finished. - +LDR R0,[R1],#4 ;load the 32-bit value stored at memory location R1 into R0, THEN add 4 to R1. This offset remains even after this + ; instruction is finished. ===Barrel Shifter=== The ARM can add a bit shift or rotate to one of its operands at no additional cost to execution time or bytecode. If the operand being shifted is a register, the value of that register is not actually changed. The shift or rotate only applies during that instruction. diff --git a/Lang/ARM-Assembly/ADFGVX-cipher b/Lang/ARM-Assembly/ADFGVX-cipher deleted file mode 120000 index acb7dd15a4..0000000000 --- a/Lang/ARM-Assembly/ADFGVX-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/ADFGVX-cipher/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Arithmetic-numbers b/Lang/ARM-Assembly/Arithmetic-numbers deleted file mode 120000 index b3332e6dc9..0000000000 --- a/Lang/ARM-Assembly/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Averages-Median b/Lang/ARM-Assembly/Averages-Median deleted file mode 120000 index c20d36fae7..0000000000 --- a/Lang/ARM-Assembly/Averages-Median +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Median/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Best-shuffle b/Lang/ARM-Assembly/Best-shuffle deleted file mode 120000 index 041ec84a9a..0000000000 --- a/Lang/ARM-Assembly/Best-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Best-shuffle/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Bifid-cipher b/Lang/ARM-Assembly/Bifid-cipher deleted file mode 120000 index 456e328d85..0000000000 --- a/Lang/ARM-Assembly/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Binary-strings b/Lang/ARM-Assembly/Binary-strings deleted file mode 120000 index a7b6ed7647..0000000000 --- a/Lang/ARM-Assembly/Binary-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-strings/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Comma-quibbling b/Lang/ARM-Assembly/Comma-quibbling deleted file mode 120000 index 3d3d7812f0..0000000000 --- a/Lang/ARM-Assembly/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Count-occurrences-of-a-substring b/Lang/ARM-Assembly/Count-occurrences-of-a-substring deleted file mode 120000 index e3696ad70d..0000000000 --- a/Lang/ARM-Assembly/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Create-an-HTML-table b/Lang/ARM-Assembly/Create-an-HTML-table deleted file mode 120000 index 72c300d67a..0000000000 --- a/Lang/ARM-Assembly/Create-an-HTML-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-an-HTML-table/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Determine-sentence-type b/Lang/ARM-Assembly/Determine-sentence-type deleted file mode 120000 index 5e77711ab2..0000000000 --- a/Lang/ARM-Assembly/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Environment-variables b/Lang/ARM-Assembly/Environment-variables deleted file mode 120000 index 11f3baa342..0000000000 --- a/Lang/ARM-Assembly/Environment-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Environment-variables/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Fibonacci-n-step-number-sequences b/Lang/ARM-Assembly/Fibonacci-n-step-number-sequences deleted file mode 120000 index 6e51a1f11e..0000000000 --- a/Lang/ARM-Assembly/Fibonacci-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-n-step-number-sequences/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Filter b/Lang/ARM-Assembly/Filter deleted file mode 120000 index 7be8949b1d..0000000000 --- a/Lang/ARM-Assembly/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Guess-the-number b/Lang/ARM-Assembly/Guess-the-number deleted file mode 120000 index f4c41a9cec..0000000000 --- a/Lang/ARM-Assembly/Guess-the-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Halt-and-catch-fire b/Lang/ARM-Assembly/Halt-and-catch-fire deleted file mode 120000 index 56faf31b66..0000000000 --- a/Lang/ARM-Assembly/Halt-and-catch-fire +++ /dev/null @@ -1 +0,0 @@ -../../Task/Halt-and-catch-fire/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Hash-from-two-arrays b/Lang/ARM-Assembly/Hash-from-two-arrays deleted file mode 120000 index 2a1c9147a6..0000000000 --- a/Lang/ARM-Assembly/Hash-from-two-arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hash-from-two-arrays/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Jewels-and-stones b/Lang/ARM-Assembly/Jewels-and-stones deleted file mode 120000 index 629d907643..0000000000 --- a/Lang/ARM-Assembly/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/K-d-tree b/Lang/ARM-Assembly/K-d-tree deleted file mode 120000 index e682e1d7f3..0000000000 --- a/Lang/ARM-Assembly/K-d-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/K-d-tree/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/ARM-Assembly/Keyboard-input-Obtain-a-Y-or-N-response deleted file mode 120000 index dc21bae989..0000000000 --- a/Lang/ARM-Assembly/Keyboard-input-Obtain-a-Y-or-N-response +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Obtain-a-Y-or-N-response/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Leonardo-numbers b/Lang/ARM-Assembly/Leonardo-numbers deleted file mode 120000 index 6639dbc2f4..0000000000 --- a/Lang/ARM-Assembly/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Letter-frequency b/Lang/ARM-Assembly/Letter-frequency deleted file mode 120000 index 16abb3b275..0000000000 --- a/Lang/ARM-Assembly/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Machine-code b/Lang/ARM-Assembly/Machine-code deleted file mode 120000 index e48d9e81b2..0000000000 --- a/Lang/ARM-Assembly/Machine-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Machine-code/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Menu b/Lang/ARM-Assembly/Menu deleted file mode 120000 index 73a332d6f3..0000000000 --- a/Lang/ARM-Assembly/Menu +++ /dev/null @@ -1 +0,0 @@ -../../Task/Menu/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Pancake-numbers b/Lang/ARM-Assembly/Pancake-numbers deleted file mode 120000 index 7bcfc9ff51..0000000000 --- a/Lang/ARM-Assembly/Pancake-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pancake-numbers/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Phrase-reversals b/Lang/ARM-Assembly/Phrase-reversals deleted file mode 120000 index 011ca34c42..0000000000 --- a/Lang/ARM-Assembly/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Pi b/Lang/ARM-Assembly/Pi deleted file mode 120000 index 97b44cbcc1..0000000000 --- a/Lang/ARM-Assembly/Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pi/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Primality-by-trial-division b/Lang/ARM-Assembly/Primality-by-trial-division deleted file mode 120000 index 1ed40416b3..0000000000 --- a/Lang/ARM-Assembly/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Quickselect-algorithm b/Lang/ARM-Assembly/Quickselect-algorithm deleted file mode 120000 index 20380ae54f..0000000000 --- a/Lang/ARM-Assembly/Quickselect-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quickselect-algorithm/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Read-a-configuration-file b/Lang/ARM-Assembly/Read-a-configuration-file deleted file mode 120000 index 76094b38c7..0000000000 --- a/Lang/ARM-Assembly/Read-a-configuration-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-configuration-file/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Repeat-a-string b/Lang/ARM-Assembly/Repeat-a-string deleted file mode 120000 index 69591f65b7..0000000000 --- a/Lang/ARM-Assembly/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Reverse-words-in-a-string b/Lang/ARM-Assembly/Reverse-words-in-a-string deleted file mode 120000 index 10d177c9f9..0000000000 --- a/Lang/ARM-Assembly/Reverse-words-in-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-words-in-a-string/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Rot-13 b/Lang/ARM-Assembly/Rot-13 deleted file mode 120000 index d5a49ba9a9..0000000000 --- a/Lang/ARM-Assembly/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Sequence-of-primes-by-trial-division b/Lang/ARM-Assembly/Sequence-of-primes-by-trial-division deleted file mode 120000 index c698f6de3b..0000000000 --- a/Lang/ARM-Assembly/Sequence-of-primes-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-primes-by-trial-division/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Sort-disjoint-sublist b/Lang/ARM-Assembly/Sort-disjoint-sublist deleted file mode 120000 index c5cadcbc7b..0000000000 --- a/Lang/ARM-Assembly/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Sorting-Algorithms-Circle-Sort b/Lang/ARM-Assembly/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..21eb603d7e --- /dev/null +++ b/Lang/ARM-Assembly/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/String-case b/Lang/ARM-Assembly/String-case deleted file mode 120000 index 08688552ec..0000000000 --- a/Lang/ARM-Assembly/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/String-prepend b/Lang/ARM-Assembly/String-prepend deleted file mode 120000 index ab543c682f..0000000000 --- a/Lang/ARM-Assembly/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Strip-block-comments b/Lang/ARM-Assembly/Strip-block-comments deleted file mode 120000 index 6a5702298a..0000000000 --- a/Lang/ARM-Assembly/Strip-block-comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-block-comments/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Strip-comments-from-a-string b/Lang/ARM-Assembly/Strip-comments-from-a-string deleted file mode 120000 index b01acc2585..0000000000 --- a/Lang/ARM-Assembly/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Strip-whitespace-from-a-string-Top-and-tail b/Lang/ARM-Assembly/Strip-whitespace-from-a-string-Top-and-tail deleted file mode 120000 index ba0f5a585c..0000000000 --- a/Lang/ARM-Assembly/Strip-whitespace-from-a-string-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-whitespace-from-a-string-Top-and-tail/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Substitution-cipher b/Lang/ARM-Assembly/Substitution-cipher deleted file mode 120000 index 9fdcf71f24..0000000000 --- a/Lang/ARM-Assembly/Substitution-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substitution-cipher/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Update-a-configuration-file b/Lang/ARM-Assembly/Update-a-configuration-file deleted file mode 120000 index 9dd67115c0..0000000000 --- a/Lang/ARM-Assembly/Update-a-configuration-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Update-a-configuration-file/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Vigen-re-cipher b/Lang/ARM-Assembly/Vigen-re-cipher deleted file mode 120000 index caeb031a4b..0000000000 --- a/Lang/ARM-Assembly/Vigen-re-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vigen-re-cipher/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Vigen-re-cipher-Cryptanalysis b/Lang/ARM-Assembly/Vigen-re-cipher-Cryptanalysis deleted file mode 120000 index ecfd7ae59c..0000000000 --- a/Lang/ARM-Assembly/Vigen-re-cipher-Cryptanalysis +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vigen-re-cipher-Cryptanalysis/ARM-Assembly \ No newline at end of file diff --git a/Lang/ARM-Assembly/Visualize-a-tree b/Lang/ARM-Assembly/Visualize-a-tree deleted file mode 120000 index 58626c23da..0000000000 --- a/Lang/ARM-Assembly/Visualize-a-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/Visualize-a-tree/ARM-Assembly \ No newline at end of file diff --git a/Lang/ASIC/Dragon-curve b/Lang/ASIC/Dragon-curve deleted file mode 120000 index 7538c55bbc..0000000000 --- a/Lang/ASIC/Dragon-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dragon-curve/ASIC \ No newline at end of file diff --git a/Lang/ASIC/Generate-lower-case-ASCII-alphabet b/Lang/ASIC/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index af19876ed5..0000000000 --- a/Lang/ASIC/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/ASIC \ No newline at end of file diff --git a/Lang/ASIC/Luhn-test-of-credit-card-numbers b/Lang/ASIC/Luhn-test-of-credit-card-numbers deleted file mode 120000 index 30c2c72edb..0000000000 --- a/Lang/ASIC/Luhn-test-of-credit-card-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Luhn-test-of-credit-card-numbers/ASIC \ No newline at end of file diff --git a/Lang/ASIC/M-bius-function b/Lang/ASIC/M-bius-function deleted file mode 120000 index 7848f34d54..0000000000 --- a/Lang/ASIC/M-bius-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/M-bius-function/ASIC \ No newline at end of file diff --git a/Lang/ASIC/Old-Russian-measure-of-length b/Lang/ASIC/Old-Russian-measure-of-length deleted file mode 120000 index e5e809a47d..0000000000 --- a/Lang/ASIC/Old-Russian-measure-of-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Old-Russian-measure-of-length/ASIC \ No newline at end of file diff --git a/Lang/ASIC/Temperature-conversion b/Lang/ASIC/Temperature-conversion deleted file mode 120000 index 312278bfcd..0000000000 --- a/Lang/ASIC/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/ASIC \ No newline at end of file diff --git a/Lang/ATS/Determine-if-two-triangles-overlap b/Lang/ATS/Determine-if-two-triangles-overlap deleted file mode 120000 index 68e5e730ef..0000000000 --- a/Lang/ATS/Determine-if-two-triangles-overlap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-two-triangles-overlap/ATS \ No newline at end of file diff --git a/Lang/ATS/Find-if-a-point-is-within-a-triangle b/Lang/ATS/Find-if-a-point-is-within-a-triangle deleted file mode 120000 index 1f2b2a99f5..0000000000 --- a/Lang/ATS/Find-if-a-point-is-within-a-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-if-a-point-is-within-a-triangle/ATS \ No newline at end of file diff --git a/Lang/ATS/Quaternion-type b/Lang/ATS/Quaternion-type new file mode 120000 index 0000000000..95bd8641ec --- /dev/null +++ b/Lang/ATS/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/ATS \ No newline at end of file diff --git a/Lang/AWK/00-LANG.txt b/Lang/AWK/00-LANG.txt index 4d384747d7..1ae6ff2ef6 100644 --- a/Lang/AWK/00-LANG.txt +++ b/Lang/AWK/00-LANG.txt @@ -8,13 +8,13 @@ Each AWK program consists of pattern-action statements. The program reads each input line, checks lines against patterns, and runs matching actions. For programs that never read input lines, the entire program can be one BEGIN { ... } block. -* ''List users who have /bin/ksh as a shell.''$ awk -F: '$7 == "/bin/ksh" { print $1 }' /etc/passwd +* ''List users who have /bin/ksh as a shell.''$ awk -F: '$7 == "/bin/ksh" { print $1 }' /etc/passwd AWK has only three types of variables: they are strings, floating-point numbers, and associative arrays (where every array index is a string). Conversion between strings and numbers is automatic. AWK also has regular expressions, which appear in many AWK programs. There are a few built-in functions, like cos() and sprintf(). -* ''Find average line length.''$ awk '{ cnt += length($0) } END { print cnt / NR }' /etc/rc +* ''Find average line length.''$ awk '{ cnt += length($0) } END { print cnt / NR }' /etc/rc The name "AWK" comes from the initials of Alfred Aho, Peter Weinberger and Brian Kernighan: they invented AWK during the 1970s. A few decades later, Kernighan continues to maintain the [[nawk|reference implementation]] of AWK. @@ -26,7 +26,7 @@ A few decades later, Kernighan continues to maintain the [[nawk|reference implem *[http://awk.info AWK Community Portal] ==Online-Execution== -* [https://ideone.com ideone.com] - gawk, mawk (both are kept up to date) +* [http://ideone.com ideone.com] - gawk, mawk (both are kept up to date) ==Todo== -[[Tasks_not_implemented_in_AWK]] \ No newline at end of file +[[Reports:Tasks_not_implemented_in_AWK]] \ No newline at end of file diff --git a/Lang/AWK/100-doors b/Lang/AWK/100-doors new file mode 120000 index 0000000000..99c9a19f16 --- /dev/null +++ b/Lang/AWK/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/AWK \ No newline at end of file diff --git a/Lang/AWK/Arithmetic-derivative b/Lang/AWK/Arithmetic-derivative deleted file mode 120000 index 5f269aa501..0000000000 --- a/Lang/AWK/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/AWK \ No newline at end of file diff --git a/Lang/AWK/Bell-numbers b/Lang/AWK/Bell-numbers deleted file mode 120000 index ba62e9e87d..0000000000 --- a/Lang/AWK/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Bioinformatics-base-count b/Lang/AWK/Bioinformatics-base-count new file mode 120000 index 0000000000..0d26eb27e1 --- /dev/null +++ b/Lang/AWK/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/AWK \ No newline at end of file diff --git a/Lang/AWK/Blum-integer b/Lang/AWK/Blum-integer deleted file mode 120000 index 3a37b18d0c..0000000000 --- a/Lang/AWK/Blum-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Blum-integer/AWK \ No newline at end of file diff --git a/Lang/AWK/Brilliant-numbers b/Lang/AWK/Brilliant-numbers deleted file mode 120000 index 75aada11ac..0000000000 --- a/Lang/AWK/Brilliant-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brilliant-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Cuban-primes b/Lang/AWK/Cuban-primes deleted file mode 120000 index e24a72c78b..0000000000 --- a/Lang/AWK/Cuban-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cuban-primes/AWK \ No newline at end of file diff --git a/Lang/AWK/Deceptive-numbers b/Lang/AWK/Deceptive-numbers deleted file mode 120000 index 8f879c57e0..0000000000 --- a/Lang/AWK/Deceptive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deceptive-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Documentation b/Lang/AWK/Documentation deleted file mode 120000 index 203588c43d..0000000000 --- a/Lang/AWK/Documentation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Documentation/AWK \ No newline at end of file diff --git a/Lang/AWK/Egyptian-division b/Lang/AWK/Egyptian-division deleted file mode 120000 index b3edb7cd3b..0000000000 --- a/Lang/AWK/Egyptian-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Egyptian-division/AWK \ No newline at end of file diff --git a/Lang/AWK/Equal-prime-and-composite-sums b/Lang/AWK/Equal-prime-and-composite-sums deleted file mode 120000 index ff748db68b..0000000000 --- a/Lang/AWK/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/AWK \ No newline at end of file diff --git a/Lang/AWK/Eulers-constant-0.5772... b/Lang/AWK/Eulers-constant-0.5772... deleted file mode 120000 index f2365557d6..0000000000 --- a/Lang/AWK/Eulers-constant-0.5772... +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-constant-0.5772.../AWK \ No newline at end of file diff --git a/Lang/AWK/Factorial-primes b/Lang/AWK/Factorial-primes deleted file mode 120000 index 7344ad75fd..0000000000 --- a/Lang/AWK/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/AWK \ No newline at end of file diff --git a/Lang/AWK/Interactive-programming-repl- b/Lang/AWK/Interactive-programming-repl- deleted file mode 120000 index 958761b6b1..0000000000 --- a/Lang/AWK/Interactive-programming-repl- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Interactive-programming-repl-/AWK \ No newline at end of file diff --git a/Lang/AWK/Isqrt-integer-square-root-of-X b/Lang/AWK/Isqrt-integer-square-root-of-X deleted file mode 120000 index 04e9a1d13c..0000000000 --- a/Lang/AWK/Isqrt-integer-square-root-of-X +++ /dev/null @@ -1 +0,0 @@ -../../Task/Isqrt-integer-square-root-of-X/AWK \ No newline at end of file diff --git a/Lang/AWK/MAC-vendor-lookup b/Lang/AWK/MAC-vendor-lookup deleted file mode 120000 index 3bffc2dd1c..0000000000 --- a/Lang/AWK/MAC-vendor-lookup +++ /dev/null @@ -1 +0,0 @@ -../../Task/MAC-vendor-lookup/AWK \ No newline at end of file diff --git a/Lang/AWK/Own-digits-power-sum b/Lang/AWK/Own-digits-power-sum deleted file mode 120000 index f78f510ce9..0000000000 --- a/Lang/AWK/Own-digits-power-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Own-digits-power-sum/AWK \ No newline at end of file diff --git a/Lang/AWK/Padovan-n-step-number-sequences b/Lang/AWK/Padovan-n-step-number-sequences deleted file mode 120000 index 6bc3dbde1f..0000000000 --- a/Lang/AWK/Padovan-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Padovan-n-step-number-sequences/AWK \ No newline at end of file diff --git a/Lang/AWK/Pierpont-primes b/Lang/AWK/Pierpont-primes deleted file mode 120000 index f41d86837f..0000000000 --- a/Lang/AWK/Pierpont-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pierpont-primes/AWK \ No newline at end of file diff --git a/Lang/AWK/Scope-modifiers b/Lang/AWK/Scope-modifiers deleted file mode 120000 index 635bec03ae..0000000000 --- a/Lang/AWK/Scope-modifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Scope-modifiers/AWK \ No newline at end of file diff --git a/Lang/AWK/Search-a-list-of-records b/Lang/AWK/Search-a-list-of-records deleted file mode 120000 index 6172b78f81..0000000000 --- a/Lang/AWK/Search-a-list-of-records +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list-of-records/AWK \ No newline at end of file diff --git a/Lang/AWK/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/AWK/Selectively-replace-multiple-instances-of-a-character-within-a-string deleted file mode 120000 index 248fe6e3f2..0000000000 --- a/Lang/AWK/Selectively-replace-multiple-instances-of-a-character-within-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/AWK \ No newline at end of file diff --git a/Lang/AWK/Sequence-of-primorial-primes b/Lang/AWK/Sequence-of-primorial-primes deleted file mode 120000 index 0448804b7b..0000000000 --- a/Lang/AWK/Sequence-of-primorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-primorial-primes/AWK \ No newline at end of file diff --git a/Lang/AWK/Soloways-recurring-rainfall b/Lang/AWK/Soloways-recurring-rainfall deleted file mode 120000 index 1f850c19b0..0000000000 --- a/Lang/AWK/Soloways-recurring-rainfall +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soloways-recurring-rainfall/AWK \ No newline at end of file diff --git a/Lang/AWK/Textonyms b/Lang/AWK/Textonyms deleted file mode 120000 index 0d5f8babd1..0000000000 --- a/Lang/AWK/Textonyms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Textonyms/AWK \ No newline at end of file diff --git a/Lang/AWK/Time-a-function b/Lang/AWK/Time-a-function deleted file mode 120000 index d78f55d9f9..0000000000 --- a/Lang/AWK/Time-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Time-a-function/AWK \ No newline at end of file diff --git a/Lang/AWK/Vampire-number b/Lang/AWK/Vampire-number deleted file mode 120000 index 3b7709e53a..0000000000 --- a/Lang/AWK/Vampire-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vampire-number/AWK \ No newline at end of file diff --git a/Lang/AWK/Wagstaff-primes b/Lang/AWK/Wagstaff-primes deleted file mode 120000 index 955871e83e..0000000000 --- a/Lang/AWK/Wagstaff-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wagstaff-primes/AWK \ No newline at end of file diff --git a/Lang/AWK/Wilson-primes-of-order-n b/Lang/AWK/Wilson-primes-of-order-n deleted file mode 120000 index 840b045a17..0000000000 --- a/Lang/AWK/Wilson-primes-of-order-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wilson-primes-of-order-n/AWK \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/00-LANG.txt b/Lang/Acornsoft-Lisp/00-LANG.txt deleted file mode 100644 index 6f33c84882..0000000000 --- a/Lang/Acornsoft-Lisp/00-LANG.txt +++ /dev/null @@ -1,19 +0,0 @@ -{{language|Acornsoft Lisp -|exec=interpreted -|parampass=value -|safety=safe -|checking=dynamic -|gc=yes}} -{{language programming paradigm|functional}} -{{language programming paradigm|procedural}} -{{implementation|Lisp}} - -'''Acornsoft Lisp''' is a dialect and implementation of [[derived from::Lisp]] developed in the early 1980s for the [[wp:BBC_Micro|BBC Micro]] and related machines. - -In the original, 1980s version, all built-in defined names were in upper case; however, versions that use lower case instead have become available. - -It is a very small Lisp. The only data types are lists, symbols, 16-bit integers, and the types that represent built-in functions and special forms. Even basic list-processing functions such as length, append, reverse, and equal are not built in. It can nonetheless be used to write interesting programs. - -==References== -* Arthur Norman and Gillian Cattell, ''LISP on the BBC Microcomputer'' -* [[wp:Acornsoft_LISP|Wikipedia:Acornsoft Lisp]] \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/00-META.yaml b/Lang/Acornsoft-Lisp/00-META.yaml deleted file mode 100644 index 4112cf5a63..0000000000 --- a/Lang/Acornsoft-Lisp/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Acornsoft_Lisp diff --git a/Lang/Acornsoft-Lisp/Ackermann-function b/Lang/Acornsoft-Lisp/Ackermann-function deleted file mode 120000 index 7bcda763dc..0000000000 --- a/Lang/Acornsoft-Lisp/Ackermann-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ackermann-function/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Church-numerals b/Lang/Acornsoft-Lisp/Church-numerals deleted file mode 120000 index 0a130ebdda..0000000000 --- a/Lang/Acornsoft-Lisp/Church-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Church-numerals/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Closures-Value-capture b/Lang/Acornsoft-Lisp/Closures-Value-capture deleted file mode 120000 index f04f5686b2..0000000000 --- a/Lang/Acornsoft-Lisp/Closures-Value-capture +++ /dev/null @@ -1 +0,0 @@ -../../Task/Closures-Value-capture/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Combinations b/Lang/Acornsoft-Lisp/Combinations deleted file mode 120000 index e9cb9f1dde..0000000000 --- a/Lang/Acornsoft-Lisp/Combinations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Combinations-with-repetitions b/Lang/Acornsoft-Lisp/Combinations-with-repetitions deleted file mode 120000 index 70f131d0f0..0000000000 --- a/Lang/Acornsoft-Lisp/Combinations-with-repetitions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations-with-repetitions/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Comma-quibbling b/Lang/Acornsoft-Lisp/Comma-quibbling deleted file mode 120000 index ffef14cd4d..0000000000 --- a/Lang/Acornsoft-Lisp/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Factorial b/Lang/Acornsoft-Lisp/Factorial deleted file mode 120000 index 550aae0490..0000000000 --- a/Lang/Acornsoft-Lisp/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Hello-world-Text b/Lang/Acornsoft-Lisp/Hello-world-Text deleted file mode 120000 index 17be1edfa0..0000000000 --- a/Lang/Acornsoft-Lisp/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Ordered-words b/Lang/Acornsoft-Lisp/Ordered-words deleted file mode 120000 index 3bf5154d1c..0000000000 --- a/Lang/Acornsoft-Lisp/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Palindrome-detection b/Lang/Acornsoft-Lisp/Palindrome-detection deleted file mode 120000 index 68d57e371f..0000000000 --- a/Lang/Acornsoft-Lisp/Palindrome-detection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-detection/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Permutations-Derangements b/Lang/Acornsoft-Lisp/Permutations-Derangements deleted file mode 120000 index 04cdd94720..0000000000 --- a/Lang/Acornsoft-Lisp/Permutations-Derangements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-Derangements/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Quine b/Lang/Acornsoft-Lisp/Quine deleted file mode 120000 index effed68d44..0000000000 --- a/Lang/Acornsoft-Lisp/Quine +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quine/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Search-a-list b/Lang/Acornsoft-Lisp/Search-a-list deleted file mode 120000 index 80011d9a5b..0000000000 --- a/Lang/Acornsoft-Lisp/Search-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Acornsoft-Lisp/Set-puzzle b/Lang/Acornsoft-Lisp/Set-puzzle deleted file mode 120000 index 8de80cf599..0000000000 --- a/Lang/Acornsoft-Lisp/Set-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-puzzle/Acornsoft-Lisp \ No newline at end of file diff --git a/Lang/Action-/00-LANG.txt b/Lang/Action-/00-LANG.txt index 3811c3c636..b37eb47c8f 100644 --- a/Lang/Action-/00-LANG.txt +++ b/Lang/Action-/00-LANG.txt @@ -4,7 +4,7 @@ }} Action! is a language written by Clinton Parker and published by Optimized Sytems Software (OSS) for the Atari 8-bit line of home computers. It is related to ALGOL and optimized for single-pass compilation to 6502 code. -A manual for the language is available at https://seriouscomputerist.atariverse.com/media/pdf/manual/OSS%20OS-A+%20-%20Manual%20(1983).pdf + ==See Also== * [[wp:Action!_(programming_language)|Action! on Wikipedia]] * [[ALGOL 68]] diff --git a/Lang/Action-/Arithmetic-derivative b/Lang/Action-/Arithmetic-derivative deleted file mode 120000 index 8206b6a192..0000000000 --- a/Lang/Action-/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Action- \ No newline at end of file diff --git a/Lang/Action-/Bioinformatics-base-count b/Lang/Action-/Bioinformatics-base-count new file mode 120000 index 0000000000..2a7e093367 --- /dev/null +++ b/Lang/Action-/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/Action- \ No newline at end of file diff --git a/Lang/Action-/Quaternion-type b/Lang/Action-/Quaternion-type new file mode 120000 index 0000000000..0cfb07db30 --- /dev/null +++ b/Lang/Action-/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Action- \ No newline at end of file diff --git a/Lang/Action-/Sorting-Algorithms-Circle-Sort b/Lang/Action-/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..a9db72f0ce --- /dev/null +++ b/Lang/Action-/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/Action- \ No newline at end of file diff --git a/Lang/ActionScript/00-LANG.txt b/Lang/ActionScript/00-LANG.txt index 4fe99ed760..14a7dc41bf 100644 --- a/Lang/ActionScript/00-LANG.txt +++ b/Lang/ActionScript/00-LANG.txt @@ -4,8 +4,7 @@ |strength=strong |safety=safe |checking=static -|LCT=yes -|tags=actionscript, as}} +|LCT=yes}} {{Language programming paradigm|Distributed}} {{Language programming paradigm|Imperative}} diff --git a/Lang/Ada/00-LANG.txt b/Lang/Ada/00-LANG.txt index e9eb8d687d..85a16e96c0 100644 --- a/Lang/Ada/00-LANG.txt +++ b/Lang/Ada/00-LANG.txt @@ -8,7 +8,7 @@ |strength=strong |safety=safe |LCT=yes -|bnf=http://www.ada-auth.org/standards/22rm/html/RM-P-1.html}}'''Ada''' is a structured, statically typed [[imperative programming|imperative]] computer programming language. Ada was initially standardized by [[ANSI]] in 1983 and by [[ISO]] in 1987. This version of the language is commonly known as [[Ada 83]]. The next version was standardized by ISO in 1995 (ISO/IEC 8652:1995) and is commonly known as [[Ada 95]]. Following that ISO published ISO/IEC 8652:1995/Amd 1:2007 in 2007, which is commonly known as [[Ada 2005]]. Afterwards they published ISO/IEC 8652:2012(E), also known as [[Ada 2012]]. Most recently ISO published [http://www.ada-auth.org/standards/22rm/html/RM-TTL.html ISO/IEC 8652:2023], commonly known as [[Ada 2022]]. Formally only the most recent version of the language is known as '''Ada'''. +|bnf=http://www.adaic.org/standards/1zrm/html/RM-P.html}}'''Ada''' is a structured, statically typed [[imperative programming|imperative]] computer programming language. Ada was initially standardized by [[ANSI]] in 1983 and by [[ISO]] in 1987. This version of the language is commonly known as [[Ada 83]]. The next version was standardized by ISO in 1995 (ISO/IEC 8652:1995) and is commonly known as [[Ada 95]]. Following that ISO published ISO/IEC 8652:1995/Amd 1:2007 in 2007, which is commonly known as [[Ada 2005]]. Most recently ISO published [http://www.ada-auth.org/standards/12rm/html/RM-TTL.html ISO/IEC 8652:2012(E)], commonly known as [[Ada 2012]]. Formally only the most recent version of the language is known as '''Ada'''. The language is named after [[wp:Ada_Lovelace|Augusta Ada King, Countess of Lovelace]] thought to be the first ever programmer. Initially it was designed for [http://www.defense.gov U.S. Department of Defense]. The language is used for large and mission-critical systems. See [[wp:Ada_(programming_language)|also]]. ==Grammar== @@ -17,6 +17,4 @@ The language is named after [[wp:Ada_Lovelace|Augusta Ada King, Countess of Love {{Language programming paradigm|Distributed}} {{Language programming paradigm|Generic}} {{Language programming paradigm|Imperative}} -{{Language programming paradigm|Object-oriented}} -==Todo== -* [[Tasks not implemented in Ada]] \ No newline at end of file +{{Language programming paradigm|Object-oriented}} \ No newline at end of file diff --git a/Lang/Ada/24-game-Solve b/Lang/Ada/24-game-Solve deleted file mode 120000 index 245a9225c6..0000000000 --- a/Lang/Ada/24-game-Solve +++ /dev/null @@ -1 +0,0 @@ -../../Task/24-game-Solve/Ada \ No newline at end of file diff --git a/Lang/Ada/Abelian-sandpile-model b/Lang/Ada/Abelian-sandpile-model deleted file mode 120000 index adfb5aa625..0000000000 --- a/Lang/Ada/Abelian-sandpile-model +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model/Ada \ No newline at end of file diff --git a/Lang/Ada/Achilles-numbers b/Lang/Ada/Achilles-numbers deleted file mode 120000 index 8a02102d36..0000000000 --- a/Lang/Ada/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Almkvist-Giullera-formula-for-pi b/Lang/Ada/Almkvist-Giullera-formula-for-pi deleted file mode 120000 index 66015473cd..0000000000 --- a/Lang/Ada/Almkvist-Giullera-formula-for-pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Almkvist-Giullera-formula-for-pi/Ada \ No newline at end of file diff --git a/Lang/Ada/Angles-geometric-normalization-and-conversion b/Lang/Ada/Angles-geometric-normalization-and-conversion deleted file mode 120000 index d4d2487c81..0000000000 --- a/Lang/Ada/Angles-geometric-normalization-and-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angles-geometric-normalization-and-conversion/Ada \ No newline at end of file diff --git a/Lang/Ada/Arithmetic-derivative b/Lang/Ada/Arithmetic-derivative deleted file mode 120000 index 87dd4d6940..0000000000 --- a/Lang/Ada/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Ada \ No newline at end of file diff --git a/Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi b/Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi deleted file mode 120000 index 14bdbe4c3d..0000000000 --- a/Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean-Calculate-Pi/Ada \ No newline at end of file diff --git a/Lang/Ada/Ascending-primes b/Lang/Ada/Ascending-primes deleted file mode 120000 index cee2b86585..0000000000 --- a/Lang/Ada/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Babylonian-spiral b/Lang/Ada/Babylonian-spiral deleted file mode 120000 index fd4ac4c6ad..0000000000 --- a/Lang/Ada/Babylonian-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babylonian-spiral/Ada \ No newline at end of file diff --git a/Lang/Ada/Bioinformatics-base-count b/Lang/Ada/Bioinformatics-base-count new file mode 120000 index 0000000000..59c9c9dde5 --- /dev/null +++ b/Lang/Ada/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/Ada \ No newline at end of file diff --git a/Lang/Ada/Biorhythms b/Lang/Ada/Biorhythms deleted file mode 120000 index 0d82777906..0000000000 --- a/Lang/Ada/Biorhythms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Biorhythms/Ada \ No newline at end of file diff --git a/Lang/Ada/Blum-integer b/Lang/Ada/Blum-integer deleted file mode 120000 index 48b2715109..0000000000 --- a/Lang/Ada/Blum-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Blum-integer/Ada \ No newline at end of file diff --git a/Lang/Ada/Boyer-Moore-string-search b/Lang/Ada/Boyer-Moore-string-search deleted file mode 120000 index 114c2a5fea..0000000000 --- a/Lang/Ada/Boyer-Moore-string-search +++ /dev/null @@ -1 +0,0 @@ -../../Task/Boyer-Moore-string-search/Ada \ No newline at end of file diff --git a/Lang/Ada/Brace-expansion b/Lang/Ada/Brace-expansion deleted file mode 120000 index b881365fa7..0000000000 --- a/Lang/Ada/Brace-expansion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brace-expansion/Ada \ No newline at end of file diff --git a/Lang/Ada/Brilliant-numbers b/Lang/Ada/Brilliant-numbers deleted file mode 120000 index 80af4238ae..0000000000 --- a/Lang/Ada/Brilliant-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brilliant-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Calkin-Wilf-sequence b/Lang/Ada/Calkin-Wilf-sequence deleted file mode 120000 index 9e4b8cd779..0000000000 --- a/Lang/Ada/Calkin-Wilf-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calkin-Wilf-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Camel-case-and-snake-case b/Lang/Ada/Camel-case-and-snake-case deleted file mode 120000 index 1d95b38233..0000000000 --- a/Lang/Ada/Camel-case-and-snake-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/Camel-case-and-snake-case/Ada \ No newline at end of file diff --git a/Lang/Ada/Canonicalize-CIDR b/Lang/Ada/Canonicalize-CIDR deleted file mode 120000 index c0c0b338b8..0000000000 --- a/Lang/Ada/Canonicalize-CIDR +++ /dev/null @@ -1 +0,0 @@ -../../Task/Canonicalize-CIDR/Ada \ No newline at end of file diff --git a/Lang/Ada/Chaos-game b/Lang/Ada/Chaos-game deleted file mode 120000 index 456fd72f97..0000000000 --- a/Lang/Ada/Chaos-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaos-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Cistercian-numerals b/Lang/Ada/Cistercian-numerals deleted file mode 120000 index a03109c188..0000000000 --- a/Lang/Ada/Cistercian-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cistercian-numerals/Ada \ No newline at end of file diff --git a/Lang/Ada/Color-wheel b/Lang/Ada/Color-wheel deleted file mode 120000 index 3d78384078..0000000000 --- a/Lang/Ada/Color-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Color-wheel/Ada \ No newline at end of file diff --git a/Lang/Ada/Combinations-and-permutations b/Lang/Ada/Combinations-and-permutations deleted file mode 120000 index 3f163f203e..0000000000 --- a/Lang/Ada/Combinations-and-permutations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations-and-permutations/Ada \ No newline at end of file diff --git a/Lang/Ada/Cuban-primes b/Lang/Ada/Cuban-primes deleted file mode 120000 index a7270c8ac4..0000000000 --- a/Lang/Ada/Cuban-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cuban-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Curzon-numbers b/Lang/Ada/Curzon-numbers deleted file mode 120000 index 4a77e1da8a..0000000000 --- a/Lang/Ada/Curzon-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Curzon-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Deepcopy b/Lang/Ada/Deepcopy deleted file mode 120000 index 4b1e30735d..0000000000 --- a/Lang/Ada/Deepcopy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deepcopy/Ada \ No newline at end of file diff --git a/Lang/Ada/Descending-primes b/Lang/Ada/Descending-primes deleted file mode 120000 index 3c6c36447c..0000000000 --- a/Lang/Ada/Descending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Descending-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Determine-sentence-type b/Lang/Ada/Determine-sentence-type deleted file mode 120000 index df39412f47..0000000000 --- a/Lang/Ada/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/Ada \ No newline at end of file diff --git a/Lang/Ada/Eban-numbers b/Lang/Ada/Eban-numbers deleted file mode 120000 index 8c7c83bfc9..0000000000 --- a/Lang/Ada/Eban-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eban-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Equal-prime-and-composite-sums b/Lang/Ada/Equal-prime-and-composite-sums deleted file mode 120000 index b1a2555466..0000000000 --- a/Lang/Ada/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/Ada \ No newline at end of file diff --git a/Lang/Ada/Eulers-constant-0.5772... b/Lang/Ada/Eulers-constant-0.5772... deleted file mode 120000 index b0e75cb33e..0000000000 --- a/Lang/Ada/Eulers-constant-0.5772... +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-constant-0.5772.../Ada \ No newline at end of file diff --git a/Lang/Ada/FTP b/Lang/Ada/FTP deleted file mode 120000 index 1d406ce7cd..0000000000 --- a/Lang/Ada/FTP +++ /dev/null @@ -1 +0,0 @@ -../../Task/FTP/Ada \ No newline at end of file diff --git a/Lang/Ada/Factorial-primes b/Lang/Ada/Factorial-primes deleted file mode 120000 index fdff310065..0000000000 --- a/Lang/Ada/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Factorions b/Lang/Ada/Factorions deleted file mode 120000 index d9b74415a9..0000000000 --- a/Lang/Ada/Factorions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorions/Ada \ No newline at end of file diff --git a/Lang/Ada/Fermat-numbers b/Lang/Ada/Fermat-numbers deleted file mode 120000 index c9d81fb3a1..0000000000 --- a/Lang/Ada/Fermat-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fermat-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Find-duplicate-files b/Lang/Ada/Find-duplicate-files deleted file mode 120000 index f7ad1ff6fd..0000000000 --- a/Lang/Ada/Find-duplicate-files +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-duplicate-files/Ada \ No newline at end of file diff --git a/Lang/Ada/Fivenum b/Lang/Ada/Fivenum deleted file mode 120000 index 7328eec9c8..0000000000 --- a/Lang/Ada/Fivenum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fivenum/Ada \ No newline at end of file diff --git a/Lang/Ada/Giuga-numbers b/Lang/Ada/Giuga-numbers deleted file mode 120000 index 24ab180f54..0000000000 --- a/Lang/Ada/Giuga-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Giuga-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Harmonic-series b/Lang/Ada/Harmonic-series deleted file mode 120000 index 97492bcb66..0000000000 --- a/Lang/Ada/Harmonic-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harmonic-series/Ada \ No newline at end of file diff --git a/Lang/Ada/Hex-words b/Lang/Ada/Hex-words deleted file mode 120000 index da49cf2b4d..0000000000 --- a/Lang/Ada/Hex-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hex-words/Ada \ No newline at end of file diff --git a/Lang/Ada/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols b/Lang/Ada/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols deleted file mode 120000 index 29e378f3f1..0000000000 --- a/Lang/Ada/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada \ No newline at end of file diff --git a/Lang/Ada/Jacobi-symbol b/Lang/Ada/Jacobi-symbol deleted file mode 120000 index 1c52eec7ce..0000000000 --- a/Lang/Ada/Jacobi-symbol +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobi-symbol/Ada \ No newline at end of file diff --git a/Lang/Ada/Jacobsthal-numbers b/Lang/Ada/Jacobsthal-numbers deleted file mode 120000 index 630504cad4..0000000000 --- a/Lang/Ada/Jacobsthal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobsthal-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Knapsack-problem-Bounded b/Lang/Ada/Knapsack-problem-Bounded deleted file mode 120000 index 1cfbda0d29..0000000000 --- a/Lang/Ada/Knapsack-problem-Bounded +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-Bounded/Ada \ No newline at end of file diff --git a/Lang/Ada/Kosaraju b/Lang/Ada/Kosaraju deleted file mode 120000 index 0b7b72cfb6..0000000000 --- a/Lang/Ada/Kosaraju +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kosaraju/Ada \ No newline at end of file diff --git a/Lang/Ada/Lah-numbers b/Lang/Ada/Lah-numbers deleted file mode 120000 index e4f08d947d..0000000000 --- a/Lang/Ada/Lah-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Lah-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Largest-number-divisible-by-its-digits b/Lang/Ada/Largest-number-divisible-by-its-digits deleted file mode 120000 index d61b3cb8be..0000000000 --- a/Lang/Ada/Largest-number-divisible-by-its-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-number-divisible-by-its-digits/Ada \ No newline at end of file diff --git a/Lang/Ada/Left-factorials b/Lang/Ada/Left-factorials deleted file mode 120000 index 8c62b38a57..0000000000 --- a/Lang/Ada/Left-factorials +++ /dev/null @@ -1 +0,0 @@ -../../Task/Left-factorials/Ada \ No newline at end of file diff --git a/Lang/Ada/Levenshtein-distance-Alignment b/Lang/Ada/Levenshtein-distance-Alignment deleted file mode 120000 index 1c6a7ca906..0000000000 --- a/Lang/Ada/Levenshtein-distance-Alignment +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance-Alignment/Ada \ No newline at end of file diff --git a/Lang/Ada/Long-literals-with-continuations b/Lang/Ada/Long-literals-with-continuations deleted file mode 120000 index 9d6be6cfc8..0000000000 --- a/Lang/Ada/Long-literals-with-continuations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-literals-with-continuations/Ada \ No newline at end of file diff --git a/Lang/Ada/Longest-increasing-subsequence b/Lang/Ada/Longest-increasing-subsequence deleted file mode 120000 index dd360a694d..0000000000 --- a/Lang/Ada/Longest-increasing-subsequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-increasing-subsequence/Ada \ No newline at end of file diff --git a/Lang/Ada/M-bius-function b/Lang/Ada/M-bius-function deleted file mode 120000 index cb59f2e52a..0000000000 --- a/Lang/Ada/M-bius-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/M-bius-function/Ada \ No newline at end of file diff --git a/Lang/Ada/Machine-code b/Lang/Ada/Machine-code deleted file mode 120000 index 52ae4edc91..0000000000 --- a/Lang/Ada/Machine-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Machine-code/Ada \ No newline at end of file diff --git a/Lang/Ada/Magic-constant b/Lang/Ada/Magic-constant deleted file mode 120000 index bd59423b8e..0000000000 --- a/Lang/Ada/Magic-constant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-constant/Ada \ No newline at end of file diff --git a/Lang/Ada/Metallic-ratios b/Lang/Ada/Metallic-ratios deleted file mode 120000 index f41030172b..0000000000 --- a/Lang/Ada/Metallic-ratios +++ /dev/null @@ -1 +0,0 @@ -../../Task/Metallic-ratios/Ada \ No newline at end of file diff --git a/Lang/Ada/Miller-Rabin-primality-test b/Lang/Ada/Miller-Rabin-primality-test new file mode 120000 index 0000000000..79bf6fd437 --- /dev/null +++ b/Lang/Ada/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Ada \ No newline at end of file diff --git a/Lang/Ada/Mind-boggling-card-trick b/Lang/Ada/Mind-boggling-card-trick deleted file mode 120000 index 11ae4366fc..0000000000 --- a/Lang/Ada/Mind-boggling-card-trick +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mind-boggling-card-trick/Ada \ No newline at end of file diff --git a/Lang/Ada/Minimal-steps-down-to-1 b/Lang/Ada/Minimal-steps-down-to-1 deleted file mode 120000 index 44f17e189f..0000000000 --- a/Lang/Ada/Minimal-steps-down-to-1 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minimal-steps-down-to-1/Ada \ No newline at end of file diff --git a/Lang/Ada/Musical-scale b/Lang/Ada/Musical-scale deleted file mode 120000 index a792f4144a..0000000000 --- a/Lang/Ada/Musical-scale +++ /dev/null @@ -1 +0,0 @@ -../../Task/Musical-scale/Ada \ No newline at end of file diff --git a/Lang/Ada/Naming-conventions b/Lang/Ada/Naming-conventions deleted file mode 120000 index 44f00f1ff1..0000000000 --- a/Lang/Ada/Naming-conventions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Naming-conventions/Ada \ No newline at end of file diff --git a/Lang/Ada/Nautical-bell b/Lang/Ada/Nautical-bell deleted file mode 120000 index 61069c35a0..0000000000 --- a/Lang/Ada/Nautical-bell +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nautical-bell/Ada \ No newline at end of file diff --git a/Lang/Ada/Next-highest-int-from-digits b/Lang/Ada/Next-highest-int-from-digits deleted file mode 120000 index e996a777e6..0000000000 --- a/Lang/Ada/Next-highest-int-from-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Next-highest-int-from-digits/Ada \ No newline at end of file diff --git a/Lang/Ada/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors b/Lang/Ada/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors deleted file mode 120000 index 58dcaaaaee..0000000000 --- a/Lang/Ada/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors/Ada \ No newline at end of file diff --git a/Lang/Ada/Old-Russian-measure-of-length b/Lang/Ada/Old-Russian-measure-of-length deleted file mode 120000 index 1d4422be24..0000000000 --- a/Lang/Ada/Old-Russian-measure-of-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Old-Russian-measure-of-length/Ada \ No newline at end of file diff --git a/Lang/Ada/Penneys-game b/Lang/Ada/Penneys-game deleted file mode 120000 index 00a5e1d496..0000000000 --- a/Lang/Ada/Penneys-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Penneys-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Permutations-by-swapping b/Lang/Ada/Permutations-by-swapping deleted file mode 120000 index 9140cf7f43..0000000000 --- a/Lang/Ada/Permutations-by-swapping +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-by-swapping/Ada \ No newline at end of file diff --git a/Lang/Ada/Play-recorded-sounds b/Lang/Ada/Play-recorded-sounds deleted file mode 120000 index 2365ca211b..0000000000 --- a/Lang/Ada/Play-recorded-sounds +++ /dev/null @@ -1 +0,0 @@ -../../Task/Play-recorded-sounds/Ada \ No newline at end of file diff --git a/Lang/Ada/Poker-hand-analyser b/Lang/Ada/Poker-hand-analyser deleted file mode 120000 index fc5a66b995..0000000000 --- a/Lang/Ada/Poker-hand-analyser +++ /dev/null @@ -1 +0,0 @@ -../../Task/Poker-hand-analyser/Ada \ No newline at end of file diff --git a/Lang/Ada/Prime-conspiracy b/Lang/Ada/Prime-conspiracy deleted file mode 120000 index 49f0dd3152..0000000000 --- a/Lang/Ada/Prime-conspiracy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-conspiracy/Ada \ No newline at end of file diff --git a/Lang/Ada/Quaternion-type b/Lang/Ada/Quaternion-type new file mode 120000 index 0000000000..9dc0eab94d --- /dev/null +++ b/Lang/Ada/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Ada \ No newline at end of file diff --git a/Lang/Ada/Random-sentence-from-book b/Lang/Ada/Random-sentence-from-book deleted file mode 120000 index f08e942e14..0000000000 --- a/Lang/Ada/Random-sentence-from-book +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-sentence-from-book/Ada \ No newline at end of file diff --git a/Lang/Ada/Read-a-file-character-by-character-UTF8 b/Lang/Ada/Read-a-file-character-by-character-UTF8 deleted file mode 120000 index 71f788273b..0000000000 --- a/Lang/Ada/Read-a-file-character-by-character-UTF8 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-file-character-by-character-UTF8/Ada \ No newline at end of file diff --git a/Lang/Ada/Record-sound b/Lang/Ada/Record-sound deleted file mode 120000 index af45b7783f..0000000000 --- a/Lang/Ada/Record-sound +++ /dev/null @@ -1 +0,0 @@ -../../Task/Record-sound/Ada \ No newline at end of file diff --git a/Lang/Ada/Safe-primes-and-unsafe-primes b/Lang/Ada/Safe-primes-and-unsafe-primes deleted file mode 120000 index 97b204f4de..0000000000 --- a/Lang/Ada/Safe-primes-and-unsafe-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Safe-primes-and-unsafe-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string deleted file mode 120000 index 5077dd9033..0000000000 --- a/Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Sexy-primes b/Lang/Ada/Sexy-primes deleted file mode 120000 index ec070f062f..0000000000 --- a/Lang/Ada/Sexy-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sexy-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Sierpinski-pentagon b/Lang/Ada/Sierpinski-pentagon deleted file mode 120000 index d3c2f495a7..0000000000 --- a/Lang/Ada/Sierpinski-pentagon +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-pentagon/Ada \ No newline at end of file diff --git a/Lang/Ada/Sierpinski-square-curve b/Lang/Ada/Sierpinski-square-curve deleted file mode 120000 index 32cee5f712..0000000000 --- a/Lang/Ada/Sierpinski-square-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-square-curve/Ada \ No newline at end of file diff --git a/Lang/Ada/Sierpinski-triangle-Graphical b/Lang/Ada/Sierpinski-triangle-Graphical deleted file mode 120000 index c5fb35984b..0000000000 --- a/Lang/Ada/Sierpinski-triangle-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-triangle-Graphical/Ada \ No newline at end of file diff --git a/Lang/Ada/Sleeping-Beauty-problem b/Lang/Ada/Sleeping-Beauty-problem deleted file mode 120000 index 1c2ef27d37..0000000000 --- a/Lang/Ada/Sleeping-Beauty-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleeping-Beauty-problem/Ada \ No newline at end of file diff --git a/Lang/Ada/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k b/Lang/Ada/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k deleted file mode 120000 index acb5a83713..0000000000 --- a/Lang/Ada/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k/Ada \ No newline at end of file diff --git a/Lang/Ada/Sorting-algorithms-Cocktail-sort-with-shifting-bounds b/Lang/Ada/Sorting-algorithms-Cocktail-sort-with-shifting-bounds deleted file mode 120000 index 484d3d768d..0000000000 --- a/Lang/Ada/Sorting-algorithms-Cocktail-sort-with-shifting-bounds +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Cocktail-sort-with-shifting-bounds/Ada \ No newline at end of file diff --git a/Lang/Ada/Sorting-algorithms-Permutation-sort b/Lang/Ada/Sorting-algorithms-Permutation-sort deleted file mode 120000 index 0f333c5ec8..0000000000 --- a/Lang/Ada/Sorting-algorithms-Permutation-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Permutation-sort/Ada \ No newline at end of file diff --git a/Lang/Ada/Test-integerness b/Lang/Ada/Test-integerness deleted file mode 120000 index 8a5462dcb5..0000000000 --- a/Lang/Ada/Test-integerness +++ /dev/null @@ -1 +0,0 @@ -../../Task/Test-integerness/Ada \ No newline at end of file diff --git a/Lang/Ada/Total-circles-area b/Lang/Ada/Total-circles-area deleted file mode 120000 index 781e585826..0000000000 --- a/Lang/Ada/Total-circles-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Total-circles-area/Ada \ No newline at end of file diff --git a/Lang/Ada/Twin-primes b/Lang/Ada/Twin-primes deleted file mode 120000 index f368573f47..0000000000 --- a/Lang/Ada/Twin-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twin-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Twos-complement b/Lang/Ada/Twos-complement deleted file mode 120000 index 396d1a76f2..0000000000 --- a/Lang/Ada/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/Ada \ No newline at end of file diff --git a/Lang/Ada/UPC b/Lang/Ada/UPC deleted file mode 120000 index 374da7b0aa..0000000000 --- a/Lang/Ada/UPC +++ /dev/null @@ -1 +0,0 @@ -../../Task/UPC/Ada \ No newline at end of file diff --git a/Lang/Ada/Ultra-useful-primes b/Lang/Ada/Ultra-useful-primes deleted file mode 120000 index c89f1426c4..0000000000 --- a/Lang/Ada/Ultra-useful-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ultra-useful-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Vector b/Lang/Ada/Vector deleted file mode 120000 index 4cc7975e2f..0000000000 --- a/Lang/Ada/Vector +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vector/Ada \ No newline at end of file diff --git a/Lang/Ada/Wagstaff-primes b/Lang/Ada/Wagstaff-primes deleted file mode 120000 index 3b705137b1..0000000000 --- a/Lang/Ada/Wagstaff-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wagstaff-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/War-card-game b/Lang/Ada/War-card-game deleted file mode 120000 index dd4f92afee..0000000000 --- a/Lang/Ada/War-card-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/War-card-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Weird-numbers b/Lang/Ada/Weird-numbers deleted file mode 120000 index 98491ade1a..0000000000 --- a/Lang/Ada/Weird-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Weird-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Wilson-primes-of-order-n b/Lang/Ada/Wilson-primes-of-order-n deleted file mode 120000 index 95a6ebc6d1..0000000000 --- a/Lang/Ada/Wilson-primes-of-order-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wilson-primes-of-order-n/Ada \ No newline at end of file diff --git a/Lang/Ada/Word-ladder b/Lang/Ada/Word-ladder deleted file mode 120000 index 495c24dbcd..0000000000 --- a/Lang/Ada/Word-ladder +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-ladder/Ada \ No newline at end of file diff --git a/Lang/Ada/Word-search b/Lang/Ada/Word-search deleted file mode 120000 index 32f00f4762..0000000000 --- a/Lang/Ada/Word-search +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-search/Ada \ No newline at end of file diff --git a/Lang/Ada/Word-wheel b/Lang/Ada/Word-wheel deleted file mode 120000 index 47f67698e0..0000000000 --- a/Lang/Ada/Word-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-wheel/Ada \ No newline at end of file diff --git a/Lang/Adina/00-LANG.txt b/Lang/Adina/00-LANG.txt deleted file mode 100644 index e796807867..0000000000 --- a/Lang/Adina/00-LANG.txt +++ /dev/null @@ -1,13 +0,0 @@ -{{language|Adina}} -Adina is a programming language, based on Racket and russian language. Unlike Racket it uses indent and operators precedence to describe program syntax. It may be used in english, because all Racket libraries are accessible. One should add "english()" in first string to use standard racket libraries. - -Адина, это язык программирования, основанный на Racket и русском языке. В отличие от Racket вместо скобок для синтаксической -структуры используются отступы и бинарные операторы. Также сделан доступ через квадратные скобки к элементам коллекции и через фигурные к методам объектов. - -Документация по адресу: https://docs.racket-lang.org/russian-lang/ - -==See Also== -* [[Racket]] - -==TODO== -[[Tasks not implemented in Adina]] \ No newline at end of file diff --git a/Lang/Adina/00-META.yaml b/Lang/Adina/00-META.yaml deleted file mode 100644 index e1ca8650ca..0000000000 --- a/Lang/Adina/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Adina diff --git a/Lang/Adina/100-doors b/Lang/Adina/100-doors deleted file mode 120000 index c96d2d65fc..0000000000 --- a/Lang/Adina/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/Adina \ No newline at end of file diff --git a/Lang/Adina/Even-or-odd b/Lang/Adina/Even-or-odd deleted file mode 120000 index 1718b42d76..0000000000 --- a/Lang/Adina/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/Adina \ No newline at end of file diff --git a/Lang/Adina/Hello-world-Text b/Lang/Adina/Hello-world-Text deleted file mode 120000 index f886a7cc4f..0000000000 --- a/Lang/Adina/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Adina \ No newline at end of file diff --git a/Lang/Adina/Loops-For b/Lang/Adina/Loops-For deleted file mode 120000 index c4d6bee093..0000000000 --- a/Lang/Adina/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Adina \ No newline at end of file diff --git a/Lang/Adina/Tree-traversal b/Lang/Adina/Tree-traversal deleted file mode 120000 index fd3896d623..0000000000 --- a/Lang/Adina/Tree-traversal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tree-traversal/Adina \ No newline at end of file diff --git a/Lang/Agena/00-LANG.txt b/Lang/Agena/00-LANG.txt index 5398f01156..c2930ac7a2 100644 --- a/Lang/Agena/00-LANG.txt +++ b/Lang/Agena/00-LANG.txt @@ -20,10 +20,5 @@ The syntax looks like very simplified [[ALGOL 68]] with elements taken from [[Lu == How has it been implemented ? == Agena is based on the [[ANSI]] [[C]] source code of [[Lua]], a popular and widely used Open Source programming language. -== Todo == -[[Tasks not implemented in Agena]] - == See Also == -[[ALGOL 68]]
-[[Lua]]
-[[SQL]] \ No newline at end of file +[[ALGOL 68]] \ No newline at end of file diff --git a/Lang/Agena/100-doors b/Lang/Agena/100-doors new file mode 120000 index 0000000000..3a9139bb1c --- /dev/null +++ b/Lang/Agena/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Agena \ No newline at end of file diff --git a/Lang/Agena/AKS-test-for-primes b/Lang/Agena/AKS-test-for-primes deleted file mode 120000 index ab27a842c8..0000000000 --- a/Lang/Agena/AKS-test-for-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/AKS-test-for-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Abundant-deficient-and-perfect-number-classifications b/Lang/Agena/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index 89450cb83c..0000000000 --- a/Lang/Agena/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/Agena \ No newline at end of file diff --git a/Lang/Agena/Abundant-odd-numbers b/Lang/Agena/Abundant-odd-numbers deleted file mode 120000 index a18ccbb662..0000000000 --- a/Lang/Agena/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Ackermann-function b/Lang/Agena/Ackermann-function deleted file mode 120000 index fb262b01a7..0000000000 --- a/Lang/Agena/Ackermann-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ackermann-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Almost-prime b/Lang/Agena/Almost-prime deleted file mode 120000 index 62b34f9616..0000000000 --- a/Lang/Agena/Almost-prime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Almost-prime/Agena \ No newline at end of file diff --git a/Lang/Agena/Angle-difference-between-two-bearings b/Lang/Agena/Angle-difference-between-two-bearings deleted file mode 120000 index 62a719bb70..0000000000 --- a/Lang/Agena/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/Agena \ No newline at end of file diff --git a/Lang/Agena/Anti-primes b/Lang/Agena/Anti-primes deleted file mode 120000 index f98d65a6cf..0000000000 --- a/Lang/Agena/Anti-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anti-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Arbitrary-precision-integers-included- b/Lang/Agena/Arbitrary-precision-integers-included- deleted file mode 120000 index 347104998a..0000000000 --- a/Lang/Agena/Arbitrary-precision-integers-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included-/Agena \ No newline at end of file diff --git a/Lang/Agena/Ascending-primes b/Lang/Agena/Ascending-primes deleted file mode 120000 index 9c8c50d2ae..0000000000 --- a/Lang/Agena/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Associative-array-Iteration b/Lang/Agena/Associative-array-Iteration deleted file mode 120000 index 55b1a0c7a6..0000000000 --- a/Lang/Agena/Associative-array-Iteration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Iteration/Agena \ No newline at end of file diff --git a/Lang/Agena/Attractive-numbers b/Lang/Agena/Attractive-numbers deleted file mode 120000 index bc968b5d21..0000000000 --- a/Lang/Agena/Attractive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Attractive-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Brazilian-numbers b/Lang/Agena/Brazilian-numbers deleted file mode 120000 index 7312d4ef84..0000000000 --- a/Lang/Agena/Brazilian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brazilian-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Calkin-Wilf-sequence b/Lang/Agena/Calkin-Wilf-sequence deleted file mode 120000 index eaff2085aa..0000000000 --- a/Lang/Agena/Calkin-Wilf-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calkin-Wilf-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Catalan-numbers b/Lang/Agena/Catalan-numbers deleted file mode 120000 index 926ef43918..0000000000 --- a/Lang/Agena/Catalan-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Character-codes b/Lang/Agena/Character-codes deleted file mode 120000 index 39121b3568..0000000000 --- a/Lang/Agena/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/Agena \ No newline at end of file diff --git a/Lang/Agena/Chowla-numbers b/Lang/Agena/Chowla-numbers deleted file mode 120000 index d4c2806c20..0000000000 --- a/Lang/Agena/Chowla-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chowla-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Damm-algorithm b/Lang/Agena/Damm-algorithm deleted file mode 120000 index d753c9e99f..0000000000 --- a/Lang/Agena/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/Agena \ No newline at end of file diff --git a/Lang/Agena/Day-of-the-week b/Lang/Agena/Day-of-the-week deleted file mode 120000 index e4733798aa..0000000000 --- a/Lang/Agena/Day-of-the-week +++ /dev/null @@ -1 +0,0 @@ -../../Task/Day-of-the-week/Agena \ No newline at end of file diff --git a/Lang/Agena/Department-numbers b/Lang/Agena/Department-numbers deleted file mode 120000 index fdeaca8fd3..0000000000 --- a/Lang/Agena/Department-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Department-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Descending-primes b/Lang/Agena/Descending-primes deleted file mode 120000 index 483dfe03f7..0000000000 --- a/Lang/Agena/Descending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Descending-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Disarium-numbers b/Lang/Agena/Disarium-numbers deleted file mode 120000 index 2bace62b71..0000000000 --- a/Lang/Agena/Disarium-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Disarium-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Entropy b/Lang/Agena/Entropy deleted file mode 120000 index f0f66caa04..0000000000 --- a/Lang/Agena/Entropy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy/Agena \ No newline at end of file diff --git a/Lang/Agena/Equal-prime-and-composite-sums b/Lang/Agena/Equal-prime-and-composite-sums deleted file mode 120000 index 376401ddea..0000000000 --- a/Lang/Agena/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/Agena \ No newline at end of file diff --git a/Lang/Agena/Factorial b/Lang/Agena/Factorial deleted file mode 120000 index 21cbc1e46b..0000000000 --- a/Lang/Agena/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/Agena \ No newline at end of file diff --git a/Lang/Agena/Factorial-primes b/Lang/Agena/Factorial-primes deleted file mode 120000 index 68796e7224..0000000000 --- a/Lang/Agena/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Gamma-function b/Lang/Agena/Gamma-function deleted file mode 120000 index c0b0340467..0000000000 --- a/Lang/Agena/Gamma-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gamma-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Gauss-Jordan-matrix-inversion b/Lang/Agena/Gauss-Jordan-matrix-inversion deleted file mode 120000 index a1bc51eaa3..0000000000 --- a/Lang/Agena/Gauss-Jordan-matrix-inversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gauss-Jordan-matrix-inversion/Agena \ No newline at end of file diff --git a/Lang/Agena/Generate-lower-case-ASCII-alphabet b/Lang/Agena/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index ace5f93bb5..0000000000 --- a/Lang/Agena/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/Agena \ No newline at end of file diff --git a/Lang/Agena/Giuga-numbers b/Lang/Agena/Giuga-numbers deleted file mode 120000 index 273fdf8c7c..0000000000 --- a/Lang/Agena/Giuga-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Giuga-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Goldbachs-comet b/Lang/Agena/Goldbachs-comet deleted file mode 120000 index 26b052a294..0000000000 --- a/Lang/Agena/Goldbachs-comet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Goldbachs-comet/Agena \ No newline at end of file diff --git a/Lang/Agena/Haversine-formula b/Lang/Agena/Haversine-formula deleted file mode 120000 index 45e20df974..0000000000 --- a/Lang/Agena/Haversine-formula +++ /dev/null @@ -1 +0,0 @@ -../../Task/Haversine-formula/Agena \ No newline at end of file diff --git a/Lang/Agena/Horners-rule-for-polynomial-evaluation b/Lang/Agena/Horners-rule-for-polynomial-evaluation deleted file mode 120000 index cffe37e87c..0000000000 --- a/Lang/Agena/Horners-rule-for-polynomial-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horners-rule-for-polynomial-evaluation/Agena \ No newline at end of file diff --git a/Lang/Agena/Humble-numbers b/Lang/Agena/Humble-numbers deleted file mode 120000 index bdce77fd35..0000000000 --- a/Lang/Agena/Humble-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Humble-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/JSON b/Lang/Agena/JSON deleted file mode 120000 index 9c20f7b68f..0000000000 --- a/Lang/Agena/JSON +++ /dev/null @@ -1 +0,0 @@ -../../Task/JSON/Agena \ No newline at end of file diff --git a/Lang/Agena/Jacobsthal-numbers b/Lang/Agena/Jacobsthal-numbers deleted file mode 120000 index 740d21ef1a..0000000000 --- a/Lang/Agena/Jacobsthal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobsthal-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Jewels-and-stones b/Lang/Agena/Jewels-and-stones deleted file mode 120000 index 7c03f8ec8f..0000000000 --- a/Lang/Agena/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/Agena \ No newline at end of file diff --git a/Lang/Agena/Jordan-P-lya-numbers b/Lang/Agena/Jordan-P-lya-numbers deleted file mode 120000 index 4e2d64a6e1..0000000000 --- a/Lang/Agena/Jordan-P-lya-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jordan-P-lya-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Juggler-sequence b/Lang/Agena/Juggler-sequence deleted file mode 120000 index e5817b72b7..0000000000 --- a/Lang/Agena/Juggler-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Juggler-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Kaprekar-numbers b/Lang/Agena/Kaprekar-numbers deleted file mode 120000 index d665f2f5f5..0000000000 --- a/Lang/Agena/Kaprekar-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kaprekar-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Legendre-prime-counting-function b/Lang/Agena/Legendre-prime-counting-function deleted file mode 120000 index 07d7bc7083..0000000000 --- a/Lang/Agena/Legendre-prime-counting-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Legendre-prime-counting-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Leonardo-numbers b/Lang/Agena/Leonardo-numbers deleted file mode 120000 index d6d819f05a..0000000000 --- a/Lang/Agena/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Levenshtein-distance b/Lang/Agena/Levenshtein-distance deleted file mode 120000 index ec3426b464..0000000000 --- a/Lang/Agena/Levenshtein-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance/Agena \ No newline at end of file diff --git a/Lang/Agena/Mayan-numerals b/Lang/Agena/Mayan-numerals deleted file mode 120000 index 671a85a6c0..0000000000 --- a/Lang/Agena/Mayan-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mayan-numerals/Agena \ No newline at end of file diff --git a/Lang/Agena/McNuggets-problem b/Lang/Agena/McNuggets-problem deleted file mode 120000 index b2417f0142..0000000000 --- a/Lang/Agena/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/Agena \ No newline at end of file diff --git a/Lang/Agena/Mian-Chowla-sequence b/Lang/Agena/Mian-Chowla-sequence deleted file mode 120000 index a6489175a6..0000000000 --- a/Lang/Agena/Mian-Chowla-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mian-Chowla-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Monty-Hall-problem b/Lang/Agena/Monty-Hall-problem deleted file mode 120000 index d1c4ae980e..0000000000 --- a/Lang/Agena/Monty-Hall-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monty-Hall-problem/Agena \ No newline at end of file diff --git a/Lang/Agena/Numbers-with-equal-rises-and-falls b/Lang/Agena/Numbers-with-equal-rises-and-falls deleted file mode 120000 index 08787d85d6..0000000000 --- a/Lang/Agena/Numbers-with-equal-rises-and-falls +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-with-equal-rises-and-falls/Agena \ No newline at end of file diff --git a/Lang/Agena/Ordered-words b/Lang/Agena/Ordered-words deleted file mode 120000 index 3503a492c8..0000000000 --- a/Lang/Agena/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/Agena \ No newline at end of file diff --git a/Lang/Agena/Periodic-table b/Lang/Agena/Periodic-table deleted file mode 120000 index cb70080867..0000000000 --- a/Lang/Agena/Periodic-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Periodic-table/Agena \ No newline at end of file diff --git a/Lang/Agena/Pernicious-numbers b/Lang/Agena/Pernicious-numbers deleted file mode 120000 index 454ce5b94d..0000000000 --- a/Lang/Agena/Pernicious-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pernicious-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Pisano-period b/Lang/Agena/Pisano-period deleted file mode 120000 index afaae8dce9..0000000000 --- a/Lang/Agena/Pisano-period +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pisano-period/Agena \ No newline at end of file diff --git a/Lang/Agena/Primality-by-trial-division b/Lang/Agena/Primality-by-trial-division deleted file mode 120000 index 621c0609eb..0000000000 --- a/Lang/Agena/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/Agena \ No newline at end of file diff --git a/Lang/Agena/Program-name b/Lang/Agena/Program-name deleted file mode 120000 index bf43276155..0000000000 --- a/Lang/Agena/Program-name +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-name/Agena \ No newline at end of file diff --git a/Lang/Agena/Quoting-constructs b/Lang/Agena/Quoting-constructs deleted file mode 120000 index f6fed80313..0000000000 --- a/Lang/Agena/Quoting-constructs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quoting-constructs/Agena \ No newline at end of file diff --git a/Lang/Agena/Read-a-file-line-by-line b/Lang/Agena/Read-a-file-line-by-line deleted file mode 120000 index a4d8ef354b..0000000000 --- a/Lang/Agena/Read-a-file-line-by-line +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-file-line-by-line/Agena \ No newline at end of file diff --git a/Lang/Agena/Reverse-a-string b/Lang/Agena/Reverse-a-string deleted file mode 120000 index db79d68725..0000000000 --- a/Lang/Agena/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Agena \ No newline at end of file diff --git a/Lang/Agena/Sequence-of-primes-by-trial-division b/Lang/Agena/Sequence-of-primes-by-trial-division deleted file mode 120000 index d7958a31a1..0000000000 --- a/Lang/Agena/Sequence-of-primes-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-primes-by-trial-division/Agena \ No newline at end of file diff --git a/Lang/Agena/Sleeping-Beauty-problem b/Lang/Agena/Sleeping-Beauty-problem deleted file mode 120000 index 2cf02e5792..0000000000 --- a/Lang/Agena/Sleeping-Beauty-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleeping-Beauty-problem/Agena \ No newline at end of file diff --git a/Lang/Agena/Smarandache-prime-digital-sequence b/Lang/Agena/Smarandache-prime-digital-sequence deleted file mode 120000 index 3a1f0e0805..0000000000 --- a/Lang/Agena/Smarandache-prime-digital-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smarandache-prime-digital-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Soloways-recurring-rainfall b/Lang/Agena/Soloways-recurring-rainfall deleted file mode 120000 index b391a79582..0000000000 --- a/Lang/Agena/Soloways-recurring-rainfall +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soloways-recurring-rainfall/Agena \ No newline at end of file diff --git a/Lang/Agena/Square-but-not-cube b/Lang/Agena/Square-but-not-cube deleted file mode 120000 index 951bd25edd..0000000000 --- a/Lang/Agena/Square-but-not-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-but-not-cube/Agena \ No newline at end of file diff --git a/Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix deleted file mode 120000 index 6bd7256f3a..0000000000 --- a/Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-elements-below-main-diagonal-of-matrix/Agena \ No newline at end of file diff --git a/Lang/Agena/Super-d-numbers b/Lang/Agena/Super-d-numbers deleted file mode 120000 index 1da0548626..0000000000 --- a/Lang/Agena/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Sylvesters-sequence b/Lang/Agena/Sylvesters-sequence deleted file mode 120000 index 9a5d51563f..0000000000 --- a/Lang/Agena/Sylvesters-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sylvesters-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Tau-function b/Lang/Agena/Tau-function deleted file mode 120000 index 579307a681..0000000000 --- a/Lang/Agena/Tau-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Tau-number b/Lang/Agena/Tau-number deleted file mode 120000 index 543c34a5b4..0000000000 --- a/Lang/Agena/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/Agena \ No newline at end of file diff --git a/Lang/Agena/The-sieve-of-Sundaram b/Lang/Agena/The-sieve-of-Sundaram deleted file mode 120000 index 5ab3c6c849..0000000000 --- a/Lang/Agena/The-sieve-of-Sundaram +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-sieve-of-Sundaram/Agena \ No newline at end of file diff --git a/Lang/Agena/Thue-Morse b/Lang/Agena/Thue-Morse deleted file mode 120000 index f3225165e3..0000000000 --- a/Lang/Agena/Thue-Morse +++ /dev/null @@ -1 +0,0 @@ -../../Task/Thue-Morse/Agena \ No newline at end of file diff --git a/Lang/Agena/Time-a-function b/Lang/Agena/Time-a-function deleted file mode 120000 index e5746c4dff..0000000000 --- a/Lang/Agena/Time-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Time-a-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Totient-function b/Lang/Agena/Totient-function deleted file mode 120000 index d74f15771c..0000000000 --- a/Lang/Agena/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Unprimeable-numbers b/Lang/Agena/Unprimeable-numbers deleted file mode 120000 index fc3b30fec4..0000000000 --- a/Lang/Agena/Unprimeable-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unprimeable-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Van-Eck-sequence b/Lang/Agena/Van-Eck-sequence deleted file mode 120000 index 1714aa1507..0000000000 --- a/Lang/Agena/Van-Eck-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-Eck-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Van-der-Corput-sequence b/Lang/Agena/Van-der-Corput-sequence deleted file mode 120000 index 92bec950df..0000000000 --- a/Lang/Agena/Van-der-Corput-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-der-Corput-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Wagstaff-primes b/Lang/Agena/Wagstaff-primes deleted file mode 120000 index b63d3369fa..0000000000 --- a/Lang/Agena/Wagstaff-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wagstaff-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Wieferich-primes b/Lang/Agena/Wieferich-primes deleted file mode 120000 index 34597fbb1d..0000000000 --- a/Lang/Agena/Wieferich-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wieferich-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Wilson-primes-of-order-n b/Lang/Agena/Wilson-primes-of-order-n deleted file mode 120000 index 6b8ae43468..0000000000 --- a/Lang/Agena/Wilson-primes-of-order-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wilson-primes-of-order-n/Agena \ No newline at end of file diff --git a/Lang/Agena/Yellowstone-sequence b/Lang/Agena/Yellowstone-sequence deleted file mode 120000 index 4464a6e815..0000000000 --- a/Lang/Agena/Yellowstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yellowstone-sequence/Agena \ No newline at end of file diff --git a/Lang/Aikido/00-LANG.txt b/Lang/Aikido/00-LANG.txt index 19bd4a47ab..4126891ffb 100644 --- a/Lang/Aikido/00-LANG.txt +++ b/Lang/Aikido/00-LANG.txt @@ -12,4 +12,4 @@ It was developed at [[Sun Microsystems|Sun Microsystems Laboratories]] by David In some respects it is similar in functionality to [[Python]], [[Perl]], [[JavaScript]] and [[Java]]. Syntactically it is very similar to [[C++]] and Java. -Aikido is available for Linux, Mac OS X and Solaris. The interpreter can be obtained from http://sourceforge.net/projects/aikido. Documentation (in PDF) is at https://sourceforge.net/projects/aikido/files/aikido/1.40/aikidoref140.pdf/download \ No newline at end of file +Aikido is available for Linux, Mac OS X and Solaris. The interpreter can be obtained from http://sourceforge.net/projects/aikido. Documentation (in PDF) is at http://downloads.sourceforge.net/aikido/aikido_prm.pdf \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Anagrams b/Lang/Amazing-Hopper/Anagrams deleted file mode 120000 index 0666803cc3..0000000000 --- a/Lang/Amazing-Hopper/Anagrams +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anagrams/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Arithmetic-evaluation b/Lang/Amazing-Hopper/Arithmetic-evaluation deleted file mode 120000 index 090fde0f4b..0000000000 --- a/Lang/Amazing-Hopper/Arithmetic-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-evaluation/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Averages-Median b/Lang/Amazing-Hopper/Averages-Median deleted file mode 120000 index 85188aa532..0000000000 --- a/Lang/Amazing-Hopper/Averages-Median +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Median/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Babbage-problem b/Lang/Amazing-Hopper/Babbage-problem deleted file mode 120000 index fbd53ae54a..0000000000 --- a/Lang/Amazing-Hopper/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Balanced-brackets b/Lang/Amazing-Hopper/Balanced-brackets deleted file mode 120000 index 22c365c13b..0000000000 --- a/Lang/Amazing-Hopper/Balanced-brackets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Balanced-brackets/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Cantor-set b/Lang/Amazing-Hopper/Cantor-set deleted file mode 120000 index b7d83aa2d8..0000000000 --- a/Lang/Amazing-Hopper/Cantor-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cantor-set/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Count-in-octal b/Lang/Amazing-Hopper/Count-in-octal deleted file mode 120000 index db01d0d594..0000000000 --- a/Lang/Amazing-Hopper/Count-in-octal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-in-octal/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Deceptive-numbers b/Lang/Amazing-Hopper/Deceptive-numbers deleted file mode 120000 index 8f0aa19f7f..0000000000 --- a/Lang/Amazing-Hopper/Deceptive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deceptive-numbers/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Digital-root b/Lang/Amazing-Hopper/Digital-root deleted file mode 120000 index 22bf453215..0000000000 --- a/Lang/Amazing-Hopper/Digital-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Digital-root/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Disarium-numbers b/Lang/Amazing-Hopper/Disarium-numbers deleted file mode 120000 index ce173c6822..0000000000 --- a/Lang/Amazing-Hopper/Disarium-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Disarium-numbers/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Dot-product b/Lang/Amazing-Hopper/Dot-product deleted file mode 120000 index 6bc7d5ea07..0000000000 --- a/Lang/Amazing-Hopper/Dot-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dot-product/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Amazing-Hopper/Exceptions-Catch-an-exception-thrown-in-a-nested-call deleted file mode 120000 index 0103e6f8e7..0000000000 --- a/Lang/Amazing-Hopper/Exceptions-Catch-an-exception-thrown-in-a-nested-call +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Formatted-numeric-output b/Lang/Amazing-Hopper/Formatted-numeric-output deleted file mode 120000 index 36d6f264bf..0000000000 --- a/Lang/Amazing-Hopper/Formatted-numeric-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Formatted-numeric-output/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Function-composition b/Lang/Amazing-Hopper/Function-composition deleted file mode 120000 index 257a080151..0000000000 --- a/Lang/Amazing-Hopper/Function-composition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-composition/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Function-definition b/Lang/Amazing-Hopper/Function-definition deleted file mode 120000 index 9bc2eac985..0000000000 --- a/Lang/Amazing-Hopper/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Hailstone-sequence b/Lang/Amazing-Hopper/Hailstone-sequence deleted file mode 120000 index c1e9f894b1..0000000000 --- a/Lang/Amazing-Hopper/Hailstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hailstone-sequence/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Haversine-formula b/Lang/Amazing-Hopper/Haversine-formula deleted file mode 120000 index 01efd99770..0000000000 --- a/Lang/Amazing-Hopper/Haversine-formula +++ /dev/null @@ -1 +0,0 @@ -../../Task/Haversine-formula/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Identity-matrix b/Lang/Amazing-Hopper/Identity-matrix deleted file mode 120000 index 4a7e2fd4cf..0000000000 --- a/Lang/Amazing-Hopper/Identity-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Identity-matrix/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Knuth-shuffle b/Lang/Amazing-Hopper/Knuth-shuffle deleted file mode 120000 index b4397143ef..0000000000 --- a/Lang/Amazing-Hopper/Knuth-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knuth-shuffle/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Long-year b/Lang/Amazing-Hopper/Long-year deleted file mode 120000 index 67734f8564..0000000000 --- a/Lang/Amazing-Hopper/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-Break b/Lang/Amazing-Hopper/Loops-Break deleted file mode 120000 index d893889883..0000000000 --- a/Lang/Amazing-Hopper/Loops-Break +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Break/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-Foreach b/Lang/Amazing-Hopper/Loops-Foreach deleted file mode 120000 index a96479cd1b..0000000000 --- a/Lang/Amazing-Hopper/Loops-Foreach +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Foreach/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-Increment-loop-index-within-loop-body b/Lang/Amazing-Hopper/Loops-Increment-loop-index-within-loop-body deleted file mode 120000 index 97bc03e8ea..0000000000 --- a/Lang/Amazing-Hopper/Loops-Increment-loop-index-within-loop-body +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Increment-loop-index-within-loop-body/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-N-plus-one-half b/Lang/Amazing-Hopper/Loops-N-plus-one-half deleted file mode 120000 index 34fd3f5304..0000000000 --- a/Lang/Amazing-Hopper/Loops-N-plus-one-half +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-N-plus-one-half/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-Nested b/Lang/Amazing-Hopper/Loops-Nested deleted file mode 120000 index b565608ed5..0000000000 --- a/Lang/Amazing-Hopper/Loops-Nested +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Nested/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-While b/Lang/Amazing-Hopper/Loops-While deleted file mode 120000 index be6130bb45..0000000000 --- a/Lang/Amazing-Hopper/Loops-While +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-While/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Loops-With-multiple-ranges b/Lang/Amazing-Hopper/Loops-With-multiple-ranges deleted file mode 120000 index 3c9f0de0dc..0000000000 --- a/Lang/Amazing-Hopper/Loops-With-multiple-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-With-multiple-ranges/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/M-bius-function b/Lang/Amazing-Hopper/M-bius-function deleted file mode 120000 index 3fa2be430d..0000000000 --- a/Lang/Amazing-Hopper/M-bius-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/M-bius-function/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Magic-squares-of-doubly-even-order b/Lang/Amazing-Hopper/Magic-squares-of-doubly-even-order deleted file mode 120000 index 3304664c75..0000000000 --- a/Lang/Amazing-Hopper/Magic-squares-of-doubly-even-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-doubly-even-order/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Magnanimous-numbers b/Lang/Amazing-Hopper/Magnanimous-numbers deleted file mode 120000 index d82f2324d0..0000000000 --- a/Lang/Amazing-Hopper/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Matrix-digital-rain b/Lang/Amazing-Hopper/Matrix-digital-rain deleted file mode 120000 index c42a700f67..0000000000 --- a/Lang/Amazing-Hopper/Matrix-digital-rain +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-digital-rain/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Mayan-numerals b/Lang/Amazing-Hopper/Mayan-numerals deleted file mode 120000 index 74c0c29a62..0000000000 --- a/Lang/Amazing-Hopper/Mayan-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mayan-numerals/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Middle-three-digits b/Lang/Amazing-Hopper/Middle-three-digits deleted file mode 120000 index c7c41225de..0000000000 --- a/Lang/Amazing-Hopper/Middle-three-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Middle-three-digits/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/One-dimensional-cellular-automata b/Lang/Amazing-Hopper/One-dimensional-cellular-automata deleted file mode 120000 index 47a2f89f22..0000000000 --- a/Lang/Amazing-Hopper/One-dimensional-cellular-automata +++ /dev/null @@ -1 +0,0 @@ -../../Task/One-dimensional-cellular-automata/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Ordered-words b/Lang/Amazing-Hopper/Ordered-words deleted file mode 120000 index 79f4afa7b3..0000000000 --- a/Lang/Amazing-Hopper/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Pseudo-random-numbers-Middle-square-method b/Lang/Amazing-Hopper/Pseudo-random-numbers-Middle-square-method deleted file mode 120000 index fde29893bc..0000000000 --- a/Lang/Amazing-Hopper/Pseudo-random-numbers-Middle-square-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Middle-square-method/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Return-multiple-values b/Lang/Amazing-Hopper/Return-multiple-values deleted file mode 120000 index 989a978413..0000000000 --- a/Lang/Amazing-Hopper/Return-multiple-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Return-multiple-values/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Run-length-encoding b/Lang/Amazing-Hopper/Run-length-encoding deleted file mode 120000 index c9540874b6..0000000000 --- a/Lang/Amazing-Hopper/Run-length-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/Run-length-encoding/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Smith-numbers b/Lang/Amazing-Hopper/Smith-numbers deleted file mode 120000 index 9f7a72e850..0000000000 --- a/Lang/Amazing-Hopper/Smith-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smith-numbers/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Sort-three-variables b/Lang/Amazing-Hopper/Sort-three-variables deleted file mode 120000 index 3adad4c634..0000000000 --- a/Lang/Amazing-Hopper/Sort-three-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-three-variables/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Split-a-character-string-based-on-change-of-character b/Lang/Amazing-Hopper/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index ac99345357..0000000000 --- a/Lang/Amazing-Hopper/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Statistics-Basic b/Lang/Amazing-Hopper/Statistics-Basic deleted file mode 120000 index bfa2d08b49..0000000000 --- a/Lang/Amazing-Hopper/Statistics-Basic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Basic/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/String-append b/Lang/Amazing-Hopper/String-append deleted file mode 120000 index 6d208e62ad..0000000000 --- a/Lang/Amazing-Hopper/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Strip-a-set-of-characters-from-a-string b/Lang/Amazing-Hopper/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index d713785f03..0000000000 --- a/Lang/Amazing-Hopper/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Strip-whitespace-from-a-string-Top-and-tail b/Lang/Amazing-Hopper/Strip-whitespace-from-a-string-Top-and-tail deleted file mode 120000 index a5452c52ea..0000000000 --- a/Lang/Amazing-Hopper/Strip-whitespace-from-a-string-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-whitespace-from-a-string-Top-and-tail/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Successive-prime-differences b/Lang/Amazing-Hopper/Successive-prime-differences deleted file mode 120000 index efd8572186..0000000000 --- a/Lang/Amazing-Hopper/Successive-prime-differences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Successive-prime-differences/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Sum-of-a-series b/Lang/Amazing-Hopper/Sum-of-a-series deleted file mode 120000 index 03635804ee..0000000000 --- a/Lang/Amazing-Hopper/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Super-d-numbers b/Lang/Amazing-Hopper/Super-d-numbers deleted file mode 120000 index 1770d7a856..0000000000 --- a/Lang/Amazing-Hopper/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Symmetric-difference b/Lang/Amazing-Hopper/Symmetric-difference deleted file mode 120000 index 1af0b3c084..0000000000 --- a/Lang/Amazing-Hopper/Symmetric-difference +++ /dev/null @@ -1 +0,0 @@ -../../Task/Symmetric-difference/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Take-notes-on-the-command-line b/Lang/Amazing-Hopper/Take-notes-on-the-command-line deleted file mode 120000 index 2fd4c913c8..0000000000 --- a/Lang/Amazing-Hopper/Take-notes-on-the-command-line +++ /dev/null @@ -1 +0,0 @@ -../../Task/Take-notes-on-the-command-line/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Text-processing-2 b/Lang/Amazing-Hopper/Text-processing-2 deleted file mode 120000 index f3d3800aca..0000000000 --- a/Lang/Amazing-Hopper/Text-processing-2 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Text-processing-2/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Truth-table b/Lang/Amazing-Hopper/Truth-table deleted file mode 120000 index 14882232f9..0000000000 --- a/Lang/Amazing-Hopper/Truth-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truth-table/Amazing-Hopper \ No newline at end of file diff --git a/Lang/Amazing-Hopper/Van-Eck-sequence b/Lang/Amazing-Hopper/Van-Eck-sequence deleted file mode 120000 index 0c660f0481..0000000000 --- a/Lang/Amazing-Hopper/Van-Eck-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-Eck-sequence/Amazing-Hopper \ No newline at end of file diff --git a/Lang/AmigaBASIC/00-LANG.txt b/Lang/AmigaBASIC/00-LANG.txt index c2e6f48854..94b3e71ee7 100644 --- a/Lang/AmigaBASIC/00-LANG.txt +++ b/Lang/AmigaBASIC/00-LANG.txt @@ -11,7 +11,5 @@ Execution speed however was not a particular strength of AmigaBASIC. Some 8-bit AmigaBASIC was superseded by [[wp:ARexx|ARexx]], a REXX-style scripting language, from AmigaOS version 2.0 onwards. The 1.x AmigaBASIC binary also works on AmigaOS 2, but not on AmigaOS 3. -Microsoft [[QuickBASIC]] (1985) and QBasic (1991) look very similar to AmigaBASIC, so their syntax highlighting rules mostly also work for AmigaBASIC code. - ==See Also== *[https://archive.org/search.php?query=amiga%20basic Scanned AmigaBASIC books at archive.org] \ No newline at end of file diff --git a/Lang/AmigaBASIC/Animate-a-pendulum b/Lang/AmigaBASIC/Animate-a-pendulum deleted file mode 120000 index 010529e570..0000000000 --- a/Lang/AmigaBASIC/Animate-a-pendulum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Animate-a-pendulum/AmigaBASIC \ No newline at end of file diff --git a/Lang/AmigaBASIC/Chaos-game b/Lang/AmigaBASIC/Chaos-game deleted file mode 120000 index 06fb31b581..0000000000 --- a/Lang/AmigaBASIC/Chaos-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaos-game/AmigaBASIC \ No newline at end of file diff --git a/Lang/Apple/00-LANG.txt b/Lang/Apple/00-LANG.txt deleted file mode 100644 index e4e452b143..0000000000 --- a/Lang/Apple/00-LANG.txt +++ /dev/null @@ -1,12 +0,0 @@ -{{language|Apple -|exec=Compiled -|safety=safe -|checking=static -|strength=strong -|site=https://github.com/vmchale/apple}} - -{{language programming paradigm|functional}} - -The Apple Array System is a JIT-compiler for a statically typed functional language specialized on arrays. - -It is expression-oriented (it has no imports); it is meant to be called from other languages. \ No newline at end of file diff --git a/Lang/Apple/00-META.yaml b/Lang/Apple/00-META.yaml deleted file mode 100644 index fcdeec5d5c..0000000000 --- a/Lang/Apple/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Apple diff --git a/Lang/Apple/Averages-Arithmetic-mean b/Lang/Apple/Averages-Arithmetic-mean deleted file mode 120000 index b4236a6909..0000000000 --- a/Lang/Apple/Averages-Arithmetic-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Arithmetic-mean/Apple \ No newline at end of file diff --git a/Lang/Apple/Averages-Pythagorean-means b/Lang/Apple/Averages-Pythagorean-means deleted file mode 120000 index 50c70e6c0b..0000000000 --- a/Lang/Apple/Averages-Pythagorean-means +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Pythagorean-means/Apple \ No newline at end of file diff --git a/Lang/Apple/Catamorphism b/Lang/Apple/Catamorphism deleted file mode 120000 index 5d06cbf18d..0000000000 --- a/Lang/Apple/Catamorphism +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catamorphism/Apple \ No newline at end of file diff --git a/Lang/Apple/Dot-product b/Lang/Apple/Dot-product deleted file mode 120000 index 084fc21920..0000000000 --- a/Lang/Apple/Dot-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dot-product/Apple \ No newline at end of file diff --git a/Lang/Apple/Factorial b/Lang/Apple/Factorial deleted file mode 120000 index 8d659daa6f..0000000000 --- a/Lang/Apple/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/Apple \ No newline at end of file diff --git a/Lang/Apple/Factors-of-an-integer b/Lang/Apple/Factors-of-an-integer deleted file mode 120000 index a965a5d4bd..0000000000 --- a/Lang/Apple/Factors-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factors-of-an-integer/Apple \ No newline at end of file diff --git a/Lang/Apple/Filter b/Lang/Apple/Filter deleted file mode 120000 index 5dfbcaf92d..0000000000 --- a/Lang/Apple/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/Apple \ No newline at end of file diff --git a/Lang/Apple/ISBN13-check-digit b/Lang/Apple/ISBN13-check-digit deleted file mode 120000 index b9d843e9fc..0000000000 --- a/Lang/Apple/ISBN13-check-digit +++ /dev/null @@ -1 +0,0 @@ -../../Task/ISBN13-check-digit/Apple \ No newline at end of file diff --git a/Lang/AppleScript/21-game b/Lang/AppleScript/21-game deleted file mode 120000 index 8108f8c3fc..0000000000 --- a/Lang/AppleScript/21-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/21-game/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Angle-difference-between-two-bearings b/Lang/AppleScript/Angle-difference-between-two-bearings deleted file mode 120000 index cb1c37c369..0000000000 --- a/Lang/AppleScript/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Arithmetic-numbers b/Lang/AppleScript/Arithmetic-numbers deleted file mode 120000 index 3cefb4a617..0000000000 --- a/Lang/AppleScript/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Associative-array-Creation b/Lang/AppleScript/Associative-array-Creation deleted file mode 120000 index 8dba66b7c2..0000000000 --- a/Lang/AppleScript/Associative-array-Creation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Creation/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Bin-given-limits b/Lang/AppleScript/Bin-given-limits deleted file mode 120000 index 955dc82ffb..0000000000 --- a/Lang/AppleScript/Bin-given-limits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bin-given-limits/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Call-a-foreign-language-function b/Lang/AppleScript/Call-a-foreign-language-function deleted file mode 120000 index 29365d0ac9..0000000000 --- a/Lang/AppleScript/Call-a-foreign-language-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-a-foreign-language-function/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Catalan-numbers b/Lang/AppleScript/Catalan-numbers deleted file mode 120000 index 0299ff88b4..0000000000 --- a/Lang/AppleScript/Catalan-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Create-an-HTML-table b/Lang/AppleScript/Create-an-HTML-table deleted file mode 120000 index c5386274dd..0000000000 --- a/Lang/AppleScript/Create-an-HTML-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-an-HTML-table/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Formatted-numeric-output b/Lang/AppleScript/Formatted-numeric-output deleted file mode 120000 index de125c08d5..0000000000 --- a/Lang/AppleScript/Formatted-numeric-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Formatted-numeric-output/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Hello-world-Newbie b/Lang/AppleScript/Hello-world-Newbie deleted file mode 120000 index 251b56564d..0000000000 --- a/Lang/AppleScript/Hello-world-Newbie +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newbie/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Horners-rule-for-polynomial-evaluation b/Lang/AppleScript/Horners-rule-for-polynomial-evaluation deleted file mode 120000 index b014f0231a..0000000000 --- a/Lang/AppleScript/Horners-rule-for-polynomial-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horners-rule-for-polynomial-evaluation/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Logical-operations b/Lang/AppleScript/Logical-operations deleted file mode 120000 index f381ea6d80..0000000000 --- a/Lang/AppleScript/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Loops-N-plus-one-half b/Lang/AppleScript/Loops-N-plus-one-half deleted file mode 120000 index c9ebbc6d6f..0000000000 --- a/Lang/AppleScript/Loops-N-plus-one-half +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-N-plus-one-half/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Loops-Wrong-ranges b/Lang/AppleScript/Loops-Wrong-ranges deleted file mode 120000 index 30ead650a7..0000000000 --- a/Lang/AppleScript/Loops-Wrong-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Wrong-ranges/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Magic-constant b/Lang/AppleScript/Magic-constant deleted file mode 120000 index 103e56a841..0000000000 --- a/Lang/AppleScript/Magic-constant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-constant/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Monte-Carlo-methods b/Lang/AppleScript/Monte-Carlo-methods deleted file mode 120000 index a3fd9d8a00..0000000000 --- a/Lang/AppleScript/Monte-Carlo-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monte-Carlo-methods/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Multifactorial b/Lang/AppleScript/Multifactorial deleted file mode 120000 index 9d3c79cdc6..0000000000 --- a/Lang/AppleScript/Multifactorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multifactorial/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Naming-conventions b/Lang/AppleScript/Naming-conventions deleted file mode 120000 index bd6fd7dc7b..0000000000 --- a/Lang/AppleScript/Naming-conventions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Naming-conventions/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Nim-game b/Lang/AppleScript/Nim-game deleted file mode 120000 index f67182813f..0000000000 --- a/Lang/AppleScript/Nim-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nim-game/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Nth-root b/Lang/AppleScript/Nth-root deleted file mode 120000 index 24be4fbbed..0000000000 --- a/Lang/AppleScript/Nth-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth-root/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Numerical-integration b/Lang/AppleScript/Numerical-integration deleted file mode 120000 index 2cd0b2ae37..0000000000 --- a/Lang/AppleScript/Numerical-integration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numerical-integration/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Penneys-game b/Lang/AppleScript/Penneys-game deleted file mode 120000 index 8e49dba4f9..0000000000 --- a/Lang/AppleScript/Penneys-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Penneys-game/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Pig-the-dice-game b/Lang/AppleScript/Pig-the-dice-game deleted file mode 120000 index db35af118f..0000000000 --- a/Lang/AppleScript/Pig-the-dice-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pig-the-dice-game/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Program-name b/Lang/AppleScript/Program-name deleted file mode 120000 index 08ec2ad4f8..0000000000 --- a/Lang/AppleScript/Program-name +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-name/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Real-constants-and-functions b/Lang/AppleScript/Real-constants-and-functions deleted file mode 120000 index 4a6c0f5db0..0000000000 --- a/Lang/AppleScript/Real-constants-and-functions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Real-constants-and-functions/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Return-multiple-values b/Lang/AppleScript/Return-multiple-values deleted file mode 120000 index f507a094fb..0000000000 --- a/Lang/AppleScript/Return-multiple-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Return-multiple-values/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Send-email b/Lang/AppleScript/Send-email deleted file mode 120000 index 4ba0780be8..0000000000 --- a/Lang/AppleScript/Send-email +++ /dev/null @@ -1 +0,0 @@ -../../Task/Send-email/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Sorting-algorithms-Stooge-sort b/Lang/AppleScript/Sorting-algorithms-Stooge-sort deleted file mode 120000 index 56b9196ffc..0000000000 --- a/Lang/AppleScript/Sorting-algorithms-Stooge-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Stooge-sort/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Sorting-algorithms-Strand-sort b/Lang/AppleScript/Sorting-algorithms-Strand-sort deleted file mode 120000 index b6b771e075..0000000000 --- a/Lang/AppleScript/Sorting-algorithms-Strand-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Strand-sort/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Textonyms b/Lang/AppleScript/Textonyms deleted file mode 120000 index e51af23b62..0000000000 --- a/Lang/AppleScript/Textonyms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Textonyms/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Variable-declaration-reset b/Lang/AppleScript/Variable-declaration-reset deleted file mode 120000 index 3059dd090c..0000000000 --- a/Lang/AppleScript/Variable-declaration-reset +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variable-declaration-reset/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Write-entire-file b/Lang/AppleScript/Write-entire-file deleted file mode 120000 index 5be6a2da0d..0000000000 --- a/Lang/AppleScript/Write-entire-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-entire-file/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Write-float-arrays-to-a-text-file b/Lang/AppleScript/Write-float-arrays-to-a-text-file deleted file mode 120000 index d7524dd990..0000000000 --- a/Lang/AppleScript/Write-float-arrays-to-a-text-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-float-arrays-to-a-text-file/AppleScript \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/00-LANG.txt b/Lang/Applesoft-BASIC/00-LANG.txt index 854387033b..b47ab777d1 100644 --- a/Lang/Applesoft-BASIC/00-LANG.txt +++ b/Lang/Applesoft-BASIC/00-LANG.txt @@ -7,5 +7,4 @@ * [[wp:Applesoft BASIC|Wikipedia: Applesoft BASIC]] * [http://www.landsnail.com/a2ref.htm Apple II Programmer's Reference] from ][ In a Mac, via [http://www.landsnail.com/ Landsnail.com] * [http://www.hoist-point.com/applesoft_basic_tutorial.htm AppleSoft BASIC tutorial for absolute beginners] -* [https://www.calormen.com/jsbasic/ Applesoft BASIC in Javascript] On-line interpreter * ''[[Tasks not implemented in Applesoft BASIC|Tasks not implemented in Applesoft BASIC]]'' \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Bifid-cipher b/Lang/Applesoft-BASIC/Bifid-cipher deleted file mode 120000 index 1e2daab5d3..0000000000 --- a/Lang/Applesoft-BASIC/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Cartesian-product-of-two-or-more-lists b/Lang/Applesoft-BASIC/Cartesian-product-of-two-or-more-lists deleted file mode 120000 index 199613d315..0000000000 --- a/Lang/Applesoft-BASIC/Cartesian-product-of-two-or-more-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cartesian-product-of-two-or-more-lists/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Case-sensitivity-of-identifiers b/Lang/Applesoft-BASIC/Case-sensitivity-of-identifiers deleted file mode 120000 index 123351bd24..0000000000 --- a/Lang/Applesoft-BASIC/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Catalan-numbers-Pascals-triangle b/Lang/Applesoft-BASIC/Catalan-numbers-Pascals-triangle deleted file mode 120000 index 7b0441411f..0000000000 --- a/Lang/Applesoft-BASIC/Catalan-numbers-Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers-Pascals-triangle/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Check-output-device-is-a-terminal b/Lang/Applesoft-BASIC/Check-output-device-is-a-terminal deleted file mode 120000 index e21d34eceb..0000000000 --- a/Lang/Applesoft-BASIC/Check-output-device-is-a-terminal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-output-device-is-a-terminal/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Church-numerals b/Lang/Applesoft-BASIC/Church-numerals deleted file mode 120000 index a114e6a3f9..0000000000 --- a/Lang/Applesoft-BASIC/Church-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Church-numerals/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Cistercian-numerals b/Lang/Applesoft-BASIC/Cistercian-numerals deleted file mode 120000 index 2c5e6c52c1..0000000000 --- a/Lang/Applesoft-BASIC/Cistercian-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cistercian-numerals/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Compare-a-list-of-strings b/Lang/Applesoft-BASIC/Compare-a-list-of-strings deleted file mode 120000 index 7eafe8f723..0000000000 --- a/Lang/Applesoft-BASIC/Compare-a-list-of-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-a-list-of-strings/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Determine-if-a-string-is-collapsible b/Lang/Applesoft-BASIC/Determine-if-a-string-is-collapsible deleted file mode 120000 index 02f9d8d440..0000000000 --- a/Lang/Applesoft-BASIC/Determine-if-a-string-is-collapsible +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-collapsible/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Determine-if-a-string-is-squeezable b/Lang/Applesoft-BASIC/Determine-if-a-string-is-squeezable deleted file mode 120000 index b18de01c9a..0000000000 --- a/Lang/Applesoft-BASIC/Determine-if-a-string-is-squeezable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-squeezable/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Display-a-linear-combination b/Lang/Applesoft-BASIC/Display-a-linear-combination deleted file mode 120000 index d72f6d3a78..0000000000 --- a/Lang/Applesoft-BASIC/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Dragon-curve b/Lang/Applesoft-BASIC/Dragon-curve deleted file mode 120000 index 89a81bf5e7..0000000000 --- a/Lang/Applesoft-BASIC/Dragon-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dragon-curve/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Draw-a-pixel b/Lang/Applesoft-BASIC/Draw-a-pixel deleted file mode 120000 index 7ca9518328..0000000000 --- a/Lang/Applesoft-BASIC/Draw-a-pixel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-pixel/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Duffinian-numbers b/Lang/Applesoft-BASIC/Duffinian-numbers deleted file mode 120000 index 803f0d38f7..0000000000 --- a/Lang/Applesoft-BASIC/Duffinian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Duffinian-numbers/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Enumerations b/Lang/Applesoft-BASIC/Enumerations deleted file mode 120000 index aa327448dc..0000000000 --- a/Lang/Applesoft-BASIC/Enumerations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Enumerations/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Euler-method b/Lang/Applesoft-BASIC/Euler-method deleted file mode 120000 index 4ae359e855..0000000000 --- a/Lang/Applesoft-BASIC/Euler-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euler-method/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Eulers-sum-of-powers-conjecture b/Lang/Applesoft-BASIC/Eulers-sum-of-powers-conjecture deleted file mode 120000 index 814a94e748..0000000000 --- a/Lang/Applesoft-BASIC/Eulers-sum-of-powers-conjecture +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-sum-of-powers-conjecture/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Fibonacci-sequence b/Lang/Applesoft-BASIC/Fibonacci-sequence deleted file mode 120000 index f95390f3d5..0000000000 --- a/Lang/Applesoft-BASIC/Fibonacci-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-sequence/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Formatted-numeric-output b/Lang/Applesoft-BASIC/Formatted-numeric-output deleted file mode 120000 index 52c4ceb520..0000000000 --- a/Lang/Applesoft-BASIC/Formatted-numeric-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Formatted-numeric-output/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/LZW-compression b/Lang/Applesoft-BASIC/LZW-compression deleted file mode 120000 index b2b0a00f3d..0000000000 --- a/Lang/Applesoft-BASIC/LZW-compression +++ /dev/null @@ -1 +0,0 @@ -../../Task/LZW-compression/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Levenshtein-distance b/Lang/Applesoft-BASIC/Levenshtein-distance deleted file mode 120000 index 890eb3e044..0000000000 --- a/Lang/Applesoft-BASIC/Levenshtein-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Look-and-say-sequence b/Lang/Applesoft-BASIC/Look-and-say-sequence deleted file mode 120000 index 134c9adfcf..0000000000 --- a/Lang/Applesoft-BASIC/Look-and-say-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Look-and-say-sequence/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Loop-over-multiple-arrays-simultaneously b/Lang/Applesoft-BASIC/Loop-over-multiple-arrays-simultaneously deleted file mode 120000 index a4b41c4dcd..0000000000 --- a/Lang/Applesoft-BASIC/Loop-over-multiple-arrays-simultaneously +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loop-over-multiple-arrays-simultaneously/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/McNuggets-problem b/Lang/Applesoft-BASIC/McNuggets-problem deleted file mode 120000 index 6db3b9c1b1..0000000000 --- a/Lang/Applesoft-BASIC/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Modular-inverse b/Lang/Applesoft-BASIC/Modular-inverse deleted file mode 120000 index d8b60109c6..0000000000 --- a/Lang/Applesoft-BASIC/Modular-inverse +++ /dev/null @@ -1 +0,0 @@ -../../Task/Modular-inverse/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Monty-Hall-problem b/Lang/Applesoft-BASIC/Monty-Hall-problem deleted file mode 120000 index 6e0ff7bcb9..0000000000 --- a/Lang/Applesoft-BASIC/Monty-Hall-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monty-Hall-problem/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Multi-dimensional-array b/Lang/Applesoft-BASIC/Multi-dimensional-array deleted file mode 120000 index c47a96b8ff..0000000000 --- a/Lang/Applesoft-BASIC/Multi-dimensional-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multi-dimensional-array/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/N-queens-problem b/Lang/Applesoft-BASIC/N-queens-problem deleted file mode 120000 index be2c30d0bc..0000000000 --- a/Lang/Applesoft-BASIC/N-queens-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/N-queens-problem/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Permutations b/Lang/Applesoft-BASIC/Permutations deleted file mode 120000 index 05f071bf7d..0000000000 --- a/Lang/Applesoft-BASIC/Permutations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Phrase-reversals b/Lang/Applesoft-BASIC/Phrase-reversals deleted file mode 120000 index 2fbcdc7099..0000000000 --- a/Lang/Applesoft-BASIC/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Pig-the-dice-game b/Lang/Applesoft-BASIC/Pig-the-dice-game deleted file mode 120000 index 47c16eca5c..0000000000 --- a/Lang/Applesoft-BASIC/Pig-the-dice-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pig-the-dice-game/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Primality-by-trial-division b/Lang/Applesoft-BASIC/Primality-by-trial-division deleted file mode 120000 index 68cfa97935..0000000000 --- a/Lang/Applesoft-BASIC/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Recamans-sequence b/Lang/Applesoft-BASIC/Recamans-sequence deleted file mode 120000 index 1d370af4f0..0000000000 --- a/Lang/Applesoft-BASIC/Recamans-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Recamans-sequence/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Rep-string b/Lang/Applesoft-BASIC/Rep-string deleted file mode 120000 index ba7d92f8da..0000000000 --- a/Lang/Applesoft-BASIC/Rep-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rep-string/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Repeat b/Lang/Applesoft-BASIC/Repeat deleted file mode 120000 index eb0c08d923..0000000000 --- a/Lang/Applesoft-BASIC/Repeat +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Run-length-encoding b/Lang/Applesoft-BASIC/Run-length-encoding deleted file mode 120000 index a4ba69544f..0000000000 --- a/Lang/Applesoft-BASIC/Run-length-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/Run-length-encoding/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Simple-database b/Lang/Applesoft-BASIC/Simple-database deleted file mode 120000 index fdb38917dd..0000000000 --- a/Lang/Applesoft-BASIC/Simple-database +++ /dev/null @@ -1 +0,0 @@ -../../Task/Simple-database/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Sorting-algorithms-Gnome-sort b/Lang/Applesoft-BASIC/Sorting-algorithms-Gnome-sort deleted file mode 120000 index 4b7c42e62c..0000000000 --- a/Lang/Applesoft-BASIC/Sorting-algorithms-Gnome-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Gnome-sort/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/String-interpolation-included- b/Lang/Applesoft-BASIC/String-interpolation-included- deleted file mode 120000 index c235a3fcea..0000000000 --- a/Lang/Applesoft-BASIC/String-interpolation-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-interpolation-included-/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Tau-number b/Lang/Applesoft-BASIC/Tau-number deleted file mode 120000 index de08050f6a..0000000000 --- a/Lang/Applesoft-BASIC/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Towers-of-Hanoi b/Lang/Applesoft-BASIC/Towers-of-Hanoi deleted file mode 120000 index 7e7bc24b30..0000000000 --- a/Lang/Applesoft-BASIC/Towers-of-Hanoi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Towers-of-Hanoi/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/War-card-game b/Lang/Applesoft-BASIC/War-card-game deleted file mode 120000 index 1b7aeabe85..0000000000 --- a/Lang/Applesoft-BASIC/War-card-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/War-card-game/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/00-LANG.txt b/Lang/Aquarius-BASIC/00-LANG.txt index 1314ae0882..787837afb3 100644 --- a/Lang/Aquarius-BASIC/00-LANG.txt +++ b/Lang/Aquarius-BASIC/00-LANG.txt @@ -2,37 +2,4 @@ |exec=interpreted |tags=basic,aquariusbasic }} -{{Implementation|BASIC}}'''Aquarius BASIC''' refers to the more or less stripped-down releases of Microsoft BASIC for the Mattel/Radofin Aquarius, a home computer released in 1983. - -The built-in ROM BASIC was seriously restricted since the system only included 4K of RAM and 8K of ROM by default. Minus the RAM used for video and system management, only about 1.7K of RAM were usable by default; the optionally available Extended Microsoft BASIC that came on ROM cartridge was somewhat more generous, and RAM expansion cartridges were available. - -BASIC lines can be a maximum of 72 characters long. Only the first two characters of a variable name are significant, so e.g. ABC and ABBA will contain the same value: - -10 ABC=3 -20 ABBA=5 -30 PRINT ABC;ABBA -RUN - 5 5 - -The Aquarius features a text-mode screen of 40x25 characters with 16 colors. BASIC only uses 38x24 characters, i.e. the row at the top and the two outermost columns on each side are not accessible when editing, PRINTing, or LISTing. However, all 40x25 characters can be modified via POKEs from BASIC to screen memory. - -Screen character memory starts at 0x3000 (12288); color RAM (with high nibble = foreground color; low nibble = background color) starts at 0x3400 (12288 + 1024 = 13312). Border color can be set by POKEing to the top left character, e.g. POKE 13312,7 will turn the border color to white. BASIC programs start at 0x3901.[https://www.vdsteenoven.com/aquarius/malloc.html] - -BASIC can set and unset 80x72-resolution pixels on the Aquarius with the PSET and PRESET commands (each text character consists of 2x3 pixels). This program for instance draws an ellipsis: -10 PRINT CHR$(11); -20 PI=3.141593 : R=30 -30 FOR I=0 TO 360 -40 X=R*SIN(I*PI/180) -50 Y=R*COS(I*PI/180) -60 PSET(39+X,35+Y) -70 NEXT - -The Aquarius character set cannot be redefined. - -By default, the total space for string variables is only 50 bytes! This can be increased with CLEAR, e.g. CLEAR 200 will reserve 200 bytes for strings. You can check with PRINT FRE("a") how much unused string space is still available. - -Emulators of the Mattel Aquarius include MAME and [https://aquarius.je/aqualite/ AquaLite]. - -==See Also== -* [[wp:Mattel Aquarius|Mattel Aquarius]] at Wikipedia -* [https://archive.org/search?query=mattel+aquarius Aquarius manuals at the Internet Archive] \ No newline at end of file +{{Implementation|BASIC}}'''Aquarius BASIC''' refers to the more or less stripped-down releases of Microsoft BASIC for the Mattel/Radofin Aquarius. The built-in ROM BASIC was seriously restricted since the system only included 4K of RAM and 8K of ROM by default. Minus the RAM used for video and system management, only about 1.7K or RAM were usable by default; the optionally available Extended Microsoft BASIC that came on ROM cartridge was somewhat more generous, and RAM expansion cartridges were available. \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/Archimedean-spiral b/Lang/Aquarius-BASIC/Archimedean-spiral deleted file mode 120000 index a52a300e36..0000000000 --- a/Lang/Aquarius-BASIC/Archimedean-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Archimedean-spiral/Aquarius-BASIC \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/Colour-bars-Display b/Lang/Aquarius-BASIC/Colour-bars-Display deleted file mode 120000 index 5113e0e205..0000000000 --- a/Lang/Aquarius-BASIC/Colour-bars-Display +++ /dev/null @@ -1 +0,0 @@ -../../Task/Colour-bars-Display/Aquarius-BASIC \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/Mandelbrot-set b/Lang/Aquarius-BASIC/Mandelbrot-set deleted file mode 120000 index e078ca10a9..0000000000 --- a/Lang/Aquarius-BASIC/Mandelbrot-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mandelbrot-set/Aquarius-BASIC \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/Matrix-digital-rain b/Lang/Aquarius-BASIC/Matrix-digital-rain deleted file mode 120000 index 227ab761a1..0000000000 --- a/Lang/Aquarius-BASIC/Matrix-digital-rain +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-digital-rain/Aquarius-BASIC \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/Musical-scale b/Lang/Aquarius-BASIC/Musical-scale deleted file mode 120000 index 16fb0326f5..0000000000 --- a/Lang/Aquarius-BASIC/Musical-scale +++ /dev/null @@ -1 +0,0 @@ -../../Task/Musical-scale/Aquarius-BASIC \ No newline at end of file diff --git a/Lang/Aquarius-BASIC/Terminal-control-Display-an-extended-character b/Lang/Aquarius-BASIC/Terminal-control-Display-an-extended-character deleted file mode 120000 index 908e3614b8..0000000000 --- a/Lang/Aquarius-BASIC/Terminal-control-Display-an-extended-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Display-an-extended-character/Aquarius-BASIC \ No newline at end of file diff --git a/Lang/Aria/00-LANG.txt b/Lang/Aria/00-LANG.txt deleted file mode 100644 index f3d1668eba..0000000000 --- a/Lang/Aria/00-LANG.txt +++ /dev/null @@ -1,15 +0,0 @@ -{{language -|exec=interpreted -|site=https://egranata.github.io/aria/ -}} - -Aria is a modern, dynamic scripting language. It is meant to be a “sweet spot” language, easy to pick-up and enjoyable to use. - -It provides a familiar C-style syntax, with a feature set inspired by well-beloved languages such as Python and Rust. It comes with little ceremony and a focus on getting stuff done. - -Aria programs are written as .aria files and passed to the Aria virtual machine, which compiles them down to bytecode and executes them. - -The Aria interpreter is written in Rust, 2024 edition. - -==Todo== -[[Tasks_not_implemented_in_Aria]] \ No newline at end of file diff --git a/Lang/Aria/00-META.yaml b/Lang/Aria/00-META.yaml deleted file mode 100644 index 35ebadd91a..0000000000 --- a/Lang/Aria/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Aria diff --git a/Lang/Aria/99-bottles-of-beer b/Lang/Aria/99-bottles-of-beer deleted file mode 120000 index c2f486227d..0000000000 --- a/Lang/Aria/99-bottles-of-beer +++ /dev/null @@ -1 +0,0 @@ -../../Task/99-bottles-of-beer/Aria \ No newline at end of file diff --git a/Lang/Aria/Hello-world-Text b/Lang/Aria/Hello-world-Text deleted file mode 120000 index bb8e1db7a7..0000000000 --- a/Lang/Aria/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Aria \ No newline at end of file diff --git a/Lang/ArkScript/00-LANG.txt b/Lang/ArkScript/00-LANG.txt deleted file mode 100644 index 11fc16bd5b..0000000000 --- a/Lang/ArkScript/00-LANG.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{language|ArkScript -|exec=bytecode -|site=https://arkscript-lang.dev -|gc=no -|parampass=value -|strength=strong -|checking=dynamic -|tags=arkscript}} -ArkScript is a small, fast, functional and scripting language for C++ projects, inspired by [[Lua]], [[Lisp]], and [[Python]]. - -The language has been designed to be concise, with only 9 keywords, and two rules to parse it: -# the first node after an opening paren ( is a "function", the following nodes are arguments -# the only exception to the previous rule is when defining the argument list of a function - - -(let foo 5) -(let bar "hello world!") - -(let egg (fun (a b c) - (+ a (* b c)))) - -(print (egg 1 foo bar)) - - -The language is also -* small: the core fit under 8000 lines of code ; also small in terms of keywords (only 9) -* a scripting language: very easy to embed it in your projects. Registering your own functions in the language is made easy -* portable: a unique bytecode which can be run everywhere the virtual machine is -* a functional language: every parameter is passed by value, everything is immutable unless specified -* powerful: provides closures and explicit capture -* promoting functionalities before performances: expressiveness often brings more productivity, though performances aren't left behind -* a Lisp inspired language, with fewer parentheses: [...] is expanded to (list ...) and {} to (begin ...) -* extensible: supports C++ module to use it in the language, adding functionalities - - -===Implementation=== -The compiler and VM are implemented in [[C++]] 20. For more details, see [https://github.com/ArkScript-lang/Ark ArkScript GitHub]. - -===License=== -ArkScript is released under the Mozilla Public License 2.0. - -===Todo=== -[[Tasks not implemented in ArkScript]] \ No newline at end of file diff --git a/Lang/ArkScript/00-META.yaml b/Lang/ArkScript/00-META.yaml deleted file mode 100644 index 0a989734f8..0000000000 --- a/Lang/ArkScript/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:ArkScript diff --git a/Lang/ArkScript/100-doors b/Lang/ArkScript/100-doors deleted file mode 120000 index 733c5ecdec..0000000000 --- a/Lang/ArkScript/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/99-bottles-of-beer b/Lang/ArkScript/99-bottles-of-beer deleted file mode 120000 index 44d94215f1..0000000000 --- a/Lang/ArkScript/99-bottles-of-beer +++ /dev/null @@ -1 +0,0 @@ -../../Task/99-bottles-of-beer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/A+B b/Lang/ArkScript/A+B deleted file mode 120000 index 482decfa5a..0000000000 --- a/Lang/ArkScript/A+B +++ /dev/null @@ -1 +0,0 @@ -../../Task/A+B/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Abbreviations-easy b/Lang/ArkScript/Abbreviations-easy deleted file mode 120000 index 03457b23d1..0000000000 --- a/Lang/ArkScript/Abbreviations-easy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-easy/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Ackermann-function b/Lang/ArkScript/Ackermann-function deleted file mode 120000 index f1f525fde6..0000000000 --- a/Lang/ArkScript/Ackermann-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ackermann-function/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Anonymous-recursion b/Lang/ArkScript/Anonymous-recursion deleted file mode 120000 index c2db291cc2..0000000000 --- a/Lang/ArkScript/Anonymous-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anonymous-recursion/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Apply-a-callback-to-an-array b/Lang/ArkScript/Apply-a-callback-to-an-array deleted file mode 120000 index da474aa4d7..0000000000 --- a/Lang/ArkScript/Apply-a-callback-to-an-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Apply-a-callback-to-an-array/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Arithmetic-Complex b/Lang/ArkScript/Arithmetic-Complex deleted file mode 120000 index c21a1d5bf8..0000000000 --- a/Lang/ArkScript/Arithmetic-Complex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Complex/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Arithmetic-Integer b/Lang/ArkScript/Arithmetic-Integer deleted file mode 120000 index 0023796f90..0000000000 --- a/Lang/ArkScript/Arithmetic-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Integer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Array-concatenation b/Lang/ArkScript/Array-concatenation deleted file mode 120000 index 250e35894f..0000000000 --- a/Lang/ArkScript/Array-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-concatenation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Array-length b/Lang/ArkScript/Array-length deleted file mode 120000 index f70d67437b..0000000000 --- a/Lang/ArkScript/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Ascending-primes b/Lang/ArkScript/Ascending-primes deleted file mode 120000 index 9fc34de6f6..0000000000 --- a/Lang/ArkScript/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Associative-array-Creation b/Lang/ArkScript/Associative-array-Creation deleted file mode 120000 index 2a5f3a1e53..0000000000 --- a/Lang/ArkScript/Associative-array-Creation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Creation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Associative-array-Iteration b/Lang/ArkScript/Associative-array-Iteration deleted file mode 120000 index f11b39f9bb..0000000000 --- a/Lang/ArkScript/Associative-array-Iteration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Iteration/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Associative-array-Merging b/Lang/ArkScript/Associative-array-Merging deleted file mode 120000 index 03affb97ec..0000000000 --- a/Lang/ArkScript/Associative-array-Merging +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Merging/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Balanced-brackets b/Lang/ArkScript/Balanced-brackets deleted file mode 120000 index 7380d4a234..0000000000 --- a/Lang/ArkScript/Balanced-brackets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Balanced-brackets/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Boolean-values b/Lang/ArkScript/Boolean-values deleted file mode 120000 index 5efbe13431..0000000000 --- a/Lang/ArkScript/Boolean-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Boolean-values/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Calculating-the-value-of-e b/Lang/ArkScript/Calculating-the-value-of-e deleted file mode 120000 index 0a0116531f..0000000000 --- a/Lang/ArkScript/Calculating-the-value-of-e +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calculating-the-value-of-e/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Call-a-function b/Lang/ArkScript/Call-a-function deleted file mode 120000 index 4d2870d9cb..0000000000 --- a/Lang/ArkScript/Call-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-a-function/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Call-an-object-method b/Lang/ArkScript/Call-an-object-method deleted file mode 120000 index 9b53aa0595..0000000000 --- a/Lang/ArkScript/Call-an-object-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-an-object-method/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Catamorphism b/Lang/ArkScript/Catamorphism deleted file mode 120000 index f6210b0ec4..0000000000 --- a/Lang/ArkScript/Catamorphism +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catamorphism/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Character-codes b/Lang/ArkScript/Character-codes deleted file mode 120000 index fcf79b3e9a..0000000000 --- a/Lang/ArkScript/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Check-that-file-exists b/Lang/ArkScript/Check-that-file-exists deleted file mode 120000 index 7e3651c090..0000000000 --- a/Lang/ArkScript/Check-that-file-exists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-that-file-exists/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Closures-Value-capture b/Lang/ArkScript/Closures-Value-capture deleted file mode 120000 index 6b30a8d976..0000000000 --- a/Lang/ArkScript/Closures-Value-capture +++ /dev/null @@ -1 +0,0 @@ -../../Task/Closures-Value-capture/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Command-line-arguments b/Lang/ArkScript/Command-line-arguments deleted file mode 120000 index 216020915c..0000000000 --- a/Lang/ArkScript/Command-line-arguments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Command-line-arguments/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Comments b/Lang/ArkScript/Comments deleted file mode 120000 index 360a2acb05..0000000000 --- a/Lang/ArkScript/Comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comments/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Compound-data-type b/Lang/ArkScript/Compound-data-type deleted file mode 120000 index a901531424..0000000000 --- a/Lang/ArkScript/Compound-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compound-data-type/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Concurrent-computing b/Lang/ArkScript/Concurrent-computing deleted file mode 120000 index 13a2e9c874..0000000000 --- a/Lang/ArkScript/Concurrent-computing +++ /dev/null @@ -1 +0,0 @@ -../../Task/Concurrent-computing/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Conditional-structures b/Lang/ArkScript/Conditional-structures deleted file mode 120000 index 10a922af53..0000000000 --- a/Lang/ArkScript/Conditional-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conditional-structures/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Conways-Game-of-Life b/Lang/ArkScript/Conways-Game-of-Life deleted file mode 120000 index 2d495d7699..0000000000 --- a/Lang/ArkScript/Conways-Game-of-Life +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conways-Game-of-Life/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Copy-a-string b/Lang/ArkScript/Copy-a-string deleted file mode 120000 index 88194e46fb..0000000000 --- a/Lang/ArkScript/Copy-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Copy-a-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Count-occurrences-of-a-substring b/Lang/ArkScript/Count-occurrences-of-a-substring deleted file mode 120000 index da5c9db0d2..0000000000 --- a/Lang/ArkScript/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Currying b/Lang/ArkScript/Currying deleted file mode 120000 index 68a7b93b42..0000000000 --- a/Lang/ArkScript/Currying +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currying/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Delete-a-file b/Lang/ArkScript/Delete-a-file deleted file mode 120000 index d6dbc3ecd5..0000000000 --- a/Lang/ArkScript/Delete-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Delete-a-file/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Dot-product b/Lang/ArkScript/Dot-product deleted file mode 120000 index 0ee74f8b5a..0000000000 --- a/Lang/ArkScript/Dot-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dot-product/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Empty-directory b/Lang/ArkScript/Empty-directory deleted file mode 120000 index 5ade8a3b8b..0000000000 --- a/Lang/ArkScript/Empty-directory +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-directory/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Empty-program b/Lang/ArkScript/Empty-program deleted file mode 120000 index d33db3e33c..0000000000 --- a/Lang/ArkScript/Empty-program +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-program/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Empty-string b/Lang/ArkScript/Empty-string deleted file mode 120000 index aa29f38546..0000000000 --- a/Lang/ArkScript/Empty-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Enforced-immutability b/Lang/ArkScript/Enforced-immutability deleted file mode 120000 index c12069d86c..0000000000 --- a/Lang/ArkScript/Enforced-immutability +++ /dev/null @@ -1 +0,0 @@ -../../Task/Enforced-immutability/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Even-or-odd b/Lang/ArkScript/Even-or-odd deleted file mode 120000 index 7aee966d84..0000000000 --- a/Lang/ArkScript/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Execute-a-system-command b/Lang/ArkScript/Execute-a-system-command deleted file mode 120000 index ab936f59d4..0000000000 --- a/Lang/ArkScript/Execute-a-system-command +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-a-system-command/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Extend-your-language b/Lang/ArkScript/Extend-your-language deleted file mode 120000 index 08fabf671d..0000000000 --- a/Lang/ArkScript/Extend-your-language +++ /dev/null @@ -1 +0,0 @@ -../../Task/Extend-your-language/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Factorial b/Lang/ArkScript/Factorial deleted file mode 120000 index 270de2c6be..0000000000 --- a/Lang/ArkScript/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Fibonacci-sequence b/Lang/ArkScript/Fibonacci-sequence deleted file mode 120000 index 46f2bbba10..0000000000 --- a/Lang/ArkScript/Fibonacci-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-sequence/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/File-input-output b/Lang/ArkScript/File-input-output deleted file mode 120000 index f2e1e6b1be..0000000000 --- a/Lang/ArkScript/File-input-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-input-output/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Filter b/Lang/ArkScript/Filter deleted file mode 120000 index 51c30a5235..0000000000 --- a/Lang/ArkScript/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/FizzBuzz b/Lang/ArkScript/FizzBuzz deleted file mode 120000 index 2464c5dcce..0000000000 --- a/Lang/ArkScript/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Flatten-a-list b/Lang/ArkScript/Flatten-a-list deleted file mode 120000 index 8540eceb42..0000000000 --- a/Lang/ArkScript/Flatten-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Flatten-a-list/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Function-definition b/Lang/ArkScript/Function-definition deleted file mode 120000 index e750f72eaf..0000000000 --- a/Lang/ArkScript/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Generate-lower-case-ASCII-alphabet b/Lang/ArkScript/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index 9cae72db7e..0000000000 --- a/Lang/ArkScript/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Greatest-element-of-a-list b/Lang/ArkScript/Greatest-element-of-a-list deleted file mode 120000 index d8bc7be88e..0000000000 --- a/Lang/ArkScript/Greatest-element-of-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-element-of-a-list/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Hello-world-Line-printer b/Lang/ArkScript/Hello-world-Line-printer deleted file mode 120000 index 205cc44ef5..0000000000 --- a/Lang/ArkScript/Hello-world-Line-printer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Line-printer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Hello-world-Newline-omission b/Lang/ArkScript/Hello-world-Newline-omission deleted file mode 120000 index e70990b485..0000000000 --- a/Lang/ArkScript/Hello-world-Newline-omission +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newline-omission/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Hello-world-Text b/Lang/ArkScript/Hello-world-Text deleted file mode 120000 index efe7845aa7..0000000000 --- a/Lang/ArkScript/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Include-a-file b/Lang/ArkScript/Include-a-file deleted file mode 120000 index ebb4a807d7..0000000000 --- a/Lang/ArkScript/Include-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Include-a-file/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Infinity b/Lang/ArkScript/Infinity deleted file mode 120000 index e2ef2bf985..0000000000 --- a/Lang/ArkScript/Infinity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Infinity/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Integer-comparison b/Lang/ArkScript/Integer-comparison deleted file mode 120000 index 6396856212..0000000000 --- a/Lang/ArkScript/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Integer-sequence b/Lang/ArkScript/Integer-sequence deleted file mode 120000 index 386017d017..0000000000 --- a/Lang/ArkScript/Integer-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-sequence/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Letter-frequency b/Lang/ArkScript/Letter-frequency deleted file mode 120000 index 5c5906f290..0000000000 --- a/Lang/ArkScript/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Literals-Floating-point b/Lang/ArkScript/Literals-Floating-point deleted file mode 120000 index 5bc172fabe..0000000000 --- a/Lang/ArkScript/Literals-Floating-point +++ /dev/null @@ -1 +0,0 @@ -../../Task/Literals-Floating-point/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Literals-Integer b/Lang/ArkScript/Literals-Integer deleted file mode 120000 index b313b7f803..0000000000 --- a/Lang/ArkScript/Literals-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Literals-Integer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Literals-String b/Lang/ArkScript/Literals-String deleted file mode 120000 index ec507deee1..0000000000 --- a/Lang/ArkScript/Literals-String +++ /dev/null @@ -1 +0,0 @@ -../../Task/Literals-String/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Logical-operations b/Lang/ArkScript/Logical-operations deleted file mode 120000 index aaefe48457..0000000000 --- a/Lang/ArkScript/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Loops-While b/Lang/ArkScript/Loops-While deleted file mode 120000 index 5f0c886bc8..0000000000 --- a/Lang/ArkScript/Loops-While +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-While/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Middle-three-digits b/Lang/ArkScript/Middle-three-digits deleted file mode 120000 index 71c7fc7a98..0000000000 --- a/Lang/ArkScript/Middle-three-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Middle-three-digits/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Munchausen-numbers b/Lang/ArkScript/Munchausen-numbers deleted file mode 120000 index c351968c20..0000000000 --- a/Lang/ArkScript/Munchausen-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munchausen-numbers/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/N-queens-problem b/Lang/ArkScript/N-queens-problem deleted file mode 120000 index e917f9e593..0000000000 --- a/Lang/ArkScript/N-queens-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/N-queens-problem/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Nested-function b/Lang/ArkScript/Nested-function deleted file mode 120000 index 85ce060fae..0000000000 --- a/Lang/ArkScript/Nested-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nested-function/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Null-object b/Lang/ArkScript/Null-object deleted file mode 120000 index a698a2ff71..0000000000 --- a/Lang/ArkScript/Null-object +++ /dev/null @@ -1 +0,0 @@ -../../Task/Null-object/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Pangram-checker b/Lang/ArkScript/Pangram-checker deleted file mode 120000 index db321bb4cb..0000000000 --- a/Lang/ArkScript/Pangram-checker +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pangram-checker/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Pick-random-element b/Lang/ArkScript/Pick-random-element deleted file mode 120000 index be2e5037b3..0000000000 --- a/Lang/ArkScript/Pick-random-element +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pick-random-element/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Program-name b/Lang/ArkScript/Program-name deleted file mode 120000 index c48917f3b8..0000000000 --- a/Lang/ArkScript/Program-name +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-name/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Program-termination b/Lang/ArkScript/Program-termination deleted file mode 120000 index 19d9d120f6..0000000000 --- a/Lang/ArkScript/Program-termination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-termination/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Read-entire-file b/Lang/ArkScript/Read-entire-file deleted file mode 120000 index e3a1c22530..0000000000 --- a/Lang/ArkScript/Read-entire-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-entire-file/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Repeat-a-string b/Lang/ArkScript/Repeat-a-string deleted file mode 120000 index ed7c4e98d3..0000000000 --- a/Lang/ArkScript/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Reverse-a-string b/Lang/ArkScript/Reverse-a-string deleted file mode 120000 index a3a2ea0c27..0000000000 --- a/Lang/ArkScript/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Semordnilap b/Lang/ArkScript/Semordnilap deleted file mode 120000 index 25df93d2d3..0000000000 --- a/Lang/ArkScript/Semordnilap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semordnilap/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Shell-one-liner b/Lang/ArkScript/Shell-one-liner deleted file mode 120000 index 889b436427..0000000000 --- a/Lang/ArkScript/Shell-one-liner +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shell-one-liner/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Short-circuit-evaluation b/Lang/ArkScript/Short-circuit-evaluation deleted file mode 120000 index dcd4ac26ee..0000000000 --- a/Lang/ArkScript/Short-circuit-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Short-circuit-evaluation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Show-ASCII-table b/Lang/ArkScript/Show-ASCII-table deleted file mode 120000 index 65d6365487..0000000000 --- a/Lang/ArkScript/Show-ASCII-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Show-ASCII-table/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sleep b/Lang/ArkScript/Sleep deleted file mode 120000 index cd07cddf41..0000000000 --- a/Lang/ArkScript/Sleep +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleep/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sorting-algorithms-Quicksort b/Lang/ArkScript/Sorting-algorithms-Quicksort deleted file mode 120000 index 003f3fb633..0000000000 --- a/Lang/ArkScript/Sorting-algorithms-Quicksort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Quicksort/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Stack b/Lang/ArkScript/Stack deleted file mode 120000 index f0aa9a05ea..0000000000 --- a/Lang/ArkScript/Stack +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stack/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-append b/Lang/ArkScript/String-append deleted file mode 120000 index ade5a20d23..0000000000 --- a/Lang/ArkScript/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-case b/Lang/ArkScript/String-case deleted file mode 120000 index 25e27a4618..0000000000 --- a/Lang/ArkScript/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-concatenation b/Lang/ArkScript/String-concatenation deleted file mode 120000 index 999b5605f7..0000000000 --- a/Lang/ArkScript/String-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-concatenation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-interpolation-included- b/Lang/ArkScript/String-interpolation-included- deleted file mode 120000 index 33fa86b906..0000000000 --- a/Lang/ArkScript/String-interpolation-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-interpolation-included-/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-length b/Lang/ArkScript/String-length deleted file mode 120000 index df129dcc11..0000000000 --- a/Lang/ArkScript/String-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-length/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-matching b/Lang/ArkScript/String-matching deleted file mode 120000 index 7558bd042a..0000000000 --- a/Lang/ArkScript/String-matching +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-matching/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-prepend b/Lang/ArkScript/String-prepend deleted file mode 120000 index 083b99bbf0..0000000000 --- a/Lang/ArkScript/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-and-product-of-an-array b/Lang/ArkScript/Sum-and-product-of-an-array deleted file mode 120000 index 4c22ecff5f..0000000000 --- a/Lang/ArkScript/Sum-and-product-of-an-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-and-product-of-an-array/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-digits-of-an-integer b/Lang/ArkScript/Sum-digits-of-an-integer deleted file mode 120000 index 29e7afd56c..0000000000 --- a/Lang/ArkScript/Sum-digits-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-digits-of-an-integer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-of-a-series b/Lang/ArkScript/Sum-of-a-series deleted file mode 120000 index f009df3580..0000000000 --- a/Lang/ArkScript/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-of-squares b/Lang/ArkScript/Sum-of-squares deleted file mode 120000 index 85176ac4bb..0000000000 --- a/Lang/ArkScript/Sum-of-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-squares/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Time-a-function b/Lang/ArkScript/Time-a-function deleted file mode 120000 index e2c1f55e22..0000000000 --- a/Lang/ArkScript/Time-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Time-a-function/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/User-input-Text b/Lang/ArkScript/User-input-Text deleted file mode 120000 index f0daf24108..0000000000 --- a/Lang/ArkScript/User-input-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/User-input-Text/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Variables b/Lang/ArkScript/Variables deleted file mode 120000 index f47b9d33ee..0000000000 --- a/Lang/ArkScript/Variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variables/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Write-entire-file b/Lang/ArkScript/Write-entire-file deleted file mode 120000 index 978c98fba7..0000000000 --- a/Lang/ArkScript/Write-entire-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-entire-file/ArkScript \ No newline at end of file diff --git a/Lang/Arturo/00-LANG.txt b/Lang/Arturo/00-LANG.txt index 7424af10da..e01d1ab72c 100644 --- a/Lang/Arturo/00-LANG.txt +++ b/Lang/Arturo/00-LANG.txt @@ -16,8 +16,8 @@ The language has been designed following some very simple and straightforward pr factorial: function [n][ - switch n > 0 -> n * factorial n-1 - -> 1 + if? n > 0 -> n * factorial n-1 + else -> 1 ] loop 1..19 [x]-> diff --git a/Lang/Arturo/Abstract-type b/Lang/Arturo/Abstract-type deleted file mode 120000 index d0cab7a251..0000000000 --- a/Lang/Arturo/Abstract-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abstract-type/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Achilles-numbers b/Lang/Arturo/Achilles-numbers deleted file mode 120000 index 14eecef378..0000000000 --- a/Lang/Arturo/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Arithmetic-derivative b/Lang/Arturo/Arithmetic-derivative deleted file mode 120000 index d1b6630a6c..0000000000 --- a/Lang/Arturo/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Bioinformatics-base-count b/Lang/Arturo/Bioinformatics-base-count new file mode 120000 index 0000000000..6562f48c25 --- /dev/null +++ b/Lang/Arturo/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Bitmap-Bresenhams-line-algorithm b/Lang/Arturo/Bitmap-Bresenhams-line-algorithm deleted file mode 120000 index 903f7d1b02..0000000000 --- a/Lang/Arturo/Bitmap-Bresenhams-line-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Bresenhams-line-algorithm/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Blum-integer b/Lang/Arturo/Blum-integer deleted file mode 120000 index 025a5231e2..0000000000 --- a/Lang/Arturo/Blum-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Blum-integer/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Dice-game-probabilities b/Lang/Arturo/Dice-game-probabilities deleted file mode 120000 index 963933dbf3..0000000000 --- a/Lang/Arturo/Dice-game-probabilities +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dice-game-probabilities/Arturo \ No newline at end of file diff --git a/Lang/Arturo/EKG-sequence-convergence b/Lang/Arturo/EKG-sequence-convergence deleted file mode 120000 index 0753ff65e6..0000000000 --- a/Lang/Arturo/EKG-sequence-convergence +++ /dev/null @@ -1 +0,0 @@ -../../Task/EKG-sequence-convergence/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Element-wise-operations b/Lang/Arturo/Element-wise-operations deleted file mode 120000 index da54867937..0000000000 --- a/Lang/Arturo/Element-wise-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Element-wise-operations/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Entropy-Narcissist b/Lang/Arturo/Entropy-Narcissist deleted file mode 120000 index a5a91d666a..0000000000 --- a/Lang/Arturo/Entropy-Narcissist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy-Narcissist/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Inheritance-Single b/Lang/Arturo/Inheritance-Single deleted file mode 120000 index 9ea196311d..0000000000 --- a/Lang/Arturo/Inheritance-Single +++ /dev/null @@ -1 +0,0 @@ -../../Task/Inheritance-Single/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Magnanimous-numbers b/Lang/Arturo/Magnanimous-numbers deleted file mode 120000 index c058d4081f..0000000000 --- a/Lang/Arturo/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Meissel-Mertens-constant b/Lang/Arturo/Meissel-Mertens-constant new file mode 120000 index 0000000000..a360b321e1 --- /dev/null +++ b/Lang/Arturo/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Munching-squares b/Lang/Arturo/Munching-squares deleted file mode 120000 index 3d1757b680..0000000000 --- a/Lang/Arturo/Munching-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munching-squares/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Number-names b/Lang/Arturo/Number-names deleted file mode 120000 index 0265b7a150..0000000000 --- a/Lang/Arturo/Number-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Number-names/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Palindromic-gapful-numbers b/Lang/Arturo/Palindromic-gapful-numbers deleted file mode 120000 index bb7c640247..0000000000 --- a/Lang/Arturo/Palindromic-gapful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindromic-gapful-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Quaternion-type b/Lang/Arturo/Quaternion-type new file mode 120000 index 0000000000..b96cba3183 --- /dev/null +++ b/Lang/Arturo/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Radical-of-an-integer b/Lang/Arturo/Radical-of-an-integer deleted file mode 120000 index 0b80f4a924..0000000000 --- a/Lang/Arturo/Radical-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Radical-of-an-integer/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Reflection-List-methods b/Lang/Arturo/Reflection-List-methods deleted file mode 120000 index b2c29c2e7a..0000000000 --- a/Lang/Arturo/Reflection-List-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reflection-List-methods/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Rosetta-Code-Find-unimplemented-tasks b/Lang/Arturo/Rosetta-Code-Find-unimplemented-tasks deleted file mode 120000 index 6c58da52bd..0000000000 --- a/Lang/Arturo/Rosetta-Code-Find-unimplemented-tasks +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rosetta-Code-Find-unimplemented-tasks/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Sorting-Algorithms-Circle-Sort b/Lang/Arturo/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..fc98e0e878 --- /dev/null +++ b/Lang/Arturo/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Spelling-of-ordinal-numbers b/Lang/Arturo/Spelling-of-ordinal-numbers deleted file mode 120000 index 0d47ac2434..0000000000 --- a/Lang/Arturo/Spelling-of-ordinal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Spelling-of-ordinal-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Super-d-numbers b/Lang/Arturo/Super-d-numbers deleted file mode 120000 index 9c8b511c5d..0000000000 --- a/Lang/Arturo/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Taxicab-numbers b/Lang/Arturo/Taxicab-numbers deleted file mode 120000 index 9c84413e59..0000000000 --- a/Lang/Arturo/Taxicab-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Taxicab-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Weird-numbers b/Lang/Arturo/Weird-numbers deleted file mode 120000 index 2f062bea69..0000000000 --- a/Lang/Arturo/Weird-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Weird-numbers/Arturo \ No newline at end of file diff --git a/Lang/Arturo/Zumkeller-numbers b/Lang/Arturo/Zumkeller-numbers deleted file mode 120000 index b956d7f399..0000000000 --- a/Lang/Arturo/Zumkeller-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zumkeller-numbers/Arturo \ No newline at end of file diff --git a/Lang/AsciiDots/Quine b/Lang/AsciiDots/Quine deleted file mode 120000 index c2090631eb..0000000000 --- a/Lang/AsciiDots/Quine +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quine/AsciiDots \ No newline at end of file diff --git a/Lang/AsciiDots/Write-language-name-in-3D-ASCII b/Lang/AsciiDots/Write-language-name-in-3D-ASCII deleted file mode 120000 index 81b3e17bd1..0000000000 --- a/Lang/AsciiDots/Write-language-name-in-3D-ASCII +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-language-name-in-3D-ASCII/AsciiDots \ No newline at end of file diff --git a/Lang/Asymptote/Array-length b/Lang/Asymptote/Array-length deleted file mode 120000 index 017bab2099..0000000000 --- a/Lang/Asymptote/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Day-of-the-week b/Lang/Asymptote/Day-of-the-week deleted file mode 120000 index f31fd61474..0000000000 --- a/Lang/Asymptote/Day-of-the-week +++ /dev/null @@ -1 +0,0 @@ -../../Task/Day-of-the-week/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Determine-sentence-type b/Lang/Asymptote/Determine-sentence-type deleted file mode 120000 index 250fb5d120..0000000000 --- a/Lang/Asymptote/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Diversity-prediction-theorem b/Lang/Asymptote/Diversity-prediction-theorem deleted file mode 120000 index 4b9f736bd3..0000000000 --- a/Lang/Asymptote/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Empty-program b/Lang/Asymptote/Empty-program new file mode 120000 index 0000000000..5636b8fc49 --- /dev/null +++ b/Lang/Asymptote/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Evaluate-binomial-coefficients b/Lang/Asymptote/Evaluate-binomial-coefficients deleted file mode 120000 index 8408c303d7..0000000000 --- a/Lang/Asymptote/Evaluate-binomial-coefficients +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evaluate-binomial-coefficients/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Factorial b/Lang/Asymptote/Factorial deleted file mode 120000 index f41eae64eb..0000000000 --- a/Lang/Asymptote/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Hello-world-Newline-omission b/Lang/Asymptote/Hello-world-Newline-omission deleted file mode 120000 index 1f04f08bd4..0000000000 --- a/Lang/Asymptote/Hello-world-Newline-omission +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newline-omission/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Jensens-Device b/Lang/Asymptote/Jensens-Device deleted file mode 120000 index 621c474cd7..0000000000 --- a/Lang/Asymptote/Jensens-Device +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jensens-Device/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Leonardo-numbers b/Lang/Asymptote/Leonardo-numbers deleted file mode 120000 index 53f9861f22..0000000000 --- a/Lang/Asymptote/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Loops-Infinite b/Lang/Asymptote/Loops-Infinite deleted file mode 120000 index 0aa1840fd7..0000000000 --- a/Lang/Asymptote/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Map-range b/Lang/Asymptote/Map-range deleted file mode 120000 index 249d69a043..0000000000 --- a/Lang/Asymptote/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/McNuggets-problem b/Lang/Asymptote/McNuggets-problem deleted file mode 120000 index 3a4a3bc974..0000000000 --- a/Lang/Asymptote/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Pancake-numbers b/Lang/Asymptote/Pancake-numbers deleted file mode 120000 index de9f5cf18c..0000000000 --- a/Lang/Asymptote/Pancake-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pancake-numbers/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Primality-by-trial-division b/Lang/Asymptote/Primality-by-trial-division deleted file mode 120000 index 0cfaa74cf3..0000000000 --- a/Lang/Asymptote/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Repeat b/Lang/Asymptote/Repeat deleted file mode 120000 index 03b0740c45..0000000000 --- a/Lang/Asymptote/Repeat +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Sudan-function b/Lang/Asymptote/Sudan-function deleted file mode 120000 index 97eca50473..0000000000 --- a/Lang/Asymptote/Sudan-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sudan-function/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Tau-function b/Lang/Asymptote/Tau-function deleted file mode 120000 index f822d893d8..0000000000 --- a/Lang/Asymptote/Tau-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-function/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Tau-number b/Lang/Asymptote/Tau-number deleted file mode 120000 index e9ae14e606..0000000000 --- a/Lang/Asymptote/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Temperature-conversion b/Lang/Asymptote/Temperature-conversion deleted file mode 120000 index f7d5a1158d..0000000000 --- a/Lang/Asymptote/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Towers-of-Hanoi b/Lang/Asymptote/Towers-of-Hanoi deleted file mode 120000 index 62a6e4d923..0000000000 --- a/Lang/Asymptote/Towers-of-Hanoi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Towers-of-Hanoi/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Twos-complement b/Lang/Asymptote/Twos-complement deleted file mode 120000 index a487252d4a..0000000000 --- a/Lang/Asymptote/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/Asymptote \ No newline at end of file diff --git a/Lang/Atari-BASIC/00-LANG.txt b/Lang/Atari-BASIC/00-LANG.txt index f0ee8029ec..233d214413 100644 --- a/Lang/Atari-BASIC/00-LANG.txt +++ b/Lang/Atari-BASIC/00-LANG.txt @@ -3,23 +3,6 @@ |tags=basic,ataribasic }} {{Implementation|BASIC}} -'''Atari BASIC''' refers to the BASIC that shipped with Atari 8-bit micros. Revision A was released on cartridge for early models like the Atari 400 and 800 (1979), while revision B was included in ROM on later models such as the 800XL (1983). (Revision A is considered superior because revision B has more bugs!) Revision C was released on cartridge to address the bugs introduced in revision B. It was also in ROM on later 800XL computers and the XE range. +'''Atari BASIC''' refers to the BASIC that shipped with Atari 8-bit micros. -Emulators for Atari 8-bit computers include: -*[https://atari800.github.io/ Atari800] (Windows, Mac, Linux, etc.) -*[https://www.virtualdub.org/altirra.html Altirra] (Windows) - -Downloading the original Atari ROMs is not necessary for Atari800 or Altirra because they include the open source Altirra ROMs, which also feature Altirra BASIC, a fully compatible replacement for Atari BASIC. Altirra BASIC and OS are also better optimized than the original Atari ROMs; especially FOR loops and floating point functions are much quicker. - -To start Atari800 in BASIC mode, run it as atari800 -basic. Some important keys in Atari800 are F1=Settings, F5=Reset, F7=Break, F9=Quit, F10=Screenshot; see [https://github.com/atari800/atari800/blob/master/DOC/USAGE DOC/USAGE] for more. Lowercase characters in strings can be entered by first pressing Caps Lock in Atari800. - -In Atari800, folders on the host computer can be mounted in ''Emulator Configuration ⇨ Host Device Settings'', so then you can e.g. use LOAD "H1:MYPROG.BAS" to load a program from local disk. By default, folders are mounted read-only. - -BASIC programs in tokenized form are loaded and saved with LOAD and SAVE; in ASCII/ATASCII format you load them with ENTER and save them with LIST, e.g. LIST “H1:PROGRAM.LST”. - -After 9 minutes of inactivity, a screen saver (called attract mode by Atari) will activate and cycle colors. This can be stopped by an occasional POKE 77,0 to reset the timer. - -Like in Palo Alto Tiny BASIC, commands can be abbreviated by their first (unique) letters and a period, e.g. L. for LIST or GR. for GRAPHICS. - -==See Also== -*[https://en.wikipedia.org/wiki/Atari_BASIC Atari BASIC] in Wikipedia \ No newline at end of file +See Wikipedia: https://en.wikipedia.org/wiki/Atari_BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Archimedean-spiral b/Lang/Atari-BASIC/Archimedean-spiral deleted file mode 120000 index 3e75563330..0000000000 --- a/Lang/Atari-BASIC/Archimedean-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Archimedean-spiral/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Chaos-game b/Lang/Atari-BASIC/Chaos-game deleted file mode 120000 index f88e0f8ada..0000000000 --- a/Lang/Atari-BASIC/Chaos-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaos-game/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Color-of-a-screen-pixel b/Lang/Atari-BASIC/Color-of-a-screen-pixel deleted file mode 120000 index b097621245..0000000000 --- a/Lang/Atari-BASIC/Color-of-a-screen-pixel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Color-of-a-screen-pixel/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Colour-bars-Display b/Lang/Atari-BASIC/Colour-bars-Display deleted file mode 120000 index 03db8dce96..0000000000 --- a/Lang/Atari-BASIC/Colour-bars-Display +++ /dev/null @@ -1 +0,0 @@ -../../Task/Colour-bars-Display/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Draw-a-clock b/Lang/Atari-BASIC/Draw-a-clock deleted file mode 120000 index f8dd467da4..0000000000 --- a/Lang/Atari-BASIC/Draw-a-clock +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-clock/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Hello-world-Text b/Lang/Atari-BASIC/Hello-world-Text deleted file mode 120000 index 27f2cf112b..0000000000 --- a/Lang/Atari-BASIC/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Mandelbrot-set b/Lang/Atari-BASIC/Mandelbrot-set deleted file mode 120000 index 45e66ccff0..0000000000 --- a/Lang/Atari-BASIC/Mandelbrot-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mandelbrot-set/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Musical-scale b/Lang/Atari-BASIC/Musical-scale deleted file mode 120000 index b870e25059..0000000000 --- a/Lang/Atari-BASIC/Musical-scale +++ /dev/null @@ -1 +0,0 @@ -../../Task/Musical-scale/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Pi b/Lang/Atari-BASIC/Pi deleted file mode 120000 index b081cc7024..0000000000 --- a/Lang/Atari-BASIC/Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pi/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Random-number-generator-device- b/Lang/Atari-BASIC/Random-number-generator-device- deleted file mode 120000 index bc35b665ee..0000000000 --- a/Lang/Atari-BASIC/Random-number-generator-device- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-number-generator-device-/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Reverse-a-string b/Lang/Atari-BASIC/Reverse-a-string deleted file mode 120000 index c2ff7e214b..0000000000 --- a/Lang/Atari-BASIC/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/System-time b/Lang/Atari-BASIC/System-time deleted file mode 120000 index c4df1e6a39..0000000000 --- a/Lang/Atari-BASIC/System-time +++ /dev/null @@ -1 +0,0 @@ -../../Task/System-time/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Terminal-control-Hiding-the-cursor b/Lang/Atari-BASIC/Terminal-control-Hiding-the-cursor deleted file mode 120000 index 78972a34b6..0000000000 --- a/Lang/Atari-BASIC/Terminal-control-Hiding-the-cursor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Hiding-the-cursor/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Terminal-control-Inverse-video b/Lang/Atari-BASIC/Terminal-control-Inverse-video deleted file mode 120000 index 8c57f75946..0000000000 --- a/Lang/Atari-BASIC/Terminal-control-Inverse-video +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Inverse-video/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Terminal-control-Positional-read b/Lang/Atari-BASIC/Terminal-control-Positional-read deleted file mode 120000 index a0575b2278..0000000000 --- a/Lang/Atari-BASIC/Terminal-control-Positional-read +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Positional-read/Atari-BASIC \ No newline at end of file diff --git a/Lang/Atari-BASIC/Terminal-control-Ringing-the-terminal-bell b/Lang/Atari-BASIC/Terminal-control-Ringing-the-terminal-bell deleted file mode 120000 index 3666cabb9e..0000000000 --- a/Lang/Atari-BASIC/Terminal-control-Ringing-the-terminal-bell +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Ringing-the-terminal-bell/Atari-BASIC \ No newline at end of file diff --git a/Lang/AutoHotKey-V2/00-LANG.txt b/Lang/AutoHotKey-V2/00-LANG.txt deleted file mode 100644 index a333f928af..0000000000 --- a/Lang/AutoHotKey-V2/00-LANG.txt +++ /dev/null @@ -1 +0,0 @@ -{{stub}}{{language|AutoHotKey V2}} \ No newline at end of file diff --git a/Lang/AutoHotKey-V2/00-META.yaml b/Lang/AutoHotKey-V2/00-META.yaml deleted file mode 100644 index 316ebe0ccb..0000000000 --- a/Lang/AutoHotKey-V2/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:AutoHotKey_V2 diff --git a/Lang/AutoHotKey-V2/Hello-world-Graphical b/Lang/AutoHotKey-V2/Hello-world-Graphical deleted file mode 120000 index 89783bc714..0000000000 --- a/Lang/AutoHotKey-V2/Hello-world-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Graphical/AutoHotKey-V2 \ No newline at end of file diff --git a/Lang/AutoHotkey/ASCII-art-diagram-converter b/Lang/AutoHotkey/ASCII-art-diagram-converter deleted file mode 120000 index fe014a6bf3..0000000000 --- a/Lang/AutoHotkey/ASCII-art-diagram-converter +++ /dev/null @@ -1 +0,0 @@ -../../Task/ASCII-art-diagram-converter/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Miller-Rabin-primality-test b/Lang/AutoHotkey/Miller-Rabin-primality-test new file mode 120000 index 0000000000..518dd6b131 --- /dev/null +++ b/Lang/AutoHotkey/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Quaternion-type b/Lang/AutoHotkey/Quaternion-type new file mode 120000 index 0000000000..00a1a5a068 --- /dev/null +++ b/Lang/AutoHotkey/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Sorting-Algorithms-Circle-Sort b/Lang/AutoHotkey/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..975740b1fa --- /dev/null +++ b/Lang/AutoHotkey/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoLISP/100-doors b/Lang/AutoLISP/100-doors deleted file mode 120000 index 4d97a8a5d6..0000000000 --- a/Lang/AutoLISP/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Babbage-problem b/Lang/AutoLISP/Babbage-problem deleted file mode 120000 index 0ae3941c82..0000000000 --- a/Lang/AutoLISP/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Balanced-brackets b/Lang/AutoLISP/Balanced-brackets deleted file mode 120000 index b752cfc1d6..0000000000 --- a/Lang/AutoLISP/Balanced-brackets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Balanced-brackets/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Entropy b/Lang/AutoLISP/Entropy deleted file mode 120000 index bc1dec235f..0000000000 --- a/Lang/AutoLISP/Entropy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Entropy-Narcissist b/Lang/AutoLISP/Entropy-Narcissist deleted file mode 120000 index 0a143c87ce..0000000000 --- a/Lang/AutoLISP/Entropy-Narcissist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy-Narcissist/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Environment-variables b/Lang/AutoLISP/Environment-variables deleted file mode 120000 index cc9ceec1ff..0000000000 --- a/Lang/AutoLISP/Environment-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Environment-variables/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Largest-proper-divisor-of-n b/Lang/AutoLISP/Largest-proper-divisor-of-n deleted file mode 120000 index 48c08fae1a..0000000000 --- a/Lang/AutoLISP/Largest-proper-divisor-of-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-proper-divisor-of-n/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/The-Twelve-Days-of-Christmas b/Lang/AutoLISP/The-Twelve-Days-of-Christmas deleted file mode 120000 index 3dd7563b0d..0000000000 --- a/Lang/AutoLISP/The-Twelve-Days-of-Christmas +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-Twelve-Days-of-Christmas/AutoLISP \ No newline at end of file diff --git a/Lang/Axiom/Quaternion-type b/Lang/Axiom/Quaternion-type new file mode 120000 index 0000000000..483576377a --- /dev/null +++ b/Lang/Axiom/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Axiom \ No newline at end of file diff --git a/Lang/BASIC/00-LANG.txt b/Lang/BASIC/00-LANG.txt index ddee550d0d..7299250982 100644 --- a/Lang/BASIC/00-LANG.txt +++ b/Lang/BASIC/00-LANG.txt @@ -12,56 +12,18 @@ BASIC became popular, with many different implementations for various computers. ==Links== *[[wp:BASIC|Wikipedia:BASIC]] -**[[wp:ASIC]] -**[[wp:Atari BASIC]] -**[[wp:BASIC-PLUS]] -**[[wp:Basic-256]] -**[[wp:Batari BASIC]] -**[[wp:BBC BASIC]] -**[[wp:Benton Harbor BASIC]] -**[[wp:Beta BASIC]] -**[[wp:CBASIC]] **[[wp:Chipmunk Basic]] -**[[wp:DarkBASIC]] -**[[wp:Dartmouth BASIC]] -**[[wp:FreeBASIC]] -**[[wp:FutureBASIC]] -**[[wp:GFA BASIC]] -**[[wp:GLBasic]] -**[[wp:Integer BASIC]] -**[[wp:Liberty BASIC]] -**[[wp:Locomotive BASIC]] **[[wp:Microsoft BASIC]] ***[[wp:Altair BASIC]] ***[[wp:Amiga BASIC]] ***[[wp:Applesoft BASIC]] ***[[wp:Atari Microsoft BASIC]] ***[[wp:Commodore BASIC]] -***[[wp:Extended Color BASIC]] ***[[wp:IBM BASIC]] -***[[wp:MS BASIC for Macintosh]] -***[[wp:MSX BASIC]] -***[[wp:Small Basic]] -***[[wp:QBasic]] -***[[wp:QuickBASIC]]‎ -***[[wp:TRS-80 Level II BASIC]] -***[[wp:Visual Basic‎]] +***[[wp:TRS-80 Level II BASIC ]] **[[wp:PowerBASIC]] **[[wp:PureBasic]] -**[[wp:QB64‎]] -**[[wp:Quite BASIC]]‎ -**[[wp:RapidQ]] -**[[wp:Realbasic]] **[[wp:Rocky Mountain BASIC]] -**[[wp:Run BASIC]] -**[[wp:S-BASIC]] -**[[wp:ScriptBasic]] -**[[wp:Sinclair BASIC]] -**[[wp:SmileBASIC‎]] **[[wp:SuperBASIC]] -**[[wp:TI BASIC (TI 99/4A)]] -**[[wp:Tiny BASIC‎]] **[[wp:True BASIC]] -**[[wp:UBASIC]] -**[[wp:Yabasic]] {{language programming paradigm|Procedural}} \ No newline at end of file diff --git a/Lang/BASIC/Abundant-deficient-and-perfect-number-classifications b/Lang/BASIC/Abundant-deficient-and-perfect-number-classifications new file mode 120000 index 0000000000..732a066bdf --- /dev/null +++ b/Lang/BASIC/Abundant-deficient-and-perfect-number-classifications @@ -0,0 +1 @@ +../../Task/Abundant-deficient-and-perfect-number-classifications/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Arithmetic-derivative b/Lang/BASIC/Arithmetic-derivative deleted file mode 120000 index 25cf9a8b6a..0000000000 --- a/Lang/BASIC/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Case-sensitivity-of-identifiers b/Lang/BASIC/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..e8b0ce1495 --- /dev/null +++ b/Lang/BASIC/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Chaocipher b/Lang/BASIC/Chaocipher deleted file mode 120000 index 634a8f59a4..0000000000 --- a/Lang/BASIC/Chaocipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaocipher/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Damm-algorithm b/Lang/BASIC/Damm-algorithm new file mode 120000 index 0000000000..41ee6d1c36 --- /dev/null +++ b/Lang/BASIC/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Determine-if-a-string-is-collapsible b/Lang/BASIC/Determine-if-a-string-is-collapsible new file mode 120000 index 0000000000..87084a2029 --- /dev/null +++ b/Lang/BASIC/Determine-if-a-string-is-collapsible @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-collapsible/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Ethiopian-multiplication b/Lang/BASIC/Ethiopian-multiplication new file mode 120000 index 0000000000..94be458bb2 --- /dev/null +++ b/Lang/BASIC/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Function-definition b/Lang/BASIC/Function-definition new file mode 120000 index 0000000000..a052c63292 --- /dev/null +++ b/Lang/BASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Gray-code b/Lang/BASIC/Gray-code new file mode 120000 index 0000000000..f0bc6f352f --- /dev/null +++ b/Lang/BASIC/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Longest-string-challenge b/Lang/BASIC/Longest-string-challenge new file mode 120000 index 0000000000..739abebd3a --- /dev/null +++ b/Lang/BASIC/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Magnanimous-numbers b/Lang/BASIC/Magnanimous-numbers deleted file mode 120000 index 9eb654340c..0000000000 --- a/Lang/BASIC/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Mayan-numerals b/Lang/BASIC/Mayan-numerals new file mode 120000 index 0000000000..ae24d05061 --- /dev/null +++ b/Lang/BASIC/Mayan-numerals @@ -0,0 +1 @@ +../../Task/Mayan-numerals/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Monty-Hall-problem b/Lang/BASIC/Monty-Hall-problem new file mode 120000 index 0000000000..ba5a5a279d --- /dev/null +++ b/Lang/BASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Move-to-front-algorithm b/Lang/BASIC/Move-to-front-algorithm deleted file mode 120000 index a9f8d4df7e..0000000000 --- a/Lang/BASIC/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/BASIC \ No newline at end of file diff --git a/Lang/BASIC/One-dimensional-cellular-automata b/Lang/BASIC/One-dimensional-cellular-automata new file mode 120000 index 0000000000..91d5b5ff5e --- /dev/null +++ b/Lang/BASIC/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Ordered-words b/Lang/BASIC/Ordered-words deleted file mode 120000 index dd2f98d4e6..0000000000 --- a/Lang/BASIC/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Partition-an-integer-x-into-n-primes b/Lang/BASIC/Partition-an-integer-x-into-n-primes deleted file mode 120000 index 8db316776d..0000000000 --- a/Lang/BASIC/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Reverse-a-string b/Lang/BASIC/Reverse-a-string new file mode 120000 index 0000000000..db5bd211b7 --- /dev/null +++ b/Lang/BASIC/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Rot-13 b/Lang/BASIC/Rot-13 new file mode 120000 index 0000000000..37a240fe69 --- /dev/null +++ b/Lang/BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Sorting-algorithms-Gnome-sort b/Lang/BASIC/Sorting-algorithms-Gnome-sort new file mode 120000 index 0000000000..ce27855f21 --- /dev/null +++ b/Lang/BASIC/Sorting-algorithms-Gnome-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Gnome-sort/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Sorting-algorithms-Quicksort b/Lang/BASIC/Sorting-algorithms-Quicksort new file mode 120000 index 0000000000..f7976ecb9f --- /dev/null +++ b/Lang/BASIC/Sorting-algorithms-Quicksort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Quicksort/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Temperature-conversion b/Lang/BASIC/Temperature-conversion new file mode 120000 index 0000000000..21182b0539 --- /dev/null +++ b/Lang/BASIC/Temperature-conversion @@ -0,0 +1 @@ +../../Task/Temperature-conversion/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Totient-function b/Lang/BASIC/Totient-function deleted file mode 120000 index fc7748e2f4..0000000000 --- a/Lang/BASIC/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/BASIC \ No newline at end of file diff --git a/Lang/BASIC256/21-game b/Lang/BASIC256/21-game deleted file mode 120000 index 6c7c8089e2..0000000000 --- a/Lang/BASIC256/21-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/21-game/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Abundant-deficient-and-perfect-number-classifications b/Lang/BASIC256/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index 8290029269..0000000000 --- a/Lang/BASIC256/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Achilles-numbers b/Lang/BASIC256/Achilles-numbers deleted file mode 120000 index 13d43c8909..0000000000 --- a/Lang/BASIC256/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Associative-array-Merging b/Lang/BASIC256/Associative-array-Merging deleted file mode 120000 index 20bef5368f..0000000000 --- a/Lang/BASIC256/Associative-array-Merging +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Merging/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Benfords-law b/Lang/BASIC256/Benfords-law deleted file mode 120000 index adf7036425..0000000000 --- a/Lang/BASIC256/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Blum-integer b/Lang/BASIC256/Blum-integer deleted file mode 120000 index 6114c8c1bc..0000000000 --- a/Lang/BASIC256/Blum-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Blum-integer/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Cartesian-product-of-two-or-more-lists b/Lang/BASIC256/Cartesian-product-of-two-or-more-lists deleted file mode 120000 index 4e3c13585b..0000000000 --- a/Lang/BASIC256/Cartesian-product-of-two-or-more-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cartesian-product-of-two-or-more-lists/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Casting-out-nines b/Lang/BASIC256/Casting-out-nines deleted file mode 120000 index 670ea3d048..0000000000 --- a/Lang/BASIC256/Casting-out-nines +++ /dev/null @@ -1 +0,0 @@ -../../Task/Casting-out-nines/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Damm-algorithm b/Lang/BASIC256/Damm-algorithm deleted file mode 120000 index 9a4557a341..0000000000 --- a/Lang/BASIC256/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Determine-if-a-string-has-all-the-same-characters b/Lang/BASIC256/Determine-if-a-string-has-all-the-same-characters deleted file mode 120000 index 0fc88a3804..0000000000 --- a/Lang/BASIC256/Determine-if-a-string-has-all-the-same-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-the-same-characters/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Determine-if-a-string-has-all-unique-characters b/Lang/BASIC256/Determine-if-a-string-has-all-unique-characters deleted file mode 120000 index 134627daea..0000000000 --- a/Lang/BASIC256/Determine-if-a-string-has-all-unique-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-unique-characters/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Determine-sentence-type b/Lang/BASIC256/Determine-sentence-type deleted file mode 120000 index 6be21d3753..0000000000 --- a/Lang/BASIC256/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Digital-root b/Lang/BASIC256/Digital-root deleted file mode 120000 index 499e6c27a3..0000000000 --- a/Lang/BASIC256/Digital-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Digital-root/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Eban-numbers b/Lang/BASIC256/Eban-numbers deleted file mode 120000 index cc54b44b18..0000000000 --- a/Lang/BASIC256/Eban-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eban-numbers/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Empty-program b/Lang/BASIC256/Empty-program new file mode 120000 index 0000000000..163b273495 --- /dev/null +++ b/Lang/BASIC256/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Equal-prime-and-composite-sums b/Lang/BASIC256/Equal-prime-and-composite-sums deleted file mode 120000 index 187242266b..0000000000 --- a/Lang/BASIC256/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Euler-method b/Lang/BASIC256/Euler-method deleted file mode 120000 index a14c38eb6c..0000000000 --- a/Lang/BASIC256/Euler-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euler-method/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Evaluate-binomial-coefficients b/Lang/BASIC256/Evaluate-binomial-coefficients deleted file mode 120000 index 415fd5e54e..0000000000 --- a/Lang/BASIC256/Evaluate-binomial-coefficients +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evaluate-binomial-coefficients/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Goldbachs-comet b/Lang/BASIC256/Goldbachs-comet deleted file mode 120000 index 6a3eabcffe..0000000000 --- a/Lang/BASIC256/Goldbachs-comet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Goldbachs-comet/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Kronecker-product b/Lang/BASIC256/Kronecker-product deleted file mode 120000 index dd258524fe..0000000000 --- a/Lang/BASIC256/Kronecker-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kronecker-product/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Longest-string-challenge b/Lang/BASIC256/Longest-string-challenge deleted file mode 120000 index 46b7ee20d4..0000000000 --- a/Lang/BASIC256/Longest-string-challenge +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-string-challenge/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/McNuggets-problem b/Lang/BASIC256/McNuggets-problem deleted file mode 120000 index 9fb9d7be2d..0000000000 --- a/Lang/BASIC256/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Meissel-Mertens-constant b/Lang/BASIC256/Meissel-Mertens-constant new file mode 120000 index 0000000000..6ff8d02267 --- /dev/null +++ b/Lang/BASIC256/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Middle-three-digits b/Lang/BASIC256/Middle-three-digits deleted file mode 120000 index a8c1d6ac74..0000000000 --- a/Lang/BASIC256/Middle-three-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Middle-three-digits/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Multiple-regression b/Lang/BASIC256/Multiple-regression deleted file mode 120000 index 4d8b79e98b..0000000000 --- a/Lang/BASIC256/Multiple-regression +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multiple-regression/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Nested-templated-data b/Lang/BASIC256/Nested-templated-data deleted file mode 120000 index f5ddb43f39..0000000000 --- a/Lang/BASIC256/Nested-templated-data +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nested-templated-data/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Number-names b/Lang/BASIC256/Number-names deleted file mode 120000 index ba5d524763..0000000000 --- a/Lang/BASIC256/Number-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Number-names/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Padovan-n-step-number-sequences b/Lang/BASIC256/Padovan-n-step-number-sequences deleted file mode 120000 index 96835908bd..0000000000 --- a/Lang/BASIC256/Padovan-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Padovan-n-step-number-sequences/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Phrase-reversals b/Lang/BASIC256/Phrase-reversals deleted file mode 120000 index 7bce29f023..0000000000 --- a/Lang/BASIC256/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Pythagorean-triples b/Lang/BASIC256/Pythagorean-triples deleted file mode 120000 index 0ded5bc54d..0000000000 --- a/Lang/BASIC256/Pythagorean-triples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagorean-triples/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Quaternion-type b/Lang/BASIC256/Quaternion-type new file mode 120000 index 0000000000..ecfff3f315 --- /dev/null +++ b/Lang/BASIC256/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification b/Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification deleted file mode 120000 index 9a890661d4..0000000000 --- a/Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ramer-Douglas-Peucker-line-simplification/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sailors-coconuts-and-a-monkey-problem b/Lang/BASIC256/Sailors-coconuts-and-a-monkey-problem deleted file mode 120000 index 3cfdfb5740..0000000000 --- a/Lang/BASIC256/Sailors-coconuts-and-a-monkey-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sailors-coconuts-and-a-monkey-problem/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors b/Lang/BASIC256/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors deleted file mode 120000 index 1cfd728c9c..0000000000 --- a/Lang/BASIC256/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sequence:-smallest-number-with-exactly-n-divisors b/Lang/BASIC256/Sequence:-smallest-number-with-exactly-n-divisors deleted file mode 120000 index f838adf5dc..0000000000 --- a/Lang/BASIC256/Sequence:-smallest-number-with-exactly-n-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence:-smallest-number-with-exactly-n-divisors/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Set-consolidation b/Lang/BASIC256/Set-consolidation deleted file mode 120000 index 720cdf3ec0..0000000000 --- a/Lang/BASIC256/Set-consolidation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-consolidation/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sexy-primes b/Lang/BASIC256/Sexy-primes deleted file mode 120000 index 86fc0a12b9..0000000000 --- a/Lang/BASIC256/Sexy-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sexy-primes/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sieve-of-Pritchard b/Lang/BASIC256/Sieve-of-Pritchard deleted file mode 120000 index 266a24b469..0000000000 --- a/Lang/BASIC256/Sieve-of-Pritchard +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Pritchard/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sort-disjoint-sublist b/Lang/BASIC256/Sort-disjoint-sublist deleted file mode 120000 index 4422d7b840..0000000000 --- a/Lang/BASIC256/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sorting-algorithms-Bogosort b/Lang/BASIC256/Sorting-algorithms-Bogosort deleted file mode 120000 index 30a3f4e141..0000000000 --- a/Lang/BASIC256/Sorting-algorithms-Bogosort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bogosort/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sorting-algorithms-Gnome-sort b/Lang/BASIC256/Sorting-algorithms-Gnome-sort deleted file mode 120000 index c4bf6071a8..0000000000 --- a/Lang/BASIC256/Sorting-algorithms-Gnome-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Gnome-sort/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Subleq b/Lang/BASIC256/Subleq deleted file mode 120000 index 1129f78a82..0000000000 --- a/Lang/BASIC256/Subleq +++ /dev/null @@ -1 +0,0 @@ -../../Task/Subleq/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sum-and-product-puzzle b/Lang/BASIC256/Sum-and-product-puzzle deleted file mode 120000 index 2b964ccfbc..0000000000 --- a/Lang/BASIC256/Sum-and-product-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-and-product-puzzle/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Table-creation-Postal-addresses b/Lang/BASIC256/Table-creation-Postal-addresses deleted file mode 120000 index d1609e7548..0000000000 --- a/Lang/BASIC256/Table-creation-Postal-addresses +++ /dev/null @@ -1 +0,0 @@ -../../Task/Table-creation-Postal-addresses/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Twos-complement b/Lang/BASIC256/Twos-complement deleted file mode 120000 index 8b3d33db0a..0000000000 --- a/Lang/BASIC256/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Validate-International-Securities-Identification-Number b/Lang/BASIC256/Validate-International-Securities-Identification-Number deleted file mode 120000 index e6606941e4..0000000000 --- a/Lang/BASIC256/Validate-International-Securities-Identification-Number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Validate-International-Securities-Identification-Number/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Van-Eck-sequence b/Lang/BASIC256/Van-Eck-sequence deleted file mode 120000 index 9c3b8e66bb..0000000000 --- a/Lang/BASIC256/Van-Eck-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-Eck-sequence/BASIC256 \ No newline at end of file diff --git a/Lang/BBC-BASIC/Angles-geometric-normalization-and-conversion b/Lang/BBC-BASIC/Angles-geometric-normalization-and-conversion deleted file mode 120000 index 92a059e0e7..0000000000 --- a/Lang/BBC-BASIC/Angles-geometric-normalization-and-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angles-geometric-normalization-and-conversion/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arbitrary-precision-integers-included- b/Lang/BBC-BASIC/Arbitrary-precision-integers-included- deleted file mode 120000 index ca18adffdc..0000000000 --- a/Lang/BBC-BASIC/Arbitrary-precision-integers-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included-/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Archimedean-spiral b/Lang/BBC-BASIC/Archimedean-spiral deleted file mode 120000 index f1badc9c0e..0000000000 --- a/Lang/BBC-BASIC/Archimedean-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Archimedean-spiral/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Bioinformatics-Sequence-mutation b/Lang/BBC-BASIC/Bioinformatics-Sequence-mutation deleted file mode 120000 index 0c458bc910..0000000000 --- a/Lang/BBC-BASIC/Bioinformatics-Sequence-mutation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bioinformatics-Sequence-mutation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Calculating-the-value-of-e b/Lang/BBC-BASIC/Calculating-the-value-of-e deleted file mode 120000 index 5059f4885f..0000000000 --- a/Lang/BBC-BASIC/Calculating-the-value-of-e +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calculating-the-value-of-e/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Currency b/Lang/BBC-BASIC/Currency deleted file mode 120000 index 93e2e05dfe..0000000000 --- a/Lang/BBC-BASIC/Currency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currency/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Cyclops-numbers b/Lang/BBC-BASIC/Cyclops-numbers deleted file mode 120000 index 5bad59ea26..0000000000 --- a/Lang/BBC-BASIC/Cyclops-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cyclops-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Emirp-primes b/Lang/BBC-BASIC/Emirp-primes deleted file mode 120000 index 83e10a9c96..0000000000 --- a/Lang/BBC-BASIC/Emirp-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Emirp-primes/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Entropy-Narcissist b/Lang/BBC-BASIC/Entropy-Narcissist deleted file mode 120000 index 8b3e51a12a..0000000000 --- a/Lang/BBC-BASIC/Entropy-Narcissist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy-Narcissist/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Fusc-sequence b/Lang/BBC-BASIC/Fusc-sequence deleted file mode 120000 index 4dbe128472..0000000000 --- a/Lang/BBC-BASIC/Fusc-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fusc-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Generate-Chess960-starting-position b/Lang/BBC-BASIC/Generate-Chess960-starting-position deleted file mode 120000 index ab2f96f714..0000000000 --- a/Lang/BBC-BASIC/Generate-Chess960-starting-position +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-Chess960-starting-position/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hex-words b/Lang/BBC-BASIC/Hex-words deleted file mode 120000 index 3149fa1db8..0000000000 --- a/Lang/BBC-BASIC/Hex-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hex-words/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hickerson-series-of-almost-integers b/Lang/BBC-BASIC/Hickerson-series-of-almost-integers deleted file mode 120000 index db668e472e..0000000000 --- a/Lang/BBC-BASIC/Hickerson-series-of-almost-integers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hickerson-series-of-almost-integers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Humble-numbers b/Lang/BBC-BASIC/Humble-numbers deleted file mode 120000 index 73b4b7f4ea..0000000000 --- a/Lang/BBC-BASIC/Humble-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Humble-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/I-before-E-except-after-C b/Lang/BBC-BASIC/I-before-E-except-after-C deleted file mode 120000 index 5cfe84a822..0000000000 --- a/Lang/BBC-BASIC/I-before-E-except-after-C +++ /dev/null @@ -1 +0,0 @@ -../../Task/I-before-E-except-after-C/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Jaro-similarity b/Lang/BBC-BASIC/Jaro-similarity deleted file mode 120000 index fe6ec92687..0000000000 --- a/Lang/BBC-BASIC/Jaro-similarity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jaro-similarity/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Julia-set b/Lang/BBC-BASIC/Julia-set deleted file mode 120000 index 658dd765c9..0000000000 --- a/Lang/BBC-BASIC/Julia-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Julia-set/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Last-Friday-of-each-month b/Lang/BBC-BASIC/Last-Friday-of-each-month deleted file mode 120000 index d35bf9dc8f..0000000000 --- a/Lang/BBC-BASIC/Last-Friday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Last-Friday-of-each-month/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/MAC-vendor-lookup b/Lang/BBC-BASIC/MAC-vendor-lookup deleted file mode 120000 index 7d73c473a7..0000000000 --- a/Lang/BBC-BASIC/MAC-vendor-lookup +++ /dev/null @@ -1 +0,0 @@ -../../Task/MAC-vendor-lookup/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Magnanimous-numbers b/Lang/BBC-BASIC/Magnanimous-numbers deleted file mode 120000 index cdd9658301..0000000000 --- a/Lang/BBC-BASIC/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/BBC-BASIC/Minimum-multiple-of-m-where-digital-sum-equals-m deleted file mode 120000 index c061ef014a..0000000000 --- a/Lang/BBC-BASIC/Minimum-multiple-of-m-where-digital-sum-equals-m +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Multi-dimensional-array b/Lang/BBC-BASIC/Multi-dimensional-array deleted file mode 120000 index 4bc7c4a17c..0000000000 --- a/Lang/BBC-BASIC/Multi-dimensional-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multi-dimensional-array/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Narcissistic-decimal-number b/Lang/BBC-BASIC/Narcissistic-decimal-number deleted file mode 120000 index 1a2b003e3a..0000000000 --- a/Lang/BBC-BASIC/Narcissistic-decimal-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Narcissistic-decimal-number/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Quaternion-type b/Lang/BBC-BASIC/Quaternion-type new file mode 120000 index 0000000000..018816057d --- /dev/null +++ b/Lang/BBC-BASIC/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rosetta-Code-Find-unimplemented-tasks b/Lang/BBC-BASIC/Rosetta-Code-Find-unimplemented-tasks deleted file mode 120000 index c601198500..0000000000 --- a/Lang/BBC-BASIC/Rosetta-Code-Find-unimplemented-tasks +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rosetta-Code-Find-unimplemented-tasks/BBC-BASIC \ No newline at end of file diff --git a/Lang/BCPL/Duffinian-numbers b/Lang/BCPL/Duffinian-numbers deleted file mode 120000 index c8e35dac97..0000000000 --- a/Lang/BCPL/Duffinian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Duffinian-numbers/BCPL \ No newline at end of file diff --git a/Lang/BCPL/Magnanimous-numbers b/Lang/BCPL/Magnanimous-numbers deleted file mode 120000 index 20df81cce1..0000000000 --- a/Lang/BCPL/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/BCPL \ No newline at end of file diff --git a/Lang/BCPL/Move-to-front-algorithm b/Lang/BCPL/Move-to-front-algorithm deleted file mode 120000 index 27c5309df1..0000000000 --- a/Lang/BCPL/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/BCPL \ No newline at end of file diff --git a/Lang/BCPL/Narcissistic-decimal-number b/Lang/BCPL/Narcissistic-decimal-number deleted file mode 120000 index e0ff77fa71..0000000000 --- a/Lang/BCPL/Narcissistic-decimal-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Narcissistic-decimal-number/BCPL \ No newline at end of file diff --git a/Lang/BCPL/Partition-an-integer-x-into-n-primes b/Lang/BCPL/Partition-an-integer-x-into-n-primes deleted file mode 120000 index ab1811d492..0000000000 --- a/Lang/BCPL/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/BCPL \ No newline at end of file diff --git a/Lang/BCPL/Totient-function b/Lang/BCPL/Totient-function deleted file mode 120000 index 03af983992..0000000000 --- a/Lang/BCPL/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/BCPL \ No newline at end of file diff --git a/Lang/BCPL/Zeckendorf-number-representation b/Lang/BCPL/Zeckendorf-number-representation deleted file mode 120000 index 6723808a9f..0000000000 --- a/Lang/BCPL/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/BCPL \ No newline at end of file diff --git a/Lang/BQN/00-LANG.txt b/Lang/BQN/00-LANG.txt index 9fc40a5cde..5a9029cbd2 100644 --- a/Lang/BQN/00-LANG.txt +++ b/Lang/BQN/00-LANG.txt @@ -2,14 +2,11 @@ |checking=dynamic |exec=bytecode |gc=yes - |site=https://mlochbaum.github.io/BQN/ + |site=https://mlochbaum.github.io/BQN |parampass=value |safety=safe |bnf=https://mlochbaum.github.io/BQN/spec/grammar.html}}{{language programming paradigm|functional}}[[Category:Programming paradigm/Tacit]] -BQN is a new (initially released 2020) [[wp:Array programming|array oriented]], [[functional_programming|functional]] programming language in the [[APL]] lineage, which aims to remove irregular and burdensome aspects of the APL tradition and put the great ideas on a firmer footing. While its use demands a solid understanding of functions and multidimensional arrays, BQN's focus on providing simple, consistent, and powerful array operations (and documentation!) makes it a good language for learning array programming and building stronger array intuition. +BQN is a new [[wp:Array programming|array oriented]], [[functional_programming|functional]] programming language in the [[APL]] lineage, which aims to remove irregular and burdensome aspects of the APL tradition and put the great ideas on a firmer footing. While its use demands a solid understanding of functions and multidimensional arrays, BQN's focus on providing simple, consistent, and powerful array operations (and documentation!) makes it a good language for learning array programming and building stronger array intuition. -Documentation can be found at https://mlochbaum.github.io/BQN/doc/. - -==Todo== -[[Tasks_not_implemented_in_BQN]] \ No newline at end of file +Documentation can be found at https://mlochbaum.github.io/BQN. \ No newline at end of file diff --git a/Lang/BQN/Abundant-odd-numbers b/Lang/BQN/Abundant-odd-numbers deleted file mode 120000 index fdb56e6ed6..0000000000 --- a/Lang/BQN/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/BQN \ No newline at end of file diff --git a/Lang/BQN/Angle-difference-between-two-bearings b/Lang/BQN/Angle-difference-between-two-bearings deleted file mode 120000 index 7a2d5afdfe..0000000000 --- a/Lang/BQN/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/BQN \ No newline at end of file diff --git a/Lang/BQN/Apply-a-callback-to-an-array b/Lang/BQN/Apply-a-callback-to-an-array deleted file mode 120000 index 0d1581adfa..0000000000 --- a/Lang/BQN/Apply-a-callback-to-an-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Apply-a-callback-to-an-array/BQN \ No newline at end of file diff --git a/Lang/BQN/Averages-Pythagorean-means b/Lang/BQN/Averages-Pythagorean-means deleted file mode 120000 index 667a8f930b..0000000000 --- a/Lang/BQN/Averages-Pythagorean-means +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Pythagorean-means/BQN \ No newline at end of file diff --git a/Lang/BQN/Base64-decode-data b/Lang/BQN/Base64-decode-data deleted file mode 120000 index 2272b7f2a1..0000000000 --- a/Lang/BQN/Base64-decode-data +++ /dev/null @@ -1 +0,0 @@ -../../Task/Base64-decode-data/BQN \ No newline at end of file diff --git a/Lang/BQN/Bell-numbers b/Lang/BQN/Bell-numbers deleted file mode 120000 index 2c520a34e3..0000000000 --- a/Lang/BQN/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/BQN \ No newline at end of file diff --git a/Lang/BQN/CUSIP b/Lang/BQN/CUSIP deleted file mode 120000 index b7ca66ab5f..0000000000 --- a/Lang/BQN/CUSIP +++ /dev/null @@ -1 +0,0 @@ -../../Task/CUSIP/BQN \ No newline at end of file diff --git a/Lang/BQN/Call-an-object-method b/Lang/BQN/Call-an-object-method deleted file mode 120000 index eb9e8d9920..0000000000 --- a/Lang/BQN/Call-an-object-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-an-object-method/BQN \ No newline at end of file diff --git a/Lang/BQN/Cartesian-product-of-two-or-more-lists b/Lang/BQN/Cartesian-product-of-two-or-more-lists deleted file mode 120000 index 9eca0c70e0..0000000000 --- a/Lang/BQN/Cartesian-product-of-two-or-more-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cartesian-product-of-two-or-more-lists/BQN \ No newline at end of file diff --git a/Lang/BQN/Determine-if-a-string-is-numeric b/Lang/BQN/Determine-if-a-string-is-numeric deleted file mode 120000 index 7756637024..0000000000 --- a/Lang/BQN/Determine-if-a-string-is-numeric +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-numeric/BQN \ No newline at end of file diff --git a/Lang/BQN/Determine-if-a-string-is-squeezable b/Lang/BQN/Determine-if-a-string-is-squeezable deleted file mode 120000 index 604c0583b1..0000000000 --- a/Lang/BQN/Determine-if-a-string-is-squeezable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-squeezable/BQN \ No newline at end of file diff --git a/Lang/BQN/Dutch-national-flag-problem b/Lang/BQN/Dutch-national-flag-problem deleted file mode 120000 index c24e10da06..0000000000 --- a/Lang/BQN/Dutch-national-flag-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dutch-national-flag-problem/BQN \ No newline at end of file diff --git a/Lang/BQN/Find-common-directory-path b/Lang/BQN/Find-common-directory-path deleted file mode 120000 index d4456eaa79..0000000000 --- a/Lang/BQN/Find-common-directory-path +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-common-directory-path/BQN \ No newline at end of file diff --git a/Lang/BQN/Globally-replace-text-in-several-files b/Lang/BQN/Globally-replace-text-in-several-files deleted file mode 120000 index b13db5355b..0000000000 --- a/Lang/BQN/Globally-replace-text-in-several-files +++ /dev/null @@ -1 +0,0 @@ -../../Task/Globally-replace-text-in-several-files/BQN \ No newline at end of file diff --git a/Lang/BQN/Harmonic-series b/Lang/BQN/Harmonic-series deleted file mode 120000 index 6efb347667..0000000000 --- a/Lang/BQN/Harmonic-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harmonic-series/BQN \ No newline at end of file diff --git a/Lang/BQN/I-before-E-except-after-C b/Lang/BQN/I-before-E-except-after-C deleted file mode 120000 index 5fd82fbd92..0000000000 --- a/Lang/BQN/I-before-E-except-after-C +++ /dev/null @@ -1 +0,0 @@ -../../Task/I-before-E-except-after-C/BQN \ No newline at end of file diff --git a/Lang/BQN/IBAN b/Lang/BQN/IBAN deleted file mode 120000 index 501e54d38b..0000000000 --- a/Lang/BQN/IBAN +++ /dev/null @@ -1 +0,0 @@ -../../Task/IBAN/BQN \ No newline at end of file diff --git a/Lang/BQN/ISBN13-check-digit b/Lang/BQN/ISBN13-check-digit deleted file mode 120000 index 70feb3a0c6..0000000000 --- a/Lang/BQN/ISBN13-check-digit +++ /dev/null @@ -1 +0,0 @@ -../../Task/ISBN13-check-digit/BQN \ No newline at end of file diff --git a/Lang/BQN/Leap-year b/Lang/BQN/Leap-year deleted file mode 120000 index b3a2268f78..0000000000 --- a/Lang/BQN/Leap-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leap-year/BQN \ No newline at end of file diff --git a/Lang/BQN/Longest-string-challenge b/Lang/BQN/Longest-string-challenge deleted file mode 120000 index bca36863c6..0000000000 --- a/Lang/BQN/Longest-string-challenge +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-string-challenge/BQN \ No newline at end of file diff --git a/Lang/BQN/Miller-Rabin-primality-test b/Lang/BQN/Miller-Rabin-primality-test new file mode 120000 index 0000000000..88fd3a622d --- /dev/null +++ b/Lang/BQN/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/BQN \ No newline at end of file diff --git a/Lang/BQN/Multifactorial b/Lang/BQN/Multifactorial deleted file mode 120000 index a2fe7ba313..0000000000 --- a/Lang/BQN/Multifactorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multifactorial/BQN \ No newline at end of file diff --git a/Lang/BQN/Munching-squares b/Lang/BQN/Munching-squares deleted file mode 120000 index 1ef4cb44d9..0000000000 --- a/Lang/BQN/Munching-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munching-squares/BQN \ No newline at end of file diff --git a/Lang/BQN/Phrase-reversals b/Lang/BQN/Phrase-reversals deleted file mode 120000 index a35381900f..0000000000 --- a/Lang/BQN/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/BQN \ No newline at end of file diff --git a/Lang/BQN/Program-name b/Lang/BQN/Program-name deleted file mode 120000 index e55b53a24c..0000000000 --- a/Lang/BQN/Program-name +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-name/BQN \ No newline at end of file diff --git a/Lang/BQN/Pseudo-random-numbers-Middle-square-method b/Lang/BQN/Pseudo-random-numbers-Middle-square-method deleted file mode 120000 index 15e8169128..0000000000 --- a/Lang/BQN/Pseudo-random-numbers-Middle-square-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Middle-square-method/BQN \ No newline at end of file diff --git a/Lang/BQN/Remove-duplicate-elements b/Lang/BQN/Remove-duplicate-elements deleted file mode 120000 index fc50c4ea75..0000000000 --- a/Lang/BQN/Remove-duplicate-elements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Remove-duplicate-elements/BQN \ No newline at end of file diff --git a/Lang/BQN/Reverse-words-in-a-string b/Lang/BQN/Reverse-words-in-a-string deleted file mode 120000 index b4a561c28a..0000000000 --- a/Lang/BQN/Reverse-words-in-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-words-in-a-string/BQN \ No newline at end of file diff --git a/Lang/BQN/Rot-13 b/Lang/BQN/Rot-13 deleted file mode 120000 index 40de4f31ae..0000000000 --- a/Lang/BQN/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/BQN \ No newline at end of file diff --git a/Lang/BQN/Self-describing-numbers b/Lang/BQN/Self-describing-numbers deleted file mode 120000 index 394307e5cb..0000000000 --- a/Lang/BQN/Self-describing-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Self-describing-numbers/BQN \ No newline at end of file diff --git a/Lang/BQN/Sequence-of-non-squares b/Lang/BQN/Sequence-of-non-squares deleted file mode 120000 index 34c4c67548..0000000000 --- a/Lang/BQN/Sequence-of-non-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-non-squares/BQN \ No newline at end of file diff --git a/Lang/BQN/Sort-an-integer-array b/Lang/BQN/Sort-an-integer-array deleted file mode 120000 index 0abf6c28d8..0000000000 --- a/Lang/BQN/Sort-an-integer-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-integer-array/BQN \ No newline at end of file diff --git a/Lang/BQN/Sort-disjoint-sublist b/Lang/BQN/Sort-disjoint-sublist deleted file mode 120000 index b6e62b246c..0000000000 --- a/Lang/BQN/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/BQN \ No newline at end of file diff --git a/Lang/BQN/Sort-numbers-lexicographically b/Lang/BQN/Sort-numbers-lexicographically deleted file mode 120000 index c09eafb48d..0000000000 --- a/Lang/BQN/Sort-numbers-lexicographically +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-numbers-lexicographically/BQN \ No newline at end of file diff --git a/Lang/BQN/Split-a-character-string-based-on-change-of-character b/Lang/BQN/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index d35a0c943b..0000000000 --- a/Lang/BQN/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/BQN \ No newline at end of file diff --git a/Lang/BQN/String-append b/Lang/BQN/String-append deleted file mode 120000 index e4188e5b03..0000000000 --- a/Lang/BQN/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/BQN \ No newline at end of file diff --git a/Lang/BQN/Tau-number b/Lang/BQN/Tau-number deleted file mode 120000 index 0d0f120696..0000000000 --- a/Lang/BQN/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/BQN \ No newline at end of file diff --git a/Lang/BQN/Test-integerness b/Lang/BQN/Test-integerness deleted file mode 120000 index da47d74420..0000000000 --- a/Lang/BQN/Test-integerness +++ /dev/null @@ -1 +0,0 @@ -../../Task/Test-integerness/BQN \ No newline at end of file diff --git a/Lang/BQN/Water-collected-between-towers b/Lang/BQN/Water-collected-between-towers deleted file mode 120000 index 905f66c364..0000000000 --- a/Lang/BQN/Water-collected-between-towers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Water-collected-between-towers/BQN \ No newline at end of file diff --git a/Lang/BaCon/Copy-a-string b/Lang/BaCon/Copy-a-string new file mode 120000 index 0000000000..a2df7bcd98 --- /dev/null +++ b/Lang/BaCon/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/BaCon \ No newline at end of file diff --git a/Lang/Babel/00-LANG.txt b/Lang/Babel/00-LANG.txt index bf16b12a25..c41d0351b4 100644 --- a/Lang/Babel/00-LANG.txt +++ b/Lang/Babel/00-LANG.txt @@ -1,6 +1,4 @@ {{alertbox|#ffffe0|''Were you looking for the [[Common Lisp]] library? That category has now been [[:Category:Babel (library)|renamed]].''}} -{{language}} -{{language programming paradigm|concatenative}} -[https://gitlab.com/claytonkb/Babel Babel] is an interpreted language designed by Clayton Bauman. It is an untyped, stack-based, postfix language with support for arrays, lists, matrices and maps (dictionaries). Babel 1.0 will support built-in crypto-based verification of code in order to enable safer remote code execution. +{{language}}[https://github.com/claytonkb/clean_babel Babel] is an interpreted language designed by Clayton Bauman. It is an untyped, stack-based, postfix language with support for arrays, lists, matrices and maps (dictionaries). Babel 1.0 will support built-in crypto-based verification of code in order to enable safer remote code execution. Babel is implemented in [[C]] and compiles with MinGW32. It is still under development, so please excuse the dust and debris in the current implementation. To get started quickly on Windows, clone the repository and run bin/babel.exe from the repo directory. This will start Babel in interactive mode and the examples given on RC are for interactive mode, unless otherwise noted. Since this is a development build, you can type '0 dev' to view the dev options. To build on Windows, use MinGW32; on Linux, use gcc. \ No newline at end of file diff --git a/Lang/BabyCobol/00-LANG.txt b/Lang/BabyCobol/00-LANG.txt deleted file mode 100644 index b106508e3b..0000000000 --- a/Lang/BabyCobol/00-LANG.txt +++ /dev/null @@ -1,7 +0,0 @@ -{{language|BabyCobol - | site = https://slebok.github.io/baby/ - | gc = no - | parampass = both - | hopl = no -}} -'''BabyCobol''' is an experiment in language design: it is small enough to be quickly implementable (fully or partially) within any framework that can support its features, but complex enough to cover typical problems of legacy language processing. If you learn how to compile [[MiniJava]], you stand a good chance of implementing a reasonably good compiler for any contemporary programming language. If you show how your language extension works on [[Featherweight Java]], it has a good chance of being applicable to any reasonable modern object-oriented programming language. If you can handle BabyCobol with your tool and with your skills, you are ready to face the challenges of software modernisation, codebase migration and legacy language processing in general. \ No newline at end of file diff --git a/Lang/BabyCobol/00-META.yaml b/Lang/BabyCobol/00-META.yaml deleted file mode 100644 index 59c8f2fb7e..0000000000 --- a/Lang/BabyCobol/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:BabyCobol diff --git a/Lang/BabyCobol/100-doors b/Lang/BabyCobol/100-doors deleted file mode 120000 index 28c01ba1d4..0000000000 --- a/Lang/BabyCobol/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/BabyCobol \ No newline at end of file diff --git a/Lang/BabyCobol/99-bottles-of-beer b/Lang/BabyCobol/99-bottles-of-beer deleted file mode 120000 index f2b7e0195f..0000000000 --- a/Lang/BabyCobol/99-bottles-of-beer +++ /dev/null @@ -1 +0,0 @@ -../../Task/99-bottles-of-beer/BabyCobol \ No newline at end of file diff --git a/Lang/BabyCobol/A+B b/Lang/BabyCobol/A+B deleted file mode 120000 index 12cf42c07d..0000000000 --- a/Lang/BabyCobol/A+B +++ /dev/null @@ -1 +0,0 @@ -../../Task/A+B/BabyCobol \ No newline at end of file diff --git a/Lang/BabyCobol/FizzBuzz b/Lang/BabyCobol/FizzBuzz deleted file mode 120000 index f3080a2a06..0000000000 --- a/Lang/BabyCobol/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/BabyCobol \ No newline at end of file diff --git a/Lang/BabyCobol/Hello-world-Text b/Lang/BabyCobol/Hello-world-Text deleted file mode 120000 index c4b041271b..0000000000 --- a/Lang/BabyCobol/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/BabyCobol \ No newline at end of file diff --git a/Lang/BabyCobol/User-input-Text b/Lang/BabyCobol/User-input-Text deleted file mode 120000 index f1d99aff15..0000000000 --- a/Lang/BabyCobol/User-input-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/User-input-Text/BabyCobol \ No newline at end of file diff --git a/Lang/Bait/00-LANG.txt b/Lang/Bait/00-LANG.txt index 18a243057f..0900661567 100644 --- a/Lang/Bait/00-LANG.txt +++ b/Lang/Bait/00-LANG.txt @@ -1,11 +1,11 @@ {{ language|Bait -|site=https://github.com/bait-lang/bait +|site=https://github.com/tiabeast/bait |strength=strong |safety=safe |checking=static }} -Bait is a simple programming language for building reliable software. +Bait is a work-in-progress simple, compiled, general purpose programming language for building reliable software. -Solutions are maintained at https://github.com/bait-lang/rosetta-bait. Please propose changes there. \ No newline at end of file +Solutions to RosettaCode are maintained at https://github.com/tiabeast/rosetta-bait. Please propose solutions there. \ No newline at end of file diff --git a/Lang/Bait/Array-length b/Lang/Bait/Array-length deleted file mode 120000 index 986225a090..0000000000 --- a/Lang/Bait/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/Bait \ No newline at end of file diff --git a/Lang/Bait/CRC-32 b/Lang/Bait/CRC-32 deleted file mode 120000 index f40324a53c..0000000000 --- a/Lang/Bait/CRC-32 +++ /dev/null @@ -1 +0,0 @@ -../../Task/CRC-32/Bait \ No newline at end of file diff --git a/Lang/Bait/Empty-string b/Lang/Bait/Empty-string deleted file mode 120000 index b1bbee2da3..0000000000 --- a/Lang/Bait/Empty-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-string/Bait \ No newline at end of file diff --git a/Lang/Bait/Loops-Continue b/Lang/Bait/Loops-Continue deleted file mode 120000 index 6e3768fbb1..0000000000 --- a/Lang/Bait/Loops-Continue +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Continue/Bait \ No newline at end of file diff --git a/Lang/Bait/Loops-Downward-for b/Lang/Bait/Loops-Downward-for deleted file mode 120000 index 128e8218f3..0000000000 --- a/Lang/Bait/Loops-Downward-for +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Downward-for/Bait \ No newline at end of file diff --git a/Lang/Bait/Loops-For b/Lang/Bait/Loops-For deleted file mode 120000 index 79b044fb61..0000000000 --- a/Lang/Bait/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Bait \ No newline at end of file diff --git a/Lang/Bait/Loops-For-with-a-specified-step b/Lang/Bait/Loops-For-with-a-specified-step deleted file mode 120000 index 941f926d61..0000000000 --- a/Lang/Bait/Loops-For-with-a-specified-step +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For-with-a-specified-step/Bait \ No newline at end of file diff --git a/Lang/Bait/Loops-Foreach b/Lang/Bait/Loops-Foreach deleted file mode 120000 index 80ae525d6d..0000000000 --- a/Lang/Bait/Loops-Foreach +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Foreach/Bait \ No newline at end of file diff --git a/Lang/Bait/Loops-While b/Lang/Bait/Loops-While deleted file mode 120000 index 4c1f6d7aff..0000000000 --- a/Lang/Bait/Loops-While +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-While/Bait \ No newline at end of file diff --git a/Lang/Bait/Pascals-triangle b/Lang/Bait/Pascals-triangle deleted file mode 120000 index 564eec1e1a..0000000000 --- a/Lang/Bait/Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pascals-triangle/Bait \ No newline at end of file diff --git a/Lang/Ballerina/00-LANG.txt b/Lang/Ballerina/00-LANG.txt index 211ba0fe40..af215acfd5 100644 --- a/Lang/Ballerina/00-LANG.txt +++ b/Lang/Ballerina/00-LANG.txt @@ -1,20 +1 @@ -{{language|Ballerina -|exec=bytecode -|strength=strong -|safety=safe -|express=explicit -|checking=static -|gc=yes -|hopl=no -|site=https://ballerina.io -}} -'''[https://en.wikipedia.org/wiki/Ballerina_(programming_language) Ballerina]''' is an open source general-purpose programming language designed and supported by [https://wso2.com/ WSO2] for cloud-era application programmers. - -It is under development on [https://github.com/ballerina-platform/ballerina-lang GitHub] and is fully documented [https://ballerina.io here]. - -Ballerina was first publicly announced in 2017 and version 1.0 was released on September 10, 2019. However, a major overhaul took place in 2022 when [https://blog.ballerina.io/posts/2022-02-01-announcing-ballerina-2201.0.0-swan-lake/ Ballerina 2201.0.0 (Swan Lake)] was released. - -The current version (2201.12.3) has distributions available for Windows, Linux and macOS and can be downloaded [https://ballerina.io/downloads/ here]. - -== See Also == -* [https://ballerina.io/learn/by-example/ Ballerina by Example] \ No newline at end of file +{{stub}}{{language|Ballerina}} \ No newline at end of file diff --git a/Lang/Ballerina/100-doors b/Lang/Ballerina/100-doors deleted file mode 120000 index 833a0fc189..0000000000 --- a/Lang/Ballerina/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/99-bottles-of-beer b/Lang/Ballerina/99-bottles-of-beer deleted file mode 120000 index b3bd8e29e3..0000000000 --- a/Lang/Ballerina/99-bottles-of-beer +++ /dev/null @@ -1 +0,0 @@ -../../Task/99-bottles-of-beer/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/A+B b/Lang/Ballerina/A+B deleted file mode 120000 index e9aab74a73..0000000000 --- a/Lang/Ballerina/A+B +++ /dev/null @@ -1 +0,0 @@ -../../Task/A+B/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/ABC-problem b/Lang/Ballerina/ABC-problem deleted file mode 120000 index 49ca7ac9ad..0000000000 --- a/Lang/Ballerina/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/AKS-test-for-primes b/Lang/Ballerina/AKS-test-for-primes deleted file mode 120000 index 9b19f08d80..0000000000 --- a/Lang/Ballerina/AKS-test-for-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/AKS-test-for-primes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Abundant-deficient-and-perfect-number-classifications b/Lang/Ballerina/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index b5353658a4..0000000000 --- a/Lang/Ballerina/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Abundant-odd-numbers b/Lang/Ballerina/Abundant-odd-numbers deleted file mode 120000 index 0b3a97c4a1..0000000000 --- a/Lang/Ballerina/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Accumulator-factory b/Lang/Ballerina/Accumulator-factory deleted file mode 120000 index 837dbbe6a0..0000000000 --- a/Lang/Ballerina/Accumulator-factory +++ /dev/null @@ -1 +0,0 @@ -../../Task/Accumulator-factory/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Achilles-numbers b/Lang/Ballerina/Achilles-numbers deleted file mode 120000 index 3336ab1c37..0000000000 --- a/Lang/Ballerina/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Ackermann-function b/Lang/Ballerina/Ackermann-function deleted file mode 120000 index b9748d884d..0000000000 --- a/Lang/Ballerina/Ackermann-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ackermann-function/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Ballerina/Add-a-variable-to-a-class-instance-at-runtime deleted file mode 120000 index 12efd91bd6..0000000000 --- a/Lang/Ballerina/Add-a-variable-to-a-class-instance-at-runtime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Add-a-variable-to-a-class-instance-at-runtime/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Additive-primes b/Lang/Ballerina/Additive-primes deleted file mode 120000 index a504210ea7..0000000000 --- a/Lang/Ballerina/Additive-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Additive-primes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Address-of-a-variable b/Lang/Ballerina/Address-of-a-variable deleted file mode 120000 index 6428e75ce3..0000000000 --- a/Lang/Ballerina/Address-of-a-variable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Address-of-a-variable/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Almost-prime b/Lang/Ballerina/Almost-prime deleted file mode 120000 index 33d501af1e..0000000000 --- a/Lang/Ballerina/Almost-prime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Almost-prime/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Amb b/Lang/Ballerina/Amb deleted file mode 120000 index 7acc58d7c4..0000000000 --- a/Lang/Ballerina/Amb +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amb/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Angle-difference-between-two-bearings b/Lang/Ballerina/Angle-difference-between-two-bearings deleted file mode 120000 index 04ff00d986..0000000000 --- a/Lang/Ballerina/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Anti-primes b/Lang/Ballerina/Anti-primes deleted file mode 120000 index 9911fc0bcb..0000000000 --- a/Lang/Ballerina/Anti-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anti-primes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Apply-a-callback-to-an-array b/Lang/Ballerina/Apply-a-callback-to-an-array deleted file mode 120000 index 9911480671..0000000000 --- a/Lang/Ballerina/Apply-a-callback-to-an-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Apply-a-callback-to-an-array/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Approximate-equality b/Lang/Ballerina/Approximate-equality deleted file mode 120000 index 0ea6692d0d..0000000000 --- a/Lang/Ballerina/Approximate-equality +++ /dev/null @@ -1 +0,0 @@ -../../Task/Approximate-equality/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Arithmetic-Complex b/Lang/Ballerina/Arithmetic-Complex deleted file mode 120000 index f87fd15204..0000000000 --- a/Lang/Ballerina/Arithmetic-Complex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Complex/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Arithmetic-Integer b/Lang/Ballerina/Arithmetic-Integer deleted file mode 120000 index a4c8cf5206..0000000000 --- a/Lang/Ballerina/Arithmetic-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Integer/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Arithmetic-Rational b/Lang/Ballerina/Arithmetic-Rational deleted file mode 120000 index 422af5f88b..0000000000 --- a/Lang/Ballerina/Arithmetic-Rational +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Rational/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Arithmetic-numbers b/Lang/Ballerina/Arithmetic-numbers deleted file mode 120000 index 38541780a0..0000000000 --- a/Lang/Ballerina/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Array-concatenation b/Lang/Ballerina/Array-concatenation deleted file mode 120000 index 41c2603b74..0000000000 --- a/Lang/Ballerina/Array-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-concatenation/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Array-length b/Lang/Ballerina/Array-length deleted file mode 120000 index 25020148f9..0000000000 --- a/Lang/Ballerina/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Arrays b/Lang/Ballerina/Arrays deleted file mode 120000 index ec5c5a266e..0000000000 --- a/Lang/Ballerina/Arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arrays/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Ascending-primes b/Lang/Ballerina/Ascending-primes deleted file mode 120000 index 51444ceb96..0000000000 --- a/Lang/Ballerina/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Associative-array-Creation b/Lang/Ballerina/Associative-array-Creation deleted file mode 120000 index 2639b285f3..0000000000 --- a/Lang/Ballerina/Associative-array-Creation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Creation/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Associative-array-Iteration b/Lang/Ballerina/Associative-array-Iteration deleted file mode 120000 index d3e31d2374..0000000000 --- a/Lang/Ballerina/Associative-array-Iteration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Iteration/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Associative-array-Merging b/Lang/Ballerina/Associative-array-Merging deleted file mode 120000 index cd38137d75..0000000000 --- a/Lang/Ballerina/Associative-array-Merging +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Merging/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Arithmetic-mean b/Lang/Ballerina/Averages-Arithmetic-mean deleted file mode 120000 index 039d1f0de8..0000000000 --- a/Lang/Ballerina/Averages-Arithmetic-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Arithmetic-mean/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Mean-angle b/Lang/Ballerina/Averages-Mean-angle deleted file mode 120000 index adf77693ce..0000000000 --- a/Lang/Ballerina/Averages-Mean-angle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-angle/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Mean-time-of-day b/Lang/Ballerina/Averages-Mean-time-of-day deleted file mode 120000 index c969ed84e4..0000000000 --- a/Lang/Ballerina/Averages-Mean-time-of-day +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-time-of-day/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Median b/Lang/Ballerina/Averages-Median deleted file mode 120000 index 5bbd39cecb..0000000000 --- a/Lang/Ballerina/Averages-Median +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Median/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Mode b/Lang/Ballerina/Averages-Mode deleted file mode 120000 index 72d0e02dae..0000000000 --- a/Lang/Ballerina/Averages-Mode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mode/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Pythagorean-means b/Lang/Ballerina/Averages-Pythagorean-means deleted file mode 120000 index fd607a9ee8..0000000000 --- a/Lang/Ballerina/Averages-Pythagorean-means +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Pythagorean-means/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Root-mean-square b/Lang/Ballerina/Averages-Root-mean-square deleted file mode 120000 index 48056410d9..0000000000 --- a/Lang/Ballerina/Averages-Root-mean-square +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Root-mean-square/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Averages-Simple-moving-average b/Lang/Ballerina/Averages-Simple-moving-average deleted file mode 120000 index 7e2849cced..0000000000 --- a/Lang/Ballerina/Averages-Simple-moving-average +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Simple-moving-average/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Balanced-brackets b/Lang/Ballerina/Balanced-brackets deleted file mode 120000 index 3d78b77dd3..0000000000 --- a/Lang/Ballerina/Balanced-brackets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Balanced-brackets/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Binary-digits b/Lang/Ballerina/Binary-digits deleted file mode 120000 index 47999ed558..0000000000 --- a/Lang/Ballerina/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Boolean-values b/Lang/Ballerina/Boolean-values deleted file mode 120000 index c01657f16a..0000000000 --- a/Lang/Ballerina/Boolean-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Boolean-values/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Caesar-cipher b/Lang/Ballerina/Caesar-cipher deleted file mode 120000 index 8e1a6603e9..0000000000 --- a/Lang/Ballerina/Caesar-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Caesar-cipher/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Calculating-the-value-of-e b/Lang/Ballerina/Calculating-the-value-of-e deleted file mode 120000 index af3085b824..0000000000 --- a/Lang/Ballerina/Calculating-the-value-of-e +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calculating-the-value-of-e/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Case-sensitivity-of-identifiers b/Lang/Ballerina/Case-sensitivity-of-identifiers deleted file mode 120000 index 42725d41da..0000000000 --- a/Lang/Ballerina/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Character-codes b/Lang/Ballerina/Character-codes deleted file mode 120000 index 6abede048f..0000000000 --- a/Lang/Ballerina/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Classes b/Lang/Ballerina/Classes deleted file mode 120000 index 0c8bd2434d..0000000000 --- a/Lang/Ballerina/Classes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Classes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Commatizing-numbers b/Lang/Ballerina/Commatizing-numbers deleted file mode 120000 index a644eda1b6..0000000000 --- a/Lang/Ballerina/Commatizing-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Commatizing-numbers/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Comments b/Lang/Ballerina/Comments deleted file mode 120000 index 6b5d53ddee..0000000000 --- a/Lang/Ballerina/Comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comments/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Copy-a-string b/Lang/Ballerina/Copy-a-string deleted file mode 120000 index ce5773b181..0000000000 --- a/Lang/Ballerina/Copy-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Copy-a-string/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Count-in-octal b/Lang/Ballerina/Count-in-octal deleted file mode 120000 index 7e70a67830..0000000000 --- a/Lang/Ballerina/Count-in-octal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-in-octal/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Currency b/Lang/Ballerina/Currency deleted file mode 120000 index 2b278dfa20..0000000000 --- a/Lang/Ballerina/Currency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currency/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Currying b/Lang/Ballerina/Currying deleted file mode 120000 index 7e465c7834..0000000000 --- a/Lang/Ballerina/Currying +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currying/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Dot-product b/Lang/Ballerina/Dot-product deleted file mode 120000 index 327f9d0969..0000000000 --- a/Lang/Ballerina/Dot-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dot-product/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Dynamic-variable-names b/Lang/Ballerina/Dynamic-variable-names deleted file mode 120000 index 5c549728ae..0000000000 --- a/Lang/Ballerina/Dynamic-variable-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dynamic-variable-names/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Empty-string b/Lang/Ballerina/Empty-string deleted file mode 120000 index a86a0ffc9d..0000000000 --- a/Lang/Ballerina/Empty-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-string/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Even-or-odd b/Lang/Ballerina/Even-or-odd deleted file mode 120000 index 2d8b1b90ab..0000000000 --- a/Lang/Ballerina/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Extreme-floating-point-values b/Lang/Ballerina/Extreme-floating-point-values deleted file mode 120000 index 7f91d37268..0000000000 --- a/Lang/Ballerina/Extreme-floating-point-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Extreme-floating-point-values/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Factors-of-an-integer b/Lang/Ballerina/Factors-of-an-integer deleted file mode 120000 index ac634eef84..0000000000 --- a/Lang/Ballerina/Factors-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factors-of-an-integer/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Farey-sequence b/Lang/Ballerina/Farey-sequence deleted file mode 120000 index d542459c5f..0000000000 --- a/Lang/Ballerina/Farey-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Farey-sequence/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Fibonacci-sequence b/Lang/Ballerina/Fibonacci-sequence deleted file mode 120000 index 96031e7d01..0000000000 --- a/Lang/Ballerina/Fibonacci-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-sequence/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Filter b/Lang/Ballerina/Filter deleted file mode 120000 index b57b5e74be..0000000000 --- a/Lang/Ballerina/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Find-limit-of-recursion b/Lang/Ballerina/Find-limit-of-recursion deleted file mode 120000 index 0c9c45aca0..0000000000 --- a/Lang/Ballerina/Find-limit-of-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-limit-of-recursion/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Fivenum b/Lang/Ballerina/Fivenum deleted file mode 120000 index 0df90aeb78..0000000000 --- a/Lang/Ballerina/Fivenum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fivenum/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/FizzBuzz b/Lang/Ballerina/FizzBuzz deleted file mode 120000 index e7f3aa8019..0000000000 --- a/Lang/Ballerina/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Floyds-triangle b/Lang/Ballerina/Floyds-triangle deleted file mode 120000 index 524ef8d9d5..0000000000 --- a/Lang/Ballerina/Floyds-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyds-triangle/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Four-bit-adder b/Lang/Ballerina/Four-bit-adder deleted file mode 120000 index da1ccb0292..0000000000 --- a/Lang/Ballerina/Four-bit-adder +++ /dev/null @@ -1 +0,0 @@ -../../Task/Four-bit-adder/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Function-definition b/Lang/Ballerina/Function-definition deleted file mode 120000 index aad5e07c0c..0000000000 --- a/Lang/Ballerina/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Gapful-numbers b/Lang/Ballerina/Gapful-numbers deleted file mode 120000 index 16bb3670f6..0000000000 --- a/Lang/Ballerina/Gapful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gapful-numbers/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Greatest-common-divisor b/Lang/Ballerina/Greatest-common-divisor deleted file mode 120000 index 0f657f13a6..0000000000 --- a/Lang/Ballerina/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Greatest-element-of-a-list b/Lang/Ballerina/Greatest-element-of-a-list deleted file mode 120000 index 579d0c3022..0000000000 --- a/Lang/Ballerina/Greatest-element-of-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-element-of-a-list/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Greatest-subsequential-sum b/Lang/Ballerina/Greatest-subsequential-sum deleted file mode 120000 index edc1a686d7..0000000000 --- a/Lang/Ballerina/Greatest-subsequential-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-subsequential-sum/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Hailstone-sequence b/Lang/Ballerina/Hailstone-sequence deleted file mode 120000 index 41dfb14066..0000000000 --- a/Lang/Ballerina/Hailstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hailstone-sequence/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Hello-world-Graphical b/Lang/Ballerina/Hello-world-Graphical deleted file mode 120000 index 4e2e7e9224..0000000000 --- a/Lang/Ballerina/Hello-world-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Graphical/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Hello-world-Newbie b/Lang/Ballerina/Hello-world-Newbie deleted file mode 120000 index b59c1b36e9..0000000000 --- a/Lang/Ballerina/Hello-world-Newbie +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newbie/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Hello-world-Newline-omission b/Lang/Ballerina/Hello-world-Newline-omission deleted file mode 120000 index 1016c5553e..0000000000 --- a/Lang/Ballerina/Hello-world-Newline-omission +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newline-omission/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Hello-world-Standard-error b/Lang/Ballerina/Hello-world-Standard-error deleted file mode 120000 index c4921dce1f..0000000000 --- a/Lang/Ballerina/Hello-world-Standard-error +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Standard-error/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Increment-a-numerical-string b/Lang/Ballerina/Increment-a-numerical-string deleted file mode 120000 index 712faa77bf..0000000000 --- a/Lang/Ballerina/Increment-a-numerical-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increment-a-numerical-string/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Integer-comparison b/Lang/Ballerina/Integer-comparison deleted file mode 120000 index 8563637dab..0000000000 --- a/Lang/Ballerina/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Integer-sequence b/Lang/Ballerina/Integer-sequence deleted file mode 120000 index 06b95f33f5..0000000000 --- a/Lang/Ballerina/Integer-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-sequence/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Levenshtein-distance b/Lang/Ballerina/Levenshtein-distance deleted file mode 120000 index 4824e03354..0000000000 --- a/Lang/Ballerina/Levenshtein-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Logical-operations b/Lang/Ballerina/Logical-operations deleted file mode 120000 index 06b4043fcb..0000000000 --- a/Lang/Ballerina/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loop-over-multiple-arrays-simultaneously b/Lang/Ballerina/Loop-over-multiple-arrays-simultaneously deleted file mode 120000 index 9b68d094d5..0000000000 --- a/Lang/Ballerina/Loop-over-multiple-arrays-simultaneously +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loop-over-multiple-arrays-simultaneously/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Break b/Lang/Ballerina/Loops-Break deleted file mode 120000 index 6ab612b087..0000000000 --- a/Lang/Ballerina/Loops-Break +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Break/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Continue b/Lang/Ballerina/Loops-Continue deleted file mode 120000 index 175be123b9..0000000000 --- a/Lang/Ballerina/Loops-Continue +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Continue/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Do-while b/Lang/Ballerina/Loops-Do-while deleted file mode 120000 index b90c6b3171..0000000000 --- a/Lang/Ballerina/Loops-Do-while +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Do-while/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Downward-for b/Lang/Ballerina/Loops-Downward-for deleted file mode 120000 index e977389f54..0000000000 --- a/Lang/Ballerina/Loops-Downward-for +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Downward-for/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-For b/Lang/Ballerina/Loops-For deleted file mode 120000 index 8ad2b8fd0c..0000000000 --- a/Lang/Ballerina/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-For-with-a-specified-step b/Lang/Ballerina/Loops-For-with-a-specified-step deleted file mode 120000 index cc892dc7f2..0000000000 --- a/Lang/Ballerina/Loops-For-with-a-specified-step +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For-with-a-specified-step/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Foreach b/Lang/Ballerina/Loops-Foreach deleted file mode 120000 index f819fadabe..0000000000 --- a/Lang/Ballerina/Loops-Foreach +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Foreach/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Increment-loop-index-within-loop-body b/Lang/Ballerina/Loops-Increment-loop-index-within-loop-body deleted file mode 120000 index 1c9b81a58a..0000000000 --- a/Lang/Ballerina/Loops-Increment-loop-index-within-loop-body +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Increment-loop-index-within-loop-body/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Infinite b/Lang/Ballerina/Loops-Infinite deleted file mode 120000 index 312369ce48..0000000000 --- a/Lang/Ballerina/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-N-plus-one-half b/Lang/Ballerina/Loops-N-plus-one-half deleted file mode 120000 index 220ecbad7f..0000000000 --- a/Lang/Ballerina/Loops-N-plus-one-half +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-N-plus-one-half/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Nested b/Lang/Ballerina/Loops-Nested deleted file mode 120000 index f32c9a3c17..0000000000 --- a/Lang/Ballerina/Loops-Nested +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Nested/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-With-multiple-ranges b/Lang/Ballerina/Loops-With-multiple-ranges deleted file mode 120000 index 2fad29a9f9..0000000000 --- a/Lang/Ballerina/Loops-With-multiple-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-With-multiple-ranges/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Loops-Wrong-ranges b/Lang/Ballerina/Loops-Wrong-ranges deleted file mode 120000 index 6c8ada2aa7..0000000000 --- a/Lang/Ballerina/Loops-Wrong-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Wrong-ranges/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Palindrome-detection b/Lang/Ballerina/Palindrome-detection deleted file mode 120000 index 981d11f5cd..0000000000 --- a/Lang/Ballerina/Palindrome-detection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-detection/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Repeat-a-string b/Lang/Ballerina/Repeat-a-string deleted file mode 120000 index 83134ceac0..0000000000 --- a/Lang/Ballerina/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Reverse-a-string b/Lang/Ballerina/Reverse-a-string deleted file mode 120000 index f4e8e73220..0000000000 --- a/Lang/Ballerina/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Rot-13 b/Lang/Ballerina/Rot-13 deleted file mode 120000 index d33ecacc03..0000000000 --- a/Lang/Ballerina/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Sieve-of-Eratosthenes b/Lang/Ballerina/Sieve-of-Eratosthenes deleted file mode 120000 index 4cae2a9d5e..0000000000 --- a/Lang/Ballerina/Sieve-of-Eratosthenes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Eratosthenes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Stack b/Lang/Ballerina/Stack deleted file mode 120000 index e073045735..0000000000 --- a/Lang/Ballerina/Stack +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stack/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Statistics-Basic b/Lang/Ballerina/Statistics-Basic deleted file mode 120000 index 7ef892b782..0000000000 --- a/Lang/Ballerina/Statistics-Basic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Basic/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/String-case b/Lang/Ballerina/String-case deleted file mode 120000 index 091d633ac8..0000000000 --- a/Lang/Ballerina/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/String-concatenation b/Lang/Ballerina/String-concatenation deleted file mode 120000 index a5a366085e..0000000000 --- a/Lang/Ballerina/String-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-concatenation/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/String-length b/Lang/Ballerina/String-length deleted file mode 120000 index 0cdb126aa0..0000000000 --- a/Lang/Ballerina/String-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-length/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Sum-and-product-of-an-array b/Lang/Ballerina/Sum-and-product-of-an-array deleted file mode 120000 index a5ba732cde..0000000000 --- a/Lang/Ballerina/Sum-and-product-of-an-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-and-product-of-an-array/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Sum-of-a-series b/Lang/Ballerina/Sum-of-a-series deleted file mode 120000 index 27da1c4b06..0000000000 --- a/Lang/Ballerina/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Sum-of-squares b/Lang/Ballerina/Sum-of-squares deleted file mode 120000 index 9f1e366796..0000000000 --- a/Lang/Ballerina/Sum-of-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-squares/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Tokenize-a-string b/Lang/Ballerina/Tokenize-a-string deleted file mode 120000 index d9a64c3a3e..0000000000 --- a/Lang/Ballerina/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Towers-of-Hanoi b/Lang/Ballerina/Towers-of-Hanoi deleted file mode 120000 index 81bf7985bd..0000000000 --- a/Lang/Ballerina/Towers-of-Hanoi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Towers-of-Hanoi/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Truncatable-primes b/Lang/Ballerina/Truncatable-primes deleted file mode 120000 index 044dcb5d58..0000000000 --- a/Lang/Ballerina/Truncatable-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truncatable-primes/Ballerina \ No newline at end of file diff --git a/Lang/Ballerina/Unicode-variable-names b/Lang/Ballerina/Unicode-variable-names deleted file mode 120000 index 7f61255815..0000000000 --- a/Lang/Ballerina/Unicode-variable-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unicode-variable-names/Ballerina \ No newline at end of file diff --git a/Lang/Basic09/00-LANG.txt b/Lang/Basic09/00-LANG.txt index fa600ca16b..16853881ce 100644 --- a/Lang/Basic09/00-LANG.txt +++ b/Lang/Basic09/00-LANG.txt @@ -1,3 +1 @@ -{{language|Basic09}} -{{implementation|BASIC}} -Basic09 is a dialect of BASIC created by Microware Systems Corporation in 1978 for use on the OS-9 operating system designed for the Motorola 6809 microporcessor. There is a version for OS-9/68000, "Microware BASIC", identical save that the INTEGER type is a four-byte signed integer instead of two-byte and REAL is IEEE 754 double precision rather than the five-byte format in the original version. \ No newline at end of file +{{language|Basic09}}Basic09 is a dialect of BASIC created by Microware Systems Corporation in 1978 for use on the OS-9 operating system designed for the Motorola 6809 microporcessor. There is a version for OS-9/68000, "Microware BASIC", identical save that the INTEGER type is a four-byte signed integer instead of two-byte and REAL is IEEE 754 double precision rather than the five-byte format in the original version. \ No newline at end of file diff --git a/Lang/Batch-File/00-LANG.txt b/Lang/Batch-File/00-LANG.txt index 06b0c85598..1bcc82760d 100644 --- a/Lang/Batch-File/00-LANG.txt +++ b/Lang/Batch-File/00-LANG.txt @@ -1,3 +1,3 @@ -{{language|Batch File}}'''Batch file''', sometimes just called Batch, is the common name for the scripting language for [[Microsoft]] command line shells, such as COMMAND.COM (in [[MS-DOS]]), and CMD.EXE (in Windows). They typically have either the .BAT or .CMD extension. Due to the association of batch files with MS-DOS in the public consciousness, sometimes this language is called the MS-DOS programming language even when used on modern versions of Windows, though this usage of the term is not technically correct. +{{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. The "batch files" written in the Batch File language are not to be confused with the "bash scripts" written in the [[bash | bash programming language]] for the [[UNIX Shell]]. \ No newline at end of file diff --git a/Lang/Batch-File/Base64-decode-data b/Lang/Batch-File/Base64-decode-data deleted file mode 120000 index ec2f53b5db..0000000000 --- a/Lang/Batch-File/Base64-decode-data +++ /dev/null @@ -1 +0,0 @@ -../../Task/Base64-decode-data/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Call-a-foreign-language-function b/Lang/Batch-File/Call-a-foreign-language-function deleted file mode 120000 index 82bd97e4ca..0000000000 --- a/Lang/Batch-File/Call-a-foreign-language-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-a-foreign-language-function/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Check-input-device-is-a-terminal b/Lang/Batch-File/Check-input-device-is-a-terminal deleted file mode 120000 index e3cbbd272b..0000000000 --- a/Lang/Batch-File/Check-input-device-is-a-terminal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-input-device-is-a-terminal/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Check-output-device-is-a-terminal b/Lang/Batch-File/Check-output-device-is-a-terminal deleted file mode 120000 index 3d54ec8254..0000000000 --- a/Lang/Batch-File/Check-output-device-is-a-terminal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-output-device-is-a-terminal/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Chinese-zodiac b/Lang/Batch-File/Chinese-zodiac deleted file mode 120000 index c2c7ae27f9..0000000000 --- a/Lang/Batch-File/Chinese-zodiac +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chinese-zodiac/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Copy-stdin-to-stdout b/Lang/Batch-File/Copy-stdin-to-stdout deleted file mode 120000 index ec25d70662..0000000000 --- a/Lang/Batch-File/Copy-stdin-to-stdout +++ /dev/null @@ -1 +0,0 @@ -../../Task/Copy-stdin-to-stdout/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Exponentiation-operator b/Lang/Batch-File/Exponentiation-operator deleted file mode 120000 index 93dda3ab18..0000000000 --- a/Lang/Batch-File/Exponentiation-operator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-operator/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Flatten-a-list b/Lang/Batch-File/Flatten-a-list deleted file mode 120000 index bdac6d0d38..0000000000 --- a/Lang/Batch-File/Flatten-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Flatten-a-list/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Handle-a-signal b/Lang/Batch-File/Handle-a-signal deleted file mode 120000 index 5dfc7c6a7d..0000000000 --- a/Lang/Batch-File/Handle-a-signal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Handle-a-signal/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Hello-world-Web-server b/Lang/Batch-File/Hello-world-Web-server deleted file mode 120000 index ef5c7e0f66..0000000000 --- a/Lang/Batch-File/Hello-world-Web-server +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Web-server/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Input-loop b/Lang/Batch-File/Input-loop new file mode 120000 index 0000000000..a2a4a9b473 --- /dev/null +++ b/Lang/Batch-File/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Keyboard-input-Keypress-check b/Lang/Batch-File/Keyboard-input-Keypress-check deleted file mode 120000 index 5711a16a1c..0000000000 --- a/Lang/Batch-File/Keyboard-input-Keypress-check +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Keypress-check/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Long-year b/Lang/Batch-File/Long-year deleted file mode 120000 index 2a90ddff12..0000000000 --- a/Lang/Batch-File/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Make-directory-path b/Lang/Batch-File/Make-directory-path deleted file mode 120000 index 057c573752..0000000000 --- a/Lang/Batch-File/Make-directory-path +++ /dev/null @@ -1 +0,0 @@ -../../Task/Make-directory-path/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Primality-by-trial-division b/Lang/Batch-File/Primality-by-trial-division deleted file mode 120000 index 5a253da7c4..0000000000 --- a/Lang/Batch-File/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Read-a-configuration-file b/Lang/Batch-File/Read-a-configuration-file deleted file mode 120000 index 163a19758c..0000000000 --- a/Lang/Batch-File/Read-a-configuration-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-configuration-file/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Read-entire-file b/Lang/Batch-File/Read-entire-file deleted file mode 120000 index a4d22dbb49..0000000000 --- a/Lang/Batch-File/Read-entire-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-entire-file/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/SHA-1 b/Lang/Batch-File/SHA-1 deleted file mode 120000 index 7b80d0565c..0000000000 --- a/Lang/Batch-File/SHA-1 +++ /dev/null @@ -1 +0,0 @@ -../../Task/SHA-1/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/SHA-256 b/Lang/Batch-File/SHA-256 deleted file mode 120000 index 88132ba441..0000000000 --- a/Lang/Batch-File/SHA-256 +++ /dev/null @@ -1 +0,0 @@ -../../Task/SHA-256/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Simple-windowed-application b/Lang/Batch-File/Simple-windowed-application deleted file mode 120000 index 98ffbccd11..0000000000 --- a/Lang/Batch-File/Simple-windowed-application +++ /dev/null @@ -1 +0,0 @@ -../../Task/Simple-windowed-application/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Sort-an-integer-array b/Lang/Batch-File/Sort-an-integer-array deleted file mode 120000 index 9e7fd40b38..0000000000 --- a/Lang/Batch-File/Sort-an-integer-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-integer-array/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Strip-a-set-of-characters-from-a-string b/Lang/Batch-File/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index bb3a4f27fc..0000000000 --- a/Lang/Batch-File/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Temperature-conversion b/Lang/Batch-File/Temperature-conversion deleted file mode 120000 index a928fb35a8..0000000000 --- a/Lang/Batch-File/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Terminal-control-Hiding-the-cursor b/Lang/Batch-File/Terminal-control-Hiding-the-cursor deleted file mode 120000 index 55e8dcde29..0000000000 --- a/Lang/Batch-File/Terminal-control-Hiding-the-cursor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Hiding-the-cursor/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Terminal-control-Preserve-screen b/Lang/Batch-File/Terminal-control-Preserve-screen deleted file mode 120000 index 8bc69bb473..0000000000 --- a/Lang/Batch-File/Terminal-control-Preserve-screen +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Preserve-screen/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Terminal-control-Unicode-output b/Lang/Batch-File/Terminal-control-Unicode-output deleted file mode 120000 index d9cf45a55e..0000000000 --- a/Lang/Batch-File/Terminal-control-Unicode-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Unicode-output/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Truncate-a-file b/Lang/Batch-File/Truncate-a-file deleted file mode 120000 index 18bcf16da0..0000000000 --- a/Lang/Batch-File/Truncate-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truncate-a-file/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/URL-decoding b/Lang/Batch-File/URL-decoding deleted file mode 120000 index 4081a1f375..0000000000 --- a/Lang/Batch-File/URL-decoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/URL-decoding/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/URL-encoding b/Lang/Batch-File/URL-encoding deleted file mode 120000 index 5609bac01d..0000000000 --- a/Lang/Batch-File/URL-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/URL-encoding/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Unicode-variable-names b/Lang/Batch-File/Unicode-variable-names deleted file mode 120000 index 04bbb2a08c..0000000000 --- a/Lang/Batch-File/Unicode-variable-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unicode-variable-names/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Unix-ls b/Lang/Batch-File/Unix-ls deleted file mode 120000 index d789240aba..0000000000 --- a/Lang/Batch-File/Unix-ls +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unix-ls/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Window-creation b/Lang/Batch-File/Window-creation deleted file mode 120000 index 733ac1868e..0000000000 --- a/Lang/Batch-File/Window-creation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Window-creation/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Write-entire-file b/Lang/Batch-File/Write-entire-file deleted file mode 120000 index ace14aef52..0000000000 --- a/Lang/Batch-File/Write-entire-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-entire-file/Batch-File \ No newline at end of file diff --git a/Lang/Bc/Anti-primes b/Lang/Bc/Anti-primes deleted file mode 120000 index 3d900bc4e9..0000000000 --- a/Lang/Bc/Anti-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anti-primes/Bc \ No newline at end of file diff --git a/Lang/Bc/Arithmetic-derivative b/Lang/Bc/Arithmetic-derivative deleted file mode 120000 index 3ff888839e..0000000000 --- a/Lang/Bc/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Bc \ No newline at end of file diff --git a/Lang/Bc/Deceptive-numbers b/Lang/Bc/Deceptive-numbers deleted file mode 120000 index 244bb00858..0000000000 --- a/Lang/Bc/Deceptive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deceptive-numbers/Bc \ No newline at end of file diff --git a/Lang/Bc/Department-numbers b/Lang/Bc/Department-numbers deleted file mode 120000 index 0e2c9bd91f..0000000000 --- a/Lang/Bc/Department-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Department-numbers/Bc \ No newline at end of file diff --git a/Lang/Bc/Fairshare-between-two-and-more b/Lang/Bc/Fairshare-between-two-and-more deleted file mode 120000 index f5c1a3523e..0000000000 --- a/Lang/Bc/Fairshare-between-two-and-more +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fairshare-between-two-and-more/Bc \ No newline at end of file diff --git a/Lang/Bc/Mandelbrot-set b/Lang/Bc/Mandelbrot-set deleted file mode 120000 index 4b8fac7b05..0000000000 --- a/Lang/Bc/Mandelbrot-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mandelbrot-set/Bc \ No newline at end of file diff --git a/Lang/Bc/Miller-Rabin-primality-test b/Lang/Bc/Miller-Rabin-primality-test new file mode 120000 index 0000000000..1ae2fd8406 --- /dev/null +++ b/Lang/Bc/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Bc \ No newline at end of file diff --git a/Lang/Bc/Sieve-of-Eratosthenes b/Lang/Bc/Sieve-of-Eratosthenes deleted file mode 120000 index de34a684a4..0000000000 --- a/Lang/Bc/Sieve-of-Eratosthenes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Eratosthenes/Bc \ No newline at end of file diff --git a/Lang/Bc/Variables b/Lang/Bc/Variables deleted file mode 120000 index 03f47bea63..0000000000 --- a/Lang/Bc/Variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variables/Bc \ No newline at end of file diff --git a/Lang/Bc/Zeckendorf-number-representation b/Lang/Bc/Zeckendorf-number-representation deleted file mode 120000 index f3a1eeba63..0000000000 --- a/Lang/Bc/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/Bc \ No newline at end of file diff --git a/Lang/Beeswax/00-LANG.txt b/Lang/Beeswax/00-LANG.txt index c131bf7731..bea56d7b6b 100644 --- a/Lang/Beeswax/00-LANG.txt +++ b/Lang/Beeswax/00-LANG.txt @@ -25,7 +25,7 @@ All data in the local and global stacks are unsigned 64-bit integers, output as == More information == -* [http://esolangs.org/wiki/beeswax Esoteric languages wiki entry] +* [[eso:Beeswax|Esoteric languages wiki entry]] == Reference implementation, example programs and complete language specification == diff --git a/Lang/Befunge/Sorting-algorithms-Bubble-sort b/Lang/Befunge/Sorting-algorithms-Bubble-sort deleted file mode 120000 index 8c2d1f0a86..0000000000 --- a/Lang/Befunge/Sorting-algorithms-Bubble-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bubble-sort/Befunge \ No newline at end of file diff --git a/Lang/Berkeley-Logo/00-LANG.txt b/Lang/Berkeley-Logo/00-LANG.txt deleted file mode 100644 index 06b91b5045..0000000000 --- a/Lang/Berkeley-Logo/00-LANG.txt +++ /dev/null @@ -1,8 +0,0 @@ -{{language|Berkeley Logo}} -{{language programming paradigm|Procedural}} -{{implementation|Logo}} -'''Berkeley Logo''' (or '''UCBLogo''') is a portable implementation of the Logo language, maintained by Brian Harvey. He has also written a series of university textbooks using this language, ''Computer Science Logo Style''. - -==External links== -* [http://www.cs.berkeley.edu/~bh/logo.html Home page] -* [https://github.com/jrincayc/ucblogo-code further UCBLogo development] \ No newline at end of file diff --git a/Lang/Berkeley-Logo/00-META.yaml b/Lang/Berkeley-Logo/00-META.yaml deleted file mode 100644 index 9eabccce73..0000000000 --- a/Lang/Berkeley-Logo/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Berkeley_Logo diff --git a/Lang/Berkeley-Logo/Abundant-deficient-and-perfect-number-classifications b/Lang/Berkeley-Logo/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index 04fb2b777b..0000000000 --- a/Lang/Berkeley-Logo/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/Berkeley-Logo \ No newline at end of file diff --git a/Lang/Berkeley-Logo/Associative-array-Creation b/Lang/Berkeley-Logo/Associative-array-Creation deleted file mode 120000 index 4d2050642e..0000000000 --- a/Lang/Berkeley-Logo/Associative-array-Creation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Creation/Berkeley-Logo \ No newline at end of file diff --git a/Lang/Berkeley-Logo/Babbage-problem b/Lang/Berkeley-Logo/Babbage-problem deleted file mode 120000 index aa1e4e41aa..0000000000 --- a/Lang/Berkeley-Logo/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/Berkeley-Logo \ No newline at end of file diff --git a/Lang/Berkeley-Logo/Bell-numbers b/Lang/Berkeley-Logo/Bell-numbers deleted file mode 120000 index 77a9bcb26c..0000000000 --- a/Lang/Berkeley-Logo/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/Berkeley-Logo \ No newline at end of file diff --git a/Lang/Berkeley-Logo/Formatted-numeric-output b/Lang/Berkeley-Logo/Formatted-numeric-output deleted file mode 120000 index 85a340c7e0..0000000000 --- a/Lang/Berkeley-Logo/Formatted-numeric-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Formatted-numeric-output/Berkeley-Logo \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/00-LANG.txt b/Lang/Binary-Lambda-Calculus/00-LANG.txt index 694f9a9437..b1d24e9edd 100644 --- a/Lang/Binary-Lambda-Calculus/00-LANG.txt +++ b/Lang/Binary-Lambda-Calculus/00-LANG.txt @@ -5,16 +5,6 @@ }} {{language programming paradigm|functional}} '''Binary Lambda Calculus''' is a minimal, pure, functional, esoteric language based on lambda calculus. [[provides::Capability:First class functions| ]] - ==External links== -* https://tromp.github.io/cl/cl.html -* https://www.ioccc.org/2012/tromp/hint.html -* https://gist.github.com/tromp/86b3184f852f65bfb814e3ab0987d861 - -Some implementations of BLC: -* [https://www.ioccc.org/2012/tromp/hint.html original tromp's implementation] for IOCCC, in pure ANSI C -* [https://github.com/tromp/AIT tromp's AIT], a project utilizing BLC for Information Theory research. Also includes a Haskell->BLC compiler and several other implementations -* [https://codeberg.org/aartaka/cl-blc aartaka's cl-blc], implementing BLC in Lisp - -==To do== -[[Tasks not implemented in Binary Lambda Calculus]] \ No newline at end of file +* [[eso:Binary_lambda_calculus|Esoteric languages wiki page]] +[[Category:Esoteric Languages]] \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/A+B b/Lang/Binary-Lambda-Calculus/A+B deleted file mode 120000 index 1a7c10c298..0000000000 --- a/Lang/Binary-Lambda-Calculus/A+B +++ /dev/null @@ -1 +0,0 @@ -../../Task/A+B/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Binary-digits b/Lang/Binary-Lambda-Calculus/Binary-digits deleted file mode 120000 index f74ad898bd..0000000000 --- a/Lang/Binary-Lambda-Calculus/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Church-numerals b/Lang/Binary-Lambda-Calculus/Church-numerals deleted file mode 120000 index 45f7ab14bd..0000000000 --- a/Lang/Binary-Lambda-Calculus/Church-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Church-numerals/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Ethiopian-multiplication b/Lang/Binary-Lambda-Calculus/Ethiopian-multiplication deleted file mode 120000 index 45465fad0c..0000000000 --- a/Lang/Binary-Lambda-Calculus/Ethiopian-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ethiopian-multiplication/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Hailstone-sequence b/Lang/Binary-Lambda-Calculus/Hailstone-sequence deleted file mode 120000 index 8bb334bdb3..0000000000 --- a/Lang/Binary-Lambda-Calculus/Hailstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hailstone-sequence/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Hello-world-Newbie b/Lang/Binary-Lambda-Calculus/Hello-world-Newbie deleted file mode 120000 index 290aaa1bd5..0000000000 --- a/Lang/Binary-Lambda-Calculus/Hello-world-Newbie +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newbie/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Hello-world-Text b/Lang/Binary-Lambda-Calculus/Hello-world-Text new file mode 120000 index 0000000000..b4dcf8b8a8 --- /dev/null +++ b/Lang/Binary-Lambda-Calculus/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Quine b/Lang/Binary-Lambda-Calculus/Quine new file mode 120000 index 0000000000..2c1595a394 --- /dev/null +++ b/Lang/Binary-Lambda-Calculus/Quine @@ -0,0 +1 @@ +../../Task/Quine/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Shell-one-liner b/Lang/Binary-Lambda-Calculus/Shell-one-liner deleted file mode 120000 index c3cce2be43..0000000000 --- a/Lang/Binary-Lambda-Calculus/Shell-one-liner +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shell-one-liner/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Binary-Lambda-Calculus/Sorting-algorithms-Merge-sort b/Lang/Binary-Lambda-Calculus/Sorting-algorithms-Merge-sort deleted file mode 120000 index 6a9a8bf4e0..0000000000 --- a/Lang/Binary-Lambda-Calculus/Sorting-algorithms-Merge-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Merge-sort/Binary-Lambda-Calculus \ No newline at end of file diff --git a/Lang/Blade/00-LANG.txt b/Lang/Blade/00-LANG.txt index 71d6c9cdba..f18c210bc3 100644 --- a/Lang/Blade/00-LANG.txt +++ b/Lang/Blade/00-LANG.txt @@ -6,13 +6,25 @@ |parampass=value |LCT=yes}}{{language programming paradigm|Object-oriented}}{{language programming paradigm|functional}} -'''Blade''' is a modern general-purpose programming language focused on enterprise Web, IoT, and secure application development. '''Blade''' offers a comprehensive set of tools and libraries out of the box leading to reduced reliance on third-party packages. +'''Blade''' is a simple, fast, clean and dynamic language that allows you to develop complex applications quickly. Blade emphasises algorithm over syntax and for this reason, it has a very small but powerful syntax set with a very natural feel. -'''Blade''' comes equipped with an integrated package management system, simplifying the management of both internal and external dependencies and a self-hostable repository server making it ideal for private organisational and personal use. Its intuitive syntax and gentle learning curve ensure an accessible experience for developers of all skill levels. Leveraging the best features from JavaScript, Python, Ruby, and Dart, '''Blade''' provides a familiar and robust ecosystem that enables developers to harness the strengths of these languages effortlessly. +If you’ve ever had experience with a compiled language (e.g. [[C]]/[[C++]], [[Java]], etc), then one thing you’ll quickly notice (at least I did) was how much the whole process of write-compile-run-debug can be tedious and get in the way of creative programming and sometimes you even forget that mind-blowing algorithm you were going to write and take over the world in the whole process of compiling. -While '''Blade''' focuses on Web and IoT, it is also great for general software development. +Sometimes, you just want to automate a few tasks, for example, I have a simple program to always remind me to get away from my laptop and eat something (you know how it is) and yet another one to suggest food for me. Do you find yourself needing this often? Do you know why you haven’t written it? Get out of your head, you are writing a compiled language! Compiling takes longer than the time it will take you to convince yourself that you need to eat. + +At other times, you have written this amazing program and you want users to be able to control it using a simple scripting language. I know… I know… there are many interpreted languages out there that will do the job just fine. Well… you still have one problem. Your users aren’t going to remember all the crazy going on in many of them (Yes [[Lua]]! I’m staring at you. What you gonna do about it?) + +Other times, we kind of find a very good solution to our problem in languages like [[Python]] (I must confess, even '''Blade''' did learn a lot of things from it), but the structure of such languages usually creates a new overhead in writing complex programs. It’s really difficult keeping a tab of indentations in such languages especially when you are not in a GUI IDE environment. I tried to work [[Python]] in nano, but man… it wasn’t easy. + +If you are feeling me, then Blade is just right for you. + +Blade is a simple language that has tried very much to learn from the mistake and successes of its predecessors. + +Blade is interpreted and simple like [[Python]] but with a more generic [[C]]-like syntax and a ridiculously simple Object-orientation similar to [[Dart]] and the granularity of [[JavaScript]] while still maintaining a very minimal syntax and keywords when compared to all of them. + +'''Blade is designed to be a memorizable language and the entire “language” can be learned in one sitting. However, Blade is as complete and powerful as any language can be and can be applied in the field of web, mobile, desktop, scientific, academic and research engineering to mention a few.''' ==Links== -* [https://bladelang.org https://bladelang.org] +* [https://bladelang.com https://bladelang.com] * [https://github.com/blade-lang/blade https://github.com/blade-lang/blade] -* [https://bladelang.org/quick-learn.html Quick Language Introduction] \ No newline at end of file +* [https://bladelang.com/quick-learn.html Quick Language Introduction] \ No newline at end of file diff --git a/Lang/BlooP/00-LANG.txt b/Lang/BlooP/00-LANG.txt index d0fc3b449f..61490d18ec 100644 --- a/Lang/BlooP/00-LANG.txt +++ b/Lang/BlooP/00-LANG.txt @@ -20,7 +20,7 @@ The best way to explain BlooP is really just to look at some examples, so here a Find the factorial of N: - + DEFINE PROCEDURE FACTORIAL [N]: BLOCK 0: BEGIN OUTPUT <= 1; @@ -31,11 +31,11 @@ BLOCK 0: BEGIN CELL(0) <= CELL(0) + 1; BLOCK 1: END; BLOCK 0: END. - + + - subtraction (this is the only way to do it, since it must be defined in terms of addition): - + DEFINE PROCEDURE MINUS [M,N]: BLOCK 0: BEGIN OUTPUT <= 0; @@ -48,12 +48,12 @@ BLOCK 0: BEGIN OUTPUT <= OUTPUT + 1; BLOCK 1: END; BLOCK 0: END. - + Nim game in BlooP. Since user input is not possible in most implementations, this version uses a procedure which takes 3 numbers. - + DEFINE PROCEDURE ''DIVIDE'' [A,B]: BLOCK 0: BEGIN IF A < B, THEN: @@ -145,7 +145,7 @@ BLOCK 0: BEGIN BLOCK 0: END. PLAY_GAME [2,1,1]; - + {{out}}
diff --git a/Lang/Blue/00-LANG.txt b/Lang/Blue/00-LANG.txt
index c95d4ccb01..32b7a80de4 100644
--- a/Lang/Blue/00-LANG.txt
+++ b/Lang/Blue/00-LANG.txt
@@ -3,7 +3,6 @@
 |site=https://github.com/jbirddog/blue
 |gc=no
 |untyped=yes}}
-{{language programming paradigm|concatenative}}
 
 Blue is a compiled low level [[Forth]]-like language that is designed for building programs without a standard library. Currently the x86-64 instruction set is supported. Example programs utilize Linux system calls but nothing in the language requires or assumes an operating system.
 
diff --git a/Lang/BootBASIC/00-LANG.txt b/Lang/BootBASIC/00-LANG.txt
index 42d742f5c8..a8f62b2d80 100644
--- a/Lang/BootBASIC/00-LANG.txt
+++ b/Lang/BootBASIC/00-LANG.txt
@@ -3,8 +3,4 @@
           |tags=basic,bootbasic
           }}
 {{Implementation|BASIC}}
-bootBASIC is an Integer BASIC interpreter created by Óscar Toledo Gutierrez that runs entirely within a boot sector on an x86-compatible machine, which is 512 bytes.
-
-==See Also==
-*[https://github.com/nanochess/bootBASIC bootBASIC on GitHub]
-*[https://parkertomatoes.github.io/v86/?type=mbr&content=Dg4OHwcX%2FL8AgMYFDUd1%2BrwA%2F7gQfFCwPuhPAegRAQnAdA7olgGX86TD6GwACcB0WOjiAIA8DXRQv8V9igVHmEh0E5FW86Z1BljoyQD%2FJQHPR0de6%2BbotABQrDw9dDS%2BZ3zoJgHrqUAjIQ0xwFDoSwGWgDwNdAtYUOigAKzoKQF1%2BlhAPegDdeTD6IAAULA%2F6NgA6AMAX6vD6BwAgDwtdA6APCt141DoDQBZAcjr7VDoBAD32OvzRugfAIA8L3QOgDwqdcRQ6BAAWffp6%2B1Q6AcAWZGZ9%2Fnr4kboOQCsPCh1C%2Bi0%2F4A8KXQr6XL%2FPEBzBk7oOwDrHzxydQuAPG51Bq3kQLQAw%2BgFAJOLB8OsJB8AwLR%2BTkaAPCB0%2BsMx0rkKAPfxCcBSdAPo8f9YBDDreTHbrCwwPAqYk3MJuQoA9%2BEBw%2BvuTsPNIOhO%2F7kxwOhrAIH8%2Fv50BKP8%2FsNQXgUUAFDozf5YPSDOdfHD6DsAvoB%2BVl%2FoLwCqPAh1Ak9PPA118sOsPA10JjwidQ2sPCJ0D%2BgWADwNdfTDTuj9%2Fuh9%2F6w8O3UJw7QAzRY8DXUHsAroAgCwDbQOuwcAzRDDuRQA9%2BEFAIDDBG5ldwB8BWxpc3RrfARydW5MfQZwcmludIJ9BmlucHV0inwDaWYqfAVnb3RvSH0Hc3lzdGVtRn0BVao%3D Try bootBASIC in v86 in your browser]
\ No newline at end of file
+bootBASIC is an Integer BASIC interpreter created by Óscar Toledo Gutierrez that runs entirely within a boot sector on an x86-compatible machine, which is 512 bytes.
\ No newline at end of file
diff --git a/Lang/BootBASIC/Empty-program b/Lang/BootBASIC/Empty-program
new file mode 120000
index 0000000000..5aaffbd057
--- /dev/null
+++ b/Lang/BootBASIC/Empty-program
@@ -0,0 +1 @@
+../../Task/Empty-program/BootBASIC
\ No newline at end of file
diff --git a/Lang/BootBASIC/Fibonacci-sequence b/Lang/BootBASIC/Fibonacci-sequence
deleted file mode 120000
index e7275cf6a0..0000000000
--- a/Lang/BootBASIC/Fibonacci-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fibonacci-sequence/BootBASIC
\ No newline at end of file
diff --git a/Lang/BootBASIC/Loops-Break b/Lang/BootBASIC/Loops-Break
deleted file mode 120000
index 6efa12814e..0000000000
--- a/Lang/BootBASIC/Loops-Break
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Break/BootBASIC
\ No newline at end of file
diff --git a/Lang/BootBASIC/Loops-N-plus-one-half b/Lang/BootBASIC/Loops-N-plus-one-half
deleted file mode 120000
index 6d9ca0cae0..0000000000
--- a/Lang/BootBASIC/Loops-N-plus-one-half
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-N-plus-one-half/BootBASIC
\ No newline at end of file
diff --git a/Lang/Bracmat/Miller-Rabin-primality-test b/Lang/Bracmat/Miller-Rabin-primality-test
new file mode 120000
index 0000000000..7c953943cd
--- /dev/null
+++ b/Lang/Bracmat/Miller-Rabin-primality-test
@@ -0,0 +1 @@
+../../Task/Miller-Rabin-primality-test/Bracmat
\ No newline at end of file
diff --git a/Lang/Brainf---/00-LANG.txt b/Lang/Brainf---/00-LANG.txt
index d9ca931bf4..7b702b4d45 100644
--- a/Lang/Brainf---/00-LANG.txt
+++ b/Lang/Brainf---/00-LANG.txt
@@ -63,10 +63,10 @@ BUT due to vehement opposition to the name [http://esolangs.org/wiki/Cupid vario
 ==See also==
 * [[Rosetta Code:Brainf***]]  ( why some people call it BF :)
 * [[RCBF]] - BF interpreters as a Rosetta Code task
-* [https://esolangs.org/wiki/brainfuck_algorithms brainf*** algorithms]
+
 ==Citations==
 
-* [https://esolangs.org/wiki/Brainfuck Esoteric languages wiki entry]
+* [[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]
diff --git a/Lang/Brainf---/Loops-While b/Lang/Brainf---/Loops-While
deleted file mode 120000
index 057717ea5a..0000000000
--- a/Lang/Brainf---/Loops-While
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-While/Brainf---
\ No newline at end of file
diff --git a/Lang/Bruijn/00-LANG.txt b/Lang/Bruijn/00-LANG.txt
deleted file mode 100644
index c0c565d6e8..0000000000
--- a/Lang/Bruijn/00-LANG.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-{{language|bruijn
-  |exec=interpreted
-  |LCT=no
-  |site=https://bruijn.marvinborner.de}}{{language programming paradigm|functional}}
-
-Bruijn is a [[functional_programming|functional]] programming language based on pure [[wp:lambda_calculus|lambda calculus]]. It uses De Bruijn indices instead of named variables and square brackets for abstractions. Like pure lambda calculus, bruijn can be compiled to [https://tromp.github.io/cl/Binary_lambda_calculus.html Binary Lambda Calculus]. Unlike pure lambda calculus, you can define named substitution rules. Bruijn has a large standard library of such definitions.
-
-Bruijn does not have primitive functions or data types. Every function (including add, map, mul, etc.) is implemented in bruijn itself. Numbers, strings, or chars are syntactic sugar for data encoded as closed terms/abstractions.
-
-Documentation can be found at https://bruijn.marvinborner.de/wiki/.
\ No newline at end of file
diff --git a/Lang/Bruijn/00-META.yaml b/Lang/Bruijn/00-META.yaml
deleted file mode 100644
index 1ddd70ba76..0000000000
--- a/Lang/Bruijn/00-META.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-from: http://rosettacode.org/wiki/Category:Bruijn
diff --git a/Lang/Bruijn/99-bottles-of-beer b/Lang/Bruijn/99-bottles-of-beer
deleted file mode 120000
index 12eb60082e..0000000000
--- a/Lang/Bruijn/99-bottles-of-beer
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/99-bottles-of-beer/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/A+B b/Lang/Bruijn/A+B
deleted file mode 120000
index f6bd8616cf..0000000000
--- a/Lang/Bruijn/A+B
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/A+B/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Ackermann-function b/Lang/Bruijn/Ackermann-function
deleted file mode 120000
index e9f8313783..0000000000
--- a/Lang/Bruijn/Ackermann-function
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Ackermann-function/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Balanced-ternary b/Lang/Bruijn/Balanced-ternary
deleted file mode 120000
index 1c4c028d9c..0000000000
--- a/Lang/Bruijn/Balanced-ternary
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Balanced-ternary/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Binary-search b/Lang/Bruijn/Binary-search
deleted file mode 120000
index 9cd581be5b..0000000000
--- a/Lang/Bruijn/Binary-search
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Binary-search/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Comments b/Lang/Bruijn/Comments
deleted file mode 120000
index e8f4b26296..0000000000
--- a/Lang/Bruijn/Comments
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Comments/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Compare-a-list-of-strings b/Lang/Bruijn/Compare-a-list-of-strings
deleted file mode 120000
index 3f35113df1..0000000000
--- a/Lang/Bruijn/Compare-a-list-of-strings
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Compare-a-list-of-strings/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Determine-sentence-type b/Lang/Bruijn/Determine-sentence-type
deleted file mode 120000
index 9232c5b2ff..0000000000
--- a/Lang/Bruijn/Determine-sentence-type
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Determine-sentence-type/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Empty-program b/Lang/Bruijn/Empty-program
deleted file mode 120000
index 2f8df23d95..0000000000
--- a/Lang/Bruijn/Empty-program
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Empty-program/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Factorial b/Lang/Bruijn/Factorial
deleted file mode 120000
index 52a5a29667..0000000000
--- a/Lang/Bruijn/Factorial
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Factorial/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Fibonacci-sequence b/Lang/Bruijn/Fibonacci-sequence
deleted file mode 120000
index 0eac3a48a3..0000000000
--- a/Lang/Bruijn/Fibonacci-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fibonacci-sequence/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/FizzBuzz b/Lang/Bruijn/FizzBuzz
deleted file mode 120000
index c2194b65ee..0000000000
--- a/Lang/Bruijn/FizzBuzz
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/FizzBuzz/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Function-composition b/Lang/Bruijn/Function-composition
deleted file mode 120000
index 9f9efd944a..0000000000
--- a/Lang/Bruijn/Function-composition
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Function-composition/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Greatest-common-divisor b/Lang/Bruijn/Greatest-common-divisor
deleted file mode 120000
index 3967007f1d..0000000000
--- a/Lang/Bruijn/Greatest-common-divisor
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Greatest-common-divisor/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Hailstone-sequence b/Lang/Bruijn/Hailstone-sequence
deleted file mode 120000
index 6f6aabadc5..0000000000
--- a/Lang/Bruijn/Hailstone-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hailstone-sequence/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Halt-and-catch-fire b/Lang/Bruijn/Halt-and-catch-fire
deleted file mode 120000
index ee57eeb8b4..0000000000
--- a/Lang/Bruijn/Halt-and-catch-fire
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Halt-and-catch-fire/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Hamming-numbers b/Lang/Bruijn/Hamming-numbers
deleted file mode 120000
index d835227d4a..0000000000
--- a/Lang/Bruijn/Hamming-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hamming-numbers/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Harmonic-series b/Lang/Bruijn/Harmonic-series
deleted file mode 120000
index b39ae4ae88..0000000000
--- a/Lang/Bruijn/Harmonic-series
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Harmonic-series/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Hello-world-Text b/Lang/Bruijn/Hello-world-Text
deleted file mode 120000
index f5faaa0772..0000000000
--- a/Lang/Bruijn/Hello-world-Text
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hello-world-Text/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Higher-order-functions b/Lang/Bruijn/Higher-order-functions
deleted file mode 120000
index 490f30652f..0000000000
--- a/Lang/Bruijn/Higher-order-functions
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Higher-order-functions/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Least-common-multiple b/Lang/Bruijn/Least-common-multiple
deleted file mode 120000
index 6042ac6fee..0000000000
--- a/Lang/Bruijn/Least-common-multiple
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Least-common-multiple/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Levenshtein-distance b/Lang/Bruijn/Levenshtein-distance
deleted file mode 120000
index e4887437b4..0000000000
--- a/Lang/Bruijn/Levenshtein-distance
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Levenshtein-distance/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Loops-Infinite b/Lang/Bruijn/Loops-Infinite
deleted file mode 120000
index 038234feba..0000000000
--- a/Lang/Bruijn/Loops-Infinite
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Infinite/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Luhn-test-of-credit-card-numbers b/Lang/Bruijn/Luhn-test-of-credit-card-numbers
deleted file mode 120000
index b0e2d09631..0000000000
--- a/Lang/Bruijn/Luhn-test-of-credit-card-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Luhn-test-of-credit-card-numbers/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Mutual-recursion b/Lang/Bruijn/Mutual-recursion
deleted file mode 120000
index daa75b7694..0000000000
--- a/Lang/Bruijn/Mutual-recursion
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Mutual-recursion/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Palindrome-detection b/Lang/Bruijn/Palindrome-detection
deleted file mode 120000
index 928ca8c645..0000000000
--- a/Lang/Bruijn/Palindrome-detection
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Palindrome-detection/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Prime-decomposition b/Lang/Bruijn/Prime-decomposition
deleted file mode 120000
index 2989bd88b7..0000000000
--- a/Lang/Bruijn/Prime-decomposition
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Prime-decomposition/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Sierpinski-triangle-Graphical b/Lang/Bruijn/Sierpinski-triangle-Graphical
deleted file mode 120000
index 5b896de867..0000000000
--- a/Lang/Bruijn/Sierpinski-triangle-Graphical
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sierpinski-triangle-Graphical/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Sorting-algorithms-Quicksort b/Lang/Bruijn/Sorting-algorithms-Quicksort
deleted file mode 120000
index 88bc24e9de..0000000000
--- a/Lang/Bruijn/Sorting-algorithms-Quicksort
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sorting-algorithms-Quicksort/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Sum-and-product-of-an-array b/Lang/Bruijn/Sum-and-product-of-an-array
deleted file mode 120000
index c56dea86f1..0000000000
--- a/Lang/Bruijn/Sum-and-product-of-an-array
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sum-and-product-of-an-array/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Ternary-logic b/Lang/Bruijn/Ternary-logic
deleted file mode 120000
index a4a336036c..0000000000
--- a/Lang/Bruijn/Ternary-logic
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Ternary-logic/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Test-a-function b/Lang/Bruijn/Test-a-function
deleted file mode 120000
index de62e05f97..0000000000
--- a/Lang/Bruijn/Test-a-function
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Test-a-function/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Towers-of-Hanoi b/Lang/Bruijn/Towers-of-Hanoi
deleted file mode 120000
index 96dafe6af8..0000000000
--- a/Lang/Bruijn/Towers-of-Hanoi
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Towers-of-Hanoi/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Validate-International-Securities-Identification-Number b/Lang/Bruijn/Validate-International-Securities-Identification-Number
deleted file mode 120000
index b96ffce45d..0000000000
--- a/Lang/Bruijn/Validate-International-Securities-Identification-Number
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Validate-International-Securities-Identification-Number/Bruijn
\ No newline at end of file
diff --git a/Lang/Bruijn/Y-combinator b/Lang/Bruijn/Y-combinator
deleted file mode 120000
index 3614ec75d6..0000000000
--- a/Lang/Bruijn/Y-combinator
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Y-combinator/Bruijn
\ No newline at end of file
diff --git a/Lang/Burlesque/00-LANG.txt b/Lang/Burlesque/00-LANG.txt
index ed9fb4f3d9..f4c2e90e61 100644
--- a/Lang/Burlesque/00-LANG.txt
+++ b/Lang/Burlesque/00-LANG.txt
@@ -13,12 +13,12 @@ allows to hide elements at the bottom of the stack and load it from there. Burle
 (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]].
diff --git a/Lang/C++/00-LANG.txt b/Lang/C++/00-LANG.txt
index 5bd73a99aa..f5d2924ed6 100644
--- a/Lang/C++/00-LANG.txt
+++ b/Lang/C++/00-LANG.txt
@@ -12,7 +12,7 @@
 |LCT=yes
 |bnf=http://cpp.comsci.us/syntax/statement/index.html}}{{codepad}}{{allows|Network access}}{{allows|Database access
 }}{{allows|Concurrency}}{{provides|Run time polymorphism}}{{provides|Compile time polymorphism}}{{allows|Windowing UI}}{{allows|Graphics}}{{allows|OpenGL}}{{allows|Dynamic linking}}{{provides|File access}}{{allows|File system access}}{{provides|Objects}}{{allows|Signal handling}}{{provides|Mutable state}}
-'''C++''' is named after the C language, from which it is derived. C++ extends C into an [[object-oriented language]]. However, unlike other object-oriented languages, it doesn't try to force you into [[object-oriented programming]], but is a multi-[[:Category:Programming Paradigms|paradigm]] language. Besides conventional [[procedural programming]] and object-oriented programming, it also supports [[generic programming]]. 
+'''C++''' is named after the [[derived from::compatible with::C]] language, from which it is derived. C++ extends C into an [[object-oriented language]]. However, unlike other object-oriented languages, it doesn't try to force you into [[object-oriented programming]], but is a multi-[[:Category:Programming Paradigms|paradigm]] language. Besides conventional [[procedural programming]] and object-oriented programming, it also supports [[generic programming]]. 
 
 If you can't find an implementation for your task in the C++ category below, please look in the [[C]] category, as many of the tasks can be implemented identically in C and C++.
 
diff --git a/Lang/C++/ADFGVX-cipher b/Lang/C++/ADFGVX-cipher
deleted file mode 120000
index 98aa7139a3..0000000000
--- a/Lang/C++/ADFGVX-cipher
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/ADFGVX-cipher/C++
\ No newline at end of file
diff --git a/Lang/C++/Add-a-variable-to-a-class-instance-at-runtime b/Lang/C++/Add-a-variable-to-a-class-instance-at-runtime
deleted file mode 120000
index 61888079c6..0000000000
--- a/Lang/C++/Add-a-variable-to-a-class-instance-at-runtime
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Add-a-variable-to-a-class-instance-at-runtime/C++
\ No newline at end of file
diff --git a/Lang/C++/B-zier-curves-Intersections b/Lang/C++/B-zier-curves-Intersections
deleted file mode 120000
index 8499695feb..0000000000
--- a/Lang/C++/B-zier-curves-Intersections
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/B-zier-curves-Intersections/C++
\ No newline at end of file
diff --git a/Lang/C++/Babylonian-spiral b/Lang/C++/Babylonian-spiral
deleted file mode 120000
index 274a26f938..0000000000
--- a/Lang/C++/Babylonian-spiral
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Babylonian-spiral/C++
\ No newline at end of file
diff --git a/Lang/C++/Bioinformatics-Global-alignment b/Lang/C++/Bioinformatics-Global-alignment
deleted file mode 120000
index 6c88065861..0000000000
--- a/Lang/C++/Bioinformatics-Global-alignment
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Bioinformatics-Global-alignment/C++
\ No newline at end of file
diff --git a/Lang/C++/Bioinformatics-base-count b/Lang/C++/Bioinformatics-base-count
new file mode 120000
index 0000000000..e0584bb6b7
--- /dev/null
+++ b/Lang/C++/Bioinformatics-base-count
@@ -0,0 +1 @@
+../../Task/Bioinformatics-base-count/C++
\ No newline at end of file
diff --git a/Lang/C++/Biorhythms b/Lang/C++/Biorhythms
deleted file mode 120000
index ef66403308..0000000000
--- a/Lang/C++/Biorhythms
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Biorhythms/C++
\ No newline at end of file
diff --git a/Lang/C++/Bitcoin-address-validation b/Lang/C++/Bitcoin-address-validation
deleted file mode 120000
index fdb6fa9bf8..0000000000
--- a/Lang/C++/Bitcoin-address-validation
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Bitcoin-address-validation/C++
\ No newline at end of file
diff --git a/Lang/C++/Bitcoin-public-point-to-address b/Lang/C++/Bitcoin-public-point-to-address
deleted file mode 120000
index 1229c8b30f..0000000000
--- a/Lang/C++/Bitcoin-public-point-to-address
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Bitcoin-public-point-to-address/C++
\ No newline at end of file
diff --git a/Lang/C++/Bitwise-IO b/Lang/C++/Bitwise-IO
deleted file mode 120000
index 0612736bad..0000000000
--- a/Lang/C++/Bitwise-IO
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Bitwise-IO/C++
\ No newline at end of file
diff --git a/Lang/C++/Blum-integer b/Lang/C++/Blum-integer
deleted file mode 120000
index 71cf501f4f..0000000000
--- a/Lang/C++/Blum-integer
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Blum-integer/C++
\ No newline at end of file
diff --git a/Lang/C++/Boyer-Moore-string-search b/Lang/C++/Boyer-Moore-string-search
deleted file mode 120000
index e5822491fa..0000000000
--- a/Lang/C++/Boyer-Moore-string-search
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Boyer-Moore-string-search/C++
\ No newline at end of file
diff --git a/Lang/C++/Camel-case-and-snake-case b/Lang/C++/Camel-case-and-snake-case
deleted file mode 120000
index a03d726c54..0000000000
--- a/Lang/C++/Camel-case-and-snake-case
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Camel-case-and-snake-case/C++
\ No newline at end of file
diff --git a/Lang/C++/Catmull-Clark-subdivision-surface b/Lang/C++/Catmull-Clark-subdivision-surface
deleted file mode 120000
index dbaa0ac83b..0000000000
--- a/Lang/C++/Catmull-Clark-subdivision-surface
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Catmull-Clark-subdivision-surface/C++
\ No newline at end of file
diff --git a/Lang/C++/Colorful-numbers b/Lang/C++/Colorful-numbers
deleted file mode 120000
index 45774ce3d7..0000000000
--- a/Lang/C++/Colorful-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Colorful-numbers/C++
\ No newline at end of file
diff --git a/Lang/C++/Commatizing-numbers b/Lang/C++/Commatizing-numbers
deleted file mode 120000
index 96b27f445d..0000000000
--- a/Lang/C++/Commatizing-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Commatizing-numbers/C++
\ No newline at end of file
diff --git a/Lang/C++/Compare-sorting-algorithms-performance b/Lang/C++/Compare-sorting-algorithms-performance
deleted file mode 120000
index 8616fdb726..0000000000
--- a/Lang/C++/Compare-sorting-algorithms-performance
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Compare-sorting-algorithms-performance/C++
\ No newline at end of file
diff --git a/Lang/C++/Compiler-virtual-machine-interpreter b/Lang/C++/Compiler-virtual-machine-interpreter
deleted file mode 120000
index 94f3cd637b..0000000000
--- a/Lang/C++/Compiler-virtual-machine-interpreter
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Compiler-virtual-machine-interpreter/C++
\ No newline at end of file
diff --git a/Lang/C++/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k b/Lang/C++/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k
deleted file mode 120000
index f464173750..0000000000
--- a/Lang/C++/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k/C++
\ No newline at end of file
diff --git a/Lang/C++/Convert-decimal-number-to-rational b/Lang/C++/Convert-decimal-number-to-rational
deleted file mode 120000
index b38261fbb7..0000000000
--- a/Lang/C++/Convert-decimal-number-to-rational
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Convert-decimal-number-to-rational/C++
\ No newline at end of file
diff --git a/Lang/C++/Cullen-and-Woodall-numbers b/Lang/C++/Cullen-and-Woodall-numbers
deleted file mode 120000
index d42755d636..0000000000
--- a/Lang/C++/Cullen-and-Woodall-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Cullen-and-Woodall-numbers/C++
\ No newline at end of file
diff --git a/Lang/C++/Currency b/Lang/C++/Currency
deleted file mode 120000
index ae0e8d6190..0000000000
--- a/Lang/C++/Currency
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Currency/C++
\ No newline at end of file
diff --git a/Lang/C++/Deconvolution-1D b/Lang/C++/Deconvolution-1D
deleted file mode 120000
index e1264f9bbd..0000000000
--- a/Lang/C++/Deconvolution-1D
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Deconvolution-1D/C++
\ No newline at end of file
diff --git a/Lang/C++/Deconvolution-2D+ b/Lang/C++/Deconvolution-2D+
deleted file mode 120000
index dba078e8e0..0000000000
--- a/Lang/C++/Deconvolution-2D+
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Deconvolution-2D+/C++
\ No newline at end of file
diff --git a/Lang/C++/Demings-funnel b/Lang/C++/Demings-funnel
deleted file mode 120000
index 4aaac74cc8..0000000000
--- a/Lang/C++/Demings-funnel
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Demings-funnel/C++
\ No newline at end of file
diff --git a/Lang/C++/Determine-sentence-type b/Lang/C++/Determine-sentence-type
deleted file mode 120000
index 707f2f3f78..0000000000
--- a/Lang/C++/Determine-sentence-type
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Determine-sentence-type/C++
\ No newline at end of file
diff --git a/Lang/C++/Distance-and-Bearing b/Lang/C++/Distance-and-Bearing
deleted file mode 120000
index 3df222c9d2..0000000000
--- a/Lang/C++/Distance-and-Bearing
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Distance-and-Bearing/C++
\ No newline at end of file
diff --git a/Lang/C++/Documentation b/Lang/C++/Documentation
deleted file mode 120000
index dd69dde201..0000000000
--- a/Lang/C++/Documentation
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Documentation/C++
\ No newline at end of file
diff --git a/Lang/C++/Dominoes b/Lang/C++/Dominoes
deleted file mode 120000
index 5c79b6947b..0000000000
--- a/Lang/C++/Dominoes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Dominoes/C++
\ No newline at end of file
diff --git a/Lang/C++/Dynamic-variable-names b/Lang/C++/Dynamic-variable-names
deleted file mode 120000
index 315556ef17..0000000000
--- a/Lang/C++/Dynamic-variable-names
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Dynamic-variable-names/C++
\ No newline at end of file
diff --git a/Lang/C++/EKG-sequence-convergence b/Lang/C++/EKG-sequence-convergence
deleted file mode 120000
index 752c0b16e1..0000000000
--- a/Lang/C++/EKG-sequence-convergence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/EKG-sequence-convergence/C++
\ No newline at end of file
diff --git a/Lang/C++/Elliptic-Curve-Digital-Signature-Algorithm b/Lang/C++/Elliptic-Curve-Digital-Signature-Algorithm
deleted file mode 120000
index 908d4e7ad6..0000000000
--- a/Lang/C++/Elliptic-Curve-Digital-Signature-Algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Elliptic-Curve-Digital-Signature-Algorithm/C++
\ No newline at end of file
diff --git a/Lang/C++/Euclid-Mullin-sequence b/Lang/C++/Euclid-Mullin-sequence
deleted file mode 120000
index f743f51e54..0000000000
--- a/Lang/C++/Euclid-Mullin-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Euclid-Mullin-sequence/C++
\ No newline at end of file
diff --git a/Lang/C++/Extend-your-language b/Lang/C++/Extend-your-language
deleted file mode 120000
index da1eb035c9..0000000000
--- a/Lang/C++/Extend-your-language
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Extend-your-language/C++
\ No newline at end of file
diff --git a/Lang/C++/Extreme-floating-point-values b/Lang/C++/Extreme-floating-point-values
deleted file mode 120000
index 36dd74b460..0000000000
--- a/Lang/C++/Extreme-floating-point-values
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Extreme-floating-point-values/C++
\ No newline at end of file
diff --git a/Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection b/Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection
deleted file mode 120000
index 9b984d5ea4..0000000000
--- a/Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Factorial-base-numbers-indexing-permutations-of-a-collection/C++
\ No newline at end of file
diff --git a/Lang/C++/Find-Chess960-starting-position-identifier b/Lang/C++/Find-Chess960-starting-position-identifier
deleted file mode 120000
index c936ac89a0..0000000000
--- a/Lang/C++/Find-Chess960-starting-position-identifier
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Find-Chess960-starting-position-identifier/C++
\ No newline at end of file
diff --git a/Lang/C++/Find-palindromic-numbers-in-both-binary-and-ternary-bases b/Lang/C++/Find-palindromic-numbers-in-both-binary-and-ternary-bases
deleted file mode 120000
index 8aca209101..0000000000
--- a/Lang/C++/Find-palindromic-numbers-in-both-binary-and-ternary-bases
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Find-palindromic-numbers-in-both-binary-and-ternary-bases/C++
\ No newline at end of file
diff --git a/Lang/C++/First-class-environments b/Lang/C++/First-class-environments
deleted file mode 120000
index 652816150b..0000000000
--- a/Lang/C++/First-class-environments
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/First-class-environments/C++
\ No newline at end of file
diff --git a/Lang/C++/Fortunate-numbers b/Lang/C++/Fortunate-numbers
deleted file mode 120000
index 7264ffc786..0000000000
--- a/Lang/C++/Fortunate-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fortunate-numbers/C++
\ No newline at end of file
diff --git a/Lang/C++/French-Republican-calendar b/Lang/C++/French-Republican-calendar
deleted file mode 120000
index b361af00f6..0000000000
--- a/Lang/C++/French-Republican-calendar
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/French-Republican-calendar/C++
\ No newline at end of file
diff --git a/Lang/C++/Functional-coverage-tree b/Lang/C++/Functional-coverage-tree
deleted file mode 120000
index 06e1a4bfaf..0000000000
--- a/Lang/C++/Functional-coverage-tree
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Functional-coverage-tree/C++
\ No newline at end of file
diff --git a/Lang/C++/Graph-colouring b/Lang/C++/Graph-colouring
deleted file mode 120000
index 8c4ffa4219..0000000000
--- a/Lang/C++/Graph-colouring
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Graph-colouring/C++
\ No newline at end of file
diff --git a/Lang/C++/Hex-words b/Lang/C++/Hex-words
deleted file mode 120000
index faf96263f0..0000000000
--- a/Lang/C++/Hex-words
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hex-words/C++
\ No newline at end of file
diff --git a/Lang/C++/History-variables b/Lang/C++/History-variables
deleted file mode 120000
index 1e4a8dbc3b..0000000000
--- a/Lang/C++/History-variables
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/History-variables/C++
\ No newline at end of file
diff --git a/Lang/C++/Holidays-related-to-Easter b/Lang/C++/Holidays-related-to-Easter
deleted file mode 120000
index 021ab990c1..0000000000
--- a/Lang/C++/Holidays-related-to-Easter
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Holidays-related-to-Easter/C++
\ No newline at end of file
diff --git a/Lang/C++/Im-a-software-engineer-get-me-out-of-here b/Lang/C++/Im-a-software-engineer-get-me-out-of-here
deleted file mode 120000
index 7c9de1375f..0000000000
--- a/Lang/C++/Im-a-software-engineer-get-me-out-of-here
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Im-a-software-engineer-get-me-out-of-here/C++
\ No newline at end of file
diff --git a/Lang/C++/Jordan-P-lya-numbers b/Lang/C++/Jordan-P-lya-numbers
deleted file mode 120000
index 2ced79cc8d..0000000000
--- a/Lang/C++/Jordan-P-lya-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Jordan-P-lya-numbers/C++
\ No newline at end of file
diff --git a/Lang/C++/Knapsack-problem-Unbounded b/Lang/C++/Knapsack-problem-Unbounded
deleted file mode 120000
index 9f78e2dcbd..0000000000
--- a/Lang/C++/Knapsack-problem-Unbounded
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Knapsack-problem-Unbounded/C++
\ No newline at end of file
diff --git a/Lang/C++/Levenshtein-distance-Alignment b/Lang/C++/Levenshtein-distance-Alignment
deleted file mode 120000
index 7c11f353ab..0000000000
--- a/Lang/C++/Levenshtein-distance-Alignment
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Levenshtein-distance-Alignment/C++
\ No newline at end of file
diff --git a/Lang/C++/Long-literals-with-continuations b/Lang/C++/Long-literals-with-continuations
deleted file mode 120000
index 911214b251..0000000000
--- a/Lang/C++/Long-literals-with-continuations
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Long-literals-with-continuations/C++
\ No newline at end of file
diff --git a/Lang/C++/Loops-Wrong-ranges b/Lang/C++/Loops-Wrong-ranges
deleted file mode 120000
index 96b90678c9..0000000000
--- a/Lang/C++/Loops-Wrong-ranges
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Wrong-ranges/C++
\ No newline at end of file
diff --git a/Lang/C++/MD4 b/Lang/C++/MD4
deleted file mode 120000
index 403f4ef081..0000000000
--- a/Lang/C++/MD4
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/MD4/C++
\ No newline at end of file
diff --git a/Lang/C++/MD5-Implementation b/Lang/C++/MD5-Implementation
deleted file mode 120000
index b31aca0e67..0000000000
--- a/Lang/C++/MD5-Implementation
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/MD5-Implementation/C++
\ No newline at end of file
diff --git a/Lang/C++/Magic-constant b/Lang/C++/Magic-constant
deleted file mode 120000
index 442fba4633..0000000000
--- a/Lang/C++/Magic-constant
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Magic-constant/C++
\ No newline at end of file
diff --git a/Lang/C++/Matrix-chain-multiplication b/Lang/C++/Matrix-chain-multiplication
deleted file mode 120000
index dd51839476..0000000000
--- a/Lang/C++/Matrix-chain-multiplication
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Matrix-chain-multiplication/C++
\ No newline at end of file
diff --git a/Lang/C++/Mayan-calendar b/Lang/C++/Mayan-calendar
deleted file mode 120000
index 3283cc776d..0000000000
--- a/Lang/C++/Mayan-calendar
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Mayan-calendar/C++
\ No newline at end of file
diff --git a/Lang/C++/Mayan-numerals b/Lang/C++/Mayan-numerals
deleted file mode 120000
index b2152a3f38..0000000000
--- a/Lang/C++/Mayan-numerals
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Mayan-numerals/C++
\ No newline at end of file
diff --git a/Lang/C++/McNuggets-problem b/Lang/C++/McNuggets-problem
deleted file mode 120000
index 26315fdf5f..0000000000
--- a/Lang/C++/McNuggets-problem
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/McNuggets-problem/C++
\ No newline at end of file
diff --git a/Lang/C++/Metronome b/Lang/C++/Metronome
deleted file mode 120000
index 64cb1fbb2c..0000000000
--- a/Lang/C++/Metronome
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Metronome/C++
\ No newline at end of file
diff --git a/Lang/C++/Mind-boggling-card-trick b/Lang/C++/Mind-boggling-card-trick
deleted file mode 120000
index 2a21de96ed..0000000000
--- a/Lang/C++/Mind-boggling-card-trick
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Mind-boggling-card-trick/C++
\ No newline at end of file
diff --git a/Lang/C++/Minimal-steps-down-to-1 b/Lang/C++/Minimal-steps-down-to-1
deleted file mode 120000
index 024c7cb7fa..0000000000
--- a/Lang/C++/Minimal-steps-down-to-1
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Minimal-steps-down-to-1/C++
\ No newline at end of file
diff --git a/Lang/C++/Minkowski-question-mark-function b/Lang/C++/Minkowski-question-mark-function
deleted file mode 120000
index b52b1b784c..0000000000
--- a/Lang/C++/Minkowski-question-mark-function
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Minkowski-question-mark-function/C++
\ No newline at end of file
diff --git a/Lang/C++/Modified-random-distribution b/Lang/C++/Modified-random-distribution
deleted file mode 120000
index 216ea99a69..0000000000
--- a/Lang/C++/Modified-random-distribution
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Modified-random-distribution/C++
\ No newline at end of file
diff --git a/Lang/C++/Mouse-position b/Lang/C++/Mouse-position
deleted file mode 120000
index a68146f1b0..0000000000
--- a/Lang/C++/Mouse-position
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Mouse-position/C++
\ No newline at end of file
diff --git a/Lang/C++/Natural-sorting b/Lang/C++/Natural-sorting
deleted file mode 120000
index 221a15ac6d..0000000000
--- a/Lang/C++/Natural-sorting
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Natural-sorting/C++
\ No newline at end of file
diff --git a/Lang/C++/Non-transitive-dice b/Lang/C++/Non-transitive-dice
deleted file mode 120000
index 2c6300fda7..0000000000
--- a/Lang/C++/Non-transitive-dice
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Non-transitive-dice/C++
\ No newline at end of file
diff --git a/Lang/C++/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/C++/Numbers-which-are-not-the-sum-of-distinct-squares
deleted file mode 120000
index 0383a88d34..0000000000
--- a/Lang/C++/Numbers-which-are-not-the-sum-of-distinct-squares
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/C++
\ No newline at end of file
diff --git a/Lang/C++/OpenWebNet-password b/Lang/C++/OpenWebNet-password
deleted file mode 120000
index 8ebe3bb3ea..0000000000
--- a/Lang/C++/OpenWebNet-password
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/OpenWebNet-password/C++
\ No newline at end of file
diff --git a/Lang/C++/Own-digits-power-sum b/Lang/C++/Own-digits-power-sum
deleted file mode 120000
index 766e68b021..0000000000
--- a/Lang/C++/Own-digits-power-sum
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Own-digits-power-sum/C++
\ No newline at end of file
diff --git a/Lang/C++/P-Adic-numbers-basic b/Lang/C++/P-Adic-numbers-basic
deleted file mode 120000
index a3301f743f..0000000000
--- a/Lang/C++/P-Adic-numbers-basic
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/P-Adic-numbers-basic/C++
\ No newline at end of file
diff --git a/Lang/C++/P-Adic-square-roots b/Lang/C++/P-Adic-square-roots
deleted file mode 120000
index a25d0f7d5c..0000000000
--- a/Lang/C++/P-Adic-square-roots
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/P-Adic-square-roots/C++
\ No newline at end of file
diff --git a/Lang/C++/Padovan-n-step-number-sequences b/Lang/C++/Padovan-n-step-number-sequences
deleted file mode 120000
index 7ac07bcd12..0000000000
--- a/Lang/C++/Padovan-n-step-number-sequences
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Padovan-n-step-number-sequences/C++
\ No newline at end of file
diff --git a/Lang/C++/Paraffins b/Lang/C++/Paraffins
deleted file mode 120000
index 97f2318ced..0000000000
--- a/Lang/C++/Paraffins
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Paraffins/C++
\ No newline at end of file
diff --git a/Lang/C++/Pentomino-tiling b/Lang/C++/Pentomino-tiling
deleted file mode 120000
index ed8fbc82bd..0000000000
--- a/Lang/C++/Pentomino-tiling
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Pentomino-tiling/C++
\ No newline at end of file
diff --git a/Lang/C++/Periodic-table b/Lang/C++/Periodic-table
deleted file mode 120000
index ed19cc1b0e..0000000000
--- a/Lang/C++/Periodic-table
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Periodic-table/C++
\ No newline at end of file
diff --git a/Lang/C++/Perlin-noise b/Lang/C++/Perlin-noise
deleted file mode 120000
index 7b0cb9e4f7..0000000000
--- a/Lang/C++/Perlin-noise
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Perlin-noise/C++
\ No newline at end of file
diff --git a/Lang/C++/Permutations-Derangements b/Lang/C++/Permutations-Derangements
deleted file mode 120000
index bd96da6362..0000000000
--- a/Lang/C++/Permutations-Derangements
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Permutations-Derangements/C++
\ No newline at end of file
diff --git a/Lang/C++/Permutations-Rank-of-a-permutation b/Lang/C++/Permutations-Rank-of-a-permutation
deleted file mode 120000
index 8154150665..0000000000
--- a/Lang/C++/Permutations-Rank-of-a-permutation
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Permutations-Rank-of-a-permutation/C++
\ No newline at end of file
diff --git a/Lang/C++/Pisano-period b/Lang/C++/Pisano-period
deleted file mode 120000
index 649197ce20..0000000000
--- a/Lang/C++/Pisano-period
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Pisano-period/C++
\ No newline at end of file
diff --git a/Lang/C++/Prime-numbers-whose-neighboring-pairs-are-tetraprimes b/Lang/C++/Prime-numbers-whose-neighboring-pairs-are-tetraprimes
deleted file mode 120000
index 3fdfaf7ab6..0000000000
--- a/Lang/C++/Prime-numbers-whose-neighboring-pairs-are-tetraprimes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/C++
\ No newline at end of file
diff --git a/Lang/C++/Problem-of-Apollonius b/Lang/C++/Problem-of-Apollonius
deleted file mode 120000
index 7195179aa2..0000000000
--- a/Lang/C++/Problem-of-Apollonius
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Problem-of-Apollonius/C++
\ No newline at end of file
diff --git a/Lang/C++/Quaternion-type b/Lang/C++/Quaternion-type
new file mode 120000
index 0000000000..053fd1142a
--- /dev/null
+++ b/Lang/C++/Quaternion-type
@@ -0,0 +1 @@
+../../Task/Quaternion-type/C++
\ No newline at end of file
diff --git a/Lang/C++/Quoting-constructs b/Lang/C++/Quoting-constructs
deleted file mode 120000
index 85f4da28e3..0000000000
--- a/Lang/C++/Quoting-constructs
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Quoting-constructs/C++
\ No newline at end of file
diff --git a/Lang/C++/RIPEMD-160 b/Lang/C++/RIPEMD-160
deleted file mode 120000
index 6d52fa405f..0000000000
--- a/Lang/C++/RIPEMD-160
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/RIPEMD-160/C++
\ No newline at end of file
diff --git a/Lang/C++/Radical-of-an-integer b/Lang/C++/Radical-of-an-integer
deleted file mode 120000
index 4918741eda..0000000000
--- a/Lang/C++/Radical-of-an-integer
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Radical-of-an-integer/C++
\ No newline at end of file
diff --git a/Lang/C++/Ramanujan-primes-twins b/Lang/C++/Ramanujan-primes-twins
deleted file mode 120000
index 3cd9279724..0000000000
--- a/Lang/C++/Ramanujan-primes-twins
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Ramanujan-primes-twins/C++
\ No newline at end of file
diff --git a/Lang/C++/Rendezvous b/Lang/C++/Rendezvous
deleted file mode 120000
index b1c8af4bea..0000000000
--- a/Lang/C++/Rendezvous
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Rendezvous/C++
\ No newline at end of file
diff --git a/Lang/C++/Search-in-paragraphs-text b/Lang/C++/Search-in-paragraphs-text
deleted file mode 120000
index 2ef4ef4a04..0000000000
--- a/Lang/C++/Search-in-paragraphs-text
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Search-in-paragraphs-text/C++
\ No newline at end of file
diff --git a/Lang/C++/Secure-temporary-file b/Lang/C++/Secure-temporary-file
deleted file mode 120000
index 24210e5146..0000000000
--- a/Lang/C++/Secure-temporary-file
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Secure-temporary-file/C++
\ No newline at end of file
diff --git a/Lang/C++/Simple-database b/Lang/C++/Simple-database
deleted file mode 120000
index 60394bf013..0000000000
--- a/Lang/C++/Simple-database
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Simple-database/C++
\ No newline at end of file
diff --git a/Lang/C++/Sisyphus-sequence b/Lang/C++/Sisyphus-sequence
deleted file mode 120000
index 9d0b48977f..0000000000
--- a/Lang/C++/Sisyphus-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sisyphus-sequence/C++
\ No newline at end of file
diff --git a/Lang/C++/Sort-an-outline-at-every-level b/Lang/C++/Sort-an-outline-at-every-level
deleted file mode 120000
index 5467a50bff..0000000000
--- a/Lang/C++/Sort-an-outline-at-every-level
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sort-an-outline-at-every-level/C++
\ No newline at end of file
diff --git a/Lang/C++/Sorting-Algorithms-Circle-Sort b/Lang/C++/Sorting-Algorithms-Circle-Sort
new file mode 120000
index 0000000000..91c7b06653
--- /dev/null
+++ b/Lang/C++/Sorting-Algorithms-Circle-Sort
@@ -0,0 +1 @@
+../../Task/Sorting-Algorithms-Circle-Sort/C++
\ No newline at end of file
diff --git a/Lang/C++/Square-form-factorization b/Lang/C++/Square-form-factorization
deleted file mode 120000
index 02b9bbca28..0000000000
--- a/Lang/C++/Square-form-factorization
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Square-form-factorization/C++
\ No newline at end of file
diff --git a/Lang/C++/Strassens-algorithm b/Lang/C++/Strassens-algorithm
deleted file mode 120000
index 1423f44a39..0000000000
--- a/Lang/C++/Strassens-algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Strassens-algorithm/C++
\ No newline at end of file
diff --git a/Lang/C++/Table-creation-Postal-addresses b/Lang/C++/Table-creation-Postal-addresses
deleted file mode 120000
index e821bbe93f..0000000000
--- a/Lang/C++/Table-creation-Postal-addresses
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Table-creation-Postal-addresses/C++
\ No newline at end of file
diff --git a/Lang/C++/Terminal-control-Coloured-text b/Lang/C++/Terminal-control-Coloured-text
deleted file mode 120000
index d28321a098..0000000000
--- a/Lang/C++/Terminal-control-Coloured-text
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Terminal-control-Coloured-text/C++
\ No newline at end of file
diff --git a/Lang/C++/The-sieve-of-Sundaram b/Lang/C++/The-sieve-of-Sundaram
deleted file mode 120000
index e0a2a39b88..0000000000
--- a/Lang/C++/The-sieve-of-Sundaram
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/The-sieve-of-Sundaram/C++
\ No newline at end of file
diff --git a/Lang/C++/Tonelli-Shanks-algorithm b/Lang/C++/Tonelli-Shanks-algorithm
deleted file mode 120000
index c3fb6b9d19..0000000000
--- a/Lang/C++/Tonelli-Shanks-algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Tonelli-Shanks-algorithm/C++
\ No newline at end of file
diff --git a/Lang/C++/Total-circles-area b/Lang/C++/Total-circles-area
deleted file mode 120000
index d9453103bd..0000000000
--- a/Lang/C++/Total-circles-area
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Total-circles-area/C++
\ No newline at end of file
diff --git a/Lang/C++/URL-parser b/Lang/C++/URL-parser
deleted file mode 120000
index c94d78f772..0000000000
--- a/Lang/C++/URL-parser
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/URL-parser/C++
\ No newline at end of file
diff --git a/Lang/C++/UTF-8-encode-and-decode b/Lang/C++/UTF-8-encode-and-decode
deleted file mode 120000
index a3942ee81c..0000000000
--- a/Lang/C++/UTF-8-encode-and-decode
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/UTF-8-encode-and-decode/C++
\ No newline at end of file
diff --git a/Lang/C++/Ukkonen-s-suffix-tree-construction b/Lang/C++/Ukkonen-s-suffix-tree-construction
deleted file mode 120000
index 3dffa49793..0000000000
--- a/Lang/C++/Ukkonen-s-suffix-tree-construction
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Ukkonen-s-suffix-tree-construction/C++
\ No newline at end of file
diff --git a/Lang/C++/Unicode-variable-names b/Lang/C++/Unicode-variable-names
deleted file mode 120000
index 229d06451e..0000000000
--- a/Lang/C++/Unicode-variable-names
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Unicode-variable-names/C++
\ No newline at end of file
diff --git a/Lang/C++/Update-a-configuration-file b/Lang/C++/Update-a-configuration-file
deleted file mode 120000
index dd78746576..0000000000
--- a/Lang/C++/Update-a-configuration-file
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Update-a-configuration-file/C++
\ No newline at end of file
diff --git a/Lang/C++/Wasteful-equidigital-and-frugal-numbers b/Lang/C++/Wasteful-equidigital-and-frugal-numbers
deleted file mode 120000
index ab51274f10..0000000000
--- a/Lang/C++/Wasteful-equidigital-and-frugal-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Wasteful-equidigital-and-frugal-numbers/C++
\ No newline at end of file
diff --git a/Lang/C++/Wordiff b/Lang/C++/Wordiff
deleted file mode 120000
index 13c6f44a9e..0000000000
--- a/Lang/C++/Wordiff
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Wordiff/C++
\ No newline at end of file
diff --git a/Lang/C-sharp/00-LANG.txt b/Lang/C-sharp/00-LANG.txt
index 2ffb00e180..17083312b1 100644
--- a/Lang/C-sharp/00-LANG.txt
+++ b/Lang/C-sharp/00-LANG.txt
@@ -17,10 +17,6 @@
 ==Citations==
 *[[wp:C_Sharp_(programming_language)|Wikipedia:C#]]
 
-== External links ==
-=== Online editors and compilers ===
-*[https://www.onlinegdb.com/ GDB Online Compiler] (Select C#)
-
 {{language programming paradigm|Imperative}}
 {{language programming paradigm|Object-oriented}}
 {{language programming paradigm|Generic}}
diff --git a/Lang/C-sharp/ADFGVX-cipher b/Lang/C-sharp/ADFGVX-cipher
deleted file mode 120000
index 1bd5856497..0000000000
--- a/Lang/C-sharp/ADFGVX-cipher
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/ADFGVX-cipher/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/ASCII-art-diagram-converter b/Lang/C-sharp/ASCII-art-diagram-converter
deleted file mode 120000
index a3c0a49ccd..0000000000
--- a/Lang/C-sharp/ASCII-art-diagram-converter
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/ASCII-art-diagram-converter/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Additive-primes b/Lang/C-sharp/Additive-primes
deleted file mode 120000
index d958846baf..0000000000
--- a/Lang/C-sharp/Additive-primes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Additive-primes/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Aliquot-sequence-classifications b/Lang/C-sharp/Aliquot-sequence-classifications
deleted file mode 120000
index 2c0be649f4..0000000000
--- a/Lang/C-sharp/Aliquot-sequence-classifications
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Aliquot-sequence-classifications/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Arithmetic-derivative b/Lang/C-sharp/Arithmetic-derivative
deleted file mode 120000
index 99fc50446f..0000000000
--- a/Lang/C-sharp/Arithmetic-derivative
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Arithmetic-derivative/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Arithmetic-numbers b/Lang/C-sharp/Arithmetic-numbers
deleted file mode 120000
index 7b33f4b583..0000000000
--- a/Lang/C-sharp/Arithmetic-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Arithmetic-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/B-zier-curves-Intersections b/Lang/C-sharp/B-zier-curves-Intersections
deleted file mode 120000
index 9583a4224f..0000000000
--- a/Lang/C-sharp/B-zier-curves-Intersections
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/B-zier-curves-Intersections/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Bifid-cipher b/Lang/C-sharp/Bifid-cipher
deleted file mode 120000
index 53987e0c76..0000000000
--- a/Lang/C-sharp/Bifid-cipher
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Bifid-cipher/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Blum-integer b/Lang/C-sharp/Blum-integer
deleted file mode 120000
index 6e857dea48..0000000000
--- a/Lang/C-sharp/Blum-integer
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Blum-integer/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Boyer-Moore-string-search b/Lang/C-sharp/Boyer-Moore-string-search
deleted file mode 120000
index 6d8ebe0502..0000000000
--- a/Lang/C-sharp/Boyer-Moore-string-search
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Boyer-Moore-string-search/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Calkin-Wilf-sequence b/Lang/C-sharp/Calkin-Wilf-sequence
deleted file mode 120000
index 75d6e98750..0000000000
--- a/Lang/C-sharp/Calkin-Wilf-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Calkin-Wilf-sequence/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Camel-case-and-snake-case b/Lang/C-sharp/Camel-case-and-snake-case
deleted file mode 120000
index 0b673ec8ed..0000000000
--- a/Lang/C-sharp/Camel-case-and-snake-case
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Camel-case-and-snake-case/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Cistercian-numerals b/Lang/C-sharp/Cistercian-numerals
deleted file mode 120000
index d482ff0533..0000000000
--- a/Lang/C-sharp/Cistercian-numerals
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Cistercian-numerals/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Colorful-numbers b/Lang/C-sharp/Colorful-numbers
deleted file mode 120000
index b35a72c815..0000000000
--- a/Lang/C-sharp/Colorful-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Colorful-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Combinations-and-permutations b/Lang/C-sharp/Combinations-and-permutations
deleted file mode 120000
index c322432e6c..0000000000
--- a/Lang/C-sharp/Combinations-and-permutations
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Combinations-and-permutations/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/C-sharp/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-
deleted file mode 120000
index 2adfbd6635..0000000000
--- a/Lang/C-sharp/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Cut-a-rectangle b/Lang/C-sharp/Cut-a-rectangle
deleted file mode 120000
index 4cec3edeaa..0000000000
--- a/Lang/C-sharp/Cut-a-rectangle
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Cut-a-rectangle/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Cyclops-numbers b/Lang/C-sharp/Cyclops-numbers
deleted file mode 120000
index c4380e8ccd..0000000000
--- a/Lang/C-sharp/Cyclops-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Cyclops-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Demings-funnel b/Lang/C-sharp/Demings-funnel
deleted file mode 120000
index 283a7555df..0000000000
--- a/Lang/C-sharp/Demings-funnel
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Demings-funnel/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Determinant-and-permanent b/Lang/C-sharp/Determinant-and-permanent
deleted file mode 120000
index fa8d657eeb..0000000000
--- a/Lang/C-sharp/Determinant-and-permanent
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Determinant-and-permanent/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Dice-game-probabilities b/Lang/C-sharp/Dice-game-probabilities
deleted file mode 120000
index 8f72eba47d..0000000000
--- a/Lang/C-sharp/Dice-game-probabilities
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Dice-game-probabilities/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Disarium-numbers b/Lang/C-sharp/Disarium-numbers
deleted file mode 120000
index 47381ac73c..0000000000
--- a/Lang/C-sharp/Disarium-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Disarium-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Distribution-of-0-digits-in-factorial-series b/Lang/C-sharp/Distribution-of-0-digits-in-factorial-series
deleted file mode 120000
index a7d175e94a..0000000000
--- a/Lang/C-sharp/Distribution-of-0-digits-in-factorial-series
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Distribution-of-0-digits-in-factorial-series/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Doomsday-rule b/Lang/C-sharp/Doomsday-rule
deleted file mode 120000
index f572c2a651..0000000000
--- a/Lang/C-sharp/Doomsday-rule
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Doomsday-rule/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Elliptic-Curve-Digital-Signature-Algorithm b/Lang/C-sharp/Elliptic-Curve-Digital-Signature-Algorithm
deleted file mode 120000
index 82412a8f32..0000000000
--- a/Lang/C-sharp/Elliptic-Curve-Digital-Signature-Algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Elliptic-Curve-Digital-Signature-Algorithm/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Erd-s-Nicolas-numbers b/Lang/C-sharp/Erd-s-Nicolas-numbers
deleted file mode 120000
index 2a21b589d2..0000000000
--- a/Lang/C-sharp/Erd-s-Nicolas-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Erd-s-Nicolas-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Execute-a-Markov-algorithm b/Lang/C-sharp/Execute-a-Markov-algorithm
deleted file mode 120000
index fac2e3f425..0000000000
--- a/Lang/C-sharp/Execute-a-Markov-algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Execute-a-Markov-algorithm/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Extensible-prime-generator b/Lang/C-sharp/Extensible-prime-generator
deleted file mode 120000
index 1e4636d3bb..0000000000
--- a/Lang/C-sharp/Extensible-prime-generator
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Extensible-prime-generator/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Fairshare-between-two-and-more b/Lang/C-sharp/Fairshare-between-two-and-more
deleted file mode 120000
index 444efb1248..0000000000
--- a/Lang/C-sharp/Fairshare-between-two-and-more
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fairshare-between-two-and-more/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/File-extension-is-in-extensions-list b/Lang/C-sharp/File-extension-is-in-extensions-list
deleted file mode 120000
index caec470709..0000000000
--- a/Lang/C-sharp/File-extension-is-in-extensions-list
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/File-extension-is-in-extensions-list/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Find-if-a-point-is-within-a-triangle b/Lang/C-sharp/Find-if-a-point-is-within-a-triangle
deleted file mode 120000
index 0c9dec87d9..0000000000
--- a/Lang/C-sharp/Find-if-a-point-is-within-a-triangle
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Find-if-a-point-is-within-a-triangle/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Fortunate-numbers b/Lang/C-sharp/Fortunate-numbers
deleted file mode 120000
index 5f6e57871d..0000000000
--- a/Lang/C-sharp/Fortunate-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fortunate-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Fractran b/Lang/C-sharp/Fractran
deleted file mode 120000
index e1ba558448..0000000000
--- a/Lang/C-sharp/Fractran
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fractran/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Generate-Chess960-starting-position b/Lang/C-sharp/Generate-Chess960-starting-position
deleted file mode 120000
index a44601322a..0000000000
--- a/Lang/C-sharp/Generate-Chess960-starting-position
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Generate-Chess960-starting-position/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Golden-ratio-Convergence b/Lang/C-sharp/Golden-ratio-Convergence
deleted file mode 120000
index ea91aeb897..0000000000
--- a/Lang/C-sharp/Golden-ratio-Convergence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Golden-ratio-Convergence/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Gotchas b/Lang/C-sharp/Gotchas
deleted file mode 120000
index c20938cf21..0000000000
--- a/Lang/C-sharp/Gotchas
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Gotchas/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Graph-colouring b/Lang/C-sharp/Graph-colouring
deleted file mode 120000
index 9124611f31..0000000000
--- a/Lang/C-sharp/Graph-colouring
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Graph-colouring/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Harmonic-series b/Lang/C-sharp/Harmonic-series
deleted file mode 120000
index 621fdcd007..0000000000
--- a/Lang/C-sharp/Harmonic-series
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Harmonic-series/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Hickerson-series-of-almost-integers b/Lang/C-sharp/Hickerson-series-of-almost-integers
deleted file mode 120000
index 1409bf65fa..0000000000
--- a/Lang/C-sharp/Hickerson-series-of-almost-integers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hickerson-series-of-almost-integers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Index-finite-lists-of-positive-integers b/Lang/C-sharp/Index-finite-lists-of-positive-integers
deleted file mode 120000
index 692e611ddc..0000000000
--- a/Lang/C-sharp/Index-finite-lists-of-positive-integers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Index-finite-lists-of-positive-integers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Jacobsthal-numbers b/Lang/C-sharp/Jacobsthal-numbers
deleted file mode 120000
index 8d875d3e3c..0000000000
--- a/Lang/C-sharp/Jacobsthal-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Jacobsthal-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Jaro-similarity b/Lang/C-sharp/Jaro-similarity
deleted file mode 120000
index 76ee880028..0000000000
--- a/Lang/C-sharp/Jaro-similarity
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Jaro-similarity/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Jordan-P-lya-numbers b/Lang/C-sharp/Jordan-P-lya-numbers
deleted file mode 120000
index bdd5391b84..0000000000
--- a/Lang/C-sharp/Jordan-P-lya-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Jordan-P-lya-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Juggler-sequence b/Lang/C-sharp/Juggler-sequence
deleted file mode 120000
index 7c2e1e5df3..0000000000
--- a/Lang/C-sharp/Juggler-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Juggler-sequence/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/K-d-tree b/Lang/C-sharp/K-d-tree
deleted file mode 120000
index 9ea6355b83..0000000000
--- a/Lang/C-sharp/K-d-tree
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/K-d-tree/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Levenshtein-distance-Alignment b/Lang/C-sharp/Levenshtein-distance-Alignment
deleted file mode 120000
index 4a86af53da..0000000000
--- a/Lang/C-sharp/Levenshtein-distance-Alignment
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Levenshtein-distance-Alignment/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Longest-string-challenge b/Lang/C-sharp/Longest-string-challenge
deleted file mode 120000
index bd57b65702..0000000000
--- a/Lang/C-sharp/Longest-string-challenge
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Longest-string-challenge/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/M-bius-function b/Lang/C-sharp/M-bius-function
deleted file mode 120000
index 56f84fb14c..0000000000
--- a/Lang/C-sharp/M-bius-function
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/M-bius-function/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Magic-constant b/Lang/C-sharp/Magic-constant
deleted file mode 120000
index b74721e026..0000000000
--- a/Lang/C-sharp/Magic-constant
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Magic-constant/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Magic-squares-of-singly-even-order b/Lang/C-sharp/Magic-squares-of-singly-even-order
deleted file mode 120000
index 7c09d264d6..0000000000
--- a/Lang/C-sharp/Magic-squares-of-singly-even-order
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Magic-squares-of-singly-even-order/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Main-step-of-GOST-28147-89 b/Lang/C-sharp/Main-step-of-GOST-28147-89
deleted file mode 120000
index 0d0396ff34..0000000000
--- a/Lang/C-sharp/Main-step-of-GOST-28147-89
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Main-step-of-GOST-28147-89/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Maze-solving b/Lang/C-sharp/Maze-solving
deleted file mode 120000
index 9a643105b4..0000000000
--- a/Lang/C-sharp/Maze-solving
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Maze-solving/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Metronome b/Lang/C-sharp/Metronome
deleted file mode 120000
index d943840c54..0000000000
--- a/Lang/C-sharp/Metronome
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Metronome/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Miller-Rabin-primality-test b/Lang/C-sharp/Miller-Rabin-primality-test
new file mode 120000
index 0000000000..4d27fefcbd
--- /dev/null
+++ b/Lang/C-sharp/Miller-Rabin-primality-test
@@ -0,0 +1 @@
+../../Task/Miller-Rabin-primality-test/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Mind-boggling-card-trick b/Lang/C-sharp/Mind-boggling-card-trick
deleted file mode 120000
index 65b695076e..0000000000
--- a/Lang/C-sharp/Mind-boggling-card-trick
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Mind-boggling-card-trick/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Minkowski-question-mark-function b/Lang/C-sharp/Minkowski-question-mark-function
deleted file mode 120000
index b16d1e756c..0000000000
--- a/Lang/C-sharp/Minkowski-question-mark-function
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Minkowski-question-mark-function/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Next-highest-int-from-digits b/Lang/C-sharp/Next-highest-int-from-digits
deleted file mode 120000
index 2462971188..0000000000
--- a/Lang/C-sharp/Next-highest-int-from-digits
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Next-highest-int-from-digits/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/P-Adic-numbers-basic b/Lang/C-sharp/P-Adic-numbers-basic
deleted file mode 120000
index 564565afb6..0000000000
--- a/Lang/C-sharp/P-Adic-numbers-basic
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/P-Adic-numbers-basic/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Padovan-sequence b/Lang/C-sharp/Padovan-sequence
deleted file mode 120000
index a90cb74ae7..0000000000
--- a/Lang/C-sharp/Padovan-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Padovan-sequence/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Pancake-numbers b/Lang/C-sharp/Pancake-numbers
deleted file mode 120000
index 5088584c71..0000000000
--- a/Lang/C-sharp/Pancake-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Pancake-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Parse-an-IP-Address b/Lang/C-sharp/Parse-an-IP-Address
deleted file mode 120000
index fe231a87e2..0000000000
--- a/Lang/C-sharp/Parse-an-IP-Address
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Parse-an-IP-Address/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Periodic-table b/Lang/C-sharp/Periodic-table
deleted file mode 120000
index 97d676b17d..0000000000
--- a/Lang/C-sharp/Periodic-table
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Periodic-table/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Prime-numbers-whose-neighboring-pairs-are-tetraprimes b/Lang/C-sharp/Prime-numbers-whose-neighboring-pairs-are-tetraprimes
deleted file mode 120000
index 6222df483b..0000000000
--- a/Lang/C-sharp/Prime-numbers-whose-neighboring-pairs-are-tetraprimes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Pseudo-random-numbers-PCG32 b/Lang/C-sharp/Pseudo-random-numbers-PCG32
deleted file mode 120000
index c32a0bbbd9..0000000000
--- a/Lang/C-sharp/Pseudo-random-numbers-PCG32
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Pseudo-random-numbers-PCG32/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Quaternion-type b/Lang/C-sharp/Quaternion-type
new file mode 120000
index 0000000000..53c4bd6185
--- /dev/null
+++ b/Lang/C-sharp/Quaternion-type
@@ -0,0 +1 @@
+../../Task/Quaternion-type/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Ray-casting-algorithm b/Lang/C-sharp/Ray-casting-algorithm
deleted file mode 120000
index 67165907f8..0000000000
--- a/Lang/C-sharp/Ray-casting-algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Ray-casting-algorithm/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Reflection-Get-source b/Lang/C-sharp/Reflection-Get-source
deleted file mode 120000
index a8b2f45e4c..0000000000
--- a/Lang/C-sharp/Reflection-Get-source
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Reflection-Get-source/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Rep-string b/Lang/C-sharp/Rep-string
deleted file mode 120000
index 0c89d0f939..0000000000
--- a/Lang/C-sharp/Rep-string
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Rep-string/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Sequence:-smallest-number-with-exactly-n-divisors b/Lang/C-sharp/Sequence:-smallest-number-with-exactly-n-divisors
deleted file mode 120000
index 71508d1c44..0000000000
--- a/Lang/C-sharp/Sequence:-smallest-number-with-exactly-n-divisors
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sequence:-smallest-number-with-exactly-n-divisors/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Solve-the-no-connection-puzzle b/Lang/C-sharp/Solve-the-no-connection-puzzle
deleted file mode 120000
index f2a7bf3a0e..0000000000
--- a/Lang/C-sharp/Solve-the-no-connection-puzzle
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Solve-the-no-connection-puzzle/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Sorting-Algorithms-Circle-Sort b/Lang/C-sharp/Sorting-Algorithms-Circle-Sort
new file mode 120000
index 0000000000..6f1414c420
--- /dev/null
+++ b/Lang/C-sharp/Sorting-Algorithms-Circle-Sort
@@ -0,0 +1 @@
+../../Task/Sorting-Algorithms-Circle-Sort/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Spelling-of-ordinal-numbers b/Lang/C-sharp/Spelling-of-ordinal-numbers
deleted file mode 120000
index f9129a4b80..0000000000
--- a/Lang/C-sharp/Spelling-of-ordinal-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Spelling-of-ordinal-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Sphenic-numbers b/Lang/C-sharp/Sphenic-numbers
deleted file mode 120000
index e745ee5efe..0000000000
--- a/Lang/C-sharp/Sphenic-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sphenic-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Square-free-integers b/Lang/C-sharp/Square-free-integers
deleted file mode 120000
index 6cabcf20b3..0000000000
--- a/Lang/C-sharp/Square-free-integers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Square-free-integers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Strassens-algorithm b/Lang/C-sharp/Strassens-algorithm
deleted file mode 120000
index 45fd91dfa9..0000000000
--- a/Lang/C-sharp/Strassens-algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Strassens-algorithm/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Suffixation-of-decimal-numbers b/Lang/C-sharp/Suffixation-of-decimal-numbers
deleted file mode 120000
index 2db739988c..0000000000
--- a/Lang/C-sharp/Suffixation-of-decimal-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Suffixation-of-decimal-numbers/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Summarize-primes b/Lang/C-sharp/Summarize-primes
deleted file mode 120000
index de1b22714d..0000000000
--- a/Lang/C-sharp/Summarize-primes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Summarize-primes/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Sylvesters-sequence b/Lang/C-sharp/Sylvesters-sequence
deleted file mode 120000
index 3899fa057e..0000000000
--- a/Lang/C-sharp/Sylvesters-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sylvesters-sequence/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Tau-function b/Lang/C-sharp/Tau-function
deleted file mode 120000
index aa9069413d..0000000000
--- a/Lang/C-sharp/Tau-function
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Tau-function/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Tau-number b/Lang/C-sharp/Tau-number
deleted file mode 120000
index 0980d5ce28..0000000000
--- a/Lang/C-sharp/Tau-number
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Tau-number/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Topswops b/Lang/C-sharp/Topswops
deleted file mode 120000
index 3f10a6cb93..0000000000
--- a/Lang/C-sharp/Topswops
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Topswops/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Total-circles-area b/Lang/C-sharp/Total-circles-area
deleted file mode 120000
index d1b9a6ffb2..0000000000
--- a/Lang/C-sharp/Total-circles-area
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Total-circles-area/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Tree-from-nesting-levels b/Lang/C-sharp/Tree-from-nesting-levels
deleted file mode 120000
index e46b1553ea..0000000000
--- a/Lang/C-sharp/Tree-from-nesting-levels
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Tree-from-nesting-levels/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Tropical-algebra-overloading b/Lang/C-sharp/Tropical-algebra-overloading
deleted file mode 120000
index 1b61aaaf8d..0000000000
--- a/Lang/C-sharp/Tropical-algebra-overloading
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Tropical-algebra-overloading/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Ultra-useful-primes b/Lang/C-sharp/Ultra-useful-primes
deleted file mode 120000
index 2258e0373a..0000000000
--- a/Lang/C-sharp/Ultra-useful-primes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Ultra-useful-primes/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Variable-declaration-reset b/Lang/C-sharp/Variable-declaration-reset
deleted file mode 120000
index ec0809da88..0000000000
--- a/Lang/C-sharp/Variable-declaration-reset
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Variable-declaration-reset/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Verify-distribution-uniformity-Chi-squared-test b/Lang/C-sharp/Verify-distribution-uniformity-Chi-squared-test
deleted file mode 120000
index 5101b70787..0000000000
--- a/Lang/C-sharp/Verify-distribution-uniformity-Chi-squared-test
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Verify-distribution-uniformity-Chi-squared-test/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Verify-distribution-uniformity-Naive b/Lang/C-sharp/Verify-distribution-uniformity-Naive
deleted file mode 120000
index c41f1e05f6..0000000000
--- a/Lang/C-sharp/Verify-distribution-uniformity-Naive
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Verify-distribution-uniformity-Naive/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Vogels-approximation-method b/Lang/C-sharp/Vogels-approximation-method
deleted file mode 120000
index bb638d067a..0000000000
--- a/Lang/C-sharp/Vogels-approximation-method
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Vogels-approximation-method/C-sharp
\ No newline at end of file
diff --git a/Lang/C-sharp/Yellowstone-sequence b/Lang/C-sharp/Yellowstone-sequence
deleted file mode 120000
index 793ce587ba..0000000000
--- a/Lang/C-sharp/Yellowstone-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Yellowstone-sequence/C-sharp
\ No newline at end of file
diff --git a/Lang/C/00-LANG.txt b/Lang/C/00-LANG.txt
index de69a4599c..e91629b964 100644
--- a/Lang/C/00-LANG.txt
+++ b/Lang/C/00-LANG.txt
@@ -29,27 +29,27 @@ C has since spread to many other [[:Category:Platforms|platforms]], and is now o
 ==Overview==
 
 ===Curly Braces===
-C uses curly braces as a separator for sections of code. All curly braces must be "balanced," i.e. every left curly brace must have a right curly brace after it. Nesting curly brace pairs inside curly braces is also acceptable as long as none of them are "lonely."
+C uses curly braces as a separator for sections of code. All curly braces must be "balanced," i.e. every left curly brace must have a right curly brace after it. Nesting curly brace pairs inside curly braces is also acceptable as long as none of them are "lonely." Most advanced code editors will help you with curly braces by automatically typing the right brace as soon as you type the left one.
 
-Most advanced code editors will help you with curly braces by automatically typing the right brace as soon as you type the left one. It is a matter of style as to whether you prefer to place an opening curly brace on its own line or at the end of the previous line. Here we use the latter style.
+int main()
+{
 
-int main() {
+// your main program goes here
+// if you forgot either of these curly braces you would get an error message when you try to compile!
 
-    // Your main program goes here.
-    // If you forgot either of these curly braces you would get an error message when you try to compile!
-
-}
+}
 
 The contents of a function, if statement, etc. must be enclosed in curly braces for the code to count as part of that section.
-{     
-    // This wouldn't actually compile as none of these variables were declared in this scope. More on that later. 
+{     
+//this wouldn't actually compile as none of these variables were declared in this scope. More on that later. 
 
-    if (K == 3) {
-        X = Y;  // This line will be skipped if K doesn't equal 3.
-    }
-    Y = Z;      // This is not part of the if statement. It will execute even if K doesn't equal 3.
+if (K == 3)
+{
+X = Y;        //this line will be skipped if K doesn't equal 3.
+}
+Y = Z;        //this is not part of the if statement. It will execute even if K doesn't equal 3.
 
-}
+}
 
 ===Semicolons===
 Any "executable" statement must end in a semicolon, such as an assignment or function call. If you get an error message from your compiler, it won't explicitly tell you "Expected semicolon at end of line X." Go to the line number it says the error is at, and look a few lines above that. You might have forgotten a semicolon there.
@@ -59,57 +59,58 @@ Unlike assembly which lets you jump anywhere or read any memory address, C impos
 
 ===Functions===
 A function is made up of three parts: its return type, its name, and its arguments. 
-int main(void) // This is the function "main," which takes no arguments and returns a 32-bit signed integer value.
+int main(void)       //This is the function "main," which takes no arguments and returns a 32-bit signed integer value.
 
-int sum(int a, int b) // This is the function "sum," which takes two integer arguments and returns an integer.
+int sum(int a,int b) //This is the function "sum," which takes two integer arguments and returns an integer.
 
 void PlaySound(char songName) 
-// This takes a character string as an argument and presumably sends a command to sound hardware.
-// It returns no values. Functions that have a return value of "void" typically do some sort of 
-// procedure whose outcome does not need to be measured or remembered later.
+//This takes a character string as an argument and presumably sends a command to sound hardware.
+//It returns no values. Functions that have a return value of "void" typically do some sort of 
+//procedure whose outcome does not need to be measured or remembered later.
 
 Note that the variable names listed as arguments when declaring a function are known as formal parameters and only are there to define the function. Variables with those names need not be declared or defined in your actual function, nor do they refer to any variables in your program that happen to have the same name. Essentially, formal parameters act as placeholders for the actual function parameters that you'll be using.
-int foo(int x) {
-    return x;
+int foo(int x){
+return x;
 } // "x" doesn't need to be a variable in your real program. If it is, that's not related in any way to the "x" here.
 
-int main() {
+int main()
+{
 
-    int y;
-    int z = 2;
+int y;
+int z = 2;
 
-    y = foo(z);  // Note that x was never involved. That's because the "x" earlier was the formal parameter.
+y = foo(z);      //note that x was never involved. That's because the "x" earlier was the formal parameter.
 
-}
+}
 
 ===Assignment===
 C allows you to define a variable as equal to a value, in more ways than just simple numerals.
-int a = 3; // Declare the variable a of type int, define it equal to decimal 3.
+int a = 3; //declare the variable a of type int, define it equal to decimal 3.
 
-int b = -1; // Declare the variable b of type int and equal to -1 (0xFFFFFFFF in hex).
+int b = -1; //declare the variable b of type int, define it equal to -1 (0xFFFFFFFF in hex)
 
 char letter = "A";
-// Declare the variable "letter" of type char and equal to capital A.
-// C allows you to treat an ascii value as its numeric equivalent whenever you feel like it. Other languages do not.
+//declare the variable "letter" of type char, it equals capital A.
+//C allows you to treat an ascii value as its numeric equivalent whenever you feel like it. Other languages do not.
 
-char *myString = "Hello"; // Define the array "myString" containing the letters "Hello" followed by a null terminator.
+char myString = "Hello"; //define the array "myString" containing the letters "Hello" followed by a null terminator.
 
-int myArray[5] = {10, 20, 30, 40, 50}; 
-// Declare the array variable "myArray" containing integer values, with a maximum size of 5 elements.
-// Then assign 10 to the beginning, 20 after it, 30 after that, and so on.
+int myArray[5] = {10,20,30,40,50}; 
+//declare the array variable "myArray" containing integer values, with a maximum size of 5 elements.
+//Then assign 10 to the beginning, 20 after it, 30 after that, and so on.
 
-int c = sum(a, b); 
-// Declare the integer variable "c". 
-// Define it to equal the output of the function sum using the previously defined variables "a" and "b" as arguments.
-// When this line of code is executed, the computer will perform the function "sum(a,b)" and store the result in c.
-// This is only valid if the return type of the function "sum" matches the type of the variable "c."
+int c = sum(a,b); 
+//declare the integer variable "c". 
+//Define it to equal the output of the function sum using the previously defined variables "a" and "b" as arguments.
+//When this line of code is executed, the computer will perform the function "sum(a,b)" and store the result in c.
+//This is only valid if the return type of the function "sum" matches the type of the variable "c."
 
 ===Declaring vs. Defining===
 This is a very unintuitive aspect of C that often confuses new users. Declaring a variable or function tells the compiler that a function may exist. Defining a variable or function assigns it a value or procedure, respectively. Compare the two examples below:
-int a; // The variable "a" has been declared, but not defined.
-a = 2; // Now the variable has been defined.
+int a; // The variable "a" has been declared, but not defined.
+a = 2; // Now the variable has been defined.
 
-int a = 2; // The variable "a" has been both declared and defined.
+int a = 2; //The variable "a" has been both declared and defined.
 
 * You cannot define a variable without declaring it first.
 * Before a variable can be used, it must be defined.
@@ -128,13 +129,13 @@ You can also add a few modifiers in front of the variable type to be more specif
 * volatile tells the compiler that this variable's value can changed by the hardware. This is commonly used for hardware registers such as those that track the mouse cursor's location, a scanline counter, etc. The value will always be read from its original memory location, ensuring that its value is always up-to-date.
 
 Examples:
-unsigned int x;
-volatile int HorizontalScroll;
+unsigned int x;
+volatile int HorizontalScroll;
 
 Functions are declared in a similar fashion to variables, except a function's "type" is the type of the value it returns.
-int foo(int bar); 
+int foo(int bar); 
 // The function foo was declared. It takes an integer as an argument and returns an integer.
-// What it actually does is currently unknown but can be defined later.
+// What it actually does is currently unknown but can be defined later.
 
 ==Citation==
 *[[wp:C_%28programming_language%29|Wikipedia:C (programming language)]]
diff --git a/Lang/C/Achilles-numbers b/Lang/C/Achilles-numbers
deleted file mode 120000
index 5c3326676b..0000000000
--- a/Lang/C/Achilles-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Achilles-numbers/C
\ No newline at end of file
diff --git a/Lang/C/Bioinformatics-base-count b/Lang/C/Bioinformatics-base-count
new file mode 120000
index 0000000000..4819495149
--- /dev/null
+++ b/Lang/C/Bioinformatics-base-count
@@ -0,0 +1 @@
+../../Task/Bioinformatics-base-count/C
\ No newline at end of file
diff --git a/Lang/C/Color-wheel b/Lang/C/Color-wheel
deleted file mode 120000
index 9d6561adcd..0000000000
--- a/Lang/C/Color-wheel
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Color-wheel/C
\ No newline at end of file
diff --git a/Lang/C/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k b/Lang/C/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k
deleted file mode 120000
index ddb6ce6303..0000000000
--- a/Lang/C/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k/C
\ No newline at end of file
diff --git a/Lang/C/Distance-and-Bearing b/Lang/C/Distance-and-Bearing
deleted file mode 120000
index 4496c69ac6..0000000000
--- a/Lang/C/Distance-and-Bearing
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Distance-and-Bearing/C
\ No newline at end of file
diff --git a/Lang/C/Dynamic-variable-names b/Lang/C/Dynamic-variable-names
deleted file mode 120000
index 278fe3b232..0000000000
--- a/Lang/C/Dynamic-variable-names
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Dynamic-variable-names/C
\ No newline at end of file
diff --git a/Lang/C/Execute-Computer-Zero b/Lang/C/Execute-Computer-Zero
deleted file mode 120000
index c10597c078..0000000000
--- a/Lang/C/Execute-Computer-Zero
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Execute-Computer-Zero/C
\ No newline at end of file
diff --git a/Lang/C/Harmonic-series b/Lang/C/Harmonic-series
deleted file mode 120000
index dfebedc2c8..0000000000
--- a/Lang/C/Harmonic-series
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Harmonic-series/C
\ No newline at end of file
diff --git a/Lang/C/History-variables b/Lang/C/History-variables
deleted file mode 120000
index 3a73616359..0000000000
--- a/Lang/C/History-variables
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/History-variables/C
\ No newline at end of file
diff --git a/Lang/C/Hunt-the-Wumpus b/Lang/C/Hunt-the-Wumpus
deleted file mode 120000
index e7186ced48..0000000000
--- a/Lang/C/Hunt-the-Wumpus
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hunt-the-Wumpus/C
\ No newline at end of file
diff --git a/Lang/C/Magic-constant b/Lang/C/Magic-constant
deleted file mode 120000
index 3d29fd6624..0000000000
--- a/Lang/C/Magic-constant
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Magic-constant/C
\ No newline at end of file
diff --git a/Lang/C/Miller-Rabin-primality-test b/Lang/C/Miller-Rabin-primality-test
new file mode 120000
index 0000000000..b9ab762a9c
--- /dev/null
+++ b/Lang/C/Miller-Rabin-primality-test
@@ -0,0 +1 @@
+../../Task/Miller-Rabin-primality-test/C
\ No newline at end of file
diff --git a/Lang/C/Nested-templated-data b/Lang/C/Nested-templated-data
deleted file mode 120000
index ef78f3cb0c..0000000000
--- a/Lang/C/Nested-templated-data
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Nested-templated-data/C
\ No newline at end of file
diff --git a/Lang/C/One-time-pad b/Lang/C/One-time-pad
deleted file mode 120000
index e0845d9058..0000000000
--- a/Lang/C/One-time-pad
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/One-time-pad/C
\ No newline at end of file
diff --git a/Lang/C/Pig-the-dice-game-Player b/Lang/C/Pig-the-dice-game-Player
deleted file mode 120000
index 28ecb509a8..0000000000
--- a/Lang/C/Pig-the-dice-game-Player
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Pig-the-dice-game-Player/C
\ No newline at end of file
diff --git a/Lang/C/Quaternion-type b/Lang/C/Quaternion-type
new file mode 120000
index 0000000000..25d9910755
--- /dev/null
+++ b/Lang/C/Quaternion-type
@@ -0,0 +1 @@
+../../Task/Quaternion-type/C
\ No newline at end of file
diff --git a/Lang/C/Radical-of-an-integer b/Lang/C/Radical-of-an-integer
deleted file mode 120000
index 3683a9456a..0000000000
--- a/Lang/C/Radical-of-an-integer
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Radical-of-an-integer/C
\ No newline at end of file
diff --git a/Lang/C/Search-in-paragraphs-text b/Lang/C/Search-in-paragraphs-text
deleted file mode 120000
index 11cd3d2def..0000000000
--- a/Lang/C/Search-in-paragraphs-text
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Search-in-paragraphs-text/C
\ No newline at end of file
diff --git a/Lang/C/Sleeping-Beauty-problem b/Lang/C/Sleeping-Beauty-problem
deleted file mode 120000
index 193e808670..0000000000
--- a/Lang/C/Sleeping-Beauty-problem
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sleeping-Beauty-problem/C
\ No newline at end of file
diff --git a/Lang/C/Sorting-Algorithms-Circle-Sort b/Lang/C/Sorting-Algorithms-Circle-Sort
new file mode 120000
index 0000000000..335574f406
--- /dev/null
+++ b/Lang/C/Sorting-Algorithms-Circle-Sort
@@ -0,0 +1 @@
+../../Task/Sorting-Algorithms-Circle-Sort/C
\ No newline at end of file
diff --git a/Lang/C3/Binary-digits b/Lang/C3/Binary-digits
deleted file mode 120000
index 34a04afae2..0000000000
--- a/Lang/C3/Binary-digits
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Binary-digits/C3
\ No newline at end of file
diff --git a/Lang/C3/Bulls-and-cows b/Lang/C3/Bulls-and-cows
deleted file mode 120000
index b5099b13d9..0000000000
--- a/Lang/C3/Bulls-and-cows
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Bulls-and-cows/C3
\ No newline at end of file
diff --git a/Lang/C3/Command-line-arguments b/Lang/C3/Command-line-arguments
deleted file mode 120000
index 6dc09a6fa5..0000000000
--- a/Lang/C3/Command-line-arguments
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Command-line-arguments/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-Continue b/Lang/C3/Loops-Continue
deleted file mode 120000
index f66d22e3d8..0000000000
--- a/Lang/C3/Loops-Continue
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Continue/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-Do-while b/Lang/C3/Loops-Do-while
deleted file mode 120000
index 993e10f705..0000000000
--- a/Lang/C3/Loops-Do-while
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Do-while/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-Downward-for b/Lang/C3/Loops-Downward-for
deleted file mode 120000
index 446607d46f..0000000000
--- a/Lang/C3/Loops-Downward-for
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Downward-for/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-For b/Lang/C3/Loops-For
deleted file mode 120000
index 21cda2f4ec..0000000000
--- a/Lang/C3/Loops-For
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-For/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-For-with-a-specified-step b/Lang/C3/Loops-For-with-a-specified-step
deleted file mode 120000
index 6ee66b7714..0000000000
--- a/Lang/C3/Loops-For-with-a-specified-step
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-For-with-a-specified-step/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-Foreach b/Lang/C3/Loops-Foreach
deleted file mode 120000
index bf5ed82064..0000000000
--- a/Lang/C3/Loops-Foreach
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Foreach/C3
\ No newline at end of file
diff --git a/Lang/C3/Loops-Infinite b/Lang/C3/Loops-Infinite
deleted file mode 120000
index 6741d32d81..0000000000
--- a/Lang/C3/Loops-Infinite
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Loops-Infinite/C3
\ No newline at end of file
diff --git a/Lang/CB80/00-LANG.txt b/Lang/CB80/00-LANG.txt
index 86de52ef42..96b8bf005c 100644
--- a/Lang/CB80/00-LANG.txt
+++ b/Lang/CB80/00-LANG.txt
@@ -1,2 +1 @@
-{{language}}{{Stub}}
-CB80 is not a separate language or dialect but rather a companion compiler for the [[CBASIC]] dialect of BASIC for 8-bit CP/M systems. The CBASIC compiler compiles source code into an intermediate form, which is stored on disk with the file extension INT. The compiled code is executed by invoking a run-time interpreter (CRUN.COM) from the command line. CB80, by contrast, compiles the source into a relocatable machine code file having an REL extension, which is then linked with necessary run-time library routines using the supplied linker (either LINK.COM or LK80.COM), to create a stand-alone executable file with the extension COM, which can be run simply by typing its name on the CP/M command-line. All of the posted CBASIC examples on Rosetta Code as of 9/14/2024 will compile and run without change under CB80. One subtle difference which could affect some programs lies in the behavior of the FOR .. NEXT statement. When run under CBASIC the body of the statement will always be executed at least once even if the index variable exceeds the value of the stop expression. If compiled using CB80, however, the loop will not be executed under those circumstances.
\ No newline at end of file
+{{language}}{{Stub}}
\ No newline at end of file
diff --git a/Lang/CBASIC/00-LANG.txt b/Lang/CBASIC/00-LANG.txt
deleted file mode 100644
index f0ff8ea32b..0000000000
--- a/Lang/CBASIC/00-LANG.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-{{stub}} {{language|CBASIC}}
-CBASIC was the commercial outgrowth of the BASIC-E compiler
-written by Gordon Eubanks as his Master's thesis while a 
-student at the Naval Postgraduate School. CBASIC -- which
-was marketed for both 8 and 16 bit CP/M systems -- differed from
-many of the BASIC dialects of the day in two major respects:
-(1) line numbers were not required unless the statement was
-the target of a GOTO or GOSUB statement (and were in any event
-treated simply as labels) and (2) real (floating point) variables
-were implemented as 14-digit binary coded decimal (BCD), which,
-particularly in business and accounting applications, avoided round-off 
-errors which purely binary floating point computations were prone
-to. Integer and string variables (which required % and $ suffixes,
-respectively) were also provided, as well as multi-dimensional arrays.
-Identifiers could be of any length, although only the first 31
-characters were significant. CBASIC supported multiline user-defined 
-functions with parameters passed by value but did not support recursion.
-CBASIC was implemented as a compiler-interpreter: the source code was
-compiled into an intermediate form, which could then be executed by
-invoking a run-time interpreter. A companion compiler, [[CB80]], was
-offered that compiled to machine code.
\ No newline at end of file
diff --git a/Lang/CBASIC/00-META.yaml b/Lang/CBASIC/00-META.yaml
deleted file mode 100644
index ad24e74664..0000000000
--- a/Lang/CBASIC/00-META.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-from: http://rosettacode.org/wiki/Category:CBASIC
diff --git a/Lang/CBASIC/100-doors b/Lang/CBASIC/100-doors
deleted file mode 120000
index e01a233041..0000000000
--- a/Lang/CBASIC/100-doors
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/100-doors/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Amicable-pairs b/Lang/CBASIC/Amicable-pairs
deleted file mode 120000
index 6386efc2a5..0000000000
--- a/Lang/CBASIC/Amicable-pairs
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Amicable-pairs/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Binary-digits b/Lang/CBASIC/Binary-digits
deleted file mode 120000
index d0de913861..0000000000
--- a/Lang/CBASIC/Binary-digits
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Binary-digits/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Factorial b/Lang/CBASIC/Factorial
deleted file mode 120000
index 97dfd0b137..0000000000
--- a/Lang/CBASIC/Factorial
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Factorial/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Fibonacci-sequence b/Lang/CBASIC/Fibonacci-sequence
deleted file mode 120000
index eb9f8cf7a1..0000000000
--- a/Lang/CBASIC/Fibonacci-sequence
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Fibonacci-sequence/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Harmonic-series b/Lang/CBASIC/Harmonic-series
deleted file mode 120000
index aa1eac83fa..0000000000
--- a/Lang/CBASIC/Harmonic-series
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Harmonic-series/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Perfect-numbers b/Lang/CBASIC/Perfect-numbers
deleted file mode 120000
index 3f847760d8..0000000000
--- a/Lang/CBASIC/Perfect-numbers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Perfect-numbers/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Rot-13 b/Lang/CBASIC/Rot-13
deleted file mode 120000
index bbda100cd2..0000000000
--- a/Lang/CBASIC/Rot-13
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Rot-13/CBASIC
\ No newline at end of file
diff --git a/Lang/CBASIC/Sieve-of-Eratosthenes b/Lang/CBASIC/Sieve-of-Eratosthenes
deleted file mode 120000
index ecdf66656a..0000000000
--- a/Lang/CBASIC/Sieve-of-Eratosthenes
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Sieve-of-Eratosthenes/CBASIC
\ No newline at end of file
diff --git a/Lang/CJam/00-LANG.txt b/Lang/CJam/00-LANG.txt
deleted file mode 100644
index 9d6f8331dc..0000000000
--- a/Lang/CJam/00-LANG.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-{{language|site=https://sourceforge.net/p/cjam/wiki/Home/}}
-
-[https://sourceforge.net/projects/cjam/ sf repo]
-
-From the [https://sourceforge.net/p/cjam/wiki/Home/ wiki]:
-
-:In order to run a CJam program, [https://sourceforge.net/projects/cjam/files/ download] the latest jar file, e.g. cjam-0.6.5.jar, and run this command:
-:
java -jar cjam-0.6.5.jar file.cjam
\ No newline at end of file diff --git a/Lang/CJam/00-META.yaml b/Lang/CJam/00-META.yaml deleted file mode 100644 index 49b8d01361..0000000000 --- a/Lang/CJam/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:CJam diff --git a/Lang/CLU/Arithmetic-derivative b/Lang/CLU/Arithmetic-derivative deleted file mode 120000 index f0f81c6bc1..0000000000 --- a/Lang/CLU/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/CLU \ No newline at end of file diff --git a/Lang/CLU/Magnanimous-numbers b/Lang/CLU/Magnanimous-numbers deleted file mode 120000 index 58e31b3004..0000000000 --- a/Lang/CLU/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/CLU \ No newline at end of file diff --git a/Lang/CLU/Move-to-front-algorithm b/Lang/CLU/Move-to-front-algorithm deleted file mode 120000 index bbdfe9bcdb..0000000000 --- a/Lang/CLU/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/CLU \ No newline at end of file diff --git a/Lang/CLU/Partition-an-integer-x-into-n-primes b/Lang/CLU/Partition-an-integer-x-into-n-primes deleted file mode 120000 index 9ff1739382..0000000000 --- a/Lang/CLU/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/CLU \ No newline at end of file diff --git a/Lang/CLU/Quaternion-type b/Lang/CLU/Quaternion-type new file mode 120000 index 0000000000..abdefd8765 --- /dev/null +++ b/Lang/CLU/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/CLU \ No newline at end of file diff --git a/Lang/CLU/Radical-of-an-integer b/Lang/CLU/Radical-of-an-integer deleted file mode 120000 index d3c117fb3a..0000000000 --- a/Lang/CLU/Radical-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Radical-of-an-integer/CLU \ No newline at end of file diff --git a/Lang/CLU/Super-d-numbers b/Lang/CLU/Super-d-numbers deleted file mode 120000 index a271a5f6dc..0000000000 --- a/Lang/CLU/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/CLU \ No newline at end of file diff --git a/Lang/CLU/Totient-function b/Lang/CLU/Totient-function deleted file mode 120000 index 75822d5b75..0000000000 --- a/Lang/CLU/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/CLU \ No newline at end of file diff --git a/Lang/CMake/Comments b/Lang/CMake/Comments deleted file mode 120000 index bc55fb468f..0000000000 --- a/Lang/CMake/Comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comments/CMake \ No newline at end of file diff --git a/Lang/COBOL/00-LANG.txt b/Lang/COBOL/00-LANG.txt index f233e74072..b08d403c2d 100644 --- a/Lang/COBOL/00-LANG.txt +++ b/Lang/COBOL/00-LANG.txt @@ -12,15 +12,12 @@ COBOL, an acronym for 'COmmon Business Oriented Language', is one of the oldest programming languages, being created in 1959. It was designed by a CODASYL (Conference on Data System Languages) committee with Grace Hopper. It is primarily used in business, finance and administration for companies and governments. It is primarily an imperative, structured language, with support for object-oriented programming added in 2002. ===Versions=== -* '''COBOL 60''' was the first version of the language. -* '''COBOL-65''' added some new features to the original specification. -* '''COBOL-68''' is the first COBOL standard and was published by [[ANSI]]. It was created to improve compatibility between the different versions of the language. -* '''COBOL-74''' added a few more features to the language, including the ability to ACCEPT the date, day and time, and the file organization clause. -* '''COBOL-85''' added many new features to COBOL, notably including: excplicit scope terminators (END-IF, END-READ, etc.), the EVALUATE verb, the CONTINUE verb, inline PERFORM statements, the ability to pass arguments by content, and the deprecation of the infamous ALTER verb. This standard was followed by the intrinsic functions amendment and a clarifications amendment in 1989 and 1991, respectively. -* '''X/Open COBOL''' was a technical standard published by the X/Open Group in 1991 to facilitate uniformity of implementations and program portability. Based on COBOL-85, it excluded much of its optional modules and obsolete features, and also specified some common non-ANSI extensions that would later become incorporated into the standard, such as the screen section for TUI programming, and record locking.{{Cite book|author=X/Open|title=Technical Standard: COBOL Language|url=https://pubs.opengroup.org/onlinepubs/009680799/toc.pdf}} -* '''COBOL 2002''' was published by [[ISO]] as ISO/IEC 1989. It included a host of new features, most notably including object-oriented programming. However, there were also other features, including: floating-point support, portable arithmetic results, pointers, calling conventions to other languages, function prototypes, [[XML]] facilities and support for execution within framework environments. This standard has suffered from poor vendor support, due to little commercial demand for the new features.{{Cite book|author=John Billman & Huib Klink|title=Thoughts on the Future of COBOL Standardization|url=https://web.archive.org/web/20090711032647/http://www.cobolstandard.info/j4/files/08-0034.pdf}} -* '''COBOL 2014''' was published on July 8th, 2014 and accepted by [[ISO]] early that summer, and then adopted by [[ANSI]] on Oct 31st, 2014.{{Cite book|title=ISO/IEC 1989:2014 Information technology – Programming languages, their environments and system software interfaces – Programming language COBOL|url=https://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=51416}} It includes numeric definitions following the [[IEEE]] 754 standard. -* '''COBOL 2023''' is the latest version of the standard, adopted in January 2023. It includes the standardizations of many previously nonstandard extensions, including transaction processing, asynchronous messaging, line sequential file organization, enhanced string manipulation, boolean shifting operators and a sleep statement. +* '''COBOL 1965''' added some new features to the original specification. +* '''ANS COBOL 1968''' is the first COBOL standard and was published by [[ANSI]]. It was created to improve compatibility between the different versions of the language. +* '''COBOL 1974''' added a few more features to the language, including the ability to ACCEPT the date, day and time, and the file organization clause. +* '''COBOL 1985''' added many new features to COBOL, notably including: scope terminators (END-IF, END-READ, etc.), the EVALUATE verb, the CONTINUE verb, inline PERFORM statements, the ability to pass arguments by content, and the deprecation of the infamous ALTER verb. This standard was followed by the intrinsic functions amendment and a clarifications amendment in 1989 and 1991, respectively. +* '''COBOL 2002''' was published by [[ISO]] as ISO/IEC 1989. It included a host of new features, most notably including object-oriented programming. However, there were also other features, including: floating-point support, portable arithmetic results, pointers, calling conventions to other languages, function prototypes, [[XML]] facilities and support for execution within framework environments. This standard has suffered from poor vendor support, due to little commercial demand for the new features.John Billman & Huib Klink, 'Thoughts on the Future of COBOL Standardization', [https://www.cobolstandard.info/j4/files/08-0034.pdf] +* '''COBOL 2014''' is the latest version of the standard, published on July 8th, 2014 and accepted by [[ISO]] early that summer, and then adopted by [[ANSI]] on Oct 31st, 2014. ISO/IEC 1989:2014 Information technology – Programming languages, their environments and system software interfaces – Programming language COBOL', [https://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=51416] It includes numeric definitions following the [[IEEE]] 754 standard. ===References=== diff --git a/Lang/COBOL/ABC-problem b/Lang/COBOL/ABC-problem deleted file mode 120000 index ca521ee81d..0000000000 --- a/Lang/COBOL/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/COBOL \ No newline at end of file diff --git a/Lang/COBOL/AVL-tree b/Lang/COBOL/AVL-tree deleted file mode 120000 index d8a20640c6..0000000000 --- a/Lang/COBOL/AVL-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/AVL-tree/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Abundant-odd-numbers b/Lang/COBOL/Abundant-odd-numbers deleted file mode 120000 index 7268a8a6ca..0000000000 --- a/Lang/COBOL/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Achilles-numbers b/Lang/COBOL/Achilles-numbers deleted file mode 120000 index 4a3a715de1..0000000000 --- a/Lang/COBOL/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Arithmetic-numbers b/Lang/COBOL/Arithmetic-numbers deleted file mode 120000 index cf8f3a0323..0000000000 --- a/Lang/COBOL/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Calkin-Wilf-sequence b/Lang/COBOL/Calkin-Wilf-sequence deleted file mode 120000 index f3e314890f..0000000000 --- a/Lang/COBOL/Calkin-Wilf-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calkin-Wilf-sequence/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Colorful-numbers b/Lang/COBOL/Colorful-numbers deleted file mode 120000 index 6d5c4f9dff..0000000000 --- a/Lang/COBOL/Colorful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Colorful-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Cullen-and-Woodall-numbers b/Lang/COBOL/Cullen-and-Woodall-numbers deleted file mode 120000 index b212ad96a5..0000000000 --- a/Lang/COBOL/Cullen-and-Woodall-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cullen-and-Woodall-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Damm-algorithm b/Lang/COBOL/Damm-algorithm deleted file mode 120000 index e4f3bf1f71..0000000000 --- a/Lang/COBOL/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/COBOL \ No newline at end of file diff --git a/Lang/COBOL/De-Bruijn-sequences b/Lang/COBOL/De-Bruijn-sequences deleted file mode 120000 index 67e8dee974..0000000000 --- a/Lang/COBOL/De-Bruijn-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/De-Bruijn-sequences/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Dijkstras-algorithm b/Lang/COBOL/Dijkstras-algorithm deleted file mode 120000 index 19c743357a..0000000000 --- a/Lang/COBOL/Dijkstras-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dijkstras-algorithm/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Farey-sequence b/Lang/COBOL/Farey-sequence deleted file mode 120000 index b402aede64..0000000000 --- a/Lang/COBOL/Farey-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Farey-sequence/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Floyd-Warshall-algorithm b/Lang/COBOL/Floyd-Warshall-algorithm deleted file mode 120000 index de49182ec8..0000000000 --- a/Lang/COBOL/Floyd-Warshall-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyd-Warshall-algorithm/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Fusc-sequence b/Lang/COBOL/Fusc-sequence deleted file mode 120000 index e8b4b1330c..0000000000 --- a/Lang/COBOL/Fusc-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fusc-sequence/COBOL \ No newline at end of file diff --git a/Lang/COBOL/K-d-tree b/Lang/COBOL/K-d-tree deleted file mode 120000 index af9595a130..0000000000 --- a/Lang/COBOL/K-d-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/K-d-tree/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Knuths-algorithm-S b/Lang/COBOL/Knuths-algorithm-S deleted file mode 120000 index 119841f920..0000000000 --- a/Lang/COBOL/Knuths-algorithm-S +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knuths-algorithm-S/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Leonardo-numbers b/Lang/COBOL/Leonardo-numbers deleted file mode 120000 index 65bc7509a4..0000000000 --- a/Lang/COBOL/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Magic-8-ball b/Lang/COBOL/Magic-8-ball deleted file mode 120000 index 4aa919846c..0000000000 --- a/Lang/COBOL/Magic-8-ball +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-8-ball/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Move-to-front-algorithm b/Lang/COBOL/Move-to-front-algorithm deleted file mode 120000 index f9458888cc..0000000000 --- a/Lang/COBOL/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Nim-game b/Lang/COBOL/Nim-game deleted file mode 120000 index 9a7c582b48..0000000000 --- a/Lang/COBOL/Nim-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nim-game/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Pancake-numbers b/Lang/COBOL/Pancake-numbers deleted file mode 120000 index 22e5574a28..0000000000 --- a/Lang/COBOL/Pancake-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pancake-numbers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Parametric-polymorphism b/Lang/COBOL/Parametric-polymorphism deleted file mode 120000 index 44f214df50..0000000000 --- a/Lang/COBOL/Parametric-polymorphism +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parametric-polymorphism/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Priority-queue b/Lang/COBOL/Priority-queue deleted file mode 120000 index 23c7bff2c3..0000000000 --- a/Lang/COBOL/Priority-queue +++ /dev/null @@ -1 +0,0 @@ -../../Task/Priority-queue/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Soloways-recurring-rainfall b/Lang/COBOL/Soloways-recurring-rainfall deleted file mode 120000 index 883bf3b2e0..0000000000 --- a/Lang/COBOL/Soloways-recurring-rainfall +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soloways-recurring-rainfall/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Strassens-algorithm b/Lang/COBOL/Strassens-algorithm deleted file mode 120000 index 488f64d9e2..0000000000 --- a/Lang/COBOL/Strassens-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strassens-algorithm/COBOL \ No newline at end of file diff --git a/Lang/COBOL/The-Name-Game b/Lang/COBOL/The-Name-Game deleted file mode 120000 index 35866ecb72..0000000000 --- a/Lang/COBOL/The-Name-Game +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-Name-Game/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Totient-function b/Lang/COBOL/Totient-function deleted file mode 120000 index 7fb7ff8b43..0000000000 --- a/Lang/COBOL/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Twos-complement b/Lang/COBOL/Twos-complement deleted file mode 120000 index 776801b9e2..0000000000 --- a/Lang/COBOL/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Vigen-re-cipher b/Lang/COBOL/Vigen-re-cipher deleted file mode 120000 index 93e3f53bcb..0000000000 --- a/Lang/COBOL/Vigen-re-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vigen-re-cipher/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Zeckendorf-number-representation b/Lang/COBOL/Zeckendorf-number-representation deleted file mode 120000 index d3c11d47da..0000000000 --- a/Lang/COBOL/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/COBOL \ No newline at end of file diff --git a/Lang/Calc/00-LANG.txt b/Lang/Calc/00-LANG.txt deleted file mode 100644 index 9066fe1741..0000000000 --- a/Lang/Calc/00-LANG.txt +++ /dev/null @@ -1,10 +0,0 @@ -{{language|Calc -|untyped=yes}} -{{language programming paradigm|stack-based}} -{{language programming paradigm|imperative}} - -Calc is a stack-based RPN calculator inside [[Emacs]]. Calc is part of GNU Emacs 22, or a package for XEmacs. - -Calc presents itself as an interactive calculator. Instructions can also be stored as macros, including control flow instructions (if-then-else, for loop, etc.), which makes Calc fully programmable. Calc also provides a library available in Emacs Lisp programs. - -Calc has more numeric types than plain Emacs Lisp. Calc has big integers, big floating-point numbers, rational numbers, complex numbers, and more. (For contrast, plain Emacs Lisp can only handle integers and floating-point numbers of limited precision.) Emacs Lisp with Calc can solve tasks requiring these types of numbers. \ No newline at end of file diff --git a/Lang/Calc/00-META.yaml b/Lang/Calc/00-META.yaml deleted file mode 100644 index 85b0e2ef53..0000000000 --- a/Lang/Calc/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Calc diff --git a/Lang/Calc/Averages-Arithmetic-mean b/Lang/Calc/Averages-Arithmetic-mean deleted file mode 120000 index 8ad84c8dbd..0000000000 --- a/Lang/Calc/Averages-Arithmetic-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Arithmetic-mean/Calc \ No newline at end of file diff --git a/Lang/Calc/Modular-exponentiation b/Lang/Calc/Modular-exponentiation deleted file mode 120000 index b72a4448d5..0000000000 --- a/Lang/Calc/Modular-exponentiation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Modular-exponentiation/Calc \ No newline at end of file diff --git a/Lang/Calcscript/00-LANG.txt b/Lang/Calcscript/00-LANG.txt deleted file mode 100644 index d2db819bbe..0000000000 --- a/Lang/Calcscript/00-LANG.txt +++ /dev/null @@ -1,10 +0,0 @@ -{{language -|site=https://gitee.com/jfiewo/calc/ -}} -Calcscript is a small lisp-like language. -* It has 3 datatypes: Int, Same, and Invalid. -* The usual 4 arithmetic operations are supported. - -See [https://gitee.com/jfiewo/calc/ the respository] for details. -{{language programming paradigm|Logic Programming}} -{{language programming paradigm|Functional}} \ No newline at end of file diff --git a/Lang/Calcscript/00-META.yaml b/Lang/Calcscript/00-META.yaml deleted file mode 100644 index cee9fc468f..0000000000 --- a/Lang/Calcscript/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Calcscript diff --git a/Lang/Chapel/Function-definition b/Lang/Chapel/Function-definition deleted file mode 120000 index 589b4afa2c..0000000000 --- a/Lang/Chapel/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/Chapel \ No newline at end of file diff --git a/Lang/Chapel/Maze-generation b/Lang/Chapel/Maze-generation deleted file mode 120000 index b4c55cfddb..0000000000 --- a/Lang/Chapel/Maze-generation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Maze-generation/Chapel \ No newline at end of file diff --git a/Lang/Chapel/Repeat b/Lang/Chapel/Repeat deleted file mode 120000 index 3c555a4885..0000000000 --- a/Lang/Chapel/Repeat +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat/Chapel \ No newline at end of file diff --git a/Lang/Cherrycake/00-LANG.txt b/Lang/Cherrycake/00-LANG.txt deleted file mode 100644 index e6fa9465bd..0000000000 --- a/Lang/Cherrycake/00-LANG.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{stub}}{{language|Cherrycake}} - -Cherrycake is a powerful language designed by [https://irishman.cloud Irishman Cloud, Inc.] and standardized by [https://fairfieldprogramming.org The Fairfield Programming Association] with the aim of simplifying the process of building web servers. With a built-in Object-Relational Mapping (ORM), Cherrycake eliminates the need for developers to manually manage database operations, allowing for seamless interaction with horizontally-scaling databases. Cherrycake leverages Ahead-of-Time (AOT) compilation, enabling improved performance and optimizations. \ No newline at end of file diff --git a/Lang/Cherrycake/00-META.yaml b/Lang/Cherrycake/00-META.yaml deleted file mode 100644 index 7466ff1cf2..0000000000 --- a/Lang/Cherrycake/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Cherrycake diff --git a/Lang/Cherrycake/FizzBuzz b/Lang/Cherrycake/FizzBuzz deleted file mode 120000 index 23576ef5a2..0000000000 --- a/Lang/Cherrycake/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/Cherrycake \ No newline at end of file diff --git a/Lang/Cherrycake/Literals-Integer b/Lang/Cherrycake/Literals-Integer deleted file mode 120000 index 691bf27426..0000000000 --- a/Lang/Cherrycake/Literals-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Literals-Integer/Cherrycake \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/21-game b/Lang/Chipmunk-Basic/21-game deleted file mode 120000 index 4144c99f1e..0000000000 --- a/Lang/Chipmunk-Basic/21-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/21-game/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/ASCII-art-diagram-converter b/Lang/Chipmunk-Basic/ASCII-art-diagram-converter deleted file mode 120000 index a034d74b58..0000000000 --- a/Lang/Chipmunk-Basic/ASCII-art-diagram-converter +++ /dev/null @@ -1 +0,0 @@ -../../Task/ASCII-art-diagram-converter/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Abundant-deficient-and-perfect-number-classifications b/Lang/Chipmunk-Basic/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index bcff1e67d9..0000000000 --- a/Lang/Chipmunk-Basic/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Ackermann-function b/Lang/Chipmunk-Basic/Ackermann-function deleted file mode 120000 index ab65fb3b6b..0000000000 --- a/Lang/Chipmunk-Basic/Ackermann-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ackermann-function/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Amicable-pairs b/Lang/Chipmunk-Basic/Amicable-pairs deleted file mode 120000 index 09bede8926..0000000000 --- a/Lang/Chipmunk-Basic/Amicable-pairs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amicable-pairs/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Angle-difference-between-two-bearings b/Lang/Chipmunk-Basic/Angle-difference-between-two-bearings deleted file mode 120000 index a85e9ed412..0000000000 --- a/Lang/Chipmunk-Basic/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Anonymous-recursion b/Lang/Chipmunk-Basic/Anonymous-recursion deleted file mode 120000 index fae9f410e3..0000000000 --- a/Lang/Chipmunk-Basic/Anonymous-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anonymous-recursion/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Arithmetic-Integer b/Lang/Chipmunk-Basic/Arithmetic-Integer deleted file mode 120000 index b9b0d2d61f..0000000000 --- a/Lang/Chipmunk-Basic/Arithmetic-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Integer/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Array-length b/Lang/Chipmunk-Basic/Array-length deleted file mode 120000 index 3b47a54405..0000000000 --- a/Lang/Chipmunk-Basic/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Associative-array-Merging b/Lang/Chipmunk-Basic/Associative-array-Merging deleted file mode 120000 index dd87e8e06c..0000000000 --- a/Lang/Chipmunk-Basic/Associative-array-Merging +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Merging/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Benfords-law b/Lang/Chipmunk-Basic/Benfords-law deleted file mode 120000 index 7340fa502c..0000000000 --- a/Lang/Chipmunk-Basic/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Binary-digits b/Lang/Chipmunk-Basic/Binary-digits deleted file mode 120000 index f633724e32..0000000000 --- a/Lang/Chipmunk-Basic/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Box-the-compass b/Lang/Chipmunk-Basic/Box-the-compass deleted file mode 120000 index a1cd1027f8..0000000000 --- a/Lang/Chipmunk-Basic/Box-the-compass +++ /dev/null @@ -1 +0,0 @@ -../../Task/Box-the-compass/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Cantor-set b/Lang/Chipmunk-Basic/Cantor-set deleted file mode 120000 index dff232c5bf..0000000000 --- a/Lang/Chipmunk-Basic/Cantor-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cantor-set/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Carmichael-3-strong-pseudoprimes b/Lang/Chipmunk-Basic/Carmichael-3-strong-pseudoprimes deleted file mode 120000 index 64c40104c4..0000000000 --- a/Lang/Chipmunk-Basic/Carmichael-3-strong-pseudoprimes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Carmichael-3-strong-pseudoprimes/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Cartesian-product-of-two-or-more-lists b/Lang/Chipmunk-Basic/Cartesian-product-of-two-or-more-lists deleted file mode 120000 index ad9ddbf01c..0000000000 --- a/Lang/Chipmunk-Basic/Cartesian-product-of-two-or-more-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cartesian-product-of-two-or-more-lists/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Case-sensitivity-of-identifiers b/Lang/Chipmunk-Basic/Case-sensitivity-of-identifiers deleted file mode 120000 index d391f1e8e2..0000000000 --- a/Lang/Chipmunk-Basic/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Casting-out-nines b/Lang/Chipmunk-Basic/Casting-out-nines deleted file mode 120000 index 5a7c2dcac0..0000000000 --- a/Lang/Chipmunk-Basic/Casting-out-nines +++ /dev/null @@ -1 +0,0 @@ -../../Task/Casting-out-nines/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Catalan-numbers-Pascals-triangle b/Lang/Chipmunk-Basic/Catalan-numbers-Pascals-triangle deleted file mode 120000 index 8fc59cdf4f..0000000000 --- a/Lang/Chipmunk-Basic/Catalan-numbers-Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers-Pascals-triangle/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Catamorphism b/Lang/Chipmunk-Basic/Catamorphism deleted file mode 120000 index db776ce5dd..0000000000 --- a/Lang/Chipmunk-Basic/Catamorphism +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catamorphism/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Character-codes b/Lang/Chipmunk-Basic/Character-codes deleted file mode 120000 index 529877dba7..0000000000 --- a/Lang/Chipmunk-Basic/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Create-a-two-dimensional-array-at-runtime b/Lang/Chipmunk-Basic/Create-a-two-dimensional-array-at-runtime deleted file mode 120000 index 0eef501718..0000000000 --- a/Lang/Chipmunk-Basic/Create-a-two-dimensional-array-at-runtime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-a-two-dimensional-array-at-runtime/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Determine-if-a-string-has-all-unique-characters b/Lang/Chipmunk-Basic/Determine-if-a-string-has-all-unique-characters deleted file mode 120000 index 88c8574cc2..0000000000 --- a/Lang/Chipmunk-Basic/Determine-if-a-string-has-all-unique-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-unique-characters/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Determine-sentence-type b/Lang/Chipmunk-Basic/Determine-sentence-type deleted file mode 120000 index 6851894430..0000000000 --- a/Lang/Chipmunk-Basic/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Dinesmans-multiple-dwelling-problem b/Lang/Chipmunk-Basic/Dinesmans-multiple-dwelling-problem deleted file mode 120000 index aa615c1450..0000000000 --- a/Lang/Chipmunk-Basic/Dinesmans-multiple-dwelling-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dinesmans-multiple-dwelling-problem/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Disarium-numbers b/Lang/Chipmunk-Basic/Disarium-numbers deleted file mode 120000 index f8085142a1..0000000000 --- a/Lang/Chipmunk-Basic/Disarium-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Disarium-numbers/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Display-a-linear-combination b/Lang/Chipmunk-Basic/Display-a-linear-combination deleted file mode 120000 index 76f3965566..0000000000 --- a/Lang/Chipmunk-Basic/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Diversity-prediction-theorem b/Lang/Chipmunk-Basic/Diversity-prediction-theorem deleted file mode 120000 index 094da6a44e..0000000000 --- a/Lang/Chipmunk-Basic/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Draw-a-rotating-cube b/Lang/Chipmunk-Basic/Draw-a-rotating-cube deleted file mode 120000 index b24865ccdc..0000000000 --- a/Lang/Chipmunk-Basic/Draw-a-rotating-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-rotating-cube/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Eban-numbers b/Lang/Chipmunk-Basic/Eban-numbers deleted file mode 120000 index 109253525e..0000000000 --- a/Lang/Chipmunk-Basic/Eban-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eban-numbers/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Egyptian-division b/Lang/Chipmunk-Basic/Egyptian-division deleted file mode 120000 index 234893fac4..0000000000 --- a/Lang/Chipmunk-Basic/Egyptian-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Egyptian-division/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Ethiopian-multiplication b/Lang/Chipmunk-Basic/Ethiopian-multiplication deleted file mode 120000 index bba9addcb7..0000000000 --- a/Lang/Chipmunk-Basic/Ethiopian-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ethiopian-multiplication/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Evaluate-binomial-coefficients b/Lang/Chipmunk-Basic/Evaluate-binomial-coefficients deleted file mode 120000 index b45aed06e2..0000000000 --- a/Lang/Chipmunk-Basic/Evaluate-binomial-coefficients +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evaluate-binomial-coefficients/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Feigenbaum-constant-calculation b/Lang/Chipmunk-Basic/Feigenbaum-constant-calculation deleted file mode 120000 index 9738d507b3..0000000000 --- a/Lang/Chipmunk-Basic/Feigenbaum-constant-calculation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Feigenbaum-constant-calculation/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences b/Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences deleted file mode 120000 index 24e6f1fb75..0000000000 --- a/Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-n-step-number-sequences/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Find-limit-of-recursion b/Lang/Chipmunk-Basic/Find-limit-of-recursion deleted file mode 120000 index 45d2935cfe..0000000000 --- a/Lang/Chipmunk-Basic/Find-limit-of-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-limit-of-recursion/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Gapful-numbers b/Lang/Chipmunk-Basic/Gapful-numbers deleted file mode 120000 index 62261c33f8..0000000000 --- a/Lang/Chipmunk-Basic/Gapful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gapful-numbers/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Generate-Chess960-starting-position b/Lang/Chipmunk-Basic/Generate-Chess960-starting-position deleted file mode 120000 index daceb0cf8f..0000000000 --- a/Lang/Chipmunk-Basic/Generate-Chess960-starting-position +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-Chess960-starting-position/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Generate-lower-case-ASCII-alphabet b/Lang/Chipmunk-Basic/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index 22e12f5ab0..0000000000 --- a/Lang/Chipmunk-Basic/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Greatest-common-divisor b/Lang/Chipmunk-Basic/Greatest-common-divisor deleted file mode 120000 index 688f826236..0000000000 --- a/Lang/Chipmunk-Basic/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Guess-the-number-With-feedback b/Lang/Chipmunk-Basic/Guess-the-number-With-feedback deleted file mode 120000 index 02ea8c88d7..0000000000 --- a/Lang/Chipmunk-Basic/Guess-the-number-With-feedback +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Jensens-Device b/Lang/Chipmunk-Basic/Jensens-Device deleted file mode 120000 index 927dca2f6f..0000000000 --- a/Lang/Chipmunk-Basic/Jensens-Device +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jensens-Device/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Leonardo-numbers b/Lang/Chipmunk-Basic/Leonardo-numbers deleted file mode 120000 index 65f7e68a9b..0000000000 --- a/Lang/Chipmunk-Basic/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Logical-operations b/Lang/Chipmunk-Basic/Logical-operations deleted file mode 120000 index 1eae3370d2..0000000000 --- a/Lang/Chipmunk-Basic/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Longest-string-challenge b/Lang/Chipmunk-Basic/Longest-string-challenge deleted file mode 120000 index 16c197c355..0000000000 --- a/Lang/Chipmunk-Basic/Longest-string-challenge +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-string-challenge/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Look-and-say-sequence b/Lang/Chipmunk-Basic/Look-and-say-sequence deleted file mode 120000 index 67f3a129f9..0000000000 --- a/Lang/Chipmunk-Basic/Look-and-say-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Look-and-say-sequence/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Magic-squares-of-odd-order b/Lang/Chipmunk-Basic/Magic-squares-of-odd-order deleted file mode 120000 index a9239c9a6f..0000000000 --- a/Lang/Chipmunk-Basic/Magic-squares-of-odd-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-odd-order/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Map-range b/Lang/Chipmunk-Basic/Map-range deleted file mode 120000 index 3aa5f00ecb..0000000000 --- a/Lang/Chipmunk-Basic/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/McNuggets-problem b/Lang/Chipmunk-Basic/McNuggets-problem deleted file mode 120000 index 6e8e21fec0..0000000000 --- a/Lang/Chipmunk-Basic/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/Chipmunk-Basic/Minimum-multiple-of-m-where-digital-sum-equals-m deleted file mode 120000 index c3bc5a092d..0000000000 --- a/Lang/Chipmunk-Basic/Minimum-multiple-of-m-where-digital-sum-equals-m +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Morse-code b/Lang/Chipmunk-Basic/Morse-code deleted file mode 120000 index 069e4c61b6..0000000000 --- a/Lang/Chipmunk-Basic/Morse-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Morse-code/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Multiple-regression b/Lang/Chipmunk-Basic/Multiple-regression deleted file mode 120000 index 82844a944e..0000000000 --- a/Lang/Chipmunk-Basic/Multiple-regression +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multiple-regression/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Nested-templated-data b/Lang/Chipmunk-Basic/Nested-templated-data deleted file mode 120000 index a7e95ed6f1..0000000000 --- a/Lang/Chipmunk-Basic/Nested-templated-data +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nested-templated-data/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Nim-game b/Lang/Chipmunk-Basic/Nim-game deleted file mode 120000 index a5f5c4be4c..0000000000 --- a/Lang/Chipmunk-Basic/Nim-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nim-game/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors b/Lang/Chipmunk-Basic/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors deleted file mode 120000 index 1a4494cec0..0000000000 --- a/Lang/Chipmunk-Basic/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Padovan-n-step-number-sequences b/Lang/Chipmunk-Basic/Padovan-n-step-number-sequences deleted file mode 120000 index fbce2420d3..0000000000 --- a/Lang/Chipmunk-Basic/Padovan-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Padovan-n-step-number-sequences/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Pascals-triangle b/Lang/Chipmunk-Basic/Pascals-triangle deleted file mode 120000 index aa62c07130..0000000000 --- a/Lang/Chipmunk-Basic/Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pascals-triangle/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Perfect-numbers b/Lang/Chipmunk-Basic/Perfect-numbers deleted file mode 120000 index 4bd1876580..0000000000 --- a/Lang/Chipmunk-Basic/Perfect-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perfect-numbers/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Phrase-reversals b/Lang/Chipmunk-Basic/Phrase-reversals deleted file mode 120000 index 3d4b70a430..0000000000 --- a/Lang/Chipmunk-Basic/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Pig-the-dice-game b/Lang/Chipmunk-Basic/Pig-the-dice-game deleted file mode 120000 index 6dbe194257..0000000000 --- a/Lang/Chipmunk-Basic/Pig-the-dice-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pig-the-dice-game/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Price-fraction b/Lang/Chipmunk-Basic/Price-fraction deleted file mode 120000 index 895d56d4cf..0000000000 --- a/Lang/Chipmunk-Basic/Price-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Price-fraction/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Proper-divisors b/Lang/Chipmunk-Basic/Proper-divisors deleted file mode 120000 index e83b2b6ef0..0000000000 --- a/Lang/Chipmunk-Basic/Proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Proper-divisors/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Pseudo-random-numbers-Middle-square-method b/Lang/Chipmunk-Basic/Pseudo-random-numbers-Middle-square-method deleted file mode 120000 index c970e2efcf..0000000000 --- a/Lang/Chipmunk-Basic/Pseudo-random-numbers-Middle-square-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Middle-square-method/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Rate-counter b/Lang/Chipmunk-Basic/Rate-counter deleted file mode 120000 index 214d671194..0000000000 --- a/Lang/Chipmunk-Basic/Rate-counter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rate-counter/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Repeat-a-string b/Lang/Chipmunk-Basic/Repeat-a-string deleted file mode 120000 index dc67dccc15..0000000000 --- a/Lang/Chipmunk-Basic/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sequence-of-non-squares b/Lang/Chipmunk-Basic/Sequence-of-non-squares deleted file mode 120000 index 70b50faaad..0000000000 --- a/Lang/Chipmunk-Basic/Sequence-of-non-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-non-squares/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sequence:-smallest-number-with-exactly-n-divisors b/Lang/Chipmunk-Basic/Sequence:-smallest-number-with-exactly-n-divisors deleted file mode 120000 index 5df75dca56..0000000000 --- a/Lang/Chipmunk-Basic/Sequence:-smallest-number-with-exactly-n-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence:-smallest-number-with-exactly-n-divisors/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Shell-one-liner b/Lang/Chipmunk-Basic/Shell-one-liner deleted file mode 120000 index a90b838683..0000000000 --- a/Lang/Chipmunk-Basic/Shell-one-liner +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shell-one-liner/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sort-disjoint-sublist b/Lang/Chipmunk-Basic/Sort-disjoint-sublist deleted file mode 120000 index 8cc8a9f39a..0000000000 --- a/Lang/Chipmunk-Basic/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sorting-algorithms-Gnome-sort b/Lang/Chipmunk-Basic/Sorting-algorithms-Gnome-sort deleted file mode 120000 index 0b812d3eff..0000000000 --- a/Lang/Chipmunk-Basic/Sorting-algorithms-Gnome-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Gnome-sort/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sorting-algorithms-Quicksort b/Lang/Chipmunk-Basic/Sorting-algorithms-Quicksort deleted file mode 120000 index 49de096b59..0000000000 --- a/Lang/Chipmunk-Basic/Sorting-algorithms-Quicksort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Quicksort/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Split-a-character-string-based-on-change-of-character b/Lang/Chipmunk-Basic/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index ae1d1da2a7..0000000000 --- a/Lang/Chipmunk-Basic/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/String-append b/Lang/Chipmunk-Basic/String-append deleted file mode 120000 index 39fda96e4e..0000000000 --- a/Lang/Chipmunk-Basic/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/String-case b/Lang/Chipmunk-Basic/String-case deleted file mode 120000 index 0564614620..0000000000 --- a/Lang/Chipmunk-Basic/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/String-interpolation-included- b/Lang/Chipmunk-Basic/String-interpolation-included- deleted file mode 120000 index 0fcd929e46..0000000000 --- a/Lang/Chipmunk-Basic/String-interpolation-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-interpolation-included-/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/String-prepend b/Lang/Chipmunk-Basic/String-prepend deleted file mode 120000 index 9efa1b444d..0000000000 --- a/Lang/Chipmunk-Basic/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Strip-a-set-of-characters-from-a-string b/Lang/Chipmunk-Basic/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index 74bd1a6833..0000000000 --- a/Lang/Chipmunk-Basic/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sudan-function b/Lang/Chipmunk-Basic/Sudan-function deleted file mode 120000 index 8b26708ee8..0000000000 --- a/Lang/Chipmunk-Basic/Sudan-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sudan-function/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Sum-of-a-series b/Lang/Chipmunk-Basic/Sum-of-a-series deleted file mode 120000 index f9bdcf9a6b..0000000000 --- a/Lang/Chipmunk-Basic/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Tau-number b/Lang/Chipmunk-Basic/Tau-number deleted file mode 120000 index fd1213a751..0000000000 --- a/Lang/Chipmunk-Basic/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Temperature-conversion b/Lang/Chipmunk-Basic/Temperature-conversion deleted file mode 120000 index e5069477ac..0000000000 --- a/Lang/Chipmunk-Basic/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/The-Name-Game b/Lang/Chipmunk-Basic/The-Name-Game deleted file mode 120000 index 5655525e11..0000000000 --- a/Lang/Chipmunk-Basic/The-Name-Game +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-Name-Game/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Twos-complement b/Lang/Chipmunk-Basic/Twos-complement deleted file mode 120000 index 4eb5b36880..0000000000 --- a/Lang/Chipmunk-Basic/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Van-Eck-sequence b/Lang/Chipmunk-Basic/Van-Eck-sequence deleted file mode 120000 index ec557b87cc..0000000000 --- a/Lang/Chipmunk-Basic/Van-Eck-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-Eck-sequence/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Vector b/Lang/Chipmunk-Basic/Vector deleted file mode 120000 index 68aa51b11b..0000000000 --- a/Lang/Chipmunk-Basic/Vector +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vector/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Clojure/Miller-Rabin-primality-test b/Lang/Clojure/Miller-Rabin-primality-test new file mode 120000 index 0000000000..67b048eb10 --- /dev/null +++ b/Lang/Clojure/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Clojure \ No newline at end of file diff --git a/Lang/CoffeeScript/00-LANG.txt b/Lang/CoffeeScript/00-LANG.txt index c50ed52dc7..08d9c62010 100644 --- a/Lang/CoffeeScript/00-LANG.txt +++ b/Lang/CoffeeScript/00-LANG.txt @@ -14,30 +14,30 @@ On December 24, 2010, Ashkenas announced the release of stable 1.0.0. A common JavaScript snippet using the jQuery library is - + $(document).ready(function() { // Initialization code goes here }); - + or even shorter, - + $(function() { // Initialization code goes here }); - + In CoffeeScript, the function keyword is replaced by the -> symbol, and indentation is used instead of curly braces (except when defining an [[associative array]]), as in Python. Also, parentheses can usually be omitted. Thus, the CoffeeScript equivalent of the snippet above is - + $(document).ready -> # Initialization code goes here - + or - + $ -> # Initialization code goes here - + == Compiling == diff --git a/Lang/CoffeeScript/Empty-program b/Lang/CoffeeScript/Empty-program new file mode 120000 index 0000000000..c325b31ffa --- /dev/null +++ b/Lang/CoffeeScript/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Sorting-Algorithms-Circle-Sort b/Lang/CoffeeScript/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..e4d7481d88 --- /dev/null +++ b/Lang/CoffeeScript/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/CoffeeScript \ No newline at end of file diff --git a/Lang/Comal/Fairshare-between-two-and-more b/Lang/Comal/Fairshare-between-two-and-more deleted file mode 120000 index 4497e4f55d..0000000000 --- a/Lang/Comal/Fairshare-between-two-and-more +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fairshare-between-two-and-more/Comal \ No newline at end of file diff --git a/Lang/Comal/Zeckendorf-number-representation b/Lang/Comal/Zeckendorf-number-representation deleted file mode 120000 index 55d16429d3..0000000000 --- a/Lang/Comal/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/Comal \ No newline at end of file diff --git a/Lang/Commodore-BASIC/Comma-quibbling b/Lang/Commodore-BASIC/Comma-quibbling deleted file mode 120000 index 5ff3afcd59..0000000000 --- a/Lang/Commodore-BASIC/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/Execute-Brain- b/Lang/Commodore-BASIC/Execute-Brain- deleted file mode 120000 index 125f41dcc4..0000000000 --- a/Lang/Commodore-BASIC/Execute-Brain- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-Brain-/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/Forest-fire b/Lang/Commodore-BASIC/Forest-fire deleted file mode 120000 index c384f7d98f..0000000000 --- a/Lang/Commodore-BASIC/Forest-fire +++ /dev/null @@ -1 +0,0 @@ -../../Task/Forest-fire/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/Miller-Rabin-primality-test b/Lang/Commodore-BASIC/Miller-Rabin-primality-test new file mode 120000 index 0000000000..7354bc510f --- /dev/null +++ b/Lang/Commodore-BASIC/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/N-queens-problem b/Lang/Commodore-BASIC/N-queens-problem deleted file mode 120000 index d5a4ff5b7a..0000000000 --- a/Lang/Commodore-BASIC/N-queens-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/N-queens-problem/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/Random-number-generator-device- b/Lang/Commodore-BASIC/Random-number-generator-device- deleted file mode 120000 index f23b1d0d42..0000000000 --- a/Lang/Commodore-BASIC/Random-number-generator-device- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-number-generator-device-/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/Reverse-a-string b/Lang/Commodore-BASIC/Reverse-a-string deleted file mode 120000 index db83958808..0000000000 --- a/Lang/Commodore-BASIC/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Commodore-BASIC/The-Twelve-Days-of-Christmas b/Lang/Commodore-BASIC/The-Twelve-Days-of-Christmas deleted file mode 120000 index cd67a05c16..0000000000 --- a/Lang/Commodore-BASIC/The-Twelve-Days-of-Christmas +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-Twelve-Days-of-Christmas/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Common-Lisp/Blum-integer b/Lang/Common-Lisp/Blum-integer deleted file mode 120000 index 854dbaeee7..0000000000 --- a/Lang/Common-Lisp/Blum-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Blum-integer/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Church-numerals b/Lang/Common-Lisp/Church-numerals deleted file mode 120000 index b8c32bb4d2..0000000000 --- a/Lang/Common-Lisp/Church-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Church-numerals/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Currency b/Lang/Common-Lisp/Currency deleted file mode 120000 index ad64f56642..0000000000 --- a/Lang/Common-Lisp/Currency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currency/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Factorial-primes b/Lang/Common-Lisp/Factorial-primes deleted file mode 120000 index cc0d935af1..0000000000 --- a/Lang/Common-Lisp/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Miller-Rabin-primality-test b/Lang/Common-Lisp/Miller-Rabin-primality-test new file mode 120000 index 0000000000..4f8dbe695d --- /dev/null +++ b/Lang/Common-Lisp/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Multi-dimensional-array b/Lang/Common-Lisp/Multi-dimensional-array deleted file mode 120000 index 37f7ef0979..0000000000 --- a/Lang/Common-Lisp/Multi-dimensional-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multi-dimensional-array/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Permutations-Derangements b/Lang/Common-Lisp/Permutations-Derangements deleted file mode 120000 index a0538e7374..0000000000 --- a/Lang/Common-Lisp/Permutations-Derangements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-Derangements/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Quaternion-type b/Lang/Common-Lisp/Quaternion-type new file mode 120000 index 0000000000..dd7bafa7e8 --- /dev/null +++ b/Lang/Common-Lisp/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Set-puzzle b/Lang/Common-Lisp/Set-puzzle deleted file mode 120000 index 6f48d7bac7..0000000000 --- a/Lang/Common-Lisp/Set-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-puzzle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Substitution-cipher b/Lang/Common-Lisp/Substitution-cipher deleted file mode 120000 index 332d90e9f0..0000000000 --- a/Lang/Common-Lisp/Substitution-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substitution-cipher/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Wieferich-primes b/Lang/Common-Lisp/Wieferich-primes deleted file mode 120000 index 91ad6e3ba2..0000000000 --- a/Lang/Common-Lisp/Wieferich-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wieferich-primes/Common-Lisp \ No newline at end of file diff --git a/Lang/Component-Pascal/00-LANG.txt b/Lang/Component-Pascal/00-LANG.txt index 7056dd922c..a83cc2b2e7 100644 --- a/Lang/Component-Pascal/00-LANG.txt +++ b/Lang/Component-Pascal/00-LANG.txt @@ -1,11 +1,4 @@ {{language|Component Pascal}}'''Component Pascal''' is a programming language in the tradition of Oberon and [[Oberon-2]], the last language Niklaus Wirth designed before he retired in 1999. It bears the name of the [[Pascal]] programming language but is incompatible with it. Instead, it is a minor variant and refinement of Oberon-2, designed and supported by a small ETH Zürich spin-off company called Oberon microsystems. Their [[IDE]] is called BlackBox Component Builder. At the time the first version was released (1994) it presented a novel approach to graphical user interface ([[GUI]]) construction based on editable forms, where fields and command buttons are linked to exported variables and executable procedures. This approach bears some similarity to the code-behind way used in [[Microsoft]]'s [[.NET]] 3.0 to access code in XAML. ==Citations== -* [http://en.wikipedia.org/wiki/Component_Pascal Wikipedia:Component Pascal] - -===See also=== -* [[Oberon-07]] -* [[Oberon-2]] -* [[Zonnon]] -* [[Modula-2]] -* [[Modula-3]] \ No newline at end of file +* [http://en.wikipedia.org/wiki/Component_Pascal Wikipedia:Component Pascal] \ No newline at end of file diff --git a/Lang/Component-Pascal/100-doors b/Lang/Component-Pascal/100-doors new file mode 120000 index 0000000000..76b023254e --- /dev/null +++ b/Lang/Component-Pascal/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Component-Pascal \ No newline at end of file diff --git a/Lang/Component-Pascal/Sorting-algorithms-Merge-sort b/Lang/Component-Pascal/Sorting-algorithms-Merge-sort deleted file mode 120000 index 9050341ad6..0000000000 --- a/Lang/Component-Pascal/Sorting-algorithms-Merge-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Merge-sort/Component-Pascal \ No newline at end of file diff --git a/Lang/Computer-zero-Assembly/00-LANG.txt b/Lang/Computer-zero-Assembly/00-LANG.txt index 779b92356f..e6ea975211 100644 --- a/Lang/Computer-zero-Assembly/00-LANG.txt +++ b/Lang/Computer-zero-Assembly/00-LANG.txt @@ -19,10 +19,10 @@ There are only 32 bytes of memory, and this includes your program code, leaving ==Self-Modifying Code== With such little RAM available, the biggest tool we have at our disposal for programming is self-modifying code. The CPU makes no distinction between data and instructions, and as such we can store values into memory before that memory is executed, in order to change what the computer will do. Here's an example: -LDA 4 +LDA 4 STA 2 ADD 3 STP -SUB 3 +SUB 3 The above snippet of code never actually ADDs anything, since that instruction gets overwritten by SUB 3. And what is SUB 3 subtracting? It's subtracting the value of STP, which can be encoded as any number between 0xE0 and 0xFF. Specifically, the encoding of SUB 3 (i.e. 0b10000011) is decreased by some value between 0xE0 and 0xFF, and since all arithmetic on this CPU is modulo 256 (as is standard for nearly all 8-bit CPUs), there will be roll-over across the FF-00 boundary. Without a hardware carry flag, however, it's difficult to track this overflow. \ No newline at end of file diff --git a/Lang/Convex/00-LANG.txt b/Lang/Convex/00-LANG.txt deleted file mode 100644 index 6676f23dde..0000000000 --- a/Lang/Convex/00-LANG.txt +++ /dev/null @@ -1,6 +0,0 @@ -Convex is a stack-based golfing esolang based on Golfscript and CJam. - -{{language|site=https://github.com/ZekNikZ/Convex}} - -{{try|Convex|[https://tio.run/#convex Try Convex on tio.run].}} -{{language_programming_paradigm|Concatenative}} \ No newline at end of file diff --git a/Lang/Convex/00-META.yaml b/Lang/Convex/00-META.yaml deleted file mode 100644 index b10fffa83e..0000000000 --- a/Lang/Convex/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Convex diff --git a/Lang/Coq/00-LANG.txt b/Lang/Coq/00-LANG.txt index dac9774672..3a03214cba 100644 --- a/Lang/Coq/00-LANG.txt +++ b/Lang/Coq/00-LANG.txt @@ -1 +1,9 @@ -#REDIRECT [[:Category:Rocq]] \ No newline at end of file +{{language|Coq +|site=http://coq.inria.fr +}} +In computer science, Coq is a proof assistant application. It allows the expression of mathematical assertions, mechanically checks proofs of these assertions, helps to find formal proofs, and extracts a certified program from the constructive proof of its formal specification. Coq works within the theory of the calculus of inductive constructions, a derivative of the calculus of constructions. Coq is not an automated [[wp:Theorem_prover|theorem prover]] but includes automatic theorem proving tactics and various decision procedures. + +==Citations== +* [[wp:Coq|Coq]] + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Coq/100-doors b/Lang/Coq/100-doors new file mode 120000 index 0000000000..fd39f903ef --- /dev/null +++ b/Lang/Coq/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Coq \ No newline at end of file diff --git a/Lang/Coq/Ackermann-function b/Lang/Coq/Ackermann-function new file mode 120000 index 0000000000..03a0752c76 --- /dev/null +++ b/Lang/Coq/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Coq \ No newline at end of file diff --git a/Lang/Coq/Extend-your-language b/Lang/Coq/Extend-your-language new file mode 120000 index 0000000000..2e717c1027 --- /dev/null +++ b/Lang/Coq/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Coq \ No newline at end of file diff --git a/Lang/Coq/Factorial b/Lang/Coq/Factorial new file mode 120000 index 0000000000..3d35ebeb5f --- /dev/null +++ b/Lang/Coq/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Coq \ No newline at end of file diff --git a/Lang/Coq/Fibonacci-sequence b/Lang/Coq/Fibonacci-sequence new file mode 120000 index 0000000000..fc6d7d958a --- /dev/null +++ b/Lang/Coq/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Coq \ No newline at end of file diff --git a/Lang/Coq/FizzBuzz b/Lang/Coq/FizzBuzz new file mode 120000 index 0000000000..966d79dca5 --- /dev/null +++ b/Lang/Coq/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Coq \ No newline at end of file diff --git a/Lang/Coq/Hello-world-Newbie b/Lang/Coq/Hello-world-Newbie new file mode 120000 index 0000000000..53590d7473 --- /dev/null +++ b/Lang/Coq/Hello-world-Newbie @@ -0,0 +1 @@ +../../Task/Hello-world-Newbie/Coq \ No newline at end of file diff --git a/Lang/Coq/Hello-world-Text b/Lang/Coq/Hello-world-Text new file mode 120000 index 0000000000..194b2d17df --- /dev/null +++ b/Lang/Coq/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Coq \ No newline at end of file diff --git a/Lang/Coq/Loops-For b/Lang/Coq/Loops-For new file mode 120000 index 0000000000..b1341b994c --- /dev/null +++ b/Lang/Coq/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Coq \ No newline at end of file diff --git a/Lang/Coq/Tree-traversal b/Lang/Coq/Tree-traversal new file mode 120000 index 0000000000..e38e9a0bdd --- /dev/null +++ b/Lang/Coq/Tree-traversal @@ -0,0 +1 @@ +../../Task/Tree-traversal/Coq \ No newline at end of file diff --git a/Lang/Coq/Variadic-function b/Lang/Coq/Variadic-function new file mode 120000 index 0000000000..391626fb92 --- /dev/null +++ b/Lang/Coq/Variadic-function @@ -0,0 +1 @@ +../../Task/Variadic-function/Coq \ No newline at end of file diff --git a/Lang/Cowgol/Align-columns b/Lang/Cowgol/Align-columns deleted file mode 120000 index 2931644d20..0000000000 --- a/Lang/Cowgol/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Arithmetic-derivative b/Lang/Cowgol/Arithmetic-derivative deleted file mode 120000 index 5d9cc4afd2..0000000000 --- a/Lang/Cowgol/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Arithmetic-numbers b/Lang/Cowgol/Arithmetic-numbers deleted file mode 120000 index ad116dfe9f..0000000000 --- a/Lang/Cowgol/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Case-sensitivity-of-identifiers b/Lang/Cowgol/Case-sensitivity-of-identifiers deleted file mode 120000 index 08822efb13..0000000000 --- a/Lang/Cowgol/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Compound-data-type b/Lang/Cowgol/Compound-data-type deleted file mode 120000 index f242ef8856..0000000000 --- a/Lang/Cowgol/Compound-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compound-data-type/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Display-a-linear-combination b/Lang/Cowgol/Display-a-linear-combination deleted file mode 120000 index 7e169cd6fe..0000000000 --- a/Lang/Cowgol/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Long-year b/Lang/Cowgol/Long-year deleted file mode 120000 index fa055b203d..0000000000 --- a/Lang/Cowgol/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Longest-common-substring b/Lang/Cowgol/Longest-common-substring deleted file mode 120000 index 219b75f317..0000000000 --- a/Lang/Cowgol/Longest-common-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-common-substring/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Magnanimous-numbers b/Lang/Cowgol/Magnanimous-numbers deleted file mode 120000 index fec44e9f41..0000000000 --- a/Lang/Cowgol/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Move-to-front-algorithm b/Lang/Cowgol/Move-to-front-algorithm deleted file mode 120000 index 137327f2ab..0000000000 --- a/Lang/Cowgol/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Multifactorial b/Lang/Cowgol/Multifactorial deleted file mode 120000 index c8a5e64301..0000000000 --- a/Lang/Cowgol/Multifactorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multifactorial/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Narcissistic-decimal-number b/Lang/Cowgol/Narcissistic-decimal-number deleted file mode 120000 index 3ff09189b6..0000000000 --- a/Lang/Cowgol/Narcissistic-decimal-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Narcissistic-decimal-number/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Partition-an-integer-x-into-n-primes b/Lang/Cowgol/Partition-an-integer-x-into-n-primes deleted file mode 120000 index 77d202dd2c..0000000000 --- a/Lang/Cowgol/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Radical-of-an-integer b/Lang/Cowgol/Radical-of-an-integer deleted file mode 120000 index b5ed3bf547..0000000000 --- a/Lang/Cowgol/Radical-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Radical-of-an-integer/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/Totient-function b/Lang/Cowgol/Totient-function deleted file mode 120000 index c04389da1a..0000000000 --- a/Lang/Cowgol/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/Cowgol \ No newline at end of file diff --git a/Lang/Cowgol/UTF-8-encode-and-decode b/Lang/Cowgol/UTF-8-encode-and-decode deleted file mode 120000 index 93ae70053a..0000000000 --- a/Lang/Cowgol/UTF-8-encode-and-decode +++ /dev/null @@ -1 +0,0 @@ -../../Task/UTF-8-encode-and-decode/Cowgol \ No newline at end of file diff --git a/Lang/Craft-Basic/Almost-prime b/Lang/Craft-Basic/Almost-prime deleted file mode 120000 index 837e60bb02..0000000000 --- a/Lang/Craft-Basic/Almost-prime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Almost-prime/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Averages-Median b/Lang/Craft-Basic/Averages-Median deleted file mode 120000 index 6ffc8a044e..0000000000 --- a/Lang/Craft-Basic/Averages-Median +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Median/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Factorial-primes b/Lang/Craft-Basic/Factorial-primes deleted file mode 120000 index b9fe46064b..0000000000 --- a/Lang/Craft-Basic/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Harmonic-series b/Lang/Craft-Basic/Harmonic-series deleted file mode 120000 index a11d3963eb..0000000000 --- a/Lang/Craft-Basic/Harmonic-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harmonic-series/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Largest-proper-divisor-of-n b/Lang/Craft-Basic/Largest-proper-divisor-of-n deleted file mode 120000 index 1f5596ae43..0000000000 --- a/Lang/Craft-Basic/Largest-proper-divisor-of-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-proper-divisor-of-n/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Loops-Infinite b/Lang/Craft-Basic/Loops-Infinite deleted file mode 120000 index 186bbe7bcc..0000000000 --- a/Lang/Craft-Basic/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Lucas-Lehmer-test b/Lang/Craft-Basic/Lucas-Lehmer-test deleted file mode 120000 index 68fae951b6..0000000000 --- a/Lang/Craft-Basic/Lucas-Lehmer-test +++ /dev/null @@ -1 +0,0 @@ -../../Task/Lucas-Lehmer-test/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Prime-decomposition b/Lang/Craft-Basic/Prime-decomposition deleted file mode 120000 index c28a3704bd..0000000000 --- a/Lang/Craft-Basic/Prime-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-decomposition/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Ultra-useful-primes b/Lang/Craft-Basic/Ultra-useful-primes deleted file mode 120000 index 6a976f0487..0000000000 --- a/Lang/Craft-Basic/Ultra-useful-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ultra-useful-primes/Craft-Basic \ No newline at end of file diff --git a/Lang/Craft-Basic/Wagstaff-primes b/Lang/Craft-Basic/Wagstaff-primes deleted file mode 120000 index 93b06b7da0..0000000000 --- a/Lang/Craft-Basic/Wagstaff-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wagstaff-primes/Craft-Basic \ No newline at end of file diff --git a/Lang/Crystal/00-LANG.txt b/Lang/Crystal/00-LANG.txt index 2d48345f43..b671a267bf 100644 --- a/Lang/Crystal/00-LANG.txt +++ b/Lang/Crystal/00-LANG.txt @@ -6,8 +6,7 @@ |strength=strong |checking=static |compat=duck -|site=http://crystal-lang.org -|hopl=no, HOPL only has an older "Crystal" language from 1986}} +|site=http://crystal-lang.org}} Crystal is a programming language with the following goals: * Have the same syntax as Ruby, or at least as similar as possible. * Never have to specify the type of a variable or method argument. @@ -15,7 +14,4 @@ Crystal is a programming language with the following goals: * Have compile-time evaluation and generation of code, to avoid boilerplate code. * Compile to efficient native code. -You can ask for help on LiberaChat in the [ircs://irc.libera.chat:6697#crystal-lang #crystal-lang] channel ([https://web.libera.chat/#crystal-lang web]). - -==Tasks not implemented in Crystal== -[[Tasks not implemented in Crystal]] \ No newline at end of file +You can ask for help on Freenode in the #crystal-lang channel. \ No newline at end of file diff --git a/Lang/Crystal/ABC-problem b/Lang/Crystal/ABC-problem deleted file mode 120000 index 4ebb385d2c..0000000000 --- a/Lang/Crystal/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/Crystal \ No newline at end of file diff --git a/Lang/Crystal/ADFGVX-cipher b/Lang/Crystal/ADFGVX-cipher deleted file mode 120000 index 20d511e75f..0000000000 --- a/Lang/Crystal/ADFGVX-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/ADFGVX-cipher/Crystal \ No newline at end of file diff --git a/Lang/Crystal/ASCII-art-diagram-converter b/Lang/Crystal/ASCII-art-diagram-converter deleted file mode 120000 index 0f1238b276..0000000000 --- a/Lang/Crystal/ASCII-art-diagram-converter +++ /dev/null @@ -1 +0,0 @@ -../../Task/ASCII-art-diagram-converter/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Abbreviations-automatic b/Lang/Crystal/Abbreviations-automatic deleted file mode 120000 index 356658ce4c..0000000000 --- a/Lang/Crystal/Abbreviations-automatic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-automatic/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Abbreviations-easy b/Lang/Crystal/Abbreviations-easy deleted file mode 120000 index b3a87e7119..0000000000 --- a/Lang/Crystal/Abbreviations-easy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-easy/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Abelian-sandpile-model b/Lang/Crystal/Abelian-sandpile-model deleted file mode 120000 index 8c440adf10..0000000000 --- a/Lang/Crystal/Abelian-sandpile-model +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Abelian-sandpile-model-Identity b/Lang/Crystal/Abelian-sandpile-model-Identity deleted file mode 120000 index ad1df3a714..0000000000 --- a/Lang/Crystal/Abelian-sandpile-model-Identity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model-Identity/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Abundant-deficient-and-perfect-number-classifications b/Lang/Crystal/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index 7cba469c21..0000000000 --- a/Lang/Crystal/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Abundant-odd-numbers b/Lang/Crystal/Abundant-odd-numbers deleted file mode 120000 index 3676d5a336..0000000000 --- a/Lang/Crystal/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Achilles-numbers b/Lang/Crystal/Achilles-numbers deleted file mode 120000 index baac6a0487..0000000000 --- a/Lang/Crystal/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Crystal/Add-a-variable-to-a-class-instance-at-runtime deleted file mode 120000 index 7c0d033962..0000000000 --- a/Lang/Crystal/Add-a-variable-to-a-class-instance-at-runtime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Add-a-variable-to-a-class-instance-at-runtime/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Address-of-a-variable b/Lang/Crystal/Address-of-a-variable deleted file mode 120000 index 55aa429a76..0000000000 --- a/Lang/Crystal/Address-of-a-variable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Address-of-a-variable/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Align-columns b/Lang/Crystal/Align-columns deleted file mode 120000 index 2ab766781e..0000000000 --- a/Lang/Crystal/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Aliquot-sequence-classifications b/Lang/Crystal/Aliquot-sequence-classifications deleted file mode 120000 index 7453e5fb67..0000000000 --- a/Lang/Crystal/Aliquot-sequence-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Aliquot-sequence-classifications/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Almost-prime b/Lang/Crystal/Almost-prime deleted file mode 120000 index 782486465b..0000000000 --- a/Lang/Crystal/Almost-prime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Almost-prime/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Amb b/Lang/Crystal/Amb deleted file mode 120000 index 31a9ff96ef..0000000000 --- a/Lang/Crystal/Amb +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amb/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Anagrams-Deranged-anagrams b/Lang/Crystal/Anagrams-Deranged-anagrams deleted file mode 120000 index 01826ee4a9..0000000000 --- a/Lang/Crystal/Anagrams-Deranged-anagrams +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anagrams-Deranged-anagrams/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Angle-difference-between-two-bearings b/Lang/Crystal/Angle-difference-between-two-bearings deleted file mode 120000 index 80eb3d6093..0000000000 --- a/Lang/Crystal/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Angles-geometric-normalization-and-conversion b/Lang/Crystal/Angles-geometric-normalization-and-conversion deleted file mode 120000 index a07d6f6045..0000000000 --- a/Lang/Crystal/Angles-geometric-normalization-and-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angles-geometric-normalization-and-conversion/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Anonymous-recursion b/Lang/Crystal/Anonymous-recursion deleted file mode 120000 index 8266f214bc..0000000000 --- a/Lang/Crystal/Anonymous-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anonymous-recursion/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Append-a-record-to-the-end-of-a-text-file b/Lang/Crystal/Append-a-record-to-the-end-of-a-text-file deleted file mode 120000 index 2a2afc8f9c..0000000000 --- a/Lang/Crystal/Append-a-record-to-the-end-of-a-text-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Append-a-record-to-the-end-of-a-text-file/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Apply-a-digital-filter-direct-form-II-transposed- b/Lang/Crystal/Apply-a-digital-filter-direct-form-II-transposed- deleted file mode 120000 index 4772cfa6a5..0000000000 --- a/Lang/Crystal/Apply-a-digital-filter-direct-form-II-transposed- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Apply-a-digital-filter-direct-form-II-transposed-/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Approximate-equality b/Lang/Crystal/Approximate-equality deleted file mode 120000 index f45d53cb9c..0000000000 --- a/Lang/Crystal/Approximate-equality +++ /dev/null @@ -1 +0,0 @@ -../../Task/Approximate-equality/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Archimedean-spiral b/Lang/Crystal/Archimedean-spiral deleted file mode 120000 index 38cdafc563..0000000000 --- a/Lang/Crystal/Archimedean-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Archimedean-spiral/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-Complex b/Lang/Crystal/Arithmetic-Complex deleted file mode 120000 index db70676449..0000000000 --- a/Lang/Crystal/Arithmetic-Complex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Complex/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-Rational b/Lang/Crystal/Arithmetic-Rational deleted file mode 120000 index 9934cb69b5..0000000000 --- a/Lang/Crystal/Arithmetic-Rational +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Rational/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-derivative b/Lang/Crystal/Arithmetic-derivative deleted file mode 120000 index afe551091f..0000000000 --- a/Lang/Crystal/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-evaluation b/Lang/Crystal/Arithmetic-evaluation deleted file mode 120000 index cefbf4e2d9..0000000000 --- a/Lang/Crystal/Arithmetic-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-evaluation/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-geometric-mean b/Lang/Crystal/Arithmetic-geometric-mean deleted file mode 120000 index c8754aa805..0000000000 --- a/Lang/Crystal/Arithmetic-geometric-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-geometric-mean-Calculate-Pi b/Lang/Crystal/Arithmetic-geometric-mean-Calculate-Pi deleted file mode 120000 index b641674514..0000000000 --- a/Lang/Crystal/Arithmetic-geometric-mean-Calculate-Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean-Calculate-Pi/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Arithmetic-numbers b/Lang/Crystal/Arithmetic-numbers deleted file mode 120000 index a07126fc36..0000000000 --- a/Lang/Crystal/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Ascending-primes b/Lang/Crystal/Ascending-primes deleted file mode 120000 index 159e1b5bed..0000000000 --- a/Lang/Crystal/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Atomic-updates b/Lang/Crystal/Atomic-updates deleted file mode 120000 index 332b197fee..0000000000 --- a/Lang/Crystal/Atomic-updates +++ /dev/null @@ -1 +0,0 @@ -../../Task/Atomic-updates/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Attractive-numbers b/Lang/Crystal/Attractive-numbers deleted file mode 120000 index 04e80138ee..0000000000 --- a/Lang/Crystal/Attractive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Attractive-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Average-loop-length b/Lang/Crystal/Average-loop-length deleted file mode 120000 index 06beee4e14..0000000000 --- a/Lang/Crystal/Average-loop-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Average-loop-length/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Averages-Mean-angle b/Lang/Crystal/Averages-Mean-angle deleted file mode 120000 index 8e548785b0..0000000000 --- a/Lang/Crystal/Averages-Mean-angle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-angle/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Averages-Mean-time-of-day b/Lang/Crystal/Averages-Mean-time-of-day deleted file mode 120000 index 4952b673eb..0000000000 --- a/Lang/Crystal/Averages-Mean-time-of-day +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-time-of-day/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Averages-Mode b/Lang/Crystal/Averages-Mode deleted file mode 120000 index bb15fa305b..0000000000 --- a/Lang/Crystal/Averages-Mode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mode/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Averages-Pythagorean-means b/Lang/Crystal/Averages-Pythagorean-means deleted file mode 120000 index a97d5df819..0000000000 --- a/Lang/Crystal/Averages-Pythagorean-means +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Pythagorean-means/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Babbage-problem b/Lang/Crystal/Babbage-problem deleted file mode 120000 index 7e1cc42ea8..0000000000 --- a/Lang/Crystal/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Babylonian-spiral b/Lang/Crystal/Babylonian-spiral deleted file mode 120000 index 7478d85b07..0000000000 --- a/Lang/Crystal/Babylonian-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babylonian-spiral/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bell-numbers b/Lang/Crystal/Bell-numbers deleted file mode 120000 index 3f05e224a6..0000000000 --- a/Lang/Crystal/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bifid-cipher b/Lang/Crystal/Bifid-cipher deleted file mode 120000 index 6b07c1520e..0000000000 --- a/Lang/Crystal/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bin-given-limits b/Lang/Crystal/Bin-given-limits deleted file mode 120000 index 40a049c833..0000000000 --- a/Lang/Crystal/Bin-given-limits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bin-given-limits/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bioinformatics-Global-alignment b/Lang/Crystal/Bioinformatics-Global-alignment deleted file mode 120000 index b8310a94b2..0000000000 --- a/Lang/Crystal/Bioinformatics-Global-alignment +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bioinformatics-Global-alignment/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Biorhythms b/Lang/Crystal/Biorhythms deleted file mode 120000 index adde97b4c1..0000000000 --- a/Lang/Crystal/Biorhythms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Biorhythms/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bitmap-Bresenhams-line-algorithm b/Lang/Crystal/Bitmap-Bresenhams-line-algorithm deleted file mode 120000 index 680f0b15d0..0000000000 --- a/Lang/Crystal/Bitmap-Bresenhams-line-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Bresenhams-line-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bitmap-Flood-fill b/Lang/Crystal/Bitmap-Flood-fill deleted file mode 120000 index 82f2b7e4ae..0000000000 --- a/Lang/Crystal/Bitmap-Flood-fill +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Flood-fill/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bitmap-Midpoint-circle-algorithm b/Lang/Crystal/Bitmap-Midpoint-circle-algorithm deleted file mode 120000 index fd45ea7903..0000000000 --- a/Lang/Crystal/Bitmap-Midpoint-circle-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Midpoint-circle-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bitmap-Read-a-PPM-file b/Lang/Crystal/Bitmap-Read-a-PPM-file deleted file mode 120000 index 72567511a0..0000000000 --- a/Lang/Crystal/Bitmap-Read-a-PPM-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Read-a-PPM-file/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bitmap-Write-a-PPM-file b/Lang/Crystal/Bitmap-Write-a-PPM-file deleted file mode 120000 index 86ca9711aa..0000000000 --- a/Lang/Crystal/Bitmap-Write-a-PPM-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Write-a-PPM-file/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Bitwise-operations b/Lang/Crystal/Bitwise-operations deleted file mode 120000 index 1a5350f2cc..0000000000 --- a/Lang/Crystal/Bitwise-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitwise-operations/Crystal \ No newline at end of file diff --git a/Lang/Crystal/CUSIP b/Lang/Crystal/CUSIP deleted file mode 120000 index b88441138f..0000000000 --- a/Lang/Crystal/CUSIP +++ /dev/null @@ -1 +0,0 @@ -../../Task/CUSIP/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Camel-case-and-snake-case b/Lang/Crystal/Camel-case-and-snake-case deleted file mode 120000 index 04ca76eb1a..0000000000 --- a/Lang/Crystal/Camel-case-and-snake-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/Camel-case-and-snake-case/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Catamorphism b/Lang/Crystal/Catamorphism deleted file mode 120000 index 59ec253ef2..0000000000 --- a/Lang/Crystal/Catamorphism +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catamorphism/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Chaocipher b/Lang/Crystal/Chaocipher deleted file mode 120000 index b200ad768f..0000000000 --- a/Lang/Crystal/Chaocipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaocipher/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Character-codes b/Lang/Crystal/Character-codes deleted file mode 120000 index bd4879b77c..0000000000 --- a/Lang/Crystal/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Cistercian-numerals b/Lang/Crystal/Cistercian-numerals deleted file mode 120000 index b439a8a963..0000000000 --- a/Lang/Crystal/Cistercian-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cistercian-numerals/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Closures-Value-capture b/Lang/Crystal/Closures-Value-capture deleted file mode 120000 index f3038be393..0000000000 --- a/Lang/Crystal/Closures-Value-capture +++ /dev/null @@ -1 +0,0 @@ -../../Task/Closures-Value-capture/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Color-wheel b/Lang/Crystal/Color-wheel deleted file mode 120000 index b0d2a4f84a..0000000000 --- a/Lang/Crystal/Color-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Color-wheel/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Colour-bars-Display b/Lang/Crystal/Colour-bars-Display deleted file mode 120000 index 0ec7f62738..0000000000 --- a/Lang/Crystal/Colour-bars-Display +++ /dev/null @@ -1 +0,0 @@ -../../Task/Colour-bars-Display/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Comma-quibbling b/Lang/Crystal/Comma-quibbling deleted file mode 120000 index 3151a9c58f..0000000000 --- a/Lang/Crystal/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Compare-a-list-of-strings b/Lang/Crystal/Compare-a-list-of-strings deleted file mode 120000 index f978784371..0000000000 --- a/Lang/Crystal/Compare-a-list-of-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-a-list-of-strings/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Compile-time-calculation b/Lang/Crystal/Compile-time-calculation deleted file mode 120000 index 306dfbb009..0000000000 --- a/Lang/Crystal/Compile-time-calculation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compile-time-calculation/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Consecutive-primes-with-ascending-or-descending-differences b/Lang/Crystal/Consecutive-primes-with-ascending-or-descending-differences deleted file mode 120000 index 697e7e52cd..0000000000 --- a/Lang/Crystal/Consecutive-primes-with-ascending-or-descending-differences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Consecutive-primes-with-ascending-or-descending-differences/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Convert-seconds-to-compound-duration b/Lang/Crystal/Convert-seconds-to-compound-duration deleted file mode 120000 index 313254bee3..0000000000 --- a/Lang/Crystal/Convert-seconds-to-compound-duration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Convert-seconds-to-compound-duration/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Count-occurrences-of-a-substring b/Lang/Crystal/Count-occurrences-of-a-substring deleted file mode 120000 index f235e95129..0000000000 --- a/Lang/Crystal/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Cullen-and-Woodall-numbers b/Lang/Crystal/Cullen-and-Woodall-numbers deleted file mode 120000 index 62ef13cd07..0000000000 --- a/Lang/Crystal/Cullen-and-Woodall-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cullen-and-Woodall-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Currency b/Lang/Crystal/Currency deleted file mode 120000 index 275fd9dcb2..0000000000 --- a/Lang/Crystal/Currency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currency/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Day-of-the-week b/Lang/Crystal/Day-of-the-week deleted file mode 120000 index 0f98ad94ee..0000000000 --- a/Lang/Crystal/Day-of-the-week +++ /dev/null @@ -1 +0,0 @@ -../../Task/Day-of-the-week/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Department-numbers b/Lang/Crystal/Department-numbers deleted file mode 120000 index 1e36b398e9..0000000000 --- a/Lang/Crystal/Department-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Department-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Detect-division-by-zero b/Lang/Crystal/Detect-division-by-zero deleted file mode 120000 index d23bedf4f0..0000000000 --- a/Lang/Crystal/Detect-division-by-zero +++ /dev/null @@ -1 +0,0 @@ -../../Task/Detect-division-by-zero/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Determine-if-a-string-has-all-the-same-characters b/Lang/Crystal/Determine-if-a-string-has-all-the-same-characters deleted file mode 120000 index a0bef4d19a..0000000000 --- a/Lang/Crystal/Determine-if-a-string-has-all-the-same-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-the-same-characters/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Determine-if-a-string-is-collapsible b/Lang/Crystal/Determine-if-a-string-is-collapsible deleted file mode 120000 index 7e2d57c2cb..0000000000 --- a/Lang/Crystal/Determine-if-a-string-is-collapsible +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-collapsible/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Determine-if-a-string-is-numeric b/Lang/Crystal/Determine-if-a-string-is-numeric deleted file mode 120000 index 907fa1cc6f..0000000000 --- a/Lang/Crystal/Determine-if-a-string-is-numeric +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-numeric/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Determine-sentence-type b/Lang/Crystal/Determine-sentence-type deleted file mode 120000 index 95914c2896..0000000000 --- a/Lang/Crystal/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Digital-root-Multiplicative-digital-root b/Lang/Crystal/Digital-root-Multiplicative-digital-root deleted file mode 120000 index 92366c8b32..0000000000 --- a/Lang/Crystal/Digital-root-Multiplicative-digital-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Digital-root-Multiplicative-digital-root/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Dijkstras-algorithm b/Lang/Crystal/Dijkstras-algorithm deleted file mode 120000 index 829bbaa132..0000000000 --- a/Lang/Crystal/Dijkstras-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dijkstras-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Diversity-prediction-theorem b/Lang/Crystal/Diversity-prediction-theorem deleted file mode 120000 index bfb6463f86..0000000000 --- a/Lang/Crystal/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Dutch-national-flag-problem b/Lang/Crystal/Dutch-national-flag-problem deleted file mode 120000 index a920e0b89a..0000000000 --- a/Lang/Crystal/Dutch-national-flag-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dutch-national-flag-problem/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Egyptian-division b/Lang/Crystal/Egyptian-division deleted file mode 120000 index 6766caec22..0000000000 --- a/Lang/Crystal/Egyptian-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Egyptian-division/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Elementary-cellular-automaton b/Lang/Crystal/Elementary-cellular-automaton deleted file mode 120000 index a397b94a1b..0000000000 --- a/Lang/Crystal/Elementary-cellular-automaton +++ /dev/null @@ -1 +0,0 @@ -../../Task/Elementary-cellular-automaton/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Elementary-cellular-automaton-Random-number-generator b/Lang/Crystal/Elementary-cellular-automaton-Random-number-generator deleted file mode 120000 index 6d743a5fc8..0000000000 --- a/Lang/Crystal/Elementary-cellular-automaton-Random-number-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Elementary-cellular-automaton-Random-number-generator/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Emirp-primes b/Lang/Crystal/Emirp-primes deleted file mode 120000 index 6a762271db..0000000000 --- a/Lang/Crystal/Emirp-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Emirp-primes/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Empty-program b/Lang/Crystal/Empty-program new file mode 120000 index 0000000000..78e7f559d2 --- /dev/null +++ b/Lang/Crystal/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Enumerations b/Lang/Crystal/Enumerations deleted file mode 120000 index 81276f7ab4..0000000000 --- a/Lang/Crystal/Enumerations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Enumerations/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Environment-variables b/Lang/Crystal/Environment-variables deleted file mode 120000 index 17cbcdefee..0000000000 --- a/Lang/Crystal/Environment-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Environment-variables/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Equilibrium-index b/Lang/Crystal/Equilibrium-index deleted file mode 120000 index 1125331aa6..0000000000 --- a/Lang/Crystal/Equilibrium-index +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equilibrium-index/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Ethiopian-multiplication b/Lang/Crystal/Ethiopian-multiplication deleted file mode 120000 index e534df962f..0000000000 --- a/Lang/Crystal/Ethiopian-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ethiopian-multiplication/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Evolutionary-algorithm b/Lang/Crystal/Evolutionary-algorithm deleted file mode 120000 index a0bcba6242..0000000000 --- a/Lang/Crystal/Evolutionary-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evolutionary-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Execute-Brain- b/Lang/Crystal/Execute-Brain- deleted file mode 120000 index 4ffee47edd..0000000000 --- a/Lang/Crystal/Execute-Brain- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-Brain-/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Exponentiation-order b/Lang/Crystal/Exponentiation-order deleted file mode 120000 index e7f6547257..0000000000 --- a/Lang/Crystal/Exponentiation-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-order/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Exponentiation-with-infix-operators-in-or-operating-on-the-base b/Lang/Crystal/Exponentiation-with-infix-operators-in-or-operating-on-the-base deleted file mode 120000 index bea2082efb..0000000000 --- a/Lang/Crystal/Exponentiation-with-infix-operators-in-or-operating-on-the-base +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-with-infix-operators-in-or-operating-on-the-base/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Extensible-prime-generator b/Lang/Crystal/Extensible-prime-generator deleted file mode 120000 index f7e46afa3d..0000000000 --- a/Lang/Crystal/Extensible-prime-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Extensible-prime-generator/Crystal \ No newline at end of file diff --git a/Lang/Crystal/File-extension-is-in-extensions-list b/Lang/Crystal/File-extension-is-in-extensions-list deleted file mode 120000 index d3f5d5ad97..0000000000 --- a/Lang/Crystal/File-extension-is-in-extensions-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-extension-is-in-extensions-list/Crystal \ No newline at end of file diff --git a/Lang/Crystal/File-modification-time b/Lang/Crystal/File-modification-time deleted file mode 120000 index b3a7e1065d..0000000000 --- a/Lang/Crystal/File-modification-time +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-modification-time/Crystal \ No newline at end of file diff --git a/Lang/Crystal/File-size b/Lang/Crystal/File-size deleted file mode 120000 index f7ccd8930e..0000000000 --- a/Lang/Crystal/File-size +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-size/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Filter b/Lang/Crystal/Filter deleted file mode 120000 index 13d5962733..0000000000 --- a/Lang/Crystal/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Find-if-a-point-is-within-a-triangle b/Lang/Crystal/Find-if-a-point-is-within-a-triangle deleted file mode 120000 index a3ff575d32..0000000000 --- a/Lang/Crystal/Find-if-a-point-is-within-a-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-if-a-point-is-within-a-triangle/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Find-the-last-Sunday-of-each-month b/Lang/Crystal/Find-the-last-Sunday-of-each-month deleted file mode 120000 index b7448c15e3..0000000000 --- a/Lang/Crystal/Find-the-last-Sunday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-last-Sunday-of-each-month/Crystal \ No newline at end of file diff --git a/Lang/Crystal/First-class-functions b/Lang/Crystal/First-class-functions deleted file mode 120000 index 41628a5683..0000000000 --- a/Lang/Crystal/First-class-functions +++ /dev/null @@ -1 +0,0 @@ -../../Task/First-class-functions/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Five-weekends b/Lang/Crystal/Five-weekends deleted file mode 120000 index aee26e19f7..0000000000 --- a/Lang/Crystal/Five-weekends +++ /dev/null @@ -1 +0,0 @@ -../../Task/Five-weekends/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Four-is-magic b/Lang/Crystal/Four-is-magic deleted file mode 120000 index e56a866dc3..0000000000 --- a/Lang/Crystal/Four-is-magic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Four-is-magic/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Function-definition b/Lang/Crystal/Function-definition deleted file mode 120000 index 1fac36efe3..0000000000 --- a/Lang/Crystal/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Generate-lower-case-ASCII-alphabet b/Lang/Crystal/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index 8b481efdf1..0000000000 --- a/Lang/Crystal/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Generator-Exponential b/Lang/Crystal/Generator-Exponential deleted file mode 120000 index d9c996b99e..0000000000 --- a/Lang/Crystal/Generator-Exponential +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generator-Exponential/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Get-system-command-output b/Lang/Crystal/Get-system-command-output deleted file mode 120000 index 75fcf73ed6..0000000000 --- a/Lang/Crystal/Get-system-command-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Get-system-command-output/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Greatest-common-divisor b/Lang/Crystal/Greatest-common-divisor deleted file mode 120000 index cac765e22c..0000000000 --- a/Lang/Crystal/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Hello-world-Graphical b/Lang/Crystal/Hello-world-Graphical deleted file mode 120000 index aa3ccec00c..0000000000 --- a/Lang/Crystal/Hello-world-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Graphical/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Hello-world-Newline-omission b/Lang/Crystal/Hello-world-Newline-omission deleted file mode 120000 index cf00f3e8a9..0000000000 --- a/Lang/Crystal/Hello-world-Newline-omission +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newline-omission/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Hello-world-Standard-error b/Lang/Crystal/Hello-world-Standard-error deleted file mode 120000 index 560e23c97c..0000000000 --- a/Lang/Crystal/Hello-world-Standard-error +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Standard-error/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Hex-words b/Lang/Crystal/Hex-words deleted file mode 120000 index 1390f8d3e3..0000000000 --- a/Lang/Crystal/Hex-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hex-words/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Hofstadter-Q-sequence b/Lang/Crystal/Hofstadter-Q-sequence deleted file mode 120000 index a856d63c6d..0000000000 --- a/Lang/Crystal/Hofstadter-Q-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hofstadter-Q-sequence/Crystal \ No newline at end of file diff --git a/Lang/Crystal/ISBN13-check-digit b/Lang/Crystal/ISBN13-check-digit deleted file mode 120000 index eedbc71ec1..0000000000 --- a/Lang/Crystal/ISBN13-check-digit +++ /dev/null @@ -1 +0,0 @@ -../../Task/ISBN13-check-digit/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Idiomatically-determine-all-the-lowercase-and-uppercase-letters b/Lang/Crystal/Idiomatically-determine-all-the-lowercase-and-uppercase-letters deleted file mode 120000 index 9e0f4e23b4..0000000000 --- a/Lang/Crystal/Idiomatically-determine-all-the-lowercase-and-uppercase-letters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Increment-a-numerical-string b/Lang/Crystal/Increment-a-numerical-string deleted file mode 120000 index aeae95c765..0000000000 --- a/Lang/Crystal/Increment-a-numerical-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increment-a-numerical-string/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Input-loop b/Lang/Crystal/Input-loop deleted file mode 120000 index 27bc4f9208..0000000000 --- a/Lang/Crystal/Input-loop +++ /dev/null @@ -1 +0,0 @@ -../../Task/Input-loop/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Integer-comparison b/Lang/Crystal/Integer-comparison deleted file mode 120000 index 1d8d9443a7..0000000000 --- a/Lang/Crystal/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Integer-overflow b/Lang/Crystal/Integer-overflow deleted file mode 120000 index 868816b94b..0000000000 --- a/Lang/Crystal/Integer-overflow +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-overflow/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Interactive-programming-repl- b/Lang/Crystal/Interactive-programming-repl- deleted file mode 120000 index 348f845b57..0000000000 --- a/Lang/Crystal/Interactive-programming-repl- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Interactive-programming-repl-/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Inverted-syntax b/Lang/Crystal/Inverted-syntax deleted file mode 120000 index 33eb9c0c4b..0000000000 --- a/Lang/Crystal/Inverted-syntax +++ /dev/null @@ -1 +0,0 @@ -../../Task/Inverted-syntax/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Isograms-and-heterograms b/Lang/Crystal/Isograms-and-heterograms deleted file mode 120000 index 46dc26699c..0000000000 --- a/Lang/Crystal/Isograms-and-heterograms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Isograms-and-heterograms/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Isqrt-integer-square-root-of-X b/Lang/Crystal/Isqrt-integer-square-root-of-X deleted file mode 120000 index d671dd4e29..0000000000 --- a/Lang/Crystal/Isqrt-integer-square-root-of-X +++ /dev/null @@ -1 +0,0 @@ -../../Task/Isqrt-integer-square-root-of-X/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Jacobsthal-numbers b/Lang/Crystal/Jacobsthal-numbers deleted file mode 120000 index da4fc1eede..0000000000 --- a/Lang/Crystal/Jacobsthal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobsthal-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Kernighans-large-earthquake-problem b/Lang/Crystal/Kernighans-large-earthquake-problem deleted file mode 120000 index d6f60d2a2c..0000000000 --- a/Lang/Crystal/Kernighans-large-earthquake-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kernighans-large-earthquake-problem/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Knuths-algorithm-S b/Lang/Crystal/Knuths-algorithm-S deleted file mode 120000 index fbde0f33c9..0000000000 --- a/Lang/Crystal/Knuths-algorithm-S +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knuths-algorithm-S/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Langtons-ant b/Lang/Crystal/Langtons-ant deleted file mode 120000 index accd634e59..0000000000 --- a/Lang/Crystal/Langtons-ant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Langtons-ant/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Last-Friday-of-each-month b/Lang/Crystal/Last-Friday-of-each-month deleted file mode 120000 index 5dd6eb4e30..0000000000 --- a/Lang/Crystal/Last-Friday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Last-Friday-of-each-month/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Least-common-multiple b/Lang/Crystal/Least-common-multiple deleted file mode 120000 index ab85fbea40..0000000000 --- a/Lang/Crystal/Least-common-multiple +++ /dev/null @@ -1 +0,0 @@ -../../Task/Least-common-multiple/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Letter-frequency b/Lang/Crystal/Letter-frequency deleted file mode 120000 index 9aed428d1c..0000000000 --- a/Lang/Crystal/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Logical-operations b/Lang/Crystal/Logical-operations deleted file mode 120000 index efa5e278dd..0000000000 --- a/Lang/Crystal/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Logistic-curve-fitting-in-epidemiology b/Lang/Crystal/Logistic-curve-fitting-in-epidemiology deleted file mode 120000 index c8d098d82a..0000000000 --- a/Lang/Crystal/Logistic-curve-fitting-in-epidemiology +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logistic-curve-fitting-in-epidemiology/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Long-year b/Lang/Crystal/Long-year deleted file mode 120000 index 2a978e84d7..0000000000 --- a/Lang/Crystal/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Longest-string-challenge b/Lang/Crystal/Longest-string-challenge deleted file mode 120000 index 8a9ac3dfd0..0000000000 --- a/Lang/Crystal/Longest-string-challenge +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-string-challenge/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Loops-Do-while b/Lang/Crystal/Loops-Do-while deleted file mode 120000 index 16d73545fb..0000000000 --- a/Lang/Crystal/Loops-Do-while +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Do-while/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Loops-Foreach b/Lang/Crystal/Loops-Foreach deleted file mode 120000 index c20a1c8c2c..0000000000 --- a/Lang/Crystal/Loops-Foreach +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Foreach/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Loops-N-plus-one-half b/Lang/Crystal/Loops-N-plus-one-half deleted file mode 120000 index baee612204..0000000000 --- a/Lang/Crystal/Loops-N-plus-one-half +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-N-plus-one-half/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Loops-With-multiple-ranges b/Lang/Crystal/Loops-With-multiple-ranges deleted file mode 120000 index a0c34f1c73..0000000000 --- a/Lang/Crystal/Loops-With-multiple-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-With-multiple-ranges/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Loops-Wrong-ranges b/Lang/Crystal/Loops-Wrong-ranges deleted file mode 120000 index 402c2c3d6b..0000000000 --- a/Lang/Crystal/Loops-Wrong-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Wrong-ranges/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Magic-8-ball b/Lang/Crystal/Magic-8-ball deleted file mode 120000 index 7694de9dbd..0000000000 --- a/Lang/Crystal/Magic-8-ball +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-8-ball/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Magnanimous-numbers b/Lang/Crystal/Magnanimous-numbers deleted file mode 120000 index f025f31b2f..0000000000 --- a/Lang/Crystal/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Map-range b/Lang/Crystal/Map-range deleted file mode 120000 index 2ce80c8e32..0000000000 --- a/Lang/Crystal/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Middle-three-digits b/Lang/Crystal/Middle-three-digits deleted file mode 120000 index c195484a68..0000000000 --- a/Lang/Crystal/Middle-three-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Middle-three-digits/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Miller-Rabin-primality-test b/Lang/Crystal/Miller-Rabin-primality-test new file mode 120000 index 0000000000..3714050251 --- /dev/null +++ b/Lang/Crystal/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Move-to-front-algorithm b/Lang/Crystal/Move-to-front-algorithm deleted file mode 120000 index 1fc15ab4a7..0000000000 --- a/Lang/Crystal/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Narcissistic-decimal-number b/Lang/Crystal/Narcissistic-decimal-number deleted file mode 120000 index 7713050610..0000000000 --- a/Lang/Crystal/Narcissistic-decimal-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Narcissistic-decimal-number/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Nested-function b/Lang/Crystal/Nested-function deleted file mode 120000 index 4453485348..0000000000 --- a/Lang/Crystal/Nested-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nested-function/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Non-decimal-radices-Convert b/Lang/Crystal/Non-decimal-radices-Convert deleted file mode 120000 index 342df0f845..0000000000 --- a/Lang/Crystal/Non-decimal-radices-Convert +++ /dev/null @@ -1 +0,0 @@ -../../Task/Non-decimal-radices-Convert/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Number-names b/Lang/Crystal/Number-names deleted file mode 120000 index 65ddc62215..0000000000 --- a/Lang/Crystal/Number-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Number-names/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Numbers-with-equal-rises-and-falls b/Lang/Crystal/Numbers-with-equal-rises-and-falls deleted file mode 120000 index 6aa2426e57..0000000000 --- a/Lang/Crystal/Numbers-with-equal-rises-and-falls +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-with-equal-rises-and-falls/Crystal \ No newline at end of file diff --git a/Lang/Crystal/One-dimensional-cellular-automata b/Lang/Crystal/One-dimensional-cellular-automata deleted file mode 120000 index e519134b4d..0000000000 --- a/Lang/Crystal/One-dimensional-cellular-automata +++ /dev/null @@ -1 +0,0 @@ -../../Task/One-dimensional-cellular-automata/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Order-by-pair-comparisons b/Lang/Crystal/Order-by-pair-comparisons deleted file mode 120000 index 7f819e26a0..0000000000 --- a/Lang/Crystal/Order-by-pair-comparisons +++ /dev/null @@ -1 +0,0 @@ -../../Task/Order-by-pair-comparisons/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Order-two-numerical-lists b/Lang/Crystal/Order-two-numerical-lists deleted file mode 120000 index 44bdc040e5..0000000000 --- a/Lang/Crystal/Order-two-numerical-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Order-two-numerical-lists/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Ordered-words b/Lang/Crystal/Ordered-words deleted file mode 120000 index 52c1bed5c6..0000000000 --- a/Lang/Crystal/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Palindrome-dates b/Lang/Crystal/Palindrome-dates deleted file mode 120000 index e9d9714cac..0000000000 --- a/Lang/Crystal/Palindrome-dates +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-dates/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Parallel-brute-force b/Lang/Crystal/Parallel-brute-force deleted file mode 120000 index 496ce76b45..0000000000 --- a/Lang/Crystal/Parallel-brute-force +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parallel-brute-force/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Parse-an-IP-Address b/Lang/Crystal/Parse-an-IP-Address deleted file mode 120000 index 940d156ab2..0000000000 --- a/Lang/Crystal/Parse-an-IP-Address +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parse-an-IP-Address/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Parsing-RPN-calculator-algorithm b/Lang/Crystal/Parsing-RPN-calculator-algorithm deleted file mode 120000 index 79e0e2ae7e..0000000000 --- a/Lang/Crystal/Parsing-RPN-calculator-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parsing-RPN-calculator-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Parsing-RPN-to-infix-conversion b/Lang/Crystal/Parsing-RPN-to-infix-conversion deleted file mode 120000 index e19adc6368..0000000000 --- a/Lang/Crystal/Parsing-RPN-to-infix-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parsing-RPN-to-infix-conversion/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Parsing-Shunting-yard-algorithm b/Lang/Crystal/Parsing-Shunting-yard-algorithm deleted file mode 120000 index a18ff957d5..0000000000 --- a/Lang/Crystal/Parsing-Shunting-yard-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parsing-Shunting-yard-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Partial-function-application b/Lang/Crystal/Partial-function-application deleted file mode 120000 index 06b96bb5bb..0000000000 --- a/Lang/Crystal/Partial-function-application +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partial-function-application/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Perfect-numbers b/Lang/Crystal/Perfect-numbers deleted file mode 120000 index 708a2045e2..0000000000 --- a/Lang/Crystal/Perfect-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perfect-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Phrase-reversals b/Lang/Crystal/Phrase-reversals deleted file mode 120000 index 7a12cc6718..0000000000 --- a/Lang/Crystal/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Power-set b/Lang/Crystal/Power-set deleted file mode 120000 index 0fd70fd5b9..0000000000 --- a/Lang/Crystal/Power-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Power-set/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Priority-queue b/Lang/Crystal/Priority-queue deleted file mode 120000 index 4f7dddb139..0000000000 --- a/Lang/Crystal/Priority-queue +++ /dev/null @@ -1 +0,0 @@ -../../Task/Priority-queue/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Program-name b/Lang/Crystal/Program-name deleted file mode 120000 index 0398fe1a1e..0000000000 --- a/Lang/Crystal/Program-name +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-name/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Quaternion-type b/Lang/Crystal/Quaternion-type new file mode 120000 index 0000000000..5a28c33333 --- /dev/null +++ b/Lang/Crystal/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Random-sentence-from-book b/Lang/Crystal/Random-sentence-from-book deleted file mode 120000 index 916a4913b6..0000000000 --- a/Lang/Crystal/Random-sentence-from-book +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-sentence-from-book/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Range-extraction b/Lang/Crystal/Range-extraction deleted file mode 120000 index 984878874c..0000000000 --- a/Lang/Crystal/Range-extraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-extraction/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Regular-expressions b/Lang/Crystal/Regular-expressions deleted file mode 120000 index 1e1b324d69..0000000000 --- a/Lang/Crystal/Regular-expressions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Regular-expressions/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Repeat b/Lang/Crystal/Repeat deleted file mode 120000 index cbbc5973da..0000000000 --- a/Lang/Crystal/Repeat +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Return-multiple-values b/Lang/Crystal/Return-multiple-values deleted file mode 120000 index df0883e4b0..0000000000 --- a/Lang/Crystal/Return-multiple-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Return-multiple-values/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Reverse-words-in-a-string b/Lang/Crystal/Reverse-words-in-a-string deleted file mode 120000 index 44576bae9a..0000000000 --- a/Lang/Crystal/Reverse-words-in-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-words-in-a-string/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Rosetta-Code-Rank-languages-by-popularity b/Lang/Crystal/Rosetta-Code-Rank-languages-by-popularity deleted file mode 120000 index 69fe9e65d5..0000000000 --- a/Lang/Crystal/Rosetta-Code-Rank-languages-by-popularity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rosetta-Code-Rank-languages-by-popularity/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Rot-13 b/Lang/Crystal/Rot-13 deleted file mode 120000 index 430011bd06..0000000000 --- a/Lang/Crystal/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Run-length-encoding b/Lang/Crystal/Run-length-encoding deleted file mode 120000 index 1a2b6b241a..0000000000 --- a/Lang/Crystal/Run-length-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/Run-length-encoding/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Search-a-list b/Lang/Crystal/Search-a-list deleted file mode 120000 index 975cbb3120..0000000000 --- a/Lang/Crystal/Search-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sequence-of-non-squares b/Lang/Crystal/Sequence-of-non-squares deleted file mode 120000 index 4854c5c8ce..0000000000 --- a/Lang/Crystal/Sequence-of-non-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-non-squares/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Set b/Lang/Crystal/Set deleted file mode 120000 index 09e0457880..0000000000 --- a/Lang/Crystal/Set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Short-circuit-evaluation b/Lang/Crystal/Short-circuit-evaluation deleted file mode 120000 index 42f8d1e06a..0000000000 --- a/Lang/Crystal/Short-circuit-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Short-circuit-evaluation/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Simple-database b/Lang/Crystal/Simple-database deleted file mode 120000 index 91a24ce202..0000000000 --- a/Lang/Crystal/Simple-database +++ /dev/null @@ -1 +0,0 @@ -../../Task/Simple-database/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Singly-linked-list-Element-definition b/Lang/Crystal/Singly-linked-list-Element-definition deleted file mode 120000 index 1c9a4e215c..0000000000 --- a/Lang/Crystal/Singly-linked-list-Element-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Singly-linked-list-Element-definition/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Singly-linked-list-Element-insertion b/Lang/Crystal/Singly-linked-list-Element-insertion deleted file mode 120000 index e0de17b549..0000000000 --- a/Lang/Crystal/Singly-linked-list-Element-insertion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Singly-linked-list-Element-insertion/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Singly-linked-list-Traversal b/Lang/Crystal/Singly-linked-list-Traversal deleted file mode 120000 index e89e5d42db..0000000000 --- a/Lang/Crystal/Singly-linked-list-Traversal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Singly-linked-list-Traversal/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sleep b/Lang/Crystal/Sleep deleted file mode 120000 index 1648e77b82..0000000000 --- a/Lang/Crystal/Sleep +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleep/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sleeping-Beauty-problem b/Lang/Crystal/Sleeping-Beauty-problem deleted file mode 120000 index 50b43e53b7..0000000000 --- a/Lang/Crystal/Sleeping-Beauty-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleeping-Beauty-problem/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Soloways-recurring-rainfall b/Lang/Crystal/Soloways-recurring-rainfall deleted file mode 120000 index 017187c230..0000000000 --- a/Lang/Crystal/Soloways-recurring-rainfall +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soloways-recurring-rainfall/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sort-a-list-of-object-identifiers b/Lang/Crystal/Sort-a-list-of-object-identifiers deleted file mode 120000 index 2b599d3df1..0000000000 --- a/Lang/Crystal/Sort-a-list-of-object-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-a-list-of-object-identifiers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sort-an-array-of-composite-structures b/Lang/Crystal/Sort-an-array-of-composite-structures deleted file mode 120000 index 5ea781aef9..0000000000 --- a/Lang/Crystal/Sort-an-array-of-composite-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-array-of-composite-structures/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sort-disjoint-sublist b/Lang/Crystal/Sort-disjoint-sublist deleted file mode 120000 index a252445ff4..0000000000 --- a/Lang/Crystal/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sort-numbers-lexicographically b/Lang/Crystal/Sort-numbers-lexicographically deleted file mode 120000 index 884dc88521..0000000000 --- a/Lang/Crystal/Sort-numbers-lexicographically +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-numbers-lexicographically/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sort-three-variables b/Lang/Crystal/Sort-three-variables deleted file mode 120000 index e206daaf02..0000000000 --- a/Lang/Crystal/Sort-three-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-three-variables/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sort-using-a-custom-comparator b/Lang/Crystal/Sort-using-a-custom-comparator deleted file mode 120000 index 0614ceb188..0000000000 --- a/Lang/Crystal/Sort-using-a-custom-comparator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-using-a-custom-comparator/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sorting-algorithms-Bubble-sort b/Lang/Crystal/Sorting-algorithms-Bubble-sort deleted file mode 120000 index 88a150acfe..0000000000 --- a/Lang/Crystal/Sorting-algorithms-Bubble-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bubble-sort/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sorting-algorithms-Stooge-sort b/Lang/Crystal/Sorting-algorithms-Stooge-sort deleted file mode 120000 index 9882d0a5e5..0000000000 --- a/Lang/Crystal/Sorting-algorithms-Stooge-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Stooge-sort/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sparkline-in-unicode b/Lang/Crystal/Sparkline-in-unicode deleted file mode 120000 index 986b27240a..0000000000 --- a/Lang/Crystal/Sparkline-in-unicode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sparkline-in-unicode/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Spelling-of-ordinal-numbers b/Lang/Crystal/Spelling-of-ordinal-numbers deleted file mode 120000 index 68e66511d0..0000000000 --- a/Lang/Crystal/Spelling-of-ordinal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Spelling-of-ordinal-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Split-a-character-string-based-on-change-of-character b/Lang/Crystal/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index 874feaced9..0000000000 --- a/Lang/Crystal/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Stack-traces b/Lang/Crystal/Stack-traces deleted file mode 120000 index 9cc8cddb52..0000000000 --- a/Lang/Crystal/Stack-traces +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stack-traces/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Stem-and-leaf-plot b/Lang/Crystal/Stem-and-leaf-plot deleted file mode 120000 index 4fac378f12..0000000000 --- a/Lang/Crystal/Stem-and-leaf-plot +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stem-and-leaf-plot/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Stirling-numbers-of-the-first-kind b/Lang/Crystal/Stirling-numbers-of-the-first-kind deleted file mode 120000 index 8a52252a36..0000000000 --- a/Lang/Crystal/Stirling-numbers-of-the-first-kind +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stirling-numbers-of-the-first-kind/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Straddling-checkerboard b/Lang/Crystal/Straddling-checkerboard deleted file mode 120000 index 1550d42cee..0000000000 --- a/Lang/Crystal/Straddling-checkerboard +++ /dev/null @@ -1 +0,0 @@ -../../Task/Straddling-checkerboard/Crystal \ No newline at end of file diff --git a/Lang/Crystal/String-append b/Lang/Crystal/String-append deleted file mode 120000 index 4f16bddd70..0000000000 --- a/Lang/Crystal/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/Crystal \ No newline at end of file diff --git a/Lang/Crystal/String-concatenation b/Lang/Crystal/String-concatenation deleted file mode 120000 index 1237b70607..0000000000 --- a/Lang/Crystal/String-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-concatenation/Crystal \ No newline at end of file diff --git a/Lang/Crystal/String-interpolation-included- b/Lang/Crystal/String-interpolation-included- deleted file mode 120000 index 05bff0aabd..0000000000 --- a/Lang/Crystal/String-interpolation-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-interpolation-included-/Crystal \ No newline at end of file diff --git a/Lang/Crystal/String-matching b/Lang/Crystal/String-matching deleted file mode 120000 index 439dd1fa36..0000000000 --- a/Lang/Crystal/String-matching +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-matching/Crystal \ No newline at end of file diff --git a/Lang/Crystal/String-prepend b/Lang/Crystal/String-prepend deleted file mode 120000 index 2c5c171e4c..0000000000 --- a/Lang/Crystal/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Strip-a-set-of-characters-from-a-string b/Lang/Crystal/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index 7c09aa4ce1..0000000000 --- a/Lang/Crystal/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Strip-block-comments b/Lang/Crystal/Strip-block-comments deleted file mode 120000 index 2a4303ed27..0000000000 --- a/Lang/Crystal/Strip-block-comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-block-comments/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Strip-comments-from-a-string b/Lang/Crystal/Strip-comments-from-a-string deleted file mode 120000 index bf4a72832d..0000000000 --- a/Lang/Crystal/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Strip-control-codes-and-extended-characters-from-a-string b/Lang/Crystal/Strip-control-codes-and-extended-characters-from-a-string deleted file mode 120000 index 2831009e2a..0000000000 --- a/Lang/Crystal/Strip-control-codes-and-extended-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-control-codes-and-extended-characters-from-a-string/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Substring-Top-and-tail b/Lang/Crystal/Substring-Top-and-tail deleted file mode 120000 index d3af8a2b7f..0000000000 --- a/Lang/Crystal/Substring-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substring-Top-and-tail/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sudan-function b/Lang/Crystal/Sudan-function deleted file mode 120000 index a75bf5defc..0000000000 --- a/Lang/Crystal/Sudan-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sudan-function/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sum-to-100 b/Lang/Crystal/Sum-to-100 deleted file mode 120000 index 02859f9ab7..0000000000 --- a/Lang/Crystal/Sum-to-100 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-to-100/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Summarize-and-say-sequence b/Lang/Crystal/Summarize-and-say-sequence deleted file mode 120000 index ac69b16598..0000000000 --- a/Lang/Crystal/Summarize-and-say-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Summarize-and-say-sequence/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Sylvesters-sequence b/Lang/Crystal/Sylvesters-sequence deleted file mode 120000 index cd026cc33a..0000000000 --- a/Lang/Crystal/Sylvesters-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sylvesters-sequence/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Symmetric-difference b/Lang/Crystal/Symmetric-difference deleted file mode 120000 index 566657d82c..0000000000 --- a/Lang/Crystal/Symmetric-difference +++ /dev/null @@ -1 +0,0 @@ -../../Task/Symmetric-difference/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Take-notes-on-the-command-line b/Lang/Crystal/Take-notes-on-the-command-line deleted file mode 120000 index e978486e4d..0000000000 --- a/Lang/Crystal/Take-notes-on-the-command-line +++ /dev/null @@ -1 +0,0 @@ -../../Task/Take-notes-on-the-command-line/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Temperature-conversion b/Lang/Crystal/Temperature-conversion deleted file mode 120000 index d97258c24c..0000000000 --- a/Lang/Crystal/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Ternary-logic b/Lang/Crystal/Ternary-logic deleted file mode 120000 index adfcdc28dd..0000000000 --- a/Lang/Crystal/Ternary-logic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ternary-logic/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Textonyms b/Lang/Crystal/Textonyms deleted file mode 120000 index e9c8a3c5ec..0000000000 --- a/Lang/Crystal/Textonyms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Textonyms/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Towers-of-Hanoi b/Lang/Crystal/Towers-of-Hanoi deleted file mode 120000 index 49ee652bdd..0000000000 --- a/Lang/Crystal/Towers-of-Hanoi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Towers-of-Hanoi/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Transliterate-English-text-using-the-Greek-alphabet b/Lang/Crystal/Transliterate-English-text-using-the-Greek-alphabet deleted file mode 120000 index cb70d2aa14..0000000000 --- a/Lang/Crystal/Transliterate-English-text-using-the-Greek-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Transliterate-English-text-using-the-Greek-alphabet/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Truncate-a-file b/Lang/Crystal/Truncate-a-file deleted file mode 120000 index a75ef5468d..0000000000 --- a/Lang/Crystal/Truncate-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truncate-a-file/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Truth-table b/Lang/Crystal/Truth-table deleted file mode 120000 index 7f3aa2a526..0000000000 --- a/Lang/Crystal/Truth-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truth-table/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Twos-complement b/Lang/Crystal/Twos-complement deleted file mode 120000 index 2272e1c36b..0000000000 --- a/Lang/Crystal/Twos-complement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twos-complement/Crystal \ No newline at end of file diff --git a/Lang/Crystal/UPC b/Lang/Crystal/UPC deleted file mode 120000 index b4d8d405f7..0000000000 --- a/Lang/Crystal/UPC +++ /dev/null @@ -1 +0,0 @@ -../../Task/UPC/Crystal \ No newline at end of file diff --git a/Lang/Crystal/UTF-8-encode-and-decode b/Lang/Crystal/UTF-8-encode-and-decode deleted file mode 120000 index acebf418fa..0000000000 --- a/Lang/Crystal/UTF-8-encode-and-decode +++ /dev/null @@ -1 +0,0 @@ -../../Task/UTF-8-encode-and-decode/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Van-der-Corput-sequence b/Lang/Crystal/Van-der-Corput-sequence deleted file mode 120000 index c9bba5d9e9..0000000000 --- a/Lang/Crystal/Van-der-Corput-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-der-Corput-sequence/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Variable-length-quantity b/Lang/Crystal/Variable-length-quantity deleted file mode 120000 index 4664ff0cf8..0000000000 --- a/Lang/Crystal/Variable-length-quantity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variable-length-quantity/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Vector b/Lang/Crystal/Vector deleted file mode 120000 index eff97fd6f9..0000000000 --- a/Lang/Crystal/Vector +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vector/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Wagstaff-primes b/Lang/Crystal/Wagstaff-primes deleted file mode 120000 index ce243d1192..0000000000 --- a/Lang/Crystal/Wagstaff-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wagstaff-primes/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Wordiff b/Lang/Crystal/Wordiff deleted file mode 120000 index fcf6f8935c..0000000000 --- a/Lang/Crystal/Wordiff +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wordiff/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Write-entire-file b/Lang/Crystal/Write-entire-file deleted file mode 120000 index f56680457a..0000000000 --- a/Lang/Crystal/Write-entire-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-entire-file/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Write-language-name-in-3D-ASCII b/Lang/Crystal/Write-language-name-in-3D-ASCII deleted file mode 120000 index 668585ccef..0000000000 --- a/Lang/Crystal/Write-language-name-in-3D-ASCII +++ /dev/null @@ -1 +0,0 @@ -../../Task/Write-language-name-in-3D-ASCII/Crystal \ No newline at end of file diff --git a/Lang/Crystal/XML-Input b/Lang/Crystal/XML-Input deleted file mode 120000 index 186294c638..0000000000 --- a/Lang/Crystal/XML-Input +++ /dev/null @@ -1 +0,0 @@ -../../Task/XML-Input/Crystal \ No newline at end of file diff --git a/Lang/Crystal/XML-XPath b/Lang/Crystal/XML-XPath deleted file mode 120000 index cc58f19135..0000000000 --- a/Lang/Crystal/XML-XPath +++ /dev/null @@ -1 +0,0 @@ -../../Task/XML-XPath/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Yellowstone-sequence b/Lang/Crystal/Yellowstone-sequence deleted file mode 120000 index e0ffb2052b..0000000000 --- a/Lang/Crystal/Yellowstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yellowstone-sequence/Crystal \ No newline at end of file diff --git a/Lang/Curto/00-LANG.txt b/Lang/Curto/00-LANG.txt deleted file mode 100644 index c2a3c801b1..0000000000 --- a/Lang/Curto/00-LANG.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{language|Curto -|exec=machine -|site=https://maleza.srht.site/curto.html -|gc=no -|parampass=reference -|untyped=yes -|tags=forth -}} - -Curto es una traducción completa de UF Forth al español. - -==Links== -*[https://maleza.srht.site/curto.html Sitio] - -{{Language programming paradigm|Concatenative}} -==Curto== - -Curto es una traducción completa de UF Forth al español. Actualmente el trabajo de tracucción está en progreso por lo que el código fuente aún no contiene caracteres especiales del idioma y la traducción de los comentarios aún no se ha completado. - -Este es un sistema Forth tradicional para la computadora virtual "uxn/varvara". "Curto" está escrito en Tal y Curto y provee una interface de texto interactiva y un editor de pantalla. El sistema no es enebrado, compila a código UXN nativo, pero actualmente solo un mínimo de optimizaciones son realizadas. El mapeo entre código fuente Curto e instrucciones de la VM es relativamente directo por lo que la pérformance debería ser mas que suficiente para todas salvo las más críticas de las situaciones. Las celdas son de 16 bits, el sistema completo ocupa alrededor de 25k de memoria, siendo necesarios otros 4k para memoria de pantalla y buffers. - -==Todo== -* [[Tasks not implemented in Curto]] \ No newline at end of file diff --git a/Lang/Curto/00-META.yaml b/Lang/Curto/00-META.yaml deleted file mode 100644 index ebc3825015..0000000000 --- a/Lang/Curto/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Curto diff --git a/Lang/Curto/Conditional-structures b/Lang/Curto/Conditional-structures deleted file mode 120000 index 0ddebd80bc..0000000000 --- a/Lang/Curto/Conditional-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conditional-structures/Curto \ No newline at end of file diff --git a/Lang/Curto/Hello-world-Text b/Lang/Curto/Hello-world-Text deleted file mode 120000 index 7e7d781c66..0000000000 --- a/Lang/Curto/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Curto \ No newline at end of file diff --git a/Lang/D/Find-Chess960-starting-position-identifier b/Lang/D/Find-Chess960-starting-position-identifier deleted file mode 120000 index 79e07139b9..0000000000 --- a/Lang/D/Find-Chess960-starting-position-identifier +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-Chess960-starting-position-identifier/D \ No newline at end of file diff --git a/Lang/D/Largest-proper-divisor-of-n b/Lang/D/Largest-proper-divisor-of-n deleted file mode 120000 index 62b7fe70aa..0000000000 --- a/Lang/D/Largest-proper-divisor-of-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-proper-divisor-of-n/D \ No newline at end of file diff --git a/Lang/D/Miller-Rabin-primality-test b/Lang/D/Miller-Rabin-primality-test new file mode 120000 index 0000000000..407bdbfce4 --- /dev/null +++ b/Lang/D/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/D \ No newline at end of file diff --git a/Lang/D/Own-digits-power-sum b/Lang/D/Own-digits-power-sum deleted file mode 120000 index 937ef98bff..0000000000 --- a/Lang/D/Own-digits-power-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Own-digits-power-sum/D \ No newline at end of file diff --git a/Lang/D/Quaternion-type b/Lang/D/Quaternion-type new file mode 120000 index 0000000000..4703070a3f --- /dev/null +++ b/Lang/D/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/D \ No newline at end of file diff --git a/Lang/D/Sorting-Algorithms-Circle-Sort b/Lang/D/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..950d2a1c8c --- /dev/null +++ b/Lang/D/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/D \ No newline at end of file diff --git a/Lang/DIBOL-11/Loops-Infinite b/Lang/DIBOL-11/Loops-Infinite deleted file mode 120000 index 81547d688b..0000000000 --- a/Lang/DIBOL-11/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/DIBOL-11 \ No newline at end of file diff --git a/Lang/Dart/100-prisoners b/Lang/Dart/100-prisoners deleted file mode 120000 index 6b68c72b8e..0000000000 --- a/Lang/Dart/100-prisoners +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-prisoners/Dart \ No newline at end of file diff --git a/Lang/Dart/15-puzzle-solver b/Lang/Dart/15-puzzle-solver deleted file mode 120000 index 9e8e216a39..0000000000 --- a/Lang/Dart/15-puzzle-solver +++ /dev/null @@ -1 +0,0 @@ -../../Task/15-puzzle-solver/Dart \ No newline at end of file diff --git a/Lang/Dart/24-game-Solve b/Lang/Dart/24-game-Solve deleted file mode 120000 index ae64875d6c..0000000000 --- a/Lang/Dart/24-game-Solve +++ /dev/null @@ -1 +0,0 @@ -../../Task/24-game-Solve/Dart \ No newline at end of file diff --git a/Lang/Dart/AVL-tree b/Lang/Dart/AVL-tree deleted file mode 120000 index 00bc5f9c2f..0000000000 --- a/Lang/Dart/AVL-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/AVL-tree/Dart \ No newline at end of file diff --git a/Lang/Dart/Arithmetic-Integer b/Lang/Dart/Arithmetic-Integer deleted file mode 120000 index b0138d9c48..0000000000 --- a/Lang/Dart/Arithmetic-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Integer/Dart \ No newline at end of file diff --git a/Lang/Dart/Benfords-law b/Lang/Dart/Benfords-law deleted file mode 120000 index bccac375ec..0000000000 --- a/Lang/Dart/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/Dart \ No newline at end of file diff --git a/Lang/Dart/Boyer-Moore-string-search b/Lang/Dart/Boyer-Moore-string-search deleted file mode 120000 index 8b8a6a6060..0000000000 --- a/Lang/Dart/Boyer-Moore-string-search +++ /dev/null @@ -1 +0,0 @@ -../../Task/Boyer-Moore-string-search/Dart \ No newline at end of file diff --git a/Lang/Dart/Break-OO-privacy b/Lang/Dart/Break-OO-privacy deleted file mode 120000 index e07e79a6ca..0000000000 --- a/Lang/Dart/Break-OO-privacy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Break-OO-privacy/Dart \ No newline at end of file diff --git a/Lang/Dart/Burrows-Wheeler-transform b/Lang/Dart/Burrows-Wheeler-transform deleted file mode 120000 index d3c9f31111..0000000000 --- a/Lang/Dart/Burrows-Wheeler-transform +++ /dev/null @@ -1 +0,0 @@ -../../Task/Burrows-Wheeler-transform/Dart \ No newline at end of file diff --git a/Lang/Dart/Case-sensitivity-of-identifiers b/Lang/Dart/Case-sensitivity-of-identifiers deleted file mode 120000 index d90aafa8e4..0000000000 --- a/Lang/Dart/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/Dart \ No newline at end of file diff --git a/Lang/Dart/Character-codes b/Lang/Dart/Character-codes deleted file mode 120000 index eee070c4f5..0000000000 --- a/Lang/Dart/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/Dart \ No newline at end of file diff --git a/Lang/Dart/Continued-fraction b/Lang/Dart/Continued-fraction deleted file mode 120000 index ea5b665958..0000000000 --- a/Lang/Dart/Continued-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Continued-fraction/Dart \ No newline at end of file diff --git a/Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- deleted file mode 120000 index eb55960eb5..0000000000 --- a/Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Dart \ No newline at end of file diff --git a/Lang/Dart/Cullen-and-Woodall-numbers b/Lang/Dart/Cullen-and-Woodall-numbers deleted file mode 120000 index 573f34cd4f..0000000000 --- a/Lang/Dart/Cullen-and-Woodall-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cullen-and-Woodall-numbers/Dart \ No newline at end of file diff --git a/Lang/Dart/Day-of-the-week b/Lang/Dart/Day-of-the-week deleted file mode 120000 index 15dd0e18f6..0000000000 --- a/Lang/Dart/Day-of-the-week +++ /dev/null @@ -1 +0,0 @@ -../../Task/Day-of-the-week/Dart \ No newline at end of file diff --git a/Lang/Dart/De-Bruijn-sequences b/Lang/Dart/De-Bruijn-sequences deleted file mode 120000 index f7a9a5e2e1..0000000000 --- a/Lang/Dart/De-Bruijn-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/De-Bruijn-sequences/Dart \ No newline at end of file diff --git a/Lang/Dart/Determine-sentence-type b/Lang/Dart/Determine-sentence-type deleted file mode 120000 index cbfbfb1793..0000000000 --- a/Lang/Dart/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/Dart \ No newline at end of file diff --git a/Lang/Dart/Dijkstras-algorithm b/Lang/Dart/Dijkstras-algorithm deleted file mode 120000 index fc7b73a06b..0000000000 --- a/Lang/Dart/Dijkstras-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dijkstras-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Diversity-prediction-theorem b/Lang/Dart/Diversity-prediction-theorem deleted file mode 120000 index 525bb8c4cf..0000000000 --- a/Lang/Dart/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/Dart \ No newline at end of file diff --git a/Lang/Dart/Euler-method b/Lang/Dart/Euler-method deleted file mode 120000 index 6501c260ce..0000000000 --- a/Lang/Dart/Euler-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euler-method/Dart \ No newline at end of file diff --git a/Lang/Dart/Evolutionary-algorithm b/Lang/Dart/Evolutionary-algorithm deleted file mode 120000 index 37e72623f8..0000000000 --- a/Lang/Dart/Evolutionary-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evolutionary-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Fibonacci-word b/Lang/Dart/Fibonacci-word deleted file mode 120000 index 5feb3092ca..0000000000 --- a/Lang/Dart/Fibonacci-word +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-word/Dart \ No newline at end of file diff --git a/Lang/Dart/Floyd-Warshall-algorithm b/Lang/Dart/Floyd-Warshall-algorithm deleted file mode 120000 index 34dc98809b..0000000000 --- a/Lang/Dart/Floyd-Warshall-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyd-Warshall-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Generate-lower-case-ASCII-alphabet b/Lang/Dart/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index 947014123e..0000000000 --- a/Lang/Dart/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/Dart \ No newline at end of file diff --git a/Lang/Dart/Iterated-digits-squaring b/Lang/Dart/Iterated-digits-squaring deleted file mode 120000 index 87955b71c0..0000000000 --- a/Lang/Dart/Iterated-digits-squaring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Iterated-digits-squaring/Dart \ No newline at end of file diff --git a/Lang/Dart/Jensens-Device b/Lang/Dart/Jensens-Device deleted file mode 120000 index 973fbf791f..0000000000 --- a/Lang/Dart/Jensens-Device +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jensens-Device/Dart \ No newline at end of file diff --git a/Lang/Dart/Jewels-and-stones b/Lang/Dart/Jewels-and-stones deleted file mode 120000 index 8673bcd41d..0000000000 --- a/Lang/Dart/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/Dart \ No newline at end of file diff --git a/Lang/Dart/Jordan-P-lya-numbers b/Lang/Dart/Jordan-P-lya-numbers deleted file mode 120000 index 84c71f877c..0000000000 --- a/Lang/Dart/Jordan-P-lya-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jordan-P-lya-numbers/Dart \ No newline at end of file diff --git a/Lang/Dart/K-d-tree b/Lang/Dart/K-d-tree deleted file mode 120000 index 4b4a8013e5..0000000000 --- a/Lang/Dart/K-d-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/K-d-tree/Dart \ No newline at end of file diff --git a/Lang/Dart/Leonardo-numbers b/Lang/Dart/Leonardo-numbers deleted file mode 120000 index 93d2f002c1..0000000000 --- a/Lang/Dart/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/Dart \ No newline at end of file diff --git a/Lang/Dart/Map-range b/Lang/Dart/Map-range deleted file mode 120000 index 5ed6b07ca1..0000000000 --- a/Lang/Dart/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/Dart \ No newline at end of file diff --git a/Lang/Dart/Meissel-Mertens-constant b/Lang/Dart/Meissel-Mertens-constant new file mode 120000 index 0000000000..bac3ec4c99 --- /dev/null +++ b/Lang/Dart/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/Dart \ No newline at end of file diff --git a/Lang/Dart/Modular-exponentiation b/Lang/Dart/Modular-exponentiation deleted file mode 120000 index afe2138c27..0000000000 --- a/Lang/Dart/Modular-exponentiation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Modular-exponentiation/Dart \ No newline at end of file diff --git a/Lang/Dart/Nth-root b/Lang/Dart/Nth-root deleted file mode 120000 index ff1dc1b2ec..0000000000 --- a/Lang/Dart/Nth-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth-root/Dart \ No newline at end of file diff --git a/Lang/Dart/Ormiston-triples b/Lang/Dart/Ormiston-triples deleted file mode 120000 index ddb933956b..0000000000 --- a/Lang/Dart/Ormiston-triples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ormiston-triples/Dart \ No newline at end of file diff --git a/Lang/Dart/Pancake-numbers b/Lang/Dart/Pancake-numbers deleted file mode 120000 index 78b8078b97..0000000000 --- a/Lang/Dart/Pancake-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pancake-numbers/Dart \ No newline at end of file diff --git a/Lang/Dart/Parse-an-IP-Address b/Lang/Dart/Parse-an-IP-Address deleted file mode 120000 index bbe41020cb..0000000000 --- a/Lang/Dart/Parse-an-IP-Address +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parse-an-IP-Address/Dart \ No newline at end of file diff --git a/Lang/Dart/Parsing-Shunting-yard-algorithm b/Lang/Dart/Parsing-Shunting-yard-algorithm deleted file mode 120000 index 764230d0e5..0000000000 --- a/Lang/Dart/Parsing-Shunting-yard-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parsing-Shunting-yard-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Partition-an-integer-x-into-n-primes b/Lang/Dart/Partition-an-integer-x-into-n-primes deleted file mode 120000 index 4b67e26b1a..0000000000 --- a/Lang/Dart/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/Dart \ No newline at end of file diff --git a/Lang/Dart/Partition-function-P b/Lang/Dart/Partition-function-P deleted file mode 120000 index 9146b4b231..0000000000 --- a/Lang/Dart/Partition-function-P +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-function-P/Dart \ No newline at end of file diff --git a/Lang/Dart/Penneys-game b/Lang/Dart/Penneys-game deleted file mode 120000 index f054d83b87..0000000000 --- a/Lang/Dart/Penneys-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Penneys-game/Dart \ No newline at end of file diff --git a/Lang/Dart/Permutations-by-swapping b/Lang/Dart/Permutations-by-swapping deleted file mode 120000 index 9009ddfa84..0000000000 --- a/Lang/Dart/Permutations-by-swapping +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-by-swapping/Dart \ No newline at end of file diff --git a/Lang/Dart/Pick-random-element b/Lang/Dart/Pick-random-element deleted file mode 120000 index 1c6ed4225d..0000000000 --- a/Lang/Dart/Pick-random-element +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pick-random-element/Dart \ No newline at end of file diff --git a/Lang/Dart/Price-fraction b/Lang/Dart/Price-fraction deleted file mode 120000 index b65d52f099..0000000000 --- a/Lang/Dart/Price-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Price-fraction/Dart \ No newline at end of file diff --git a/Lang/Dart/Primality-by-Wilsons-theorem b/Lang/Dart/Primality-by-Wilsons-theorem deleted file mode 120000 index 6834b7d634..0000000000 --- a/Lang/Dart/Primality-by-Wilsons-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-Wilsons-theorem/Dart \ No newline at end of file diff --git a/Lang/Dart/Pseudo-random-numbers-PCG32 b/Lang/Dart/Pseudo-random-numbers-PCG32 deleted file mode 120000 index 40ec498984..0000000000 --- a/Lang/Dart/Pseudo-random-numbers-PCG32 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-PCG32/Dart \ No newline at end of file diff --git a/Lang/Dart/Pythagoras-tree b/Lang/Dart/Pythagoras-tree deleted file mode 120000 index af9f37b604..0000000000 --- a/Lang/Dart/Pythagoras-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagoras-tree/Dart \ No newline at end of file diff --git a/Lang/Dart/Random-Latin-squares b/Lang/Dart/Random-Latin-squares deleted file mode 120000 index 226cba5197..0000000000 --- a/Lang/Dart/Random-Latin-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-Latin-squares/Dart \ No newline at end of file diff --git a/Lang/Dart/Random-sentence-from-book b/Lang/Dart/Random-sentence-from-book deleted file mode 120000 index 2b4a3a67d4..0000000000 --- a/Lang/Dart/Random-sentence-from-book +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-sentence-from-book/Dart \ No newline at end of file diff --git a/Lang/Dart/Repeat b/Lang/Dart/Repeat deleted file mode 120000 index f9635c7eb9..0000000000 --- a/Lang/Dart/Repeat +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat/Dart \ No newline at end of file diff --git a/Lang/Dart/Rot-13 b/Lang/Dart/Rot-13 deleted file mode 120000 index 6136f05da5..0000000000 --- a/Lang/Dart/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/Dart \ No newline at end of file diff --git a/Lang/Dart/Solve-a-Numbrix-puzzle b/Lang/Dart/Solve-a-Numbrix-puzzle deleted file mode 120000 index 38339de00c..0000000000 --- a/Lang/Dart/Solve-a-Numbrix-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Numbrix-puzzle/Dart \ No newline at end of file diff --git a/Lang/Dart/Sorting-algorithms-Gnome-sort b/Lang/Dart/Sorting-algorithms-Gnome-sort deleted file mode 120000 index 0f0280ed89..0000000000 --- a/Lang/Dart/Sorting-algorithms-Gnome-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Gnome-sort/Dart \ No newline at end of file diff --git a/Lang/Dart/Split-a-character-string-based-on-change-of-character b/Lang/Dart/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index 06c92b1b7c..0000000000 --- a/Lang/Dart/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/Dart \ No newline at end of file diff --git a/Lang/Dart/Strassens-algorithm b/Lang/Dart/Strassens-algorithm deleted file mode 120000 index db4cbbbc5d..0000000000 --- a/Lang/Dart/Strassens-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strassens-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/String-append b/Lang/Dart/String-append deleted file mode 120000 index c2bbf5b38e..0000000000 --- a/Lang/Dart/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/Dart \ No newline at end of file diff --git a/Lang/Dart/Tau-function b/Lang/Dart/Tau-function deleted file mode 120000 index b1181f3147..0000000000 --- a/Lang/Dart/Tau-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-function/Dart \ No newline at end of file diff --git a/Lang/Dart/Tau-number b/Lang/Dart/Tau-number deleted file mode 120000 index 16f7c51341..0000000000 --- a/Lang/Dart/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/Dart \ No newline at end of file diff --git a/Lang/Dart/Temperature-conversion b/Lang/Dart/Temperature-conversion deleted file mode 120000 index 52e8aaa5fb..0000000000 --- a/Lang/Dart/Temperature-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Temperature-conversion/Dart \ No newline at end of file diff --git a/Lang/Dart/The-Name-Game b/Lang/Dart/The-Name-Game deleted file mode 120000 index 41a16ad1a3..0000000000 --- a/Lang/Dart/The-Name-Game +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-Name-Game/Dart \ No newline at end of file diff --git a/Lang/Dart/Tonelli-Shanks-algorithm b/Lang/Dart/Tonelli-Shanks-algorithm deleted file mode 120000 index 72acd046bd..0000000000 --- a/Lang/Dart/Tonelli-Shanks-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tonelli-Shanks-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Topological-sort b/Lang/Dart/Topological-sort deleted file mode 120000 index 7361beca1d..0000000000 --- a/Lang/Dart/Topological-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Topological-sort/Dart \ No newline at end of file diff --git a/Lang/Dart/Validate-International-Securities-Identification-Number b/Lang/Dart/Validate-International-Securities-Identification-Number deleted file mode 120000 index 72bbf1cc0f..0000000000 --- a/Lang/Dart/Validate-International-Securities-Identification-Number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Validate-International-Securities-Identification-Number/Dart \ No newline at end of file diff --git a/Lang/Dart/Word-search b/Lang/Dart/Word-search deleted file mode 120000 index c9693c2a8f..0000000000 --- a/Lang/Dart/Word-search +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-search/Dart \ No newline at end of file diff --git a/Lang/Dart/Yin-and-yang b/Lang/Dart/Yin-and-yang deleted file mode 120000 index 2e5b73348b..0000000000 --- a/Lang/Dart/Yin-and-yang +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yin-and-yang/Dart \ No newline at end of file diff --git a/Lang/Dart/Zeckendorf-arithmetic b/Lang/Dart/Zeckendorf-arithmetic deleted file mode 120000 index bfaf3b6837..0000000000 --- a/Lang/Dart/Zeckendorf-arithmetic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-arithmetic/Dart \ No newline at end of file diff --git a/Lang/Dart/Zeckendorf-number-representation b/Lang/Dart/Zeckendorf-number-representation deleted file mode 120000 index eb4adc0005..0000000000 --- a/Lang/Dart/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/Dart \ No newline at end of file diff --git a/Lang/Dc/Arithmetic-geometric-mean b/Lang/Dc/Arithmetic-geometric-mean deleted file mode 120000 index a4f9246885..0000000000 --- a/Lang/Dc/Arithmetic-geometric-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean/Dc \ No newline at end of file diff --git a/Lang/Dc/Comma-quibbling b/Lang/Dc/Comma-quibbling deleted file mode 120000 index 179958b910..0000000000 --- a/Lang/Dc/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/Dc \ No newline at end of file diff --git a/Lang/Dc/Continued-fraction b/Lang/Dc/Continued-fraction deleted file mode 120000 index d81af848ce..0000000000 --- a/Lang/Dc/Continued-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Continued-fraction/Dc \ No newline at end of file diff --git a/Lang/Dc/Increment-a-numerical-string b/Lang/Dc/Increment-a-numerical-string deleted file mode 120000 index 946a96ac1a..0000000000 --- a/Lang/Dc/Increment-a-numerical-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increment-a-numerical-string/Dc \ No newline at end of file diff --git a/Lang/Dc/Man-or-boy-test b/Lang/Dc/Man-or-boy-test deleted file mode 120000 index 3b3beb62b4..0000000000 --- a/Lang/Dc/Man-or-boy-test +++ /dev/null @@ -1 +0,0 @@ -../../Task/Man-or-boy-test/Dc \ No newline at end of file diff --git a/Lang/Dc/Sieve-of-Eratosthenes b/Lang/Dc/Sieve-of-Eratosthenes deleted file mode 120000 index ac1e159057..0000000000 --- a/Lang/Dc/Sieve-of-Eratosthenes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Eratosthenes/Dc \ No newline at end of file diff --git a/Lang/Dc/Terminal-control-Ringing-the-terminal-bell b/Lang/Dc/Terminal-control-Ringing-the-terminal-bell deleted file mode 120000 index 0790097004..0000000000 --- a/Lang/Dc/Terminal-control-Ringing-the-terminal-bell +++ /dev/null @@ -1 +0,0 @@ -../../Task/Terminal-control-Ringing-the-terminal-bell/Dc \ No newline at end of file diff --git a/Lang/Delphi/Bioinformatics-base-count b/Lang/Delphi/Bioinformatics-base-count new file mode 120000 index 0000000000..8964650820 --- /dev/null +++ b/Lang/Delphi/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Generate-Chess960-starting-position b/Lang/Delphi/Generate-Chess960-starting-position deleted file mode 120000 index 2c3a66190d..0000000000 --- a/Lang/Delphi/Generate-Chess960-starting-position +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-Chess960-starting-position/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Meissel-Mertens-constant b/Lang/Delphi/Meissel-Mertens-constant new file mode 120000 index 0000000000..2b1c7d3804 --- /dev/null +++ b/Lang/Delphi/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Quaternion-type b/Lang/Delphi/Quaternion-type new file mode 120000 index 0000000000..fe804d3654 --- /dev/null +++ b/Lang/Delphi/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Sorting-Algorithms-Circle-Sort b/Lang/Delphi/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..d4a4f938c0 --- /dev/null +++ b/Lang/Delphi/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/Delphi \ No newline at end of file diff --git a/Lang/Draco/Align-columns b/Lang/Draco/Align-columns deleted file mode 120000 index 00c426b153..0000000000 --- a/Lang/Draco/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/Draco \ No newline at end of file diff --git a/Lang/Draco/Anti-primes b/Lang/Draco/Anti-primes deleted file mode 120000 index e9ba464537..0000000000 --- a/Lang/Draco/Anti-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anti-primes/Draco \ No newline at end of file diff --git a/Lang/Draco/Arithmetic-derivative b/Lang/Draco/Arithmetic-derivative deleted file mode 120000 index b83ffadf85..0000000000 --- a/Lang/Draco/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/Draco \ No newline at end of file diff --git a/Lang/Draco/Arithmetic-numbers b/Lang/Draco/Arithmetic-numbers deleted file mode 120000 index f4a20d710c..0000000000 --- a/Lang/Draco/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/Draco \ No newline at end of file diff --git a/Lang/Draco/Binary-digits b/Lang/Draco/Binary-digits deleted file mode 120000 index a5389aa8f6..0000000000 --- a/Lang/Draco/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/Draco \ No newline at end of file diff --git a/Lang/Draco/Case-sensitivity-of-identifiers b/Lang/Draco/Case-sensitivity-of-identifiers deleted file mode 120000 index a2d3247bb9..0000000000 --- a/Lang/Draco/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/Draco \ No newline at end of file diff --git a/Lang/Draco/Compound-data-type b/Lang/Draco/Compound-data-type deleted file mode 120000 index 4fcd536f99..0000000000 --- a/Lang/Draco/Compound-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compound-data-type/Draco \ No newline at end of file diff --git a/Lang/Draco/Count-the-coins b/Lang/Draco/Count-the-coins deleted file mode 120000 index f1018ebb94..0000000000 --- a/Lang/Draco/Count-the-coins +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-the-coins/Draco \ No newline at end of file diff --git a/Lang/Draco/Cullen-and-Woodall-numbers b/Lang/Draco/Cullen-and-Woodall-numbers deleted file mode 120000 index 4559430dd4..0000000000 --- a/Lang/Draco/Cullen-and-Woodall-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cullen-and-Woodall-numbers/Draco \ No newline at end of file diff --git a/Lang/Draco/Display-a-linear-combination b/Lang/Draco/Display-a-linear-combination deleted file mode 120000 index bbaeb41c31..0000000000 --- a/Lang/Draco/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/Draco \ No newline at end of file diff --git a/Lang/Draco/Doomsday-rule b/Lang/Draco/Doomsday-rule deleted file mode 120000 index 50f248643e..0000000000 --- a/Lang/Draco/Doomsday-rule +++ /dev/null @@ -1 +0,0 @@ -../../Task/Doomsday-rule/Draco \ No newline at end of file diff --git a/Lang/Draco/Duffinian-numbers b/Lang/Draco/Duffinian-numbers deleted file mode 120000 index ffc5f5f29b..0000000000 --- a/Lang/Draco/Duffinian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Duffinian-numbers/Draco \ No newline at end of file diff --git a/Lang/Draco/Floyds-triangle b/Lang/Draco/Floyds-triangle deleted file mode 120000 index c58a68cb7d..0000000000 --- a/Lang/Draco/Floyds-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyds-triangle/Draco \ No newline at end of file diff --git a/Lang/Draco/Horners-rule-for-polynomial-evaluation b/Lang/Draco/Horners-rule-for-polynomial-evaluation deleted file mode 120000 index 3be037b7e6..0000000000 --- a/Lang/Draco/Horners-rule-for-polynomial-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horners-rule-for-polynomial-evaluation/Draco \ No newline at end of file diff --git a/Lang/Draco/Long-year b/Lang/Draco/Long-year deleted file mode 120000 index 33c1756d36..0000000000 --- a/Lang/Draco/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/Draco \ No newline at end of file diff --git a/Lang/Draco/Magnanimous-numbers b/Lang/Draco/Magnanimous-numbers deleted file mode 120000 index 8cea312423..0000000000 --- a/Lang/Draco/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/Draco \ No newline at end of file diff --git a/Lang/Draco/Munchausen-numbers b/Lang/Draco/Munchausen-numbers deleted file mode 120000 index 52967d68c1..0000000000 --- a/Lang/Draco/Munchausen-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munchausen-numbers/Draco \ No newline at end of file diff --git a/Lang/Draco/Narcissistic-decimal-number b/Lang/Draco/Narcissistic-decimal-number deleted file mode 120000 index e893d928d6..0000000000 --- a/Lang/Draco/Narcissistic-decimal-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Narcissistic-decimal-number/Draco \ No newline at end of file diff --git a/Lang/Draco/Roman-numerals-Encode b/Lang/Draco/Roman-numerals-Encode deleted file mode 120000 index 11eed87fb8..0000000000 --- a/Lang/Draco/Roman-numerals-Encode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Roman-numerals-Encode/Draco \ No newline at end of file diff --git a/Lang/Draco/Set-consolidation b/Lang/Draco/Set-consolidation deleted file mode 120000 index 152dd9a3bb..0000000000 --- a/Lang/Draco/Set-consolidation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-consolidation/Draco \ No newline at end of file diff --git a/Lang/Draco/Tokenize-a-string b/Lang/Draco/Tokenize-a-string deleted file mode 120000 index b60ddd21df..0000000000 --- a/Lang/Draco/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/Draco \ No newline at end of file diff --git a/Lang/Draco/Totient-function b/Lang/Draco/Totient-function deleted file mode 120000 index 25a06f1db3..0000000000 --- a/Lang/Draco/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/Draco \ No newline at end of file diff --git a/Lang/Draco/Yin-and-yang b/Lang/Draco/Yin-and-yang deleted file mode 120000 index 77445e0f51..0000000000 --- a/Lang/Draco/Yin-and-yang +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yin-and-yang/Draco \ No newline at end of file diff --git a/Lang/Draco/Zeckendorf-number-representation b/Lang/Draco/Zeckendorf-number-representation deleted file mode 120000 index 5142294607..0000000000 --- a/Lang/Draco/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/Draco \ No newline at end of file diff --git a/Lang/Dragonstone/00-LANG.txt b/Lang/Dragonstone/00-LANG.txt deleted file mode 100644 index 910f7b9a21..0000000000 --- a/Lang/Dragonstone/00-LANG.txt +++ /dev/null @@ -1,9 +0,0 @@ -{{language -|exec=both -|gc=optional -|parampass=both -|express=both -|strength=strong -|checking=both -|site=http://dragonstone-lang.org}} -'''Dragonstone''' is a general purpose, high-level, object-oriented programming language. It is both an interpreted and compiled language, it's inspired by Ruby and Crystal but designed for programmer happiness, productivity, and choice. \ No newline at end of file diff --git a/Lang/Dragonstone/00-META.yaml b/Lang/Dragonstone/00-META.yaml deleted file mode 100644 index 33832d2528..0000000000 --- a/Lang/Dragonstone/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Dragonstone diff --git a/Lang/Dragonstone/Comments b/Lang/Dragonstone/Comments deleted file mode 120000 index 49a5841988..0000000000 --- a/Lang/Dragonstone/Comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comments/Dragonstone \ No newline at end of file diff --git a/Lang/Dragonstone/Hello-world-Newline-omission b/Lang/Dragonstone/Hello-world-Newline-omission deleted file mode 120000 index a67c99cc88..0000000000 --- a/Lang/Dragonstone/Hello-world-Newline-omission +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newline-omission/Dragonstone \ No newline at end of file diff --git a/Lang/Dragonstone/Hello-world-Text b/Lang/Dragonstone/Hello-world-Text deleted file mode 120000 index 7f601f87ad..0000000000 --- a/Lang/Dragonstone/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Dragonstone \ No newline at end of file diff --git a/Lang/Dragonstone/Loops-While b/Lang/Dragonstone/Loops-While deleted file mode 120000 index c8a2239e27..0000000000 --- a/Lang/Dragonstone/Loops-While +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-While/Dragonstone \ No newline at end of file diff --git a/Lang/DreamBerd/00-LANG.txt b/Lang/DreamBerd/00-LANG.txt deleted file mode 100644 index 55321be995..0000000000 --- a/Lang/DreamBerd/00-LANG.txt +++ /dev/null @@ -1,10 +0,0 @@ -DreamBerd is a perfect esoteric programming language. Some of its features include: -*Array indexes starting at -1 -*No loops -*"Maybe" boolean value -*Many kinds of equality checks -*Type annotations -*"previous/next/current" keywords (for seeing the past/future/present of a variable) -*Signals - -{{language|DreamBerd|exec=interpreted|site=https://github.com/TodePond/DreamBerd|gc=yes}} \ No newline at end of file diff --git a/Lang/DreamBerd/00-META.yaml b/Lang/DreamBerd/00-META.yaml deleted file mode 100644 index 0e5cef5b8d..0000000000 --- a/Lang/DreamBerd/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:DreamBerd diff --git a/Lang/DreamBerd/Hello-world-Text b/Lang/DreamBerd/Hello-world-Text deleted file mode 120000 index d474da8442..0000000000 --- a/Lang/DreamBerd/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/DreamBerd \ No newline at end of file diff --git a/Lang/Dt/00-LANG.txt b/Lang/Dt/00-LANG.txt deleted file mode 100644 index 334761ebe6..0000000000 --- a/Lang/Dt/00-LANG.txt +++ /dev/null @@ -1,5 +0,0 @@ -{{stub}} -{{language|dt|site=https://dt.plumbing/|tags=dt}} -{{Language programming paradigm|Concatenative}} - -"dt is duct tape for your Unix pipes. A programming language for doing small stuff fast, easy, and readable." \ No newline at end of file diff --git a/Lang/Dt/00-META.yaml b/Lang/Dt/00-META.yaml deleted file mode 100644 index 9d58ae2101..0000000000 --- a/Lang/Dt/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Dt diff --git a/Lang/Dt/Array-length b/Lang/Dt/Array-length deleted file mode 120000 index 8bf9a963d9..0000000000 --- a/Lang/Dt/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/Dt \ No newline at end of file diff --git a/Lang/Dt/Binary-digits b/Lang/Dt/Binary-digits deleted file mode 120000 index 8249525c7c..0000000000 --- a/Lang/Dt/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/Dt \ No newline at end of file diff --git a/Lang/Dt/Greatest-common-divisor b/Lang/Dt/Greatest-common-divisor deleted file mode 120000 index 4c746aac43..0000000000 --- a/Lang/Dt/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/Dt \ No newline at end of file diff --git a/Lang/Dt/Hello-world-Newline-omission b/Lang/Dt/Hello-world-Newline-omission deleted file mode 120000 index 3620ed3017..0000000000 --- a/Lang/Dt/Hello-world-Newline-omission +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Newline-omission/Dt \ No newline at end of file diff --git a/Lang/Dt/Hello-world-Standard-error b/Lang/Dt/Hello-world-Standard-error deleted file mode 120000 index 697f7d4651..0000000000 --- a/Lang/Dt/Hello-world-Standard-error +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Standard-error/Dt \ No newline at end of file diff --git a/Lang/Dt/Hello-world-Text b/Lang/Dt/Hello-world-Text deleted file mode 120000 index afdb9e5013..0000000000 --- a/Lang/Dt/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Dt \ No newline at end of file diff --git a/Lang/Dt/Increment-a-numerical-string b/Lang/Dt/Increment-a-numerical-string deleted file mode 120000 index 975bccc02f..0000000000 --- a/Lang/Dt/Increment-a-numerical-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increment-a-numerical-string/Dt \ No newline at end of file diff --git a/Lang/Dt/Phrase-reversals b/Lang/Dt/Phrase-reversals deleted file mode 120000 index 4f2999eeab..0000000000 --- a/Lang/Dt/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/Dt \ No newline at end of file diff --git a/Lang/Dt/Program-termination b/Lang/Dt/Program-termination deleted file mode 120000 index 2132c13c46..0000000000 --- a/Lang/Dt/Program-termination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-termination/Dt \ No newline at end of file diff --git a/Lang/Dt/Reverse-a-string b/Lang/Dt/Reverse-a-string deleted file mode 120000 index 305497c558..0000000000 --- a/Lang/Dt/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Dt \ No newline at end of file diff --git a/Lang/Dt/Tokenize-a-string b/Lang/Dt/Tokenize-a-string deleted file mode 120000 index c12dc3ceea..0000000000 --- a/Lang/Dt/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/Dt \ No newline at end of file diff --git a/Lang/DuckDB/00-LANG.txt b/Lang/DuckDB/00-LANG.txt deleted file mode 100644 index 2609130966..0000000000 --- a/Lang/DuckDB/00-LANG.txt +++ /dev/null @@ -1,4 +0,0 @@ -[[DuckDB]] is an open-source, fast in-process analytical database management system based on a feature-rich SQL dialect complemented with deep integrations into client APIs. - -[[Category:Programming Languages]] -[[Category:SQL]] \ No newline at end of file diff --git a/Lang/DuckDB/00-META.yaml b/Lang/DuckDB/00-META.yaml deleted file mode 100644 index c9eafe7cf5..0000000000 --- a/Lang/DuckDB/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:DuckDB diff --git a/Lang/DuckDB/100-doors b/Lang/DuckDB/100-doors deleted file mode 120000 index a0ee1f337e..0000000000 --- a/Lang/DuckDB/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/99-bottles-of-beer b/Lang/DuckDB/99-bottles-of-beer deleted file mode 120000 index c5f15cd273..0000000000 --- a/Lang/DuckDB/99-bottles-of-beer +++ /dev/null @@ -1 +0,0 @@ -../../Task/99-bottles-of-beer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/A+B b/Lang/DuckDB/A+B deleted file mode 120000 index ae6220876f..0000000000 --- a/Lang/DuckDB/A+B +++ /dev/null @@ -1 +0,0 @@ -../../Task/A+B/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/ABC-problem b/Lang/DuckDB/ABC-problem deleted file mode 120000 index 36e60dd0cd..0000000000 --- a/Lang/DuckDB/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Anagrams b/Lang/DuckDB/Anagrams deleted file mode 120000 index e80c01b2e3..0000000000 --- a/Lang/DuckDB/Anagrams +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anagrams/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Anonymous-recursion b/Lang/DuckDB/Anonymous-recursion deleted file mode 120000 index e4448d2542..0000000000 --- a/Lang/DuckDB/Anonymous-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anonymous-recursion/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-Complex b/Lang/DuckDB/Arithmetic-Complex deleted file mode 120000 index 7e149e59dc..0000000000 --- a/Lang/DuckDB/Arithmetic-Complex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Complex/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-Integer b/Lang/DuckDB/Arithmetic-Integer deleted file mode 120000 index 5bc3696b71..0000000000 --- a/Lang/DuckDB/Arithmetic-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-geometric-mean b/Lang/DuckDB/Arithmetic-geometric-mean deleted file mode 120000 index 2519d0a8f8..0000000000 --- a/Lang/DuckDB/Arithmetic-geometric-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-numbers b/Lang/DuckDB/Arithmetic-numbers deleted file mode 120000 index a5e7e075b9..0000000000 --- a/Lang/DuckDB/Arithmetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Array-concatenation b/Lang/DuckDB/Array-concatenation deleted file mode 120000 index 7ef5be0b5a..0000000000 --- a/Lang/DuckDB/Array-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-concatenation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Array-length b/Lang/DuckDB/Array-length deleted file mode 120000 index ebd59786ea..0000000000 --- a/Lang/DuckDB/Array-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Array-length/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arrays b/Lang/DuckDB/Arrays deleted file mode 120000 index 85190ece0f..0000000000 --- a/Lang/DuckDB/Arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arrays/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Associative-array-Creation b/Lang/DuckDB/Associative-array-Creation deleted file mode 120000 index ea2505f34f..0000000000 --- a/Lang/DuckDB/Associative-array-Creation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Creation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Associative-array-Iteration b/Lang/DuckDB/Associative-array-Iteration deleted file mode 120000 index c8269906e9..0000000000 --- a/Lang/DuckDB/Associative-array-Iteration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Iteration/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Associative-array-Merging b/Lang/DuckDB/Associative-array-Merging deleted file mode 120000 index 4e70d9ab01..0000000000 --- a/Lang/DuckDB/Associative-array-Merging +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Merging/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Arithmetic-mean b/Lang/DuckDB/Averages-Arithmetic-mean deleted file mode 120000 index 7ef12ec4b6..0000000000 --- a/Lang/DuckDB/Averages-Arithmetic-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Arithmetic-mean/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Mean-angle b/Lang/DuckDB/Averages-Mean-angle deleted file mode 120000 index 5b1aa18e5e..0000000000 --- a/Lang/DuckDB/Averages-Mean-angle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-angle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Mean-time-of-day b/Lang/DuckDB/Averages-Mean-time-of-day deleted file mode 120000 index 7971faf640..0000000000 --- a/Lang/DuckDB/Averages-Mean-time-of-day +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-time-of-day/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Mode b/Lang/DuckDB/Averages-Mode deleted file mode 120000 index 0ba388e74d..0000000000 --- a/Lang/DuckDB/Averages-Mode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mode/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Pythagorean-means b/Lang/DuckDB/Averages-Pythagorean-means deleted file mode 120000 index 1a5cb3068d..0000000000 --- a/Lang/DuckDB/Averages-Pythagorean-means +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Pythagorean-means/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Babbage-problem b/Lang/DuckDB/Babbage-problem deleted file mode 120000 index 7cee7b9a76..0000000000 --- a/Lang/DuckDB/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Benfords-law b/Lang/DuckDB/Benfords-law deleted file mode 120000 index 9302673cc0..0000000000 --- a/Lang/DuckDB/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bin-given-limits b/Lang/DuckDB/Bin-given-limits deleted file mode 120000 index ba754d6a93..0000000000 --- a/Lang/DuckDB/Bin-given-limits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bin-given-limits/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Binary-digits b/Lang/DuckDB/Binary-digits deleted file mode 120000 index c4e4b4a580..0000000000 --- a/Lang/DuckDB/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bitwise-IO b/Lang/DuckDB/Bitwise-IO deleted file mode 120000 index d00e607776..0000000000 --- a/Lang/DuckDB/Bitwise-IO +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitwise-IO/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bitwise-operations b/Lang/DuckDB/Bitwise-operations deleted file mode 120000 index a0841908e6..0000000000 --- a/Lang/DuckDB/Bitwise-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitwise-operations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/CSV-data-manipulation b/Lang/DuckDB/CSV-data-manipulation deleted file mode 120000 index 799ed97795..0000000000 --- a/Lang/DuckDB/CSV-data-manipulation +++ /dev/null @@ -1 +0,0 @@ -../../Task/CSV-data-manipulation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Call-a-function b/Lang/DuckDB/Call-a-function deleted file mode 120000 index bf87fb6ba8..0000000000 --- a/Lang/DuckDB/Call-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-a-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Cartesian-product-of-two-or-more-lists b/Lang/DuckDB/Cartesian-product-of-two-or-more-lists deleted file mode 120000 index f0873100b0..0000000000 --- a/Lang/DuckDB/Cartesian-product-of-two-or-more-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cartesian-product-of-two-or-more-lists/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Case-sensitivity-of-identifiers b/Lang/DuckDB/Case-sensitivity-of-identifiers deleted file mode 120000 index 2a0900e2e4..0000000000 --- a/Lang/DuckDB/Case-sensitivity-of-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Case-sensitivity-of-identifiers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Catalan-numbers b/Lang/DuckDB/Catalan-numbers deleted file mode 120000 index 5591f12e62..0000000000 --- a/Lang/DuckDB/Catalan-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Catalan-numbers-Pascals-triangle b/Lang/DuckDB/Catalan-numbers-Pascals-triangle deleted file mode 120000 index 690dec4614..0000000000 --- a/Lang/DuckDB/Catalan-numbers-Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers-Pascals-triangle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Check-that-file-exists b/Lang/DuckDB/Check-that-file-exists deleted file mode 120000 index 7a35121080..0000000000 --- a/Lang/DuckDB/Check-that-file-exists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-that-file-exists/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Collections b/Lang/DuckDB/Collections deleted file mode 120000 index 4bd2b4f60a..0000000000 --- a/Lang/DuckDB/Collections +++ /dev/null @@ -1 +0,0 @@ -../../Task/Collections/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Combinations b/Lang/DuckDB/Combinations deleted file mode 120000 index 61cb39c1bb..0000000000 --- a/Lang/DuckDB/Combinations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Combinations-with-repetitions b/Lang/DuckDB/Combinations-with-repetitions deleted file mode 120000 index 3781b1dd53..0000000000 --- a/Lang/DuckDB/Combinations-with-repetitions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations-with-repetitions/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Compare-a-list-of-strings b/Lang/DuckDB/Compare-a-list-of-strings deleted file mode 120000 index dcf4a9dc8d..0000000000 --- a/Lang/DuckDB/Compare-a-list-of-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-a-list-of-strings/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Compare-length-of-two-strings b/Lang/DuckDB/Compare-length-of-two-strings deleted file mode 120000 index b29bfdb369..0000000000 --- a/Lang/DuckDB/Compare-length-of-two-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-length-of-two-strings/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Compound-data-type b/Lang/DuckDB/Compound-data-type deleted file mode 120000 index dc469b307b..0000000000 --- a/Lang/DuckDB/Compound-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compound-data-type/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Conditional-structures b/Lang/DuckDB/Conditional-structures deleted file mode 120000 index 19bf4a5caa..0000000000 --- a/Lang/DuckDB/Conditional-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conditional-structures/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Convert-seconds-to-compound-duration b/Lang/DuckDB/Convert-seconds-to-compound-duration deleted file mode 120000 index 44055a0c42..0000000000 --- a/Lang/DuckDB/Convert-seconds-to-compound-duration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Convert-seconds-to-compound-duration/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Copy-a-string b/Lang/DuckDB/Copy-a-string deleted file mode 120000 index d5f908f98d..0000000000 --- a/Lang/DuckDB/Copy-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Copy-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Count-occurrences-of-a-substring b/Lang/DuckDB/Count-occurrences-of-a-substring deleted file mode 120000 index 82775de6e5..0000000000 --- a/Lang/DuckDB/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Create-a-two-dimensional-array-at-runtime b/Lang/DuckDB/Create-a-two-dimensional-array-at-runtime deleted file mode 120000 index 14657f9c21..0000000000 --- a/Lang/DuckDB/Create-a-two-dimensional-array-at-runtime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-a-two-dimensional-array-at-runtime/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Cumulative-standard-deviation b/Lang/DuckDB/Cumulative-standard-deviation deleted file mode 120000 index f323d6c56e..0000000000 --- a/Lang/DuckDB/Cumulative-standard-deviation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cumulative-standard-deviation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Currency b/Lang/DuckDB/Currency deleted file mode 120000 index 092e5fcb13..0000000000 --- a/Lang/DuckDB/Currency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currency/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Day-of-the-week b/Lang/DuckDB/Day-of-the-week deleted file mode 120000 index 467c28db17..0000000000 --- a/Lang/DuckDB/Day-of-the-week +++ /dev/null @@ -1 +0,0 @@ -../../Task/Day-of-the-week/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Define-a-primitive-data-type b/Lang/DuckDB/Define-a-primitive-data-type deleted file mode 120000 index f086397ed2..0000000000 --- a/Lang/DuckDB/Define-a-primitive-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Define-a-primitive-data-type/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Detect-division-by-zero b/Lang/DuckDB/Detect-division-by-zero deleted file mode 120000 index 92508ad1dd..0000000000 --- a/Lang/DuckDB/Detect-division-by-zero +++ /dev/null @@ -1 +0,0 @@ -../../Task/Detect-division-by-zero/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determinant-and-permanent b/Lang/DuckDB/Determinant-and-permanent deleted file mode 120000 index 6bccec7e87..0000000000 --- a/Lang/DuckDB/Determinant-and-permanent +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determinant-and-permanent/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters b/Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters deleted file mode 120000 index 3a9bd20a7a..0000000000 --- a/Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-the-same-characters/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-has-all-unique-characters b/Lang/DuckDB/Determine-if-a-string-has-all-unique-characters deleted file mode 120000 index 64885aacf1..0000000000 --- a/Lang/DuckDB/Determine-if-a-string-has-all-unique-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-unique-characters/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-is-collapsible b/Lang/DuckDB/Determine-if-a-string-is-collapsible deleted file mode 120000 index 0bb2727b9c..0000000000 --- a/Lang/DuckDB/Determine-if-a-string-is-collapsible +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-collapsible/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-is-numeric b/Lang/DuckDB/Determine-if-a-string-is-numeric deleted file mode 120000 index ead16cd478..0000000000 --- a/Lang/DuckDB/Determine-if-a-string-is-numeric +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-numeric/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-is-squeezable b/Lang/DuckDB/Determine-if-a-string-is-squeezable deleted file mode 120000 index 57414557b7..0000000000 --- a/Lang/DuckDB/Determine-if-a-string-is-squeezable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-squeezable/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-sentence-type b/Lang/DuckDB/Determine-sentence-type deleted file mode 120000 index 50fb0aaf1b..0000000000 --- a/Lang/DuckDB/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Digital-root b/Lang/DuckDB/Digital-root deleted file mode 120000 index 736b8ccc4f..0000000000 --- a/Lang/DuckDB/Digital-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Digital-root/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Diversity-prediction-theorem b/Lang/DuckDB/Diversity-prediction-theorem deleted file mode 120000 index 2c04d6784a..0000000000 --- a/Lang/DuckDB/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Documentation b/Lang/DuckDB/Documentation deleted file mode 120000 index f9f6aaf2ce..0000000000 --- a/Lang/DuckDB/Documentation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Documentation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Dot-product b/Lang/DuckDB/Dot-product deleted file mode 120000 index b17f0214ea..0000000000 --- a/Lang/DuckDB/Dot-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dot-product/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Dynamic-variable-names b/Lang/DuckDB/Dynamic-variable-names deleted file mode 120000 index c534bbc61d..0000000000 --- a/Lang/DuckDB/Dynamic-variable-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dynamic-variable-names/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Element-wise-operations b/Lang/DuckDB/Element-wise-operations deleted file mode 120000 index 7d7754f7f7..0000000000 --- a/Lang/DuckDB/Element-wise-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Element-wise-operations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Empty-string b/Lang/DuckDB/Empty-string deleted file mode 120000 index 67b471da95..0000000000 --- a/Lang/DuckDB/Empty-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Entropy b/Lang/DuckDB/Entropy deleted file mode 120000 index 9c2bc0a9a7..0000000000 --- a/Lang/DuckDB/Entropy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Enumerations b/Lang/DuckDB/Enumerations deleted file mode 120000 index 0605dce25b..0000000000 --- a/Lang/DuckDB/Enumerations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Enumerations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Equilibrium-index b/Lang/DuckDB/Equilibrium-index deleted file mode 120000 index 40fbbe81bb..0000000000 --- a/Lang/DuckDB/Equilibrium-index +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equilibrium-index/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Euler-method b/Lang/DuckDB/Euler-method deleted file mode 120000 index 61aa9557d0..0000000000 --- a/Lang/DuckDB/Euler-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euler-method/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Eulers-constant-0.5772... b/Lang/DuckDB/Eulers-constant-0.5772... deleted file mode 120000 index c954937ec2..0000000000 --- a/Lang/DuckDB/Eulers-constant-0.5772... +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-constant-0.5772.../DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Eulers-identity b/Lang/DuckDB/Eulers-identity deleted file mode 120000 index 58919d8390..0000000000 --- a/Lang/DuckDB/Eulers-identity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-identity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Evaluate-binomial-coefficients b/Lang/DuckDB/Evaluate-binomial-coefficients deleted file mode 120000 index 69d838bb98..0000000000 --- a/Lang/DuckDB/Evaluate-binomial-coefficients +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evaluate-binomial-coefficients/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Even-or-odd b/Lang/DuckDB/Even-or-odd deleted file mode 120000 index e428a57303..0000000000 --- a/Lang/DuckDB/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Exponentiation-order b/Lang/DuckDB/Exponentiation-order deleted file mode 120000 index 56438a22ee..0000000000 --- a/Lang/DuckDB/Exponentiation-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-order/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Extreme-floating-point-values b/Lang/DuckDB/Extreme-floating-point-values deleted file mode 120000 index 617a7e99de..0000000000 --- a/Lang/DuckDB/Extreme-floating-point-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Extreme-floating-point-values/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Factorial b/Lang/DuckDB/Factorial deleted file mode 120000 index 24543aba0b..0000000000 --- a/Lang/DuckDB/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Factors-of-an-integer b/Lang/DuckDB/Factors-of-an-integer deleted file mode 120000 index 70e5ed8d56..0000000000 --- a/Lang/DuckDB/Factors-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factors-of-an-integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Fairshare-between-two-and-more b/Lang/DuckDB/Fairshare-between-two-and-more deleted file mode 120000 index 0c62807925..0000000000 --- a/Lang/DuckDB/Fairshare-between-two-and-more +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fairshare-between-two-and-more/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Feigenbaum-constant-calculation b/Lang/DuckDB/Feigenbaum-constant-calculation deleted file mode 120000 index 6f57f3044b..0000000000 --- a/Lang/DuckDB/Feigenbaum-constant-calculation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Feigenbaum-constant-calculation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Fibonacci-sequence b/Lang/DuckDB/Fibonacci-sequence deleted file mode 120000 index 0411dbf9f3..0000000000 --- a/Lang/DuckDB/Fibonacci-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-sequence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/File-input-output b/Lang/DuckDB/File-input-output deleted file mode 120000 index 0bb640b9cd..0000000000 --- a/Lang/DuckDB/File-input-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-input-output/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Filter b/Lang/DuckDB/Filter deleted file mode 120000 index bec860336f..0000000000 --- a/Lang/DuckDB/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Find-limit-of-recursion b/Lang/DuckDB/Find-limit-of-recursion deleted file mode 120000 index e7eff55309..0000000000 --- a/Lang/DuckDB/Find-limit-of-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-limit-of-recursion/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Find-the-last-Sunday-of-each-month b/Lang/DuckDB/Find-the-last-Sunday-of-each-month deleted file mode 120000 index 39172062a9..0000000000 --- a/Lang/DuckDB/Find-the-last-Sunday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-last-Sunday-of-each-month/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Five-weekends b/Lang/DuckDB/Five-weekends deleted file mode 120000 index 4d8ed3ebe3..0000000000 --- a/Lang/DuckDB/Five-weekends +++ /dev/null @@ -1 +0,0 @@ -../../Task/Five-weekends/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Fixed-length-records b/Lang/DuckDB/Fixed-length-records deleted file mode 120000 index 0b8d72de87..0000000000 --- a/Lang/DuckDB/Fixed-length-records +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fixed-length-records/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Flatten-a-list b/Lang/DuckDB/Flatten-a-list deleted file mode 120000 index 5bd1c5b0d8..0000000000 --- a/Lang/DuckDB/Flatten-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Flatten-a-list/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Formatted-numeric-output b/Lang/DuckDB/Formatted-numeric-output deleted file mode 120000 index 789e647161..0000000000 --- a/Lang/DuckDB/Formatted-numeric-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/Formatted-numeric-output/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Forward-difference b/Lang/DuckDB/Forward-difference deleted file mode 120000 index 6a0d935f36..0000000000 --- a/Lang/DuckDB/Forward-difference +++ /dev/null @@ -1 +0,0 @@ -../../Task/Forward-difference/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Function-definition b/Lang/DuckDB/Function-definition deleted file mode 120000 index b39d093883..0000000000 --- a/Lang/DuckDB/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Gamma-function b/Lang/DuckDB/Gamma-function deleted file mode 120000 index 6fcec68436..0000000000 --- a/Lang/DuckDB/Gamma-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gamma-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Gapful-numbers b/Lang/DuckDB/Gapful-numbers deleted file mode 120000 index 875c3e4310..0000000000 --- a/Lang/DuckDB/Gapful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gapful-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Generate-lower-case-ASCII-alphabet b/Lang/DuckDB/Generate-lower-case-ASCII-alphabet deleted file mode 120000 index 51094f97da..0000000000 --- a/Lang/DuckDB/Generate-lower-case-ASCII-alphabet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-lower-case-ASCII-alphabet/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Generic-swap b/Lang/DuckDB/Generic-swap deleted file mode 120000 index b384241f1f..0000000000 --- a/Lang/DuckDB/Generic-swap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generic-swap/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Golden-ratio-Convergence b/Lang/DuckDB/Golden-ratio-Convergence deleted file mode 120000 index 0ca8f2458f..0000000000 --- a/Lang/DuckDB/Golden-ratio-Convergence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Golden-ratio-Convergence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Gotchas b/Lang/DuckDB/Gotchas deleted file mode 120000 index 16cceb3ff0..0000000000 --- a/Lang/DuckDB/Gotchas +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gotchas/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Greatest-common-divisor b/Lang/DuckDB/Greatest-common-divisor deleted file mode 120000 index 6fb062c771..0000000000 --- a/Lang/DuckDB/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Greatest-element-of-a-list b/Lang/DuckDB/Greatest-element-of-a-list deleted file mode 120000 index 5a2c7a66c9..0000000000 --- a/Lang/DuckDB/Greatest-element-of-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-element-of-a-list/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Greatest-subsequential-sum b/Lang/DuckDB/Greatest-subsequential-sum deleted file mode 120000 index dd3661e978..0000000000 --- a/Lang/DuckDB/Greatest-subsequential-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-subsequential-sum/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/HTTP b/Lang/DuckDB/HTTP deleted file mode 120000 index f77a3116ff..0000000000 --- a/Lang/DuckDB/HTTP +++ /dev/null @@ -1 +0,0 @@ -../../Task/HTTP/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/HTTPS b/Lang/DuckDB/HTTPS deleted file mode 120000 index 694faecb0f..0000000000 --- a/Lang/DuckDB/HTTPS +++ /dev/null @@ -1 +0,0 @@ -../../Task/HTTPS/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/HTTPS-Authenticated b/Lang/DuckDB/HTTPS-Authenticated deleted file mode 120000 index c1b123b3b8..0000000000 --- a/Lang/DuckDB/HTTPS-Authenticated +++ /dev/null @@ -1 +0,0 @@ -../../Task/HTTPS-Authenticated/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hailstone-sequence b/Lang/DuckDB/Hailstone-sequence deleted file mode 120000 index 8cb9cd3c4d..0000000000 --- a/Lang/DuckDB/Hailstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hailstone-sequence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Harmonic-series b/Lang/DuckDB/Harmonic-series deleted file mode 120000 index d5b23dfe32..0000000000 --- a/Lang/DuckDB/Harmonic-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harmonic-series/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hash-from-two-arrays b/Lang/DuckDB/Hash-from-two-arrays deleted file mode 120000 index 4fd3efc241..0000000000 --- a/Lang/DuckDB/Hash-from-two-arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hash-from-two-arrays/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hash-join b/Lang/DuckDB/Hash-join deleted file mode 120000 index d89e18cc75..0000000000 --- a/Lang/DuckDB/Hash-join +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hash-join/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Haversine-formula b/Lang/DuckDB/Haversine-formula deleted file mode 120000 index 102a047e33..0000000000 --- a/Lang/DuckDB/Haversine-formula +++ /dev/null @@ -1 +0,0 @@ -../../Task/Haversine-formula/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hello-world-Text b/Lang/DuckDB/Hello-world-Text deleted file mode 120000 index 1af484f405..0000000000 --- a/Lang/DuckDB/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Here-document b/Lang/DuckDB/Here-document deleted file mode 120000 index f233028f5b..0000000000 --- a/Lang/DuckDB/Here-document +++ /dev/null @@ -1 +0,0 @@ -../../Task/Here-document/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/ISBN13-check-digit b/Lang/DuckDB/ISBN13-check-digit deleted file mode 120000 index ad247e79cf..0000000000 --- a/Lang/DuckDB/ISBN13-check-digit +++ /dev/null @@ -1 +0,0 @@ -../../Task/ISBN13-check-digit/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Identity-matrix b/Lang/DuckDB/Identity-matrix deleted file mode 120000 index d8402f7ae8..0000000000 --- a/Lang/DuckDB/Identity-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Identity-matrix/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols b/Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols deleted file mode 120000 index 90e880a4b1..0000000000 --- a/Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters b/Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters deleted file mode 120000 index 3722271469..0000000000 --- a/Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Increment-a-numerical-string b/Lang/DuckDB/Increment-a-numerical-string deleted file mode 120000 index a9f84c0e8c..0000000000 --- a/Lang/DuckDB/Increment-a-numerical-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increment-a-numerical-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Infinity b/Lang/DuckDB/Infinity deleted file mode 120000 index ed12f74690..0000000000 --- a/Lang/DuckDB/Infinity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Infinity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Integer-comparison b/Lang/DuckDB/Integer-comparison deleted file mode 120000 index c6cacfcd06..0000000000 --- a/Lang/DuckDB/Integer-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/Integer-comparison/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Introspection b/Lang/DuckDB/Introspection deleted file mode 120000 index c3bb6d896d..0000000000 --- a/Lang/DuckDB/Introspection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Introspection/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Inverted-index b/Lang/DuckDB/Inverted-index deleted file mode 120000 index 81053e0c15..0000000000 --- a/Lang/DuckDB/Inverted-index +++ /dev/null @@ -1 +0,0 @@ -../../Task/Inverted-index/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Inverted-syntax b/Lang/DuckDB/Inverted-syntax deleted file mode 120000 index cadc81e3b6..0000000000 --- a/Lang/DuckDB/Inverted-syntax +++ /dev/null @@ -1 +0,0 @@ -../../Task/Inverted-syntax/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/JSON b/Lang/DuckDB/JSON deleted file mode 120000 index e4757a4b09..0000000000 --- a/Lang/DuckDB/JSON +++ /dev/null @@ -1 +0,0 @@ -../../Task/JSON/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Jaro-similarity b/Lang/DuckDB/Jaro-similarity deleted file mode 120000 index 39c64b8488..0000000000 --- a/Lang/DuckDB/Jaro-similarity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jaro-similarity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Knuth-shuffle b/Lang/DuckDB/Knuth-shuffle deleted file mode 120000 index 7d43c57cbe..0000000000 --- a/Lang/DuckDB/Knuth-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knuth-shuffle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Largest-int-from-concatenated-ints b/Lang/DuckDB/Largest-int-from-concatenated-ints deleted file mode 120000 index 8e73a50292..0000000000 --- a/Lang/DuckDB/Largest-int-from-concatenated-ints +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-int-from-concatenated-ints/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Last-Friday-of-each-month b/Lang/DuckDB/Last-Friday-of-each-month deleted file mode 120000 index 1236ebdc14..0000000000 --- a/Lang/DuckDB/Last-Friday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Last-Friday-of-each-month/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Leap-year b/Lang/DuckDB/Leap-year deleted file mode 120000 index 5816394f02..0000000000 --- a/Lang/DuckDB/Leap-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leap-year/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Left-factorials b/Lang/DuckDB/Left-factorials deleted file mode 120000 index 6877bf1f73..0000000000 --- a/Lang/DuckDB/Left-factorials +++ /dev/null @@ -1 +0,0 @@ -../../Task/Left-factorials/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Leonardo-numbers b/Lang/DuckDB/Leonardo-numbers deleted file mode 120000 index 206ddcfce9..0000000000 --- a/Lang/DuckDB/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Letter-frequency b/Lang/DuckDB/Letter-frequency deleted file mode 120000 index 29228c3e0b..0000000000 --- a/Lang/DuckDB/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Levenshtein-distance b/Lang/DuckDB/Levenshtein-distance deleted file mode 120000 index d0954b60f2..0000000000 --- a/Lang/DuckDB/Levenshtein-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/List-comprehensions b/Lang/DuckDB/List-comprehensions deleted file mode 120000 index 72558c43a1..0000000000 --- a/Lang/DuckDB/List-comprehensions +++ /dev/null @@ -1 +0,0 @@ -../../Task/List-comprehensions/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Literals-Integer b/Lang/DuckDB/Literals-Integer deleted file mode 120000 index 39629959b4..0000000000 --- a/Lang/DuckDB/Literals-Integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Literals-Integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Logical-operations b/Lang/DuckDB/Logical-operations deleted file mode 120000 index 14d59b0f70..0000000000 --- a/Lang/DuckDB/Logical-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logical-operations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Longest-increasing-subsequence b/Lang/DuckDB/Longest-increasing-subsequence deleted file mode 120000 index 35a8443499..0000000000 --- a/Lang/DuckDB/Longest-increasing-subsequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-increasing-subsequence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Break b/Lang/DuckDB/Loops-Break deleted file mode 120000 index 40b7904e3f..0000000000 --- a/Lang/DuckDB/Loops-Break +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Break/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Do-while b/Lang/DuckDB/Loops-Do-while deleted file mode 120000 index 257f84d6ba..0000000000 --- a/Lang/DuckDB/Loops-Do-while +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Do-while/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Downward-for b/Lang/DuckDB/Loops-Downward-for deleted file mode 120000 index 5516907335..0000000000 --- a/Lang/DuckDB/Loops-Downward-for +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Downward-for/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-For b/Lang/DuckDB/Loops-For deleted file mode 120000 index 56dde9a604..0000000000 --- a/Lang/DuckDB/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-For-with-a-specified-step b/Lang/DuckDB/Loops-For-with-a-specified-step deleted file mode 120000 index f7e2b536d7..0000000000 --- a/Lang/DuckDB/Loops-For-with-a-specified-step +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For-with-a-specified-step/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Increment-loop-index-within-loop-body b/Lang/DuckDB/Loops-Increment-loop-index-within-loop-body deleted file mode 120000 index d530992462..0000000000 --- a/Lang/DuckDB/Loops-Increment-loop-index-within-loop-body +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Increment-loop-index-within-loop-body/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-N-plus-one-half b/Lang/DuckDB/Loops-N-plus-one-half deleted file mode 120000 index f9812bda7e..0000000000 --- a/Lang/DuckDB/Loops-N-plus-one-half +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-N-plus-one-half/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Nested b/Lang/DuckDB/Loops-Nested deleted file mode 120000 index 8b4afa46b5..0000000000 --- a/Lang/DuckDB/Loops-Nested +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Nested/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-While b/Lang/DuckDB/Loops-While deleted file mode 120000 index 60343480f3..0000000000 --- a/Lang/DuckDB/Loops-While +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-While/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-With-multiple-ranges b/Lang/DuckDB/Loops-With-multiple-ranges deleted file mode 120000 index 540b734a24..0000000000 --- a/Lang/DuckDB/Loops-With-multiple-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-With-multiple-ranges/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Luhn-test-of-credit-card-numbers b/Lang/DuckDB/Luhn-test-of-credit-card-numbers deleted file mode 120000 index 397557411e..0000000000 --- a/Lang/DuckDB/Luhn-test-of-credit-card-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Luhn-test-of-credit-card-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/MD5 b/Lang/DuckDB/MD5 deleted file mode 120000 index ab453e87da..0000000000 --- a/Lang/DuckDB/MD5 +++ /dev/null @@ -1 +0,0 @@ -../../Task/MD5/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Map-range b/Lang/DuckDB/Map-range deleted file mode 120000 index 6cd697a04b..0000000000 --- a/Lang/DuckDB/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Matrix-multiplication b/Lang/DuckDB/Matrix-multiplication deleted file mode 120000 index 2110896869..0000000000 --- a/Lang/DuckDB/Matrix-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-multiplication/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Matrix-transposition b/Lang/DuckDB/Matrix-transposition deleted file mode 120000 index 7e416217b2..0000000000 --- a/Lang/DuckDB/Matrix-transposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-transposition/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Merge-and-aggregate-datasets b/Lang/DuckDB/Merge-and-aggregate-datasets deleted file mode 120000 index e9d467735b..0000000000 --- a/Lang/DuckDB/Merge-and-aggregate-datasets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Merge-and-aggregate-datasets/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Metallic-ratios b/Lang/DuckDB/Metallic-ratios deleted file mode 120000 index 56fa981641..0000000000 --- a/Lang/DuckDB/Metallic-ratios +++ /dev/null @@ -1 +0,0 @@ -../../Task/Metallic-ratios/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Middle-three-digits b/Lang/DuckDB/Middle-three-digits deleted file mode 120000 index 9c32c60a1c..0000000000 --- a/Lang/DuckDB/Middle-three-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Middle-three-digits/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Monte-Carlo-methods b/Lang/DuckDB/Monte-Carlo-methods deleted file mode 120000 index f27be4f0e8..0000000000 --- a/Lang/DuckDB/Monte-Carlo-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monte-Carlo-methods/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Nested-function b/Lang/DuckDB/Nested-function deleted file mode 120000 index 6ccb0c0029..0000000000 --- a/Lang/DuckDB/Nested-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nested-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Nth b/Lang/DuckDB/Nth deleted file mode 120000 index 6d1fd0295b..0000000000 --- a/Lang/DuckDB/Nth +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Nth-root b/Lang/DuckDB/Nth-root deleted file mode 120000 index bdfee4887c..0000000000 --- a/Lang/DuckDB/Nth-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth-root/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/One-of-n-lines-in-a-file b/Lang/DuckDB/One-of-n-lines-in-a-file deleted file mode 120000 index 84adf8bb46..0000000000 --- a/Lang/DuckDB/One-of-n-lines-in-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/One-of-n-lines-in-a-file/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Order-two-numerical-lists b/Lang/DuckDB/Order-two-numerical-lists deleted file mode 120000 index fcd259b6c0..0000000000 --- a/Lang/DuckDB/Order-two-numerical-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Order-two-numerical-lists/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Ordered-words b/Lang/DuckDB/Ordered-words deleted file mode 120000 index 57d12d9c27..0000000000 --- a/Lang/DuckDB/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Palindrome-detection b/Lang/DuckDB/Palindrome-detection deleted file mode 120000 index a318cb02ae..0000000000 --- a/Lang/DuckDB/Palindrome-detection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-detection/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Parameterized-SQL-statement b/Lang/DuckDB/Parameterized-SQL-statement deleted file mode 120000 index dded36b01b..0000000000 --- a/Lang/DuckDB/Parameterized-SQL-statement +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parameterized-SQL-statement/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Pascals-triangle b/Lang/DuckDB/Pascals-triangle deleted file mode 120000 index e38a99fc2d..0000000000 --- a/Lang/DuckDB/Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pascals-triangle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Permutations b/Lang/DuckDB/Permutations deleted file mode 120000 index fa1198c6a6..0000000000 --- a/Lang/DuckDB/Permutations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Permutations-Derangements b/Lang/DuckDB/Permutations-Derangements deleted file mode 120000 index b4140ee27e..0000000000 --- a/Lang/DuckDB/Permutations-Derangements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-Derangements/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Pick-random-element b/Lang/DuckDB/Pick-random-element deleted file mode 120000 index 4eec54c36e..0000000000 --- a/Lang/DuckDB/Pick-random-element +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pick-random-element/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Primality-by-trial-division b/Lang/DuckDB/Primality-by-trial-division deleted file mode 120000 index 8e9e10eb1a..0000000000 --- a/Lang/DuckDB/Primality-by-trial-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-trial-division/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Prime-decomposition b/Lang/DuckDB/Prime-decomposition deleted file mode 120000 index dbb3b57727..0000000000 --- a/Lang/DuckDB/Prime-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-decomposition/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Probabilistic-choice b/Lang/DuckDB/Probabilistic-choice deleted file mode 120000 index caa9cf57ce..0000000000 --- a/Lang/DuckDB/Probabilistic-choice +++ /dev/null @@ -1 +0,0 @@ -../../Task/Probabilistic-choice/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Proper-divisors b/Lang/DuckDB/Proper-divisors deleted file mode 120000 index a8b8cf32ca..0000000000 --- a/Lang/DuckDB/Proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Proper-divisors/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Pseudo-random-numbers-Middle-square-method b/Lang/DuckDB/Pseudo-random-numbers-Middle-square-method deleted file mode 120000 index 3424580b60..0000000000 --- a/Lang/DuckDB/Pseudo-random-numbers-Middle-square-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Middle-square-method/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Random-numbers b/Lang/DuckDB/Random-numbers deleted file mode 120000 index 4e7ae21251..0000000000 --- a/Lang/DuckDB/Random-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Range-expansion b/Lang/DuckDB/Range-expansion deleted file mode 120000 index 73f7852f3e..0000000000 --- a/Lang/DuckDB/Range-expansion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-expansion/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Range-extraction b/Lang/DuckDB/Range-extraction deleted file mode 120000 index 70b9fee7f2..0000000000 --- a/Lang/DuckDB/Range-extraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-extraction/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Read-a-file-line-by-line b/Lang/DuckDB/Read-a-file-line-by-line deleted file mode 120000 index 5698cabe3f..0000000000 --- a/Lang/DuckDB/Read-a-file-line-by-line +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-file-line-by-line/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Reflection-List-methods b/Lang/DuckDB/Reflection-List-methods deleted file mode 120000 index e87f71ad29..0000000000 --- a/Lang/DuckDB/Reflection-List-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reflection-List-methods/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Reflection-List-properties b/Lang/DuckDB/Reflection-List-properties deleted file mode 120000 index 61160f5035..0000000000 --- a/Lang/DuckDB/Reflection-List-properties +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reflection-List-properties/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Remove-duplicate-elements b/Lang/DuckDB/Remove-duplicate-elements deleted file mode 120000 index e38927d88b..0000000000 --- a/Lang/DuckDB/Remove-duplicate-elements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Remove-duplicate-elements/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Rep-string b/Lang/DuckDB/Rep-string deleted file mode 120000 index ce2543465d..0000000000 --- a/Lang/DuckDB/Rep-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rep-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Repeat-a-string b/Lang/DuckDB/Repeat-a-string deleted file mode 120000 index 126fb8a5a7..0000000000 --- a/Lang/DuckDB/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Return-multiple-values b/Lang/DuckDB/Return-multiple-values deleted file mode 120000 index 44885d997f..0000000000 --- a/Lang/DuckDB/Return-multiple-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Return-multiple-values/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Reverse-a-string b/Lang/DuckDB/Reverse-a-string deleted file mode 120000 index 9c2fcefbbf..0000000000 --- a/Lang/DuckDB/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Roots-of-unity b/Lang/DuckDB/Roots-of-unity deleted file mode 120000 index fbae972a1d..0000000000 --- a/Lang/DuckDB/Roots-of-unity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Roots-of-unity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Run-length-encoding b/Lang/DuckDB/Run-length-encoding deleted file mode 120000 index 798b72b50c..0000000000 --- a/Lang/DuckDB/Run-length-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/Run-length-encoding/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Search-a-list-of-records b/Lang/DuckDB/Search-a-list-of-records deleted file mode 120000 index 8875d845bf..0000000000 --- a/Lang/DuckDB/Search-a-list-of-records +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list-of-records/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Set b/Lang/DuckDB/Set deleted file mode 120000 index 7e25aac634..0000000000 --- a/Lang/DuckDB/Set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Set-consolidation b/Lang/DuckDB/Set-consolidation deleted file mode 120000 index 46e9513ebb..0000000000 --- a/Lang/DuckDB/Set-consolidation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-consolidation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Show-the-epoch b/Lang/DuckDB/Show-the-epoch deleted file mode 120000 index 6cd68764f9..0000000000 --- a/Lang/DuckDB/Show-the-epoch +++ /dev/null @@ -1 +0,0 @@ -../../Task/Show-the-epoch/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sieve-of-Eratosthenes b/Lang/DuckDB/Sieve-of-Eratosthenes deleted file mode 120000 index ee6aa1fbd3..0000000000 --- a/Lang/DuckDB/Sieve-of-Eratosthenes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Eratosthenes/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sort-an-array-of-composite-structures b/Lang/DuckDB/Sort-an-array-of-composite-structures deleted file mode 120000 index 35612aed66..0000000000 --- a/Lang/DuckDB/Sort-an-array-of-composite-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-array-of-composite-structures/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sort-numbers-lexicographically b/Lang/DuckDB/Sort-numbers-lexicographically deleted file mode 120000 index 390860d685..0000000000 --- a/Lang/DuckDB/Sort-numbers-lexicographically +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-numbers-lexicographically/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Statistics-Basic b/Lang/DuckDB/Statistics-Basic deleted file mode 120000 index c3caa99be7..0000000000 --- a/Lang/DuckDB/Statistics-Basic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Basic/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-append b/Lang/DuckDB/String-append deleted file mode 120000 index cc8ce5011e..0000000000 --- a/Lang/DuckDB/String-append +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-append/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-case b/Lang/DuckDB/String-case deleted file mode 120000 index ab3478758f..0000000000 --- a/Lang/DuckDB/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-comparison b/Lang/DuckDB/String-comparison deleted file mode 120000 index b7a7339e14..0000000000 --- a/Lang/DuckDB/String-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-comparison/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-interpolation-included- b/Lang/DuckDB/String-interpolation-included- deleted file mode 120000 index 807f8abec4..0000000000 --- a/Lang/DuckDB/String-interpolation-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-interpolation-included-/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-length b/Lang/DuckDB/String-length deleted file mode 120000 index f49078b058..0000000000 --- a/Lang/DuckDB/String-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-length/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-matching b/Lang/DuckDB/String-matching deleted file mode 120000 index e3f7fa5300..0000000000 --- a/Lang/DuckDB/String-matching +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-matching/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-prepend b/Lang/DuckDB/String-prepend deleted file mode 120000 index ea6f95610c..0000000000 --- a/Lang/DuckDB/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-a-set-of-characters-from-a-string b/Lang/DuckDB/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index 77ce9f900d..0000000000 --- a/Lang/DuckDB/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-comments-from-a-string b/Lang/DuckDB/Strip-comments-from-a-string deleted file mode 120000 index f58b2c006d..0000000000 --- a/Lang/DuckDB/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string b/Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string deleted file mode 120000 index e3de3aa487..0000000000 --- a/Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-control-codes-and-extended-characters-from-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail b/Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail deleted file mode 120000 index 93405e661f..0000000000 --- a/Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-whitespace-from-a-string-Top-and-tail/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Substring b/Lang/DuckDB/Substring deleted file mode 120000 index fe9daf5b9c..0000000000 --- a/Lang/DuckDB/Substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substring/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sudoku b/Lang/DuckDB/Sudoku deleted file mode 120000 index efc19532bb..0000000000 --- a/Lang/DuckDB/Sudoku +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sudoku/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-and-product-of-an-array b/Lang/DuckDB/Sum-and-product-of-an-array deleted file mode 120000 index 9db07cfe55..0000000000 --- a/Lang/DuckDB/Sum-and-product-of-an-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-and-product-of-an-array/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-digits-of-an-integer b/Lang/DuckDB/Sum-digits-of-an-integer deleted file mode 120000 index 2b4e9e5805..0000000000 --- a/Lang/DuckDB/Sum-digits-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-digits-of-an-integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-multiples-of-3-and-5 b/Lang/DuckDB/Sum-multiples-of-3-and-5 deleted file mode 120000 index 06a19cefb7..0000000000 --- a/Lang/DuckDB/Sum-multiples-of-3-and-5 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-multiples-of-3-and-5/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-of-a-series b/Lang/DuckDB/Sum-of-a-series deleted file mode 120000 index db0f6f79c5..0000000000 --- a/Lang/DuckDB/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-of-squares b/Lang/DuckDB/Sum-of-squares deleted file mode 120000 index fe3d9a8a52..0000000000 --- a/Lang/DuckDB/Sum-of-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-squares/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Symmetric-difference b/Lang/DuckDB/Symmetric-difference deleted file mode 120000 index f254423d5f..0000000000 --- a/Lang/DuckDB/Symmetric-difference +++ /dev/null @@ -1 +0,0 @@ -../../Task/Symmetric-difference/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Table-creation-Postal-addresses b/Lang/DuckDB/Table-creation-Postal-addresses deleted file mode 120000 index 174f03f886..0000000000 --- a/Lang/DuckDB/Table-creation-Postal-addresses +++ /dev/null @@ -1 +0,0 @@ -../../Task/Table-creation-Postal-addresses/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Test-integerness b/Lang/DuckDB/Test-integerness deleted file mode 120000 index 0e9573c924..0000000000 --- a/Lang/DuckDB/Test-integerness +++ /dev/null @@ -1 +0,0 @@ -../../Task/Test-integerness/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Text-processing-2 b/Lang/DuckDB/Text-processing-2 deleted file mode 120000 index b3c883d2ec..0000000000 --- a/Lang/DuckDB/Text-processing-2 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Text-processing-2/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Thue-Morse b/Lang/DuckDB/Thue-Morse deleted file mode 120000 index e14a41e488..0000000000 --- a/Lang/DuckDB/Thue-Morse +++ /dev/null @@ -1 +0,0 @@ -../../Task/Thue-Morse/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Time-a-function b/Lang/DuckDB/Time-a-function deleted file mode 120000 index d82a288f55..0000000000 --- a/Lang/DuckDB/Time-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Time-a-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Tokenize-a-string b/Lang/DuckDB/Tokenize-a-string deleted file mode 120000 index ee6d07a4b5..0000000000 --- a/Lang/DuckDB/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Top-rank-per-group b/Lang/DuckDB/Top-rank-per-group deleted file mode 120000 index ada50a852c..0000000000 --- a/Lang/DuckDB/Top-rank-per-group +++ /dev/null @@ -1 +0,0 @@ -../../Task/Top-rank-per-group/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Trigonometric-functions b/Lang/DuckDB/Trigonometric-functions deleted file mode 120000 index 58530b66ee..0000000000 --- a/Lang/DuckDB/Trigonometric-functions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Trigonometric-functions/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/URL-decoding b/Lang/DuckDB/URL-decoding deleted file mode 120000 index c717460642..0000000000 --- a/Lang/DuckDB/URL-decoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/URL-decoding/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/UTF-8-encode-and-decode b/Lang/DuckDB/UTF-8-encode-and-decode deleted file mode 120000 index 792323a78c..0000000000 --- a/Lang/DuckDB/UTF-8-encode-and-decode +++ /dev/null @@ -1 +0,0 @@ -../../Task/UTF-8-encode-and-decode/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Unix-ls b/Lang/DuckDB/Unix-ls deleted file mode 120000 index 85287a21f6..0000000000 --- a/Lang/DuckDB/Unix-ls +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unix-ls/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Variable-size-Get b/Lang/DuckDB/Variable-size-Get deleted file mode 120000 index 3cff7c631a..0000000000 --- a/Lang/DuckDB/Variable-size-Get +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variable-size-Get/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Variable-size-Set b/Lang/DuckDB/Variable-size-Set deleted file mode 120000 index ee4a003cfa..0000000000 --- a/Lang/DuckDB/Variable-size-Set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variable-size-Set/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Vector-products b/Lang/DuckDB/Vector-products deleted file mode 120000 index 3347aa5bba..0000000000 --- a/Lang/DuckDB/Vector-products +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vector-products/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Zero-to-the-zero-power b/Lang/DuckDB/Zero-to-the-zero-power deleted file mode 120000 index 7c7bac0f0b..0000000000 --- a/Lang/DuckDB/Zero-to-the-zero-power +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zero-to-the-zero-power/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Zig-zag-matrix b/Lang/DuckDB/Zig-zag-matrix deleted file mode 120000 index dee409f57f..0000000000 --- a/Lang/DuckDB/Zig-zag-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zig-zag-matrix/DuckDB \ No newline at end of file diff --git a/Lang/E/Miller-Rabin-primality-test b/Lang/E/Miller-Rabin-primality-test new file mode 120000 index 0000000000..f586feb18b --- /dev/null +++ b/Lang/E/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/E \ No newline at end of file diff --git a/Lang/E/Quaternion-type b/Lang/E/Quaternion-type new file mode 120000 index 0000000000..ecc55ca8a4 --- /dev/null +++ b/Lang/E/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/E \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Haversine-formula b/Lang/EDSAC-order-code/Haversine-formula deleted file mode 120000 index 0cab079f84..0000000000 --- a/Lang/EDSAC-order-code/Haversine-formula +++ /dev/null @@ -1 +0,0 @@ -../../Task/Haversine-formula/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Josephus-problem b/Lang/EDSAC-order-code/Josephus-problem deleted file mode 120000 index bce73441c6..0000000000 --- a/Lang/EDSAC-order-code/Josephus-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Josephus-problem/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Magic-squares-of-doubly-even-order b/Lang/EDSAC-order-code/Magic-squares-of-doubly-even-order deleted file mode 120000 index 1753b89dcd..0000000000 --- a/Lang/EDSAC-order-code/Magic-squares-of-doubly-even-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-doubly-even-order/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Magic-squares-of-odd-order b/Lang/EDSAC-order-code/Magic-squares-of-odd-order deleted file mode 120000 index 1a44dde0cd..0000000000 --- a/Lang/EDSAC-order-code/Magic-squares-of-odd-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-odd-order/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Magic-squares-of-singly-even-order b/Lang/EDSAC-order-code/Magic-squares-of-singly-even-order deleted file mode 120000 index 68c523816d..0000000000 --- a/Lang/EDSAC-order-code/Magic-squares-of-singly-even-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-singly-even-order/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Maze-generation b/Lang/EDSAC-order-code/Maze-generation deleted file mode 120000 index 93d824a0ca..0000000000 --- a/Lang/EDSAC-order-code/Maze-generation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Maze-generation/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/EDSAC-order-code/Numerical-integration-Gauss-Legendre-Quadrature deleted file mode 120000 index f518a6e1fc..0000000000 --- a/Lang/EDSAC-order-code/Numerical-integration-Gauss-Legendre-Quadrature +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numerical-integration-Gauss-Legendre-Quadrature/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Pseudo-random-numbers-Middle-square-method b/Lang/EDSAC-order-code/Pseudo-random-numbers-Middle-square-method deleted file mode 120000 index 9e378bb2f4..0000000000 --- a/Lang/EDSAC-order-code/Pseudo-random-numbers-Middle-square-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Middle-square-method/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Pythagorean-quadruples b/Lang/EDSAC-order-code/Pythagorean-quadruples deleted file mode 120000 index 43dfaa296f..0000000000 --- a/Lang/EDSAC-order-code/Pythagorean-quadruples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagorean-quadruples/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Shoelace-formula-for-polygonal-area b/Lang/EDSAC-order-code/Shoelace-formula-for-polygonal-area deleted file mode 120000 index fb3446e1bf..0000000000 --- a/Lang/EDSAC-order-code/Shoelace-formula-for-polygonal-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shoelace-formula-for-polygonal-area/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Sorting-algorithms-Gnome-sort b/Lang/EDSAC-order-code/Sorting-algorithms-Gnome-sort deleted file mode 120000 index 3be03b0294..0000000000 --- a/Lang/EDSAC-order-code/Sorting-algorithms-Gnome-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Gnome-sort/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Statistics-Normal-distribution b/Lang/EDSAC-order-code/Statistics-Normal-distribution deleted file mode 120000 index 8051b92f59..0000000000 --- a/Lang/EDSAC-order-code/Statistics-Normal-distribution +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Normal-distribution/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Sum-digits-of-an-integer b/Lang/EDSAC-order-code/Sum-digits-of-an-integer deleted file mode 120000 index 23c793fd07..0000000000 --- a/Lang/EDSAC-order-code/Sum-digits-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-digits-of-an-integer/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EDSAC-order-code/Water-collected-between-towers b/Lang/EDSAC-order-code/Water-collected-between-towers deleted file mode 120000 index 7c9456760f..0000000000 --- a/Lang/EDSAC-order-code/Water-collected-between-towers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Water-collected-between-towers/EDSAC-order-code \ No newline at end of file diff --git a/Lang/EMal/00-LANG.txt b/Lang/EMal/00-LANG.txt index 3af52fab5c..9ecf11d932 100644 --- a/Lang/EMal/00-LANG.txt +++ b/Lang/EMal/00-LANG.txt @@ -6,23 +6,21 @@ |site=https://emal-lang.sourceforge.io |tags=emal |gc=yes}} -EMal is a prototyping programming language that supports English and Italian syntax. +EMal is a prototyping programming language that supports english and italian syntax. -EMal wants to be expressive and readable. It supports closures, classes, records; it's influenced by Java, Perl, Javascript. +EMal wants to be expressive and easy to read. -The programming environment consists of an interpreter that directly navigates the AST produced by the parser. - -This is an example that, inside the same script, calculates F10 = 55 in English and in Italian: +This is an example that, inside the same script, calculates F10 = 55 in english and in italian: type FibonacciInEnglish -fun fibonacci ← int by int n +fun fibonacci = int by int n if n < 2 do return n else do return fibonacci(n - 1) + fibonacci(n - 2) end end writeLine(fibonacci(10)) tipo FibonacciInItaliano -funzione fibonacci ← intero da intero n +funzione fibonacci = intero da intero n se n < 2 ritorna n altrimenti diff --git a/Lang/EMal/ABC-problem b/Lang/EMal/ABC-problem deleted file mode 120000 index 4b49dc2baf..0000000000 --- a/Lang/EMal/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/EMal \ No newline at end of file diff --git a/Lang/EMal/Babbage-problem b/Lang/EMal/Babbage-problem deleted file mode 120000 index 8a7db13311..0000000000 --- a/Lang/EMal/Babbage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babbage-problem/EMal \ No newline at end of file diff --git a/Lang/EMal/Bifid-cipher b/Lang/EMal/Bifid-cipher deleted file mode 120000 index 1dbee9fec8..0000000000 --- a/Lang/EMal/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/EMal \ No newline at end of file diff --git a/Lang/EMal/Character-codes b/Lang/EMal/Character-codes deleted file mode 120000 index 88b6717d1c..0000000000 --- a/Lang/EMal/Character-codes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Character-codes/EMal \ No newline at end of file diff --git a/Lang/EMal/Comments b/Lang/EMal/Comments deleted file mode 120000 index 09f782bacf..0000000000 --- a/Lang/EMal/Comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comments/EMal \ No newline at end of file diff --git a/Lang/EMal/Delegates b/Lang/EMal/Delegates deleted file mode 120000 index 5293d68109..0000000000 --- a/Lang/EMal/Delegates +++ /dev/null @@ -1 +0,0 @@ -../../Task/Delegates/EMal \ No newline at end of file diff --git a/Lang/EMal/Determine-if-a-string-is-squeezable b/Lang/EMal/Determine-if-a-string-is-squeezable deleted file mode 120000 index 27c56fc092..0000000000 --- a/Lang/EMal/Determine-if-a-string-is-squeezable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-squeezable/EMal \ No newline at end of file diff --git a/Lang/EMal/Dynamic-variable-names b/Lang/EMal/Dynamic-variable-names deleted file mode 120000 index 28a70b20a1..0000000000 --- a/Lang/EMal/Dynamic-variable-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dynamic-variable-names/EMal \ No newline at end of file diff --git a/Lang/EMal/Empty-string b/Lang/EMal/Empty-string deleted file mode 120000 index a051653333..0000000000 --- a/Lang/EMal/Empty-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-string/EMal \ No newline at end of file diff --git a/Lang/EMal/Enumerations b/Lang/EMal/Enumerations deleted file mode 120000 index 711fc51114..0000000000 --- a/Lang/EMal/Enumerations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Enumerations/EMal \ No newline at end of file diff --git a/Lang/EMal/Environment-variables b/Lang/EMal/Environment-variables deleted file mode 120000 index 04065bea17..0000000000 --- a/Lang/EMal/Environment-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Environment-variables/EMal \ No newline at end of file diff --git a/Lang/EMal/Filter b/Lang/EMal/Filter deleted file mode 120000 index e496c77526..0000000000 --- a/Lang/EMal/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/EMal \ No newline at end of file diff --git a/Lang/EMal/FizzBuzz b/Lang/EMal/FizzBuzz deleted file mode 120000 index 7a42e8cf25..0000000000 --- a/Lang/EMal/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/EMal \ No newline at end of file diff --git a/Lang/EMal/Gamma-function b/Lang/EMal/Gamma-function deleted file mode 120000 index f928139952..0000000000 --- a/Lang/EMal/Gamma-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gamma-function/EMal \ No newline at end of file diff --git a/Lang/EMal/Greatest-common-divisor b/Lang/EMal/Greatest-common-divisor deleted file mode 120000 index 5a6de213e1..0000000000 --- a/Lang/EMal/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/EMal \ No newline at end of file diff --git a/Lang/EMal/Guess-the-number b/Lang/EMal/Guess-the-number deleted file mode 120000 index fc6e3366e6..0000000000 --- a/Lang/EMal/Guess-the-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number/EMal \ No newline at end of file diff --git a/Lang/EMal/Halt-and-catch-fire b/Lang/EMal/Halt-and-catch-fire deleted file mode 120000 index 63015fddfa..0000000000 --- a/Lang/EMal/Halt-and-catch-fire +++ /dev/null @@ -1 +0,0 @@ -../../Task/Halt-and-catch-fire/EMal \ No newline at end of file diff --git a/Lang/EMal/Hash-from-two-arrays b/Lang/EMal/Hash-from-two-arrays deleted file mode 120000 index 25f9a9c7af..0000000000 --- a/Lang/EMal/Hash-from-two-arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hash-from-two-arrays/EMal \ No newline at end of file diff --git a/Lang/EMal/Inheritance-Single b/Lang/EMal/Inheritance-Single deleted file mode 120000 index a68d11ae59..0000000000 --- a/Lang/EMal/Inheritance-Single +++ /dev/null @@ -1 +0,0 @@ -../../Task/Inheritance-Single/EMal \ No newline at end of file diff --git a/Lang/EMal/Loops-For b/Lang/EMal/Loops-For deleted file mode 120000 index ac145e5175..0000000000 --- a/Lang/EMal/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/EMal \ No newline at end of file diff --git a/Lang/EMal/Loops-For-with-a-specified-step b/Lang/EMal/Loops-For-with-a-specified-step deleted file mode 120000 index 420591b041..0000000000 --- a/Lang/EMal/Loops-For-with-a-specified-step +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For-with-a-specified-step/EMal \ No newline at end of file diff --git a/Lang/EMal/Loops-Increment-loop-index-within-loop-body b/Lang/EMal/Loops-Increment-loop-index-within-loop-body deleted file mode 120000 index d82571b9b9..0000000000 --- a/Lang/EMal/Loops-Increment-loop-index-within-loop-body +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Increment-loop-index-within-loop-body/EMal \ No newline at end of file diff --git a/Lang/EMal/Loops-N-plus-one-half b/Lang/EMal/Loops-N-plus-one-half deleted file mode 120000 index 45adbe30ec..0000000000 --- a/Lang/EMal/Loops-N-plus-one-half +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-N-plus-one-half/EMal \ No newline at end of file diff --git a/Lang/EMal/Loops-While b/Lang/EMal/Loops-While deleted file mode 120000 index 016c2ea1d7..0000000000 --- a/Lang/EMal/Loops-While +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-While/EMal \ No newline at end of file diff --git a/Lang/EMal/Mutual-recursion b/Lang/EMal/Mutual-recursion deleted file mode 120000 index cb3ebc8ca5..0000000000 --- a/Lang/EMal/Mutual-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mutual-recursion/EMal \ No newline at end of file diff --git a/Lang/EMal/Nth-root b/Lang/EMal/Nth-root deleted file mode 120000 index 58e1f9e30f..0000000000 --- a/Lang/EMal/Nth-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth-root/EMal \ No newline at end of file diff --git a/Lang/EMal/Sorting-algorithms-Bogosort b/Lang/EMal/Sorting-algorithms-Bogosort deleted file mode 120000 index 8dc8cc02d3..0000000000 --- a/Lang/EMal/Sorting-algorithms-Bogosort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bogosort/EMal \ No newline at end of file diff --git a/Lang/EMal/Sorting-algorithms-Bubble-sort b/Lang/EMal/Sorting-algorithms-Bubble-sort deleted file mode 120000 index 53f744e6e9..0000000000 --- a/Lang/EMal/Sorting-algorithms-Bubble-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bubble-sort/EMal \ No newline at end of file diff --git a/Lang/EMal/Sorting-algorithms-Stooge-sort b/Lang/EMal/Sorting-algorithms-Stooge-sort deleted file mode 120000 index 05296c2a09..0000000000 --- a/Lang/EMal/Sorting-algorithms-Stooge-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Stooge-sort/EMal \ No newline at end of file diff --git a/Lang/EMal/String-case b/Lang/EMal/String-case deleted file mode 120000 index 8193cfe690..0000000000 --- a/Lang/EMal/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/EMal \ No newline at end of file diff --git a/Lang/EMal/String-comparison b/Lang/EMal/String-comparison deleted file mode 120000 index 02b430a538..0000000000 --- a/Lang/EMal/String-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-comparison/EMal \ No newline at end of file diff --git a/Lang/EMal/String-prepend b/Lang/EMal/String-prepend deleted file mode 120000 index 9ace108cf5..0000000000 --- a/Lang/EMal/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/EMal \ No newline at end of file diff --git a/Lang/EMal/Sudan-function b/Lang/EMal/Sudan-function deleted file mode 120000 index ea87f1432e..0000000000 --- a/Lang/EMal/Sudan-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sudan-function/EMal \ No newline at end of file diff --git a/Lang/EMal/Ternary-logic b/Lang/EMal/Ternary-logic deleted file mode 120000 index 837bedfab5..0000000000 --- a/Lang/EMal/Ternary-logic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ternary-logic/EMal \ No newline at end of file diff --git a/Lang/EMal/Towers-of-Hanoi b/Lang/EMal/Towers-of-Hanoi deleted file mode 120000 index 5771f28b4c..0000000000 --- a/Lang/EMal/Towers-of-Hanoi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Towers-of-Hanoi/EMal \ No newline at end of file diff --git a/Lang/EMal/Tree-traversal b/Lang/EMal/Tree-traversal deleted file mode 120000 index b693d069a6..0000000000 --- a/Lang/EMal/Tree-traversal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tree-traversal/EMal \ No newline at end of file diff --git a/Lang/EMal/User-input-Text b/Lang/EMal/User-input-Text deleted file mode 120000 index 3c00cf11ba..0000000000 --- a/Lang/EMal/User-input-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/User-input-Text/EMal \ No newline at end of file diff --git a/Lang/EMal/Van-Eck-sequence b/Lang/EMal/Van-Eck-sequence deleted file mode 120000 index 45280862ec..0000000000 --- a/Lang/EMal/Van-Eck-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Van-Eck-sequence/EMal \ No newline at end of file diff --git a/Lang/ERRE/Leonardo-numbers b/Lang/ERRE/Leonardo-numbers deleted file mode 120000 index 3e0d0050d1..0000000000 --- a/Lang/ERRE/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/ERRE \ No newline at end of file diff --git a/Lang/ERRE/Quaternion-type b/Lang/ERRE/Quaternion-type new file mode 120000 index 0000000000..fcc1edb64e --- /dev/null +++ b/Lang/ERRE/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/ERRE \ No newline at end of file diff --git a/Lang/EasyLang/00-LANG.txt b/Lang/EasyLang/00-LANG.txt index e09a925b83..e4d3b910bf 100644 --- a/Lang/EasyLang/00-LANG.txt +++ b/Lang/EasyLang/00-LANG.txt @@ -1,19 +1,16 @@ {{language |exec=interpreted -|site=https://easylang.online/ +|site=https://easylang.dev/ |parampass=value, reference |safety=safe |express=explicit |checking=static |tags=learning, web canvas}} -[https://easylang.online/ide/ '''Browser IDE'''] +[https://easylang.dev/ide/ '''Browser IDE'''] ''Easylang'' is a (beginners) programming language with built-in commands for graphics output. The statically typed language has a reduced syntax and semantics. Variables do not have to be declared, the data type is encoded in the variable name - as was usual in the earlier home computer BASIC. The data types are strings and numbers (floating point), arrays of strings and numbers, and arrays of arrays. Arrays are 1-based and can grow. Programs compiled into an AST tree run in the browser or in the browser IDE. -[https://easylang.online/ide/ A browser IDE] with different tutorials, one for beginners, makes programming and learning to program as easy as possible. +[https://easylang.dev/ide/ A browser IDE] with different tutorials, one for beginners, makes programming and learning to program as easy as possible. -The finished programs can be easily integrated into a [https://easylang.online/apps/ website]. - -==Todo== -[[Tasks not implemented in EasyLang]] \ No newline at end of file +The finished programs can be easily integrated into a [https://easylang.dev/apps/ website]. \ No newline at end of file diff --git a/Lang/EasyLang/2048 b/Lang/EasyLang/2048 deleted file mode 120000 index 4a69b16207..0000000000 --- a/Lang/EasyLang/2048 +++ /dev/null @@ -1 +0,0 @@ -../../Task/2048/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/24-game b/Lang/EasyLang/24-game deleted file mode 120000 index 85da2301e7..0000000000 --- a/Lang/EasyLang/24-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/24-game/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/4-rings-or-4-squares-puzzle b/Lang/EasyLang/4-rings-or-4-squares-puzzle deleted file mode 120000 index f8f08276c2..0000000000 --- a/Lang/EasyLang/4-rings-or-4-squares-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/4-rings-or-4-squares-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/9-billion-names-of-God-the-integer b/Lang/EasyLang/9-billion-names-of-God-the-integer deleted file mode 120000 index eab904ccaa..0000000000 --- a/Lang/EasyLang/9-billion-names-of-God-the-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/9-billion-names-of-God-the-integer/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/ABC-problem b/Lang/EasyLang/ABC-problem deleted file mode 120000 index 18a0732918..0000000000 --- a/Lang/EasyLang/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/AKS-test-for-primes b/Lang/EasyLang/AKS-test-for-primes deleted file mode 120000 index fb3fd809a4..0000000000 --- a/Lang/EasyLang/AKS-test-for-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/AKS-test-for-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abbreviations-automatic b/Lang/EasyLang/Abbreviations-automatic deleted file mode 120000 index 10b2251691..0000000000 --- a/Lang/EasyLang/Abbreviations-automatic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-automatic/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abbreviations-easy b/Lang/EasyLang/Abbreviations-easy deleted file mode 120000 index 9f43877f2b..0000000000 --- a/Lang/EasyLang/Abbreviations-easy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-easy/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abbreviations-simple b/Lang/EasyLang/Abbreviations-simple deleted file mode 120000 index 53295111be..0000000000 --- a/Lang/EasyLang/Abbreviations-simple +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-simple/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abelian-sandpile-model b/Lang/EasyLang/Abelian-sandpile-model deleted file mode 120000 index c97f3c3aa6..0000000000 --- a/Lang/EasyLang/Abelian-sandpile-model +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abelian-sandpile-model-Identity b/Lang/EasyLang/Abelian-sandpile-model-Identity deleted file mode 120000 index c44f8cb53d..0000000000 --- a/Lang/EasyLang/Abelian-sandpile-model-Identity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abelian-sandpile-model-Identity/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abundant-deficient-and-perfect-number-classifications b/Lang/EasyLang/Abundant-deficient-and-perfect-number-classifications deleted file mode 120000 index 3d14411268..0000000000 --- a/Lang/EasyLang/Abundant-deficient-and-perfect-number-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-deficient-and-perfect-number-classifications/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abundant-odd-numbers b/Lang/EasyLang/Abundant-odd-numbers deleted file mode 120000 index 78400648db..0000000000 --- a/Lang/EasyLang/Abundant-odd-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abundant-odd-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Achilles-numbers b/Lang/EasyLang/Achilles-numbers deleted file mode 120000 index 90c0643d0e..0000000000 --- a/Lang/EasyLang/Achilles-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Achilles-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Align-columns b/Lang/EasyLang/Align-columns deleted file mode 120000 index 09ddaaad2b..0000000000 --- a/Lang/EasyLang/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Aliquot-sequence-classifications b/Lang/EasyLang/Aliquot-sequence-classifications deleted file mode 120000 index 3085d38bff..0000000000 --- a/Lang/EasyLang/Aliquot-sequence-classifications +++ /dev/null @@ -1 +0,0 @@ -../../Task/Aliquot-sequence-classifications/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Almost-prime b/Lang/EasyLang/Almost-prime deleted file mode 120000 index f2e37e388e..0000000000 --- a/Lang/EasyLang/Almost-prime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Almost-prime/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Amb b/Lang/EasyLang/Amb deleted file mode 120000 index cee73196db..0000000000 --- a/Lang/EasyLang/Amb +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amb/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Amicable-pairs b/Lang/EasyLang/Amicable-pairs deleted file mode 120000 index 445221e26c..0000000000 --- a/Lang/EasyLang/Amicable-pairs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Amicable-pairs/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Anagrams b/Lang/EasyLang/Anagrams deleted file mode 120000 index 1a48ded8aa..0000000000 --- a/Lang/EasyLang/Anagrams +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anagrams/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Anagrams-Deranged-anagrams b/Lang/EasyLang/Anagrams-Deranged-anagrams deleted file mode 120000 index b7af47405b..0000000000 --- a/Lang/EasyLang/Anagrams-Deranged-anagrams +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anagrams-Deranged-anagrams/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Angle-difference-between-two-bearings b/Lang/EasyLang/Angle-difference-between-two-bearings deleted file mode 120000 index a2eba57e69..0000000000 --- a/Lang/EasyLang/Angle-difference-between-two-bearings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angle-difference-between-two-bearings/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Angles-geometric-normalization-and-conversion b/Lang/EasyLang/Angles-geometric-normalization-and-conversion deleted file mode 120000 index afa5d2ad31..0000000000 --- a/Lang/EasyLang/Angles-geometric-normalization-and-conversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Angles-geometric-normalization-and-conversion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Animation b/Lang/EasyLang/Animation deleted file mode 120000 index a11bf8da48..0000000000 --- a/Lang/EasyLang/Animation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Animation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Anti-primes b/Lang/EasyLang/Anti-primes deleted file mode 120000 index 9f890a169f..0000000000 --- a/Lang/EasyLang/Anti-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anti-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Approximate-equality b/Lang/EasyLang/Approximate-equality deleted file mode 120000 index 916cbf0873..0000000000 --- a/Lang/EasyLang/Approximate-equality +++ /dev/null @@ -1 +0,0 @@ -../../Task/Approximate-equality/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Archimedean-spiral b/Lang/EasyLang/Archimedean-spiral deleted file mode 120000 index 61f1f9fb04..0000000000 --- a/Lang/EasyLang/Archimedean-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Archimedean-spiral/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Arithmetic-Complex b/Lang/EasyLang/Arithmetic-Complex deleted file mode 120000 index 547a37cd78..0000000000 --- a/Lang/EasyLang/Arithmetic-Complex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-Complex/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Arithmetic-derivative b/Lang/EasyLang/Arithmetic-derivative deleted file mode 120000 index 13a223ff6a..0000000000 --- a/Lang/EasyLang/Arithmetic-derivative +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-derivative/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Arithmetic-evaluation b/Lang/EasyLang/Arithmetic-evaluation deleted file mode 120000 index cbf63cb359..0000000000 --- a/Lang/EasyLang/Arithmetic-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-evaluation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Arithmetic-geometric-mean b/Lang/EasyLang/Arithmetic-geometric-mean deleted file mode 120000 index 49e1f0e922..0000000000 --- a/Lang/EasyLang/Arithmetic-geometric-mean +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Arithmetic-geometric-mean-Calculate-Pi b/Lang/EasyLang/Arithmetic-geometric-mean-Calculate-Pi deleted file mode 120000 index 3be49c9de9..0000000000 --- a/Lang/EasyLang/Arithmetic-geometric-mean-Calculate-Pi +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-geometric-mean-Calculate-Pi/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ascending-primes b/Lang/EasyLang/Ascending-primes deleted file mode 120000 index f20d5f06bb..0000000000 --- a/Lang/EasyLang/Ascending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ascending-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Associative-array-Merging b/Lang/EasyLang/Associative-array-Merging deleted file mode 120000 index efe48db36d..0000000000 --- a/Lang/EasyLang/Associative-array-Merging +++ /dev/null @@ -1 +0,0 @@ -../../Task/Associative-array-Merging/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Attractive-numbers b/Lang/EasyLang/Attractive-numbers deleted file mode 120000 index cec03b0311..0000000000 --- a/Lang/EasyLang/Attractive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Attractive-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Average-loop-length b/Lang/EasyLang/Average-loop-length deleted file mode 120000 index adb975f11d..0000000000 --- a/Lang/EasyLang/Average-loop-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Average-loop-length/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Averages-Mean-angle b/Lang/EasyLang/Averages-Mean-angle deleted file mode 120000 index 24f9f1474b..0000000000 --- a/Lang/EasyLang/Averages-Mean-angle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-angle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Averages-Mean-time-of-day b/Lang/EasyLang/Averages-Mean-time-of-day deleted file mode 120000 index 860451fa65..0000000000 --- a/Lang/EasyLang/Averages-Mean-time-of-day +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mean-time-of-day/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Averages-Mode b/Lang/EasyLang/Averages-Mode deleted file mode 120000 index 3d5aef1b7e..0000000000 --- a/Lang/EasyLang/Averages-Mode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Mode/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Averages-Pythagorean-means b/Lang/EasyLang/Averages-Pythagorean-means deleted file mode 120000 index 54e04474ad..0000000000 --- a/Lang/EasyLang/Averages-Pythagorean-means +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Pythagorean-means/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Averages-Root-mean-square b/Lang/EasyLang/Averages-Root-mean-square deleted file mode 120000 index c6747681ce..0000000000 --- a/Lang/EasyLang/Averages-Root-mean-square +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Root-mean-square/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Averages-Simple-moving-average b/Lang/EasyLang/Averages-Simple-moving-average deleted file mode 120000 index 526250f81a..0000000000 --- a/Lang/EasyLang/Averages-Simple-moving-average +++ /dev/null @@ -1 +0,0 @@ -../../Task/Averages-Simple-moving-average/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Babylonian-spiral b/Lang/EasyLang/Babylonian-spiral deleted file mode 120000 index a141d2cd6b..0000000000 --- a/Lang/EasyLang/Babylonian-spiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Babylonian-spiral/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Balanced-brackets b/Lang/EasyLang/Balanced-brackets deleted file mode 120000 index 5f2b730d5e..0000000000 --- a/Lang/EasyLang/Balanced-brackets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Balanced-brackets/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bell-numbers b/Lang/EasyLang/Bell-numbers deleted file mode 120000 index 127123a7d4..0000000000 --- a/Lang/EasyLang/Bell-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bell-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Benfords-law b/Lang/EasyLang/Benfords-law deleted file mode 120000 index a907859e75..0000000000 --- a/Lang/EasyLang/Benfords-law +++ /dev/null @@ -1 +0,0 @@ -../../Task/Benfords-law/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Best-shuffle b/Lang/EasyLang/Best-shuffle deleted file mode 120000 index 56cfd176ba..0000000000 --- a/Lang/EasyLang/Best-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Best-shuffle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bifid-cipher b/Lang/EasyLang/Bifid-cipher deleted file mode 120000 index 00c9d65ab1..0000000000 --- a/Lang/EasyLang/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bin-given-limits b/Lang/EasyLang/Bin-given-limits deleted file mode 120000 index cc28e3775f..0000000000 --- a/Lang/EasyLang/Bin-given-limits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bin-given-limits/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bioinformatics-Sequence-mutation b/Lang/EasyLang/Bioinformatics-Sequence-mutation deleted file mode 120000 index 6d30bfa11e..0000000000 --- a/Lang/EasyLang/Bioinformatics-Sequence-mutation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bioinformatics-Sequence-mutation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Biorhythms b/Lang/EasyLang/Biorhythms deleted file mode 120000 index 3e8c2b07fa..0000000000 --- a/Lang/EasyLang/Biorhythms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Biorhythms/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bitmap-B-zier-curves-Quadratic b/Lang/EasyLang/Bitmap-B-zier-curves-Quadratic deleted file mode 120000 index 569a661356..0000000000 --- a/Lang/EasyLang/Bitmap-B-zier-curves-Quadratic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-B-zier-curves-Quadratic/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bitmap-Bresenhams-line-algorithm b/Lang/EasyLang/Bitmap-Bresenhams-line-algorithm deleted file mode 120000 index 5b05ee202b..0000000000 --- a/Lang/EasyLang/Bitmap-Bresenhams-line-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Bresenhams-line-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bitmap-Midpoint-circle-algorithm b/Lang/EasyLang/Bitmap-Midpoint-circle-algorithm deleted file mode 120000 index 9b995802ee..0000000000 --- a/Lang/EasyLang/Bitmap-Midpoint-circle-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Midpoint-circle-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Blum-integer b/Lang/EasyLang/Blum-integer deleted file mode 120000 index bc9517af8d..0000000000 --- a/Lang/EasyLang/Blum-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Blum-integer/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Box-the-compass b/Lang/EasyLang/Box-the-compass deleted file mode 120000 index 4fd6c85d9d..0000000000 --- a/Lang/EasyLang/Box-the-compass +++ /dev/null @@ -1 +0,0 @@ -../../Task/Box-the-compass/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Boyer-Moore-string-search b/Lang/EasyLang/Boyer-Moore-string-search deleted file mode 120000 index 189112146a..0000000000 --- a/Lang/EasyLang/Boyer-Moore-string-search +++ /dev/null @@ -1 +0,0 @@ -../../Task/Boyer-Moore-string-search/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Brace-expansion b/Lang/EasyLang/Brace-expansion deleted file mode 120000 index fadaa7c96a..0000000000 --- a/Lang/EasyLang/Brace-expansion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brace-expansion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Brilliant-numbers b/Lang/EasyLang/Brilliant-numbers deleted file mode 120000 index 280a1c45cc..0000000000 --- a/Lang/EasyLang/Brilliant-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brilliant-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bulls-and-cows-Player b/Lang/EasyLang/Bulls-and-cows-Player deleted file mode 120000 index 9e4aef5378..0000000000 --- a/Lang/EasyLang/Bulls-and-cows-Player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bulls-and-cows-Player/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Burrows-Wheeler-transform b/Lang/EasyLang/Burrows-Wheeler-transform deleted file mode 120000 index d3dcf6a651..0000000000 --- a/Lang/EasyLang/Burrows-Wheeler-transform +++ /dev/null @@ -1 +0,0 @@ -../../Task/Burrows-Wheeler-transform/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/CRC-32 b/Lang/EasyLang/CRC-32 deleted file mode 120000 index 75d250a063..0000000000 --- a/Lang/EasyLang/CRC-32 +++ /dev/null @@ -1 +0,0 @@ -../../Task/CRC-32/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/CSV-data-manipulation b/Lang/EasyLang/CSV-data-manipulation deleted file mode 120000 index 18ae83328e..0000000000 --- a/Lang/EasyLang/CSV-data-manipulation +++ /dev/null @@ -1 +0,0 @@ -../../Task/CSV-data-manipulation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/CSV-to-HTML-translation b/Lang/EasyLang/CSV-to-HTML-translation deleted file mode 120000 index 7a4f03c98e..0000000000 --- a/Lang/EasyLang/CSV-to-HTML-translation +++ /dev/null @@ -1 +0,0 @@ -../../Task/CSV-to-HTML-translation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/CUSIP b/Lang/EasyLang/CUSIP deleted file mode 120000 index 18e1a39668..0000000000 --- a/Lang/EasyLang/CUSIP +++ /dev/null @@ -1 +0,0 @@ -../../Task/CUSIP/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Caesar-cipher b/Lang/EasyLang/Caesar-cipher deleted file mode 120000 index 1d121f0b00..0000000000 --- a/Lang/EasyLang/Caesar-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Caesar-cipher/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Calendar b/Lang/EasyLang/Calendar deleted file mode 120000 index a7149967d9..0000000000 --- a/Lang/EasyLang/Calendar +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Calkin-Wilf-sequence b/Lang/EasyLang/Calkin-Wilf-sequence deleted file mode 120000 index 4e52e0d6e6..0000000000 --- a/Lang/EasyLang/Calkin-Wilf-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calkin-Wilf-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Camel-case-and-snake-case b/Lang/EasyLang/Camel-case-and-snake-case deleted file mode 120000 index 0a9d3d035c..0000000000 --- a/Lang/EasyLang/Camel-case-and-snake-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/Camel-case-and-snake-case/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Canonicalize-CIDR b/Lang/EasyLang/Canonicalize-CIDR deleted file mode 120000 index ef98b51c97..0000000000 --- a/Lang/EasyLang/Canonicalize-CIDR +++ /dev/null @@ -1 +0,0 @@ -../../Task/Canonicalize-CIDR/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cantor-set b/Lang/EasyLang/Cantor-set deleted file mode 120000 index 3166a68c95..0000000000 --- a/Lang/EasyLang/Cantor-set +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cantor-set/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Carmichael-3-strong-pseudoprimes b/Lang/EasyLang/Carmichael-3-strong-pseudoprimes deleted file mode 120000 index 87390cac39..0000000000 --- a/Lang/EasyLang/Carmichael-3-strong-pseudoprimes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Carmichael-3-strong-pseudoprimes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cartesian-product-of-two-or-more-lists b/Lang/EasyLang/Cartesian-product-of-two-or-more-lists deleted file mode 120000 index 012d512db6..0000000000 --- a/Lang/EasyLang/Cartesian-product-of-two-or-more-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cartesian-product-of-two-or-more-lists/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Casting-out-nines b/Lang/EasyLang/Casting-out-nines deleted file mode 120000 index c70d0861aa..0000000000 --- a/Lang/EasyLang/Casting-out-nines +++ /dev/null @@ -1 +0,0 @@ -../../Task/Casting-out-nines/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Catalan-numbers-Pascals-triangle b/Lang/EasyLang/Catalan-numbers-Pascals-triangle deleted file mode 120000 index 08636a2ee3..0000000000 --- a/Lang/EasyLang/Catalan-numbers-Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Catalan-numbers-Pascals-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Chaocipher b/Lang/EasyLang/Chaocipher deleted file mode 120000 index 46e0f46135..0000000000 --- a/Lang/EasyLang/Chaocipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chaocipher/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cheryls-birthday b/Lang/EasyLang/Cheryls-birthday deleted file mode 120000 index da4092e3ea..0000000000 --- a/Lang/EasyLang/Cheryls-birthday +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cheryls-birthday/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Chinese-zodiac b/Lang/EasyLang/Chinese-zodiac deleted file mode 120000 index 0eac7aa885..0000000000 --- a/Lang/EasyLang/Chinese-zodiac +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chinese-zodiac/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cholesky-decomposition b/Lang/EasyLang/Cholesky-decomposition deleted file mode 120000 index 3d9b8e35d4..0000000000 --- a/Lang/EasyLang/Cholesky-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cholesky-decomposition/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Circles-of-given-radius-through-two-points b/Lang/EasyLang/Circles-of-given-radius-through-two-points deleted file mode 120000 index 86863b1617..0000000000 --- a/Lang/EasyLang/Circles-of-given-radius-through-two-points +++ /dev/null @@ -1 +0,0 @@ -../../Task/Circles-of-given-radius-through-two-points/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Circular-primes b/Lang/EasyLang/Circular-primes deleted file mode 120000 index 8f738fed37..0000000000 --- a/Lang/EasyLang/Circular-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Circular-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cistercian-numerals b/Lang/EasyLang/Cistercian-numerals deleted file mode 120000 index 63eb472b3f..0000000000 --- a/Lang/EasyLang/Cistercian-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cistercian-numerals/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Closest-pair-problem b/Lang/EasyLang/Closest-pair-problem deleted file mode 120000 index 3aef86373f..0000000000 --- a/Lang/EasyLang/Closest-pair-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Closest-pair-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Color-wheel b/Lang/EasyLang/Color-wheel deleted file mode 120000 index c18069acb1..0000000000 --- a/Lang/EasyLang/Color-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Color-wheel/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Colorful-numbers b/Lang/EasyLang/Colorful-numbers deleted file mode 120000 index ebe27902b2..0000000000 --- a/Lang/EasyLang/Colorful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Colorful-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Colour-pinstripe-Display b/Lang/EasyLang/Colour-pinstripe-Display deleted file mode 120000 index 2e66fb03ab..0000000000 --- a/Lang/EasyLang/Colour-pinstripe-Display +++ /dev/null @@ -1 +0,0 @@ -../../Task/Colour-pinstripe-Display/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Combinations-and-permutations b/Lang/EasyLang/Combinations-and-permutations deleted file mode 120000 index 8cabf1d02c..0000000000 --- a/Lang/EasyLang/Combinations-and-permutations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations-and-permutations/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Comma-quibbling b/Lang/EasyLang/Comma-quibbling deleted file mode 120000 index 2a8720ee6a..0000000000 --- a/Lang/EasyLang/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Compare-a-list-of-strings b/Lang/EasyLang/Compare-a-list-of-strings deleted file mode 120000 index c992d49d46..0000000000 --- a/Lang/EasyLang/Compare-a-list-of-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-a-list-of-strings/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k b/Lang/EasyLang/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k deleted file mode 120000 index d18afd0e66..0000000000 --- a/Lang/EasyLang/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k +++ /dev/null @@ -1 +0,0 @@ -../../Task/Composite-numbers-k-with-no-single-digit-factors-whose-factors-are-all-substrings-of-k/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Consecutive-primes-with-ascending-or-descending-differences b/Lang/EasyLang/Consecutive-primes-with-ascending-or-descending-differences deleted file mode 120000 index 4752a5c8c3..0000000000 --- a/Lang/EasyLang/Consecutive-primes-with-ascending-or-descending-differences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Consecutive-primes-with-ascending-or-descending-differences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Constrained-random-points-on-a-circle b/Lang/EasyLang/Constrained-random-points-on-a-circle deleted file mode 120000 index 63f4482942..0000000000 --- a/Lang/EasyLang/Constrained-random-points-on-a-circle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Constrained-random-points-on-a-circle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Continued-fraction b/Lang/EasyLang/Continued-fraction deleted file mode 120000 index 9f39488e59..0000000000 --- a/Lang/EasyLang/Continued-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Continued-fraction/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Convert-decimal-number-to-rational b/Lang/EasyLang/Convert-decimal-number-to-rational deleted file mode 120000 index d8af3c05f9..0000000000 --- a/Lang/EasyLang/Convert-decimal-number-to-rational +++ /dev/null @@ -1 +0,0 @@ -../../Task/Convert-decimal-number-to-rational/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Convex-hull b/Lang/EasyLang/Convex-hull deleted file mode 120000 index 9e70f24915..0000000000 --- a/Lang/EasyLang/Convex-hull +++ /dev/null @@ -1 +0,0 @@ -../../Task/Convex-hull/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Count-occurrences-of-a-substring b/Lang/EasyLang/Count-occurrences-of-a-substring deleted file mode 120000 index 4597b1fb7c..0000000000 --- a/Lang/EasyLang/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cramers-rule b/Lang/EasyLang/Cramers-rule deleted file mode 120000 index 15d86e7ebe..0000000000 --- a/Lang/EasyLang/Cramers-rule +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cramers-rule/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Create-a-two-dimensional-array-at-runtime b/Lang/EasyLang/Create-a-two-dimensional-array-at-runtime deleted file mode 120000 index 9ab5d02120..0000000000 --- a/Lang/EasyLang/Create-a-two-dimensional-array-at-runtime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-a-two-dimensional-array-at-runtime/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Create-an-HTML-table b/Lang/EasyLang/Create-an-HTML-table deleted file mode 120000 index 977757451c..0000000000 --- a/Lang/EasyLang/Create-an-HTML-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-an-HTML-table/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cuban-primes b/Lang/EasyLang/Cuban-primes deleted file mode 120000 index 602fb8a030..0000000000 --- a/Lang/EasyLang/Cuban-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cuban-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cullen-and-Woodall-numbers b/Lang/EasyLang/Cullen-and-Woodall-numbers deleted file mode 120000 index d8702031ba..0000000000 --- a/Lang/EasyLang/Cullen-and-Woodall-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cullen-and-Woodall-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Currency b/Lang/EasyLang/Currency deleted file mode 120000 index a42c848ea8..0000000000 --- a/Lang/EasyLang/Currency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Currency/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Curzon-numbers b/Lang/EasyLang/Curzon-numbers deleted file mode 120000 index 570e1186b0..0000000000 --- a/Lang/EasyLang/Curzon-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Curzon-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cut-a-rectangle b/Lang/EasyLang/Cut-a-rectangle deleted file mode 120000 index 879a5ce073..0000000000 --- a/Lang/EasyLang/Cut-a-rectangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cut-a-rectangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cyclops-numbers b/Lang/EasyLang/Cyclops-numbers deleted file mode 120000 index 6df72e0544..0000000000 --- a/Lang/EasyLang/Cyclops-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cyclops-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Damm-algorithm b/Lang/EasyLang/Damm-algorithm deleted file mode 120000 index d7f6db29b1..0000000000 --- a/Lang/EasyLang/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Date-format b/Lang/EasyLang/Date-format deleted file mode 120000 index 443f76ed6a..0000000000 --- a/Lang/EasyLang/Date-format +++ /dev/null @@ -1 +0,0 @@ -../../Task/Date-format/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/De-Bruijn-sequences b/Lang/EasyLang/De-Bruijn-sequences deleted file mode 120000 index faba25f06a..0000000000 --- a/Lang/EasyLang/De-Bruijn-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/De-Bruijn-sequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Deal-cards-for-FreeCell b/Lang/EasyLang/Deal-cards-for-FreeCell deleted file mode 120000 index 9d47d59041..0000000000 --- a/Lang/EasyLang/Deal-cards-for-FreeCell +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deal-cards-for-FreeCell/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Death-Star b/Lang/EasyLang/Death-Star deleted file mode 120000 index 71ec2dde3d..0000000000 --- a/Lang/EasyLang/Death-Star +++ /dev/null @@ -1 +0,0 @@ -../../Task/Death-Star/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Deceptive-numbers b/Lang/EasyLang/Deceptive-numbers deleted file mode 120000 index eae8f8459d..0000000000 --- a/Lang/EasyLang/Deceptive-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deceptive-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Deconvolution-1D b/Lang/EasyLang/Deconvolution-1D deleted file mode 120000 index 7dba9ab208..0000000000 --- a/Lang/EasyLang/Deconvolution-1D +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deconvolution-1D/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Deepcopy b/Lang/EasyLang/Deepcopy deleted file mode 120000 index 4137c6d590..0000000000 --- a/Lang/EasyLang/Deepcopy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Deepcopy/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Demings-funnel b/Lang/EasyLang/Demings-funnel deleted file mode 120000 index d19d38286f..0000000000 --- a/Lang/EasyLang/Demings-funnel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Demings-funnel/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Descending-primes b/Lang/EasyLang/Descending-primes deleted file mode 120000 index 2cdfe30a0e..0000000000 --- a/Lang/EasyLang/Descending-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Descending-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determinant-and-permanent b/Lang/EasyLang/Determinant-and-permanent deleted file mode 120000 index 09ae422506..0000000000 --- a/Lang/EasyLang/Determinant-and-permanent +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determinant-and-permanent/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determine-if-a-string-has-all-the-same-characters b/Lang/EasyLang/Determine-if-a-string-has-all-the-same-characters deleted file mode 120000 index 164270fc83..0000000000 --- a/Lang/EasyLang/Determine-if-a-string-has-all-the-same-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-the-same-characters/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determine-if-a-string-has-all-unique-characters b/Lang/EasyLang/Determine-if-a-string-has-all-unique-characters deleted file mode 120000 index cec3ed07b3..0000000000 --- a/Lang/EasyLang/Determine-if-a-string-has-all-unique-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-unique-characters/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determine-if-a-string-is-collapsible b/Lang/EasyLang/Determine-if-a-string-is-collapsible deleted file mode 120000 index 05c87ac5e5..0000000000 --- a/Lang/EasyLang/Determine-if-a-string-is-collapsible +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-collapsible/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determine-if-a-string-is-squeezable b/Lang/EasyLang/Determine-if-a-string-is-squeezable deleted file mode 120000 index 3684f2848c..0000000000 --- a/Lang/EasyLang/Determine-if-a-string-is-squeezable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-squeezable/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determine-if-two-triangles-overlap b/Lang/EasyLang/Determine-if-two-triangles-overlap deleted file mode 120000 index 94cb794e8e..0000000000 --- a/Lang/EasyLang/Determine-if-two-triangles-overlap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-two-triangles-overlap/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Determine-sentence-type b/Lang/EasyLang/Determine-sentence-type deleted file mode 120000 index 191e85776f..0000000000 --- a/Lang/EasyLang/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Dice-game-probabilities b/Lang/EasyLang/Dice-game-probabilities deleted file mode 120000 index 5267c4bcfb..0000000000 --- a/Lang/EasyLang/Dice-game-probabilities +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dice-game-probabilities/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Digital-root-Multiplicative-digital-root b/Lang/EasyLang/Digital-root-Multiplicative-digital-root deleted file mode 120000 index c1e68a7fcb..0000000000 --- a/Lang/EasyLang/Digital-root-Multiplicative-digital-root +++ /dev/null @@ -1 +0,0 @@ -../../Task/Digital-root-Multiplicative-digital-root/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Dijkstras-algorithm b/Lang/EasyLang/Dijkstras-algorithm deleted file mode 120000 index de47a7cc8f..0000000000 --- a/Lang/EasyLang/Dijkstras-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dijkstras-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Dinesmans-multiple-dwelling-problem b/Lang/EasyLang/Dinesmans-multiple-dwelling-problem deleted file mode 120000 index 09fc1d4edc..0000000000 --- a/Lang/EasyLang/Dinesmans-multiple-dwelling-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dinesmans-multiple-dwelling-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Disarium-numbers b/Lang/EasyLang/Disarium-numbers deleted file mode 120000 index f7a091cb49..0000000000 --- a/Lang/EasyLang/Disarium-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Disarium-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Discordian-date b/Lang/EasyLang/Discordian-date deleted file mode 120000 index 637d22e417..0000000000 --- a/Lang/EasyLang/Discordian-date +++ /dev/null @@ -1 +0,0 @@ -../../Task/Discordian-date/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Display-a-linear-combination b/Lang/EasyLang/Display-a-linear-combination deleted file mode 120000 index e045995ad6..0000000000 --- a/Lang/EasyLang/Display-a-linear-combination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Display-a-linear-combination/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Distribution-of-0-digits-in-factorial-series b/Lang/EasyLang/Distribution-of-0-digits-in-factorial-series deleted file mode 120000 index 10532131de..0000000000 --- a/Lang/EasyLang/Distribution-of-0-digits-in-factorial-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Distribution-of-0-digits-in-factorial-series/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Diversity-prediction-theorem b/Lang/EasyLang/Diversity-prediction-theorem deleted file mode 120000 index 794b1e0805..0000000000 --- a/Lang/EasyLang/Diversity-prediction-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Diversity-prediction-theorem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Doomsday-rule b/Lang/EasyLang/Doomsday-rule deleted file mode 120000 index f576833747..0000000000 --- a/Lang/EasyLang/Doomsday-rule +++ /dev/null @@ -1 +0,0 @@ -../../Task/Doomsday-rule/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Draw-a-cuboid b/Lang/EasyLang/Draw-a-cuboid deleted file mode 120000 index bc7664226a..0000000000 --- a/Lang/EasyLang/Draw-a-cuboid +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-cuboid/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Draw-a-sphere b/Lang/EasyLang/Draw-a-sphere deleted file mode 120000 index 4a92493ec5..0000000000 --- a/Lang/EasyLang/Draw-a-sphere +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-sphere/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Duffinian-numbers b/Lang/EasyLang/Duffinian-numbers deleted file mode 120000 index 75befe0bb1..0000000000 --- a/Lang/EasyLang/Duffinian-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Duffinian-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Dutch-national-flag-problem b/Lang/EasyLang/Dutch-national-flag-problem deleted file mode 120000 index 09cb24ca60..0000000000 --- a/Lang/EasyLang/Dutch-national-flag-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dutch-national-flag-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/EKG-sequence-convergence b/Lang/EasyLang/EKG-sequence-convergence deleted file mode 120000 index a5d661cade..0000000000 --- a/Lang/EasyLang/EKG-sequence-convergence +++ /dev/null @@ -1 +0,0 @@ -../../Task/EKG-sequence-convergence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Earliest-difference-between-prime-gaps b/Lang/EasyLang/Earliest-difference-between-prime-gaps deleted file mode 120000 index e8abb13bc1..0000000000 --- a/Lang/EasyLang/Earliest-difference-between-prime-gaps +++ /dev/null @@ -1 +0,0 @@ -../../Task/Earliest-difference-between-prime-gaps/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Eban-numbers b/Lang/EasyLang/Eban-numbers deleted file mode 120000 index 37afec99ff..0000000000 --- a/Lang/EasyLang/Eban-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eban-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Egyptian-division b/Lang/EasyLang/Egyptian-division deleted file mode 120000 index 8d011b8470..0000000000 --- a/Lang/EasyLang/Egyptian-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Egyptian-division/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Element-wise-operations b/Lang/EasyLang/Element-wise-operations deleted file mode 120000 index 79d10fbb82..0000000000 --- a/Lang/EasyLang/Element-wise-operations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Element-wise-operations/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Elementary-cellular-automaton b/Lang/EasyLang/Elementary-cellular-automaton deleted file mode 120000 index 14cf04ae05..0000000000 --- a/Lang/EasyLang/Elementary-cellular-automaton +++ /dev/null @@ -1 +0,0 @@ -../../Task/Elementary-cellular-automaton/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Elementary-cellular-automaton-Infinite-length b/Lang/EasyLang/Elementary-cellular-automaton-Infinite-length deleted file mode 120000 index 440a0e3168..0000000000 --- a/Lang/EasyLang/Elementary-cellular-automaton-Infinite-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Elementary-cellular-automaton-Infinite-length/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Emirp-primes b/Lang/EasyLang/Emirp-primes deleted file mode 120000 index 59db016c15..0000000000 --- a/Lang/EasyLang/Emirp-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Emirp-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Empty-program b/Lang/EasyLang/Empty-program deleted file mode 120000 index 833f921ffb..0000000000 --- a/Lang/EasyLang/Empty-program +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-program/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Entropy b/Lang/EasyLang/Entropy deleted file mode 120000 index e06e8d9283..0000000000 --- a/Lang/EasyLang/Entropy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Equal-prime-and-composite-sums b/Lang/EasyLang/Equal-prime-and-composite-sums deleted file mode 120000 index d416ab6d61..0000000000 --- a/Lang/EasyLang/Equal-prime-and-composite-sums +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equal-prime-and-composite-sums/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Equilibrium-index b/Lang/EasyLang/Equilibrium-index deleted file mode 120000 index 165c2ae56a..0000000000 --- a/Lang/EasyLang/Equilibrium-index +++ /dev/null @@ -1 +0,0 @@ -../../Task/Equilibrium-index/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Erd-s-Nicolas-numbers b/Lang/EasyLang/Erd-s-Nicolas-numbers deleted file mode 120000 index 83838eb37b..0000000000 --- a/Lang/EasyLang/Erd-s-Nicolas-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Erd-s-Nicolas-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes b/Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes deleted file mode 120000 index a64dc7d4f0..0000000000 --- a/Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Erd-s-Selfridge-categorization-of-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Esthetic-numbers b/Lang/EasyLang/Esthetic-numbers deleted file mode 120000 index 17ae4253cc..0000000000 --- a/Lang/EasyLang/Esthetic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Esthetic-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Euclid-Mullin-sequence b/Lang/EasyLang/Euclid-Mullin-sequence deleted file mode 120000 index 465875e6ff..0000000000 --- a/Lang/EasyLang/Euclid-Mullin-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euclid-Mullin-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Euler-method b/Lang/EasyLang/Euler-method deleted file mode 120000 index 6d314b22d5..0000000000 --- a/Lang/EasyLang/Euler-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Euler-method/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Eulers-constant-0.5772... b/Lang/EasyLang/Eulers-constant-0.5772... deleted file mode 120000 index 481b218714..0000000000 --- a/Lang/EasyLang/Eulers-constant-0.5772... +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-constant-0.5772.../EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Eulers-identity b/Lang/EasyLang/Eulers-identity deleted file mode 120000 index 6753a604ea..0000000000 --- a/Lang/EasyLang/Eulers-identity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Eulers-identity/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Evaluate-binomial-coefficients b/Lang/EasyLang/Evaluate-binomial-coefficients deleted file mode 120000 index ca9734f276..0000000000 --- a/Lang/EasyLang/Evaluate-binomial-coefficients +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evaluate-binomial-coefficients/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Even-or-odd b/Lang/EasyLang/Even-or-odd deleted file mode 120000 index b33718ea9f..0000000000 --- a/Lang/EasyLang/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Events b/Lang/EasyLang/Events deleted file mode 120000 index 84019d59c2..0000000000 --- a/Lang/EasyLang/Events +++ /dev/null @@ -1 +0,0 @@ -../../Task/Events/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Evolutionary-algorithm b/Lang/EasyLang/Evolutionary-algorithm deleted file mode 120000 index 1e38bedd7f..0000000000 --- a/Lang/EasyLang/Evolutionary-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Evolutionary-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Execute-Brain- b/Lang/EasyLang/Execute-Brain- deleted file mode 120000 index f895a53826..0000000000 --- a/Lang/EasyLang/Execute-Brain- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-Brain-/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Execute-Computer-Zero b/Lang/EasyLang/Execute-Computer-Zero deleted file mode 120000 index 49e608b246..0000000000 --- a/Lang/EasyLang/Execute-Computer-Zero +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-Computer-Zero/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Execute-HQ9+ b/Lang/EasyLang/Execute-HQ9+ deleted file mode 120000 index aa3358e92d..0000000000 --- a/Lang/EasyLang/Execute-HQ9+ +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-HQ9+/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Execute-SNUSP b/Lang/EasyLang/Execute-SNUSP deleted file mode 120000 index d27fd2f524..0000000000 --- a/Lang/EasyLang/Execute-SNUSP +++ /dev/null @@ -1 +0,0 @@ -../../Task/Execute-SNUSP/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Exponentiation-operator b/Lang/EasyLang/Exponentiation-operator deleted file mode 120000 index 5f8b2cb64c..0000000000 --- a/Lang/EasyLang/Exponentiation-operator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-operator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Exponentiation-order b/Lang/EasyLang/Exponentiation-order deleted file mode 120000 index de7c440428..0000000000 --- a/Lang/EasyLang/Exponentiation-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-order/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Exponentiation-with-infix-operators-in-or-operating-on-the-base b/Lang/EasyLang/Exponentiation-with-infix-operators-in-or-operating-on-the-base deleted file mode 120000 index 131a7d1381..0000000000 --- a/Lang/EasyLang/Exponentiation-with-infix-operators-in-or-operating-on-the-base +++ /dev/null @@ -1 +0,0 @@ -../../Task/Exponentiation-with-infix-operators-in-or-operating-on-the-base/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Extensible-prime-generator b/Lang/EasyLang/Extensible-prime-generator deleted file mode 120000 index 6415b07f48..0000000000 --- a/Lang/EasyLang/Extensible-prime-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Extensible-prime-generator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Extreme-floating-point-values b/Lang/EasyLang/Extreme-floating-point-values deleted file mode 120000 index 8c4ae21587..0000000000 --- a/Lang/EasyLang/Extreme-floating-point-values +++ /dev/null @@ -1 +0,0 @@ -../../Task/Extreme-floating-point-values/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/FASTA-format b/Lang/EasyLang/FASTA-format deleted file mode 120000 index ca29d4ff3f..0000000000 --- a/Lang/EasyLang/FASTA-format +++ /dev/null @@ -1 +0,0 @@ -../../Task/FASTA-format/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Factorial-primes b/Lang/EasyLang/Factorial-primes deleted file mode 120000 index 6eb3f0a8b6..0000000000 --- a/Lang/EasyLang/Factorial-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Factorions b/Lang/EasyLang/Factorions deleted file mode 120000 index 52bf4a578c..0000000000 --- a/Lang/EasyLang/Factorions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorions/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Factors-of-a-Mersenne-number b/Lang/EasyLang/Factors-of-a-Mersenne-number deleted file mode 120000 index 3539cc5a50..0000000000 --- a/Lang/EasyLang/Factors-of-a-Mersenne-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factors-of-a-Mersenne-number/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Farey-sequence b/Lang/EasyLang/Farey-sequence deleted file mode 120000 index ce155397f5..0000000000 --- a/Lang/EasyLang/Farey-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Farey-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fast-Fourier-transform b/Lang/EasyLang/Fast-Fourier-transform deleted file mode 120000 index 6486d41d10..0000000000 --- a/Lang/EasyLang/Fast-Fourier-transform +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fast-Fourier-transform/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Faulhabers-formula b/Lang/EasyLang/Faulhabers-formula deleted file mode 120000 index a0587d4c22..0000000000 --- a/Lang/EasyLang/Faulhabers-formula +++ /dev/null @@ -1 +0,0 @@ -../../Task/Faulhabers-formula/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Faulhabers-triangle b/Lang/EasyLang/Faulhabers-triangle deleted file mode 120000 index 0ced82832c..0000000000 --- a/Lang/EasyLang/Faulhabers-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Faulhabers-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Feigenbaum-constant-calculation b/Lang/EasyLang/Feigenbaum-constant-calculation deleted file mode 120000 index 0bc8f6925c..0000000000 --- a/Lang/EasyLang/Feigenbaum-constant-calculation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Feigenbaum-constant-calculation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fermat-numbers b/Lang/EasyLang/Fermat-numbers deleted file mode 120000 index 0bf9bf359c..0000000000 --- a/Lang/EasyLang/Fermat-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fermat-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fibonacci-n-step-number-sequences b/Lang/EasyLang/Fibonacci-n-step-number-sequences deleted file mode 120000 index 164fc80462..0000000000 --- a/Lang/EasyLang/Fibonacci-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-n-step-number-sequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fibonacci-word b/Lang/EasyLang/Fibonacci-word deleted file mode 120000 index a05179a237..0000000000 --- a/Lang/EasyLang/Fibonacci-word +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-word/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fibonacci-word-fractal b/Lang/EasyLang/Fibonacci-word-fractal deleted file mode 120000 index d075c27d88..0000000000 --- a/Lang/EasyLang/Fibonacci-word-fractal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fibonacci-word-fractal/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/File-extension-is-in-extensions-list b/Lang/EasyLang/File-extension-is-in-extensions-list deleted file mode 120000 index 6f2ec30cd2..0000000000 --- a/Lang/EasyLang/File-extension-is-in-extensions-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-extension-is-in-extensions-list/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-Chess960-starting-position-identifier b/Lang/EasyLang/Find-Chess960-starting-position-identifier deleted file mode 120000 index 74db5136c0..0000000000 --- a/Lang/EasyLang/Find-Chess960-starting-position-identifier +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-Chess960-starting-position-identifier/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-common-directory-path b/Lang/EasyLang/Find-common-directory-path deleted file mode 120000 index 2f1337d020..0000000000 --- a/Lang/EasyLang/Find-common-directory-path +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-common-directory-path/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-if-a-point-is-within-a-triangle b/Lang/EasyLang/Find-if-a-point-is-within-a-triangle deleted file mode 120000 index cd1bb80075..0000000000 --- a/Lang/EasyLang/Find-if-a-point-is-within-a-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-if-a-point-is-within-a-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-palindromic-numbers-in-both-binary-and-ternary-bases b/Lang/EasyLang/Find-palindromic-numbers-in-both-binary-and-ternary-bases deleted file mode 120000 index 3aca354001..0000000000 --- a/Lang/EasyLang/Find-palindromic-numbers-in-both-binary-and-ternary-bases +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-palindromic-numbers-in-both-binary-and-ternary-bases/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-the-intersection-of-a-line-with-a-plane b/Lang/EasyLang/Find-the-intersection-of-a-line-with-a-plane deleted file mode 120000 index ec7aff0f03..0000000000 --- a/Lang/EasyLang/Find-the-intersection-of-a-line-with-a-plane +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-intersection-of-a-line-with-a-plane/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-the-intersection-of-two-lines b/Lang/EasyLang/Find-the-intersection-of-two-lines deleted file mode 120000 index cffadf31bc..0000000000 --- a/Lang/EasyLang/Find-the-intersection-of-two-lines +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-intersection-of-two-lines/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-the-last-Sunday-of-each-month b/Lang/EasyLang/Find-the-last-Sunday-of-each-month deleted file mode 120000 index 967f81859a..0000000000 --- a/Lang/EasyLang/Find-the-last-Sunday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-last-Sunday-of-each-month/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-the-missing-permutation b/Lang/EasyLang/Find-the-missing-permutation deleted file mode 120000 index 062fcb8e1c..0000000000 --- a/Lang/EasyLang/Find-the-missing-permutation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-missing-permutation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/First-perfect-square-in-base-n-with-n-unique-digits b/Lang/EasyLang/First-perfect-square-in-base-n-with-n-unique-digits deleted file mode 120000 index cef6960be2..0000000000 --- a/Lang/EasyLang/First-perfect-square-in-base-n-with-n-unique-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/First-perfect-square-in-base-n-with-n-unique-digits/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/First-power-of-2-that-has-leading-decimal-digits-of-12 b/Lang/EasyLang/First-power-of-2-that-has-leading-decimal-digits-of-12 deleted file mode 120000 index 0246bc2ab7..0000000000 --- a/Lang/EasyLang/First-power-of-2-that-has-leading-decimal-digits-of-12 +++ /dev/null @@ -1 +0,0 @@ -../../Task/First-power-of-2-that-has-leading-decimal-digits-of-12/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Five-weekends b/Lang/EasyLang/Five-weekends deleted file mode 120000 index 1465857f84..0000000000 --- a/Lang/EasyLang/Five-weekends +++ /dev/null @@ -1 +0,0 @@ -../../Task/Five-weekends/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fivenum b/Lang/EasyLang/Fivenum deleted file mode 120000 index 48a3ffd336..0000000000 --- a/Lang/EasyLang/Fivenum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fivenum/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Flow-control-structures b/Lang/EasyLang/Flow-control-structures deleted file mode 120000 index c22991f348..0000000000 --- a/Lang/EasyLang/Flow-control-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Flow-control-structures/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Floyd-Warshall-algorithm b/Lang/EasyLang/Floyd-Warshall-algorithm deleted file mode 120000 index 3210a33bb1..0000000000 --- a/Lang/EasyLang/Floyd-Warshall-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyd-Warshall-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Floyds-triangle b/Lang/EasyLang/Floyds-triangle deleted file mode 120000 index 59c29e05b0..0000000000 --- a/Lang/EasyLang/Floyds-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyds-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fortunate-numbers b/Lang/EasyLang/Fortunate-numbers deleted file mode 120000 index 2c6e02874b..0000000000 --- a/Lang/EasyLang/Fortunate-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fortunate-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Forward-difference b/Lang/EasyLang/Forward-difference deleted file mode 120000 index 12de7eedb0..0000000000 --- a/Lang/EasyLang/Forward-difference +++ /dev/null @@ -1 +0,0 @@ -../../Task/Forward-difference/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Four-bit-adder b/Lang/EasyLang/Four-bit-adder deleted file mode 120000 index aa95757586..0000000000 --- a/Lang/EasyLang/Four-bit-adder +++ /dev/null @@ -1 +0,0 @@ -../../Task/Four-bit-adder/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Four-is-magic b/Lang/EasyLang/Four-is-magic deleted file mode 120000 index 12775a7d16..0000000000 --- a/Lang/EasyLang/Four-is-magic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Four-is-magic/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fraction-reduction b/Lang/EasyLang/Fraction-reduction deleted file mode 120000 index 61af524020..0000000000 --- a/Lang/EasyLang/Fraction-reduction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fraction-reduction/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fractran b/Lang/EasyLang/Fractran deleted file mode 120000 index 431453ab79..0000000000 --- a/Lang/EasyLang/Fractran +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fractran/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/French-Republican-calendar b/Lang/EasyLang/French-Republican-calendar deleted file mode 120000 index 63cacd897e..0000000000 --- a/Lang/EasyLang/French-Republican-calendar +++ /dev/null @@ -1 +0,0 @@ -../../Task/French-Republican-calendar/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Function-prototype b/Lang/EasyLang/Function-prototype deleted file mode 120000 index d56b3a5da3..0000000000 --- a/Lang/EasyLang/Function-prototype +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-prototype/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fusc-sequence b/Lang/EasyLang/Fusc-sequence deleted file mode 120000 index d1a5af47df..0000000000 --- a/Lang/EasyLang/Fusc-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fusc-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Galton-box-animation b/Lang/EasyLang/Galton-box-animation deleted file mode 120000 index afd1fd5e74..0000000000 --- a/Lang/EasyLang/Galton-box-animation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Galton-box-animation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Gamma-function b/Lang/EasyLang/Gamma-function deleted file mode 120000 index 16283d7c69..0000000000 --- a/Lang/EasyLang/Gamma-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gamma-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Gapful-numbers b/Lang/EasyLang/Gapful-numbers deleted file mode 120000 index 2017e0e11f..0000000000 --- a/Lang/EasyLang/Gapful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gapful-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Gauss-Jordan-matrix-inversion b/Lang/EasyLang/Gauss-Jordan-matrix-inversion deleted file mode 120000 index 4edf8b08eb..0000000000 --- a/Lang/EasyLang/Gauss-Jordan-matrix-inversion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gauss-Jordan-matrix-inversion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Gaussian-elimination b/Lang/EasyLang/Gaussian-elimination deleted file mode 120000 index 3600b047b6..0000000000 --- a/Lang/EasyLang/Gaussian-elimination +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gaussian-elimination/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/General-FizzBuzz b/Lang/EasyLang/General-FizzBuzz deleted file mode 120000 index c74a1c59eb..0000000000 --- a/Lang/EasyLang/General-FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/General-FizzBuzz/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Generate-Chess960-starting-position b/Lang/EasyLang/Generate-Chess960-starting-position deleted file mode 120000 index 7aebe5f336..0000000000 --- a/Lang/EasyLang/Generate-Chess960-starting-position +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-Chess960-starting-position/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Gray-code b/Lang/EasyLang/Gray-code deleted file mode 120000 index 0807a99d28..0000000000 --- a/Lang/EasyLang/Gray-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gray-code/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Greatest-subsequential-sum b/Lang/EasyLang/Greatest-subsequential-sum deleted file mode 120000 index 679d3c6deb..0000000000 --- a/Lang/EasyLang/Greatest-subsequential-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-subsequential-sum/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Guess-the-number-With-feedback-player- b/Lang/EasyLang/Guess-the-number-With-feedback-player- deleted file mode 120000 index 56ad8fd02a..0000000000 --- a/Lang/EasyLang/Guess-the-number-With-feedback-player- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player-/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hailstone-sequence b/Lang/EasyLang/Hailstone-sequence deleted file mode 120000 index 164d38791c..0000000000 --- a/Lang/EasyLang/Hailstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hailstone-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Halt-and-catch-fire b/Lang/EasyLang/Halt-and-catch-fire deleted file mode 120000 index fe61f64c40..0000000000 --- a/Lang/EasyLang/Halt-and-catch-fire +++ /dev/null @@ -1 +0,0 @@ -../../Task/Halt-and-catch-fire/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hamming-numbers b/Lang/EasyLang/Hamming-numbers deleted file mode 120000 index 6f52ef2c78..0000000000 --- a/Lang/EasyLang/Hamming-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hamming-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Happy-numbers b/Lang/EasyLang/Happy-numbers deleted file mode 120000 index c4ab4d4ef3..0000000000 --- a/Lang/EasyLang/Happy-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Happy-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Harmonic-series b/Lang/EasyLang/Harmonic-series deleted file mode 120000 index 06ca0ca4a5..0000000000 --- a/Lang/EasyLang/Harmonic-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harmonic-series/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Harshad-or-Niven-series b/Lang/EasyLang/Harshad-or-Niven-series deleted file mode 120000 index 3452b1b733..0000000000 --- a/Lang/EasyLang/Harshad-or-Niven-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Harshad-or-Niven-series/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hash-from-two-arrays b/Lang/EasyLang/Hash-from-two-arrays deleted file mode 120000 index 0d148a2df3..0000000000 --- a/Lang/EasyLang/Hash-from-two-arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hash-from-two-arrays/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Haversine-formula b/Lang/EasyLang/Haversine-formula deleted file mode 120000 index add760760e..0000000000 --- a/Lang/EasyLang/Haversine-formula +++ /dev/null @@ -1 +0,0 @@ -../../Task/Haversine-formula/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Here-document b/Lang/EasyLang/Here-document deleted file mode 120000 index 55d2509af0..0000000000 --- a/Lang/EasyLang/Here-document +++ /dev/null @@ -1 +0,0 @@ -../../Task/Here-document/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Heronian-triangles b/Lang/EasyLang/Heronian-triangles deleted file mode 120000 index 8656dc59f0..0000000000 --- a/Lang/EasyLang/Heronian-triangles +++ /dev/null @@ -1 +0,0 @@ -../../Task/Heronian-triangles/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hex-words b/Lang/EasyLang/Hex-words deleted file mode 120000 index 0d39e2eee9..0000000000 --- a/Lang/EasyLang/Hex-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hex-words/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hilbert-curve b/Lang/EasyLang/Hilbert-curve deleted file mode 120000 index ff5cdcedf4..0000000000 --- a/Lang/EasyLang/Hilbert-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hilbert-curve/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hofstadter-Conway-$10-000-sequence b/Lang/EasyLang/Hofstadter-Conway-$10-000-sequence deleted file mode 120000 index 13e3a43372..0000000000 --- a/Lang/EasyLang/Hofstadter-Conway-$10-000-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hofstadter-Conway-$10-000-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hofstadter-Figure-Figure-sequences b/Lang/EasyLang/Hofstadter-Figure-Figure-sequences deleted file mode 120000 index d5a34b275d..0000000000 --- a/Lang/EasyLang/Hofstadter-Figure-Figure-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hofstadter-Figure-Figure-sequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hofstadter-Q-sequence b/Lang/EasyLang/Hofstadter-Q-sequence deleted file mode 120000 index f26e722f60..0000000000 --- a/Lang/EasyLang/Hofstadter-Q-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hofstadter-Q-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Honeycombs b/Lang/EasyLang/Honeycombs deleted file mode 120000 index 5885102888..0000000000 --- a/Lang/EasyLang/Honeycombs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Honeycombs/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Horners-rule-for-polynomial-evaluation b/Lang/EasyLang/Horners-rule-for-polynomial-evaluation deleted file mode 120000 index c1ae14c36b..0000000000 --- a/Lang/EasyLang/Horners-rule-for-polynomial-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Horners-rule-for-polynomial-evaluation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Humble-numbers b/Lang/EasyLang/Humble-numbers deleted file mode 120000 index 8f9c0f4eae..0000000000 --- a/Lang/EasyLang/Humble-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Humble-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hunt-the-Wumpus b/Lang/EasyLang/Hunt-the-Wumpus deleted file mode 120000 index 8a2489577d..0000000000 --- a/Lang/EasyLang/Hunt-the-Wumpus +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hunt-the-Wumpus/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/IBAN b/Lang/EasyLang/IBAN deleted file mode 120000 index 961014b963..0000000000 --- a/Lang/EasyLang/IBAN +++ /dev/null @@ -1 +0,0 @@ -../../Task/IBAN/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Identity-matrix b/Lang/EasyLang/Identity-matrix deleted file mode 120000 index 301b6d2c90..0000000000 --- a/Lang/EasyLang/Identity-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Identity-matrix/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols b/Lang/EasyLang/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols deleted file mode 120000 index ff1573925b..0000000000 --- a/Lang/EasyLang/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Idiomatically-determine-all-the-lowercase-and-uppercase-letters b/Lang/EasyLang/Idiomatically-determine-all-the-lowercase-and-uppercase-letters deleted file mode 120000 index 116f99247d..0000000000 --- a/Lang/EasyLang/Idiomatically-determine-all-the-lowercase-and-uppercase-letters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Im-a-software-engineer-get-me-out-of-here b/Lang/EasyLang/Im-a-software-engineer-get-me-out-of-here deleted file mode 120000 index 70ace224d9..0000000000 --- a/Lang/EasyLang/Im-a-software-engineer-get-me-out-of-here +++ /dev/null @@ -1 +0,0 @@ -../../Task/Im-a-software-engineer-get-me-out-of-here/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Image-noise b/Lang/EasyLang/Image-noise deleted file mode 120000 index da8d100ac1..0000000000 --- a/Lang/EasyLang/Image-noise +++ /dev/null @@ -1 +0,0 @@ -../../Task/Image-noise/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Increasing-gaps-between-consecutive-Niven-numbers b/Lang/EasyLang/Increasing-gaps-between-consecutive-Niven-numbers deleted file mode 120000 index 2b4a5b83cc..0000000000 --- a/Lang/EasyLang/Increasing-gaps-between-consecutive-Niven-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increasing-gaps-between-consecutive-Niven-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Infinity b/Lang/EasyLang/Infinity deleted file mode 120000 index 56d94eeddb..0000000000 --- a/Lang/EasyLang/Infinity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Infinity/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Isograms-and-heterograms b/Lang/EasyLang/Isograms-and-heterograms deleted file mode 120000 index 44f53b57ff..0000000000 --- a/Lang/EasyLang/Isograms-and-heterograms +++ /dev/null @@ -1 +0,0 @@ -../../Task/Isograms-and-heterograms/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Isqrt-integer-square-root-of-X b/Lang/EasyLang/Isqrt-integer-square-root-of-X deleted file mode 120000 index 79ccfaeb51..0000000000 --- a/Lang/EasyLang/Isqrt-integer-square-root-of-X +++ /dev/null @@ -1 +0,0 @@ -../../Task/Isqrt-integer-square-root-of-X/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Iterated-digits-squaring b/Lang/EasyLang/Iterated-digits-squaring deleted file mode 120000 index 193be9fcba..0000000000 --- a/Lang/EasyLang/Iterated-digits-squaring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Iterated-digits-squaring/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jacobi-symbol b/Lang/EasyLang/Jacobi-symbol deleted file mode 120000 index fec464ee0d..0000000000 --- a/Lang/EasyLang/Jacobi-symbol +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobi-symbol/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jacobsthal-numbers b/Lang/EasyLang/Jacobsthal-numbers deleted file mode 120000 index 9469db92c2..0000000000 --- a/Lang/EasyLang/Jacobsthal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobsthal-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jaro-Winkler-distance b/Lang/EasyLang/Jaro-Winkler-distance deleted file mode 120000 index 727f74b880..0000000000 --- a/Lang/EasyLang/Jaro-Winkler-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jaro-Winkler-distance/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jaro-similarity b/Lang/EasyLang/Jaro-similarity deleted file mode 120000 index d630573e8e..0000000000 --- a/Lang/EasyLang/Jaro-similarity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jaro-similarity/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jewels-and-stones b/Lang/EasyLang/Jewels-and-stones deleted file mode 120000 index 79405be237..0000000000 --- a/Lang/EasyLang/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jordan-P-lya-numbers b/Lang/EasyLang/Jordan-P-lya-numbers deleted file mode 120000 index dda236d7e7..0000000000 --- a/Lang/EasyLang/Jordan-P-lya-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jordan-P-lya-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/JortSort b/Lang/EasyLang/JortSort deleted file mode 120000 index 69c9d425de..0000000000 --- a/Lang/EasyLang/JortSort +++ /dev/null @@ -1 +0,0 @@ -../../Task/JortSort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Juggler-sequence b/Lang/EasyLang/Juggler-sequence deleted file mode 120000 index a501986168..0000000000 --- a/Lang/EasyLang/Juggler-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Juggler-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/K-means++-clustering b/Lang/EasyLang/K-means++-clustering deleted file mode 120000 index 9c59e662f6..0000000000 --- a/Lang/EasyLang/K-means++-clustering +++ /dev/null @@ -1 +0,0 @@ -../../Task/K-means++-clustering/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kaprekar-numbers b/Lang/EasyLang/Kaprekar-numbers deleted file mode 120000 index 8b04bae44a..0000000000 --- a/Lang/EasyLang/Kaprekar-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kaprekar-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kernighans-large-earthquake-problem b/Lang/EasyLang/Kernighans-large-earthquake-problem deleted file mode 120000 index 3ab1e4458e..0000000000 --- a/Lang/EasyLang/Kernighans-large-earthquake-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kernighans-large-earthquake-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Keyboard-input-Keypress-check b/Lang/EasyLang/Keyboard-input-Keypress-check deleted file mode 120000 index 749a963892..0000000000 --- a/Lang/EasyLang/Keyboard-input-Keypress-check +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Keypress-check/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/EasyLang/Keyboard-input-Obtain-a-Y-or-N-response deleted file mode 120000 index afc72ecd9d..0000000000 --- a/Lang/EasyLang/Keyboard-input-Obtain-a-Y-or-N-response +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Obtain-a-Y-or-N-response/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Knapsack-problem-Bounded b/Lang/EasyLang/Knapsack-problem-Bounded deleted file mode 120000 index d0f7a40df2..0000000000 --- a/Lang/EasyLang/Knapsack-problem-Bounded +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-Bounded/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Knapsack-problem-Continuous b/Lang/EasyLang/Knapsack-problem-Continuous deleted file mode 120000 index a54e4a1363..0000000000 --- a/Lang/EasyLang/Knapsack-problem-Continuous +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-Continuous/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Knapsack-problem-Unbounded b/Lang/EasyLang/Knapsack-problem-Unbounded deleted file mode 120000 index feaf22d24e..0000000000 --- a/Lang/EasyLang/Knapsack-problem-Unbounded +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knapsack-problem-Unbounded/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Knights-tour b/Lang/EasyLang/Knights-tour deleted file mode 120000 index c3c72273c2..0000000000 --- a/Lang/EasyLang/Knights-tour +++ /dev/null @@ -1 +0,0 @@ -../../Task/Knights-tour/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kolakoski-sequence b/Lang/EasyLang/Kolakoski-sequence deleted file mode 120000 index 0d808caea4..0000000000 --- a/Lang/EasyLang/Kolakoski-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kolakoski-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kosaraju b/Lang/EasyLang/Kosaraju deleted file mode 120000 index 84b9e66a67..0000000000 --- a/Lang/EasyLang/Kosaraju +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kosaraju/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kronecker-product b/Lang/EasyLang/Kronecker-product deleted file mode 120000 index 1246c0ce28..0000000000 --- a/Lang/EasyLang/Kronecker-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kronecker-product/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kronecker-product-based-fractals b/Lang/EasyLang/Kronecker-product-based-fractals deleted file mode 120000 index 563af0ba71..0000000000 --- a/Lang/EasyLang/Kronecker-product-based-fractals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kronecker-product-based-fractals/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/LU-decomposition b/Lang/EasyLang/LU-decomposition deleted file mode 120000 index b8f8a0d85a..0000000000 --- a/Lang/EasyLang/LU-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/LU-decomposition/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Lah-numbers b/Lang/EasyLang/Lah-numbers deleted file mode 120000 index 911d26c4d0..0000000000 --- a/Lang/EasyLang/Lah-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Lah-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Largest-int-from-concatenated-ints b/Lang/EasyLang/Largest-int-from-concatenated-ints deleted file mode 120000 index 10e1335e8a..0000000000 --- a/Lang/EasyLang/Largest-int-from-concatenated-ints +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-int-from-concatenated-ints/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Largest-number-divisible-by-its-digits b/Lang/EasyLang/Largest-number-divisible-by-its-digits deleted file mode 120000 index 9d5fa3e8c6..0000000000 --- a/Lang/EasyLang/Largest-number-divisible-by-its-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Largest-number-divisible-by-its-digits/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Last-Friday-of-each-month b/Lang/EasyLang/Last-Friday-of-each-month deleted file mode 120000 index 35882f9070..0000000000 --- a/Lang/EasyLang/Last-Friday-of-each-month +++ /dev/null @@ -1 +0,0 @@ -../../Task/Last-Friday-of-each-month/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Last-letter-first-letter b/Lang/EasyLang/Last-letter-first-letter deleted file mode 120000 index 0b195a1260..0000000000 --- a/Lang/EasyLang/Last-letter-first-letter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Last-letter-first-letter/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Law-of-cosines---triples b/Lang/EasyLang/Law-of-cosines---triples deleted file mode 120000 index c863a3f9c0..0000000000 --- a/Lang/EasyLang/Law-of-cosines---triples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Law-of-cosines---triples/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Leap-year b/Lang/EasyLang/Leap-year deleted file mode 120000 index 786a015a2b..0000000000 --- a/Lang/EasyLang/Leap-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leap-year/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Least-common-multiple b/Lang/EasyLang/Least-common-multiple deleted file mode 120000 index 4e6553c21f..0000000000 --- a/Lang/EasyLang/Least-common-multiple +++ /dev/null @@ -1 +0,0 @@ -../../Task/Least-common-multiple/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Left-factorials b/Lang/EasyLang/Left-factorials deleted file mode 120000 index 99571138e4..0000000000 --- a/Lang/EasyLang/Left-factorials +++ /dev/null @@ -1 +0,0 @@ -../../Task/Left-factorials/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Legendre-prime-counting-function b/Lang/EasyLang/Legendre-prime-counting-function deleted file mode 120000 index 4b5478a288..0000000000 --- a/Lang/EasyLang/Legendre-prime-counting-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Legendre-prime-counting-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Leonardo-numbers b/Lang/EasyLang/Leonardo-numbers deleted file mode 120000 index 14bd56d652..0000000000 --- a/Lang/EasyLang/Leonardo-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Leonardo-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Letter-frequency b/Lang/EasyLang/Letter-frequency deleted file mode 120000 index a5bfe27f68..0000000000 --- a/Lang/EasyLang/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Levenshtein-distance b/Lang/EasyLang/Levenshtein-distance deleted file mode 120000 index 85d30bfcbc..0000000000 --- a/Lang/EasyLang/Levenshtein-distance +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Levenshtein-distance-Alignment b/Lang/EasyLang/Levenshtein-distance-Alignment deleted file mode 120000 index dc79306a8c..0000000000 --- a/Lang/EasyLang/Levenshtein-distance-Alignment +++ /dev/null @@ -1 +0,0 @@ -../../Task/Levenshtein-distance-Alignment/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Linear-congruential-generator b/Lang/EasyLang/Linear-congruential-generator deleted file mode 120000 index 08ba24e5b7..0000000000 --- a/Lang/EasyLang/Linear-congruential-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Linear-congruential-generator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/List-rooted-trees b/Lang/EasyLang/List-rooted-trees deleted file mode 120000 index 14cdfaa5a6..0000000000 --- a/Lang/EasyLang/List-rooted-trees +++ /dev/null @@ -1 +0,0 @@ -../../Task/List-rooted-trees/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Logistic-curve-fitting-in-epidemiology b/Lang/EasyLang/Logistic-curve-fitting-in-epidemiology deleted file mode 120000 index 265f7cdf24..0000000000 --- a/Lang/EasyLang/Logistic-curve-fitting-in-epidemiology +++ /dev/null @@ -1 +0,0 @@ -../../Task/Logistic-curve-fitting-in-epidemiology/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Long-literals-with-continuations b/Lang/EasyLang/Long-literals-with-continuations deleted file mode 120000 index ffe5aa4238..0000000000 --- a/Lang/EasyLang/Long-literals-with-continuations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-literals-with-continuations/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Long-primes b/Lang/EasyLang/Long-primes deleted file mode 120000 index 7bcfe1337a..0000000000 --- a/Lang/EasyLang/Long-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Long-year b/Lang/EasyLang/Long-year deleted file mode 120000 index c98469be44..0000000000 --- a/Lang/EasyLang/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Longest-common-subsequence b/Lang/EasyLang/Longest-common-subsequence deleted file mode 120000 index 6cc703826c..0000000000 --- a/Lang/EasyLang/Longest-common-subsequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-common-subsequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Longest-common-substring b/Lang/EasyLang/Longest-common-substring deleted file mode 120000 index dae80ce24b..0000000000 --- a/Lang/EasyLang/Longest-common-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-common-substring/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Longest-increasing-subsequence b/Lang/EasyLang/Longest-increasing-subsequence deleted file mode 120000 index eabf95f750..0000000000 --- a/Lang/EasyLang/Longest-increasing-subsequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-increasing-subsequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Look-and-say-sequence b/Lang/EasyLang/Look-and-say-sequence deleted file mode 120000 index acea496bc5..0000000000 --- a/Lang/EasyLang/Look-and-say-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Look-and-say-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Loop-over-multiple-arrays-simultaneously b/Lang/EasyLang/Loop-over-multiple-arrays-simultaneously deleted file mode 120000 index cc8922c8e4..0000000000 --- a/Lang/EasyLang/Loop-over-multiple-arrays-simultaneously +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loop-over-multiple-arrays-simultaneously/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Loops-Increment-loop-index-within-loop-body b/Lang/EasyLang/Loops-Increment-loop-index-within-loop-body deleted file mode 120000 index f96a49aa6f..0000000000 --- a/Lang/EasyLang/Loops-Increment-loop-index-within-loop-body +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Increment-loop-index-within-loop-body/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Loops-Wrong-ranges b/Lang/EasyLang/Loops-Wrong-ranges deleted file mode 120000 index d803a36357..0000000000 --- a/Lang/EasyLang/Loops-Wrong-ranges +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Wrong-ranges/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Lucas-Lehmer-test b/Lang/EasyLang/Lucas-Lehmer-test deleted file mode 120000 index 37ce43bc05..0000000000 --- a/Lang/EasyLang/Lucas-Lehmer-test +++ /dev/null @@ -1 +0,0 @@ -../../Task/Lucas-Lehmer-test/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ludic-numbers b/Lang/EasyLang/Ludic-numbers deleted file mode 120000 index 1d6fc2e015..0000000000 --- a/Lang/EasyLang/Ludic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ludic-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Luhn-test-of-credit-card-numbers b/Lang/EasyLang/Luhn-test-of-credit-card-numbers deleted file mode 120000 index 6cdbead8c8..0000000000 --- a/Lang/EasyLang/Luhn-test-of-credit-card-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Luhn-test-of-credit-card-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Lychrel-numbers b/Lang/EasyLang/Lychrel-numbers deleted file mode 120000 index a66932caaa..0000000000 --- a/Lang/EasyLang/Lychrel-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Lychrel-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/M-bius-function b/Lang/EasyLang/M-bius-function deleted file mode 120000 index 8ddd81962a..0000000000 --- a/Lang/EasyLang/M-bius-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/M-bius-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/MD4 b/Lang/EasyLang/MD4 deleted file mode 120000 index 607e4d2f65..0000000000 --- a/Lang/EasyLang/MD4 +++ /dev/null @@ -1 +0,0 @@ -../../Task/MD4/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/MD5 b/Lang/EasyLang/MD5 deleted file mode 120000 index 1974a8639d..0000000000 --- a/Lang/EasyLang/MD5 +++ /dev/null @@ -1 +0,0 @@ -../../Task/MD5/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Mad-Libs b/Lang/EasyLang/Mad-Libs deleted file mode 120000 index 80e4f5b2e7..0000000000 --- a/Lang/EasyLang/Mad-Libs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mad-Libs/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Magic-8-ball b/Lang/EasyLang/Magic-8-ball deleted file mode 120000 index 27f204a23e..0000000000 --- a/Lang/EasyLang/Magic-8-ball +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-8-ball/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Magic-constant b/Lang/EasyLang/Magic-constant deleted file mode 120000 index e7bddcf034..0000000000 --- a/Lang/EasyLang/Magic-constant +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-constant/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Magic-squares-of-doubly-even-order b/Lang/EasyLang/Magic-squares-of-doubly-even-order deleted file mode 120000 index b5f41f3cca..0000000000 --- a/Lang/EasyLang/Magic-squares-of-doubly-even-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-doubly-even-order/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Magic-squares-of-odd-order b/Lang/EasyLang/Magic-squares-of-odd-order deleted file mode 120000 index c1250ae803..0000000000 --- a/Lang/EasyLang/Magic-squares-of-odd-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-odd-order/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Magic-squares-of-singly-even-order b/Lang/EasyLang/Magic-squares-of-singly-even-order deleted file mode 120000 index bffad4e9d9..0000000000 --- a/Lang/EasyLang/Magic-squares-of-singly-even-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-squares-of-singly-even-order/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Magnanimous-numbers b/Lang/EasyLang/Magnanimous-numbers deleted file mode 120000 index b244e9bef4..0000000000 --- a/Lang/EasyLang/Magnanimous-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magnanimous-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Map-range b/Lang/EasyLang/Map-range deleted file mode 120000 index 7f2fe886c3..0000000000 --- a/Lang/EasyLang/Map-range +++ /dev/null @@ -1 +0,0 @@ -../../Task/Map-range/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Matrix-chain-multiplication b/Lang/EasyLang/Matrix-chain-multiplication deleted file mode 120000 index 49b2582836..0000000000 --- a/Lang/EasyLang/Matrix-chain-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-chain-multiplication/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Matrix-exponentiation-operator b/Lang/EasyLang/Matrix-exponentiation-operator deleted file mode 120000 index ffeb77ddad..0000000000 --- a/Lang/EasyLang/Matrix-exponentiation-operator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-exponentiation-operator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Matrix-multiplication b/Lang/EasyLang/Matrix-multiplication deleted file mode 120000 index 210bca9988..0000000000 --- a/Lang/EasyLang/Matrix-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-multiplication/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Matrix-transposition b/Lang/EasyLang/Matrix-transposition deleted file mode 120000 index 8c003a6e84..0000000000 --- a/Lang/EasyLang/Matrix-transposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Matrix-transposition/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Maximum-triangle-path-sum b/Lang/EasyLang/Maximum-triangle-path-sum deleted file mode 120000 index eed040fd4d..0000000000 --- a/Lang/EasyLang/Maximum-triangle-path-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Maximum-triangle-path-sum/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Mayan-numerals b/Lang/EasyLang/Mayan-numerals deleted file mode 120000 index 101692428a..0000000000 --- a/Lang/EasyLang/Mayan-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mayan-numerals/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/McNuggets-problem b/Lang/EasyLang/McNuggets-problem deleted file mode 120000 index 4eb97330c9..0000000000 --- a/Lang/EasyLang/McNuggets-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/McNuggets-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Merge-and-aggregate-datasets b/Lang/EasyLang/Merge-and-aggregate-datasets deleted file mode 120000 index 4240a68719..0000000000 --- a/Lang/EasyLang/Merge-and-aggregate-datasets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Merge-and-aggregate-datasets/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Mertens-function b/Lang/EasyLang/Mertens-function deleted file mode 120000 index 9535db88d7..0000000000 --- a/Lang/EasyLang/Mertens-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mertens-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Mian-Chowla-sequence b/Lang/EasyLang/Mian-Chowla-sequence deleted file mode 120000 index 314aaad4b1..0000000000 --- a/Lang/EasyLang/Mian-Chowla-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mian-Chowla-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Mind-boggling-card-trick b/Lang/EasyLang/Mind-boggling-card-trick deleted file mode 120000 index ae422a355d..0000000000 --- a/Lang/EasyLang/Mind-boggling-card-trick +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mind-boggling-card-trick/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/EasyLang/Minimum-multiple-of-m-where-digital-sum-equals-m deleted file mode 120000 index 8adaf5f3b6..0000000000 --- a/Lang/EasyLang/Minimum-multiple-of-m-where-digital-sum-equals-m +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Minkowski-question-mark-function b/Lang/EasyLang/Minkowski-question-mark-function deleted file mode 120000 index e4df814cca..0000000000 --- a/Lang/EasyLang/Minkowski-question-mark-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minkowski-question-mark-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Modified-random-distribution b/Lang/EasyLang/Modified-random-distribution deleted file mode 120000 index 127bc0bcb6..0000000000 --- a/Lang/EasyLang/Modified-random-distribution +++ /dev/null @@ -1 +0,0 @@ -../../Task/Modified-random-distribution/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Modular-exponentiation b/Lang/EasyLang/Modular-exponentiation deleted file mode 120000 index 7257cc430f..0000000000 --- a/Lang/EasyLang/Modular-exponentiation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Modular-exponentiation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Monty-Hall-problem b/Lang/EasyLang/Monty-Hall-problem deleted file mode 120000 index e126dc0d13..0000000000 --- a/Lang/EasyLang/Monty-Hall-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monty-Hall-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Motzkin-numbers b/Lang/EasyLang/Motzkin-numbers deleted file mode 120000 index f45ac71ffe..0000000000 --- a/Lang/EasyLang/Motzkin-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Motzkin-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Move-to-front-algorithm b/Lang/EasyLang/Move-to-front-algorithm deleted file mode 120000 index 8c3f8fe7f9..0000000000 --- a/Lang/EasyLang/Move-to-front-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Move-to-front-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Multi-base-primes b/Lang/EasyLang/Multi-base-primes deleted file mode 120000 index 0b06b01c9e..0000000000 --- a/Lang/EasyLang/Multi-base-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multi-base-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Multifactorial b/Lang/EasyLang/Multifactorial deleted file mode 120000 index f917509ca1..0000000000 --- a/Lang/EasyLang/Multifactorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multifactorial/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Multisplit b/Lang/EasyLang/Multisplit deleted file mode 120000 index 3f480eaeea..0000000000 --- a/Lang/EasyLang/Multisplit +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multisplit/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Munchausen-numbers b/Lang/EasyLang/Munchausen-numbers deleted file mode 120000 index 82315ebcc3..0000000000 --- a/Lang/EasyLang/Munchausen-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munchausen-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Mutual-recursion b/Lang/EasyLang/Mutual-recursion deleted file mode 120000 index 9dbd653e23..0000000000 --- a/Lang/EasyLang/Mutual-recursion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mutual-recursion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Negative-base-numbers b/Lang/EasyLang/Negative-base-numbers deleted file mode 120000 index 750b2fa4de..0000000000 --- a/Lang/EasyLang/Negative-base-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Negative-base-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Nested-function b/Lang/EasyLang/Nested-function deleted file mode 120000 index 3d6f80739f..0000000000 --- a/Lang/EasyLang/Nested-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nested-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Next-highest-int-from-digits b/Lang/EasyLang/Next-highest-int-from-digits deleted file mode 120000 index b3f44119a8..0000000000 --- a/Lang/EasyLang/Next-highest-int-from-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Next-highest-int-from-digits/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Non-continuous-subsequences b/Lang/EasyLang/Non-continuous-subsequences deleted file mode 120000 index 1ddebfbef7..0000000000 --- a/Lang/EasyLang/Non-continuous-subsequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Non-continuous-subsequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Non-decimal-radices-Convert b/Lang/EasyLang/Non-decimal-radices-Convert deleted file mode 120000 index e286a4396d..0000000000 --- a/Lang/EasyLang/Non-decimal-radices-Convert +++ /dev/null @@ -1 +0,0 @@ -../../Task/Non-decimal-radices-Convert/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Non-decimal-radices-Input b/Lang/EasyLang/Non-decimal-radices-Input deleted file mode 120000 index 15845b7041..0000000000 --- a/Lang/EasyLang/Non-decimal-radices-Input +++ /dev/null @@ -1 +0,0 @@ -../../Task/Non-decimal-radices-Input/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Nonoblock b/Lang/EasyLang/Nonoblock deleted file mode 120000 index e2c27bd166..0000000000 --- a/Lang/EasyLang/Nonoblock +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nonoblock/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Number-names b/Lang/EasyLang/Number-names deleted file mode 120000 index abedf4dd40..0000000000 --- a/Lang/EasyLang/Number-names +++ /dev/null @@ -1 +0,0 @@ -../../Task/Number-names/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Number-reversal-game b/Lang/EasyLang/Number-reversal-game deleted file mode 120000 index a55399f2e0..0000000000 --- a/Lang/EasyLang/Number-reversal-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Number-reversal-game/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/EasyLang/Numbers-which-are-not-the-sum-of-distinct-squares deleted file mode 120000 index b728c3fcbc..0000000000 --- a/Lang/EasyLang/Numbers-which-are-not-the-sum-of-distinct-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors b/Lang/EasyLang/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors deleted file mode 120000 index 9d8dc2f2d3..0000000000 --- a/Lang/EasyLang/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Numbers-with-equal-rises-and-falls b/Lang/EasyLang/Numbers-with-equal-rises-and-falls deleted file mode 120000 index 56cab1b4aa..0000000000 --- a/Lang/EasyLang/Numbers-with-equal-rises-and-falls +++ /dev/null @@ -1 +0,0 @@ -../../Task/Numbers-with-equal-rises-and-falls/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Odd-word-problem b/Lang/EasyLang/Odd-word-problem deleted file mode 120000 index 0886623884..0000000000 --- a/Lang/EasyLang/Odd-word-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Odd-word-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Old-Russian-measure-of-length b/Lang/EasyLang/Old-Russian-measure-of-length deleted file mode 120000 index f293c18a0a..0000000000 --- a/Lang/EasyLang/Old-Russian-measure-of-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/Old-Russian-measure-of-length/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Old-lady-swallowed-a-fly b/Lang/EasyLang/Old-lady-swallowed-a-fly deleted file mode 120000 index f3a3472099..0000000000 --- a/Lang/EasyLang/Old-lady-swallowed-a-fly +++ /dev/null @@ -1 +0,0 @@ -../../Task/Old-lady-swallowed-a-fly/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/One-dimensional-cellular-automata b/Lang/EasyLang/One-dimensional-cellular-automata deleted file mode 120000 index 6cef842f96..0000000000 --- a/Lang/EasyLang/One-dimensional-cellular-automata +++ /dev/null @@ -1 +0,0 @@ -../../Task/One-dimensional-cellular-automata/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/One-of-n-lines-in-a-file b/Lang/EasyLang/One-of-n-lines-in-a-file deleted file mode 120000 index 683c0899da..0000000000 --- a/Lang/EasyLang/One-of-n-lines-in-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/One-of-n-lines-in-a-file/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/OpenWebNet-password b/Lang/EasyLang/OpenWebNet-password deleted file mode 120000 index 1cfc17e776..0000000000 --- a/Lang/EasyLang/OpenWebNet-password +++ /dev/null @@ -1 +0,0 @@ -../../Task/OpenWebNet-password/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Order-by-pair-comparisons b/Lang/EasyLang/Order-by-pair-comparisons deleted file mode 120000 index 78fc8f28e3..0000000000 --- a/Lang/EasyLang/Order-by-pair-comparisons +++ /dev/null @@ -1 +0,0 @@ -../../Task/Order-by-pair-comparisons/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Order-disjoint-list-items b/Lang/EasyLang/Order-disjoint-list-items deleted file mode 120000 index bd0f2b89f9..0000000000 --- a/Lang/EasyLang/Order-disjoint-list-items +++ /dev/null @@ -1 +0,0 @@ -../../Task/Order-disjoint-list-items/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Order-two-numerical-lists b/Lang/EasyLang/Order-two-numerical-lists deleted file mode 120000 index 0574c3c6db..0000000000 --- a/Lang/EasyLang/Order-two-numerical-lists +++ /dev/null @@ -1 +0,0 @@ -../../Task/Order-two-numerical-lists/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ordered-words b/Lang/EasyLang/Ordered-words deleted file mode 120000 index 284c4e7df2..0000000000 --- a/Lang/EasyLang/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ormiston-triples b/Lang/EasyLang/Ormiston-triples deleted file mode 120000 index de3ff3dcf1..0000000000 --- a/Lang/EasyLang/Ormiston-triples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ormiston-triples/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Own-digits-power-sum b/Lang/EasyLang/Own-digits-power-sum deleted file mode 120000 index 2d5efd33b1..0000000000 --- a/Lang/EasyLang/Own-digits-power-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Own-digits-power-sum/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Padovan-n-step-number-sequences b/Lang/EasyLang/Padovan-n-step-number-sequences deleted file mode 120000 index 3c37f1b5a3..0000000000 --- a/Lang/EasyLang/Padovan-n-step-number-sequences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Padovan-n-step-number-sequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Padovan-sequence b/Lang/EasyLang/Padovan-sequence deleted file mode 120000 index d568888890..0000000000 --- a/Lang/EasyLang/Padovan-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Padovan-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Palindrome-dates b/Lang/EasyLang/Palindrome-dates deleted file mode 120000 index a27c75b0d5..0000000000 --- a/Lang/EasyLang/Palindrome-dates +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-dates/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Palindrome-detection b/Lang/EasyLang/Palindrome-detection deleted file mode 120000 index 0bc00641f5..0000000000 --- a/Lang/EasyLang/Palindrome-detection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-detection/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pangram-checker b/Lang/EasyLang/Pangram-checker deleted file mode 120000 index f7779ae2cf..0000000000 --- a/Lang/EasyLang/Pangram-checker +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pangram-checker/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Paraffins b/Lang/EasyLang/Paraffins deleted file mode 120000 index 954e9b549e..0000000000 --- a/Lang/EasyLang/Paraffins +++ /dev/null @@ -1 +0,0 @@ -../../Task/Paraffins/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Parsing-RPN-calculator-algorithm b/Lang/EasyLang/Parsing-RPN-calculator-algorithm deleted file mode 120000 index 4c308dc876..0000000000 --- a/Lang/EasyLang/Parsing-RPN-calculator-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parsing-RPN-calculator-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Particle-fountain b/Lang/EasyLang/Particle-fountain deleted file mode 120000 index df8fc026b9..0000000000 --- a/Lang/EasyLang/Particle-fountain +++ /dev/null @@ -1 +0,0 @@ -../../Task/Particle-fountain/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Partition-an-integer-x-into-n-primes b/Lang/EasyLang/Partition-an-integer-x-into-n-primes deleted file mode 120000 index 21cc93eeed..0000000000 --- a/Lang/EasyLang/Partition-an-integer-x-into-n-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-an-integer-x-into-n-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Partition-function-P b/Lang/EasyLang/Partition-function-P deleted file mode 120000 index 07b0e608d7..0000000000 --- a/Lang/EasyLang/Partition-function-P +++ /dev/null @@ -1 +0,0 @@ -../../Task/Partition-function-P/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pascal-matrix-generation b/Lang/EasyLang/Pascal-matrix-generation deleted file mode 120000 index 2a45a12baf..0000000000 --- a/Lang/EasyLang/Pascal-matrix-generation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pascal-matrix-generation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pascals-triangle b/Lang/EasyLang/Pascals-triangle deleted file mode 120000 index 1c14b19dad..0000000000 --- a/Lang/EasyLang/Pascals-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pascals-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pascals-triangle-Puzzle b/Lang/EasyLang/Pascals-triangle-Puzzle deleted file mode 120000 index bb3b35817e..0000000000 --- a/Lang/EasyLang/Pascals-triangle-Puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pascals-triangle-Puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Password-generator b/Lang/EasyLang/Password-generator deleted file mode 120000 index 004d74f550..0000000000 --- a/Lang/EasyLang/Password-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Password-generator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pathological-floating-point-problems b/Lang/EasyLang/Pathological-floating-point-problems deleted file mode 120000 index feb17cf372..0000000000 --- a/Lang/EasyLang/Pathological-floating-point-problems +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pathological-floating-point-problems/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Peano-curve b/Lang/EasyLang/Peano-curve deleted file mode 120000 index 5f0f6138e3..0000000000 --- a/Lang/EasyLang/Peano-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Peano-curve/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Penneys-game b/Lang/EasyLang/Penneys-game deleted file mode 120000 index 8a534b3c6f..0000000000 --- a/Lang/EasyLang/Penneys-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Penneys-game/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Percolation-Mean-cluster-density b/Lang/EasyLang/Percolation-Mean-cluster-density deleted file mode 120000 index 5231594fc4..0000000000 --- a/Lang/EasyLang/Percolation-Mean-cluster-density +++ /dev/null @@ -1 +0,0 @@ -../../Task/Percolation-Mean-cluster-density/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Percolation-Site-percolation b/Lang/EasyLang/Percolation-Site-percolation deleted file mode 120000 index 50ffe015c4..0000000000 --- a/Lang/EasyLang/Percolation-Site-percolation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Percolation-Site-percolation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Perfect-numbers b/Lang/EasyLang/Perfect-numbers deleted file mode 120000 index 7b9c303b67..0000000000 --- a/Lang/EasyLang/Perfect-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perfect-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Perfect-shuffle b/Lang/EasyLang/Perfect-shuffle deleted file mode 120000 index 728edc88c9..0000000000 --- a/Lang/EasyLang/Perfect-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perfect-shuffle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Perfect-totient-numbers b/Lang/EasyLang/Perfect-totient-numbers deleted file mode 120000 index 73baaf8d08..0000000000 --- a/Lang/EasyLang/Perfect-totient-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perfect-totient-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Periodic-table b/Lang/EasyLang/Periodic-table deleted file mode 120000 index 43eef9d72c..0000000000 --- a/Lang/EasyLang/Periodic-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Periodic-table/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Peripheral-drift-illusion b/Lang/EasyLang/Peripheral-drift-illusion deleted file mode 120000 index 6922becd71..0000000000 --- a/Lang/EasyLang/Peripheral-drift-illusion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Peripheral-drift-illusion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Perlin-noise b/Lang/EasyLang/Perlin-noise deleted file mode 120000 index 2f94e8bd94..0000000000 --- a/Lang/EasyLang/Perlin-noise +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perlin-noise/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Permutation-test b/Lang/EasyLang/Permutation-test deleted file mode 120000 index d3b1950f7a..0000000000 --- a/Lang/EasyLang/Permutation-test +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutation-test/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Permutations-Derangements b/Lang/EasyLang/Permutations-Derangements deleted file mode 120000 index 1993da537c..0000000000 --- a/Lang/EasyLang/Permutations-Derangements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-Derangements/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Permutations-Rank-of-a-permutation b/Lang/EasyLang/Permutations-Rank-of-a-permutation deleted file mode 120000 index 0512aed3af..0000000000 --- a/Lang/EasyLang/Permutations-Rank-of-a-permutation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-Rank-of-a-permutation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Permutations-by-swapping b/Lang/EasyLang/Permutations-by-swapping deleted file mode 120000 index 6fca752258..0000000000 --- a/Lang/EasyLang/Permutations-by-swapping +++ /dev/null @@ -1 +0,0 @@ -../../Task/Permutations-by-swapping/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pernicious-numbers b/Lang/EasyLang/Pernicious-numbers deleted file mode 120000 index 2adf8c61c2..0000000000 --- a/Lang/EasyLang/Pernicious-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pernicious-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Phrase-reversals b/Lang/EasyLang/Phrase-reversals deleted file mode 120000 index 3631697399..0000000000 --- a/Lang/EasyLang/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pierpont-primes b/Lang/EasyLang/Pierpont-primes deleted file mode 120000 index 6e3e44c04c..0000000000 --- a/Lang/EasyLang/Pierpont-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pierpont-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pig-the-dice-game b/Lang/EasyLang/Pig-the-dice-game deleted file mode 120000 index 50b35f7797..0000000000 --- a/Lang/EasyLang/Pig-the-dice-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pig-the-dice-game/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pinstripe-Display b/Lang/EasyLang/Pinstripe-Display deleted file mode 120000 index db25917458..0000000000 --- a/Lang/EasyLang/Pinstripe-Display +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pinstripe-Display/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pisano-period b/Lang/EasyLang/Pisano-period deleted file mode 120000 index 03e71e0e0c..0000000000 --- a/Lang/EasyLang/Pisano-period +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pisano-period/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Plasma-effect b/Lang/EasyLang/Plasma-effect deleted file mode 120000 index 5f845f7e61..0000000000 --- a/Lang/EasyLang/Plasma-effect +++ /dev/null @@ -1 +0,0 @@ -../../Task/Plasma-effect/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Playfair-cipher b/Lang/EasyLang/Playfair-cipher deleted file mode 120000 index 3d1568669f..0000000000 --- a/Lang/EasyLang/Playfair-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Playfair-cipher/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Playing-cards b/Lang/EasyLang/Playing-cards deleted file mode 120000 index 65c563fef4..0000000000 --- a/Lang/EasyLang/Playing-cards +++ /dev/null @@ -1 +0,0 @@ -../../Task/Playing-cards/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Poker-hand-analyser b/Lang/EasyLang/Poker-hand-analyser deleted file mode 120000 index 0d36d9a0f9..0000000000 --- a/Lang/EasyLang/Poker-hand-analyser +++ /dev/null @@ -1 +0,0 @@ -../../Task/Poker-hand-analyser/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Polynomial-long-division b/Lang/EasyLang/Polynomial-long-division deleted file mode 120000 index b22845819d..0000000000 --- a/Lang/EasyLang/Polynomial-long-division +++ /dev/null @@ -1 +0,0 @@ -../../Task/Polynomial-long-division/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Polynomial-regression b/Lang/EasyLang/Polynomial-regression deleted file mode 120000 index 8dbd1d3e30..0000000000 --- a/Lang/EasyLang/Polynomial-regression +++ /dev/null @@ -1 +0,0 @@ -../../Task/Polynomial-regression/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Polyspiral b/Lang/EasyLang/Polyspiral deleted file mode 120000 index 56ca0cfce7..0000000000 --- a/Lang/EasyLang/Polyspiral +++ /dev/null @@ -1 +0,0 @@ -../../Task/Polyspiral/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Population-count b/Lang/EasyLang/Population-count deleted file mode 120000 index 8b6ff189cf..0000000000 --- a/Lang/EasyLang/Population-count +++ /dev/null @@ -1 +0,0 @@ -../../Task/Population-count/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Price-fraction b/Lang/EasyLang/Price-fraction deleted file mode 120000 index 425841fb81..0000000000 --- a/Lang/EasyLang/Price-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Price-fraction/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Primality-by-Wilsons-theorem b/Lang/EasyLang/Primality-by-Wilsons-theorem deleted file mode 120000 index f47bc08707..0000000000 --- a/Lang/EasyLang/Primality-by-Wilsons-theorem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primality-by-Wilsons-theorem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Prime-conspiracy b/Lang/EasyLang/Prime-conspiracy deleted file mode 120000 index 5276eb838d..0000000000 --- a/Lang/EasyLang/Prime-conspiracy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-conspiracy/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Prime-numbers-whose-neighboring-pairs-are-tetraprimes b/Lang/EasyLang/Prime-numbers-whose-neighboring-pairs-are-tetraprimes deleted file mode 120000 index deadbe682f..0000000000 --- a/Lang/EasyLang/Prime-numbers-whose-neighboring-pairs-are-tetraprimes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Prime-triangle b/Lang/EasyLang/Prime-triangle deleted file mode 120000 index 1d703d33b5..0000000000 --- a/Lang/EasyLang/Prime-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Primes---allocate-descendants-to-their-ancestors b/Lang/EasyLang/Primes---allocate-descendants-to-their-ancestors deleted file mode 120000 index c5cfa0147b..0000000000 --- a/Lang/EasyLang/Primes---allocate-descendants-to-their-ancestors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primes---allocate-descendants-to-their-ancestors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Primorial-numbers b/Lang/EasyLang/Primorial-numbers deleted file mode 120000 index d0a4900284..0000000000 --- a/Lang/EasyLang/Primorial-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Primorial-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Probabilistic-choice b/Lang/EasyLang/Probabilistic-choice deleted file mode 120000 index f4c8e2ec2b..0000000000 --- a/Lang/EasyLang/Probabilistic-choice +++ /dev/null @@ -1 +0,0 @@ -../../Task/Probabilistic-choice/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Problem-of-Apollonius b/Lang/EasyLang/Problem-of-Apollonius deleted file mode 120000 index 34ccacd36b..0000000000 --- a/Lang/EasyLang/Problem-of-Apollonius +++ /dev/null @@ -1 +0,0 @@ -../../Task/Problem-of-Apollonius/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Proper-divisors b/Lang/EasyLang/Proper-divisors deleted file mode 120000 index a6f15193a6..0000000000 --- a/Lang/EasyLang/Proper-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Proper-divisors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a b/Lang/EasyLang/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a deleted file mode 120000 index 4f4d220e94..0000000000 --- a/Lang/EasyLang/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pythagorean-quadruples b/Lang/EasyLang/Pythagorean-quadruples deleted file mode 120000 index 63bc250851..0000000000 --- a/Lang/EasyLang/Pythagorean-quadruples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagorean-quadruples/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pythagorean-triples b/Lang/EasyLang/Pythagorean-triples deleted file mode 120000 index ae5979164c..0000000000 --- a/Lang/EasyLang/Pythagorean-triples +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pythagorean-triples/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Queue-Definition b/Lang/EasyLang/Queue-Definition deleted file mode 120000 index 60d84f451e..0000000000 --- a/Lang/EasyLang/Queue-Definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Queue-Definition/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Queue-Usage b/Lang/EasyLang/Queue-Usage deleted file mode 120000 index 0a07f759a8..0000000000 --- a/Lang/EasyLang/Queue-Usage +++ /dev/null @@ -1 +0,0 @@ -../../Task/Queue-Usage/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Quoting-constructs b/Lang/EasyLang/Quoting-constructs deleted file mode 120000 index 4d929963d4..0000000000 --- a/Lang/EasyLang/Quoting-constructs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quoting-constructs/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/RIPEMD-160 b/Lang/EasyLang/RIPEMD-160 deleted file mode 120000 index c7b5193d17..0000000000 --- a/Lang/EasyLang/RIPEMD-160 +++ /dev/null @@ -1 +0,0 @@ -../../Task/RIPEMD-160/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/RPG-attributes-generator b/Lang/EasyLang/RPG-attributes-generator deleted file mode 120000 index 1bb6325d13..0000000000 --- a/Lang/EasyLang/RPG-attributes-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/RPG-attributes-generator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/RSA-code b/Lang/EasyLang/RSA-code deleted file mode 120000 index ab0c3fd0ae..0000000000 --- a/Lang/EasyLang/RSA-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/RSA-code/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Radical-of-an-integer b/Lang/EasyLang/Radical-of-an-integer deleted file mode 120000 index 9e440b9a9f..0000000000 --- a/Lang/EasyLang/Radical-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Radical-of-an-integer/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ramanujan-primes-twins b/Lang/EasyLang/Ramanujan-primes-twins deleted file mode 120000 index 5e0a528dbb..0000000000 --- a/Lang/EasyLang/Ramanujan-primes-twins +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ramanujan-primes-twins/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ramer-Douglas-Peucker-line-simplification b/Lang/EasyLang/Ramer-Douglas-Peucker-line-simplification deleted file mode 120000 index e4799ac235..0000000000 --- a/Lang/EasyLang/Ramer-Douglas-Peucker-line-simplification +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ramer-Douglas-Peucker-line-simplification/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Random-Latin-squares b/Lang/EasyLang/Random-Latin-squares deleted file mode 120000 index 377972d9e1..0000000000 --- a/Lang/EasyLang/Random-Latin-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-Latin-squares/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Range-consolidation b/Lang/EasyLang/Range-consolidation deleted file mode 120000 index 2af9d87ce4..0000000000 --- a/Lang/EasyLang/Range-consolidation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-consolidation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Range-expansion b/Lang/EasyLang/Range-expansion deleted file mode 120000 index b1e04fdc47..0000000000 --- a/Lang/EasyLang/Range-expansion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-expansion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Range-extraction b/Lang/EasyLang/Range-extraction deleted file mode 120000 index b10a21cd95..0000000000 --- a/Lang/EasyLang/Range-extraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Range-extraction/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ranking-methods b/Lang/EasyLang/Ranking-methods deleted file mode 120000 index 7f1b7f2c09..0000000000 --- a/Lang/EasyLang/Ranking-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ranking-methods/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Rare-numbers b/Lang/EasyLang/Rare-numbers deleted file mode 120000 index 015d554002..0000000000 --- a/Lang/EasyLang/Rare-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rare-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Rate-counter b/Lang/EasyLang/Rate-counter deleted file mode 120000 index d4dfd5cedd..0000000000 --- a/Lang/EasyLang/Rate-counter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rate-counter/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Read-a-specific-line-from-a-file b/Lang/EasyLang/Read-a-specific-line-from-a-file deleted file mode 120000 index d7d3ddb462..0000000000 --- a/Lang/EasyLang/Read-a-specific-line-from-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-specific-line-from-a-file/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Recamans-sequence b/Lang/EasyLang/Recamans-sequence deleted file mode 120000 index 9a09fd7e52..0000000000 --- a/Lang/EasyLang/Recamans-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Recamans-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Reduced-row-echelon-form b/Lang/EasyLang/Reduced-row-echelon-form deleted file mode 120000 index 7ab5f9f24b..0000000000 --- a/Lang/EasyLang/Reduced-row-echelon-form +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reduced-row-echelon-form/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Rep-string b/Lang/EasyLang/Rep-string deleted file mode 120000 index c011f2f49a..0000000000 --- a/Lang/EasyLang/Rep-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rep-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Repeat-a-string b/Lang/EasyLang/Repeat-a-string deleted file mode 120000 index ecd0e89fe6..0000000000 --- a/Lang/EasyLang/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Resistor-mesh b/Lang/EasyLang/Resistor-mesh deleted file mode 120000 index 7e1b48a0ca..0000000000 --- a/Lang/EasyLang/Resistor-mesh +++ /dev/null @@ -1 +0,0 @@ -../../Task/Resistor-mesh/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Reverse-words-in-a-string b/Lang/EasyLang/Reverse-words-in-a-string deleted file mode 120000 index ab8b42f790..0000000000 --- a/Lang/EasyLang/Reverse-words-in-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-words-in-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Rhonda-numbers b/Lang/EasyLang/Rhonda-numbers deleted file mode 120000 index 5ec2f03aee..0000000000 --- a/Lang/EasyLang/Rhonda-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rhonda-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Rock-paper-scissors b/Lang/EasyLang/Rock-paper-scissors deleted file mode 120000 index f5bc56ac98..0000000000 --- a/Lang/EasyLang/Rock-paper-scissors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rock-paper-scissors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Roots-of-a-function b/Lang/EasyLang/Roots-of-a-function deleted file mode 120000 index 184fd0b60d..0000000000 --- a/Lang/EasyLang/Roots-of-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Roots-of-a-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Roots-of-unity b/Lang/EasyLang/Roots-of-unity deleted file mode 120000 index 828ac953fa..0000000000 --- a/Lang/EasyLang/Roots-of-unity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Roots-of-unity/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Runge-Kutta-method b/Lang/EasyLang/Runge-Kutta-method deleted file mode 120000 index 404f8f7a22..0000000000 --- a/Lang/EasyLang/Runge-Kutta-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Runge-Kutta-method/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ruth-Aaron-numbers b/Lang/EasyLang/Ruth-Aaron-numbers deleted file mode 120000 index 8c50b35963..0000000000 --- a/Lang/EasyLang/Ruth-Aaron-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ruth-Aaron-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/SEDOLs b/Lang/EasyLang/SEDOLs deleted file mode 120000 index 51d6fbebdf..0000000000 --- a/Lang/EasyLang/SEDOLs +++ /dev/null @@ -1 +0,0 @@ -../../Task/SEDOLs/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/SHA-1 b/Lang/EasyLang/SHA-1 deleted file mode 120000 index 85ee6bdeff..0000000000 --- a/Lang/EasyLang/SHA-1 +++ /dev/null @@ -1 +0,0 @@ -../../Task/SHA-1/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/SHA-256 b/Lang/EasyLang/SHA-256 deleted file mode 120000 index 90c60df38f..0000000000 --- a/Lang/EasyLang/SHA-256 +++ /dev/null @@ -1 +0,0 @@ -../../Task/SHA-256/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Safe-primes-and-unsafe-primes b/Lang/EasyLang/Safe-primes-and-unsafe-primes deleted file mode 120000 index 1a2584a87e..0000000000 --- a/Lang/EasyLang/Safe-primes-and-unsafe-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Safe-primes-and-unsafe-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem b/Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem deleted file mode 120000 index 13c2416787..0000000000 --- a/Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sailors-coconuts-and-a-monkey-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Scope-Function-names-and-labels b/Lang/EasyLang/Scope-Function-names-and-labels deleted file mode 120000 index 159b6679bd..0000000000 --- a/Lang/EasyLang/Scope-Function-names-and-labels +++ /dev/null @@ -1 +0,0 @@ -../../Task/Scope-Function-names-and-labels/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Search-a-list b/Lang/EasyLang/Search-a-list deleted file mode 120000 index ccb29f0b91..0000000000 --- a/Lang/EasyLang/Search-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string deleted file mode 120000 index c9738f521a..0000000000 --- a/Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Self-numbers b/Lang/EasyLang/Self-numbers deleted file mode 120000 index 219b2abf44..0000000000 --- a/Lang/EasyLang/Self-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Self-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Semiprime b/Lang/EasyLang/Semiprime deleted file mode 120000 index ed622fe02f..0000000000 --- a/Lang/EasyLang/Semiprime +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semiprime/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Semordnilap b/Lang/EasyLang/Semordnilap deleted file mode 120000 index 54e7d67bd7..0000000000 --- a/Lang/EasyLang/Semordnilap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semordnilap/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sequence-of-non-squares b/Lang/EasyLang/Sequence-of-non-squares deleted file mode 120000 index 5a90eeec96..0000000000 --- a/Lang/EasyLang/Sequence-of-non-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence-of-non-squares/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors b/Lang/EasyLang/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors deleted file mode 120000 index b4f1a1113a..0000000000 --- a/Lang/EasyLang/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence:-smallest-number-greater-than-previous-term-with-exactly-n-divisors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sequence:-smallest-number-with-exactly-n-divisors b/Lang/EasyLang/Sequence:-smallest-number-with-exactly-n-divisors deleted file mode 120000 index cbc83c21b2..0000000000 --- a/Lang/EasyLang/Sequence:-smallest-number-with-exactly-n-divisors +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sequence:-smallest-number-with-exactly-n-divisors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Set-puzzle b/Lang/EasyLang/Set-puzzle deleted file mode 120000 index feae2ec924..0000000000 --- a/Lang/EasyLang/Set-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Set-right-adjacent-bits b/Lang/EasyLang/Set-right-adjacent-bits deleted file mode 120000 index ec9bf3c5a8..0000000000 --- a/Lang/EasyLang/Set-right-adjacent-bits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Set-right-adjacent-bits/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Seven-sided-dice-from-five-sided-dice b/Lang/EasyLang/Seven-sided-dice-from-five-sided-dice deleted file mode 120000 index 683da7030b..0000000000 --- a/Lang/EasyLang/Seven-sided-dice-from-five-sided-dice +++ /dev/null @@ -1 +0,0 @@ -../../Task/Seven-sided-dice-from-five-sided-dice/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sexy-primes b/Lang/EasyLang/Sexy-primes deleted file mode 120000 index 5323f1eac1..0000000000 --- a/Lang/EasyLang/Sexy-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sexy-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Shoelace-formula-for-polygonal-area b/Lang/EasyLang/Shoelace-formula-for-polygonal-area deleted file mode 120000 index 3018474b33..0000000000 --- a/Lang/EasyLang/Shoelace-formula-for-polygonal-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shoelace-formula-for-polygonal-area/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Short-circuit-evaluation b/Lang/EasyLang/Short-circuit-evaluation deleted file mode 120000 index 13fc1386b3..0000000000 --- a/Lang/EasyLang/Short-circuit-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Short-circuit-evaluation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Shortest-common-supersequence b/Lang/EasyLang/Shortest-common-supersequence deleted file mode 120000 index 607dae8dd4..0000000000 --- a/Lang/EasyLang/Shortest-common-supersequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shortest-common-supersequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Show-the-epoch b/Lang/EasyLang/Show-the-epoch deleted file mode 120000 index 67a6b1a9c5..0000000000 --- a/Lang/EasyLang/Show-the-epoch +++ /dev/null @@ -1 +0,0 @@ -../../Task/Show-the-epoch/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sierpinski-square-curve b/Lang/EasyLang/Sierpinski-square-curve deleted file mode 120000 index 5a67658618..0000000000 --- a/Lang/EasyLang/Sierpinski-square-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-square-curve/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sierpinski-triangle b/Lang/EasyLang/Sierpinski-triangle deleted file mode 120000 index 36520550cb..0000000000 --- a/Lang/EasyLang/Sierpinski-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sieve-of-Pritchard b/Lang/EasyLang/Sieve-of-Pritchard deleted file mode 120000 index 26c5587430..0000000000 --- a/Lang/EasyLang/Sieve-of-Pritchard +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sieve-of-Pritchard/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Simple-turtle-graphics b/Lang/EasyLang/Simple-turtle-graphics deleted file mode 120000 index 331a87bdae..0000000000 --- a/Lang/EasyLang/Simple-turtle-graphics +++ /dev/null @@ -1 +0,0 @@ -../../Task/Simple-turtle-graphics/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sisyphus-sequence b/Lang/EasyLang/Sisyphus-sequence deleted file mode 120000 index e2e1045744..0000000000 --- a/Lang/EasyLang/Sisyphus-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sisyphus-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sleep b/Lang/EasyLang/Sleep deleted file mode 120000 index 35689819c7..0000000000 --- a/Lang/EasyLang/Sleep +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleep/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sleeping-Beauty-problem b/Lang/EasyLang/Sleeping-Beauty-problem deleted file mode 120000 index 3221388f3b..0000000000 --- a/Lang/EasyLang/Sleeping-Beauty-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sleeping-Beauty-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Smarandache-Wellin-primes b/Lang/EasyLang/Smarandache-Wellin-primes deleted file mode 120000 index bedd3c4b04..0000000000 --- a/Lang/EasyLang/Smarandache-Wellin-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smarandache-Wellin-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Smarandache-prime-digital-sequence b/Lang/EasyLang/Smarandache-prime-digital-sequence deleted file mode 120000 index 5a92cc0ae9..0000000000 --- a/Lang/EasyLang/Smarandache-prime-digital-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smarandache-prime-digital-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Smith-numbers b/Lang/EasyLang/Smith-numbers deleted file mode 120000 index 101193f3b1..0000000000 --- a/Lang/EasyLang/Smith-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smith-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Soloways-recurring-rainfall b/Lang/EasyLang/Soloways-recurring-rainfall deleted file mode 120000 index 9662259f25..0000000000 --- a/Lang/EasyLang/Soloways-recurring-rainfall +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soloways-recurring-rainfall/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Solve-a-Hidato-puzzle b/Lang/EasyLang/Solve-a-Hidato-puzzle deleted file mode 120000 index 91cd1509fe..0000000000 --- a/Lang/EasyLang/Solve-a-Hidato-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Hidato-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Solve-a-Holy-Knights-tour b/Lang/EasyLang/Solve-a-Holy-Knights-tour deleted file mode 120000 index 0807789002..0000000000 --- a/Lang/EasyLang/Solve-a-Holy-Knights-tour +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Holy-Knights-tour/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Solve-a-Hopido-puzzle b/Lang/EasyLang/Solve-a-Hopido-puzzle deleted file mode 120000 index f1ae260677..0000000000 --- a/Lang/EasyLang/Solve-a-Hopido-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Hopido-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Solve-a-Numbrix-puzzle b/Lang/EasyLang/Solve-a-Numbrix-puzzle deleted file mode 120000 index 9dc56df255..0000000000 --- a/Lang/EasyLang/Solve-a-Numbrix-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-a-Numbrix-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Solve-the-no-connection-puzzle b/Lang/EasyLang/Solve-the-no-connection-puzzle deleted file mode 120000 index 759be373e6..0000000000 --- a/Lang/EasyLang/Solve-the-no-connection-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Solve-the-no-connection-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-a-list-of-object-identifiers b/Lang/EasyLang/Sort-a-list-of-object-identifiers deleted file mode 120000 index 6767e4212b..0000000000 --- a/Lang/EasyLang/Sort-a-list-of-object-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-a-list-of-object-identifiers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-an-integer-array b/Lang/EasyLang/Sort-an-integer-array deleted file mode 120000 index b6e22e35fd..0000000000 --- a/Lang/EasyLang/Sort-an-integer-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-integer-array/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-an-outline-at-every-level b/Lang/EasyLang/Sort-an-outline-at-every-level deleted file mode 120000 index aa549fd59a..0000000000 --- a/Lang/EasyLang/Sort-an-outline-at-every-level +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-outline-at-every-level/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-disjoint-sublist b/Lang/EasyLang/Sort-disjoint-sublist deleted file mode 120000 index eb35c6be68..0000000000 --- a/Lang/EasyLang/Sort-disjoint-sublist +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-disjoint-sublist/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-numbers-lexicographically b/Lang/EasyLang/Sort-numbers-lexicographically deleted file mode 120000 index 096e63b030..0000000000 --- a/Lang/EasyLang/Sort-numbers-lexicographically +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-numbers-lexicographically/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-three-variables b/Lang/EasyLang/Sort-three-variables deleted file mode 120000 index ffc5d5785b..0000000000 --- a/Lang/EasyLang/Sort-three-variables +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-three-variables/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Bead-sort b/Lang/EasyLang/Sorting-algorithms-Bead-sort deleted file mode 120000 index a450a04067..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Bead-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bead-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Bogosort b/Lang/EasyLang/Sorting-algorithms-Bogosort deleted file mode 120000 index b0d8dd10f8..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Bogosort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Bogosort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Cocktail-sort b/Lang/EasyLang/Sorting-algorithms-Cocktail-sort deleted file mode 120000 index 6ea90a8bea..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Cocktail-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Cocktail-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Cocktail-sort-with-shifting-bounds b/Lang/EasyLang/Sorting-algorithms-Cocktail-sort-with-shifting-bounds deleted file mode 120000 index 885e9fc6f4..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Cocktail-sort-with-shifting-bounds +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Cocktail-sort-with-shifting-bounds/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Comb-sort b/Lang/EasyLang/Sorting-algorithms-Comb-sort deleted file mode 120000 index 105d051508..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Comb-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Comb-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Counting-sort b/Lang/EasyLang/Sorting-algorithms-Counting-sort deleted file mode 120000 index 55b1fd89b9..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Counting-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Counting-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Gnome-sort b/Lang/EasyLang/Sorting-algorithms-Gnome-sort deleted file mode 120000 index 4325128d9d..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Gnome-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Gnome-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Pancake-sort b/Lang/EasyLang/Sorting-algorithms-Pancake-sort deleted file mode 120000 index 7f8da5bd54..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Pancake-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Pancake-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Patience-sort b/Lang/EasyLang/Sorting-algorithms-Patience-sort deleted file mode 120000 index 6123828d8e..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Patience-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Patience-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Permutation-sort b/Lang/EasyLang/Sorting-algorithms-Permutation-sort deleted file mode 120000 index 858ffd0315..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Permutation-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Permutation-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Shell-sort b/Lang/EasyLang/Sorting-algorithms-Shell-sort deleted file mode 120000 index f5b30c5803..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Shell-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Shell-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Stooge-sort b/Lang/EasyLang/Sorting-algorithms-Stooge-sort deleted file mode 120000 index 8f8f251e34..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Stooge-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Stooge-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Strand-sort b/Lang/EasyLang/Sorting-algorithms-Strand-sort deleted file mode 120000 index 005353ca66..0000000000 --- a/Lang/EasyLang/Sorting-algorithms-Strand-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Strand-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Soundex b/Lang/EasyLang/Soundex deleted file mode 120000 index 1f0885f64a..0000000000 --- a/Lang/EasyLang/Soundex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soundex/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sparkline-in-unicode b/Lang/EasyLang/Sparkline-in-unicode deleted file mode 120000 index 7ec2356a98..0000000000 --- a/Lang/EasyLang/Sparkline-in-unicode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sparkline-in-unicode/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Spelling-of-ordinal-numbers b/Lang/EasyLang/Spelling-of-ordinal-numbers deleted file mode 120000 index 657348f1ae..0000000000 --- a/Lang/EasyLang/Spelling-of-ordinal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Spelling-of-ordinal-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sphenic-numbers b/Lang/EasyLang/Sphenic-numbers deleted file mode 120000 index 376288b88d..0000000000 --- a/Lang/EasyLang/Sphenic-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sphenic-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Spinning-rod-animation-Text b/Lang/EasyLang/Spinning-rod-animation-Text deleted file mode 120000 index 8d7a484a76..0000000000 --- a/Lang/EasyLang/Spinning-rod-animation-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Spinning-rod-animation-Text/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Spiral-matrix b/Lang/EasyLang/Spiral-matrix deleted file mode 120000 index 6a306658a2..0000000000 --- a/Lang/EasyLang/Spiral-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Spiral-matrix/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Square-but-not-cube b/Lang/EasyLang/Square-but-not-cube deleted file mode 120000 index 573451d99d..0000000000 --- a/Lang/EasyLang/Square-but-not-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-but-not-cube/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Square-form-factorization b/Lang/EasyLang/Square-form-factorization deleted file mode 120000 index 02496c127b..0000000000 --- a/Lang/EasyLang/Square-form-factorization +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-form-factorization/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Square-free-integers b/Lang/EasyLang/Square-free-integers deleted file mode 120000 index 07046cee4c..0000000000 --- a/Lang/EasyLang/Square-free-integers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Square-free-integers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stable-marriage-problem b/Lang/EasyLang/Stable-marriage-problem deleted file mode 120000 index 5a03ad65b0..0000000000 --- a/Lang/EasyLang/Stable-marriage-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stable-marriage-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stack b/Lang/EasyLang/Stack deleted file mode 120000 index 0038ea59db..0000000000 --- a/Lang/EasyLang/Stack +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stack/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stair-climbing-puzzle b/Lang/EasyLang/Stair-climbing-puzzle deleted file mode 120000 index e0c07f706d..0000000000 --- a/Lang/EasyLang/Stair-climbing-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stair-climbing-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Start-from-a-main-routine b/Lang/EasyLang/Start-from-a-main-routine deleted file mode 120000 index 6b5dd8c795..0000000000 --- a/Lang/EasyLang/Start-from-a-main-routine +++ /dev/null @@ -1 +0,0 @@ -../../Task/Start-from-a-main-routine/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Statistics-Basic b/Lang/EasyLang/Statistics-Basic deleted file mode 120000 index 5d69a2f87b..0000000000 --- a/Lang/EasyLang/Statistics-Basic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Basic/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Statistics-Normal-distribution b/Lang/EasyLang/Statistics-Normal-distribution deleted file mode 120000 index cfeed445c6..0000000000 --- a/Lang/EasyLang/Statistics-Normal-distribution +++ /dev/null @@ -1 +0,0 @@ -../../Task/Statistics-Normal-distribution/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stem-and-leaf-plot b/Lang/EasyLang/Stem-and-leaf-plot deleted file mode 120000 index cf4dace06c..0000000000 --- a/Lang/EasyLang/Stem-and-leaf-plot +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stem-and-leaf-plot/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stern-Brocot-sequence b/Lang/EasyLang/Stern-Brocot-sequence deleted file mode 120000 index 0fd407fbf1..0000000000 --- a/Lang/EasyLang/Stern-Brocot-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stern-Brocot-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stirling-numbers-of-the-first-kind b/Lang/EasyLang/Stirling-numbers-of-the-first-kind deleted file mode 120000 index 3bef923a99..0000000000 --- a/Lang/EasyLang/Stirling-numbers-of-the-first-kind +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stirling-numbers-of-the-first-kind/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stirling-numbers-of-the-second-kind b/Lang/EasyLang/Stirling-numbers-of-the-second-kind deleted file mode 120000 index c6b742cdc9..0000000000 --- a/Lang/EasyLang/Stirling-numbers-of-the-second-kind +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stirling-numbers-of-the-second-kind/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Straddling-checkerboard b/Lang/EasyLang/Straddling-checkerboard deleted file mode 120000 index df23fad6e0..0000000000 --- a/Lang/EasyLang/Straddling-checkerboard +++ /dev/null @@ -1 +0,0 @@ -../../Task/Straddling-checkerboard/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/String-matching b/Lang/EasyLang/String-matching deleted file mode 120000 index 8b66f9754a..0000000000 --- a/Lang/EasyLang/String-matching +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-matching/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Strip-a-set-of-characters-from-a-string b/Lang/EasyLang/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index 343f54ba3e..0000000000 --- a/Lang/EasyLang/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Strip-block-comments b/Lang/EasyLang/Strip-block-comments deleted file mode 120000 index afef7eb48f..0000000000 --- a/Lang/EasyLang/Strip-block-comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-block-comments/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Strip-comments-from-a-string b/Lang/EasyLang/Strip-comments-from-a-string deleted file mode 120000 index 8ec4466745..0000000000 --- a/Lang/EasyLang/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Strip-control-codes-and-extended-characters-from-a-string b/Lang/EasyLang/Strip-control-codes-and-extended-characters-from-a-string deleted file mode 120000 index 7c122382c3..0000000000 --- a/Lang/EasyLang/Strip-control-codes-and-extended-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-control-codes-and-extended-characters-from-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Strip-whitespace-from-a-string-Top-and-tail b/Lang/EasyLang/Strip-whitespace-from-a-string-Top-and-tail deleted file mode 120000 index af79da1705..0000000000 --- a/Lang/EasyLang/Strip-whitespace-from-a-string-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-whitespace-from-a-string-Top-and-tail/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Strong-and-weak-primes b/Lang/EasyLang/Strong-and-weak-primes deleted file mode 120000 index 7a0f4adcd7..0000000000 --- a/Lang/EasyLang/Strong-and-weak-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strong-and-weak-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Subleq b/Lang/EasyLang/Subleq deleted file mode 120000 index 1401c9e3d6..0000000000 --- a/Lang/EasyLang/Subleq +++ /dev/null @@ -1 +0,0 @@ -../../Task/Subleq/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Substitution-cipher b/Lang/EasyLang/Substitution-cipher deleted file mode 120000 index 08b863c199..0000000000 --- a/Lang/EasyLang/Substitution-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substitution-cipher/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Subtractive-generator b/Lang/EasyLang/Subtractive-generator deleted file mode 120000 index 67b19013ad..0000000000 --- a/Lang/EasyLang/Subtractive-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Subtractive-generator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Successive-prime-differences b/Lang/EasyLang/Successive-prime-differences deleted file mode 120000 index 904f218dfa..0000000000 --- a/Lang/EasyLang/Successive-prime-differences +++ /dev/null @@ -1 +0,0 @@ -../../Task/Successive-prime-differences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sudan-function b/Lang/EasyLang/Sudan-function deleted file mode 120000 index 00925b61cc..0000000000 --- a/Lang/EasyLang/Sudan-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sudan-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Suffixation-of-decimal-numbers b/Lang/EasyLang/Suffixation-of-decimal-numbers deleted file mode 120000 index 2c99b570e5..0000000000 --- a/Lang/EasyLang/Suffixation-of-decimal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Suffixation-of-decimal-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sum-and-product-puzzle b/Lang/EasyLang/Sum-and-product-puzzle deleted file mode 120000 index 8dd4cbcafb..0000000000 --- a/Lang/EasyLang/Sum-and-product-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-and-product-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sum-digits-of-an-integer b/Lang/EasyLang/Sum-digits-of-an-integer deleted file mode 120000 index 5cfc0b706a..0000000000 --- a/Lang/EasyLang/Sum-digits-of-an-integer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-digits-of-an-integer/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sum-multiples-of-3-and-5 b/Lang/EasyLang/Sum-multiples-of-3-and-5 deleted file mode 120000 index 6323853305..0000000000 --- a/Lang/EasyLang/Sum-multiples-of-3-and-5 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-multiples-of-3-and-5/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sum-of-a-series b/Lang/EasyLang/Sum-of-a-series deleted file mode 120000 index 47dcaccd14..0000000000 --- a/Lang/EasyLang/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/EasyLang/Sum-of-elements-below-main-diagonal-of-matrix deleted file mode 120000 index 9d1f3d5072..0000000000 --- a/Lang/EasyLang/Sum-of-elements-below-main-diagonal-of-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-elements-below-main-diagonal-of-matrix/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sum-to-100 b/Lang/EasyLang/Sum-to-100 deleted file mode 120000 index 8a6d9e6af8..0000000000 --- a/Lang/EasyLang/Sum-to-100 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-to-100/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Super-d-numbers b/Lang/EasyLang/Super-d-numbers deleted file mode 120000 index c760610b85..0000000000 --- a/Lang/EasyLang/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Superellipse b/Lang/EasyLang/Superellipse deleted file mode 120000 index cf8cdb08f6..0000000000 --- a/Lang/EasyLang/Superellipse +++ /dev/null @@ -1 +0,0 @@ -../../Task/Superellipse/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Superpermutation-minimisation b/Lang/EasyLang/Superpermutation-minimisation deleted file mode 120000 index 6607fe41d8..0000000000 --- a/Lang/EasyLang/Superpermutation-minimisation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Superpermutation-minimisation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sutherland-Hodgman-polygon-clipping b/Lang/EasyLang/Sutherland-Hodgman-polygon-clipping deleted file mode 120000 index 948deb6c32..0000000000 --- a/Lang/EasyLang/Sutherland-Hodgman-polygon-clipping +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sutherland-Hodgman-polygon-clipping/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sylvesters-sequence b/Lang/EasyLang/Sylvesters-sequence deleted file mode 120000 index 14370fd966..0000000000 --- a/Lang/EasyLang/Sylvesters-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sylvesters-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Tau-function b/Lang/EasyLang/Tau-function deleted file mode 120000 index a037a03797..0000000000 --- a/Lang/EasyLang/Tau-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Tau-number b/Lang/EasyLang/Tau-number deleted file mode 120000 index 2164c80d5f..0000000000 --- a/Lang/EasyLang/Tau-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tau-number/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Taxicab-numbers b/Lang/EasyLang/Taxicab-numbers deleted file mode 120000 index 7035ad16c4..0000000000 --- a/Lang/EasyLang/Taxicab-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Taxicab-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Teacup-rim-text b/Lang/EasyLang/Teacup-rim-text deleted file mode 120000 index 6602971306..0000000000 --- a/Lang/EasyLang/Teacup-rim-text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Teacup-rim-text/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ternary-logic b/Lang/EasyLang/Ternary-logic deleted file mode 120000 index fbbe98ec9f..0000000000 --- a/Lang/EasyLang/Ternary-logic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ternary-logic/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Test-integerness b/Lang/EasyLang/Test-integerness deleted file mode 120000 index e308fb8af8..0000000000 --- a/Lang/EasyLang/Test-integerness +++ /dev/null @@ -1 +0,0 @@ -../../Task/Test-integerness/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/The-sieve-of-Sundaram b/Lang/EasyLang/The-sieve-of-Sundaram deleted file mode 120000 index 873d444bf6..0000000000 --- a/Lang/EasyLang/The-sieve-of-Sundaram +++ /dev/null @@ -1 +0,0 @@ -../../Task/The-sieve-of-Sundaram/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Thue-Morse b/Lang/EasyLang/Thue-Morse deleted file mode 120000 index 9e3ae46e6c..0000000000 --- a/Lang/EasyLang/Thue-Morse +++ /dev/null @@ -1 +0,0 @@ -../../Task/Thue-Morse/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Time-a-function b/Lang/EasyLang/Time-a-function deleted file mode 120000 index 3bc0053e39..0000000000 --- a/Lang/EasyLang/Time-a-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Time-a-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Tokenize-a-string b/Lang/EasyLang/Tokenize-a-string deleted file mode 120000 index bd4e1f9903..0000000000 --- a/Lang/EasyLang/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Tokenize-a-string-with-escaping b/Lang/EasyLang/Tokenize-a-string-with-escaping deleted file mode 120000 index 1059b903ad..0000000000 --- a/Lang/EasyLang/Tokenize-a-string-with-escaping +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string-with-escaping/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Top-rank-per-group b/Lang/EasyLang/Top-rank-per-group deleted file mode 120000 index 861db59645..0000000000 --- a/Lang/EasyLang/Top-rank-per-group +++ /dev/null @@ -1 +0,0 @@ -../../Task/Top-rank-per-group/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Topological-sort b/Lang/EasyLang/Topological-sort deleted file mode 120000 index 8100dde197..0000000000 --- a/Lang/EasyLang/Topological-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Topological-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Topswops b/Lang/EasyLang/Topswops deleted file mode 120000 index 2080f48b84..0000000000 --- a/Lang/EasyLang/Topswops +++ /dev/null @@ -1 +0,0 @@ -../../Task/Topswops/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Total-circles-area b/Lang/EasyLang/Total-circles-area deleted file mode 120000 index 17bfc868ba..0000000000 --- a/Lang/EasyLang/Total-circles-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Total-circles-area/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Totient-function b/Lang/EasyLang/Totient-function deleted file mode 120000 index 8d52b6ae58..0000000000 --- a/Lang/EasyLang/Totient-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Totient-function/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Trabb-Pardo-Knuth-algorithm b/Lang/EasyLang/Trabb-Pardo-Knuth-algorithm deleted file mode 120000 index ca1b958ae3..0000000000 --- a/Lang/EasyLang/Trabb-Pardo-Knuth-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Trabb-Pardo-Knuth-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Tree-traversal b/Lang/EasyLang/Tree-traversal deleted file mode 120000 index a81a5f8eea..0000000000 --- a/Lang/EasyLang/Tree-traversal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tree-traversal/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Trigonometric-functions b/Lang/EasyLang/Trigonometric-functions deleted file mode 120000 index 387caf6602..0000000000 --- a/Lang/EasyLang/Trigonometric-functions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Trigonometric-functions/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Truncatable-primes b/Lang/EasyLang/Truncatable-primes deleted file mode 120000 index 4dcfac21ce..0000000000 --- a/Lang/EasyLang/Truncatable-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truncatable-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Truth-table b/Lang/EasyLang/Truth-table deleted file mode 120000 index 73d0946392..0000000000 --- a/Lang/EasyLang/Truth-table +++ /dev/null @@ -1 +0,0 @@ -../../Task/Truth-table/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Twelve-statements b/Lang/EasyLang/Twelve-statements deleted file mode 120000 index eb9094a7a2..0000000000 --- a/Lang/EasyLang/Twelve-statements +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twelve-statements/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Twin-primes b/Lang/EasyLang/Twin-primes deleted file mode 120000 index 7fe7d30975..0000000000 --- a/Lang/EasyLang/Twin-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Twin-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/UPC b/Lang/EasyLang/UPC deleted file mode 120000 index 2bb2969064..0000000000 --- a/Lang/EasyLang/UPC +++ /dev/null @@ -1 +0,0 @@ -../../Task/UPC/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/URL-decoding b/Lang/EasyLang/URL-decoding deleted file mode 120000 index a070edc78b..0000000000 --- a/Lang/EasyLang/URL-decoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/URL-decoding/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/URL-encoding b/Lang/EasyLang/URL-encoding deleted file mode 120000 index c0b065b1e5..0000000000 --- a/Lang/EasyLang/URL-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/URL-encoding/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/UTF-8-encode-and-decode b/Lang/EasyLang/UTF-8-encode-and-decode deleted file mode 120000 index c4de9115dc..0000000000 --- a/Lang/EasyLang/UTF-8-encode-and-decode +++ /dev/null @@ -1 +0,0 @@ -../../Task/UTF-8-encode-and-decode/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ulam-spiral-for-primes- b/Lang/EasyLang/Ulam-spiral-for-primes- deleted file mode 120000 index 0cc2a340bc..0000000000 --- a/Lang/EasyLang/Ulam-spiral-for-primes- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ulam-spiral-for-primes-/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Unbias-a-random-generator b/Lang/EasyLang/Unbias-a-random-generator deleted file mode 120000 index 964b26809c..0000000000 --- a/Lang/EasyLang/Unbias-a-random-generator +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unbias-a-random-generator/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Unicode-strings b/Lang/EasyLang/Unicode-strings deleted file mode 120000 index c52bd4da5c..0000000000 --- a/Lang/EasyLang/Unicode-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unicode-strings/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Universal-Turing-machine b/Lang/EasyLang/Universal-Turing-machine deleted file mode 120000 index c6c36c7e83..0000000000 --- a/Lang/EasyLang/Universal-Turing-machine +++ /dev/null @@ -1 +0,0 @@ -../../Task/Universal-Turing-machine/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Unprimeable-numbers b/Lang/EasyLang/Unprimeable-numbers deleted file mode 120000 index ae808307c7..0000000000 --- a/Lang/EasyLang/Unprimeable-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Unprimeable-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Validate-International-Securities-Identification-Number b/Lang/EasyLang/Validate-International-Securities-Identification-Number deleted file mode 120000 index 125038f3d2..0000000000 --- a/Lang/EasyLang/Validate-International-Securities-Identification-Number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Validate-International-Securities-Identification-Number/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Vampire-number b/Lang/EasyLang/Vampire-number deleted file mode 120000 index b4339746b7..0000000000 --- a/Lang/EasyLang/Vampire-number +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vampire-number/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Vector b/Lang/EasyLang/Vector deleted file mode 120000 index 3185c7d539..0000000000 --- a/Lang/EasyLang/Vector +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vector/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Vector-products b/Lang/EasyLang/Vector-products deleted file mode 120000 index dd2b30f534..0000000000 --- a/Lang/EasyLang/Vector-products +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vector-products/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Verhoeff-algorithm b/Lang/EasyLang/Verhoeff-algorithm deleted file mode 120000 index 31c375b7e9..0000000000 --- a/Lang/EasyLang/Verhoeff-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Verhoeff-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Verify-distribution-uniformity-Naive b/Lang/EasyLang/Verify-distribution-uniformity-Naive deleted file mode 120000 index bc6d548e1b..0000000000 --- a/Lang/EasyLang/Verify-distribution-uniformity-Naive +++ /dev/null @@ -1 +0,0 @@ -../../Task/Verify-distribution-uniformity-Naive/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Vigen-re-cipher-Cryptanalysis b/Lang/EasyLang/Vigen-re-cipher-Cryptanalysis deleted file mode 120000 index 019adf3986..0000000000 --- a/Lang/EasyLang/Vigen-re-cipher-Cryptanalysis +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vigen-re-cipher-Cryptanalysis/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Vogels-approximation-method b/Lang/EasyLang/Vogels-approximation-method deleted file mode 120000 index 576b7c1373..0000000000 --- a/Lang/EasyLang/Vogels-approximation-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Vogels-approximation-method/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Voronoi-diagram b/Lang/EasyLang/Voronoi-diagram deleted file mode 120000 index d875657141..0000000000 --- a/Lang/EasyLang/Voronoi-diagram +++ /dev/null @@ -1 +0,0 @@ -../../Task/Voronoi-diagram/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/War-card-game b/Lang/EasyLang/War-card-game deleted file mode 120000 index 4889819208..0000000000 --- a/Lang/EasyLang/War-card-game +++ /dev/null @@ -1 +0,0 @@ -../../Task/War-card-game/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Wasteful-equidigital-and-frugal-numbers b/Lang/EasyLang/Wasteful-equidigital-and-frugal-numbers deleted file mode 120000 index 2c61d301f5..0000000000 --- a/Lang/EasyLang/Wasteful-equidigital-and-frugal-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wasteful-equidigital-and-frugal-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Weird-numbers b/Lang/EasyLang/Weird-numbers deleted file mode 120000 index 503b16eabc..0000000000 --- a/Lang/EasyLang/Weird-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Weird-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Wieferich-primes b/Lang/EasyLang/Wieferich-primes deleted file mode 120000 index 51f8158742..0000000000 --- a/Lang/EasyLang/Wieferich-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wieferich-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Wilson-primes-of-order-n b/Lang/EasyLang/Wilson-primes-of-order-n deleted file mode 120000 index a776d56b33..0000000000 --- a/Lang/EasyLang/Wilson-primes-of-order-n +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wilson-primes-of-order-n/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Wireworld b/Lang/EasyLang/Wireworld deleted file mode 120000 index 873d48f6a7..0000000000 --- a/Lang/EasyLang/Wireworld +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wireworld/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Word-ladder b/Lang/EasyLang/Word-ladder deleted file mode 120000 index c40a883a5f..0000000000 --- a/Lang/EasyLang/Word-ladder +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-ladder/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Word-wheel b/Lang/EasyLang/Word-wheel deleted file mode 120000 index cc8df0aac8..0000000000 --- a/Lang/EasyLang/Word-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-wheel/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/World-Cup-group-stage b/Lang/EasyLang/World-Cup-group-stage deleted file mode 120000 index 903f2de54b..0000000000 --- a/Lang/EasyLang/World-Cup-group-stage +++ /dev/null @@ -1 +0,0 @@ -../../Task/World-Cup-group-stage/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Xiaolin-Wus-line-algorithm b/Lang/EasyLang/Xiaolin-Wus-line-algorithm deleted file mode 120000 index ece28f1e59..0000000000 --- a/Lang/EasyLang/Xiaolin-Wus-line-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Xiaolin-Wus-line-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Yellowstone-sequence b/Lang/EasyLang/Yellowstone-sequence deleted file mode 120000 index 76abf29ac7..0000000000 --- a/Lang/EasyLang/Yellowstone-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yellowstone-sequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Yin-and-yang b/Lang/EasyLang/Yin-and-yang deleted file mode 120000 index 5eb9553382..0000000000 --- a/Lang/EasyLang/Yin-and-yang +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yin-and-yang/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Zeckendorf-number-representation b/Lang/EasyLang/Zeckendorf-number-representation deleted file mode 120000 index 8198319b91..0000000000 --- a/Lang/EasyLang/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Zhang-Suen-thinning-algorithm b/Lang/EasyLang/Zhang-Suen-thinning-algorithm deleted file mode 120000 index 06bef59d73..0000000000 --- a/Lang/EasyLang/Zhang-Suen-thinning-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zhang-Suen-thinning-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Zig-zag-matrix b/Lang/EasyLang/Zig-zag-matrix deleted file mode 120000 index 59c91477d5..0000000000 --- a/Lang/EasyLang/Zig-zag-matrix +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zig-zag-matrix/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Zumkeller-numbers b/Lang/EasyLang/Zumkeller-numbers deleted file mode 120000 index 194eacc320..0000000000 --- a/Lang/EasyLang/Zumkeller-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zumkeller-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EchoLisp/Miller-Rabin-primality-test b/Lang/EchoLisp/Miller-Rabin-primality-test new file mode 120000 index 0000000000..a1456f561f --- /dev/null +++ b/Lang/EchoLisp/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/EchoLisp \ No newline at end of file diff --git a/Lang/Ecstasy/00-LANG.txt b/Lang/Ecstasy/00-LANG.txt index 9c977a310d..7358e7f1ea 100644 --- a/Lang/Ecstasy/00-LANG.txt +++ b/Lang/Ecstasy/00-LANG.txt @@ -25,7 +25,4 @@ The primary benefits of Ecstasy are: * A security model designed for the serverless cloud, using lightweight software containers and dependency injection (IOC/DI) * A reified generic type system with support for unions, intersection, and difference types, first-class tuples and functions, type inference, and type-safe mixins * Built-in concurrency support, with first-class support for object immutability, and the elimination of shared-mutable data -* All of the modern capabilities that developers have grown to depend on, such as: [[garbage collection|Automatic memory management]], an integrated module system, first-class lambdas and functions, partial binding and currying, cross-platform portability, and an open source development model - -==TODO== -* [[Tasks not implemented in Ecstasy]] \ No newline at end of file +* All of the modern capabilities that developers have grown to depend on, such as: [[garbage collection|Automatic memory management]], an integrated module system, first-class lambdas and functions, partial binding and currying, cross-platform portability, and an open source development model \ No newline at end of file diff --git a/Lang/Ecstasy/100-prisoners b/Lang/Ecstasy/100-prisoners deleted file mode 120000 index e9fb2d2f70..0000000000 --- a/Lang/Ecstasy/100-prisoners +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-prisoners/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Assertions b/Lang/Ecstasy/Assertions deleted file mode 120000 index 0802d10c0c..0000000000 --- a/Lang/Ecstasy/Assertions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Assertions/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/N-queens-problem b/Lang/Ecstasy/N-queens-problem deleted file mode 120000 index 695c0416ee..0000000000 --- a/Lang/Ecstasy/N-queens-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/N-queens-problem/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Pointers-and-references b/Lang/Ecstasy/Pointers-and-references deleted file mode 120000 index 9b85919b2d..0000000000 --- a/Lang/Ecstasy/Pointers-and-references +++ /dev/null @@ -1 +0,0 @@ -../../Task/Pointers-and-references/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Program-name b/Lang/Ecstasy/Program-name deleted file mode 120000 index 6411623f47..0000000000 --- a/Lang/Ecstasy/Program-name +++ /dev/null @@ -1 +0,0 @@ -../../Task/Program-name/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Reflection-List-methods b/Lang/Ecstasy/Reflection-List-methods deleted file mode 120000 index f4010fce77..0000000000 --- a/Lang/Ecstasy/Reflection-List-methods +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reflection-List-methods/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Reflection-List-properties b/Lang/Ecstasy/Reflection-List-properties deleted file mode 120000 index 40ec86fd95..0000000000 --- a/Lang/Ecstasy/Reflection-List-properties +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reflection-List-properties/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Search-a-list b/Lang/Ecstasy/Search-a-list deleted file mode 120000 index f6044e825c..0000000000 --- a/Lang/Ecstasy/Search-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Send-an-unknown-method-call b/Lang/Ecstasy/Send-an-unknown-method-call deleted file mode 120000 index 5d1a4cbed5..0000000000 --- a/Lang/Ecstasy/Send-an-unknown-method-call +++ /dev/null @@ -1 +0,0 @@ -../../Task/Send-an-unknown-method-call/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Singleton b/Lang/Ecstasy/Singleton deleted file mode 120000 index 8c9a0eb1b2..0000000000 --- a/Lang/Ecstasy/Singleton +++ /dev/null @@ -1 +0,0 @@ -../../Task/Singleton/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-case b/Lang/Ecstasy/String-case deleted file mode 120000 index 75c8cc65c2..0000000000 --- a/Lang/Ecstasy/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-comparison b/Lang/Ecstasy/String-comparison deleted file mode 120000 index 2a690e7c01..0000000000 --- a/Lang/Ecstasy/String-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-comparison/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-concatenation b/Lang/Ecstasy/String-concatenation deleted file mode 120000 index a8fc37bb41..0000000000 --- a/Lang/Ecstasy/String-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-concatenation/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-length b/Lang/Ecstasy/String-length deleted file mode 120000 index e3f6d6a12a..0000000000 --- a/Lang/Ecstasy/String-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-length/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Substring b/Lang/Ecstasy/Substring deleted file mode 120000 index 59160f9d22..0000000000 --- a/Lang/Ecstasy/Substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substring/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Substring-Top-and-tail b/Lang/Ecstasy/Substring-Top-and-tail deleted file mode 120000 index cf035aa347..0000000000 --- a/Lang/Ecstasy/Substring-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substring-Top-and-tail/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/System-time b/Lang/Ecstasy/System-time deleted file mode 120000 index 4b0a593cce..0000000000 --- a/Lang/Ecstasy/System-time +++ /dev/null @@ -1 +0,0 @@ -../../Task/System-time/Ecstasy \ No newline at end of file diff --git a/Lang/Ed/00-LANG.txt b/Lang/Ed/00-LANG.txt deleted file mode 100644 index 0ffa56bf3c..0000000000 --- a/Lang/Ed/00-LANG.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{stub}} -{{language|Ed}} -This is the command language used by [[wp:ed_(software)]], -the line oriented text editor, not to be confused with [[Sed]], the stream editor. - -Implementations are [[GNU Ed]], [[Plan 9 Ed]], BSD ed, and original UNIX ed. -Ed is also a precursor to a whole family of other text editors and command languages. -Including [[Sed]], ex, vi, vim, sam, and others. - -Ed scripts are usually ran as (on the example of [[GNU Ed]]) - -cat script.ed | ed -lEGs file.in - - -Or, more portably, with Basic Regular Expressions on BSD, Mac, and [[GNU Ed]]. - -cat script.ed | ed -s file.in - - -There's a convention of starting every ed script with capital H on a line of its own, to toggle more verbose error messages on. And optionally end the script with capital Q to force-quit without saving the changes to file. - -A good reference for Ed is it's info page, which can be found online [https://linux.die.net/man/1/ed here]. - -Also see [[Tasks not implemented in Ed]] - -[[Category:Editor]] -[[Category:Utility]] \ No newline at end of file diff --git a/Lang/Ed/00-META.yaml b/Lang/Ed/00-META.yaml deleted file mode 100644 index 8c668497f3..0000000000 --- a/Lang/Ed/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Ed diff --git a/Lang/Ed/A+B b/Lang/Ed/A+B deleted file mode 120000 index 00ee271a45..0000000000 --- a/Lang/Ed/A+B +++ /dev/null @@ -1 +0,0 @@ -../../Task/A+B/Ed \ No newline at end of file diff --git a/Lang/Ed/Address-of-a-variable b/Lang/Ed/Address-of-a-variable deleted file mode 120000 index b7216d9c2d..0000000000 --- a/Lang/Ed/Address-of-a-variable +++ /dev/null @@ -1 +0,0 @@ -../../Task/Address-of-a-variable/Ed \ No newline at end of file diff --git a/Lang/Ed/Append-a-record-to-the-end-of-a-text-file b/Lang/Ed/Append-a-record-to-the-end-of-a-text-file deleted file mode 120000 index c20f4ffb66..0000000000 --- a/Lang/Ed/Append-a-record-to-the-end-of-a-text-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Append-a-record-to-the-end-of-a-text-file/Ed \ No newline at end of file diff --git a/Lang/Ed/Balanced-brackets b/Lang/Ed/Balanced-brackets deleted file mode 120000 index 12f98da078..0000000000 --- a/Lang/Ed/Balanced-brackets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Balanced-brackets/Ed \ No newline at end of file diff --git a/Lang/Ed/Base64-decode-data b/Lang/Ed/Base64-decode-data deleted file mode 120000 index d08c0a29a4..0000000000 --- a/Lang/Ed/Base64-decode-data +++ /dev/null @@ -1 +0,0 @@ -../../Task/Base64-decode-data/Ed \ No newline at end of file diff --git a/Lang/Ed/Binary-digits b/Lang/Ed/Binary-digits deleted file mode 120000 index 3593438a83..0000000000 --- a/Lang/Ed/Binary-digits +++ /dev/null @@ -1 +0,0 @@ -../../Task/Binary-digits/Ed \ No newline at end of file diff --git a/Lang/Ed/Brace-expansion b/Lang/Ed/Brace-expansion deleted file mode 120000 index 57b88b6984..0000000000 --- a/Lang/Ed/Brace-expansion +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brace-expansion/Ed \ No newline at end of file diff --git a/Lang/Ed/CSV-to-HTML-translation b/Lang/Ed/CSV-to-HTML-translation deleted file mode 120000 index 982d76328a..0000000000 --- a/Lang/Ed/CSV-to-HTML-translation +++ /dev/null @@ -1 +0,0 @@ -../../Task/CSV-to-HTML-translation/Ed \ No newline at end of file diff --git a/Lang/Ed/Camel-case-and-snake-case b/Lang/Ed/Camel-case-and-snake-case deleted file mode 120000 index 34e48e10ce..0000000000 --- a/Lang/Ed/Camel-case-and-snake-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/Camel-case-and-snake-case/Ed \ No newline at end of file diff --git a/Lang/Ed/Check-input-device-is-a-terminal b/Lang/Ed/Check-input-device-is-a-terminal deleted file mode 120000 index aaa70cb2b9..0000000000 --- a/Lang/Ed/Check-input-device-is-a-terminal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-input-device-is-a-terminal/Ed \ No newline at end of file diff --git a/Lang/Ed/Check-output-device-is-a-terminal b/Lang/Ed/Check-output-device-is-a-terminal deleted file mode 120000 index 7304043875..0000000000 --- a/Lang/Ed/Check-output-device-is-a-terminal +++ /dev/null @@ -1 +0,0 @@ -../../Task/Check-output-device-is-a-terminal/Ed \ No newline at end of file diff --git a/Lang/Ed/Chinese-zodiac b/Lang/Ed/Chinese-zodiac deleted file mode 120000 index 3a56ea0052..0000000000 --- a/Lang/Ed/Chinese-zodiac +++ /dev/null @@ -1 +0,0 @@ -../../Task/Chinese-zodiac/Ed \ No newline at end of file diff --git a/Lang/Ed/Cistercian-numerals b/Lang/Ed/Cistercian-numerals deleted file mode 120000 index f8c9ddde28..0000000000 --- a/Lang/Ed/Cistercian-numerals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cistercian-numerals/Ed \ No newline at end of file diff --git a/Lang/Ed/Comma-quibbling b/Lang/Ed/Comma-quibbling deleted file mode 120000 index d9dc3b3989..0000000000 --- a/Lang/Ed/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/Ed \ No newline at end of file diff --git a/Lang/Ed/Comments b/Lang/Ed/Comments deleted file mode 120000 index 08d536496b..0000000000 --- a/Lang/Ed/Comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comments/Ed \ No newline at end of file diff --git a/Lang/Ed/Conditional-structures b/Lang/Ed/Conditional-structures deleted file mode 120000 index 46db5ede62..0000000000 --- a/Lang/Ed/Conditional-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conditional-structures/Ed \ No newline at end of file diff --git a/Lang/Ed/Copy-a-string b/Lang/Ed/Copy-a-string deleted file mode 120000 index 55ec74ae6a..0000000000 --- a/Lang/Ed/Copy-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Copy-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Count-occurrences-of-a-substring b/Lang/Ed/Count-occurrences-of-a-substring deleted file mode 120000 index 1c698d3069..0000000000 --- a/Lang/Ed/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/Ed \ No newline at end of file diff --git a/Lang/Ed/Create-a-file b/Lang/Ed/Create-a-file deleted file mode 120000 index 11ca37c1ec..0000000000 --- a/Lang/Ed/Create-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Create-a-file/Ed \ No newline at end of file diff --git a/Lang/Ed/Date-format b/Lang/Ed/Date-format deleted file mode 120000 index 972dcea98a..0000000000 --- a/Lang/Ed/Date-format +++ /dev/null @@ -1 +0,0 @@ -../../Task/Date-format/Ed \ No newline at end of file diff --git a/Lang/Ed/Delete-a-file b/Lang/Ed/Delete-a-file deleted file mode 120000 index f208022c59..0000000000 --- a/Lang/Ed/Delete-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Delete-a-file/Ed \ No newline at end of file diff --git a/Lang/Ed/Determine-if-a-string-has-all-the-same-characters b/Lang/Ed/Determine-if-a-string-has-all-the-same-characters deleted file mode 120000 index 448ed7ccc8..0000000000 --- a/Lang/Ed/Determine-if-a-string-has-all-the-same-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-the-same-characters/Ed \ No newline at end of file diff --git a/Lang/Ed/Determine-if-a-string-has-all-unique-characters b/Lang/Ed/Determine-if-a-string-has-all-unique-characters deleted file mode 120000 index 3ce9aedae3..0000000000 --- a/Lang/Ed/Determine-if-a-string-has-all-unique-characters +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-has-all-unique-characters/Ed \ No newline at end of file diff --git a/Lang/Ed/Determine-if-a-string-is-collapsible b/Lang/Ed/Determine-if-a-string-is-collapsible deleted file mode 120000 index 8b2921d3eb..0000000000 --- a/Lang/Ed/Determine-if-a-string-is-collapsible +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-collapsible/Ed \ No newline at end of file diff --git a/Lang/Ed/Determine-if-a-string-is-numeric b/Lang/Ed/Determine-if-a-string-is-numeric deleted file mode 120000 index 05c951f131..0000000000 --- a/Lang/Ed/Determine-if-a-string-is-numeric +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-numeric/Ed \ No newline at end of file diff --git a/Lang/Ed/Empty-string b/Lang/Ed/Empty-string deleted file mode 120000 index d609b5a73a..0000000000 --- a/Lang/Ed/Empty-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Empty-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Ethiopian-multiplication b/Lang/Ed/Ethiopian-multiplication deleted file mode 120000 index a218310c2e..0000000000 --- a/Lang/Ed/Ethiopian-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ethiopian-multiplication/Ed \ No newline at end of file diff --git a/Lang/Ed/Even-or-odd b/Lang/Ed/Even-or-odd deleted file mode 120000 index 216cea134c..0000000000 --- a/Lang/Ed/Even-or-odd +++ /dev/null @@ -1 +0,0 @@ -../../Task/Even-or-odd/Ed \ No newline at end of file diff --git a/Lang/Ed/File-input-output b/Lang/Ed/File-input-output deleted file mode 120000 index ab2356c090..0000000000 --- a/Lang/Ed/File-input-output +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-input-output/Ed \ No newline at end of file diff --git a/Lang/Ed/Filter b/Lang/Ed/Filter deleted file mode 120000 index 0e10013135..0000000000 --- a/Lang/Ed/Filter +++ /dev/null @@ -1 +0,0 @@ -../../Task/Filter/Ed \ No newline at end of file diff --git a/Lang/Ed/Find-common-directory-path b/Lang/Ed/Find-common-directory-path deleted file mode 120000 index 31b50e9c25..0000000000 --- a/Lang/Ed/Find-common-directory-path +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-common-directory-path/Ed \ No newline at end of file diff --git a/Lang/Ed/FizzBuzz b/Lang/Ed/FizzBuzz deleted file mode 120000 index 5f01963d2b..0000000000 --- a/Lang/Ed/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/Ed \ No newline at end of file diff --git a/Lang/Ed/Hello-world-Text b/Lang/Ed/Hello-world-Text deleted file mode 120000 index 09329e9578..0000000000 --- a/Lang/Ed/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Ed \ No newline at end of file diff --git a/Lang/Ed/Here-document b/Lang/Ed/Here-document deleted file mode 120000 index 1aca222a29..0000000000 --- a/Lang/Ed/Here-document +++ /dev/null @@ -1 +0,0 @@ -../../Task/Here-document/Ed \ No newline at end of file diff --git a/Lang/Ed/I-before-E-except-after-C b/Lang/Ed/I-before-E-except-after-C deleted file mode 120000 index 017b410bd0..0000000000 --- a/Lang/Ed/I-before-E-except-after-C +++ /dev/null @@ -1 +0,0 @@ -../../Task/I-before-E-except-after-C/Ed \ No newline at end of file diff --git a/Lang/Ed/Increment-a-numerical-string b/Lang/Ed/Increment-a-numerical-string deleted file mode 120000 index e55a87b09f..0000000000 --- a/Lang/Ed/Increment-a-numerical-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Increment-a-numerical-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Jewels-and-stones b/Lang/Ed/Jewels-and-stones deleted file mode 120000 index aa6e0865ea..0000000000 --- a/Lang/Ed/Jewels-and-stones +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jewels-and-stones/Ed \ No newline at end of file diff --git a/Lang/Ed/Longest-common-subsequence b/Lang/Ed/Longest-common-subsequence deleted file mode 120000 index d0e8efbf1e..0000000000 --- a/Lang/Ed/Longest-common-subsequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Longest-common-subsequence/Ed \ No newline at end of file diff --git a/Lang/Ed/Loops-For b/Lang/Ed/Loops-For deleted file mode 120000 index 3de59c57c2..0000000000 --- a/Lang/Ed/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Ed \ No newline at end of file diff --git a/Lang/Ed/Loops-Foreach b/Lang/Ed/Loops-Foreach deleted file mode 120000 index c06f3655df..0000000000 --- a/Lang/Ed/Loops-Foreach +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Foreach/Ed \ No newline at end of file diff --git a/Lang/Ed/Morse-code b/Lang/Ed/Morse-code deleted file mode 120000 index e5384e5776..0000000000 --- a/Lang/Ed/Morse-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Morse-code/Ed \ No newline at end of file diff --git a/Lang/Ed/Nth b/Lang/Ed/Nth deleted file mode 120000 index d2f15b3c88..0000000000 --- a/Lang/Ed/Nth +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth/Ed \ No newline at end of file diff --git a/Lang/Ed/Palindrome-detection b/Lang/Ed/Palindrome-detection deleted file mode 120000 index 1bec256a92..0000000000 --- a/Lang/Ed/Palindrome-detection +++ /dev/null @@ -1 +0,0 @@ -../../Task/Palindrome-detection/Ed \ No newline at end of file diff --git a/Lang/Ed/Phrase-reversals b/Lang/Ed/Phrase-reversals deleted file mode 120000 index 0ee3f41dfa..0000000000 --- a/Lang/Ed/Phrase-reversals +++ /dev/null @@ -1 +0,0 @@ -../../Task/Phrase-reversals/Ed \ No newline at end of file diff --git a/Lang/Ed/Quine b/Lang/Ed/Quine deleted file mode 120000 index 3690e73126..0000000000 --- a/Lang/Ed/Quine +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quine/Ed \ No newline at end of file diff --git a/Lang/Ed/Random-number-generator-device- b/Lang/Ed/Random-number-generator-device- deleted file mode 120000 index ebfa530984..0000000000 --- a/Lang/Ed/Random-number-generator-device- +++ /dev/null @@ -1 +0,0 @@ -../../Task/Random-number-generator-device-/Ed \ No newline at end of file diff --git a/Lang/Ed/Read-a-specific-line-from-a-file b/Lang/Ed/Read-a-specific-line-from-a-file deleted file mode 120000 index 68b3526a94..0000000000 --- a/Lang/Ed/Read-a-specific-line-from-a-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Read-a-specific-line-from-a-file/Ed \ No newline at end of file diff --git a/Lang/Ed/Regular-expressions b/Lang/Ed/Regular-expressions deleted file mode 120000 index 03fa790d32..0000000000 --- a/Lang/Ed/Regular-expressions +++ /dev/null @@ -1 +0,0 @@ -../../Task/Regular-expressions/Ed \ No newline at end of file diff --git a/Lang/Ed/Rep-string b/Lang/Ed/Rep-string deleted file mode 120000 index 1cabc7547c..0000000000 --- a/Lang/Ed/Rep-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rep-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Repeat-a-string b/Lang/Ed/Repeat-a-string deleted file mode 120000 index 88553bc853..0000000000 --- a/Lang/Ed/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Reverse-a-string b/Lang/Ed/Reverse-a-string deleted file mode 120000 index 6104b59dd9..0000000000 --- a/Lang/Ed/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Reverse-words-in-a-string b/Lang/Ed/Reverse-words-in-a-string deleted file mode 120000 index d59e80e1fb..0000000000 --- a/Lang/Ed/Reverse-words-in-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-words-in-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Roman-numerals-Decode b/Lang/Ed/Roman-numerals-Decode deleted file mode 120000 index 81a8608ea4..0000000000 --- a/Lang/Ed/Roman-numerals-Decode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Roman-numerals-Decode/Ed \ No newline at end of file diff --git a/Lang/Ed/Roman-numerals-Encode b/Lang/Ed/Roman-numerals-Encode deleted file mode 120000 index 686206e904..0000000000 --- a/Lang/Ed/Roman-numerals-Encode +++ /dev/null @@ -1 +0,0 @@ -../../Task/Roman-numerals-Encode/Ed \ No newline at end of file diff --git a/Lang/Ed/Rot-13 b/Lang/Ed/Rot-13 deleted file mode 120000 index 731a496ae9..0000000000 --- a/Lang/Ed/Rot-13 +++ /dev/null @@ -1 +0,0 @@ -../../Task/Rot-13/Ed \ No newline at end of file diff --git a/Lang/Ed/Run-length-encoding b/Lang/Ed/Run-length-encoding deleted file mode 120000 index 69e6b1b531..0000000000 --- a/Lang/Ed/Run-length-encoding +++ /dev/null @@ -1 +0,0 @@ -../../Task/Run-length-encoding/Ed \ No newline at end of file diff --git a/Lang/Ed/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/Ed/Selectively-replace-multiple-instances-of-a-character-within-a-string deleted file mode 120000 index e414614b56..0000000000 --- a/Lang/Ed/Selectively-replace-multiple-instances-of-a-character-within-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Semordnilap b/Lang/Ed/Semordnilap deleted file mode 120000 index daf7a5ecb1..0000000000 --- a/Lang/Ed/Semordnilap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semordnilap/Ed \ No newline at end of file diff --git a/Lang/Ed/Sort-an-integer-array b/Lang/Ed/Sort-an-integer-array deleted file mode 120000 index b1a2a66ffa..0000000000 --- a/Lang/Ed/Sort-an-integer-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-an-integer-array/Ed \ No newline at end of file diff --git a/Lang/Ed/Split-a-character-string-based-on-change-of-character b/Lang/Ed/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index 0033ba43dd..0000000000 --- a/Lang/Ed/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/Ed \ No newline at end of file diff --git a/Lang/Ed/String-case b/Lang/Ed/String-case deleted file mode 120000 index daab926f48..0000000000 --- a/Lang/Ed/String-case +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-case/Ed \ No newline at end of file diff --git a/Lang/Ed/String-comparison b/Lang/Ed/String-comparison deleted file mode 120000 index d24860c04c..0000000000 --- a/Lang/Ed/String-comparison +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-comparison/Ed \ No newline at end of file diff --git a/Lang/Ed/String-concatenation b/Lang/Ed/String-concatenation deleted file mode 120000 index f24bfde76e..0000000000 --- a/Lang/Ed/String-concatenation +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-concatenation/Ed \ No newline at end of file diff --git a/Lang/Ed/String-interpolation-included- b/Lang/Ed/String-interpolation-included- deleted file mode 120000 index 6b90881c7e..0000000000 --- a/Lang/Ed/String-interpolation-included- +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-interpolation-included-/Ed \ No newline at end of file diff --git a/Lang/Ed/String-length b/Lang/Ed/String-length deleted file mode 120000 index de41c29ef2..0000000000 --- a/Lang/Ed/String-length +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-length/Ed \ No newline at end of file diff --git a/Lang/Ed/String-matching b/Lang/Ed/String-matching deleted file mode 120000 index 2895138190..0000000000 --- a/Lang/Ed/String-matching +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-matching/Ed \ No newline at end of file diff --git a/Lang/Ed/String-prepend b/Lang/Ed/String-prepend deleted file mode 120000 index ce1d9a46f5..0000000000 --- a/Lang/Ed/String-prepend +++ /dev/null @@ -1 +0,0 @@ -../../Task/String-prepend/Ed \ No newline at end of file diff --git a/Lang/Ed/Strip-a-set-of-characters-from-a-string b/Lang/Ed/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index 6a57ca5210..0000000000 --- a/Lang/Ed/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Strip-block-comments b/Lang/Ed/Strip-block-comments deleted file mode 120000 index 913cdfb609..0000000000 --- a/Lang/Ed/Strip-block-comments +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-block-comments/Ed \ No newline at end of file diff --git a/Lang/Ed/Strip-comments-from-a-string b/Lang/Ed/Strip-comments-from-a-string deleted file mode 120000 index f7c3c178f3..0000000000 --- a/Lang/Ed/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Strip-control-codes-and-extended-characters-from-a-string b/Lang/Ed/Strip-control-codes-and-extended-characters-from-a-string deleted file mode 120000 index 8cffb60723..0000000000 --- a/Lang/Ed/Strip-control-codes-and-extended-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-control-codes-and-extended-characters-from-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Strip-whitespace-from-a-string-Top-and-tail b/Lang/Ed/Strip-whitespace-from-a-string-Top-and-tail deleted file mode 120000 index 87421d1e38..0000000000 --- a/Lang/Ed/Strip-whitespace-from-a-string-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-whitespace-from-a-string-Top-and-tail/Ed \ No newline at end of file diff --git a/Lang/Ed/Substring b/Lang/Ed/Substring deleted file mode 120000 index 373a20b8f4..0000000000 --- a/Lang/Ed/Substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substring/Ed \ No newline at end of file diff --git a/Lang/Ed/Substring-Top-and-tail b/Lang/Ed/Substring-Top-and-tail deleted file mode 120000 index bff998aeb0..0000000000 --- a/Lang/Ed/Substring-Top-and-tail +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substring-Top-and-tail/Ed \ No newline at end of file diff --git a/Lang/Ed/Tokenize-a-string b/Lang/Ed/Tokenize-a-string deleted file mode 120000 index d8f4499b3c..0000000000 --- a/Lang/Ed/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/Ed \ No newline at end of file diff --git a/Lang/Ed/Word-wrap b/Lang/Ed/Word-wrap deleted file mode 120000 index b86e0349c6..0000000000 --- a/Lang/Ed/Word-wrap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-wrap/Ed \ No newline at end of file diff --git a/Lang/Eero/Quaternion-type b/Lang/Eero/Quaternion-type new file mode 120000 index 0000000000..91a82e433f --- /dev/null +++ b/Lang/Eero/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Eero \ No newline at end of file diff --git a/Lang/Eiffel/Loops-For b/Lang/Eiffel/Loops-For deleted file mode 120000 index 30f93ee824..0000000000 --- a/Lang/Eiffel/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Loops-Infinite b/Lang/Eiffel/Loops-Infinite deleted file mode 120000 index 1016f5af23..0000000000 --- a/Lang/Eiffel/Loops-Infinite +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-Infinite/Eiffel \ No newline at end of file diff --git a/Lang/Elena/00-LANG.txt b/Lang/Elena/00-LANG.txt index c3a21bf2d4..671257e3ee 100644 --- a/Lang/Elena/00-LANG.txt +++ b/Lang/Elena/00-LANG.txt @@ -1,5 +1,5 @@ {{language|Elena -|site=https://elena-lang.github.io/ +|site=http://elenalang.sourceforge.net |exec=bytecode |strength=strong |safety=safe diff --git a/Lang/Elena/Comma-quibbling b/Lang/Elena/Comma-quibbling deleted file mode 120000 index f92aff5654..0000000000 --- a/Lang/Elena/Comma-quibbling +++ /dev/null @@ -1 +0,0 @@ -../../Task/Comma-quibbling/Elena \ No newline at end of file diff --git a/Lang/Elena/Concurrent-computing b/Lang/Elena/Concurrent-computing deleted file mode 120000 index d22278e519..0000000000 --- a/Lang/Elena/Concurrent-computing +++ /dev/null @@ -1 +0,0 @@ -../../Task/Concurrent-computing/Elena \ No newline at end of file diff --git a/Lang/Elena/HTTP b/Lang/Elena/HTTP deleted file mode 120000 index c94b6f99cd..0000000000 --- a/Lang/Elena/HTTP +++ /dev/null @@ -1 +0,0 @@ -../../Task/HTTP/Elena \ No newline at end of file diff --git a/Lang/Elena/HTTPS b/Lang/Elena/HTTPS deleted file mode 120000 index 879dfcb045..0000000000 --- a/Lang/Elena/HTTPS +++ /dev/null @@ -1 +0,0 @@ -../../Task/HTTPS/Elena \ No newline at end of file diff --git a/Lang/Elena/Quaternion-type b/Lang/Elena/Quaternion-type new file mode 120000 index 0000000000..1637f784c6 --- /dev/null +++ b/Lang/Elena/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Elena \ No newline at end of file diff --git a/Lang/Elixir/Arithmetic-evaluation b/Lang/Elixir/Arithmetic-evaluation deleted file mode 120000 index 421d00b13e..0000000000 --- a/Lang/Elixir/Arithmetic-evaluation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arithmetic-evaluation/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Continued-fraction b/Lang/Elixir/Continued-fraction deleted file mode 120000 index 03e2722a4e..0000000000 --- a/Lang/Elixir/Continued-fraction +++ /dev/null @@ -1 +0,0 @@ -../../Task/Continued-fraction/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Cyclops-numbers b/Lang/Elixir/Cyclops-numbers deleted file mode 120000 index 0e8897c007..0000000000 --- a/Lang/Elixir/Cyclops-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cyclops-numbers/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Determinant-and-permanent b/Lang/Elixir/Determinant-and-permanent deleted file mode 120000 index 91e99770a2..0000000000 --- a/Lang/Elixir/Determinant-and-permanent +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determinant-and-permanent/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Empty-program b/Lang/Elixir/Empty-program new file mode 120000 index 0000000000..e1c7956a55 --- /dev/null +++ b/Lang/Elixir/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Gapful-numbers b/Lang/Elixir/Gapful-numbers deleted file mode 120000 index c482e40173..0000000000 --- a/Lang/Elixir/Gapful-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gapful-numbers/Elixir \ No newline at end of file diff --git a/Lang/Elixir/K-d-tree b/Lang/Elixir/K-d-tree deleted file mode 120000 index 4a7008abc8..0000000000 --- a/Lang/Elixir/K-d-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/K-d-tree/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Miller-Rabin-primality-test b/Lang/Elixir/Miller-Rabin-primality-test new file mode 120000 index 0000000000..911bb7e6dd --- /dev/null +++ b/Lang/Elixir/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Padovan-sequence b/Lang/Elixir/Padovan-sequence deleted file mode 120000 index 1b11fdfcb3..0000000000 --- a/Lang/Elixir/Padovan-sequence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Padovan-sequence/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Parallel-brute-force b/Lang/Elixir/Parallel-brute-force deleted file mode 120000 index 154ccc9bb9..0000000000 --- a/Lang/Elixir/Parallel-brute-force +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parallel-brute-force/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Parse-an-IP-Address b/Lang/Elixir/Parse-an-IP-Address deleted file mode 120000 index bad8e9a86e..0000000000 --- a/Lang/Elixir/Parse-an-IP-Address +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parse-an-IP-Address/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Shoelace-formula-for-polygonal-area b/Lang/Elixir/Shoelace-formula-for-polygonal-area deleted file mode 120000 index f28f8d7f49..0000000000 --- a/Lang/Elixir/Shoelace-formula-for-polygonal-area +++ /dev/null @@ -1 +0,0 @@ -../../Task/Shoelace-formula-for-polygonal-area/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Sorting-Algorithms-Circle-Sort b/Lang/Elixir/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..97335bafb5 --- /dev/null +++ b/Lang/Elixir/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Strassens-algorithm b/Lang/Elixir/Strassens-algorithm deleted file mode 120000 index b73f87ff60..0000000000 --- a/Lang/Elixir/Strassens-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strassens-algorithm/Elixir \ No newline at end of file diff --git a/Lang/Elm/ABC-problem b/Lang/Elm/ABC-problem deleted file mode 120000 index 9dc41045b3..0000000000 --- a/Lang/Elm/ABC-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/ABC-problem/Elm \ No newline at end of file diff --git a/Lang/Elm/Caesar-cipher b/Lang/Elm/Caesar-cipher deleted file mode 120000 index e2f4604523..0000000000 --- a/Lang/Elm/Caesar-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Caesar-cipher/Elm \ No newline at end of file diff --git a/Lang/Elm/Greatest-common-divisor b/Lang/Elm/Greatest-common-divisor deleted file mode 120000 index b61057b86e..0000000000 --- a/Lang/Elm/Greatest-common-divisor +++ /dev/null @@ -1 +0,0 @@ -../../Task/Greatest-common-divisor/Elm \ No newline at end of file diff --git a/Lang/Elm/Prime-decomposition b/Lang/Elm/Prime-decomposition deleted file mode 120000 index a3a9b92e08..0000000000 --- a/Lang/Elm/Prime-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Prime-decomposition/Elm \ No newline at end of file diff --git a/Lang/Elm/Sum-of-a-series b/Lang/Elm/Sum-of-a-series deleted file mode 120000 index b1ba524bb3..0000000000 --- a/Lang/Elm/Sum-of-a-series +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sum-of-a-series/Elm \ No newline at end of file diff --git a/Lang/Emacs-Lisp/AVL-tree b/Lang/Emacs-Lisp/AVL-tree deleted file mode 120000 index b9212102d2..0000000000 --- a/Lang/Emacs-Lisp/AVL-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/AVL-tree/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Abbreviations-automatic b/Lang/Emacs-Lisp/Abbreviations-automatic deleted file mode 120000 index 917fbde092..0000000000 --- a/Lang/Emacs-Lisp/Abbreviations-automatic +++ /dev/null @@ -1 +0,0 @@ -../../Task/Abbreviations-automatic/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Align-columns b/Lang/Emacs-Lisp/Align-columns deleted file mode 120000 index 9be61160c6..0000000000 --- a/Lang/Emacs-Lisp/Align-columns +++ /dev/null @@ -1 +0,0 @@ -../../Task/Align-columns/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Anagrams b/Lang/Emacs-Lisp/Anagrams deleted file mode 120000 index 0bf987f884..0000000000 --- a/Lang/Emacs-Lisp/Anagrams +++ /dev/null @@ -1 +0,0 @@ -../../Task/Anagrams/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Bulls-and-cows b/Lang/Emacs-Lisp/Bulls-and-cows deleted file mode 120000 index b0602ecaf2..0000000000 --- a/Lang/Emacs-Lisp/Bulls-and-cows +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bulls-and-cows/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Color-wheel b/Lang/Emacs-Lisp/Color-wheel deleted file mode 120000 index 90b9cec116..0000000000 --- a/Lang/Emacs-Lisp/Color-wheel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Color-wheel/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Compare-length-of-two-strings b/Lang/Emacs-Lisp/Compare-length-of-two-strings deleted file mode 120000 index 2aa87a97f8..0000000000 --- a/Lang/Emacs-Lisp/Compare-length-of-two-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-length-of-two-strings/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Count-occurrences-of-a-substring b/Lang/Emacs-Lisp/Count-occurrences-of-a-substring deleted file mode 120000 index 461c47a81c..0000000000 --- a/Lang/Emacs-Lisp/Count-occurrences-of-a-substring +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-occurrences-of-a-substring/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Date-manipulation b/Lang/Emacs-Lisp/Date-manipulation deleted file mode 120000 index d88e6a9576..0000000000 --- a/Lang/Emacs-Lisp/Date-manipulation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Date-manipulation/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Determine-if-a-string-is-numeric b/Lang/Emacs-Lisp/Determine-if-a-string-is-numeric deleted file mode 120000 index 2314291eaa..0000000000 --- a/Lang/Emacs-Lisp/Determine-if-a-string-is-numeric +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-if-a-string-is-numeric/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Determine-sentence-type b/Lang/Emacs-Lisp/Determine-sentence-type deleted file mode 120000 index 633b068253..0000000000 --- a/Lang/Emacs-Lisp/Determine-sentence-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determine-sentence-type/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Find-palindromic-numbers-in-both-binary-and-ternary-bases b/Lang/Emacs-Lisp/Find-palindromic-numbers-in-both-binary-and-ternary-bases deleted file mode 120000 index d1e4e53b61..0000000000 --- a/Lang/Emacs-Lisp/Find-palindromic-numbers-in-both-binary-and-ternary-bases +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-palindromic-numbers-in-both-binary-and-ternary-bases/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Generate-random-chess-position b/Lang/Emacs-Lisp/Generate-random-chess-position deleted file mode 120000 index 7ef4f0bf90..0000000000 --- a/Lang/Emacs-Lisp/Generate-random-chess-position +++ /dev/null @@ -1 +0,0 @@ -../../Task/Generate-random-chess-position/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Emacs-Lisp/Keyboard-input-Flush-the-keyboard-buffer deleted file mode 120000 index db888b4ffd..0000000000 --- a/Lang/Emacs-Lisp/Keyboard-input-Flush-the-keyboard-buffer +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Flush-the-keyboard-buffer/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Keyboard-input-Keypress-check b/Lang/Emacs-Lisp/Keyboard-input-Keypress-check deleted file mode 120000 index 1bf55a234e..0000000000 --- a/Lang/Emacs-Lisp/Keyboard-input-Keypress-check +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Keypress-check/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Emacs-Lisp/Keyboard-input-Obtain-a-Y-or-N-response deleted file mode 120000 index d6205cc54b..0000000000 --- a/Lang/Emacs-Lisp/Keyboard-input-Obtain-a-Y-or-N-response +++ /dev/null @@ -1 +0,0 @@ -../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Letter-frequency b/Lang/Emacs-Lisp/Letter-frequency deleted file mode 120000 index fd0ce57ae8..0000000000 --- a/Lang/Emacs-Lisp/Letter-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Letter-frequency/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Ordered-words b/Lang/Emacs-Lisp/Ordered-words deleted file mode 120000 index 444b596fcd..0000000000 --- a/Lang/Emacs-Lisp/Ordered-words +++ /dev/null @@ -1 +0,0 @@ -../../Task/Ordered-words/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Search-a-list b/Lang/Emacs-Lisp/Search-a-list deleted file mode 120000 index 6aef3bcdb0..0000000000 --- a/Lang/Emacs-Lisp/Search-a-list +++ /dev/null @@ -1 +0,0 @@ -../../Task/Search-a-list/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Snake b/Lang/Emacs-Lisp/Snake deleted file mode 120000 index b334d7a373..0000000000 --- a/Lang/Emacs-Lisp/Snake +++ /dev/null @@ -1 +0,0 @@ -../../Task/Snake/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Soundex b/Lang/Emacs-Lisp/Soundex deleted file mode 120000 index d8aeb9b48e..0000000000 --- a/Lang/Emacs-Lisp/Soundex +++ /dev/null @@ -1 +0,0 @@ -../../Task/Soundex/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Split-a-character-string-based-on-change-of-character b/Lang/Emacs-Lisp/Split-a-character-string-based-on-change-of-character deleted file mode 120000 index 7bff70bc55..0000000000 --- a/Lang/Emacs-Lisp/Split-a-character-string-based-on-change-of-character +++ /dev/null @@ -1 +0,0 @@ -../../Task/Split-a-character-string-based-on-change-of-character/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Strip-a-set-of-characters-from-a-string b/Lang/Emacs-Lisp/Strip-a-set-of-characters-from-a-string deleted file mode 120000 index 901b18a4e0..0000000000 --- a/Lang/Emacs-Lisp/Strip-a-set-of-characters-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-a-set-of-characters-from-a-string/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Strip-comments-from-a-string b/Lang/Emacs-Lisp/Strip-comments-from-a-string deleted file mode 120000 index e8fcd5a3c3..0000000000 --- a/Lang/Emacs-Lisp/Strip-comments-from-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strip-comments-from-a-string/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Substitution-cipher b/Lang/Emacs-Lisp/Substitution-cipher deleted file mode 120000 index 93f7ee4d63..0000000000 --- a/Lang/Emacs-Lisp/Substitution-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Substitution-cipher/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Word-frequency b/Lang/Emacs-Lisp/Word-frequency deleted file mode 120000 index 74fd09e7f4..0000000000 --- a/Lang/Emacs-Lisp/Word-frequency +++ /dev/null @@ -1 +0,0 @@ -../../Task/Word-frequency/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Erlang/Cheryls-birthday b/Lang/Erlang/Cheryls-birthday deleted file mode 120000 index 2e3c0e28bc..0000000000 --- a/Lang/Erlang/Cheryls-birthday +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cheryls-birthday/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Determinant-and-permanent b/Lang/Erlang/Determinant-and-permanent deleted file mode 120000 index 1dcba08234..0000000000 --- a/Lang/Erlang/Determinant-and-permanent +++ /dev/null @@ -1 +0,0 @@ -../../Task/Determinant-and-permanent/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Floyd-Warshall-algorithm b/Lang/Erlang/Floyd-Warshall-algorithm deleted file mode 120000 index ac856e6ffa..0000000000 --- a/Lang/Erlang/Floyd-Warshall-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Floyd-Warshall-algorithm/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Long-multiplication b/Lang/Erlang/Long-multiplication deleted file mode 120000 index 12ca47c665..0000000000 --- a/Lang/Erlang/Long-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-multiplication/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Miller-Rabin-primality-test b/Lang/Erlang/Miller-Rabin-primality-test new file mode 120000 index 0000000000..5bdd377694 --- /dev/null +++ b/Lang/Erlang/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Parse-an-IP-Address b/Lang/Erlang/Parse-an-IP-Address deleted file mode 120000 index 3e48d0f0b1..0000000000 --- a/Lang/Erlang/Parse-an-IP-Address +++ /dev/null @@ -1 +0,0 @@ -../../Task/Parse-an-IP-Address/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Stem-and-leaf-plot b/Lang/Erlang/Stem-and-leaf-plot deleted file mode 120000 index 1763f740f3..0000000000 --- a/Lang/Erlang/Stem-and-leaf-plot +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stem-and-leaf-plot/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Strassens-algorithm b/Lang/Erlang/Strassens-algorithm deleted file mode 120000 index 62150c659e..0000000000 --- a/Lang/Erlang/Strassens-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Strassens-algorithm/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Super-d-numbers b/Lang/Erlang/Super-d-numbers deleted file mode 120000 index de46d8ba65..0000000000 --- a/Lang/Erlang/Super-d-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Super-d-numbers/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Tonelli-Shanks-algorithm b/Lang/Erlang/Tonelli-Shanks-algorithm deleted file mode 120000 index 5c601a781e..0000000000 --- a/Lang/Erlang/Tonelli-Shanks-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tonelli-Shanks-algorithm/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Zeckendorf-number-representation b/Lang/Erlang/Zeckendorf-number-representation deleted file mode 120000 index 6a77e53f6b..0000000000 --- a/Lang/Erlang/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/Erlang \ No newline at end of file diff --git a/Lang/Euler/FizzBuzz b/Lang/Euler/FizzBuzz new file mode 120000 index 0000000000..407a608e21 --- /dev/null +++ b/Lang/Euler/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Euler \ No newline at end of file diff --git a/Lang/Euler/Giuga-numbers b/Lang/Euler/Giuga-numbers new file mode 120000 index 0000000000..d2ecdddc43 --- /dev/null +++ b/Lang/Euler/Giuga-numbers @@ -0,0 +1 @@ +../../Task/Giuga-numbers/Euler \ No newline at end of file diff --git a/Lang/Euler/Jensens-Device b/Lang/Euler/Jensens-Device new file mode 120000 index 0000000000..f153ab6bd3 --- /dev/null +++ b/Lang/Euler/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Euler \ No newline at end of file diff --git a/Lang/Euler/Return-multiple-values b/Lang/Euler/Return-multiple-values new file mode 120000 index 0000000000..661e0398e8 --- /dev/null +++ b/Lang/Euler/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Euler \ No newline at end of file diff --git a/Lang/Euler/Sum-and-product-of-an-array b/Lang/Euler/Sum-and-product-of-an-array new file mode 120000 index 0000000000..da7cbd08c8 --- /dev/null +++ b/Lang/Euler/Sum-and-product-of-an-array @@ -0,0 +1 @@ +../../Task/Sum-and-product-of-an-array/Euler \ No newline at end of file diff --git a/Lang/Euler/Sum-of-squares b/Lang/Euler/Sum-of-squares new file mode 120000 index 0000000000..1bc1bddf09 --- /dev/null +++ b/Lang/Euler/Sum-of-squares @@ -0,0 +1 @@ +../../Task/Sum-of-squares/Euler \ No newline at end of file diff --git a/Lang/Euphoria/00-LANG.txt b/Lang/Euphoria/00-LANG.txt index 9dc38ade08..702dca9e88 100644 --- a/Lang/Euphoria/00-LANG.txt +++ b/Lang/Euphoria/00-LANG.txt @@ -18,7 +18,4 @@ Euphoria is a powerful yet simple programming language, developed by Robert Crai ==See also== * [[wp:Euphoria (programming language)|Euphoria on Wikipedia]] * [http://rapideuphoria.com/ RapidEuphoria site] -* [http://openeuphoria.org/ openEuphoria site] - -==Todo== -[https://rosettacode.org/wiki/Tasks_not_implemented_in_Euphoria Tasks not implemented in Euphoria] \ No newline at end of file +* [http://openeuphoria.org/ openEuphoria site] \ No newline at end of file diff --git a/Lang/Euphoria/Calculating-the-value-of-e b/Lang/Euphoria/Calculating-the-value-of-e deleted file mode 120000 index ae2255b209..0000000000 --- a/Lang/Euphoria/Calculating-the-value-of-e +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calculating-the-value-of-e/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Combinations b/Lang/Euphoria/Combinations deleted file mode 120000 index 10b7f0283e..0000000000 --- a/Lang/Euphoria/Combinations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Convert-seconds-to-compound-duration b/Lang/Euphoria/Convert-seconds-to-compound-duration deleted file mode 120000 index 91ba9055cf..0000000000 --- a/Lang/Euphoria/Convert-seconds-to-compound-duration +++ /dev/null @@ -1 +0,0 @@ -../../Task/Convert-seconds-to-compound-duration/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Empty-program b/Lang/Euphoria/Empty-program new file mode 120000 index 0000000000..241cd5711b --- /dev/null +++ b/Lang/Euphoria/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/File-size-distribution b/Lang/Euphoria/File-size-distribution deleted file mode 120000 index a10a0eb48b..0000000000 --- a/Lang/Euphoria/File-size-distribution +++ /dev/null @@ -1 +0,0 @@ -../../Task/File-size-distribution/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Nth b/Lang/Euphoria/Nth deleted file mode 120000 index 6f87edee5c..0000000000 --- a/Lang/Euphoria/Nth +++ /dev/null @@ -1 +0,0 @@ -../../Task/Nth/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Quaternion-type b/Lang/Euphoria/Quaternion-type new file mode 120000 index 0000000000..aedb6b51e1 --- /dev/null +++ b/Lang/Euphoria/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Repeat b/Lang/Euphoria/Repeat deleted file mode 120000 index 750ad0f53c..0000000000 --- a/Lang/Euphoria/Repeat +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat/Euphoria \ No newline at end of file diff --git a/Lang/Evaldraw/00-LANG.txt b/Lang/Evaldraw/00-LANG.txt deleted file mode 100644 index 5031d48124..0000000000 --- a/Lang/Evaldraw/00-LANG.txt +++ /dev/null @@ -1,102 +0,0 @@ - -{{language -|exec=machine -|gc=no -|safety=unsafe -|parampass=value -|checking=static -|strength=weak -|tags=c -}}{{language programming paradigm|Imperative}} - -'''EVALDRAW''' is a quirky little programming tool that can be used to make small applications and games, or even do 1D, 2D or 3D graphs, or create custom musical instruments. -Evaldraw is technically a tool and not the language, however, since RSCRIPT and Evaldraw are tied together, we can consider Evaldraw a programming language in itself. From this point, this article will refer to the capabilities of RSCRIPT and Evaldraw together. - -==Compiler modes== - -* '''EVAL''' the initially bundled compiler, developed by Ken Silverman. Had only doubles and arrays of doubles. -* '''RSCRIPT''' added in 2010 and created by Robert Rodgers. Added support for structs, making entities to handle. Easier to translate to C. - -==Overview== - -Evaldraw has syntax similar to C. - -===Curly Braces=== - -EVALDRAW supports grouping multiple statements in curly braces. They are not needed for single statements. - -===Semicolons=== - -All statements, except for the last statement in a function must end with a semicolon; - -===Functions=== - -Functions all return an implicit double value from the last statement in the function. -Parameters passed to functions can be doubles, arrays or structs. - -===Statements=== - -The following statements are supported: -* IF and IF-ELSE (but no SWITCH-case) -* Loop constructs such as DO{ codeblock }WHILE(condition); WHILE(cond){ block } and the FOR-loop as in C. -* goto label and label: declaration similar to C. -* a RETURN statement can at any point in a function return a floating point number. The last value is implicitly returned. -* BREAK and CONTINUE statements. Loops can be exited with BREAK, or remainder of code body can be skipped with CONTINUE. -* ENUMs allow the programmer to give numerical constants names. Dependencies between enum values are possible, allowing the programmer to make one enum a calculation based on previous enum values. -* Variables can be declared automatically on the local stack, or using the STATIC modifier to make a variable global. - -===Case insensitive=== -All names and keywords are case insensitive. This can create some confusion when porting from- or to C. - -===All you need is 64-bit float=== - -All variables, also those declared in structs are double. If no type is supplied, double is assumed. -All functions return a double. - -===Arrays=== -Arrays that are power of two are wrapped, non power-of-two arrays set index zero if accessed out of bounds. -For example, if we define static xcoords[4]; and try to access xcoords[5] we the returned value is at index 5%4 which is xcoords[1]. - -===Structs=== -Structs can be declared and be passed as function parameters. -A struct may doubles, arrays of doubles and other structs. - -For example struct vec{x,y,z;}; defines a struct with 3 fields. -struct boid_t{ vec pos; vec dir; } defines a struct that contains substructs pos and dir. - -===Pass by value or pass by ref=== -Doubles are passed by value, but can be passed by ref by prefixing a & symbol. -All other variables, arrays and structs are passed by ref. - -===Builtins=== -There are many built in functions. -The EVAL and RSCRIPT compiler modes support the following 1-param functions: -* ABS - gives the absolute value. Same as fabs in C. -* ACOS - arcos in radians -* ASIN - arsin in radians -* ATAN - arctan in radians -* ATN - alias for atan -* CEIL - round a value up to nearest integer. -* COS - cosine in radians -* EXP - raise Eulers number to some power. EXP(1) = 2.718281 -* FABS - alias for ABS -* FACT - factorial. FACT(5) = 5! -* FLOOR - round a value down to nearest integer. -* INT - different from floor, truncates (removes decimals). -* LOG - returns the natural logarithm of x. LOG(x) = ln(x) -* SGN - returns the sign of a number. -1, 0 or +1 -* SIN - sine in radians -* SQRT - square root -* TAN - tan in radians -* UNIT - returns the unit function of x. Returns 0.0 for x<0, 0.5 for x==0 and 1.0 for x>0. - -And the following two param functions: -* ATAN2(x,y) - gives angle in radians from positive x-axis to some point x,y. -* FADD - eval and rscript compatibility. -* FMOD - alternative to modulus % operator. -* LOG(x,b) - return log of x with base b. -* MIN(a,b) - return smallest -* MAX(a,b) - return largest -* POW(a,b) - raise a to power b - -There is no concept of include statements or libraries. It is assumed evaldraw programs are small scripts to try out ideas that later will be integrated into a professional programming language such as C. \ No newline at end of file diff --git a/Lang/Evaldraw/00-META.yaml b/Lang/Evaldraw/00-META.yaml deleted file mode 100644 index 4dff698a21..0000000000 --- a/Lang/Evaldraw/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Evaldraw diff --git a/Lang/Evaldraw/Bitmap-Midpoint-circle-algorithm b/Lang/Evaldraw/Bitmap-Midpoint-circle-algorithm deleted file mode 120000 index 732c70e6bd..0000000000 --- a/Lang/Evaldraw/Bitmap-Midpoint-circle-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bitmap-Midpoint-circle-algorithm/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Brownian-tree b/Lang/Evaldraw/Brownian-tree deleted file mode 120000 index 0f66f104b4..0000000000 --- a/Lang/Evaldraw/Brownian-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/Brownian-tree/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Draw-a-clock b/Lang/Evaldraw/Draw-a-clock deleted file mode 120000 index 7b8f5d2c12..0000000000 --- a/Lang/Evaldraw/Draw-a-clock +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-clock/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Draw-a-cuboid b/Lang/Evaldraw/Draw-a-cuboid deleted file mode 120000 index ad6b9a59e0..0000000000 --- a/Lang/Evaldraw/Draw-a-cuboid +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-cuboid/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Draw-a-pixel b/Lang/Evaldraw/Draw-a-pixel deleted file mode 120000 index f0b3d6eb37..0000000000 --- a/Lang/Evaldraw/Draw-a-pixel +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-pixel/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Draw-a-rotating-cube b/Lang/Evaldraw/Draw-a-rotating-cube deleted file mode 120000 index db1cc3c9ca..0000000000 --- a/Lang/Evaldraw/Draw-a-rotating-cube +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-rotating-cube/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Draw-a-sphere b/Lang/Evaldraw/Draw-a-sphere deleted file mode 120000 index 47572e62bb..0000000000 --- a/Lang/Evaldraw/Draw-a-sphere +++ /dev/null @@ -1 +0,0 @@ -../../Task/Draw-a-sphere/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Find-if-a-point-is-within-a-triangle b/Lang/Evaldraw/Find-if-a-point-is-within-a-triangle deleted file mode 120000 index ba57b42d05..0000000000 --- a/Lang/Evaldraw/Find-if-a-point-is-within-a-triangle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-if-a-point-is-within-a-triangle/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Find-the-intersection-of-a-line-with-a-plane b/Lang/Evaldraw/Find-the-intersection-of-a-line-with-a-plane deleted file mode 120000 index b0041d3a8e..0000000000 --- a/Lang/Evaldraw/Find-the-intersection-of-a-line-with-a-plane +++ /dev/null @@ -1 +0,0 @@ -../../Task/Find-the-intersection-of-a-line-with-a-plane/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Forest-fire b/Lang/Evaldraw/Forest-fire deleted file mode 120000 index 757c62c9b4..0000000000 --- a/Lang/Evaldraw/Forest-fire +++ /dev/null @@ -1 +0,0 @@ -../../Task/Forest-fire/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Fractal-tree b/Lang/Evaldraw/Fractal-tree deleted file mode 120000 index ce7aebb8a5..0000000000 --- a/Lang/Evaldraw/Fractal-tree +++ /dev/null @@ -1 +0,0 @@ -../../Task/Fractal-tree/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Munching-squares b/Lang/Evaldraw/Munching-squares deleted file mode 120000 index ba05ebca80..0000000000 --- a/Lang/Evaldraw/Munching-squares +++ /dev/null @@ -1 +0,0 @@ -../../Task/Munching-squares/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Perlin-noise b/Lang/Evaldraw/Perlin-noise deleted file mode 120000 index 91b7dec527..0000000000 --- a/Lang/Evaldraw/Perlin-noise +++ /dev/null @@ -1 +0,0 @@ -../../Task/Perlin-noise/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Sierpinski-triangle-Graphical b/Lang/Evaldraw/Sierpinski-triangle-Graphical deleted file mode 120000 index fd95d1d620..0000000000 --- a/Lang/Evaldraw/Sierpinski-triangle-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-triangle-Graphical/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Sutherland-Hodgman-polygon-clipping b/Lang/Evaldraw/Sutherland-Hodgman-polygon-clipping deleted file mode 120000 index 3381508835..0000000000 --- a/Lang/Evaldraw/Sutherland-Hodgman-polygon-clipping +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sutherland-Hodgman-polygon-clipping/Evaldraw \ No newline at end of file diff --git a/Lang/Evaldraw/Yin-and-yang b/Lang/Evaldraw/Yin-and-yang deleted file mode 120000 index ba36a16954..0000000000 --- a/Lang/Evaldraw/Yin-and-yang +++ /dev/null @@ -1 +0,0 @@ -../../Task/Yin-and-yang/Evaldraw \ No newline at end of file diff --git a/Lang/Excel/Arrays b/Lang/Excel/Arrays deleted file mode 120000 index bad8c856a9..0000000000 --- a/Lang/Excel/Arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arrays/Excel \ No newline at end of file diff --git a/Lang/Excel/Cholesky-decomposition b/Lang/Excel/Cholesky-decomposition deleted file mode 120000 index 2db67f4a20..0000000000 --- a/Lang/Excel/Cholesky-decomposition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Cholesky-decomposition/Excel \ No newline at end of file diff --git a/Lang/Excel/Conditional-structures b/Lang/Excel/Conditional-structures deleted file mode 120000 index f4ffdbd4b9..0000000000 --- a/Lang/Excel/Conditional-structures +++ /dev/null @@ -1 +0,0 @@ -../../Task/Conditional-structures/Excel \ No newline at end of file diff --git a/Lang/Excel/Damm-algorithm b/Lang/Excel/Damm-algorithm deleted file mode 120000 index f736e88724..0000000000 --- a/Lang/Excel/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/Excel \ No newline at end of file diff --git a/Lang/Excel/Entropy b/Lang/Excel/Entropy deleted file mode 120000 index 8d4e6441d6..0000000000 --- a/Lang/Excel/Entropy +++ /dev/null @@ -1 +0,0 @@ -../../Task/Entropy/Excel \ No newline at end of file diff --git a/Lang/Excel/FizzBuzz b/Lang/Excel/FizzBuzz deleted file mode 120000 index 15df08a856..0000000000 --- a/Lang/Excel/FizzBuzz +++ /dev/null @@ -1 +0,0 @@ -../../Task/FizzBuzz/Excel \ No newline at end of file diff --git a/Lang/Excel/Function-definition b/Lang/Excel/Function-definition deleted file mode 120000 index e6ecf64bef..0000000000 --- a/Lang/Excel/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/Excel \ No newline at end of file diff --git a/Lang/Excel/Jacobi-symbol b/Lang/Excel/Jacobi-symbol deleted file mode 120000 index 85f7061c07..0000000000 --- a/Lang/Excel/Jacobi-symbol +++ /dev/null @@ -1 +0,0 @@ -../../Task/Jacobi-symbol/Excel \ No newline at end of file diff --git a/Lang/Excel/Loops-For b/Lang/Excel/Loops-For deleted file mode 120000 index 876b47b179..0000000000 --- a/Lang/Excel/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Excel \ No newline at end of file diff --git a/Lang/Excel/Repeat-a-string b/Lang/Excel/Repeat-a-string deleted file mode 120000 index 2c684073cb..0000000000 --- a/Lang/Excel/Repeat-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Repeat-a-string/Excel \ No newline at end of file diff --git a/Lang/Excel/Reverse-a-string b/Lang/Excel/Reverse-a-string deleted file mode 120000 index 2a3cf97cfe..0000000000 --- a/Lang/Excel/Reverse-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Reverse-a-string/Excel \ No newline at end of file diff --git a/Lang/Excel/Tokenize-a-string b/Lang/Excel/Tokenize-a-string deleted file mode 120000 index 9d5af3b4b4..0000000000 --- a/Lang/Excel/Tokenize-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tokenize-a-string/Excel \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/00-LANG.txt b/Lang/Extended-Color-BASIC/00-LANG.txt deleted file mode 100644 index 17efd36e93..0000000000 --- a/Lang/Extended-Color-BASIC/00-LANG.txt +++ /dev/null @@ -1,7 +0,0 @@ -{{language|Extended Color BASIC}} - -Microsoft Extended Color BASIC the BASIC interpreter for the Tandy Color Computer and the Dragon Data Motorola 6809 processor based machines. - -==See Also== -* [[wp:Extended Color BASIC|Wikipedia: Extended Color BASIC]] -* [[Tasks not Implemented in Extended Color BASIC]] \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/00-META.yaml b/Lang/Extended-Color-BASIC/00-META.yaml deleted file mode 100644 index 57e9e4028d..0000000000 --- a/Lang/Extended-Color-BASIC/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:Extended_Color_BASIC diff --git a/Lang/Extended-Color-BASIC/Arrays b/Lang/Extended-Color-BASIC/Arrays deleted file mode 120000 index 2ca9fdf8eb..0000000000 --- a/Lang/Extended-Color-BASIC/Arrays +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arrays/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Copy-a-string b/Lang/Extended-Color-BASIC/Copy-a-string deleted file mode 120000 index 7a931a182a..0000000000 --- a/Lang/Extended-Color-BASIC/Copy-a-string +++ /dev/null @@ -1 +0,0 @@ -../../Task/Copy-a-string/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Hello-world-Text b/Lang/Extended-Color-BASIC/Hello-world-Text deleted file mode 120000 index b5cfbf6b90..0000000000 --- a/Lang/Extended-Color-BASIC/Hello-world-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Text/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Loops-For b/Lang/Extended-Color-BASIC/Loops-For deleted file mode 120000 index 8719420a7c..0000000000 --- a/Lang/Extended-Color-BASIC/Loops-For +++ /dev/null @@ -1 +0,0 @@ -../../Task/Loops-For/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Quine b/Lang/Extended-Color-BASIC/Quine deleted file mode 120000 index fb6135d264..0000000000 --- a/Lang/Extended-Color-BASIC/Quine +++ /dev/null @@ -1 +0,0 @@ -../../Task/Quine/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/User-input-Text b/Lang/Extended-Color-BASIC/User-input-Text deleted file mode 120000 index 545233f9b1..0000000000 --- a/Lang/Extended-Color-BASIC/User-input-Text +++ /dev/null @@ -1 +0,0 @@ -../../Task/User-input-Text/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/F-Sharp/00-LANG.txt b/Lang/F-Sharp/00-LANG.txt index db0c37eee0..ba98a5db01 100644 --- a/Lang/F-Sharp/00-LANG.txt +++ b/Lang/F-Sharp/00-LANG.txt @@ -9,9 +9,8 @@ It is based on the [[Caml]] language, and resembles it in syntax. F# is included as an 'official' .NET language in [[Visual Studio]] 2010 and later. -==Links== +==External Links== * [http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/default.aspx F# Website at Microsoft] * [http://blogs.msdn.com/dsyme/ Don Syme's F# Weblog] -* [[Tasks_not_implemented_in_F_Sharp]] [[Category:Caml Implementations]] \ No newline at end of file diff --git a/Lang/F-Sharp/AKS-test-for-primes b/Lang/F-Sharp/AKS-test-for-primes deleted file mode 120000 index 8cadb5934e..0000000000 --- a/Lang/F-Sharp/AKS-test-for-primes +++ /dev/null @@ -1 +0,0 @@ -../../Task/AKS-test-for-primes/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Bifid-cipher b/Lang/F-Sharp/Bifid-cipher deleted file mode 120000 index 4ac927ed58..0000000000 --- a/Lang/F-Sharp/Bifid-cipher +++ /dev/null @@ -1 +0,0 @@ -../../Task/Bifid-cipher/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Call-an-object-method b/Lang/F-Sharp/Call-an-object-method deleted file mode 120000 index 69c90b1041..0000000000 --- a/Lang/F-Sharp/Call-an-object-method +++ /dev/null @@ -1 +0,0 @@ -../../Task/Call-an-object-method/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Define-a-primitive-data-type b/Lang/F-Sharp/Define-a-primitive-data-type deleted file mode 120000 index ef08834748..0000000000 --- a/Lang/F-Sharp/Define-a-primitive-data-type +++ /dev/null @@ -1 +0,0 @@ -../../Task/Define-a-primitive-data-type/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Dice-game-probabilities b/Lang/F-Sharp/Dice-game-probabilities deleted file mode 120000 index 70c873d7d5..0000000000 --- a/Lang/F-Sharp/Dice-game-probabilities +++ /dev/null @@ -1 +0,0 @@ -../../Task/Dice-game-probabilities/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Golden-ratio-Convergence b/Lang/F-Sharp/Golden-ratio-Convergence deleted file mode 120000 index beb42e1ac6..0000000000 --- a/Lang/F-Sharp/Golden-ratio-Convergence +++ /dev/null @@ -1 +0,0 @@ -../../Task/Golden-ratio-Convergence/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Hilbert-curve b/Lang/F-Sharp/Hilbert-curve deleted file mode 120000 index 556d6ba0f5..0000000000 --- a/Lang/F-Sharp/Hilbert-curve +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hilbert-curve/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/I-before-E-except-after-C b/Lang/F-Sharp/I-before-E-except-after-C deleted file mode 120000 index 67d12030f9..0000000000 --- a/Lang/F-Sharp/I-before-E-except-after-C +++ /dev/null @@ -1 +0,0 @@ -../../Task/I-before-E-except-after-C/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Kronecker-product b/Lang/F-Sharp/Kronecker-product deleted file mode 120000 index 683005869b..0000000000 --- a/Lang/F-Sharp/Kronecker-product +++ /dev/null @@ -1 +0,0 @@ -../../Task/Kronecker-product/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Long-literals-with-continuations b/Lang/F-Sharp/Long-literals-with-continuations deleted file mode 120000 index 25a8149ce8..0000000000 --- a/Lang/F-Sharp/Long-literals-with-continuations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-literals-with-continuations/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Long-multiplication b/Lang/F-Sharp/Long-multiplication new file mode 120000 index 0000000000..a8ece45d37 --- /dev/null +++ b/Lang/F-Sharp/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Long-year b/Lang/F-Sharp/Long-year deleted file mode 120000 index 94b40682e9..0000000000 --- a/Lang/F-Sharp/Long-year +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-year/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Mad-Libs b/Lang/F-Sharp/Mad-Libs deleted file mode 120000 index 69a30ced53..0000000000 --- a/Lang/F-Sharp/Mad-Libs +++ /dev/null @@ -1 +0,0 @@ -../../Task/Mad-Libs/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Maximum-triangle-path-sum b/Lang/F-Sharp/Maximum-triangle-path-sum deleted file mode 120000 index 2a3b549ec5..0000000000 --- a/Lang/F-Sharp/Maximum-triangle-path-sum +++ /dev/null @@ -1 +0,0 @@ -../../Task/Maximum-triangle-path-sum/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Miller-Rabin-primality-test b/Lang/F-Sharp/Miller-Rabin-primality-test new file mode 120000 index 0000000000..4b1a1d67d8 --- /dev/null +++ b/Lang/F-Sharp/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Minkowski-question-mark-function b/Lang/F-Sharp/Minkowski-question-mark-function deleted file mode 120000 index 7a9886265b..0000000000 --- a/Lang/F-Sharp/Minkowski-question-mark-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Minkowski-question-mark-function/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Multi-dimensional-array b/Lang/F-Sharp/Multi-dimensional-array deleted file mode 120000 index 0d6b1aaed5..0000000000 --- a/Lang/F-Sharp/Multi-dimensional-array +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multi-dimensional-array/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Multiplicative-order b/Lang/F-Sharp/Multiplicative-order deleted file mode 120000 index b2064cc3e0..0000000000 --- a/Lang/F-Sharp/Multiplicative-order +++ /dev/null @@ -1 +0,0 @@ -../../Task/Multiplicative-order/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Old-lady-swallowed-a-fly b/Lang/F-Sharp/Old-lady-swallowed-a-fly deleted file mode 120000 index 066ed3c32b..0000000000 --- a/Lang/F-Sharp/Old-lady-swallowed-a-fly +++ /dev/null @@ -1 +0,0 @@ -../../Task/Old-lady-swallowed-a-fly/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Probabilistic-choice b/Lang/F-Sharp/Probabilistic-choice deleted file mode 120000 index b7d2692fe4..0000000000 --- a/Lang/F-Sharp/Probabilistic-choice +++ /dev/null @@ -1 +0,0 @@ -../../Task/Probabilistic-choice/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Quaternion-type b/Lang/F-Sharp/Quaternion-type new file mode 120000 index 0000000000..2de1d9f870 --- /dev/null +++ b/Lang/F-Sharp/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Same-fringe b/Lang/F-Sharp/Same-fringe deleted file mode 120000 index 04d84b3c5a..0000000000 --- a/Lang/F-Sharp/Same-fringe +++ /dev/null @@ -1 +0,0 @@ -../../Task/Same-fringe/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Secure-temporary-file b/Lang/F-Sharp/Secure-temporary-file deleted file mode 120000 index 525cda7b5d..0000000000 --- a/Lang/F-Sharp/Secure-temporary-file +++ /dev/null @@ -1 +0,0 @@ -../../Task/Secure-temporary-file/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Sockets b/Lang/F-Sharp/Sockets deleted file mode 120000 index 13e34e4285..0000000000 --- a/Lang/F-Sharp/Sockets +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sockets/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Sort-a-list-of-object-identifiers b/Lang/F-Sharp/Sort-a-list-of-object-identifiers deleted file mode 120000 index 396fa34539..0000000000 --- a/Lang/F-Sharp/Sort-a-list-of-object-identifiers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-a-list-of-object-identifiers/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Sort-numbers-lexicographically b/Lang/F-Sharp/Sort-numbers-lexicographically deleted file mode 120000 index bcc33d5bb2..0000000000 --- a/Lang/F-Sharp/Sort-numbers-lexicographically +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sort-numbers-lexicographically/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Sorting-algorithms-Strand-sort b/Lang/F-Sharp/Sorting-algorithms-Strand-sort deleted file mode 120000 index 0a9c6a6f0f..0000000000 --- a/Lang/F-Sharp/Sorting-algorithms-Strand-sort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Strand-sort/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Stair-climbing-puzzle b/Lang/F-Sharp/Stair-climbing-puzzle deleted file mode 120000 index e1348f8b99..0000000000 --- a/Lang/F-Sharp/Stair-climbing-puzzle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Stair-climbing-puzzle/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Thue-Morse b/Lang/F-Sharp/Thue-Morse deleted file mode 120000 index 32428af765..0000000000 --- a/Lang/F-Sharp/Thue-Morse +++ /dev/null @@ -1 +0,0 @@ -../../Task/Thue-Morse/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Variable-length-quantity b/Lang/F-Sharp/Variable-length-quantity deleted file mode 120000 index 2c43b02869..0000000000 --- a/Lang/F-Sharp/Variable-length-quantity +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variable-length-quantity/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Variadic-function b/Lang/F-Sharp/Variadic-function deleted file mode 120000 index d32ee2a40f..0000000000 --- a/Lang/F-Sharp/Variadic-function +++ /dev/null @@ -1 +0,0 @@ -../../Task/Variadic-function/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Wireworld b/Lang/F-Sharp/Wireworld deleted file mode 120000 index 32d571d649..0000000000 --- a/Lang/F-Sharp/Wireworld +++ /dev/null @@ -1 +0,0 @@ -../../Task/Wireworld/F-Sharp \ No newline at end of file diff --git a/Lang/FALSE/Empty-program b/Lang/FALSE/Empty-program new file mode 120000 index 0000000000..35445789cd --- /dev/null +++ b/Lang/FALSE/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Zeckendorf-number-representation b/Lang/FALSE/Zeckendorf-number-representation deleted file mode 120000 index fdef231a56..0000000000 --- a/Lang/FALSE/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/FALSE \ No newline at end of file diff --git a/Lang/FOCAL/Combinations b/Lang/FOCAL/Combinations deleted file mode 120000 index 882a5e580d..0000000000 --- a/Lang/FOCAL/Combinations +++ /dev/null @@ -1 +0,0 @@ -../../Task/Combinations/FOCAL \ No newline at end of file diff --git a/Lang/FOCAL/Count-the-coins b/Lang/FOCAL/Count-the-coins deleted file mode 120000 index 6334bdc3d9..0000000000 --- a/Lang/FOCAL/Count-the-coins +++ /dev/null @@ -1 +0,0 @@ -../../Task/Count-the-coins/FOCAL \ No newline at end of file diff --git a/Lang/FOCAL/Hunt-the-Wumpus b/Lang/FOCAL/Hunt-the-Wumpus deleted file mode 120000 index 098e817517..0000000000 --- a/Lang/FOCAL/Hunt-the-Wumpus +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hunt-the-Wumpus/FOCAL \ No newline at end of file diff --git a/Lang/FOCAL/Magic-8-ball b/Lang/FOCAL/Magic-8-ball deleted file mode 120000 index 4e734aa073..0000000000 --- a/Lang/FOCAL/Magic-8-ball +++ /dev/null @@ -1 +0,0 @@ -../../Task/Magic-8-ball/FOCAL \ No newline at end of file diff --git a/Lang/FOCAL/Sierpinski-carpet b/Lang/FOCAL/Sierpinski-carpet deleted file mode 120000 index 986467c5d7..0000000000 --- a/Lang/FOCAL/Sierpinski-carpet +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sierpinski-carpet/FOCAL \ No newline at end of file diff --git a/Lang/FOCAL/Smith-numbers b/Lang/FOCAL/Smith-numbers deleted file mode 120000 index 3ffdfd37fd..0000000000 --- a/Lang/FOCAL/Smith-numbers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Smith-numbers/FOCAL \ No newline at end of file diff --git a/Lang/FOCAL/Zeckendorf-number-representation b/Lang/FOCAL/Zeckendorf-number-representation deleted file mode 120000 index d0cbc5b4d2..0000000000 --- a/Lang/FOCAL/Zeckendorf-number-representation +++ /dev/null @@ -1 +0,0 @@ -../../Task/Zeckendorf-number-representation/FOCAL \ No newline at end of file diff --git a/Lang/Factor/00-LANG.txt b/Lang/Factor/00-LANG.txt index bb19ed678a..2eaeb516fd 100644 --- a/Lang/Factor/00-LANG.txt +++ b/Lang/Factor/00-LANG.txt @@ -1,6 +1,6 @@ {{language |exec=machine -|site=https://factorcode.org +|site=http://factorcode.org |gc=yes |parampass=reference |safety=safe @@ -12,9 +12,9 @@ |LCT=yes}} Factor is a stack-based, concatenative, general-purpose programming language with a focus on practicality. -Initially developed by Slava Pestov, Factor began life in 2003 as a scripting language written for a game. The implementation was originally an interpreter written in [[Java]], but has since gained an optimizing compiler and has been rewritten in Factor with a minimal [[C++]] core. Read more about Factor's implementation history [https://concatenative.org/wiki/view/Factor/Implementation%20history here]. Factor is still being developed by dozens of contributors, with the latest [https://re.factorcode.org/2023/08/factor-0-99-now-available.html stable release] in August 2023. +Initially developed by Slava Pestov, Factor began life in 2003 as a scripting language written for a game. The implementation was originally an interpreter written in [[Java]], but has since gained an optimizing compiler and has been rewritten in Factor with a minimal [[C++]] core. Read more about Factor's implementation history [http://concatenative.org/wiki/view/Factor/Implementation%20history here]. As of June 2020, Factor is still being developed by several contributors, with the latest [http://re-factor.blogspot.com/2018/07/factor-098-now-available.html stable release] in July 2018. -Factor is a stack language similar to, but of a higher level than, [[Forth]]. Factor is a [https://concatenative.org/wiki/view/Concatenative%20language concatenative language], meaning that rather than applying functions to arguments (applicative languages) to evaluate things, we compose functions to evaluate a single piece of data — the entire program up until that particular point. In Factor, the basic structure of data flow is function composition. That is, foo bar baz is equivalent to baz(bar(foo())) in an applicative language. This offers a nice left-to-right style of reading and data flow. +Factor is a stack language similar to, but of a higher level than, [[Forth]]. Factor is a [http://concatenative.org/wiki/view/Concatenative%20language concatenative language], meaning that rather than applying functions to arguments (applicative languages) to evaluate things, we compose functions to evaluate a single piece of data — the entire program up until that particular point. In Factor, the basic structure of data flow is function composition. That is, foo bar baz is equivalent to baz(bar(foo())) in an applicative language. This offers a nice left-to-right style of reading and data flow. In Factor, we tend to name data flow operations rather than values. In an applicative language, you might write var x = ...; @@ -24,11 +24,11 @@ In Factor this is a data flow pattern called bi. [ foo ] [ bar ] bi This says, "apply foo to the object at the top of the data stack, and apply bar to it as well." Rather than naming the values x, y, and z, we named the data flow pattern. -Factor comes with many practical features, including a [[Interactive programming (repl)#Factor|REPL]], a self-contained help browser, an object inspector, a debugger/code walker, a deployment tool, editor integration for most popular text editors and [[IDE]]s, and introspection capabilities useful for developers. Factor has a fully-featured library, including things such as an HTTP server/client, bindings to graphics libraries and databases, a [[C]] [[FFI]], a cross-platform [[GUI]] framework, on down to niche things like polynomial arithmetic. Factor features an object system that takes inspiration from [[Common Lisp]] and [[Self]]. +Factor comes with many practical features, including a REPL, a self-contained help browser, an object inspector, a debugger/code walker, a deployment tool, editor integration for most popular text editors and IDEs, and introspection capabilities useful for developers. Factor has a fully-featured library, including things such as an HTTP server/client, bindings to graphics libraries and databases, a C FFI, a cross-platform GUI framework, on down to niche things like polynomial arithmetic. Factor features an object system that takes inspiration from [[Common Lisp]] and [[Self]]. Most code tends to be expressed naturally in a functional manner. Factor comes with combinators (higher-order functions) typically seen in functional languages, such as map, filter, reduce, and many more. Although most things can be done efficiently without mutation, Factor doesn't shy away from it when it's useful. Mutating words end with exclamation points (by convention). Factor provides lexical and dynamic variables which can make writing imperative code more natural, or allows one to clean up code that performs a lot of stack shuffling. -One of Factor's greatest strengths is its ability to factor words into smaller words. Due to the nature of [[concatenative programming]], this is typically a cut and paste job that can be done almost anywhere there is whitespace. Factor also has impressive metaprogramming capabilities. Since Factor is almost entirely written in Factor, there is full introspection support, including seamless access to Factor's parser, allowing one to define new syntax. Factor also offers [[Lisp]]-style macros, and in general, Factor code can be treated like a collection ([https://en.wikipedia.org/wiki/Homoiconicity homoiconicity]). +One of Factor's greatest strengths is its ability to factor words into smaller words. Due to the nature of concatenative programming, this is typically a cut and paste job that can be done almost anywhere there is whitespace. Factor also has impressive metaprogramming capabilities. Since Factor is almost entirely written in Factor, there is full introspection support, including seamless access to Factor's parser, allowing one to define new syntax. Factor also offers Lisp-style macros, and in general, Factor code can be treated like a collection ([https://en.wikipedia.org/wiki/Homoiconicity homoiconicity]). ==About Factor examples on Rosetta Code== Most of the newer examples are meant to be copied and pasted directly into the listener (Factor's REPL) where they should run without issue. In order to deploy the examples to binaries or run them as scripts, you'll need to put them in a vocabulary (e.g. IN: myvocab and set a MAIN: word which acts as the entry point for the program. If an example doesn't run, it probably means that the example only works in an older version of Factor. Most of the time, this is because certain words have been changed without maintaining backwards compatibility (e.g. iota became in Factor 0.98). @@ -37,13 +37,10 @@ For this reason, it is advised that examples use the works with tem
{{works with|Factor|0.98}}
becomes {{works with|Factor|0.98}} -==Todo== -[https://rosettacode.org/wiki/Tasks_not_implemented_in_Factor Tasks not implemented in Factor] - ==Links== -*[https://factorcode.org Factor programming language] -*[https://planet.factorcode.org Planet Factor] -*[https://concatenative.org/wiki/view/Factor Factor on concatenative.org] +*[http://factorcode.org Factor programming language] +*[http://planet.factorcode.org Planet Factor] +*[http://concatenative.org/wiki/view/Factor Factor on concatenative.org] *[https://en.wikipedia.org/wiki/Factor_(programming_language) Factor on Wikipedia] {{Language programming paradigm|Concatenative}} \ No newline at end of file diff --git a/Lang/Factor/Best-shuffle b/Lang/Factor/Best-shuffle deleted file mode 120000 index a10c8f5d14..0000000000 --- a/Lang/Factor/Best-shuffle +++ /dev/null @@ -1 +0,0 @@ -../../Task/Best-shuffle/Factor \ No newline at end of file diff --git a/Lang/Factor/Bioinformatics-base-count b/Lang/Factor/Bioinformatics-base-count new file mode 120000 index 0000000000..cf4a54a26f --- /dev/null +++ b/Lang/Factor/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/Factor \ No newline at end of file diff --git a/Lang/Factor/Quaternion-type b/Lang/Factor/Quaternion-type new file mode 120000 index 0000000000..47f0548ea8 --- /dev/null +++ b/Lang/Factor/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Factor \ No newline at end of file diff --git a/Lang/Factor/Tic-tac-toe b/Lang/Factor/Tic-tac-toe deleted file mode 120000 index 183c5fb3e0..0000000000 --- a/Lang/Factor/Tic-tac-toe +++ /dev/null @@ -1 +0,0 @@ -../../Task/Tic-tac-toe/Factor \ No newline at end of file diff --git a/Lang/Fe/00-LANG.txt b/Lang/Fe/00-LANG.txt index 526acc2adb..e459a4ddde 100644 --- a/Lang/Fe/00-LANG.txt +++ b/Lang/Fe/00-LANG.txt @@ -1,5 +1,6 @@ {{language|exec=interpreted|checking=dynamic|gc=yes|site=https://github.com/rxi/fe}} -fe is a '''tiny''', embeddable language implemented in ANSI C. +== '''fe''' == +A '''tiny''', embeddable language implemented in ANSI C (= reverse (fn (lst) (let res nil) diff --git a/Lang/Fennel/00-LANG.txt b/Lang/Fennel/00-LANG.txt index a3b3fb9075..548a2dac3c 100644 --- a/Lang/Fennel/00-LANG.txt +++ b/Lang/Fennel/00-LANG.txt @@ -1,4 +1,4 @@ -{{language|Fennel|hopl=no|site=https://fennel-lang.org/}} +{{language|Fennel}} According to Fennel website: Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system. -
-;Related tasks: -* [[Convert_CSV_records_to_TSV]]

+ diff --git a/Task/CSV-data-manipulation/ALGOL-68/csv-data-manipulation.alg b/Task/CSV-data-manipulation/ALGOL-68/csv-data-manipulation.alg index 97c2d04278..749c7da413 100644 --- a/Task/CSV-data-manipulation/ALGOL-68/csv-data-manipulation.alg +++ b/Task/CSV-data-manipulation/ALGOL-68/csv-data-manipulation.alg @@ -3,8 +3,8 @@ PROC char count = (CHAR c, STRING str) INT: BEGIN INT count := 0; FOR i TO UPB str DO - IF c = str[i] THEN count +:= 1 - FI + IF c = str[i] THEN count +:= 1 + FI OD; count END; @@ -17,9 +17,9 @@ PROC char split = (STRING str, CHAR sep) FLEX[]STRING : INT start := 1; [char count (sep, str) + 1] STRING list; WHILE start <= strlen ANDF char in string (sep, p, str[start:]) DO - p +:= start - 1; - list[cnt +:= 1] := str[start:p-1]; - start := p + 1 + p +:= start - 1; + list[cnt +:= 1] := str[start:p-1]; + start := p + 1 OD; IF cnt = 0 THEN list[cnt +:= 1] := str ELIF start <= UPB str + 1 THEN list[cnt +:= 1] := str[start:] @@ -31,7 +31,7 @@ PROC join = ([]STRING words, STRING sep) STRING: IF UPB words > 0 THEN STRING str := words [1]; FOR i FROM 2 TO UPB words DO - str +:= sep + words[i] + str +:= sep + words[i] OD; str ELSE @@ -60,10 +60,10 @@ OP TOINT = (STRING str) INT: BEGIN INT n := 0, sign := 1; FOR i TO UPB str WHILE sign /= 0 DO - IF is digit (str[i]) THEN n := n * 10 + ABS str[i] - ABS "0" - ELIF i = 1 AND str[i] = "-" THEN sign := -1 - ELIF i /= 1 OR str[i] /= "+" THEN sign := 0 - FI + IF is digit (str[i]) THEN n := n * 10 + ABS str[i] - ABS "0" + ELIF i = 1 AND str[i] = "-" THEN sign := -1 + ELIF i /= 1 OR str[i] /= "+" THEN sign := 0 + FI OD; n * sign END; diff --git a/Task/CSV-data-manipulation/AWK/csv-data-manipulation.awk b/Task/CSV-data-manipulation/AWK/csv-data-manipulation.awk index 5f148a16dd..f45946981e 100644 --- a/Task/CSV-data-manipulation/AWK/csv-data-manipulation.awk +++ b/Task/CSV-data-manipulation/AWK/csv-data-manipulation.awk @@ -6,7 +6,7 @@ NR==1 { } { sum = 0 - for (i=1; i<=NF; i++) { + for (i=1; i<=NF; i++) { sum += $i } print $0, sum diff --git a/Task/CSV-data-manipulation/Ada/csv-data-manipulation-1.adb b/Task/CSV-data-manipulation/Ada/csv-data-manipulation-1.ada similarity index 100% rename from Task/CSV-data-manipulation/Ada/csv-data-manipulation-1.adb rename to Task/CSV-data-manipulation/Ada/csv-data-manipulation-1.ada diff --git a/Task/CSV-data-manipulation/Ada/csv-data-manipulation-2.adb b/Task/CSV-data-manipulation/Ada/csv-data-manipulation-2.ada similarity index 100% rename from Task/CSV-data-manipulation/Ada/csv-data-manipulation-2.adb rename to Task/CSV-data-manipulation/Ada/csv-data-manipulation-2.ada diff --git a/Task/CSV-data-manipulation/Ada/csv-data-manipulation-3.adb b/Task/CSV-data-manipulation/Ada/csv-data-manipulation-3.ada similarity index 100% rename from Task/CSV-data-manipulation/Ada/csv-data-manipulation-3.adb rename to Task/CSV-data-manipulation/Ada/csv-data-manipulation-3.ada diff --git a/Task/CSV-data-manipulation/C/csv-data-manipulation-1.c b/Task/CSV-data-manipulation/C/csv-data-manipulation-1.c index 6f6b83c3bc..060dd21931 100644 --- a/Task/CSV-data-manipulation/C/csv-data-manipulation-1.c +++ b/Task/CSV-data-manipulation/C/csv-data-manipulation-1.c @@ -16,10 +16,10 @@ typedef struct { - char * delim; - unsigned int rows; - unsigned int cols; - char ** table; + char * delim; + unsigned int rows; + unsigned int cols; + char ** table; } CSV; @@ -27,28 +27,28 @@ typedef struct { * Utility function to trim whitespaces from left & right of a string */ int trim(char ** str) { - int trimmed; - int n; - int len; + int trimmed; + int n; + int len; + + len = strlen(*str); + n = len - 1; + /* from right */ + while((n>=0) && isspace((*str)[n])) { + (*str)[n] = '\0'; + trimmed += 1; + n--; + } - len = strlen(*str); - n = len - 1; - /* from right */ - while((n>=0) && isspace((*str)[n])) { - (*str)[n] = '\0'; - trimmed += 1; - n--; - } - - /* from left */ - n = 0; - while((n < len) && (isspace((*str)[0]))) { - (*str)[0] = '\0'; - *str = (*str)+1; - trimmed += 1; - n++; - } - return trimmed; + /* from left */ + n = 0; + while((n < len) && (isspace((*str)[0]))) { + (*str)[0] = '\0'; + *str = (*str)+1; + trimmed += 1; + n++; + } + return trimmed; } @@ -56,11 +56,11 @@ int trim(char ** str) { * De-allocate csv structure */ int csv_destroy(CSV * csv) { - if (csv == NULL) { return 0; } - if (csv->table != NULL) { free(csv->table); } - if (csv->delim != NULL) { free(csv->delim); } - free(csv); - return 0; + if (csv == NULL) { return 0; } + if (csv->table != NULL) { free(csv->table); } + if (csv->delim != NULL) { free(csv->delim); } + free(csv); + return 0; } @@ -68,23 +68,23 @@ int csv_destroy(CSV * csv) { * Allocate memory for a CSV structure */ CSV * csv_create(unsigned int cols, unsigned int rows) { - CSV * csv; + CSV * csv; + + csv = malloc(sizeof(CSV)); + csv->rows = rows; + csv->cols = cols; + csv->delim = strdup(","); - csv = malloc(sizeof(CSV)); - csv->rows = rows; - csv->cols = cols; - csv->delim = strdup(","); + csv->table = malloc(sizeof(char *) * cols * rows); + if (csv->table == NULL) { goto error; } - csv->table = malloc(sizeof(char *) * cols * rows); - if (csv->table == NULL) { goto error; } + memset(csv->table, 0, sizeof(char *) * cols * rows); - memset(csv->table, 0, sizeof(char *) * cols * rows); - - return csv; + return csv; error: - csv_destroy(csv); - return NULL; + csv_destroy(csv); + return NULL; } @@ -92,9 +92,9 @@ error: * Get value in CSV table at COL, ROW */ char * csv_get(CSV * csv, unsigned int col, unsigned int row) { - unsigned int idx; - idx = col + (row * csv->cols); - return csv->table[idx]; + unsigned int idx; + idx = col + (row * csv->cols); + return csv->table[idx]; } @@ -102,84 +102,84 @@ char * csv_get(CSV * csv, unsigned int col, unsigned int row) { * Set value in CSV table at COL, ROW */ int csv_set(CSV * csv, unsigned int col, unsigned int row, char * value) { - unsigned int idx; - idx = col + (row * csv->cols); - csv->table[idx] = value; - return 0; + unsigned int idx; + idx = col + (row * csv->cols); + csv->table[idx] = value; + return 0; } void csv_display(CSV * csv) { - int row, col; - char * content; - if ((csv->rows == 0) || (csv->cols==0)) { - printf("[Empty table]\n"); - return ; - } + int row, col; + char * content; + if ((csv->rows == 0) || (csv->cols==0)) { + printf("[Empty table]\n"); + return ; + } - printf("\n[Table cols=%d rows=%d]\n", csv->cols, csv->rows); - for (row=0; rowrows; row++) { - printf("[|"); - for (col=0; colcols; col++) { - content = csv_get(csv, col, row); + printf("\n[Table cols=%d rows=%d]\n", csv->cols, csv->rows); + for (row=0; rowrows; row++) { + printf("[|"); + for (col=0; colcols; col++) { + content = csv_get(csv, col, row); printf("%s\t|", content); - } + } printf("]\n"); - } - printf("\n"); + } + printf("\n"); } /** * Resize CSV table */ int csv_resize(CSV * old_csv, unsigned int new_cols, unsigned int new_rows) { - unsigned int cur_col, - cur_row, - max_cols, - max_rows; - CSV * new_csv; - char * content; - bool in_old, in_new; + unsigned int cur_col, + cur_row, + max_cols, + max_rows; + CSV * new_csv; + char * content; + bool in_old, in_new; - /* Build a new (fake) csv */ - new_csv = csv_create(new_cols, new_rows); - if (new_csv == NULL) { goto error; } + /* Build a new (fake) csv */ + new_csv = csv_create(new_cols, new_rows); + if (new_csv == NULL) { goto error; } - new_csv->rows = new_rows; - new_csv->cols = new_cols; + new_csv->rows = new_rows; + new_csv->cols = new_cols; - max_cols = (new_cols > old_csv->cols)? new_cols : old_csv->cols; - max_rows = (new_rows > old_csv->rows)? new_rows : old_csv->rows; + max_cols = (new_cols > old_csv->cols)? new_cols : old_csv->cols; + max_rows = (new_rows > old_csv->rows)? new_rows : old_csv->rows; - for (cur_col=0; cur_colcols) && (cur_row < old_csv->rows); - in_new = (cur_col < new_csv->cols) && (cur_row < new_csv->rows); + for (cur_col=0; cur_colcols) && (cur_row < old_csv->rows); + in_new = (cur_col < new_csv->cols) && (cur_row < new_csv->rows); - if (in_old && in_new) { - /* re-link data */ - content = csv_get(old_csv, cur_col, cur_row); - csv_set(new_csv, cur_col, cur_row, content); - } else if (in_old) { - /* destroy data */ - content = csv_get(old_csv, cur_col, cur_row); - free(content); - } else { /* skip */ } - } - } - /* on rows */ - free(old_csv->table); - old_csv->rows = new_rows; - old_csv->cols = new_cols; - old_csv->table = new_csv->table; - new_csv->table = NULL; - csv_destroy(new_csv); + if (in_old && in_new) { + /* re-link data */ + content = csv_get(old_csv, cur_col, cur_row); + csv_set(new_csv, cur_col, cur_row, content); + } else if (in_old) { + /* destroy data */ + content = csv_get(old_csv, cur_col, cur_row); + free(content); + } else { /* skip */ } + } + } + /* on rows */ + free(old_csv->table); + old_csv->rows = new_rows; + old_csv->cols = new_cols; + old_csv->table = new_csv->table; + new_csv->table = NULL; + csv_destroy(new_csv); - return 0; + return 0; error: - printf("Unable to resize CSV table: error %d - %s\n", errno, strerror(errno)); - return -1; + printf("Unable to resize CSV table: error %d - %s\n", errno, strerror(errno)); + return -1; } @@ -187,42 +187,42 @@ error: * Open CSV file and load its content into provided CSV structure **/ int csv_open(CSV * csv, char * filename) { - FILE * fp; - unsigned int m_rows; - unsigned int m_cols, cols; - char line[2048]; - char * lineptr; - char * token; + FILE * fp; + unsigned int m_rows; + unsigned int m_cols, cols; + char line[2048]; + char * lineptr; + char * token; - fp = fopen(filename, "r"); - if (fp == NULL) { goto error; } + fp = fopen(filename, "r"); + if (fp == NULL) { goto error; } - m_rows = 0; - m_cols = 0; - while(fgets(line, sizeof(line), fp) != NULL) { - m_rows += 1; - cols = 0; - lineptr = line; - while ((token = strtok(lineptr, csv->delim)) != NULL) { - lineptr = NULL; - trim(&token); + m_rows = 0; + m_cols = 0; + while(fgets(line, sizeof(line), fp) != NULL) { + m_rows += 1; + cols = 0; + lineptr = line; + while ((token = strtok(lineptr, csv->delim)) != NULL) { + lineptr = NULL; + trim(&token); cols += 1; - if (cols > m_cols) { m_cols = cols; } + if (cols > m_cols) { m_cols = cols; } csv_resize(csv, m_cols, m_rows); csv_set(csv, cols-1, m_rows-1, strdup(token)); } - } + } - fclose(fp); - csv->rows = m_rows; - csv->cols = m_cols; - return 0; + fclose(fp); + csv->rows = m_rows; + csv->cols = m_cols; + return 0; error: - fclose(fp); - printf("Unable to open %s for reading.", filename); - return -1; + fclose(fp); + printf("Unable to open %s for reading.", filename); + return -1; } @@ -230,22 +230,22 @@ error: * Open CSV file and save CSV structure content into it **/ int csv_save(CSV * csv, char * filename) { - FILE * fp; - int row, col; - char * content; + FILE * fp; + int row, col; + char * content; - fp = fopen(filename, "w"); - for (row=0; rowrows; row++) { - for (col=0; colcols; col++) { - content = csv_get(csv, col, row); + fp = fopen(filename, "w"); + for (row=0; rowrows; row++) { + for (col=0; colcols; col++) { + content = csv_get(csv, col, row); fprintf(fp, "%s%s", content, - ((col == csv->cols-1) ? "" : csv->delim) ); - } + ((col == csv->cols-1) ? "" : csv->delim) ); + } fprintf(fp, "\n"); - } + } - fclose(fp); - return 0; + fclose(fp); + return 0; } @@ -253,23 +253,23 @@ int csv_save(CSV * csv, char * filename) { * Test */ int main(int argc, char ** argv) { - CSV * csv; + CSV * csv; - printf("%s\n%s\n\n",TITLE, URL); + printf("%s\n%s\n\n",TITLE, URL); - csv = csv_create(0, 0); - csv_open(csv, "fixtures/csv-data-manipulation.csv"); - csv_display(csv); + csv = csv_create(0, 0); + csv_open(csv, "fixtures/csv-data-manipulation.csv"); + csv_display(csv); - csv_set(csv, 0, 0, "Column0"); - csv_set(csv, 1, 1, "100"); - csv_set(csv, 2, 2, "200"); - csv_set(csv, 3, 3, "300"); - csv_set(csv, 4, 4, "400"); - csv_display(csv); + csv_set(csv, 0, 0, "Column0"); + csv_set(csv, 1, 1, "100"); + csv_set(csv, 2, 2, "200"); + csv_set(csv, 3, 3, "300"); + csv_set(csv, 4, 4, "400"); + csv_display(csv); - csv_save(csv, "tmp/csv-data-manipulation.result.csv"); - csv_destroy(csv); + csv_save(csv, "tmp/csv-data-manipulation.result.csv"); + csv_destroy(csv); - return 0; + return 0; } diff --git a/Task/CSV-data-manipulation/COBOL/csv-data-manipulation.cob b/Task/CSV-data-manipulation/COBOL/csv-data-manipulation.cobol similarity index 100% rename from Task/CSV-data-manipulation/COBOL/csv-data-manipulation.cob rename to Task/CSV-data-manipulation/COBOL/csv-data-manipulation.cobol diff --git a/Task/CSV-data-manipulation/Delphi/csv-data-manipulation.pas b/Task/CSV-data-manipulation/Delphi/csv-data-manipulation.delphi similarity index 100% rename from Task/CSV-data-manipulation/Delphi/csv-data-manipulation.pas rename to Task/CSV-data-manipulation/Delphi/csv-data-manipulation.delphi diff --git a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb deleted file mode 100644 index dd05c0680d..0000000000 --- a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb +++ /dev/null @@ -1,5 +0,0 @@ -create or replace table csv as -from read_csv_auto('rc-csv-data-manipulation.csv'); - -# View the first row of the table: -from csv limit 1; diff --git a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb deleted file mode 100644 index 5078ee97a4..0000000000 --- a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb +++ /dev/null @@ -1,4 +0,0 @@ -copy - (select *, (C1 + C2 + C3 + C4 + C5) as sum - from csv) - to 'junk.csv'; diff --git a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb deleted file mode 100644 index b3c1bedcf5..0000000000 --- a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE csv ADD COLUMN sum integer; - -UPDATE csv -SET sum = C1 + C2 + C3 + C4 + C5; - -copy csv to 'junk2.csv'; diff --git a/Task/CSV-data-manipulation/ECL/csv-data-manipulation.ecl b/Task/CSV-data-manipulation/ECL/csv-data-manipulation.ecl index 1e1feac64c..b69c763781 100644 --- a/Task/CSV-data-manipulation/ECL/csv-data-manipulation.ecl +++ b/Task/CSV-data-manipulation/ECL/csv-data-manipulation.ecl @@ -5,7 +5,7 @@ STRING Field2; STRING Field3; STRING Field4; STRING Field5; -END; +END; MyDataset := DATASET ('~Rosetta::myCSVFile', MyFileLayout,CSV(SEPARATOR(','))); diff --git a/Task/CSV-data-manipulation/EasyLang/csv-data-manipulation.easy b/Task/CSV-data-manipulation/EasyLang/csv-data-manipulation.easy deleted file mode 100644 index 75513102c2..0000000000 --- a/Task/CSV-data-manipulation/EasyLang/csv-data-manipulation.easy +++ /dev/null @@ -1,17 +0,0 @@ -s$ = input -print s$ & ",SUM" -repeat - s$ = input - until s$ = "" - sum = 0 - for v in number strsplit s$ "," - sum += v - . - print s$ & "," & sum -. -input_data -C1,C2,C3,C4,C5 -1,5,9,13,17 -2,6,10,14,18 -3,7,11,15,19 -4,8,12,16,20 diff --git a/Task/CSV-data-manipulation/EchoLisp/csv-data-manipulation-1.l b/Task/CSV-data-manipulation/EchoLisp/csv-data-manipulation-1.l index d621e254ba..9afa63c6bb 100644 --- a/Task/CSV-data-manipulation/EchoLisp/csv-data-manipulation-1.l +++ b/Task/CSV-data-manipulation/EchoLisp/csv-data-manipulation-1.l @@ -10,10 +10,12 @@ (define (task file) (let* - ((table (csv->table file)) - (header (first table)) - (rows (rest table))) + ((table (csv->table file)) + (header (first table)) + (rows (rest table))) + + (table->csv + (append header "SUM") ;; add last column + (for/list ((row rows)) (append row (apply + row)))))) - (table->csv - (append header "SUM") ;; add last column - (for/list ((row rows)) (append row (apply + row)))))) + diff --git a/Task/CSV-data-manipulation/Elixir/csv-data-manipulation.ex b/Task/CSV-data-manipulation/Elixir/csv-data-manipulation.elixir similarity index 100% rename from Task/CSV-data-manipulation/Elixir/csv-data-manipulation.ex rename to Task/CSV-data-manipulation/Elixir/csv-data-manipulation.elixir diff --git a/Task/CSV-data-manipulation/Euphoria/csv-data-manipulation.eu b/Task/CSV-data-manipulation/Euphoria/csv-data-manipulation.eu deleted file mode 100644 index 66f5a8b1dd..0000000000 --- a/Task/CSV-data-manipulation/Euphoria/csv-data-manipulation.eu +++ /dev/null @@ -1,91 +0,0 @@ ---- Read CSV file and add columns headed with 'SUM' ---- with trace --- trace(0) - -include get.e -include std/text.e - -function split(sequence s, integer c) - sequence removables = " \t\n\r\x05\u0234\" " - sequence out - integer first, delim - out = {} - first = 1 - while first <= length(s) do - delim = find_from(c,s,first) - if delim = 0 then - delim = length(s)+1 - end if - out = append(out,trim(s[first..delim-1],removables)) - first = delim + 1 - end while - return out -end function - -procedure main() - integer fn -- the file number - integer fn2 -- the output file number - integer e -- the number of lines read - object line -- the next line from the file - sequence data = {} -- parsed csv data row - sequence headerNames = {} -- array saving column names - atom sum = 0.0 -- sum for each row - sequence var -- holds numerical data read - - -- First we try to open the file called "data.csv". - fn = open("data.csv", "r") - if fn = -1 then - puts(1, "Can't open data.csv\n") - -- abort(); - end if - - -- Then we create an output file for processed data. - fn2 = open("newdata.csv", "w") - if fn2 = -1 then - puts(1, "Can't create newdata.csv\n") - end if - - -- By successfully opening the file we have established that - -- the file exists, and open() gives us a file number (or "handle") - -- that we can use to perform operations on the file. - - e = 1 - while 1 do - line = gets(fn) - if atom(line) then - exit - end if - data = split(line, ',') - - if (e=1) then - -- Save the header labels and - -- write them to output file. - headerNames = data - for i=1 to length(headerNames) do - printf(fn2, "%s,", {headerNames[i]}) - end for - printf(fn2, "SUM\n") - end if - - -- Run a sum for the numerical data. - if (e >= 2) then - for i=1 to length(data) do - printf(fn2, "%s,", {data[i]}) - var = value(data[i]) - if var[1] = 0 then - -- data read is numerical - -- add to sum - sum = sum + var[2] - end if - end for - printf(fn2, "%g\n", {sum}) - sum = 0.0 - end if - e = e + 1 - end while - - close(fn) - close(fn2) -end procedure - -main() diff --git a/Task/CSV-data-manipulation/Euphoria/csv-data-manipulation.euphoria b/Task/CSV-data-manipulation/Euphoria/csv-data-manipulation.euphoria new file mode 100644 index 0000000000..85ed288be0 --- /dev/null +++ b/Task/CSV-data-manipulation/Euphoria/csv-data-manipulation.euphoria @@ -0,0 +1,91 @@ +--- Read CSV file and add columns headed with 'SUM' +--- with trace +-- trace(0) + +include get.e +include std/text.e + +function split(sequence s, integer c) + sequence removables = " \t\n\r\x05\u0234\" " + sequence out + integer first, delim + out = {} + first = 1 + while first <= length(s) do + delim = find_from(c,s,first) + if delim = 0 then + delim = length(s)+1 + end if + out = append(out,trim(s[first..delim-1],removables)) + first = delim + 1 + end while + return out +end function + +procedure main() + integer fn -- the file number + integer fn2 -- the output file number + integer e -- the number of lines read + object line -- the next line from the file + sequence data = {} -- parsed csv data row + sequence headerNames = {} -- array saving column names + atom sum = 0.0 -- sum for each row + sequence var -- holds numerical data read + + -- First we try to open the file called "data.csv". + fn = open("data.csv", "r") + if fn = -1 then + puts(1, "Can't open data.csv\n") + -- abort(); + end if + + -- Then we create an output file for processed data. + fn2 = open("newdata.csv", "w") + if fn2 = -1 then + puts(1, "Can't create newdata.csv\n") + end if + + -- By successfully opening the file we have established that + -- the file exists, and open() gives us a file number (or "handle") + -- that we can use to perform operations on the file. + + e = 1 + while 1 do + line = gets(fn) + if atom(line) then + exit + end if + data = split(line, ',') + + if (e=1) then + -- Save the header labels and + -- write them to output file. + headerNames = data + for i=1 to length(headerNames) do + printf(fn2, "%s,", {headerNames[i]}) + end for + printf(fn2, "SUM\n") + end if + + -- Run a sum for the numerical data. + if (e >= 2) then + for i=1 to length(data) do + printf(fn2, "%s,", {data[i]}) + var = value(data[i]) + if var[1] = 0 then + -- data read is numerical + -- add to sum + sum = sum + var[2] + end if + end for + printf(fn2, "%g\n", {sum}) + sum = 0.0 + end if + e = e + 1 + end while + + close(fn) + close(fn2) +end procedure + +main() diff --git a/Task/CSV-data-manipulation/Fortran/csv-data-manipulation-2.f b/Task/CSV-data-manipulation/Fortran/csv-data-manipulation-2.f index 6e400d25ef..ef63969cbc 100644 --- a/Task/CSV-data-manipulation/Fortran/csv-data-manipulation-2.f +++ b/Task/CSV-data-manipulation/Fortran/csv-data-manipulation-2.f @@ -1,20 +1,20 @@ Copies a file with 5 comma-separated values to a line, appending a column holding their sum. - INTEGER N !Instead of littering the source with "5" - PARAMETER (N = 5) !Provide some provenance. - CHARACTER*6 HEAD(N) !A perfect size? - INTEGER X(N) !Integers suffice. - INTEGER LINPR,IN !I/O unit numbers. - LINPR = 6 !Standard output via this unit number. - IN = 10 !Some unit number for the input file. - OPEN (IN,FILE="CSVtest.csv",STATUS="OLD",ACTION="READ") !For formatted input. + INTEGER N !Instead of littering the source with "5" + PARAMETER (N = 5) !Provide some provenance. + CHARACTER*6 HEAD(N) !A perfect size? + INTEGER X(N) !Integers suffice. + INTEGER LINPR,IN !I/O unit numbers. + LINPR = 6 !Standard output via this unit number. + IN = 10 !Some unit number for the input file. + OPEN (IN,FILE="CSVtest.csv",STATUS="OLD",ACTION="READ") !For formatted input. - READ (IN,*) HEAD !The first line has texts as column headings. - WRITE (LINPR,1) (TRIM(HEAD(I)), I = 1,N),"Sum" !Append a "Sum" column. - 1 FORMAT (666(A:",")) !The : sez "stop if no list element awaits". - 2 READ (IN,*,END = 10) X !Read a line's worth of numbers, separated by commas or spaces. - WRITE (LINPR,3) X,SUM(X) !Write, with a total appended. - 3 FORMAT (666(I0:",")) !I0 editing uses only as many columns as are needed. - GO TO 2 !Do it again. + READ (IN,*) HEAD !The first line has texts as column headings. + WRITE (LINPR,1) (TRIM(HEAD(I)), I = 1,N),"Sum" !Append a "Sum" column. + 1 FORMAT (666(A:",")) !The : sez "stop if no list element awaits". + 2 READ (IN,*,END = 10) X !Read a line's worth of numbers, separated by commas or spaces. + WRITE (LINPR,3) X,SUM(X) !Write, with a total appended. + 3 FORMAT (666(I0:",")) !I0 editing uses only as many columns as are needed. + GO TO 2 !Do it again. - 10 CLOSE (IN) !All done. - END !That's all. + 10 CLOSE (IN) !All done. + END !That's all. diff --git a/Task/CSV-data-manipulation/FunL/csv-data-manipulation.funl b/Task/CSV-data-manipulation/FunL/csv-data-manipulation.funl index 2bb6312e7a..17cee74435 100644 --- a/Task/CSV-data-manipulation/FunL/csv-data-manipulation.funl +++ b/Task/CSV-data-manipulation/FunL/csv-data-manipulation.funl @@ -34,7 +34,7 @@ def updateRow( header, row, updates ) = updates( r ) vector( r(f) | f <- header ) -def update( table, updates ) = +def update( table, updates ) = Table( table.header, (updateRow(table.header, r, updates) | r <- table.rows).toList() ) def addColumn( table, column, updates ) = diff --git a/Task/CSV-data-manipulation/Go/csv-data-manipulation.go b/Task/CSV-data-manipulation/Go/csv-data-manipulation.go index b893656760..d6adc29b82 100644 --- a/Task/CSV-data-manipulation/Go/csv-data-manipulation.go +++ b/Task/CSV-data-manipulation/Go/csv-data-manipulation.go @@ -1,58 +1,58 @@ package main import ( - "encoding/csv" - "log" - "os" - "strconv" + "encoding/csv" + "log" + "os" + "strconv" ) func main() { - rows := readSample() - appendSum(rows) - writeChanges(rows) + rows := readSample() + appendSum(rows) + writeChanges(rows) } func readSample() [][]string { - f, err := os.Open("sample.csv") - if err != nil { - log.Fatal(err) - } - rows, err := csv.NewReader(f).ReadAll() - f.Close() - if err != nil { - log.Fatal(err) - } - return rows + f, err := os.Open("sample.csv") + if err != nil { + log.Fatal(err) + } + rows, err := csv.NewReader(f).ReadAll() + f.Close() + if err != nil { + log.Fatal(err) + } + return rows } func appendSum(rows [][]string) { - rows[0] = append(rows[0], "SUM") - for i := 1; i < len(rows); i++ { - rows[i] = append(rows[i], sum(rows[i])) - } + rows[0] = append(rows[0], "SUM") + for i := 1; i < len(rows); i++ { + rows[i] = append(rows[i], sum(rows[i])) + } } func sum(row []string) string { - sum := 0 - for _, s := range row { - x, err := strconv.Atoi(s) - if err != nil { - return "NA" - } - sum += x - } - return strconv.Itoa(sum) + sum := 0 + for _, s := range row { + x, err := strconv.Atoi(s) + if err != nil { + return "NA" + } + sum += x + } + return strconv.Itoa(sum) } func writeChanges(rows [][]string) { - f, err := os.Create("output.csv") - if err != nil { - log.Fatal(err) - } - err = csv.NewWriter(f).WriteAll(rows) - f.Close() - if err != nil { - log.Fatal(err) - } + f, err := os.Create("output.csv") + if err != nil { + log.Fatal(err) + } + err = csv.NewWriter(f).WriteAll(rows) + f.Close() + if err != nil { + log.Fatal(err) + } } diff --git a/Task/CSV-data-manipulation/Julia/csv-data-manipulation.jl b/Task/CSV-data-manipulation/Julia/csv-data-manipulation.julia similarity index 100% rename from Task/CSV-data-manipulation/Julia/csv-data-manipulation.jl rename to Task/CSV-data-manipulation/Julia/csv-data-manipulation.julia diff --git a/Task/CSV-data-manipulation/Kotlin/csv-data-manipulation.kts b/Task/CSV-data-manipulation/Kotlin/csv-data-manipulation.kotlin similarity index 100% rename from Task/CSV-data-manipulation/Kotlin/csv-data-manipulation.kts rename to Task/CSV-data-manipulation/Kotlin/csv-data-manipulation.kotlin diff --git a/Task/CSV-data-manipulation/Logo/csv-data-manipulation-1.logo b/Task/CSV-data-manipulation/Logo/csv-data-manipulation-1.logo deleted file mode 100644 index c8936190c7..0000000000 --- a/Task/CSV-data-manipulation/Logo/csv-data-manipulation-1.logo +++ /dev/null @@ -1,19 +0,0 @@ -to csv.data.manipulation :in :out - local [header line list sum] - openread :in - setread :in - openwrite :out - setwrite :out - make "header readword - print word :header ",SUM - while [not eofp] [ - make "line readword - make "list parse map [ifelse equalp ? ", ["\ ] [?]] :line - make "sum apply "sum :list - print (word :line "\, :sum) - ] - close :in - setread [] - close :out - setwrite [] -end diff --git a/Task/CSV-data-manipulation/Logo/csv-data-manipulation-2.logo b/Task/CSV-data-manipulation/Logo/csv-data-manipulation-2.logo deleted file mode 100644 index 13633defa8..0000000000 --- a/Task/CSV-data-manipulation/Logo/csv-data-manipulation-2.logo +++ /dev/null @@ -1 +0,0 @@ -csv.data.manipulation "data.csv "output.csv diff --git a/Task/CSV-data-manipulation/Lua/csv-data-manipulation-1.lua b/Task/CSV-data-manipulation/Lua/csv-data-manipulation-1.lua deleted file mode 100644 index 8296349d52..0000000000 --- a/Task/CSV-data-manipulation/Lua/csv-data-manipulation-1.lua +++ /dev/null @@ -1,11 +0,0 @@ --- Lua has no built in methods to handle csv files. --- it does have string.gmatch, which we use to global.match whatever isn't a comma - -print(io.read"l" .. ",SUM") -for line in io.lines() do - local sum = 0 - for field in line:gmatch"[^,]+" do - sum = sum + field - end - print(line .. "," .. sum) -end diff --git a/Task/CSV-data-manipulation/Lua/csv-data-manipulation-2.lua b/Task/CSV-data-manipulation/Lua/csv-data-manipulation-2.lua deleted file mode 100644 index 0469930ba1..0000000000 --- a/Task/CSV-data-manipulation/Lua/csv-data-manipulation-2.lua +++ /dev/null @@ -1,26 +0,0 @@ -local csv={} - --- read csv file, save records and fields into table -for line in io.lines('file.csv') do - local fields = {} - for field in line:gmatch"[^,]+" do - table.insert(fields, tonumber(field) or field) - end - table.insert(csv, fields) -end - --- change csv values -table.insert(csv[1], 'SUM') -for i=2,#csv do - local sum=0 - for _, val in ipairs(csv[i]) do - sum = sum + val - end - table.insert(csv[i], sum) -end - --- Save -local fileHandler = io.open('file.csv', 'w') -for NR, fields in ipairs(csv) do - fileHandler:write(table.concat(fields,","), "\n") -end diff --git a/Task/CSV-data-manipulation/Lua/csv-data-manipulation.lua b/Task/CSV-data-manipulation/Lua/csv-data-manipulation.lua new file mode 100644 index 0000000000..26ddaeabc9 --- /dev/null +++ b/Task/CSV-data-manipulation/Lua/csv-data-manipulation.lua @@ -0,0 +1,31 @@ +local csv={} +for line in io.lines('file.csv') do + table.insert(csv, {}) + local i=1 + for j=1,#line do + if line:sub(j,j) == ',' then + table.insert(csv[#csv], line:sub(i,j-1)) + i=j+1 + end + end + table.insert(csv[#csv], line:sub(i,j)) +end + +table.insert(csv[1], 'SUM') +for i=2,#csv do + local sum=0 + for j=1,#csv[i] do + sum=sum + tonumber(csv[i][j]) + end + if sum>0 then + table.insert(csv[i], sum) + end +end + +local newFileData = '' +for i=1,#csv do + newFileData=newFileData .. table.concat(csv[i], ',') .. '\n' +end + +local file=io.open('file.csv', 'w') +file:write(newFileData) diff --git a/Task/CSV-data-manipulation/M2000-Interpreter/csv-data-manipulation.m2000 b/Task/CSV-data-manipulation/M2000-Interpreter/csv-data-manipulation.m2000 index ebca3c0383..7ef687eccb 100644 --- a/Task/CSV-data-manipulation/M2000-Interpreter/csv-data-manipulation.m2000 +++ b/Task/CSV-data-manipulation/M2000-Interpreter/csv-data-manipulation.m2000 @@ -1,7 +1,6 @@ -Locale 1032 Module Checkit { Function Sum { - DECIMAL c=0 + Long c=0 while not empty { c+=number } @@ -9,7 +8,7 @@ Module Checkit { } Document CSV$ = {C1,C2,C3,C4,C5 1,5,9,13,17 - 2,6,10.3,14,18 + 2,6,10,14,18 3,7,11,15,19 4,8,12,16,20 } @@ -20,13 +19,13 @@ Module Checkit { \\ use standard decimal point char \\ use standard (non json style string) \\ True = use bare strings (without "") - Input With "","",,true - Write With chr$(9),locale$(0xE),,true + Input With "",,,true + Write With"",,,true \\ for excel csv use Input With chr$(9),,true, true Open "data1.csv" for Wide Input as #M Open "data2.csv" for Wide Output as #M1 Input #M, h1$, h2$, h3$, h4$, h5$ - Write #M1, h1$, h2$, h3$, h4$, h5$, "SUM" + Write #M1, h1$, h2$, h3$, h4$, h5$ Print h1$, h2$, h3$, h4$, h5$ While not Eof(#M) { @@ -36,15 +35,13 @@ Module Checkit { } close #M1 Close #M - Input With chr$(9),locale$(0xE),,true Open "data2.csv" for Wide Input as #M - Input #M, h1$, h2$, h3$, h4$, h5$, h6$ - Print h1$, h2$, h3$, h4$, h5$, h6$ + Input #M, h1$, h2$, h3$, h4$, h5$ + Print h1$, h2$, h3$, h4$, h5$ While not Eof(#M) { Input #M, A1, A2, A3, A4, A5, Sum Print A1, A2, A3, A4, A5, Sum } Close #M - Win "Excel", dir$+"data2.csv" } Checkit diff --git a/Task/CSV-data-manipulation/MATLAB/csv-data-manipulation-1.m b/Task/CSV-data-manipulation/MATLAB/csv-data-manipulation-1.m index ad5d27aed9..16512a1db4 100644 --- a/Task/CSV-data-manipulation/MATLAB/csv-data-manipulation-1.m +++ b/Task/CSV-data-manipulation/MATLAB/csv-data-manipulation-1.m @@ -7,7 +7,7 @@ X = dlmread(filename,',',1,0); fid = fopen('data.out.csv','w+'); fprintf(fid,'%s,sum\n',header); for k=1:size(X,1), - fprintf(fid,"%i,",X(k,:)); - fprintf(fid,"%i\n",sum(X(k,:))); + fprintf(fid,"%i,",X(k,:)); + fprintf(fid,"%i\n",sum(X(k,:))); end; fclose(fid); diff --git a/Task/CSV-data-manipulation/Nu/csv-data-manipulation-1.nu b/Task/CSV-data-manipulation/Nu/csv-data-manipulation-1.nu deleted file mode 100644 index d137dc1b65..0000000000 --- a/Task/CSV-data-manipulation/Nu/csv-data-manipulation-1.nu +++ /dev/null @@ -1,5 +0,0 @@ -open 'test_in.csv' | - each { |row| - let sum = ($row | values | math sum); - $row | insert Sum $sum - } diff --git a/Task/CSV-data-manipulation/Nu/csv-data-manipulation-2.nu b/Task/CSV-data-manipulation/Nu/csv-data-manipulation-2.nu deleted file mode 100644 index 82640ab976..0000000000 --- a/Task/CSV-data-manipulation/Nu/csv-data-manipulation-2.nu +++ /dev/null @@ -1 +0,0 @@ -open 'test_in.csv' | upsert Sum {|row| $row | values | math sum } diff --git a/Task/CSV-data-manipulation/OCaml/csv-data-manipulation.ml b/Task/CSV-data-manipulation/OCaml/csv-data-manipulation.ocaml similarity index 100% rename from Task/CSV-data-manipulation/OCaml/csv-data-manipulation.ml rename to Task/CSV-data-manipulation/OCaml/csv-data-manipulation.ocaml diff --git a/Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas b/Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas deleted file mode 100644 index c2a30c8cee..0000000000 --- a/Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas +++ /dev/null @@ -1,9 +0,0 @@ -begin - var lines := ReadLines('data.csv').Select((line,i) -> begin - if i = 0 then - Result := line + ',SUM' - else Result := line + ',' + line.Split(',').Sum(x -> x.ToInteger); - end); - WriteLines('outdata.csv',lines); - lines.PrintLines; -end. diff --git a/Task/CSV-data-manipulation/PowerShell/csv-data-manipulation.ps1 b/Task/CSV-data-manipulation/PowerShell/csv-data-manipulation.psh similarity index 100% rename from Task/CSV-data-manipulation/PowerShell/csv-data-manipulation.ps1 rename to Task/CSV-data-manipulation/PowerShell/csv-data-manipulation.psh diff --git a/Task/CSV-data-manipulation/Prolog/csv-data-manipulation.pro b/Task/CSV-data-manipulation/Prolog/csv-data-manipulation.pro index 4f86884d47..028345fd11 100644 --- a/Task/CSV-data-manipulation/Prolog/csv-data-manipulation.pro +++ b/Task/CSV-data-manipulation/Prolog/csv-data-manipulation.pro @@ -2,21 +2,21 @@ test :- augment('test.csv', 'test.out.csv'). % augment( +InFileName, +OutFileName) augment(InFile, OutFile) :- - open(OutFile, write, OutStream), - ( ( csv_read_file_row(InFile, Row, [line(Line)]), - % Row is of the form row( Item1, Item2, ....). - addrow(Row, Out), - csv_write_stream(OutStream, [Out], []), - fail - ) - ; close(OutStream) - ). + open(OutFile, write, OutStream), + ( ( csv_read_file_row(InFile, Row, [line(Line)]), + % Row is of the form row( Item1, Item2, ....). + addrow(Row, Out), + csv_write_stream(OutStream, [Out], []), + fail + ) + ; close(OutStream) + ). % If the first item in a row is an integer, then append the sum; % otherwise append 'SUM': addrow( Term, NewTerm ) :- - Term =.. [F | List], - List = [X|_], - (integer(X) -> sum_list(List, Sum) ; Sum = 'SUM'), - append(List, [Sum], NewList), - NewTerm =.. [F | NewList]. + Term =.. [F | List], + List = [X|_], + (integer(X) -> sum_list(List, Sum) ; Sum = 'SUM'), + append(List, [Sum], NewList), + NewTerm =.. [F | NewList]. diff --git a/Task/CSV-data-manipulation/Python/csv-data-manipulation-4.py b/Task/CSV-data-manipulation/Python/csv-data-manipulation-4.py deleted file mode 100644 index a35b14ce8d..0000000000 --- a/Task/CSV-data-manipulation/Python/csv-data-manipulation-4.py +++ /dev/null @@ -1,9 +0,0 @@ -import polars as pl - -filepath = "data.csv" - -( - pl.scan_csv(filepath) - .with_columns(pl.sum_horizontal(pl.all()).alias("SUM")) - .sink_csv(filepath) -) diff --git a/Task/CSV-data-manipulation/Rebol/csv-data-manipulation.rebol b/Task/CSV-data-manipulation/Rebol/csv-data-manipulation.rebol deleted file mode 100644 index 5f0eab3980..0000000000 --- a/Task/CSV-data-manipulation/Rebol/csv-data-manipulation.rebol +++ /dev/null @@ -1,35 +0,0 @@ -Rebol [ - title: "Rosetta code: CSV data manipulation" - file: %CSV_data_manipulation.r3 - url: https://rosettacode.org/wiki/CSV_data_manipulation -] - -write %test.csv {C1,C2,C3,C4,C5 -1,5,9,13,17 -2,6,10,14,18 -3,7,11,15,19 -4,8,12,16,20} ;; create a sample CSV file on disk - -probe-csv: func [data][ - foreach row data [probe row] ;; helper: print each parsed CSV row using probe -] - -import csv ;; enable CSV codec for load/save of CSV files - -data: load %test.csv ;; load CSV into a block of rows (row 1 is header) -print "^/Original:" probe-csv data ;; show original data - -;; Add SUM column: -append data/1 "SUM" ;; extend header with a new column "SUM" -foreach row next data [ ;; iterate over data rows (skip header) - sum: 0 - forall row [ ;; walk each cell in the row in place - change row to integer! row/1 ;; convert current cell to integer (mutates row) - sum: sum + row/1 ;; accumulate the running total - ] - append row sum ;; append the computed sum at the end of the row -] -print "^/Modified:" probe-csv data ;; show data after adding the SUM column - -save %new.csv data ;; save the modified data to a new CSV file -print "^/Reloaded:" probe-csv load %new.csv ;; reload and display to verify persistence diff --git a/Task/CSV-data-manipulation/Red/csv-data-manipulation-2.red b/Task/CSV-data-manipulation/Red/csv-data-manipulation-2.red index c48fba572d..caf8b0fc9d 100644 --- a/Task/CSV-data-manipulation/Red/csv-data-manipulation-2.red +++ b/Task/CSV-data-manipulation/Red/csv-data-manipulation-2.red @@ -1,6 +1,6 @@ >>forall data [either (index? data) = 1[ - append data/1 "SUM" + append data/1 "SUM" ][ - append data/1 to string! - (to integer! data/1/1) + (to integer! data/1/2) + (to integer! data/1/3) + (to integer! data/1/4) + (to integer! data/1/5) + append data/1 to string! + (to integer! data/1/1) + (to integer! data/1/2) + (to integer! data/1/3) + (to integer! data/1/4) + (to integer! data/1/5) ]] diff --git a/Task/CSV-data-manipulation/Rust/csv-data-manipulation.rs b/Task/CSV-data-manipulation/Rust/csv-data-manipulation.rust similarity index 100% rename from Task/CSV-data-manipulation/Rust/csv-data-manipulation.rs rename to Task/CSV-data-manipulation/Rust/csv-data-manipulation.rust diff --git a/Task/CSV-data-manipulation/Scala/csv-data-manipulation.scala b/Task/CSV-data-manipulation/Scala/csv-data-manipulation.scala index 2abe9cda6f..634a37b191 100644 --- a/Task/CSV-data-manipulation/Scala/csv-data-manipulation.scala +++ b/Task/CSV-data-manipulation/Scala/csv-data-manipulation.scala @@ -3,10 +3,10 @@ import scala.io.Source object parseCSV extends App { val rawData = """|C1,C2,C3,C4,C5 - |1,5,9,13,17 - |2,6,10,14,18 - |3,7,11,15,19 - |20,21,22,23,24""".stripMargin + |1,5,9,13,17 + |2,6,10,14,18 + |3,7,11,15,19 + |20,21,22,23,24""".stripMargin val data = Seq((Source.fromString(rawData).getLines()).map(_.split(",")).toSeq: _*) diff --git a/Task/CSV-data-manipulation/SenseTalk/csv-data-manipulation.sensetalk b/Task/CSV-data-manipulation/SenseTalk/csv-data-manipulation.sensetalk index 8278882de7..da0e4ef1f9 100644 --- a/Task/CSV-data-manipulation/SenseTalk/csv-data-manipulation.sensetalk +++ b/Task/CSV-data-manipulation/SenseTalk/csv-data-manipulation.sensetalk @@ -14,7 +14,7 @@ insert "SUM" into item 1 of csvData -- add a new column heading // Go through all of the data rows to add the sum repeat with rowNum= 2 to the number of items in csvData - insert the sum of item rowNum of csvData into item rowNum of csvData + insert the sum of item rowNum of csvData into item rowNum of csvData end repeat put csvData -- see the modified data as a list of lists diff --git a/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-1.tcl b/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-1.tcl index ad39da5984..9d26066be0 100644 --- a/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-1.tcl +++ b/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-1.tcl @@ -13,9 +13,9 @@ proc addSumColumn {filename {title "SUM"}} { set sumcol [$m columns] $m add column $title for {set i 1} {$i < [$m rows]} {incr i} { - # Fill out a dummy value - $m set cell $sumcol $i 0 - $m set cell $sumcol $i [tcl::mathop::+ {*}[$m get row $i]] + # Fill out a dummy value + $m set cell $sumcol $i 0 + $m set cell $sumcol $i [tcl::mathop::+ {*}[$m get row $i]] } # Write the CSV out diff --git a/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-2.tcl b/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-2.tcl index 328e7512b6..e863925092 100644 --- a/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-2.tcl +++ b/Task/CSV-data-manipulation/Tcl/csv-data-manipulation-2.tcl @@ -1,6 +1,6 @@ set f [open example.csv r] puts "[gets $f],SUM" while { [gets $f row] > 0 } { - puts "$row,[expr [string map {, +} $row]]" + puts "$row,[expr [string map {, +} $row]]" } close $f diff --git a/Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua b/Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua deleted file mode 100644 index e6b7e04c7f..0000000000 --- a/Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua +++ /dev/null @@ -1,11 +0,0 @@ -# Simple CSV manipulation - -# Effect of running `&fras "example.csv"` -$ C1,C2,C3,C4,C5 -$ 1,5,9,13,17 -$ 2,6,10,14,18 -$ 3,7,11,15,19 -$ 4,8,12,16,20 - -&p⍜°csv(⍜⍉˜⊂⊂□"SUM"≡(□⍜⋕/+)⊸↘1) -# Save using `&fwa "example.csv"` diff --git a/Task/CSV-data-manipulation/VBScript/csv-data-manipulation.vb b/Task/CSV-data-manipulation/VBScript/csv-data-manipulation.vb new file mode 100644 index 0000000000..da5502ec55 --- /dev/null +++ b/Task/CSV-data-manipulation/VBScript/csv-data-manipulation.vb @@ -0,0 +1,35 @@ +'Instatiate FSO. +Set objFSO = CreateObject("Scripting.FileSystemObject") +'Open the CSV file for reading. The file is in the same folder as the script and named csv_sample.csv. +Set objInCSV = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) & "\csv_sample.csv",1,False) +'Set header status to account for the first line as the column headers. +IsHeader = True +'Initialize the var for the output string. +OutTxt = "" +'Read each line of the file. +Do Until objInCSV.AtEndOfStream + line = objInCSV.ReadLine + If IsHeader Then + OutTxt = OutTxt & line & ",SUM" & vbCrLf + IsHeader = False + Else + OutTxt = OutTxt & line & "," & AddElements(line) & vbCrLf + End If +Loop +'Close the file. +objInCSV.Close +'Open the same file for writing. +Set objOutCSV = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) & "\csv_sample.csv",2,True) +'Write the var OutTxt to the file overwriting existing contents. +objOutCSV.Write OutTxt +'Close the file. +objOutCSV.Close +Set objFSO = Nothing + +'Routine to add each element in a row. +Function AddElements(s) + arr = Split(s,",") + For i = 0 To UBound(arr) + AddElements = AddElements + CInt(arr(i)) + Next +End Function diff --git a/Task/CSV-data-manipulation/VBScript/csv-data-manipulation.vbs b/Task/CSV-data-manipulation/VBScript/csv-data-manipulation.vbs deleted file mode 100644 index 00e334063a..0000000000 --- a/Task/CSV-data-manipulation/VBScript/csv-data-manipulation.vbs +++ /dev/null @@ -1,35 +0,0 @@ -'Instatiate FSO. -Set objFSO = CreateObject("Scripting.FileSystemObject") -'Open the CSV file for reading. The file is in the same folder as the script and named csv_sample.csv. -Set objInCSV = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) & "\csv_sample.csv",1,False) -'Set header status to account for the first line as the column headers. -IsHeader = True -'Initialize the var for the output string. -OutTxt = "" -'Read each line of the file. -Do Until objInCSV.AtEndOfStream - line = objInCSV.ReadLine - If IsHeader Then - OutTxt = OutTxt & line & ",SUM" & vbCrLf - IsHeader = False - Else - OutTxt = OutTxt & line & "," & AddElements(line) & vbCrLf - End If -Loop -'Close the file. -objInCSV.Close -'Open the same file for writing. -Set objOutCSV = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) & "\csv_sample.csv",2,True) -'Write the var OutTxt to the file overwriting existing contents. -objOutCSV.Write OutTxt -'Close the file. -objOutCSV.Close -Set objFSO = Nothing - -'Routine to add each element in a row. -Function AddElements(s) - arr = Split(s,",") - For i = 0 To UBound(arr) - AddElements = AddElements + CInt(arr(i)) - Next -End Function diff --git a/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.adb b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.ada similarity index 100% rename from Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.adb rename to Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.ada diff --git a/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.adb b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.ada similarity index 100% rename from Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.adb rename to Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.ada diff --git a/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.adb b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.ada similarity index 100% rename from Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.adb rename to Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.ada diff --git a/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.au3 b/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.au3 deleted file mode 100644 index 050b3b68a8..0000000000 --- a/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.au3 +++ /dev/null @@ -1,28 +0,0 @@ - Local $ascarray[4] = [34,38,60,62] - $String = "Character,Speech" & @CRLF - $String &= "The multitude,The messiah! Show us the messiah!" & @CRLF - $String &= "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!" & @CRLF - $String &= "The multitude,Who are you?" & @CRLF - $String &= "Brians mother,I'm his mother; that's who!" & @CRLF - $String &= "The multitude,Behold his mother! Behold his mother!" - For $i = 0 To UBound($ascarray) -1 - $String = Stringreplace($String, chr($ascarray[$i]), "&#"&$ascarray[$i]&";") - Next - $newstring = "" & @CRLF - $crlfsplit = StringSplit($String, @CRLF, 1) - For $i = 1 To $crlfsplit[0] - If $i = 1 Then $newstring &= "" & @CRLF - $newstring &= "" & @CRLF - $komsplit = StringSplit($crlfsplit[$i], ",") - For $k = 1 To $komsplit[0] - If $i = 1 Then - $newstring &= "" & @CRLF - Else - $newstring &= "" & @CRLF - EndIf - Next - $newstring &= "" & @CRLF - If $i = 1 Then $newstring &= "" & @CRLF - Next - $newstring &= "
" &$komsplit[$k] & "" &$komsplit[$k] & "
" - ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newstring = ' & $newstring & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console diff --git a/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit b/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit new file mode 100644 index 0000000000..a7f613cb1e --- /dev/null +++ b/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit @@ -0,0 +1,28 @@ + Local $ascarray[4] = [34,38,60,62] + $String = "Character,Speech" & @CRLF + $String &= "The multitude,The messiah! Show us the messiah!" & @CRLF + $String &= "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!" & @CRLF + $String &= "The multitude,Who are you?" & @CRLF + $String &= "Brians mother,I'm his mother; that's who!" & @CRLF + $String &= "The multitude,Behold his mother! Behold his mother!" + For $i = 0 To UBound($ascarray) -1 + $String = Stringreplace($String, chr($ascarray[$i]), "&#"&$ascarray[$i]&";") + Next + $newstring = "" & @CRLF + $crlfsplit = StringSplit($String, @CRLF, 1) + For $i = 1 To $crlfsplit[0] + If $i = 1 Then $newstring &= "" & @CRLF + $newstring &= "" & @CRLF + $komsplit = StringSplit($crlfsplit[$i], ",") + For $k = 1 To $komsplit[0] + If $i = 1 Then + $newstring &= "" & @CRLF + Else + $newstring &= "" & @CRLF + EndIf + Next + $newstring &= "" & @CRLF + If $i = 1 Then $newstring &= "" & @CRLF + Next + $newstring &= "
" &$komsplit[$k] & "" &$komsplit[$k] & "
" + ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newstring = ' & $newstring & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console diff --git a/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp b/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp index 3d37c4ac15..aa156642cd 100644 --- a/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp +++ b/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp @@ -7,10 +7,10 @@ std::string csvToHTML( const std::string & ) ; int main( ) { std::string text = "Character,Speech\n" "The multitude,The messiah! Show us the messiah!\n" - "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n" - "The multitude,Who are you?\n" - "Brians mother,I'm his mother; that's who!\n" - "The multitude,Behold his mother! Behold his mother!\n" ; + "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n" + "The multitude,Who are you?\n" + "Brians mother,I'm his mother; that's who!\n" + "The multitude,Behold his mother! Behold his mother!\n" ; std::cout << csvToHTML( text ) ; return 0 ; } diff --git a/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs index 0f5c4a0ec4..57a1a95782 100644 --- a/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs +++ b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c b/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c index a4931a238c..226784fac0 100644 --- a/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c +++ b/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c @@ -1,29 +1,29 @@ #include const char *input = - "Character,Speech\n" - "The multitude,The messiah! Show us the messiah!\n" - "Brians mother,Now you listen here! He's not the messiah; " - "he's a very naughty boy! Now go away!\n" - "The multitude,Who are you?\n" - "Brians mother,I'm his mother; that's who!\n" - "The multitude,Behold his mother! Behold his mother!"; + "Character,Speech\n" + "The multitude,The messiah! Show us the messiah!\n" + "Brians mother,Now you listen here! He's not the messiah; " + "he's a very naughty boy! Now go away!\n" + "The multitude,Who are you?\n" + "Brians mother,I'm his mother; that's who!\n" + "The multitude,Behold his mother! Behold his mother!"; int main() { - const char *s; - printf("\n\n\n
"); - for (s = input; *s; s++) { - switch(*s) { - case '\n': printf("
"); break; - case ',': printf(""); break; - case '<': printf("<"); break; - case '>': printf(">"); break; - case '&': printf("&"); break; - default: putchar(*s); - } - } - puts("
"); + const char *s; + printf("\n\n\n
"); + for (s = input; *s; s++) { + switch(*s) { + case '\n': printf("
"); break; + case ',': printf(""); break; + case '<': printf("<"); break; + case '>': printf(">"); break; + case '&': printf("&"); break; + default: putchar(*s); + } + } + puts("
"); - return 0; + return 0; } diff --git a/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee b/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee index 3d1193f8f7..ed257aadae 100644 --- a/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee +++ b/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee @@ -1,8 +1,8 @@ String::__defineGetter__ 'escaped', () -> - this.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') // rosettacode doesn't like " + this.replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') // rosettacode doesn't like " text = ''' Character,Speech @@ -19,21 +19,21 @@ header = lines.shift() console.log """ - - - - - + + + + + """ for line in lines - [character, speech] = line - console.log """ - - - """ + [character, speech] = line + console.log """ + + + """ console.log """ - +
#{header[0]}#{header[1]}
#{header[0]}#{header[1]}
#{character}#{speech.escaped}#{character}#{speech.escaped}
- """ + """ diff --git a/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp index b61d81aa92..db8c7f95f8 100644 --- a/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp +++ b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp @@ -8,9 +8,9 @@ The multitude,Behold his mother! Behold his mother!") (defun split-string (string delim-char) (let ((result '())) (do* ((start 0 (1+ end)) - (end (position delim-char string) - (position delim-char string :start start))) - ((not end) (reverse (cons (subseq string start) result))) + (end (position delim-char string) + (position delim-char string :start start))) + ((not end) (reverse (cons (subseq string start) result))) (push (subseq string start end) result)))) ;;; HTML escape code modified from: @@ -27,27 +27,27 @@ The multitude,Behold his mother! Behold his mother!") (let ((to-escape "<>&")) (flet ((needs-escape-p (char) (find char to-escape))) (with-output-to-string (out) - (loop for start = 0 then (1+ pos) - for pos = (position-if #'needs-escape-p in :start start) - do (write-sequence in out :start start :end pos) - when pos do (write-sequence (escape-char (char in pos)) out) - while pos))))) + (loop for start = 0 then (1+ pos) + for pos = (position-if #'needs-escape-p in :start start) + do (write-sequence in out :start start :end pos) + when pos do (write-sequence (escape-char (char in pos)) out) + while pos))))) (defun html-row (values headerp) (let ((tag (if headerp "th" "td"))) (with-output-to-string (out) (write-string "" out) (dolist (val values) - (format out "<~A>~A" tag (escape val) tag)) + (format out "<~A>~A" tag (escape val) tag)) (write-string "" out)))) (defun csv->html (csv) (let* ((lines (split-string csv #\Newline)) - (cols (split-string (first lines) #\,)) - (rows (mapcar (lambda (row) (split-string row #\,)) (rest lines)))) + (cols (split-string (first lines) #\,)) + (rows (mapcar (lambda (row) (split-string row #\,)) (rest lines)))) (with-output-to-string (html) (format html "~C" #\Newline) (format html "~C~A~C" #\Tab (html-row cols t) #\Newline) (dolist (row rows) - (format html "~C~A~C" #\Tab (html-row row nil) #\Newline)) + (format html "~C~A~C" #\Tab (html-row row nil) #\Newline)) (write-string "
" html)))) diff --git a/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp index 06570481c8..66cb3587a8 100644 --- a/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp +++ b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp @@ -1,8 +1,8 @@ - - - - - - + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.pas b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.delphi similarity index 100% rename from Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.pas rename to Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.delphi diff --git a/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.pas b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.delphi similarity index 100% rename from Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.pas rename to Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.delphi diff --git a/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.pas b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.delphi similarity index 100% rename from Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.pas rename to Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.delphi diff --git a/Task/CSV-to-HTML-translation/EasyLang/csv-to-html-translation.easy b/Task/CSV-to-HTML-translation/EasyLang/csv-to-html-translation.easy deleted file mode 100644 index 7403d22932..0000000000 --- a/Task/CSV-to-HTML-translation/EasyLang/csv-to-html-translation.easy +++ /dev/null @@ -1,37 +0,0 @@ -h$ = "\n\n\n\n
" -repeat - s$ = input - until s$ = "" - write h$ - for c$ in strchars s$ - if c$ = "," - if scnd = 0 - c$ = "" - else - c$ = "" - . - elif c$ = "<" - c$ = "<" - elif c$ = ">" - c$ = ">" - elif c$ = "&" - c$ = "&" - . - write c$ - . - if scnd = 0 - h$ = "
" - scnd = 1 - else - h$ = "
" - . -. -print "
" -# -input_data -Character,Speech -The multitude,The messiah! Show us the messiah! -Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! -The multitude,Who are you? -Brians mother,I'm his mother; that's who! -The multitude,Behold his mother! Behold his mother! diff --git a/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-1.l b/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-1.l index d19889b08f..a7a16c05df 100644 --- a/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-1.l +++ b/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-1.l @@ -5,25 +5,25 @@ ;; LISTS->HTML (define html 'html) (define (emit-tag tag html-proc content ) - (if (style tag) - (push html (format "<%s style='%a'>" tag (style tag))) - (push html (format "<%s>" tag ))) - (html-proc content) - (push html (format " " tag ))) - + (if (style tag) + (push html (format "<%s style='%a'>" tag (style tag))) + (push html (format "<%s>" tag ))) + (html-proc content) + (push html (format " " tag ))) + ;; html procs : 1 tag, 1 proc (define (h-raw content) - (push html (format "%s" content))) + (push html (format "%s" content))) (define (h-header headers) - (for ((h headers)) (emit-tag 'th h-raw h))) + (for ((h headers)) (emit-tag 'th h-raw h))) (define (h-row row) - (for ((item row)) (emit-tag 'td h-raw item))) + (for ((item row)) (emit-tag 'td h-raw item))) (define (h-table table ) - (emit-tag 'tr h-header (first table)) - (for ((row (rest table))) (emit-tag 'tr h-row row))) - + (emit-tag 'tr h-header (first table)) + (for ((row (rest table))) (emit-tag 'tr h-row row))) + (define (html-dump) (string-join (stack->list html) " ")) - + ;; STYLES (style 'td "text-align:left") (style 'table "border-spacing: 10px;border:28px ridge orange") ;; special biblical border diff --git a/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-2.l b/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-2.l index 72ca8f6071..777daf9665 100644 --- a/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-2.l +++ b/Task/CSV-to-HTML-translation/EchoLisp/csv-to-html-translation-2.l @@ -9,9 +9,9 @@ >>#) (define (task speech) - (define table (csv->table speech)) - (stack html) - (emit-tag 'table h-table table) - (html-dump)) - + (define table (csv->table speech)) + (stack html) + (emit-tag 'table h-table table) + (html-dump)) + (task MontyPython) diff --git a/Task/CSV-to-HTML-translation/Ed/csv-to-html-translation.ed b/Task/CSV-to-HTML-translation/Ed/csv-to-html-translation.ed deleted file mode 100644 index 88664bdb10..0000000000 --- a/Task/CSV-to-HTML-translation/Ed/csv-to-html-translation.ed +++ /dev/null @@ -1,15 +0,0 @@ -H -g/&/s//\&/g -g//s//\>/g -g/"/s//\"e;/g -g/^/s// /g -g/,/s//<\/td>/g -g/$/s//<\/td>\ - <\/tr>/ -1s/^/\ -/ -$s/$/\ -<\/table>/ -,p -Q diff --git a/Task/CSV-to-HTML-translation/Erlang/csv-to-html-translation.erl b/Task/CSV-to-HTML-translation/Erlang/csv-to-html-translation.erl index 31bfd905e1..b319341dbb 100644 --- a/Task/CSV-to-HTML-translation/Erlang/csv-to-html-translation.erl +++ b/Task/CSV-to-HTML-translation/Erlang/csv-to-html-translation.erl @@ -3,9 +3,9 @@ -export( [table_translation/1, task/0] ). table_translation( CSV ) -> - [Headers | Contents] = [string:tokens(X, ",") || X <- string:tokens( CSV, "\n")], - Table = create_html_table:html_table( [{border, "1"}, {cellpadding, "10"}], Headers, Contents ), - create_html_table:external_format( Table ). + [Headers | Contents] = [string:tokens(X, ",") || X <- string:tokens( CSV, "\n")], + Table = create_html_table:html_table( [{border, "1"}, {cellpadding, "10"}], Headers, Contents ), + create_html_table:external_format( Table ). task() -> table_translation( csv() ). diff --git a/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-1.eu b/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-1.euphoria similarity index 100% rename from Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-1.eu rename to Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-1.euphoria diff --git a/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-2.eu b/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-2.euphoria similarity index 100% rename from Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-2.eu rename to Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation-2.euphoria diff --git a/Task/CSV-to-HTML-translation/Forth/csv-to-html-translation-1.fth b/Task/CSV-to-HTML-translation/Forth/csv-to-html-translation-1.fth index 9bf8d4b906..b59459c399 100644 --- a/Task/CSV-to-HTML-translation/Forth/csv-to-html-translation-1.fth +++ b/Task/CSV-to-HTML-translation/Forth/csv-to-html-translation-1.fth @@ -5,18 +5,18 @@ : END-ROW END-COLUMN ." " CR ; : CSV2HTML - ."
" CR BEGIN-ROW - BEGIN KEY DUP #EOF <> WHILE - CASE - 10 OF END-ROW BEGIN-ROW ENDOF - [CHAR] , OF END-COLUMN BEGIN-COLUMN ENDOF - [CHAR] < OF ." <" ENDOF - [CHAR] > OF ." >" ENDOF - [CHAR] & OF ." &" ENDOF - DUP EMIT - ENDCASE - REPEAT - END-ROW ."
" CR + ." " CR BEGIN-ROW + BEGIN KEY DUP #EOF <> WHILE + CASE + 10 OF END-ROW BEGIN-ROW ENDOF + [CHAR] , OF END-COLUMN BEGIN-COLUMN ENDOF + [CHAR] < OF ." <" ENDOF + [CHAR] > OF ." >" ENDOF + [CHAR] & OF ." &" ENDOF + DUP EMIT + ENDCASE + REPEAT + END-ROW ."
" CR ; CSV2HTML BYE diff --git a/Task/CSV-to-HTML-translation/Fortran/csv-to-html-translation.f b/Task/CSV-to-HTML-translation/Fortran/csv-to-html-translation.f index 99aae70f36..73683283d8 100644 --- a/Task/CSV-to-HTML-translation/Fortran/csv-to-html-translation.f +++ b/Task/CSV-to-HTML-translation/Fortran/csv-to-html-translation.f @@ -1,71 +1,71 @@ - SUBROUTINE CSVTEXT2HTML(FNAME,HEADED) !Does not recognise quoted strings. + SUBROUTINE CSVTEXT2HTML(FNAME,HEADED) !Does not recognise quoted strings. Converts without checking field counts, or noting special characters. - CHARACTER*(*) FNAME !Names the input file. - LOGICAL HEADED !Perhaps its first line is to be a heading. - INTEGER MANY !How long is a piece of string? - PARAMETER (MANY=666) !This should suffice. - CHARACTER*(MANY) ALINE !A scratchpad for the input. - INTEGER MARK(0:MANY + 1) !Fingers the commas on a line. - INTEGER I,L,N !Assistants. - CHARACTER*2 WOT(2) !I don't see why a "table datum" could not be for either. - PARAMETER (WOT = (/"th","td"/)) !A table heding or a table datum - INTEGER IT !But, one must select appropriately. - INTEGER KBD,MSG,IN !A selection. - COMMON /IOUNITS/ KBD,MSG,IN !The caller thus avoids collisions. - OPEN(IN,FILE=FNAME,STATUS="OLD",ACTION="READ",ERR=661) !Go for the file. - WRITE (MSG,1) !Start the blather. - 1 FORMAT ("") !By stating that a table follows. - MARK(0) = 0 !Syncopation for the comma fingers. - N = 0 !No records read. + CHARACTER*(*) FNAME !Names the input file. + LOGICAL HEADED !Perhaps its first line is to be a heading. + INTEGER MANY !How long is a piece of string? + PARAMETER (MANY=666) !This should suffice. + CHARACTER*(MANY) ALINE !A scratchpad for the input. + INTEGER MARK(0:MANY + 1) !Fingers the commas on a line. + INTEGER I,L,N !Assistants. + CHARACTER*2 WOT(2) !I don't see why a "table datum" could not be for either. + PARAMETER (WOT = (/"th","td"/)) !A table heding or a table datum + INTEGER IT !But, one must select appropriately. + INTEGER KBD,MSG,IN !A selection. + COMMON /IOUNITS/ KBD,MSG,IN !The caller thus avoids collisions. + OPEN(IN,FILE=FNAME,STATUS="OLD",ACTION="READ",ERR=661) !Go for the file. + WRITE (MSG,1) !Start the blather. + 1 FORMAT ("
") !By stating that a table follows. + MARK(0) = 0 !Syncopation for the comma fingers. + N = 0 !No records read. - 10 READ (IN,11,END = 20) L,ALINE(1:MIN(L,MANY)) !Carefully acquire some text. - 11 FORMAT (Q,A) !Q = number of characters yet to read, A = characters. - N = N + 1 !So, a record has been read. - IF (L.GT.MANY) THEN !Perhaps it is rather long? - WRITE (MSG,12) N,L,MANY !Alas! - 12 FORMAT ("Line ",I0," has length ",I0,"! My limit is ",I0) !Squawk/ - L = MANY !The limit actually read. - END IF !So much for paranoia. - IF (N.EQ.1 .AND. HEADED) THEN !Is the first line to be treated specially? - WRITE (MSG,*) "" !Yep. Nominate a heading. - IT = 1 !And select "th" rather than "td". - ELSE !But mostly, - IT = 2 !Just another row for the table. - END IF !So much for the first line. - NCOLS = 0 !No commas have been seen. - DO I = 1,L !So scan the text for them. - IF (ICHAR(ALINE(I:I)).EQ.ICHAR(",")) THEN !Here? - NCOLS = NCOLS + 1 !Yes! - MARK(NCOLS) = I !The texts are between commas. - END IF !So much for that character. - END DO !On to the next. - NCOLS = NCOLS + 1 !This is why the + 1 for the size of MARK. - MARK(NCOLS) = L + 1 !End-of-line is as if a comma was one further along. - WRITE (MSG,13) !Now roll all the texts. - 1 (WOT(IT), !This starting a cell, - 2 ALINE(MARK(I - 1) + 1:MARK(I) - 1), !This being the text between the commas, - 3 WOT(IT), !And this ending each cell. - 4 I = 1,NCOLS), !For this number of columns. - 5 "/tr" !And this ends the row. - 13 FORMAT (" ",666("<",A,">",A,"")) !How long is a piece of string? - IF (N.EQ.1 .AND. HEADED) WRITE (MSG,*) "" !Finish the possible header. - GO TO 10 !And try for another record. + 10 READ (IN,11,END = 20) L,ALINE(1:MIN(L,MANY)) !Carefully acquire some text. + 11 FORMAT (Q,A) !Q = number of characters yet to read, A = characters. + N = N + 1 !So, a record has been read. + IF (L.GT.MANY) THEN !Perhaps it is rather long? + WRITE (MSG,12) N,L,MANY !Alas! + 12 FORMAT ("Line ",I0," has length ",I0,"! My limit is ",I0) !Squawk/ + L = MANY !The limit actually read. + END IF !So much for paranoia. + IF (N.EQ.1 .AND. HEADED) THEN !Is the first line to be treated specially? + WRITE (MSG,*) "" !Yep. Nominate a heading. + IT = 1 !And select "th" rather than "td". + ELSE !But mostly, + IT = 2 !Just another row for the table. + END IF !So much for the first line. + NCOLS = 0 !No commas have been seen. + DO I = 1,L !So scan the text for them. + IF (ICHAR(ALINE(I:I)).EQ.ICHAR(",")) THEN !Here? + NCOLS = NCOLS + 1 !Yes! + MARK(NCOLS) = I !The texts are between commas. + END IF !So much for that character. + END DO !On to the next. + NCOLS = NCOLS + 1 !This is why the + 1 for the size of MARK. + MARK(NCOLS) = L + 1 !End-of-line is as if a comma was one further along. + WRITE (MSG,13) !Now roll all the texts. + 1 (WOT(IT), !This starting a cell, + 2 ALINE(MARK(I - 1) + 1:MARK(I) - 1), !This being the text between the commas, + 3 WOT(IT), !And this ending each cell. + 4 I = 1,NCOLS), !For this number of columns. + 5 "/tr" !And this ends the row. + 13 FORMAT (" ",666("<",A,">",A,"")) !How long is a piece of string? + IF (N.EQ.1 .AND. HEADED) WRITE (MSG,*) "" !Finish the possible header. + GO TO 10 !And try for another record. - 20 CLOSE (IN) !Finished with input. - WRITE (MSG,21) !And finished with output. - 21 FORMAT ("
") !This writes starting at column one. - RETURN !Done! + 20 CLOSE (IN) !Finished with input. + WRITE (MSG,21) !And finished with output. + 21 FORMAT ("") !This writes starting at column one. + RETURN !Done! Confusions. - 661 WRITE (MSG,*) "Can't open file ",FNAME !Alas. - END !So much for the conversion. + 661 WRITE (MSG,*) "Can't open file ",FNAME !Alas. + END !So much for the conversion. INTEGER KBD,MSG,IN COMMON /IOUNITS/ KBD,MSG,IN - KBD = 5 !Standard input. - MSG = 6 !Standard output. - IN = 10 !Some unspecial number. + KBD = 5 !Standard input. + MSG = 6 !Standard output. + IN = 10 !Some unspecial number. - CALL CSVTEXT2HTML("Text.csv",.FALSE.) !The first line is not special. + CALL CSVTEXT2HTML("Text.csv",.FALSE.) !The first line is not special. WRITE (MSG,*) - CALL CSVTEXT2HTML("Text.csv",.TRUE.) !The first line is a heading. + CALL CSVTEXT2HTML("Text.csv",.TRUE.) !The first line is a heading. END diff --git a/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs index 19062de634..e1a1189b39 100644 --- a/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs +++ b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs @@ -6,6 +6,6 @@ main = interact (\csv -> "\n" ++ (unlines $ map ((\cols -> "\n" ++ (concatMap (\x -> " \n") cols) ++ "") . split (==',')) $ lines csv) ++ "
" ++ concatMap (\c -> case c of {'<' -> "<"; '>' -> ">"; - '&' -> "&"; '"' -> """; _ -> [c]}) x + '&' -> "&"; '"' -> """; _ -> [c]}) x ++ "
") diff --git a/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java index 854a68e627..348dee6b96 100644 --- a/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java +++ b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java @@ -4,83 +4,83 @@ import java.io.PrintStream; class Csv2Html { - public static String escapeChars(String lineIn) { - StringBuilder sb = new StringBuilder(); - int lineLength = lineIn.length(); - for (int i = 0; i < lineLength; i++) { - char c = lineIn.charAt(i); - switch (c) { - case '"': - sb.append("""); - break; - case '&': - sb.append("&"); - break; - case '\'': - sb.append("'"); - break; - case '<': - sb.append("<"); - break; - case '>': - sb.append(">"); - break; - default: sb.append(c); - } - } - return sb.toString(); - } + public static String escapeChars(String lineIn) { + StringBuilder sb = new StringBuilder(); + int lineLength = lineIn.length(); + for (int i = 0; i < lineLength; i++) { + char c = lineIn.charAt(i); + switch (c) { + case '"': + sb.append("""); + break; + case '&': + sb.append("&"); + break; + case '\'': + sb.append("'"); + break; + case '<': + sb.append("<"); + break; + case '>': + sb.append(">"); + break; + default: sb.append(c); + } + } + return sb.toString(); + } - public static void tableHeader(PrintStream ps, String[] columns) { - ps.print(""); - for (int i = 0; i < columns.length; i++) { - ps.print(""); - ps.print(columns[i]); - ps.print(""); - } - ps.println(""); - } + public static void tableHeader(PrintStream ps, String[] columns) { + ps.print(""); + for (int i = 0; i < columns.length; i++) { + ps.print(""); + ps.print(columns[i]); + ps.print(""); + } + ps.println(""); + } + + public static void tableRow(PrintStream ps, String[] columns) { + ps.print(""); + for (int i = 0; i < columns.length; i++) { + ps.print(""); + ps.print(columns[i]); + ps.print(""); + } + ps.println(""); + } + + public static void main(String[] args) throws Exception { + boolean withTableHeader = (args.length != 0); + + InputStreamReader isr = new InputStreamReader(System.in); + BufferedReader br = new BufferedReader(isr); + PrintStream stdout = System.out; + + stdout.println(""); + stdout.println(""); + stdout.println(""); + stdout.println("Csv2Html"); + stdout.println(""); + stdout.println("

Csv2Html

"); - public static void tableRow(PrintStream ps, String[] columns) { - ps.print(""); - for (int i = 0; i < columns.length; i++) { - ps.print(""); - ps.print(columns[i]); - ps.print(""); - } - ps.println(""); - } - - public static void main(String[] args) throws Exception { - boolean withTableHeader = (args.length != 0); - - InputStreamReader isr = new InputStreamReader(System.in); - BufferedReader br = new BufferedReader(isr); - PrintStream stdout = System.out; - - stdout.println(""); - stdout.println(""); - stdout.println(""); - stdout.println("Csv2Html"); - stdout.println(""); - stdout.println("

Csv2Html

"); - - stdout.println(""); - String stdinLine; - boolean firstLine = true; - while ((stdinLine = br.readLine()) != null) { - String[] columns = escapeChars(stdinLine).split(","); - if (withTableHeader == true && firstLine == true) { - tableHeader(stdout, columns); - firstLine = false; - } else { - tableRow(stdout, columns); - } - } - stdout.println("
"); - } + stdout.println(""); + String stdinLine; + boolean firstLine = true; + while ((stdinLine = br.readLine()) != null) { + String[] columns = escapeChars(stdinLine).split(","); + if (withTableHeader == true && firstLine == true) { + tableHeader(stdout, columns); + firstLine = false; + } else { + tableRow(stdout, columns); + } + } + stdout.println("
"); + } } diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js index c3c985804f..216911471c 100644 --- a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js +++ b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js @@ -1,9 +1,9 @@ var csv = "Character,Speech\n" + - "The multitude,The messiah! Show us the messiah!\n" + - "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n" + - "The multitude,Who are you?\n" + - "Brians mother,I'm his mother; that's who!\n" + - "The multitude,Behold his mother! Behold his mother!"; + "The multitude,The messiah! Show us the messiah!\n" + + "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n" + + "The multitude,Who are you?\n" + + "Brians mother,I'm his mother; that's who!\n" + + "The multitude,Behold his mother! Behold his mother!"; var lines = csv.replace(/&/g, '&') .replace(/ - - CharacterSpeech - - - The multitudeThe messiah! Show us the messiah! - Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry> - The multitudeWho are you? - Brians motherI'm his mother; that's who! - The multitudeBehold his mother! Behold his mother! + + CharacterSpeech + + + The multitudeThe messiah! Show us the messiah! + Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry> + The multitudeWho are you? + Brians motherI'm his mother; that's who! + The multitudeBehold his mother! Behold his mother! diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-4.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-4.js deleted file mode 100644 index 1124a5e5d1..0000000000 --- a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-4.js +++ /dev/null @@ -1,40 +0,0 @@ -function csvToHtml(input) { - if (!input || typeof input !== 'string') { - throw new Error('Invalid input!'); - } - - function _createTableCell(cellContents, index) { - if (!cellContents || typeof cellContents !== 'string') { - throw new Error('Invalid data!'); - } - - const tableCell = document.createElement( - (index === 0) ? 'th' : 'td' - ); - - tableCell.textContent = cellContents.trim(); - return tableCell; - } - - const rows = input.split('\n'); - const table = document.createElement('table'); - - rows.forEach((row, index) => { - const tableRow = document.createElement('tr'); - const tableCells = row.split(','); - - tableCells.forEach((cell) => { - try { - tableRow.appendChild( - _createTableCell(cell, index), - ); - } catch (error) { - console.error(error); - } - }); - - table.appendChild(tableRow); - }); - - return table; -} diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-5.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-5.js deleted file mode 100644 index 986924331b..0000000000 --- a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-5.js +++ /dev/null @@ -1,14 +0,0 @@ -const inputData = `Character,Speech -The multitude,The messiah! Show us the messiah! -Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! -The multitude,Who are you? -Brians mother,I'm his mother; that's who! -The multitude,Behold his mother! Behold his mother!`; - -try { - document.body.append( - csvToHtml(inputData), - ); -} catch (error) { - console.error(error) -} diff --git a/Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-1.jl b/Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-1.julia similarity index 100% rename from Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-1.jl rename to Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-1.julia diff --git a/Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-2.jl b/Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-2.julia similarity index 100% rename from Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-2.jl rename to Task/CSV-to-HTML-translation/Julia/csv-to-html-translation-2.julia diff --git a/Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-1.kts b/Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-1.kotlin similarity index 100% rename from Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-1.kts rename to Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-1.kotlin diff --git a/Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-2.kts b/Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-2.kotlin similarity index 100% rename from Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-2.kts rename to Task/CSV-to-HTML-translation/Kotlin/csv-to-html-translation-2.kotlin diff --git a/Task/CSV-to-HTML-translation/M2000-Interpreter/csv-to-html-translation.m2000 b/Task/CSV-to-HTML-translation/M2000-Interpreter/csv-to-html-translation.m2000 index 446db07183..af515e282b 100644 --- a/Task/CSV-to-HTML-translation/M2000-Interpreter/csv-to-html-translation.m2000 +++ b/Task/CSV-to-HTML-translation/M2000-Interpreter/csv-to-html-translation.m2000 @@ -1,72 +1,72 @@ module csv2html { - nl$={ - } - Repl$=lambda$ (a$) ->{ - a$=replace$("&", "&",a$) - a$=replace$(">", ">",a$) - a$=replace$("""", """,a$) - // add any other replacement here - =replace$("<", "<",a$) - } - Tag$=lambda$ nl$, repl$ (a$, b$, n=4)->{ - if n>0 then - a$=rtrim$(replace$(nl$, nl$+string$(" ", n), nl$+a$)) - if right$(a$,2)<>nl$ then a$+=nl$ - else - if right$(a$, 2)=nl$ then if left$(a$,2)<>nl$ then a$=nl$+a$ - end if - prop=(,) : Read ? prop // forth parameter optional (we have to initalize first with an empty array) - p=each(prop) : prop$="" // p is an iteration object. - while p - prop$+=" "+repl$(prop#val$(p^))+"="+quote$(repl$(prop#val$(p^+1))) - p=each(prop,p^+2) // start new from p^+2 (p^ is the internal counter) - end while - ="<"+b$+prop$+">"+a$+""+nl$ - } - - // Prepare FILE csv - tofile$={Character,Speech - The multitude,The messiah! Show us the messiah! - Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! - The multitude,Who are you? - Brians mother,I'm his mother; that's who! - The multitude,Behold his mother! Behold his mother! - } - open "forHtml.csv" for wide output as #f - Print #f, tofile$; - close #f - // prepare the input style for Input from file statement - // "," - we use comma between fields - // "." - for numbers we use dot for decimal separator - // false - we didn't read json style strings to normal strings (so \n convert to code 13, \t to code 9) - // true - we read strings unquote - input with ",",".",false, true - - // Read csv file - i=1 - document export$="" - Open "forHtml.csv" for wide input as #f - while not eof(#f) - input #f, a$, b$ - a$=repl$(a$) - b$=repl$(b$) - if i=1 then - export$+=tag$(tag$(a$, "th", 0)+tag$(b$,"th", 0), "tr", 4) - else - export$+=tag$(tag$(a$, "td", 0)+tag$(b$,"td", 0), "tr", 4) - end if - i++ - end while - close #f - style$=tag$({TD {background-color:#ddddff; } - thead TD {background-color:#ddffdd; text-align:center; } - },"style",4,("type", "text/css")) - title$= tag$("CSV to HTML translation - Extra Credit","title",0) - Head$= tag$(title$+ style$,"head") - html$={}+nl$+tag$(head$+tag$(tag$(export$, "table"), "body"), "html") - clipboard html$ - Report html$ - Print "Press Esc to exit browser" - browser "about: "+html$ + nl$={ + } + Repl$=lambda$ (a$) ->{ + a$=replace$("&", "&",a$) + a$=replace$(">", ">",a$) + a$=replace$("""", """,a$) + // add any other replacement here + =replace$("<", "<",a$) + } + Tag$=lambda$ nl$, repl$ (a$, b$, n=4)->{ + if n>0 then + a$=rtrim$(replace$(nl$, nl$+string$(" ", n), nl$+a$)) + if right$(a$,2)<>nl$ then a$+=nl$ + else + if right$(a$, 2)=nl$ then if left$(a$,2)<>nl$ then a$=nl$+a$ + end if + prop=(,) : Read ? prop // forth parameter optional (we have to initalize first with an empty array) + p=each(prop) : prop$="" // p is an iteration object. + while p + prop$+=" "+repl$(prop#val$(p^))+"="+quote$(repl$(prop#val$(p^+1))) + p=each(prop,p^+2) // start new from p^+2 (p^ is the internal counter) + end while + ="<"+b$+prop$+">"+a$+""+nl$ + } + + // Prepare FILE csv + tofile$={Character,Speech + The multitude,The messiah! Show us the messiah! + Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! + The multitude,Who are you? + Brians mother,I'm his mother; that's who! + The multitude,Behold his mother! Behold his mother! + } + open "forHtml.csv" for wide output as #f + Print #f, tofile$; + close #f + // prepare the input style for Input from file statement + // "," - we use comma between fields + // "." - for numbers we use dot for decimal separator + // false - we didn't read json style strings to normal strings (so \n convert to code 13, \t to code 9) + // true - we read strings unquote + input with ",",".",false, true + + // Read csv file + i=1 + document export$="" + Open "forHtml.csv" for wide input as #f + while not eof(#f) + input #f, a$, b$ + a$=repl$(a$) + b$=repl$(b$) + if i=1 then + export$+=tag$(tag$(a$, "th", 0)+tag$(b$,"th", 0), "tr", 4) + else + export$+=tag$(tag$(a$, "td", 0)+tag$(b$,"td", 0), "tr", 4) + end if + i++ + end while + close #f + style$=tag$({TD {background-color:#ddddff; } + thead TD {background-color:#ddffdd; text-align:center; } + },"style",4,("type", "text/css")) + title$= tag$("CSV to HTML translation - Extra Credit","title",0) + Head$= tag$(title$+ style$,"head") + html$={}+nl$+tag$(head$+tag$(tag$(export$, "table"), "body"), "html") + clipboard html$ + Report html$ + Print "Press Esc to exit browser" + browser "about: "+html$ } csv2html diff --git a/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m index 26001f6ada..fc8d987cac 100644 --- a/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m +++ b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Maple/csv-to-html-translation.maple b/Task/CSV-to-HTML-translation/Maple/csv-to-html-translation.maple index 0203f01f0d..5b6d65d7eb 100644 --- a/Task/CSV-to-HTML-translation/Maple/csv-to-html-translation.maple +++ b/Task/CSV-to-HTML-translation/Maple/csv-to-html-translation.maple @@ -1,10 +1,10 @@ #A translation of the C code posted html_table := proc(str) - local char; + local char; printf("\n\n\n\n" + htmlrow = "\t\n" - // loop through the values in the current csv row - for i in range(1, len(record)) - htmlrow = htmlrow + "\t\t<" + tag + ">" + (record ~ i) + "\n" - end for + // loop through the values in the current csv row + for i in range(1, len(record)) + htmlrow = htmlrow + "\t\t<" + tag + ">" + (record ~ i) + "\n" + end for - return htmlrow + "\t\n" + return htmlrow + "\t\n" end def // get the name of the csv file then open it @@ -23,7 +23,7 @@ htmltable = (htmltable + toHtmlRow(#0, "th")) // add all other rows to the table for i in range(1, $dbsize) - htmltable = (htmltable + toHtmlRow(#i, "td")) + htmltable = (htmltable + toHtmlRow(#i, "td")) end for // close the html table diff --git a/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num b/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num deleted file mode 100644 index c250b2c016..0000000000 --- a/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num +++ /dev/null @@ -1,85 +0,0 @@ -#* -(this is a multiline comment in Nom) - -GRAMMAR OR PARSE TOKENS - nl* - new line, end of line - field* - one csv field - fieldset* - a number of fields - record* - one record (line) or a set of csv fields - recordset* - -*# - - # using the empty recordset trick - begin { - add "recordset*"; push; - } - read; - # ignore whitespace outside of quotes - " " { while [ ]; clear; .restart } - "\n" { put; clear; add "nl*"; push; .reparse } - '"' { - until '"'; clip; clop; unescape '"'; - whilenot [\n,]; - replace "&" "&"; replace "<" "<"; replace ">" ">"; - put; clear; add ""; put; clear; - add "field*"; push; - clear; .reparse - } - "," { clear; } - - whilenot [\n,]; - replace "&" "&"; replace "<" "<"; replace ">" ">"; - put; clear; add ""; put; clear; - add "field*"; push; - -parse> - # useful for debugging - #add "line "; lines; add " char "; chars; add ": "; print; clear; - #add "\n"; unstack; print; clip; stack; - - # 1 token - pop; - # a record may be terminated by the end of input - (eof)."fieldset*" { - clear; add ""; get; add "\n"; put; clear; - add "record*"; push; .reparse - } - # 2 tokens - pop; - "recordset*field*" { - replace "field" "fieldset"; push; push; .reparse - } - # ignore blank lines - "recordset*nl*" { - clip; clip; clip; push; .reparse - } - "fieldset*field*" { - clear; get; ++; get; --; put; clear; - add "fieldset*"; push; .reparse - } - "fieldset*nl*" { - clear; add "\n "; get; add "\n"; put; clear; - add "record*"; push; .reparse - } - "recordset*record*" { - clear; a+; get; - ++; get; --; put; clear; - # if the count is 1, then this is the 1st - # record and should be marked up as a table header. - count; "1" { - clear; get; replace "tr>" "thead>"; put; - } - clear; add "recordset*"; push; .reparse - } - - (eof) { - !"recordset*" { - clear; add "[invalid csv]\nThe parse stack was: "; print; - clear; unstack; add "\n"; print; quit; - } - clear; - add "
"); for char in str do if char = "\n" then - printf("
") + printf("
") elif char = "," then printf("") elif char = "<" then @@ -12,7 +12,7 @@ html_table := proc(str) elif char = ">" then printf(">") elif char = "&" then - printf("&") + printf("&") else printf(char) end if; diff --git a/Task/CSV-to-HTML-translation/Nanoquery/csv-to-html-translation.nanoquery b/Task/CSV-to-HTML-translation/Nanoquery/csv-to-html-translation.nanoquery index 7af517fddc..1421fc83b6 100644 --- a/Task/CSV-to-HTML-translation/Nanoquery/csv-to-html-translation.nanoquery +++ b/Task/CSV-to-HTML-translation/Nanoquery/csv-to-html-translation.nanoquery @@ -1,13 +1,13 @@ // a method that converts a csv row into a html table row as a string def toHtmlRow(record, tag) - htmlrow = "\t
"; get; add ""; get; add "
\n"; get; add "
\n"; - add "[valid csv!] Found "; count; add " records.\n"; - print; quit; - } - push; push; diff --git a/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num b/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num deleted file mode 100644 index fa64e7c50e..0000000000 --- a/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-1.ml b/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-1.ocaml similarity index 100% rename from Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-1.ml rename to Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-1.ocaml diff --git a/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-2.ml b/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-2.ocaml similarity index 100% rename from Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-2.ml rename to Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-2.ocaml diff --git a/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-3.ml b/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-3.ocaml similarity index 100% rename from Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-3.ml rename to Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-3.ocaml diff --git a/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-4.ml b/Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-4.ocaml similarity index 100% rename from Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-4.ml rename to Task/CSV-to-HTML-translation/OCaml/csv-to-html-translation-4.ocaml diff --git a/Task/CSV-to-HTML-translation/Oberon/csv-to-html-translation.oberon b/Task/CSV-to-HTML-translation/Oberon-2/csv-to-html-translation.oberon similarity index 100% rename from Task/CSV-to-HTML-translation/Oberon/csv-to-html-translation.oberon rename to Task/CSV-to-HTML-translation/Oberon-2/csv-to-html-translation.oberon diff --git a/Task/CSV-to-HTML-translation/OmniMark/csv-to-html-translation-1.xom b/Task/CSV-to-HTML-translation/OmniMark/csv-to-html-translation-1.xom deleted file mode 100644 index 10f9ee5923..0000000000 --- a/Task/CSV-to-HTML-translation/OmniMark/csv-to-html-translation-1.xom +++ /dev/null @@ -1,73 +0,0 @@ -global switch thead initial {true} -global switch tbody-first initial {true} - -define function process-tr (value stream line) as - do when thead - output '%n' - else when tbody-first - output '%n' - output '%n' - deactivate tbody-first - else - output '' - done - repeat scan line - match ',' any-text => char - output '' when thead - output '' unless thead - using group ents submit char - match any-text => char - using group ents submit char - again - output '' unless thead - output '' when thead - output '' - deactivate thead - - -process-start - output '%n' || - '%n' || - '%n' || - '%n' || - 'Monty Python’s Life of Brian (1979). Scene 20 (extract).%n' || - '%n' || - '%n' || - '%n' || - '%n' || - '%n' || - '%n' || - '%n' - -process-end - output '%n' || - '
%n' || - '%n' || - '%n' - ; Output validates to XHTML 1.0 - https://validator.w3.org/check - -process - local stream s - set s to "Character,Speech%n" || - "The multitude,The messiah! Show us the messiah!%n" || - "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!%n" || - "The multitude,Who are you?%n" || - "Brians mother,I'm his mother; that's who!%n" || - "The multitude,Behold his mother! Behold his mother!%n" - using group line submit s - -group ents - - find '<' - output '<' - - find '>' - output '>' - - find "'" - output ''' - -group line - - find line-start any-text+ => line - process-tr(line) diff --git a/Task/CSV-to-HTML-translation/OmniMark/csv-to-html-translation-2.xom b/Task/CSV-to-HTML-translation/OmniMark/csv-to-html-translation-2.xom deleted file mode 100644 index 92ff6b135c..0000000000 --- a/Task/CSV-to-HTML-translation/OmniMark/csv-to-html-translation-2.xom +++ /dev/null @@ -1,27 +0,0 @@ - - - - -Monty Python’s Life of Brian (1979). Scene 20 (extract). - - - - - - - - - - - - - - - - - -
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
- - diff --git a/Task/CSV-to-HTML-translation/OpenEdge-Progress/csv-to-html-translation-2.openedge b/Task/CSV-to-HTML-translation/OpenEdge-Progress/csv-to-html-translation-2.openedge index 5d586a5912..0a1dc0c135 100644 --- a/Task/CSV-to-HTML-translation/OpenEdge-Progress/csv-to-html-translation-2.openedge +++ b/Task/CSV-to-HTML-translation/OpenEdge-Progress/csv-to-html-translation-2.openedge @@ -1,28 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-1.ps1 b/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-1.psh similarity index 100% rename from Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-1.ps1 rename to Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-1.psh diff --git a/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-2.ps1 b/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-2.psh similarity index 100% rename from Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-2.ps1 rename to Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-2.psh diff --git a/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-3.ps1 b/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-3.psh similarity index 100% rename from Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-3.ps1 rename to Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-3.psh diff --git a/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-4.ps1 b/Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-4.psh similarity index 100% rename from Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-4.ps1 rename to Task/CSV-to-HTML-translation/PowerShell/csv-to-html-translation-4.psh diff --git a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro index 735abd10f0..06bf8c825f 100644 --- a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro +++ b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro @@ -1,52 +1,52 @@ csv_html :- - L = "Character,Speech + L = "Character,Speech The multitude,The messiah! Show us the messiah! Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! The multitude,Who are you? Brians mother,I'm his mother; that's who! The multitude,Behold his mother! Behold his mother!", - csv_html(L, Out, []), - string_to_list(Str, Out), - writeln(Str). + csv_html(L, Out, []), + string_to_list(Str, Out), + writeln(Str). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % simple HTML % csv_html(L) --> - "\n", - csv_tr(L), - "
". + "\n", + csv_tr(L), + "
". csv_tr([]) --> []. csv_tr(L) --> - "\n", - csv_td(L, S), - "\n\n", - csv_tr(S). + "\n", + csv_td(L, S), + "\n\n", + csv_tr(S). csv_td(L, S) --> - "", - csv_td_in(L, S), - "". + "", + csv_td_in(L, S), + "". csv_td_in([], []) --> []. csv_td_in([10|L], L) --> []. csv_td_in([44|L], S) --> - "", - csv_td_in(L,S). + "", + csv_td_in(L,S). csv_td_in([60|T], S) --> - "<", - csv_td_in(T, S). + "<", + csv_td_in(T, S). csv_td_in([62|T], S) --> - ">", - csv_td_in(T, S). + ">", + csv_td_in(T, S). csv_td_in([H|T], S) --> - [H], - csv_td_in(T, S). + [H], + csv_td_in(T, S). diff --git a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro index 317040a50e..c5c27aeaa0 100644 --- a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro +++ b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro @@ -1,5 +1,5 @@ csv_html_plus :- - L = + L = "Character,Speech The multitude,The messiah! Show us the messiah! Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! @@ -7,84 +7,84 @@ The multitude,Who are you? Brians mother,I'm his mother; that's who! The multitude,Behold his mother! Behold his mother!", - csv_html_plus(L, Out1, []), - string_to_list(Str1, Out1), - writeln(Str1). + csv_html_plus(L, Out1, []), + string_to_list(Str1, Out1), + writeln(Str1). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HTML + % csv_html_plus(L) --> - "\n", - csv_head(L, R), - csv_body(R), - "
". + "\n", + csv_head(L, R), + csv_body(R), + "
". csv_head(L, R) --> - "\n", - csv_head_tr(L, R), - "\n". + "\n", + csv_head_tr(L, R), + "\n". csv_head_tr(L, R) --> - "\n", - csv_head_th(L, R), - "\n\n". + "\n", + csv_head_th(L, R), + "\n\n". csv_head_th(L, S) --> - "", - csv_head_th_in(L, S), - "". + "", + csv_head_th_in(L, S), + "". csv_head_th_in([], []) --> []. csv_head_th_in([10|L], L) --> []. csv_head_th_in([44|L], S) --> - "", - csv_head_th_in(L,S). + "", + csv_head_th_in(L,S). csv_head_th_in([H|T], S) --> - [H], - csv_head_th_in(T, S). + [H], + csv_head_th_in(T, S). csv_body(L) --> - "\n", - csv_body_tr(L), - "\n". + "\n", + csv_body_tr(L), + "\n". csv_body_tr([]) --> []. csv_body_tr(L) --> - "\n", - csv_body_td(L, S), - "\n\n", - csv_body_tr(S). + "\n", + csv_body_td(L, S), + "\n\n", + csv_body_tr(S). csv_body_td(L, S) --> - "", - csv_body_td_in(L, S), - "". + "", + csv_body_td_in(L, S), + "". csv_body_td_in([], []) --> []. csv_body_td_in([10|L], L) --> []. csv_body_td_in([44|L], S) --> - "", - csv_body_td_in(L,S). + "", + csv_body_td_in(L,S). csv_body_td_in([60|T], S) --> - "<", - csv_body_td_in(T, S). + "<", + csv_body_td_in(T, S). csv_body_td_in([62|T], S) --> - ">", - csv_body_td_in(T, S). + ">", + csv_body_td_in(T, S). csv_body_td_in([H|T], S) --> - [H], - csv_body_td_in(T, S). + [H], + csv_body_td_in(T, S). diff --git a/Task/CSV-to-HTML-translation/Raku/csv-to-html-translation-1.raku b/Task/CSV-to-HTML-translation/Raku/csv-to-html-translation-1.raku index f6bfab0ad8..c171689eae 100644 --- a/Task/CSV-to-HTML-translation/Raku/csv-to-html-translation-1.raku +++ b/Task/CSV-to-HTML-translation/Raku/csv-to-html-translation-1.raku @@ -25,4 +25,4 @@ printf # that / at the end is just an unspace, you can omit it, but then you have to delete # all whitespace and comments between split(…) and .map .map({tag 'td', $^cell}))})\ # map those cells as td - .join("\n"); # append a newline for nicer output + .join("\n"); # append a newline for nicer output diff --git a/Task/CSV-to-HTML-translation/Rebol/csv-to-html-translation-1.rebol b/Task/CSV-to-HTML-translation/Rebol/csv-to-html-translation-1.rebol deleted file mode 100644 index 406c067313..0000000000 --- a/Task/CSV-to-HTML-translation/Rebol/csv-to-html-translation-1.rebol +++ /dev/null @@ -1,53 +0,0 @@ -Rebol [ - title: "Rosetta code: CSV to HTML translation" - file: %CSV_to_HTML_translation.r3 - url: https://rosettacode.org/wiki/CSV_to_HTML_translation - needs: 3.15.0 ;; or something like that -] -import csv - -csv-to-html: function/with [ - "Generate string with html table from csv data file" - csv [string! file!] "input .csv data" -][ - escape-html csv - - data: decode 'csv csv - html: copy "^/" - - emit-row/head data/1 - foreach row next data [ emit-row row ] - emit
-][ - html: none - emit: func [val][ - if block? val [val: ajoin val] - append html val - ] - emit-row: func[row /head][ - emit [""] - foreach col row [ - emit-tag either head ['th]['td] col - ] - emit "^/" - ] - emit-tag: func [tag content][ - emit [#"<" tag #">" content ""] - ] - escape-html: function/with [str][ - parse str [any[ - to esc [ - change #"<" "<" - | change #">" ">" - | change #"&" "&" - ] - ]] - ][ esc: charset "<>&" ] -] - -print csv-to-html {Character,Speech -The multitude,The messiah! Show us the messiah! -Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! -The multitude,Who are you? -Brians mother,I'm his mother; that's who! -The multitude,Behold his mother! Behold his mother!} diff --git a/Task/CSV-to-HTML-translation/Rebol/csv-to-html-translation-2.rebol b/Task/CSV-to-HTML-translation/Rebol/csv-to-html-translation-2.rebol deleted file mode 100644 index dfebcd13ff..0000000000 --- a/Task/CSV-to-HTML-translation/Rebol/csv-to-html-translation-2.rebol +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - -
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Run-BASIC/csv-to-html-translation.basic b/Task/CSV-to-HTML-translation/Run-BASIC/csv-to-html-translation.basic index 41e53b8200..4fa25a5ea3 100644 --- a/Task/CSV-to-HTML-translation/Run-BASIC/csv-to-html-translation.basic +++ b/Task/CSV-to-HTML-translation/Run-BASIC/csv-to-html-translation.basic @@ -5,7 +5,7 @@ The multitude,Who are you? Brians mother,I'm his mother; that's who! The multitude,Behold his mother! Behold his mother!" -k = instr(csv$,",") ' 2 exra lines to get heading +k = instr(csv$,",") ' 2 exra lines to get heading csv$ = left$(csv$,k - 1) + " + mid$(csv$,k + 1) csv$ = strRep$(csv$,",","") @@ -15,10 +15,10 @@ wait ' string replace rep str with ' -------------------------------- FUNCTION strRep$(strRep$,rep$,with$) -ln = len(rep$) -k = instr(strRep$,rep$) +ln = len(rep$) +k = instr(strRep$,rep$) while k - strRep$ = left$(strRep$,k - 1) + with$ + mid$(strRep$,k + ln) - k = instr(strRep$,rep$) + strRep$ = left$(strRep$,k - 1) + with$ + mid$(strRep$,k + ln) + k = instr(strRep$,rep$) WEND END FUNCTION diff --git a/Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-1.rs b/Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-1.rust similarity index 100% rename from Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-1.rs rename to Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-1.rust diff --git a/Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-2.rs b/Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-2.rust similarity index 100% rename from Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-2.rs rename to Task/CSV-to-HTML-translation/Rust/csv-to-html-translation-2.rust diff --git a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl index 2761df41e6..6b41ae0db4 100644 --- a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl +++ b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl @@ -18,7 +18,7 @@ html::init puts [subst { [html::openTag table {summary="csv2html program output"}] [html::while {[rows size]} { - [html::row {*}[html::quoteFormValue [rows get]]] + [html::row {*}[html::quoteFormValue [rows get]]] }] [html::closeTag] }] diff --git a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl index 18c6bcdfff..748d62eea4 100644 --- a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl +++ b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl @@ -37,9 +37,9 @@ foreach line [split $csvData "\n"] { # Generate the output puts [subst { [table { - [tr [html::quoteFormValue [rows get]] {bgcolor="yellow"}] - [html::while {[rows size]} { - [tr [html::quoteFormValue [rows get]]] - }] + [tr [html::quoteFormValue [rows get]] {bgcolor="yellow"}] + [html::while {[rows size]} { + [tr [html::quoteFormValue [rows get]]] + }] }] }] diff --git a/Task/CSV-to-HTML-translation/Uiua/csv-to-html-translation.uiua b/Task/CSV-to-HTML-translation/Uiua/csv-to-html-translation.uiua deleted file mode 100644 index 8b7fe76408..0000000000 --- a/Task/CSV-to-HTML-translation/Uiua/csv-to-html-translation.uiua +++ /dev/null @@ -1,9 +0,0 @@ -$ Character,Speech -$ The multitude,The messiah! Show us the messiah! -$ Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! -$ The multitude,Who are you? -$ Brians mother,I'm his mother; that's who! -$ The multitude,Behold his mother! Behold his mother! -⊜(□$"_"/◇⊂⊜(□$"_")⊸≠@,)⊸≠@\n -/◇$"_\n_" -&p$"\n\n_\n
CharacterSpeech
" diff --git a/Task/CSV-to-HTML-translation/VBScript/csv-to-html-translation.vb b/Task/CSV-to-HTML-translation/VBScript/csv-to-html-translation.vb new file mode 100644 index 0000000000..2eadb9ed6f --- /dev/null +++ b/Task/CSV-to-HTML-translation/VBScript/csv-to-html-translation.vb @@ -0,0 +1,33 @@ +Set objfso = CreateObject("Scripting.FileSystemObject") + +parent_folder = objfso.GetParentFolderName(WScript.ScriptFullName) & "\" + +Set objcsv = objfso.OpenTextFile(parent_folder & "in.csv",1,False) +Set objhtml = objfso.OpenTextFile(paren_folder & "out.html",2,True) + +objhtml.Write(csv_to_html(objcsv.ReadAll)) + +objcsv.Close +objhtml.Close +Set objfso = Nothing + +Function csv_to_html(s) + row = Split(s,vbCrLf) + 'write the header + tmp = "" + For i = 0 To UBound(row) + field = Split(row(i),",") + If i = 0 Then + tmp = tmp & "" + Else + tmp = tmp & "" + End If + Next + 'write the footer + tmp = tmp & "
" & replace_chars(field(0)) & "" & replace_chars(field(1)) & "
" & replace_chars(field(0)) & "" & replace_chars(field(1)) & "
" + csv_to_html = tmp +End Function + +Function replace_chars(s) + replace_chars = Replace(Replace(s,"<","<"),">",">") +End Function diff --git a/Task/CSV-to-HTML-translation/VBScript/csv-to-html-translation.vbs b/Task/CSV-to-HTML-translation/VBScript/csv-to-html-translation.vbs deleted file mode 100644 index 33894748ed..0000000000 --- a/Task/CSV-to-HTML-translation/VBScript/csv-to-html-translation.vbs +++ /dev/null @@ -1,33 +0,0 @@ -Set objfso = CreateObject("Scripting.FileSystemObject") - -parent_folder = objfso.GetParentFolderName(WScript.ScriptFullName) & "\" - -Set objcsv = objfso.OpenTextFile(parent_folder & "in.csv",1,False) -Set objhtml = objfso.OpenTextFile(paren_folder & "out.html",2,True) - -objhtml.Write(csv_to_html(objcsv.ReadAll)) - -objcsv.Close -objhtml.Close -Set objfso = Nothing - -Function csv_to_html(s) - row = Split(s,vbCrLf) - 'write the header - tmp = "" - For i = 0 To UBound(row) - field = Split(row(i),",") - If i = 0 Then - tmp = tmp & "" - Else - tmp = tmp & "" - End If - Next - 'write the footer - tmp = tmp & "
" & replace_chars(field(0)) & "" & replace_chars(field(1)) & "
" & replace_chars(field(0)) & "" & replace_chars(field(1)) & "
" - csv_to_html = tmp -End Function - -Function replace_chars(s) - replace_chars = Replace(Replace(s,"<","<"),">",">") -End Function diff --git a/Task/CUSIP/11l/cusip.11l b/Task/CUSIP/11l/cusip.11l index c3bafa6306..c1a3973294 100644 --- a/Task/CUSIP/11l/cusip.11l +++ b/Task/CUSIP/11l/cusip.11l @@ -1,10 +1,10 @@ F cusip_check(=cusip) I cusip.len != 9 - X.throw ValueError(‘CUSIP must be 9 characters’) + X ValueError(‘CUSIP must be 9 characters’) cusip = cusip.uppercase() V total = 0 - L(i) 0.<8 + L(i) 8 V v = 0 V c = cusip[i] I c.is_digit() diff --git a/Task/CUSIP/ALGOL-68/cusip.alg b/Task/CUSIP/ALGOL-68/cusip.alg index 95cae39ff8..32d1c0bad0 100644 --- a/Task/CUSIP/ALGOL-68/cusip.alg +++ b/Task/CUSIP/ALGOL-68/cusip.alg @@ -1,35 +1,44 @@ -BEGIN # validate CUSIP codes # - - # returns TRUE if cusip string is a valid CUSIP code, FALSE otherwise # - OP ISCUSIP = ( STRING cusip string )BOOL: - IF UPB cusip string - LWB cusip string /= 8 - THEN FALSE # CUSIP code is not 9 characters long # - ELSE # CUSIP code has the correct length # - - # returns the base 39 digit corresponding to a character of a CUSIP code # - PROC cusip digit = ( CHAR c char )INT: - IF STRING cusip digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#"[ AT 0 ]; - INT digit := 0; - char in string( c char, digit, cusip digits ) - THEN digit - ELSE -999 # invalid digit # - FI # cusip digit # ; - - []CHAR cusip = cusip string[ AT 1 ]; - INT sum := 0; - INT check digit = cusip digit( cusip[ UPB cusip ] ); - FOR c pos TO UPB cusip - 1 DO - INT digit := cusip digit( cusip[ c pos ] ); - IF NOT ODD c pos THEN digit *:= 2 FI; - sum +:= ( digit OVER 10 ) + ( digit MOD 10 ) - OD; - ( 10 - ( sum MOD 10 ) ) MOD 10 = check digit - FI # is cusip # ; +BEGIN + # returns TRUE if cusip is a valid CUSIP code # + OP ISCUSIP = ( STRING cusip )BOOL: + IF ( UPB cusip - LWB cusip ) /= 8 + THEN + # code is wrong length # + FALSE + ELSE + # string is 9 characters long - check it is valid # + STRING cusip digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#"[ AT 0 ]; + INT check digit := 0; + IF NOT char in string( cusip[ UPB cusip ], check digit, cusip digits ) + THEN + # invalid check digit # + FALSE + ELSE + # OK so far compare the calculated check sum to the supplied one # + INT sum := 0; + INT c pos := LWB cusip - 1; + FOR i TO 8 DO + INT digit := 0; + IF NOT char in string( cusip[ i + c pos ], digit, cusip digits ) + THEN + # invalid digit # + digit := -999 + FI; + IF NOT ODD i + THEN + # even digit # + digit *:= 2 + FI; + sum +:= ( digit OVER 10 ) + ( digit MOD 10 ) + OD; + ( 10 - ( sum MOD 10 ) ) MOD 10 = check digit + FI + FI ; # ISCUSIP # # task test cases # PROC test cusip = ( STRING cusip )VOID: - print( ( cusip, IF ISCUSIP cusip THEN " valid" ELSE " invalid" FI, newline ) ); + print( ( cusip, IF ISCUSIP cusip THEN " valid" ELSE " invalid" FI, newline ) ); test cusip( "037833100" ); test cusip( "17275R102" ); diff --git a/Task/CUSIP/ANSI-BASIC/cusip.basic b/Task/CUSIP/ANSI-BASIC/cusip.basic deleted file mode 100644 index 13e8080304..0000000000 --- a/Task/CUSIP/ANSI-BASIC/cusip.basic +++ /dev/null @@ -1,63 +0,0 @@ -100 REM CUSIP -110 DECLARE EXTERNAL SUB PrintVerdict -120 DECLARE EXTERNAL FUNCTION CusipCheckDigit -130 DECLARE EXTERNAL FUNCTION IsValidCusip -140 PRINT "CUSIP Verdict" -150 CALL PrintVerdict("037833100") -160 CALL PrintVerdict("17275R102") -170 CALL PrintVerdict("38259P508") -180 CALL PrintVerdict("594918104") -190 CALL PrintVerdict("68389X106") -200 CALL PrintVerdict("68389X105") -210 END -220 REM ** -230 EXTERNAL FUNCTION CusipCheckDigit(Cusip$) -240 LET I = 1 -250 LET Sum = 0 -260 LET L = LEN(Cusip$) -270 DO WHILE I < L -280 LET C$ = Cusip$(I:I) -290 IF ("0" <= C$) AND (C$ <= "9") THEN -300 LET V = VAL(C$) -310 ELSEIF ("A" <= C$) AND (C$ <= "Z") THEN -320 LET V = ORD(C$) - 65 + 10 -330 ELSEIF C$ = "*" THEN -340 LET V = 36 -350 ELSEIF C$ = "@" THEN -360 LET V = 37 -370 ELSEIF C$ = "#" THEN -380 LET V = 38 -390 ELSE -400 LET CusipCheckDigit = -1 -410 EXIT FUNCTION -420 END IF -430 IF MOD(I - 1, 2) = 1 THEN LET V = 2 * V -440 IF I <= 8 THEN LET Sum = Sum + INT(V / 10) + MOD(V, 10) -450 LET I = I + 1 -460 LOOP -470 IF I <> 9 THEN -480 LET CusipCheckDigit = -1 -490 ELSE -500 LET CusipCheckDigit = MOD(10 - MOD(Sum, 10), 10) -510 END IF -520 END FUNCTION -530 REM ** -540 EXTERNAL FUNCTION IsValidCusip (Cusip$) -550 LET Check = CusipCheckDigit(Cusip$) -560 IF Check < 0 THEN -570 LET IsValidCusip = 0 -580 ELSEIF Cusip$(9:9) = CHR$(48 + Check) THEN -590 LET IsValidCusip = -1 -600 ELSE -610 LET IsValidCusip = 0 -620 END IF -630 END FUNCTION -640 REM ** -650 EXTERNAL SUB PrintVerdict (Cusip$) -660 PRINT Cusip$; -670 IF IsValidCusip(Cusip$) <>0 THEN -680 PRINT " : Valid" -690 ELSE -700 PRINT " : Invalid" -710 END IF -720 END SUB diff --git a/Task/CUSIP/Ada/cusip.adb b/Task/CUSIP/Ada/cusip.ada similarity index 100% rename from Task/CUSIP/Ada/cusip.adb rename to Task/CUSIP/Ada/cusip.ada diff --git a/Task/CUSIP/Arturo/cusip.arturo b/Task/CUSIP/Arturo/cusip.arturo index bde0bd1ddc..b8615d3d49 100644 --- a/Task/CUSIP/Arturo/cusip.arturo +++ b/Task/CUSIP/Arturo/cusip.arturo @@ -1,17 +1,17 @@ validCUSIP?: function [cusip][ s: 0 - alpha: 'A'..'Z' + alpha: `A`..`Z` loop.with:'i chop cusip 'c [ v: 0 - when.has: c [ - [|numeric?] -> v: to :integer to :string c - [|in? alpha] -> v: (index alpha c) + 1 + 9 - [= '*'] -> v: 36 - [= '@'] -> v: 37 - [= '#'] -> v: 38 - ] + case ø + when? [numeric? c] -> v: to :integer to :string c + when? [in? c alpha] -> v: (index alpha c) + 1 + 9 + when? [c = `*`] -> v: 36 + when? [c = `@`] -> v: 37 + when? [c = `#`] -> v: 38 + else [] if odd? i -> v: 2 * v diff --git a/Task/CUSIP/BQN/cusip.bqn b/Task/CUSIP/BQN/cusip.bqn deleted file mode 100644 index dd8bf31a89..0000000000 --- a/Task/CUSIP/BQN/cusip.bqn +++ /dev/null @@ -1,5 +0,0 @@ -d ← ∾"0A*@#"+⟜↕¨10‿26‿1‿1‿1 -m ← 8⥊1‿2 -Check ← ¯1(⊑=10|0-˜´10(|+⌊∘÷˜)m×↓)d⊐⊢ - -Check¨ "037833100"‿"17275R102"‿"38259P508"‿"594918104"‿"68389X106"‿"68389X105" diff --git a/Task/CUSIP/C++/cusip.cpp b/Task/CUSIP/C++/cusip.cpp index 12e2532ff9..801e0800fb 100644 --- a/Task/CUSIP/C++/cusip.cpp +++ b/Task/CUSIP/C++/cusip.cpp @@ -12,11 +12,9 @@ bool isCusip(const std::string& s) { if ('0' <= c && c <= '9') { v = c - '0'; } else if ('A' <= c && c <= 'Z') { - v = c - 'A' + 10; + v = c - '@'; } else if (c = '*') { v = 36; - } else if (c = '@') { - v = 37; } else if (c = '#') { v = 38; } else { diff --git a/Task/CUSIP/Crystal/cusip.cr b/Task/CUSIP/Crystal/cusip.cr deleted file mode 100644 index f601d4b0cf..0000000000 --- a/Task/CUSIP/Crystal/cusip.cr +++ /dev/null @@ -1,28 +0,0 @@ -def cusip_check (input) - return false unless input.size == 9 - sum = 0 - input.chars.each_with_index do |c, i| - break if i == 8 - v = case c - when .ascii_number? then c.to_i - when .ascii_uppercase? then c.ord - 'A'.ord + 10 - when '*' then 36 - when '@' then 37 - when '#' then 38 - else return false - end - v *= 2 if (i+1).even? - - sum += v // 10 + v % 10 - end - input[-1].to_i? == (10 - sum % 10) % 10 -end - -["037833100", - "17275R102", - "38259P508", - "594918104", - "68389X106", - "68389X105"].each do |cusip| - print cusip, ": ", cusip_check(cusip) ? "valid" : "invalid", "\n" -end diff --git a/Task/CUSIP/Delphi/cusip.pas b/Task/CUSIP/Delphi/cusip.delphi similarity index 100% rename from Task/CUSIP/Delphi/cusip.pas rename to Task/CUSIP/Delphi/cusip.delphi diff --git a/Task/CUSIP/EasyLang/cusip.easy b/Task/CUSIP/EasyLang/cusip.easy deleted file mode 100644 index 574de473d0..0000000000 --- a/Task/CUSIP/EasyLang/cusip.easy +++ /dev/null @@ -1,27 +0,0 @@ -func check inp$ . - for i = 1 to 8 - c = strcode substr inp$ i 1 - if c >= 48 and c <= 57 - v = c - 48 - elif c >= 65 and c <= 91 - v = c - 64 + 9 - elif c = 42 - v = 36 - elif c = 64 - v = 37 - elif c = 35 - v = 38 - . - if i mod 2 = 0 : v *= 2 - sum += v div 10 + v mod 10 - . - return if (10 - sum mod 10) mod 10 = number substr inp$ 9 1 -. -for s$ in [ "037833100" "17275R102" "38259P508" "594918104" "68389X106" "68389X105" ] - write s$ & " is " - if check s$ = 1 - print "valid" - else - print "invalid" - . -. diff --git a/Task/CUSIP/Julia/cusip.jl b/Task/CUSIP/Julia/cusip.julia similarity index 100% rename from Task/CUSIP/Julia/cusip.jl rename to Task/CUSIP/Julia/cusip.julia diff --git a/Task/CUSIP/Kotlin/cusip.kts b/Task/CUSIP/Kotlin/cusip.kotlin similarity index 100% rename from Task/CUSIP/Kotlin/cusip.kts rename to Task/CUSIP/Kotlin/cusip.kotlin diff --git a/Task/CUSIP/Langur/cusip-1.langur b/Task/CUSIP/Langur/cusip-1.langur index 69451c3430..0182e11c55 100644 --- a/Task/CUSIP/Langur/cusip-1.langur +++ b/Task/CUSIP/Langur/cusip-1.langur @@ -1,21 +1,23 @@ -val isCusip = fn(s string) { - if len(s) != 9 : return false - - val basechars = '0'..'9' ~ 'A'..'Z' ~ "*@#" - - val sum = for[=0] i of 8 { - var v = index(basechars, by=s2s(s, of=i)) - if not v: return false - v = v[1]-1 - if i div 2: v *= 2 - _for += v \ 10 + v rem 10 +val .isCusip = f(.s) { + if not isString(.s) or len(.s) != 9 { + return false } - s[9]-'0' == (10-(sum rem 10)) rem 10 + val .basechars = cp2s('0'..'9') ~ cp2s('A'..'Z') ~ "*@#" + + val .sum = for[=0] .i of 8 { + var .v = index(s2s(.s, .i), .basechars) + if not .v: return false + .v = .v[1]-1 + if .i div 2: .v x= 2 + _for += .v \ 10 + .v rem 10 + } + + .s[9]-'0' == (10-(.sum rem 10)) rem 10 } -val candidates = fw/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ +val .candidates = w/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ -for c in candidates { - writeln c, ": ", if(isCusip(c): "good" ; "bad") +for .c in .candidates { + writeln .c, ": ", if(.isCusip(.c): "good" ; "bad") } diff --git a/Task/CUSIP/Langur/cusip-2.langur b/Task/CUSIP/Langur/cusip-2.langur index ed2dd39a3f..e855068536 100644 --- a/Task/CUSIP/Langur/cusip-2.langur +++ b/Task/CUSIP/Langur/cusip-2.langur @@ -1,35 +1,37 @@ -val isCusip = fn(s string) { - if len(s) != 9 : return false +val .isCusip = f(.s) { + if not isString(.s) or len(.s) != 9 { + return false + } - val basechars = '0'..'9' ~ 'A'..'Z' ~ "*@#" + val .sum = for[=0] .i of 8 { + val .c = .s[.i] + var .v = 0 - val sum = for[=0] i of 8 { - val c = s[i] - var v = 0 - - switch[and] c { + given .c { + # for given, default op between conditions is "and" + # for switch, default op between conditions is "or" case >= '0', <= '9': - v = c-'0' + .v = .c-'0' case >= 'A', <= 'Z': - v = c-55 # c-'A'+10 + .v = .c-55 # .c-'A'+10 - case '*': v = 36 - case '@': v = 37 - case '#': v = 38 + case '*': .v = 36 + case '@': .v = 37 + case '#': .v = 38 default: return false } - if i div 2: v *= 2 - _for += v \ 10 + v rem 10 + if .i div 2: .v x= 2 + _for += .v \ 10 + .v rem 10 } - s[9]-'0' == (10-(sum rem 10)) rem 10 + .s[9]-'0' == (10-(.sum rem 10)) rem 10 } -val candidates = fw/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ +val .candidates = w/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ -for c in candidates { - writeln c, ": ", if(isCusip(c): "good" ; "bad") +for .c in .candidates { + writeln .c, ": ", if(.isCusip(.c): "good" ; "bad") } diff --git a/Task/CUSIP/Loglan82/cusip.loglan82 b/Task/CUSIP/Loglan82/cusip.loglan82 deleted file mode 100644 index 7a3a1210de..0000000000 --- a/Task/CUSIP/Loglan82/cusip.loglan82 +++ /dev/null @@ -1,89 +0,0 @@ -(* CUSIP *) - -block - - unit check_digit: function (cusip: string): integer; - var - sum, v, i_first, i_last, i: integer, - c: character, - check_needed: boolean, - ccusip: arrayof character; - begin - sum := 0; - ccusip := unpack(cusip); - i, i_first := lower(ccusip); - i_last := upper(ccusip); - check_needed := true; - while (i < i_last) and check_needed - do - c := ccusip(i); - if ord(c) >= ord('0') and ord(c) <= ord('9') - then - v := ord(c) - ord('0') - else - if ord('A') <= ord(c) and ord(c) <= ord('Z') - then - v := ord(c) - ord('A') + 10 - else - case c - when '*': v := 36; - when '@': v := 37; - when '#': v := 38; - otherwise - result := -1; - check_needed := false - esac - fi - fi; - if check_needed - then - if (i - i_first) mod 2 = 1 then v := 2 * v fi; - if i - i_first <= 7 then sum := sum + v div 10 + v mod 10 fi; - i := i + 1 - fi; - od; - if check_needed - then - if i - i_first =/= 8 - then - result := -1 - else - result := (10 - sum mod 10) mod 10 - fi; - fi; - end check_digit; - - unit is_valid: function (cusip: string): boolean; - var - check: integer, - ccusip: arrayof character; - begin - check := check_digit(cusip); - if check < 0 - then - result := false - else - ccusip := unpack(cusip); - result := ord(ccusip(lower(ccusip) + 8)) = ord('0') + check - fi; - end is_valid; - - unit write_verdict: procedure (cusip: string); - begin - if is_valid(cusip) - then - writeln(cusip, " : Valid") - else - writeln(cusip, " : Invalid") - fi - end write_verdict; - -begin - writeln("CUSIP Verdict"); - call write_verdict("037833100"); - call write_verdict("17275R102"); - call write_verdict("38259P508"); - call write_verdict("594918104"); - call write_verdict("68389X106"); - call write_verdict("68389X105"); -end; diff --git a/Task/CUSIP/MiniScript/cusip.mini b/Task/CUSIP/MiniScript/cusip.mini deleted file mode 100644 index 332bcb24f8..0000000000 --- a/Task/CUSIP/MiniScript/cusip.mini +++ /dev/null @@ -1,34 +0,0 @@ -isCusip = function(s) - if s.len != 9 then return false - sum = 0 - for i in range(0, 7) - c = s[i] - v = 0 - if c >= "0" and c <= "9" then - v = code(c) - 48 - else if c >= "A" and c <= "Z" then - v = code(c) - 55 - else if c == "*" then - v = 36 - else if c == "@" then - v = 37 - else if c == "#" then - v = 38 - else - return false - end if - if i%2 == 1 then v *= 2 // check if odd as using 0-based indexing - sum += floor(v/10) + v%10 - end for - return code(s[8]) - 48 == (10 - (sum%10)) % 10 -end function - -candidates = [ - "037833100", "17275R102", "38259P508", - "594918104", "68389X106", "68389X105", -] -for candidate in candidates - s = "valid" - if not isCusip(candidate) then s = "invalid" - print candidate + " -> " + s -end for diff --git a/Task/CUSIP/Oberon-07/cusip.oberon b/Task/CUSIP/Oberon-07/cusip.oberon deleted file mode 100644 index 23d635fd12..0000000000 --- a/Task/CUSIP/Oberon-07/cusip.oberon +++ /dev/null @@ -1,60 +0,0 @@ -MODULE Cusip; (* validate CUSIP codes *) - IMPORT Strings, Out; - - CONST cusipBase = 39; - cusipLength = 9; - VAR cusipDigits : ARRAY cusipBase + 1 OF CHAR; (* 39 digits + trailing nul *) - - (* returns TRUE if cusip is a valid CUSIP code, FALSE otherwise *) - PROCEDURE isCusip( cusip : ARRAY OF CHAR ) : BOOLEAN; - VAR sum, digit, cPos, checkDigit : INTEGER; - isValid : BOOLEAN; - - (* returns the base 39 digit corresponding to a character of a CUSIP code *) - PROCEDURE cusipDigit( cChar : CHAR ) : INTEGER; - VAR digit, dPos : INTEGER; - BEGIN - digit := -999; - dPos := 0; - WHILE ( dPos <= cusipBase ) & ( digit < 0 ) DO - IF cusipDigits[ dPos ] = cChar THEN digit := dPos END; - INC( dPos ) - END - RETURN digit - END cusipDigit ; - - BEGIN - IF Strings.Length( cusip ) # cusipLength THEN - isValid := FALSE (* invalid length code *) - ELSE - (* CUSIP code has the correct length *) - sum := 0; - checkDigit := cusipDigit( cusip[ cusipLength - 1 ] ); - FOR cPos := 0 TO cusipLength - 2 DO - digit := cusipDigit( cusip[ cPos ] ); - IF ODD( cPos ) THEN digit := digit * 2 END; - INC( sum, ( digit DIV 10 ) + ( digit MOD 10 ) ) - END; - isValid := ( 10 - ( sum MOD 10 ) ) MOD 10 = checkDigit - END - RETURN isValid - END isCusip ; - - PROCEDURE testCusip( cusip : ARRAY OF CHAR ) ; - BEGIN - Out.String( cusip ); - IF isCusip( cusip ) THEN Out.String( " valid" ) ELSE Out.String( " invalid" ) END; - Out.Ln - END testCusip; - -BEGIN - - cusipDigits := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#"; - - testCusip( "037833100" ); - testCusip( "17275R102" ); - testCusip( "38259P508" ); - testCusip( "594918104" ); - testCusip( "68389X106" ); - testCusip( "68389X105" ) -END Cusip. diff --git a/Task/CUSIP/Pascal-P/cusip.pas b/Task/CUSIP/Pascal-P/cusip.pas deleted file mode 100644 index 34d081a34a..0000000000 --- a/Task/CUSIP/Pascal-P/cusip.pas +++ /dev/null @@ -1,70 +0,0 @@ -program cusip(output); - -const - cusiplen = 9; - -type - tcusip = array [1 .. cusiplen] of char; - - function cusipcheckdigit(cusip: tcusip): integer; - (* Check digit *) - var - i, sum, v: integer; - c: char; - contcheck: boolean; (* Continue checking? *) - begin - i := 1; - sum := 0; - contcheck := true; - while (i <= cusiplen) and contcheck do - begin - c := cusip[i]; - if ('0' <= c) and (c <= '9') then v := ord(c) - 48 - else if ('A' <= c) and (c <= 'Z') then v := ord(c) - 65 + 10 - else if c = '*' then v := 36 - else if c = '@' then v := 37 - else if c = '#' then v := 38 - else - begin - cusipcheckdigit := -1; - contcheck := false; - end; - if contcheck then - begin - if (i - 1) mod 2 = 1 then v := 2 * v; - if i <= 8 then sum := sum + (v div 10) + (v mod 10); - i := i + 1; - end; - end; - if contcheck then - if i <> 10 then cusipcheckdigit := -1 - else cusipcheckdigit := (10 - (sum mod 10)) mod 10; - end; - - function isvalidcusip(cusip: tcusip): boolean; - var - check: integer; - begin - check := cusipcheckdigit(cusip); - if check < 0 then isvalidcusip := false - else isvalidcusip := (ord(cusip[9]) = ord(48 + check)); - end; - - procedure writeverdict(cusip: tcusip); - (* Write the verdict *) - begin - write(cusip); - if isvalidcusip(cusip) then writeln(' : Valid') - else writeln(' : Invalid'); - end; - -begin - writeln('CUSIP Verdict'); - writeverdict('037833100'); - writeverdict('17275R102'); - writeverdict('38259P508'); - writeverdict('594918104'); - writeverdict('68389X106'); - writeverdict('68389X105'); - (* readln; *) -end. diff --git a/Task/CUSIP/PascalABC.NET/cusip.pas b/Task/CUSIP/PascalABC.NET/cusip.pas deleted file mode 100644 index 30d756c32e..0000000000 --- a/Task/CUSIP/PascalABC.NET/cusip.pas +++ /dev/null @@ -1,32 +0,0 @@ -function IsCusip(s: string): boolean; -begin - result := false; - if (s.Length <> 9) then exit; - var sum := 0; - var v := 0; - for var i := 1 to 8 do - begin - var c := s[i]; - if c.isdigit then - v := c.todigit - else if (c >= 'A') and (c <= 'Z') then - v := ord(c) - ord('A') + 10 - else if c = '*' then - v := 36 - else if c = '@' then - v := 37 - else if c = '#' then - v := 38; - if (i mod 2) = 0 then - v := v * 2; - sum += (v div 10) + (v mod 10); - end; - var check := (10 - (sum mod 10)) mod 10; - result := s[9].todigit = check; -end; - -begin - var candidates := |'037833100', '17275R102', '38259P508', '594918104', '68389X106', '68389X105'|; - foreach var candidate in candidates do - println(candidate, if IsCusip(candidate) then 'correct' else 'incorrect'); -end. diff --git a/Task/CUSIP/Phix/cusip.phix b/Task/CUSIP/Phix/cusip.phix index e0bfdfac32..4db8980c3d 100644 --- a/Task/CUSIP/Phix/cusip.phix +++ b/Task/CUSIP/Phix/cusip.phix @@ -1,40 +1,42 @@ -sequence cch = {} +(phixonline)--> + sequence cch = {} -function CusipCheckDigit(string cusip) -integer s = 0, c, v - if length(cch)=0 then - cch = repeat(-1,256) - for i='0' to '9' do - cch[i] = i-'0' - end for - for i='A' to 'Z' do - cch[i] = i-55 - end for - cch['*'] = 36 - cch['@'] = 37 - cch['#'] = 38 - end if - if length(cusip)!=9 or find('\0',cusip) then return 0 end if - for i=1 to 8 do - c := cusip[i] - v := cch[c] - if v=-1 then return 0 end if - if remainder(i,2)=0 then - v *= 2 - end if - s += floor(v/10)+mod(v,10) - end for - return cusip[9]=mod(10-mod(s,10),10)+'0' -end function + function CusipCheckDigit(string cusip) + integer s = 0, c, v + if length(cch)=0 then + cch = repeat(-1,256) + for i='0' to '9' do + cch[i] = i-'0' + end for + for i='A' to 'Z' do + cch[i] = i-55 + end for + cch['*'] = 36 + cch['@'] = 37 + cch['#'] = 38 + end if + if length(cusip)!=9 or find('\0',cusip) then return 0 end if + for i=1 to 8 do + c := cusip[i] + v := cch[c] + if v=-1 then return 0 end if + if remainder(i,2)=0 then + v *= 2 + end if + s += floor(v/10)+mod(v,10) + end for + return cusip[9]=mod(10-mod(s,10),10)+'0' + end function -sequence tests = {"037833100", -- Apple Incorporated - "17275R102", -- Cisco Systems - "38259P508", -- Google Incorporated - "594918104", -- Microsoft Corporation - "68389X106", -- Oracle Corporation (incorrect) - "68389X105"} -- Oracle Corporation + sequence tests = {"037833100", -- Apple Incorporated + "17275R102", -- Cisco Systems + "38259P508", -- Google Incorporated + "594918104", -- Microsoft Corporation + "68389X106", -- Oracle Corporation (incorrect) + "68389X105"} -- Oracle Corporation -for i=1 to length(tests) do - string ti = tests[i] - printf(1,"%s : %s\n",{ti,{"invalid","valid"}[CusipCheckDigit(ti)+1]}) -end for + for i=1 to length(tests) do + string ti = tests[i] + printf(1,"%s : %s\n",{ti,{"invalid","valid"}[CusipCheckDigit(ti)+1]}) + end for +" & Text); + Text := crypt(Text, Key); + Ada.Text_IO.Put_Line("Ciphertext ----------->" & Text); + Ada.Text_IO.Put_Line("Decrypted Ciphertext ->" & crypt(Text, -Key)); + +end Caesar; diff --git a/Task/Caesar-cipher/Ada/caesar-cipher.adb b/Task/Caesar-cipher/Ada/caesar-cipher.adb deleted file mode 100644 index 2969e50b30..0000000000 --- a/Task/Caesar-cipher/Ada/caesar-cipher.adb +++ /dev/null @@ -1,58 +0,0 @@ --- Caesar Cipher Implementation in Ada - -with Ada.Text_IO; use Ada.Text_IO; - -procedure Caesar is - - -- Base function to encrypt a character - function Cipher(Char_To_Encrypt: Character; Shift: Integer; Base: Character) return Character is - Base_Pos : constant Natural := Character'Pos(Base); - begin - return Character'Val((Character'Pos(Char_To_Encrypt) + Shift - Base_Pos) mod 26 + Base_Pos); - end Cipher; - - -- Function to encrypt a character - function Encrypt_Char(Char_To_Encrypt: Character; Shift: Integer) return Character is - begin - case Char_To_Encrypt is - when 'A'..'Z' => - -- Encrypt uppercase letters - return Cipher (Char_To_Encrypt, Shift, 'A'); - when 'a'..'z' => - -- Encrypt lowercase letters - return Cipher (Char_To_Encrypt, Shift, 'a'); - when others => - -- Leave other characters unchanged - return Char_To_Encrypt; - end case; - end Encrypt_Char; - - -- Function to decrypt a character - function Decrypt_Char(Char_To_Decrypt: Character; Shift: Integer) return Character is - begin - return Encrypt_Char(Char_To_Decrypt, -Shift); - end Decrypt_Char; - - Message: constant String := Ada.Text_IO.Get_Line; - Shift: Positive := 3; -- Default key from "Commentarii de Bello Gallico" shift cipher - -- Shift value (can be any positive integer) - - Encrypted_Message: String(Message'Range); - Decrypted_Message: String(Message'Range); -begin - -- Encrypt the message - for I in Message'Range loop - Encrypted_Message(I) := Encrypt_Char(Message(I), Shift); - end loop; - - -- Decrypt the encrypted message - for I in Message'Range loop - Decrypted_Message(I) := Decrypt_Char(Encrypted_Message(I), Shift); - end loop; - - -- Display results - Put_Line("Plaintext: " & Message); - Put_Line("Ciphertext: " & Encrypted_Message); - Put_Line("Decrypted Ciphertext: " & Decrypted_Message); - -end Caesar; diff --git a/Task/Caesar-cipher/Arturo/caesar-cipher.arturo b/Task/Caesar-cipher/Arturo/caesar-cipher.arturo index 99de7301d6..fae4207181 100644 --- a/Task/Caesar-cipher/Arturo/caesar-cipher.arturo +++ b/Task/Caesar-cipher/Arturo/caesar-cipher.arturo @@ -1,11 +1,11 @@ -ia: to :integer 'a' -iA: to :integer 'A' -lowAZ: 'a'..'z' -uppAZ: 'A'..'Z' +ia: to :integer `a` +iA: to :integer `A` +lowAZ: `a`..`z` +uppAZ: `A`..`Z` caesar: function [s, xx][ k: (not? null? attr 'decode)? -> 26-xx -> xx - result: "" + result: new "" loop s 'i [ (in? i lowAZ)? -> 'result ++ to :char ia + (k + (to :integer i) - ia) % 26 [ diff --git a/Task/Caesar-cipher/AutoHotkey/caesar-cipher-2.ahk b/Task/Caesar-cipher/AutoHotkey/caesar-cipher-2.ahk index f7915dd6a9..f1ee9d5a1d 100644 --- a/Task/Caesar-cipher/AutoHotkey/caesar-cipher-2.ahk +++ b/Task/Caesar-cipher/AutoHotkey/caesar-cipher-2.ahk @@ -1,13 +1,13 @@ Caesar(string, n){ - Loop Parse, string - { - If (Asc(A_LoopField) >= Asc("A") and Asc(A_LoopField) <= Asc("Z")) - out .= Chr(Mod(Asc(A_LoopField)-Asc("A")+n,26)+Asc("A")) - Else If (Asc(A_LoopField) >= Asc("a") and Asc(A_LoopField) <= Asc("z")) - out .= Chr(Mod(Asc(A_LoopField)-Asc("a")+n,26)+Asc("a")) - Else out .= A_LoopField - } - return out + Loop Parse, string + { + If (Asc(A_LoopField) >= Asc("A") and Asc(A_LoopField) <= Asc("Z")) + out .= Chr(Mod(Asc(A_LoopField)-Asc("A")+n,26)+Asc("A")) + Else If (Asc(A_LoopField) >= Asc("a") and Asc(A_LoopField) <= Asc("z")) + out .= Chr(Mod(Asc(A_LoopField)-Asc("a")+n,26)+Asc("a")) + Else out .= A_LoopField + } + return out } MsgBox % Caesar("h i", 2) "`n" Caesar("Hi", 20) diff --git a/Task/Caesar-cipher/AutoIt/caesar-cipher.au3 b/Task/Caesar-cipher/AutoIt/caesar-cipher.au3 deleted file mode 100644 index 38bc2d140f..0000000000 --- a/Task/Caesar-cipher/AutoIt/caesar-cipher.au3 +++ /dev/null @@ -1,32 +0,0 @@ -$Caesar = Caesar("Hi", 2, True) -MsgBox(0, "Caesar", $Caesar) -Func Caesar($String, $int, $encrypt = True) - If Not IsNumber($int) Or Not StringIsDigit($int) Then Return SetError(1, 0, 0) - If $int < 1 Or $int > 25 Then Return SetError(2, 0, 0) - Local $sLetters, $x - $String = StringUpper($String) - $split = StringSplit($String, "") - For $i = 1 To $split[0] - If Asc($split[$i]) - 64 > 26 Or Asc($split[$i]) - 64 < 1 Then - $sLetters &= $split[$i] - ContinueLoop - EndIf - If $encrypt = True Then - $move = Asc($split[$i]) - 64 + $int - Else - $move = Asc($split[$i]) - 64 - $int - EndIf - If $move > 26 Then - $move -= 26 - ElseIf $move < 1 Then - $move += 26 - EndIf - While $move - $x = Mod($move, 26) - If $x = 0 Then $x = 26 - $sLetters &= Chr($x + 64) - $move = ($move - $x) / 26 - WEnd - Next - Return $sLetters -EndFunc ;==>Caesar diff --git a/Task/Caesar-cipher/AutoIt/caesar-cipher.autoit b/Task/Caesar-cipher/AutoIt/caesar-cipher.autoit new file mode 100644 index 0000000000..c10d78e8b2 --- /dev/null +++ b/Task/Caesar-cipher/AutoIt/caesar-cipher.autoit @@ -0,0 +1,32 @@ +$Caesar = Caesar("Hi", 2, True) +MsgBox(0, "Caesar", $Caesar) +Func Caesar($String, $int, $encrypt = True) + If Not IsNumber($int) Or Not StringIsDigit($int) Then Return SetError(1, 0, 0) + If $int < 1 Or $int > 25 Then Return SetError(2, 0, 0) + Local $sLetters, $x + $String = StringUpper($String) + $split = StringSplit($String, "") + For $i = 1 To $split[0] + If Asc($split[$i]) - 64 > 26 Or Asc($split[$i]) - 64 < 1 Then + $sLetters &= $split[$i] + ContinueLoop + EndIf + If $encrypt = True Then + $move = Asc($split[$i]) - 64 + $int + Else + $move = Asc($split[$i]) - 64 - $int + EndIf + If $move > 26 Then + $move -= 26 + ElseIf $move < 1 Then + $move += 26 + EndIf + While $move + $x = Mod($move, 26) + If $x = 0 Then $x = 26 + $sLetters &= Chr($x + 64) + $move = ($move - $x) / 26 + WEnd + Next + Return $sLetters +EndFunc ;==>Caesar diff --git a/Task/Caesar-cipher/Ballerina/caesar-cipher.ballerina b/Task/Caesar-cipher/Ballerina/caesar-cipher.ballerina deleted file mode 100644 index c0061314bf..0000000000 --- a/Task/Caesar-cipher/Ballerina/caesar-cipher.ballerina +++ /dev/null @@ -1,32 +0,0 @@ -import ballerina/io; - -function encrypt(string s, int key) returns string { - final int offset = key % 26; - if offset == 0 { return s; } - int d; - int[] chars = []; - foreach int c in s.toCodePointInts() { - if c >= 64 && c <= 90 { - d = c + offset; - if d > 90 { d -= 26; } - } else if c >= 97 && c <= 122 { - d = c + offset; - if d > 122 { d -= 26; } - } else { - d = c; - } - chars.push(d); - } - return checkpanic string:fromCodePointInts(chars); -} - -function decrypt(string s, int key) returns string { - return encrypt(s, 26 - key); -} - -public function main() { - string encoded = encrypt("Bright vixens jump; dozy fowl quack.", 8); - io:println(encoded); - string decoded = decrypt(encoded, 8); - io:println(decoded); -} diff --git a/Task/Caesar-cipher/Beads/caesar-cipher.beads b/Task/Caesar-cipher/Beads/caesar-cipher.beads index a52cddd6b2..cf30bf8193 100644 --- a/Task/Caesar-cipher/Beads/caesar-cipher.beads +++ b/Task/Caesar-cipher/Beads/caesar-cipher.beads @@ -1,33 +1,33 @@ beads 1 program 'Caesar cipher' calc main_init - var str = "The five boxing wizards (🤖) jump quickly." - log "Plain: {str}" - str = Encrypt(str, 3) - log "Encrypted: {str}" - str = Decrypt(str, 3) - log "Decrypted: {str}" + var str = "The five boxing wizards (🤖) jump quickly." + log "Plain: {str}" + str = Encrypt(str, 3) + log "Encrypted: {str}" + str = Decrypt(str, 3) + log "Decrypted: {str}" // encrypt a string by shifting the letters over by a number of slots // pass through any characters that are not in the Roman alphabet calc Encrypt( - input:str --- string to encrypt - nshift --- number of characters to slide over - ) : str --- encrypted string - - var newStr = "" - loop from:1 to:str_len(input) count:myCount - var unicode : num = from_char(subset(input, from:myCount, len:1)) - if unicode >= 65 and unicode <= 90 - unicode = mod((unicode - 65 + nshift), 26) + 65 - elif unicode >= 97 and unicode <= 122 - unicode = mod((unicode - 97 + nshift), 26) + 97 - newStr = newStr & to_char(unicode) - return newStr + input:str --- string to encrypt + nshift --- number of characters to slide over + ) : str --- encrypted string + + var newStr = "" + loop from:1 to:str_len(input) count:myCount + var unicode : num = from_char(subset(input, from:myCount, len:1)) + if unicode >= 65 and unicode <= 90 + unicode = mod((unicode - 65 + nshift), 26) + 65 + elif unicode >= 97 and unicode <= 122 + unicode = mod((unicode - 97 + nshift), 26) + 97 + newStr = newStr & to_char(unicode) + return newStr // undo the encryption calc Decrypt( - input:str - nshift - ) : str - // we could also just shift by 26-nshift, same as going in reverse - return Encrypt(input, -nshift) + input:str + nshift + ) : str + // we could also just shift by 26-nshift, same as going in reverse + return Encrypt(input, -nshift) diff --git a/Task/Caesar-cipher/C++/caesar-cipher-1.cpp b/Task/Caesar-cipher/C++/caesar-cipher-1.cpp index 561efccc0f..a896bbf42b 100644 --- a/Task/Caesar-cipher/C++/caesar-cipher-1.cpp +++ b/Task/Caesar-cipher/C++/caesar-cipher-1.cpp @@ -11,15 +11,15 @@ public : char operator( )( char c ) { if ( isspace( c ) ) - return ' ' ; + return ' ' ; else { - static std::string letters( "abcdefghijklmnopqrstuvwxyz" ) ; - std::string::size_type found = letters.find(tolower( c )) ; - int shiftedpos = ( static_cast( found ) + shift ) % 26 ; - if ( shiftedpos < 0 ) //in case of decryption possibly - shiftedpos = 26 + shiftedpos ; - char shifted = letters[shiftedpos] ; - return shifted ; + static std::string letters( "abcdefghijklmnopqrstuvwxyz" ) ; + std::string::size_type found = letters.find(tolower( c )) ; + int shiftedpos = ( static_cast( found ) + shift ) % 26 ; + if ( shiftedpos < 0 ) //in case of decryption possibly + shiftedpos = 26 + shiftedpos ; + char shifted = letters[shiftedpos] ; + return shifted ; } } } ; @@ -33,12 +33,12 @@ int main( ) { std::cin >> myshift ; std::cout << "Before encryption:\n" << input << std::endl ; std::transform ( input.begin( ) , input.end( ) , input.begin( ) , - MyTransform( myshift ) ) ; + MyTransform( myshift ) ) ; std::cout << "encrypted:\n" ; std::cout << input << std::endl ; myshift *= -1 ; //decrypting again std::transform ( input.begin( ) , input.end( ) , input.begin( ) , - MyTransform( myshift ) ) ; + MyTransform( myshift ) ) ; std::cout << "Decrypted again:\n" ; std::cout << input << std::endl ; return 0 ; diff --git a/Task/Caesar-cipher/C/caesar-cipher.c b/Task/Caesar-cipher/C/caesar-cipher.c index a1c557ead9..3d5cdffa65 100644 --- a/Task/Caesar-cipher/C/caesar-cipher.c +++ b/Task/Caesar-cipher/C/caesar-cipher.c @@ -9,7 +9,7 @@ void rot(int c, char *str) { - int l = strlen(str); + int l = strlen(str); const char* alpha_low = "abcdefghijklmnopqrstuvwxyz"; @@ -21,32 +21,32 @@ void rot(int c, char *str) int i; /* loop var */ - for (i = 0; i < l; i++) /* for each letter in string */ - { - if( 0 == isalpha(str[i]) ) continue; /* not alphabet character */ + for (i = 0; i < l; i++) /* for each letter in string */ + { + if( 0 == isalpha(str[i]) ) continue; /* not alphabet character */ idx = (int) (tolower(str[i]) - 'a') + c) % 26; /* compute index */ - if( isupper(str[i]) ) + if( isupper(str[i]) ) subst = alpha_high[idx]; else subst = alpha_low[idx]; str[i] = subst; - } + } } int main(int argc, char** argv) { - char str[] = "This is a top secret text message!"; - - printf("Original: %s\n", str); - caesar(str); - printf("Encrypted: %s\n", str); - decaesar(str); - printf("Decrypted: %s\n", str); - - return 0; + char str[] = "This is a top secret text message!"; + + printf("Original: %s\n", str); + caesar(str); + printf("Encrypted: %s\n", str); + decaesar(str); + printf("Decrypted: %s\n", str); + + return 0; } diff --git a/Task/Caesar-cipher/COBOL/caesar-cipher-1.cob b/Task/Caesar-cipher/COBOL/caesar-cipher-1.cob deleted file mode 100644 index 02c1bfd4bd..0000000000 --- a/Task/Caesar-cipher/COBOL/caesar-cipher-1.cob +++ /dev/null @@ -1,36 +0,0 @@ - IDENTIFICATION DIVISION. - PROGRAM-ID. CAESAR. - - DATA DIVISION. - WORKING-STORAGE SECTION. - 01 MSG PIC X(50) - VALUE "The quick brown fox jumped over the lazy dog.". - 01 OFFSET PIC 9(4) VALUE 7 USAGE BINARY. - 01 FROM-CHARS PIC X(52). - 01 TO-CHARS PIC X(52). - 01 TABL. - 02 PIC X(26) VALUE "abcdefghijklmnopqrstuvwxyz". - 02 PIC X(26) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ". - 02 PIC X(26) VALUE "abcdefghijklmnopqrstuvwxyz". - 02 PIC X(26) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ". - - PROCEDURE DIVISION. - BEGIN. - DISPLAY MSG - PERFORM ENCRYPT - DISPLAY MSG - PERFORM DECRYPT - DISPLAY MSG - STOP RUN. - - ENCRYPT. - MOVE TABL (1:52) TO FROM-CHARS - MOVE TABL (1 + OFFSET:52) TO TO-CHARS - INSPECT MSG CONVERTING FROM-CHARS TO TO-CHARS. - - DECRYPT. - MOVE TABL (1 + OFFSET:52) TO FROM-CHARS - MOVE TABL (1:52) TO TO-CHARS - INSPECT MSG CONVERTING FROM-CHARS TO TO-CHARS. - - END PROGRAM CAESAR. diff --git a/Task/Caesar-cipher/COBOL/caesar-cipher-1.cobol b/Task/Caesar-cipher/COBOL/caesar-cipher-1.cobol new file mode 100644 index 0000000000..af62e5229c --- /dev/null +++ b/Task/Caesar-cipher/COBOL/caesar-cipher-1.cobol @@ -0,0 +1,37 @@ + identification division. + program-id. caesar. + data division. + 1 msg pic x(50) + value "The quick brown fox jumped over the lazy dog.". + 1 offset binary pic 9(4) value 7. + 1 from-chars pic x(52). + 1 to-chars pic x(52). + 1 tabl. + 2 pic x(26) value "abcdefghijklmnopqrstuvwxyz". + 2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ". + 2 pic x(26) value "abcdefghijklmnopqrstuvwxyz". + 2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ". + procedure division. + begin. + display msg + perform encrypt + display msg + perform decrypt + display msg + stop run + . + + encrypt. + move tabl (1:52) to from-chars + move tabl (1 + offset:52) to to-chars + inspect msg converting from-chars + to to-chars + . + + decrypt. + move tabl (1 + offset:52) to from-chars + move tabl (1:52) to to-chars + inspect msg converting from-chars + to to-chars + . + end program caesar. diff --git a/Task/Caesar-cipher/COBOL/caesar-cipher-2.cob b/Task/Caesar-cipher/COBOL/caesar-cipher-2.cob deleted file mode 100644 index 20f86ddb95..0000000000 --- a/Task/Caesar-cipher/COBOL/caesar-cipher-2.cob +++ /dev/null @@ -1,84 +0,0 @@ - >>SOURCE FORMAT IS FREE -IDENTIFICATION DIVISION. -PROGRAM-ID. caesar-cipher. - -ENVIRONMENT DIVISION. -CONFIGURATION SECTION. -REPOSITORY. - FUNCTION encrypt - FUNCTION decrypt. - -DATA DIVISION. -WORKING-STORAGE SECTION. -01 plaintext PIC X(50). -01 offset USAGE BINARY-CHAR. -01 encrypted-str PIC X(50). - -PROCEDURE DIVISION. - DISPLAY "Enter a message to encrypt: " WITH NO ADVANCING - ACCEPT plaintext - DISPLAY "Enter the amount to shift by: " WITH NO ADVANCING - ACCEPT offset - MOVE encrypt(offset, plaintext) TO encrypted-str - DISPLAY "Encrypted: " encrypted-str - DISPLAY "Decrypted: " decrypt(offset, encrypted-str). - -END PROGRAM caesar-cipher. - -IDENTIFICATION DIVISION. -FUNCTION-ID. encrypt. - -ENVIRONMENT DIVISION. -CONFIGURATION SECTION. -REPOSITORY. - FUNCTION ALL INTRINSIC. - -DATA DIVISION. -LOCAL-STORAGE SECTION. -01 i USAGE INDEX. -01 a USAGE BINARY-CHAR. -LINKAGE SECTION. -01 offset USAGE BINARY-CHAR. -01 str PIC X(50). -01 encrypted-str PIC X(50). - -PROCEDURE DIVISION USING offset, str RETURNING encrypted-str. - PERFORM VARYING i FROM 1 BY 1 UNTIL i > LENGTH(str) - IF str(i:1) IS NOT ALPHABETIC OR str(i:1) = SPACE - MOVE str(i:1) TO encrypted-str(i:1) - EXIT PERFORM CYCLE - END-IF - IF str(i:1) IS ALPHABETIC-UPPER - MOVE ORD("A") TO a - ELSE - MOVE ORD("a") TO a - END-IF - MOVE CHAR(MOD(ORD(str(i:1)) - a + offset, 26) + a) - TO encrypted-str(i:1) - END-PERFORM - EXIT FUNCTION. - -END FUNCTION encrypt. - -IDENTIFICATION DIVISION. -FUNCTION-ID. decrypt. - -ENVIRONMENT DIVISION. -CONFIGURATION SECTION. -REPOSITORY. - FUNCTION encrypt. - -DATA DIVISION. -LOCAL-STORAGE SECTION. -01 decrypt-offset USAGE BINARY-CHAR. -LINKAGE SECTION. -01 offset USAGE BINARY-CHAR. -01 str PIC X(50). -01 decrypted-str PIC X(50). - -PROCEDURE DIVISION USING offset, str RETURNING decrypted-str. - SUBTRACT offset FROM 26 GIVING decrypt-offset - MOVE encrypt(decrypt-offset, str) TO decrypted-str - EXIT FUNCTION. - -END FUNCTION decrypt. diff --git a/Task/Caesar-cipher/COBOL/caesar-cipher-2.cobol b/Task/Caesar-cipher/COBOL/caesar-cipher-2.cobol new file mode 100644 index 0000000000..e287e5b7aa --- /dev/null +++ b/Task/Caesar-cipher/COBOL/caesar-cipher-2.cobol @@ -0,0 +1,86 @@ + >>SOURCE FORMAT IS FREE +PROGRAM-ID. caesar-cipher. + +ENVIRONMENT DIVISION. +CONFIGURATION SECTION. +REPOSITORY. + FUNCTION encrypt + FUNCTION decrypt + . +DATA DIVISION. +WORKING-STORAGE SECTION. +01 plaintext PIC X(50). +01 offset PIC 99. + +01 encrypted-str PIC X(50). + +PROCEDURE DIVISION. + DISPLAY "Enter a message to encrypt: " NO ADVANCING + ACCEPT plaintext + DISPLAY "Enter the amount to shift by: " NO ADVANCING + ACCEPT offset + + MOVE FUNCTION encrypt(offset, plaintext) TO encrypted-str + DISPLAY "Encrypted: " encrypted-str + DISPLAY "Decrypted: " FUNCTION decrypt(offset, encrypted-str) + . +END PROGRAM caesar-cipher. + + +FUNCTION-ID. encrypt. + +DATA DIVISION. +LOCAL-STORAGE SECTION. +01 i PIC 9(3). + +01 a PIC 9(3). + +LINKAGE SECTION. +01 offset PIC 99. +01 str PIC X(50). + +01 encrypted-str PIC X(50). + +PROCEDURE DIVISION USING offset, str RETURNING encrypted-str. + MOVE str TO encrypted-str + PERFORM VARYING i FROM 1 BY 1 UNTIL i > FUNCTION LENGTH(str) + IF encrypted-str (i:1) IS NOT ALPHABETIC OR encrypted-str (i:1) = SPACE + EXIT PERFORM CYCLE + END-IF + + IF encrypted-str (i:1) IS ALPHABETIC-UPPER + MOVE FUNCTION ORD("A") TO a + ELSE + MOVE FUNCTION ORD("a") TO a + END-IF + + MOVE FUNCTION CHAR(FUNCTION MOD(FUNCTION ORD(encrypted-str (i:1)) + - a + offset, 26) + a) + TO encrypted-str (i:1) + END-PERFORM + . +END FUNCTION encrypt. + + +FUNCTION-ID. decrypt. + +ENVIRONMENT DIVISION. +CONFIGURATION SECTION. +REPOSITORY. + FUNCTION encrypt + . +DATA DIVISION. +LOCAL-STORAGE SECTION. +01 decrypt-offset PIC 99. + +LINKAGE SECTION. +01 offset PIC 99. +01 str PIC X(50). + +01 decrypted-str PIC X(50). + +PROCEDURE DIVISION USING offset, str RETURNING decrypted-str. + SUBTRACT 26 FROM offset GIVING decrypt-offset + MOVE FUNCTION encrypt(decrypt-offset, str) TO decrypted-str + . +END FUNCTION decrypt. diff --git a/Task/Caesar-cipher/Clojure/caesar-cipher-3.clj b/Task/Caesar-cipher/Clojure/caesar-cipher-3.clj deleted file mode 100644 index d6436b49b6..0000000000 --- a/Task/Caesar-cipher/Clojure/caesar-cipher-3.clj +++ /dev/null @@ -1,7 +0,0 @@ -(defn fast-caesar [n s] - (let [m (mod n 26) - upper (map char (range 65 91)) - upper->new (zipmap upper (drop m (cycle upper))) - lower (map char (range 97 123)) - lower->new (zipmap lower (drop m (cycle lower)))] - (clojure.string/escape s (merge upper->new lower->new)))) diff --git a/Task/Caesar-cipher/Crystal/caesar-cipher.cr b/Task/Caesar-cipher/Crystal/caesar-cipher.crystal similarity index 100% rename from Task/Caesar-cipher/Crystal/caesar-cipher.cr rename to Task/Caesar-cipher/Crystal/caesar-cipher.crystal diff --git a/Task/Caesar-cipher/Cubescript/caesar-cipher-1.cube b/Task/Caesar-cipher/Cubescript/caesar-cipher-1.cube index cb7ede7b2e..1d272423ca 100644 --- a/Task/Caesar-cipher/Cubescript/caesar-cipher-1.cube +++ b/Task/Caesar-cipher/Cubescript/caesar-cipher-1.cube @@ -2,57 +2,57 @@ alias modn [ mod (+ (mod $arg1 $arg2) $arg2) $arg2 ] //Cubescript's built-in mod will fail on negative numbers alias cipher [ - push alpha [ - "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" - "a b c d e f g h i j k l m n o p q r s t u v w x y z" - ] [ push chars [] [ - loop i (strlen $arg1) [ - looplist n $alpha [ - if (! (listlen $chars)) [ - alias chars (? (> (listindex $n (substr $arg1 $i 1)) -1) $n []) - ] - ] - alias arg1 ( - concatword (substr $arg1 0 $i) ( - ? (> (listindex $chars (substr $arg1 $i 1)) -1) ( - at $chars ( - modn (+ ( - listindex $chars (substr $arg1 $i 1) - ) $arg2) (listlen $chars) - ) - ) (substr $arg1 $i 1) - ) (substr $arg1 (+ $i 1) (strlen $arg1)) - ) - alias chars [] - ] - ] ] - result $arg1 + push alpha [ + "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" + "a b c d e f g h i j k l m n o p q r s t u v w x y z" + ] [ push chars [] [ + loop i (strlen $arg1) [ + looplist n $alpha [ + if (! (listlen $chars)) [ + alias chars (? (> (listindex $n (substr $arg1 $i 1)) -1) $n []) + ] + ] + alias arg1 ( + concatword (substr $arg1 0 $i) ( + ? (> (listindex $chars (substr $arg1 $i 1)) -1) ( + at $chars ( + modn (+ ( + listindex $chars (substr $arg1 $i 1) + ) $arg2) (listlen $chars) + ) + ) (substr $arg1 $i 1) + ) (substr $arg1 (+ $i 1) (strlen $arg1)) + ) + alias chars [] + ] + ] ] + result $arg1 ] alias decipher [ - push alpha [ - "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" - "a b c d e f g h i j k l m n o p q r s t u v w x y z" - ] [ push chars [] [ - loop i (strlen $arg1) [ - looplist n $alpha [ - if (! (listlen $chars)) [ - alias chars (? (> (listindex $n (substr $arg1 $i 1)) -1) $n []) - ] - ] - alias arg1 ( - concatword (substr $arg1 0 $i) ( - ? (> (listindex $chars (substr $arg1 $i 1)) -1) ( - at $chars ( - modn (- ( - listindex $chars (substr $arg1 $i 1) - ) $arg2 ) (listlen $chars) - ) - ) (substr $arg1 $i 1) - ) (substr $arg1 (+ $i 1) (strlen $arg1)) - ) - alias chars [] - ] - ] ] - result $arg1 + push alpha [ + "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" + "a b c d e f g h i j k l m n o p q r s t u v w x y z" + ] [ push chars [] [ + loop i (strlen $arg1) [ + looplist n $alpha [ + if (! (listlen $chars)) [ + alias chars (? (> (listindex $n (substr $arg1 $i 1)) -1) $n []) + ] + ] + alias arg1 ( + concatword (substr $arg1 0 $i) ( + ? (> (listindex $chars (substr $arg1 $i 1)) -1) ( + at $chars ( + modn (- ( + listindex $chars (substr $arg1 $i 1) + ) $arg2 ) (listlen $chars) + ) + ) (substr $arg1 $i 1) + ) (substr $arg1 (+ $i 1) (strlen $arg1)) + ) + alias chars [] + ] + ] ] + result $arg1 ] diff --git a/Task/Caesar-cipher/EasyLang/caesar-cipher.easy b/Task/Caesar-cipher/EasyLang/caesar-cipher.easy deleted file mode 100644 index 8fe83e93e8..0000000000 --- a/Task/Caesar-cipher/EasyLang/caesar-cipher.easy +++ /dev/null @@ -1,15 +0,0 @@ -func$ crypt str$ key . - for c$ in strchars str$ - c = strcode c$ - if c >= 65 and c <= 90 - c = (c + key - 65) mod 26 + 65 - elif c >= 97 and c <= 122 - c = (c + key - 97) mod 26 + 97 - . - enc$ &= strchar c - . - return enc$ -. -enc$ = crypt "Rosetta Code" 4 -print enc$ -print crypt enc$ -4 diff --git a/Task/Caesar-cipher/Eiffel/caesar-cipher.e b/Task/Caesar-cipher/Eiffel/caesar-cipher.e index 685702644b..05b947e03d 100644 --- a/Task/Caesar-cipher/Eiffel/caesar-cipher.e +++ b/Task/Caesar-cipher/Eiffel/caesar-cipher.e @@ -1,53 +1,53 @@ class - APPLICATION + APPLICATION inherit - ARGUMENTS + ARGUMENTS create - make + make feature {NONE} -- Initialization - make - -- Run application. - local - s: STRING_32 - do - s := "The tiny tiger totally taunted the tall Till." - print ("%NString to encode: " + s) - print ("%NEncoded string: " + encode (s, 12)) - print ("%NDecoded string (after encoding and decoding): " + decode (encode (s, 12), 12)) - end + make + -- Run application. + local + s: STRING_32 + do + s := "The tiny tiger totally taunted the tall Till." + print ("%NString to encode: " + s) + print ("%NEncoded string: " + encode (s, 12)) + print ("%NDecoded string (after encoding and decoding): " + decode (encode (s, 12), 12)) + end -feature -- Basic operations +feature -- Basic operations - decode (to_be_decoded: STRING_32; offset: INTEGER): STRING_32 - -- Decode `to be decoded' according to `offset'. - do - Result := encode (to_be_decoded, 26 - offset) - end + decode (to_be_decoded: STRING_32; offset: INTEGER): STRING_32 + -- Decode `to be decoded' according to `offset'. + do + Result := encode (to_be_decoded, 26 - offset) + end - encode (to_be_encoded: STRING_32; offset: INTEGER): STRING_32 - -- Encode `to be encoded' according to `offset'. - local - l_offset: INTEGER - l_char_code: INTEGER - do - create Result.make_empty - l_offset := (offset \\ 26) + 26 - across to_be_encoded as tbe loop - if tbe.item.is_alpha then - if tbe.item.is_upper then - l_char_code := ('A').code + (tbe.item.code - ('A').code + l_offset) \\ 26 - Result.append_character (l_char_code.to_character_32) - else - l_char_code := ('a').code + (tbe.item.code - ('a').code + l_offset) \\ 26 - Result.append_character (l_char_code.to_character_32) - end - else - Result.append_character (tbe.item) - end - end - end + encode (to_be_encoded: STRING_32; offset: INTEGER): STRING_32 + -- Encode `to be encoded' according to `offset'. + local + l_offset: INTEGER + l_char_code: INTEGER + do + create Result.make_empty + l_offset := (offset \\ 26) + 26 + across to_be_encoded as tbe loop + if tbe.item.is_alpha then + if tbe.item.is_upper then + l_char_code := ('A').code + (tbe.item.code - ('A').code + l_offset) \\ 26 + Result.append_character (l_char_code.to_character_32) + else + l_char_code := ('a').code + (tbe.item.code - ('a').code + l_offset) \\ 26 + Result.append_character (l_char_code.to_character_32) + end + else + Result.append_character (tbe.item) + end + end + end end diff --git a/Task/Caesar-cipher/Elena/caesar-cipher.elena b/Task/Caesar-cipher/Elena/caesar-cipher.elena index 1565b7d1f0..b87575f5f6 100644 --- a/Task/Caesar-cipher/Elena/caesar-cipher.elena +++ b/Task/Caesar-cipher/Elena/caesar-cipher.elena @@ -10,37 +10,37 @@ const int Key = 12; class Encrypting : Enumerator { - int _key; - Enumerator _enumerator; + int theKey; + Enumerator theEnumerator; constructor(int key, string text) { - _key := key; - _enumerator := text.enumerator(); + theKey := key; + theEnumerator := text.enumerator(); } - bool next() => _enumerator; + bool next() => theEnumerator; - reset() => _enumerator; + reset() => theEnumerator; - enumerable() => _enumerator; + enumerable() => theEnumerator; - get Value() + get() { - var ch := *_enumerator; + var ch := theEnumerator.get(); var index := Letters.indexOf(0, ch); if (-1 < index) { - ^ Letters[(_key+index).mod(26)] + ^ Letters[(theKey+index).mod:26] } else { index := BigLetters.indexOf(0, ch); if (-1 < index) { - ^ BigLetters[(_key+index).mod(26)] + ^ BigLetters[(theKey+index).mod:26] } else { @@ -59,17 +59,17 @@ extension encryptOp = new Encrypting(26 - key, self).summarize(new StringWriter()); } -public Program() +public program() { - Console.printLine("Original text :",TestText); + console.printLine("Original text :",TestText); - var encryptedText := TestText.encrypt(Key); + var encryptedText := TestText.encrypt:Key; - Console.printLine("Encrypted text:",encryptedText); + console.printLine("Encrypted text:",encryptedText); - var decryptedText := encryptedText.decrypt(Key); + var decryptedText := encryptedText.decrypt:Key; - Console.printLine("Decrypted text:",decryptedText); + console.printLine("Decrypted text:",decryptedText); - Console.readChar() + console.readChar() } diff --git a/Task/Caesar-cipher/Elixir/caesar-cipher.ex b/Task/Caesar-cipher/Elixir/caesar-cipher.elixir similarity index 100% rename from Task/Caesar-cipher/Elixir/caesar-cipher.ex rename to Task/Caesar-cipher/Elixir/caesar-cipher.elixir diff --git a/Task/Caesar-cipher/Elm/caesar-cipher.elm b/Task/Caesar-cipher/Elm/caesar-cipher.elm deleted file mode 100644 index b4a7c073f9..0000000000 --- a/Task/Caesar-cipher/Elm/caesar-cipher.elm +++ /dev/null @@ -1,88 +0,0 @@ -module Main exposing (main) - -import Browser -import Html exposing (Html, h2, div, p, input, button, text, textarea) -import Html.Attributes exposing (style, class, placeholder, value) -import Html.Events exposing (onInput, onClick) - - --- MAIN - -main = - Browser.sandbox { init = init, update = update, view = view } - - --- MODEL - -type alias Model = - { codeKey : Int - , normtext : String - } - - -init : Model -init = - { codeKey = 3 - , normtext = "" } - - --- UPDATE - -type Msg - = Change String - | DecKey - | IncKey - - -update : Msg -> Model -> Model -update msg model = - case msg of - DecKey -> - { model | codeKey = model.codeKey - 1} - IncKey -> - { model | codeKey = model.codeKey + 1} - Change newContent -> - { model | normtext = String.toUpper newContent } - - - -encodeChar : Int -> Char -> Char -encodeChar codeKey character = - if Char.isUpper character then - Char.fromCode (modBy 26 (Char.toCode character - 65 + codeKey) + 65) - - else if Char.isLower character then - Char.fromCode (modBy 26 (Char.toCode (Char.toUpper character) - 65 + codeKey) + 65) - - else - character - - -encodeText : Int -> String -> String -encodeText codeKey normtext = - String.map (encodeChar codeKey) normtext - - -subheads aKey = - if aKey > 0 then "Original" - else if aKey < 0 then "Encrypted text" - else "?" - --- VIEW - -view : Model -> Html Msg -view model = - div [] - [ div [] - [h2 [class "h2style"] [text (subheads model.codeKey)] - , textarea [ class "textframe", placeholder "Write here your text!" - , value model.normtext, onInput Change ] [] - ] - , div [] - [h2 [class "h2style"] [text (subheads (negate model.codeKey))] - , textarea [ class "textframe", value (encodeText model.codeKey model.normtext) ] []] - , div [class "keystyle"] [ button [ class "butstyle", onClick DecKey ] [ text "-1" ] - , text (" Key " ++ String.fromInt model.codeKey) - , button [ class "butstyle", onClick IncKey ] [ text "+1" ] - ] - ] diff --git a/Task/Caesar-cipher/Euphoria/caesar-cipher.eu b/Task/Caesar-cipher/Euphoria/caesar-cipher.eu deleted file mode 100644 index f7ca288339..0000000000 --- a/Task/Caesar-cipher/Euphoria/caesar-cipher.eu +++ /dev/null @@ -1,54 +0,0 @@ ---caesar cipher for Rosetta Code wiki ---User:Lnettnay - ---usage eui caesar ->default text, key and encode flag ---usage eui caesar 'Text with spaces and punctuation!' 5 D ---If text has imbedded spaces must use apostophes instead of quotes so all punctuation works ---key = integer from 1 to 25, defaults to 13 ---flag = E (Encode) or D (Decode), defaults to E ---no error checking is done on key or flag - -include std/get.e -include std/types.e - - -sequence cmd = command_line() -sequence val --- default text for encryption -sequence text = "The Quick Brown Fox Jumps Over The Lazy Dog." -atom key = 13 -- default to Rot-13 -sequence flag = "E" -- default to Encrypt -atom offset -atom num_letters = 26 -- number of characters in alphabet - ---get text -if length(cmd) >= 3 then - text = cmd[3] -end if - ---get key value -if length(cmd) >= 4 then - val = value(cmd[4]) - key = val[2] -end if - ---get Encrypt/Decrypt flag -if length(cmd) = 5 then - flag = cmd[5] - if compare(flag, "D") = 0 then - key = 26 - key - end if -end if - -for i = 1 to length(text) do - if t_alpha(text[i]) then - if t_lower(text[i]) then - offset = 'a' - else - offset = 'A' - end if - text[i] = remainder(text[i] - offset + key, num_letters) + offset - end if -end for - -printf(1,"%s\n",{text}) diff --git a/Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria b/Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria new file mode 100644 index 0000000000..939241f9f7 --- /dev/null +++ b/Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria @@ -0,0 +1,54 @@ +--caesar cipher for Rosetta Code wiki +--User:Lnettnay + +--usage eui caesar ->default text, key and encode flag +--usage eui caesar 'Text with spaces and punctuation!' 5 D +--If text has imbedded spaces must use apostophes instead of quotes so all punctuation works +--key = integer from 1 to 25, defaults to 13 +--flag = E (Encode) or D (Decode), defaults to E +--no error checking is done on key or flag + +include std/get.e +include std/types.e + + +sequence cmd = command_line() +sequence val +-- default text for encryption +sequence text = "The Quick Brown Fox Jumps Over The Lazy Dog." +atom key = 13 -- default to Rot-13 +sequence flag = "E" -- default to Encrypt +atom offset +atom num_letters = 26 -- number of characters in alphabet + +--get text +if length(cmd) >= 3 then + text = cmd[3] +end if + +--get key value +if length(cmd) >= 4 then + val = value(cmd[4]) + key = val[2] +end if + +--get Encrypt/Decrypt flag +if length(cmd) = 5 then + flag = cmd[5] + if compare(flag, "D") = 0 then + key = 26 - key + end if +end if + +for i = 1 to length(text) do + if t_alpha(text[i]) then + if t_lower(text[i]) then + offset = 'a' + else + offset = 'A' + end if + text[i] = remainder(text[i] - offset + key, num_letters) + offset + end if +end for + +printf(1,"%s\n",{text}) diff --git a/Task/Caesar-cipher/Fhidwfe/caesar-cipher.fhidwfe b/Task/Caesar-cipher/Fhidwfe/caesar-cipher.fhidwfe index 099eb3b7af..29eb95324a 100644 --- a/Task/Caesar-cipher/Fhidwfe/caesar-cipher.fhidwfe +++ b/Task/Caesar-cipher/Fhidwfe/caesar-cipher.fhidwfe @@ -8,7 +8,7 @@ function void caesar_encode(message:ptr key:uint) { temp = + temp key// shift lowercase letters if > temp 'z' { temp = - temp 26ub - } ; + } ; } { if in temp uppers { temp = + temp key// shift uppercase letters diff --git a/Task/Caesar-cipher/Forth/caesar-cipher.fth b/Task/Caesar-cipher/Forth/caesar-cipher.fth index ba76eb1619..e92410572f 100644 --- a/Task/Caesar-cipher/Forth/caesar-cipher.fth +++ b/Task/Caesar-cipher/Forth/caesar-cipher.fth @@ -1,19 +1,19 @@ -: caesar ( c n -- c ) +: ceasar ( c n -- c ) over 32 or [char] a - dup 0 26 within if over + 25 > if 26 - then + else 2drop then ; -: caesar-string ( n str len -- ) - over + swap do i c@ over caesar i c! loop drop ; +: ceasar-string ( n str len -- ) + over + swap do i c@ over ceasar i c! loop drop ; -: caesar-inverse ( n -- 'n ) 26 swap - 26 mod ; +: ceasar-inverse ( n -- 'n ) 26 swap - 26 mod ; 2variable test s" The five boxing wizards jump quickly!" test 2! -3 test 2@ caesar-string +3 test 2@ ceasar-string test 2@ cr type -3 caesar-inverse test 2@ caesar-string +3 ceasar-inverse test 2@ ceasar-string test 2@ cr type diff --git a/Task/Caesar-cipher/FutureBasic/caesar-cipher.basic b/Task/Caesar-cipher/FutureBasic/caesar-cipher.basic deleted file mode 100644 index d76978d854..0000000000 --- a/Task/Caesar-cipher/FutureBasic/caesar-cipher.basic +++ /dev/null @@ -1,42 +0,0 @@ -CFStringRef local fn Encrypt( s as CFStringRef, key as int ) - CFMutableStringRef s1 = fn MutableStringWithString(s) - for int i = 0 to len(s1) - 1 - unichar c = ucc(s1,i) - select - case ( c >= _"A" && c <= _"Z") - c += key : if ( c > _"Z" ) then c -= 26 - case ( c >= _"a" && c <= _"z" ) - c += key : if ( c > _"z" ) then c -= 26 - end select - mid(s1,i,1) = ucs(c) - next -end fn = s1 - -CFStringRef local fn Decrypt( s as CFStringRef, key as int ) - CFMutableStringRef s1 = fn MutableStringWithString(s) - for int i = 0 to len(s1) - 1 - unichar c = ucc(s1,i) - select - case ( c >= _"A" && c <= _"Z") - c -= key : if ( c < _"A" ) then c += 26 - case ( c >= _"a" && c <= _"z" ) - c -= key : if ( c < _"a" ) then c += 26 - end select - mid(s1,i,1) = ucs(c) - next -end fn = s1 - -void local fn DoIt - CFStringRef s = @"The sun's not yellow, it's chicken" - print s - - s = fn Encrypt( s, 6 ) - print s - - s = fn Decrypt( s, 6 ) - print s -end fn - -fn DoIt - -HandleEvents diff --git a/Task/Caesar-cipher/GAP/caesar-cipher.gap b/Task/Caesar-cipher/GAP/caesar-cipher.gap index 87c53d8859..0a3b660ca3 100644 --- a/Task/Caesar-cipher/GAP/caesar-cipher.gap +++ b/Task/Caesar-cipher/GAP/caesar-cipher.gap @@ -1,22 +1,22 @@ CaesarCipher := function(s, n) - local r, c, i, lower, upper; - lower := "abcdefghijklmnopqrstuvwxyz"; - upper := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - r := ""; - for c in s do - i := Position(lower, c); - if i <> fail then - Add(r, lower[RemInt(i + n - 1, 26) + 1]); - else - i := Position(upper, c); - if i <> fail then - Add(r, upper[RemInt(i + n - 1, 26) + 1]); - else - Add(r, c); - fi; - fi; - od; - return r; + local r, c, i, lower, upper; + lower := "abcdefghijklmnopqrstuvwxyz"; + upper := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + r := ""; + for c in s do + i := Position(lower, c); + if i <> fail then + Add(r, lower[RemInt(i + n - 1, 26) + 1]); + else + i := Position(upper, c); + if i <> fail then + Add(r, upper[RemInt(i + n - 1, 26) + 1]); + else + Add(r, c); + fi; + fi; + od; + return r; end; CaesarCipher("IBM", 25); diff --git a/Task/Caesar-cipher/GW-BASIC/caesar-cipher.basic b/Task/Caesar-cipher/GW-BASIC/caesar-cipher.basic deleted file mode 100644 index e1601d38fa..0000000000 --- a/Task/Caesar-cipher/GW-BASIC/caesar-cipher.basic +++ /dev/null @@ -1,16 +0,0 @@ -10 REM Caesar cipher -20 CLS -30 DEC$ = "" -40 TYPE$ = "cleartext " -50 PRINT "If decrypting enter "+" "+" -- else press enter "; : INPUT DEC$ -60 INPUT "Enter offset > "; IOFFSET -70 IF DEC$ = "d" THEN IOFFSET = 26-IOFFSET: TYPE$ = "ciphertext " -110 PRINT "Enter "+TYPE$+"> "; -120 INPUT CAD$ -140 LONGITUD = LEN(CAD$) -150 FOR I = 1 TO LONGITUD -160 ITEMP = ASC(MID$(CAD$,I,1)) -170 IF ITEMP > 64 AND ITEMP < 91 THEN ITEMP = ((ITEMP-65)+IOFFSET) MOD 26 : PRINT CHR$(ITEMP+65); : ELSE PRINT CHR$(ITEMP); -230 NEXT I -240 PRINT -250 END diff --git a/Task/Caesar-cipher/Icon/caesar-cipher-2.icon b/Task/Caesar-cipher/Icon/caesar-cipher-2.icon deleted file mode 100644 index a8ccbb7d25..0000000000 --- a/Task/Caesar-cipher/Icon/caesar-cipher-2.icon +++ /dev/null @@ -1,12 +0,0 @@ -(function caeser by of - (let alphabets (proj (map char-code) (range 65 91) (range 97 123)) - shifted (.. vec (map (rotate by) alphabets)) - table (kv-dict (flatten alphabets) (flatten shifted))) - (... str (map #(or (table %) %) of))) - -(let original "The Quick Brown Fox Jumps Over The Lazy Dog." - encrypted (caeser -1 original) - decrypted (caeser 1 encrypted)) -"Original: {original} -Encrypted: {encrypted} -Decrypted: {decrypted}" diff --git a/Task/Caesar-cipher/Icon/caesar-cipher-1.icon b/Task/Caesar-cipher/Icon/caesar-cipher.icon similarity index 100% rename from Task/Caesar-cipher/Icon/caesar-cipher-1.icon rename to Task/Caesar-cipher/Icon/caesar-cipher.icon diff --git a/Task/Caesar-cipher/JavaScript/caesar-cipher-1.js b/Task/Caesar-cipher/JavaScript/caesar-cipher-1.js index 88ee6f5baf..44f68eb7d2 100644 --- a/Task/Caesar-cipher/JavaScript/caesar-cipher-1.js +++ b/Task/Caesar-cipher/JavaScript/caesar-cipher-1.js @@ -1,6 +1,6 @@ function caesar (text, shift) { return text.toUpperCase().replace(/[^A-Z]/g,'').replace(/./g, function(a) { - return String.fromCharCode(((a.charCodeAt(0) - 65 + shift) % 26 + 26) % 26 + 65); + return String.fromCharCode(65+(a.charCodeAt(0)-65+shift)%26); }); } diff --git a/Task/Caesar-cipher/JavaScript/caesar-cipher-2.js b/Task/Caesar-cipher/JavaScript/caesar-cipher-2.js index f2a3cc1a6b..3d30b7a5ac 100644 --- a/Task/Caesar-cipher/JavaScript/caesar-cipher-2.js +++ b/Task/Caesar-cipher/JavaScript/caesar-cipher-2.js @@ -2,4 +2,4 @@ var caesar = (text, shift) => text .toUpperCase() .replace(/[^A-Z]/g, '') .replace(/./g, a => - String.fromCharCode(((a.charCodeAt(0) - 65 + shift) % 26 + 26) % 26 + 65)); + String.fromCharCode(65 + (a.charCodeAt(0) - 65 + shift) % 26)); diff --git a/Task/Caesar-cipher/Jq/caesar-cipher.jq b/Task/Caesar-cipher/Jq/caesar-cipher.jq index 00df4895b4..7bf6d7b4ec 100644 --- a/Task/Caesar-cipher/Jq/caesar-cipher.jq +++ b/Task/Caesar-cipher/Jq/caesar-cipher.jq @@ -12,11 +12,11 @@ def encrypt(key): else if ($c >= 97 and $c <= 122) # 'a' to 'z' then .d = $c + $offset | if (.d > 122) - then .d += -26 - else . - end - else . - end + then .d += -26 + else . + end + else . + end end | .chars[$i] = .d ) | .chars | implode diff --git a/Task/Caesar-cipher/Julia/caesar-cipher.jl b/Task/Caesar-cipher/Julia/caesar-cipher.julia similarity index 100% rename from Task/Caesar-cipher/Julia/caesar-cipher.jl rename to Task/Caesar-cipher/Julia/caesar-cipher.julia diff --git a/Task/Caesar-cipher/Koka/caesar-cipher.koka b/Task/Caesar-cipher/Koka/caesar-cipher.koka deleted file mode 100644 index 75887f40dc..0000000000 --- a/Task/Caesar-cipher/Koka/caesar-cipher.koka +++ /dev/null @@ -1,21 +0,0 @@ -fun encode(s : string, shift : int) - fun encode-char(c) - if c < 'A' || (c > 'Z' && c < 'a') || c > 'z' return c - val base = if c < 'Z' then (c - 'A').int else (c - 'a').int - val rot = (base + shift) % 26 - (rot.char + (if c < 'Z' then 'A' else 'a')) - s.map(encode-char) - -fun decode(s: string, shift: int) - s.encode(0 - shift) - -fun trip(s: string, shift: int) - s.encode(shift).decode(shift) - -fun main() - "HI".encode(2).println - "HI".encode(20).println - "HI".trip(10).println - val enc = "The quick brown fox jumped over the lazy dog".encode(11) - enc.println - enc.decode(11).println diff --git a/Task/Caesar-cipher/Kotlin/caesar-cipher.kts b/Task/Caesar-cipher/Kotlin/caesar-cipher.kotlin similarity index 100% rename from Task/Caesar-cipher/Kotlin/caesar-cipher.kts rename to Task/Caesar-cipher/Kotlin/caesar-cipher.kotlin diff --git a/Task/Caesar-cipher/Langur/caesar-cipher.langur b/Task/Caesar-cipher/Langur/caesar-cipher.langur index 447cb4856b..8b2463f249 100644 --- a/Task/Caesar-cipher/Langur/caesar-cipher.langur +++ b/Task/Caesar-cipher/Langur/caesar-cipher.langur @@ -1,10 +1,10 @@ -val rot = fn(s, key) { - cp2s map(s2cp(s), by=fn(c) { rotate(rotate(c, distance=key, range='a'..'z'), distance=key, range='A'..'Z') }) +val .rot = f(.s, .key) { + cp2s map(f(.c) rotate(rotate(.c, .key, 'a'..'z'), .key, 'A'..'Z'), s2cp .s) } -val s = "A quick brown fox jumped over something." -val key = 3 +val .s = "A quick brown fox jumped over something." +val .key = 3 -writeln " original: ", s -writeln "encrypted: ", rot(s, key) -writeln "decrypted: ", rot(rot(s, key), -key) +writeln " original: ", .s +writeln "encrypted: ", .rot(.s, .key) +writeln "decrypted: ", .rot(.rot(.s, .key), -.key) diff --git a/Task/Caesar-cipher/Lua/caesar-cipher-1.lua b/Task/Caesar-cipher/Lua/caesar-cipher-1.lua index eacdfb1093..517bb19671 100644 --- a/Task/Caesar-cipher/Lua/caesar-cipher-1.lua +++ b/Task/Caesar-cipher/Lua/caesar-cipher-1.lua @@ -1,30 +1,30 @@ local function encrypt(text, key) - return text:gsub("%a", function(t) - local base = (t:lower() == t and string.byte('a') or string.byte('A')) + return text:gsub("%a", function(t) + local base = (t:lower() == t and string.byte('a') or string.byte('A')) - local r = t:byte() - base - r = r + key - r = r%26 -- works correctly even if r is negative - r = r + base - return string.char(r) - end) + local r = t:byte() - base + r = r + key + r = r%26 -- works correctly even if r is negative + r = r + base + return string.char(r) + end) end local function decrypt(text, key) - return encrypt(text, -key) + return encrypt(text, -key) end caesar = { - encrypt = encrypt, - decrypt = decrypt, + encrypt = encrypt, + decrypt = decrypt, } -- test do - local text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz" - local encrypted = caesar.encrypt(text, 7) - local decrypted = caesar.decrypt(encrypted, 7) - print("Original text: ", text) - print("Encrypted text: ", encrypted) - print("Decrypted text: ", decrypted) + local text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz" + local encrypted = caesar.encrypt(text, 7) + local decrypted = caesar.decrypt(encrypted, 7) + print("Original text: ", text) + print("Encrypted text: ", encrypted) + print("Decrypted text: ", decrypted) end diff --git a/Task/Caesar-cipher/M2000-Interpreter/caesar-cipher.m2000 b/Task/Caesar-cipher/M2000-Interpreter/caesar-cipher.m2000 index 93f88beb46..5d55037e59 100644 --- a/Task/Caesar-cipher/M2000-Interpreter/caesar-cipher.m2000 +++ b/Task/Caesar-cipher/M2000-Interpreter/caesar-cipher.m2000 @@ -16,6 +16,6 @@ Print Cipher$(B$,-10) n=1 ' n negative or positive or zero for i=65 to 65+25 - a=(1+(i -64)+n+24) mod 26 + 65 - ? chr$(a), + a=(1+(i -64)+n+24) mod 26 + 65 + ? chr$(a), next diff --git a/Task/Caesar-cipher/MATLAB/caesar-cipher-1.m b/Task/Caesar-cipher/MATLAB/caesar-cipher-1.m index bf35b9494d..ba19440994 100644 --- a/Task/Caesar-cipher/MATLAB/caesar-cipher-1.m +++ b/Task/Caesar-cipher/MATLAB/caesar-cipher-1.m @@ -1,6 +1,6 @@ function s = cipherCaesar(s, key) s = char( mod(s - 'A' + key, 25 ) + 'A'); - end; + end; function s = decipherCaesar(s, key) s = char( mod(s - 'A' - key, 25 ) + 'A'); end; diff --git a/Task/Caesar-cipher/MLite/caesar-cipher.mlite b/Task/Caesar-cipher/MLite/caesar-cipher.mlite index 7fe15099ea..2d6971bf8e 100644 --- a/Task/Caesar-cipher/MLite/caesar-cipher.mlite +++ b/Task/Caesar-cipher/MLite/caesar-cipher.mlite @@ -6,35 +6,35 @@ fun readfile () = readfile [] readfile ` ln :: x end -local - val lower_a = ord #"a"; - val lower_z = ord #"z"; - val upper_a = ord #"A"; - val upper_z = ord #"Z"; - - fun which - (c_upper c) = (upper_a, upper_z) - | _ = (lower_a, lower_z) - ; - - fun scale - (c, az) where (c > #1 az) = scale( (#0 az + (c - #1 az - 1)), az) - | (c, az) = c +local + val lower_a = ord #"a"; + val lower_z = ord #"z"; + val upper_a = ord #"A"; + val upper_z = ord #"Z"; + fun which + (c_upper c) = (upper_a, upper_z) + | _ = (lower_a, lower_z) + ; + + fun scale + (c, az) where (c > #1 az) = scale( (#0 az + (c - #1 az - 1)), az) + | (c, az) = c + in - fun encipher - ([], offset, t) = implode ` rev t - | (x :: xs, offset, t) where (c_alphabetic x) = encipher (xs, offset, (chr ` scale (ord x + offset, which x)) :: t) - | (x :: xs, offset, t) = encipher (xs, offset, x :: t) - | (s, offset) = if (offset < 0) then - encipher (explode s, 26 + (offset rem 26), []) - else - encipher (explode s, offset rem 26, []) + fun encipher + ([], offset, t) = implode ` rev t + | (x :: xs, offset, t) where (c_alphabetic x) = encipher (xs, offset, (chr ` scale (ord x + offset, which x)) :: t) + | (x :: xs, offset, t) = encipher (xs, offset, x :: t) + | (s, offset) = if (offset < 0) then + encipher (explode s, 26 + (offset rem 26), []) + else + encipher (explode s, offset rem 26, []) end fun default - (false, y) = y - | (x, _) = x + (false, y) = y + | (x, _) = x ; map println ` map (fn s = encipher (s,ston ` default (argv 0, "1"))) ` readfile (); diff --git a/Task/Caesar-cipher/Nanoquery/caesar-cipher.nanoquery b/Task/Caesar-cipher/Nanoquery/caesar-cipher.nanoquery index 7859f16aeb..f44fbeb3a6 100644 --- a/Task/Caesar-cipher/Nanoquery/caesar-cipher.nanoquery +++ b/Task/Caesar-cipher/Nanoquery/caesar-cipher.nanoquery @@ -1,35 +1,35 @@ def caesar_encode(plaintext, shift) - uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - lowercase = "abcdefghijklmnopqrstuvwxyz" + uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + lowercase = "abcdefghijklmnopqrstuvwxyz" - cipher = "" - for char in plaintext - if char in uppercase - cipher += uppercase[uppercase[char] - (26 - shift)] - else if char in lowercase - cipher += lowercase[lowercase[char] - (26 - shift)] - else - cipher += char - end - end + cipher = "" + for char in plaintext + if char in uppercase + cipher += uppercase[uppercase[char] - (26 - shift)] + else if char in lowercase + cipher += lowercase[lowercase[char] - (26 - shift)] + else + cipher += char + end + end - return cipher + return cipher end def caesar_decode(cipher, shift) - uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - lowercase = "abcdefghijklmnopqrstuvwxyz" + uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + lowercase = "abcdefghijklmnopqrstuvwxyz" - plaintext = "" - for char in cipher - if char in uppercase - plaintext += uppercase[uppercase[char] - shift] - else if char in lowercase - plaintext += lowercase[lowercase[char] - shift] - else - plaintext += char - end - end + plaintext = "" + for char in cipher + if char in uppercase + plaintext += uppercase[uppercase[char] - shift] + else if char in lowercase + plaintext += lowercase[lowercase[char] - shift] + else + plaintext += char + end + end - return plaintext + return plaintext end diff --git a/Task/Caesar-cipher/OCaml/caesar-cipher-1.ml b/Task/Caesar-cipher/OCaml/caesar-cipher-1.ocaml similarity index 100% rename from Task/Caesar-cipher/OCaml/caesar-cipher-1.ml rename to Task/Caesar-cipher/OCaml/caesar-cipher-1.ocaml diff --git a/Task/Caesar-cipher/OCaml/caesar-cipher-2.ml b/Task/Caesar-cipher/OCaml/caesar-cipher-2.ocaml similarity index 100% rename from Task/Caesar-cipher/OCaml/caesar-cipher-2.ml rename to Task/Caesar-cipher/OCaml/caesar-cipher-2.ocaml diff --git a/Task/Caesar-cipher/Oberon/caesar-cipher.oberon b/Task/Caesar-cipher/Oberon-2/caesar-cipher.oberon similarity index 100% rename from Task/Caesar-cipher/Oberon/caesar-cipher.oberon rename to Task/Caesar-cipher/Oberon-2/caesar-cipher.oberon diff --git a/Task/Caesar-cipher/OmniMark/caesar-cipher.xom b/Task/Caesar-cipher/OmniMark/caesar-cipher.xom deleted file mode 100644 index 8395716c58..0000000000 --- a/Task/Caesar-cipher/OmniMark/caesar-cipher.xom +++ /dev/null @@ -1,25 +0,0 @@ -; caesar.xom -global integer gi-k initial {13} -global stream gs-ed initial {'encode'} -global stream gs-phrase - -define stream function apply-cipher (value stream phrase, value integer k, value stream ed) as - local integer b - local stream ciphered - open ciphered as buffer - repeat scan phrase - match letter => char - set b to char binary 0 - increment b by k when ed = 'encode' - increment b by 26 - k when ed = 'decode' - decrement b by 26 when char matches uc and b > 90 - decrement b by 26 when char matches lc and b > 122 - put ciphered "b" % b - match any => char - put ciphered char - again - close ciphered - return ciphered - -process - output apply-cipher(gs-phrase, gi-k, gs-ed) || '%n%n' diff --git a/Task/Caesar-cipher/PascalABC.NET/caesar-cipher.pas b/Task/Caesar-cipher/PascalABC.NET/caesar-cipher.pas deleted file mode 100644 index 722c8f1b44..0000000000 --- a/Task/Caesar-cipher/PascalABC.NET/caesar-cipher.pas +++ /dev/null @@ -1,20 +0,0 @@ -## -function encrypt(msg:string;k:integer):string; -begin - var big:=('A'..'Z').ToArray; - var ltl:=('a'..'z').ToArray; - foreach var c in msg do - case c of - 'A'..'Z': result+=big[(big.IndexOf(c)+k) mod 26]; - 'a'..'z': result+=ltl[(ltl.IndexOf(c)+k) mod 26]; - else result+=c; - end; -end; -function decrypt(msg:string;k:integer):=encrypt(msg, 26-k); - -var (key, message):=(3,'The five boxing wizards jump quickly'); -Println('Original:',message); -message:=encrypt(message, 3); -Println('Encrypted:',message); -message:=decrypt(message, 3); -Println('Decrypted:',message); diff --git a/Task/Caesar-cipher/Pluto/caesar-cipher.pluto b/Task/Caesar-cipher/Pluto/caesar-cipher.pluto deleted file mode 100644 index ce61edf0ca..0000000000 --- a/Task/Caesar-cipher/Pluto/caesar-cipher.pluto +++ /dev/null @@ -1,20 +0,0 @@ -local function caesar(s, k, e=true) - -- Parameters: s (string), k (key) - -- e (true=encode, false=decode) - if !e do k=-k end - local out = "" - for i = 1, #s do - local c = s[i] - if c:islower() then - out ..= string.char((c:byte() - 97 + k) % 26 + 97) - elseif c:isupper() then - out ..= string.char((c:byte() - 65 + k) % 26 + 65) - else - out ..= c - end - end - return out -end - -print(caesar("The quick brown fox jumps over the lazy dog.", 3)) -print(caesar("Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj.", 3, false)) diff --git a/Task/Caesar-cipher/PowerShell/caesar-cipher.ps1 b/Task/Caesar-cipher/PowerShell/caesar-cipher.psh similarity index 100% rename from Task/Caesar-cipher/PowerShell/caesar-cipher.ps1 rename to Task/Caesar-cipher/PowerShell/caesar-cipher.psh diff --git a/Task/Caesar-cipher/Prolog/caesar-cipher.pro b/Task/Caesar-cipher/Prolog/caesar-cipher.pro index bd0957e07b..bf0e31a910 100644 --- a/Task/Caesar-cipher/Prolog/caesar-cipher.pro +++ b/Task/Caesar-cipher/Prolog/caesar-cipher.pro @@ -1,33 +1,33 @@ :- use_module(library(clpfd)). caesar :- - L1 = "The five boxing wizards jump quickly", - writef("Original : %s\n", [L1]), + L1 = "The five boxing wizards jump quickly", + writef("Original : %s\n", [L1]), - % encryption of the sentence - encoding(3, L1, L2) , - writef("Encoding : %s\n", [L2]), + % encryption of the sentence + encoding(3, L1, L2) , + writef("Encoding : %s\n", [L2]), - % deciphering on the encoded sentence - encoding(3, L3, L2), - writef("Decoding : %s\n", [L3]). + % deciphering on the encoded sentence + encoding(3, L3, L2), + writef("Decoding : %s\n", [L3]). % encoding/decoding of a sentence encoding(Key, L1, L2) :- - maplist(caesar_cipher(Key), L1, L2). + maplist(caesar_cipher(Key), L1, L2). caesar_cipher(_, 32, 32) :- !. caesar_cipher(Key, V1, V2) :- - V #= Key + V1, + V #= Key + V1, - % we verify that we are in the limits of A-Z and a-z. - ((V1 #=< 0'Z #/\ V #> 0'Z) #\/ (V1 #=< 0'z #/\ V #> 0'z) - #\/ - (V1 #< 0'A #/\ V2 #>= 0'A)#\/ (V1 #< 0'a #/\ V2 #>= 0'a)) #==> A, + % we verify that we are in the limits of A-Z and a-z. + ((V1 #=< 0'Z #/\ V #> 0'Z) #\/ (V1 #=< 0'z #/\ V #> 0'z) + #\/ + (V1 #< 0'A #/\ V2 #>= 0'A)#\/ (V1 #< 0'a #/\ V2 #>= 0'a)) #==> A, - % if we are not in these limits A is 1, otherwise 0. - V2 #= V - A * 26, + % if we are not in these limits A is 1, otherwise 0. + V2 #= V - A * 26, - % compute values of V1 and V2 - label([A, V1, V2]). + % compute values of V1 and V2 + label([A, V1, V2]). diff --git a/Task/Caesar-cipher/Python/caesar-cipher-1.py b/Task/Caesar-cipher/Python/caesar-cipher-1.py index 7f31eb37ce..975933b38c 100644 --- a/Task/Caesar-cipher/Python/caesar-cipher-1.py +++ b/Task/Caesar-cipher/Python/caesar-cipher-1.py @@ -1,8 +1,8 @@ def caesar(s, k, decode = False): - if decode: k = 26 - k - return "".join([chr((ord(i) - 65 + k) % 26 + 65) - for i in s.upper() - if ord(i) >= 65 and ord(i) <= 90 ]) + if decode: k = 26 - k + return "".join([chr((ord(i) - 65 + k) % 26 + 65) + for i in s.upper() + if ord(i) >= 65 and ord(i) <= 90 ]) msg = "The quick brown fox jumped over the lazy dogs" print msg diff --git a/Task/Caesar-cipher/REXX/caesar-cipher-1.rexx b/Task/Caesar-cipher/REXX/caesar-cipher-1.rexx index bb11547520..06c3e7d028 100644 --- a/Task/Caesar-cipher/REXX/caesar-cipher-1.rexx +++ b/Task/Caesar-cipher/REXX/caesar-cipher-1.rexx @@ -1,35 +1,22 @@ -/*REXX program supports the Caesar cipher for the Latin alphabet only, */ -/* no punctuation or blanks allowed, lowercase is treated as uppercase. */ -Parse Upper Arg key text /* get key & uppercased text to be ciphered*/ -text=space(text,0) /* elide any and blanks */ -Say 'Caesar cipher key:' key /* echo the Caesar cipher key */ -Say ' plain text:' text /* " " plain text */ -code=caesar(text,key) -Say ' ciphered:' code /* " " ciphered text */ -back=caesar(code,-key) -Say ' unciphered:' back /* " " unciphered text */ -If back\==text Then - Say "unciphered text doesn't match plain text." -Exit /* stick a fork in it, we're all done*/ -/*----------------------------------------------------------------------*/ -caesar: Procedure - Parse Arg text,key - abc='ABCDEFGHIJKLMNOPQRSTUVWXYZ' - If abs(key)>length(abc)-1|key==0 Then - Call err 'key ('key') is invalid.' - badpos=verify(text,abc) /* any illegal character in the text */ - If badpos\==0 Then - Call err 'unsupported character:' substr(text,badpos,1) - If key>0 Then /* cipher */ - key2=key+1 - Else /* decipher */ - key2=length(abc)+key+1 - Return translate(text,substr(abc||abc,key2,length(abc)),abc) -/*----------------------------------------------------------------------*/ -err: - Say - Say '***error***' - Say - Say arg(1) - Say - Exit 13 +/*REXX program supports the Caesar cypher for the Latin alphabet only, no punctuation */ +/*──────────── or blanks allowed, all lowercase Latin letters are treated as uppercase.*/ +parse arg key .; arg . p /*get key & uppercased text to be used.*/ +p= space(p, 0) /*elide any and all spaces (blanks). */ + say 'Caesar cypher key:' key /*echo the Caesar cypher key to console*/ + say ' plain text:' p /* " " plain text " " */ +y= Caesar(p, key); say ' cyphered:' y /* " " cyphered text " " */ +z= Caesar(y,-key); say ' uncyphered:' z /* " " uncyphered text " " */ +if z\==p then say "plain text doesn't match uncyphered cyphered text." +exit 0 /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +Caesar: procedure; arg s,k; @= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + ak= abs(k) /*obtain the absolute value of the key.*/ + L= length(@) /*obtain the length of the @ string. */ + if ak>length(@)-1 | k==0 then call err k 'key is invalid.' + _= verify(s, @) /*any illegal characters specified ? */ + if _\==0 then call err 'unsupported character:' substr(s, _, 1) + if k>0 then ky= k + 1 /*either cypher it, or ··· */ + else ky= L + 1 - ak /* decypher it. */ + return translate(s, substr(@ || @, ky, L), @) /*return the processed text.*/ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +err: say; say '***error***'; say; say arg(1); say; exit 13 diff --git a/Task/Caesar-cipher/REXX/caesar-cipher-2.rexx b/Task/Caesar-cipher/REXX/caesar-cipher-2.rexx index e548c94eaf..6aa291ac4d 100644 --- a/Task/Caesar-cipher/REXX/caesar-cipher-2.rexx +++ b/Task/Caesar-cipher/REXX/caesar-cipher-2.rexx @@ -1,39 +1,22 @@ -/*REXX program supports the Caesar cipher for most keyboard characters */ -/* including blanks.*/ - Parse Arg key text /* get key and the text to be ciph */ - Say 'Caesar cipher key:' key /* echo the Caesar cipher key */ - Say ' plain text:' text /* " " plain text */ - code=caesar(text,key) - Say ' ciphered:' code /* " " ciphered text */ - back=caesar(code,-key) - Say ' unciphered:' back /* " " unciphered text */ - If back\==text Then - Say "plain text doesn't match unciphered ciphered text." - Exit /* stick a fork in it, we're all done */ -/*----------------------------------------------------------------------*/ -caesar: Procedure - Parse Arg txt,ky - abcx='abcdefghijklmnopqrstuvwxyz' - abcx=translate(abcx)abcx"0123456789(){}[]<>'" /*add uppercase, digits */ - abcx=abcx'~!@#$%^&*_+:";?,./`-= ' /* also add other characters */ - l=length(abcx) /* obtain the length of abcx */ - aky=abs(ky) /* absolute value of the key */ - If aky>length(abcx)-1|ky==0 Then - Call err ky 'key is invalid.' - badpos=verify(txt,abcx) /* any illegal character in txt */ - If badpos\==0 Then - Call err 'unsupported character:' substr(txt,badpos,1) - If ky>0 Then /* cipher */ - ky=ky+1 - Else /* decipher */ - ky=l+1-aky - /* return translated input */ - Return translate(txt,substr(abcx||abcx,ky,l),abcx) -/*----------------------------------------------------------------------*/ -err: - Say - Say '***error***' - Say - Say arg(1) - Say - Exit 13 +/*REXX program supports the Caesar cypher for most keyboard characters including blanks.*/ +parse arg key p /*get key and the text to be cyphered. */ + say 'Caesar cypher key:' key /*echo the Caesar cypher key to console*/ + say ' plain text:' p /* " " plain text " " */ +y= Caesar(p, key); say ' cyphered:' y /* " " cyphered text " " */ +z= Caesar(y,-key); say ' uncyphered:' z /* " " uncyphered text " " */ +if z\==p then say "plain text doesn't match uncyphered cyphered text." +exit 0 /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +Caesar: procedure; parse arg s,k; @= 'abcdefghijklmnopqrstuvwxyz' + @= translate(@)@"0123456789(){}[]<>'" /*add uppercase, digits, group symbols.*/ + @= @'~!@#$%^&*_+:";?,./`-= ' /*also add other characters to the list*/ + L= length(@) /*obtain the length of the @ string. */ + ak= abs(k) /*obtain the absolute value of the key.*/ + if ak>length(@)-1 | k==0 then call err k 'key is invalid.' + _= verify(s,@) /*any illegal characters specified ? */ + if _\==0 then call err 'unsupported character:' substr(s, _, 1) + if k>0 then ky= k + 1 /*either cypher it, or ··· */ + else ky= L + 1 - ak /* decypher it. */ + return translate(s, substr(@ || @, ky, L), @) /*return the processed text.*/ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +err: say; say '***error***'; say; say arg(1); say; exit 13 diff --git a/Task/Caesar-cipher/Rebol/caesar-cipher.rebol b/Task/Caesar-cipher/Rebol/caesar-cipher.rebol deleted file mode 100644 index 80053bbce7..0000000000 --- a/Task/Caesar-cipher/Rebol/caesar-cipher.rebol +++ /dev/null @@ -1,37 +0,0 @@ -Rebol [ - title: "Rosetta code: Caesar cipher" - file: %Caesar_cipher.r3 - url: https://rosettacode.org/wiki/Caesar_cipher - needs: 3.0.0 - note: {Based on Red language version} -] - -caesar: function/with [ - src [string!] - key [integer!] -][ - parse/case src [ - any [ - change s: [lower (o: #"a") | upper (o: #"A")] (rot s/1 key o) - | skip - ] - ] - src -][ - lower: charset [#"a" - #"z"] - upper: charset [#"A" - #"Z"] - rot: func [ - char [char!] - key [number!] - ofs [char!] - ][ - to char! key + char - ofs // 26 + ofs - ] -] - -encrypt: :caesar -decrypt: func spec-of :caesar [caesar src negate key] - -;; DEMO: -print encrypt "Ceasar Cipher" 4 ;== Giewev Gmtliv -print decrypt "Giewev Gmtliv" 4 ;== Ceasar Cipher diff --git a/Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus b/Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus deleted file mode 100644 index eb65b69fc6..0000000000 --- a/Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus +++ /dev/null @@ -1,25 +0,0 @@ -#lang rhombus/static - -import lib("racket/base.rkt") expose: - #{string->list} as string_to_list - #{list->string} as list_to_string - modulo - -fun make_rot13_char(key :: Int): - fun (char :: Char): - let char_int = char.to_int() - fun rot13_by_case(char_int, a_char :: Char) :: Int : - modulo(char_int - a_char.to_int() + key, 26) + a_char.to_int() - if char.is_alphabetic(): - | if char.is_lowercase(): - | Char.from_int(rot13_by_case(char_int, Char"a")) - | Char.from_int(rot13_by_case(char_int, Char"A")) - | char - -fun rot13_string(str :: String, key :: Int) :: String : - let chars :: PairList = string_to_list(str) - let rot13_char = make_rot13_char(key) - let str :: MutableString = list_to_string(chars.map(rot13_char)) - str.snapshot() - -rot13_string("Hello, World!", 14) // Output: "Vszzc, Kcfzr!"" diff --git a/Task/Caesar-cipher/Rust/caesar-cipher.rs b/Task/Caesar-cipher/Rust/caesar-cipher.rust similarity index 100% rename from Task/Caesar-cipher/Rust/caesar-cipher.rs rename to Task/Caesar-cipher/Rust/caesar-cipher.rust diff --git a/Task/Caesar-cipher/Scheme/caesar-cipher.scm b/Task/Caesar-cipher/Scheme/caesar-cipher.ss similarity index 100% rename from Task/Caesar-cipher/Scheme/caesar-cipher.scm rename to Task/Caesar-cipher/Scheme/caesar-cipher.ss diff --git a/Task/Caesar-cipher/Sed/caesar-cipher.sed b/Task/Caesar-cipher/Sed/caesar-cipher.sed index 7b8eb7895b..a599313519 100644 --- a/Task/Caesar-cipher/Sed/caesar-cipher.sed +++ b/Task/Caesar-cipher/Sed/caesar-cipher.sed @@ -2,26 +2,26 @@ # Input: \ntext to encode /^[0-9]+$/ { - # validate a number and translate it to analog form - s/$/;9876543210dddddddddd/ - s/([0-9]);.*\1.{10}(.?)/\2/ - s/2/11/ - s/1/dddddddddd/g - /[3-9]|d{25}d+/ { - s/.*/Error: Key must be <= 25/ - q - } - # append from-table - s/$/\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/ - # .. and to-table - s/$/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/ - # rotate to-table, lower and uppercase independently, removing one `d' at a time - : rotate - s/^d(.*\n[^Z]+Z)(.)(.{25})(.)(.{25})/\1\3\2\5\4/ - t rotate - s/\n// - h - d + # validate a number and translate it to analog form + s/$/;9876543210dddddddddd/ + s/([0-9]);.*\1.{10}(.?)/\2/ + s/2/11/ + s/1/dddddddddd/g + /[3-9]|d{25}d+/ { + s/.*/Error: Key must be <= 25/ + q + } + # append from-table + s/$/\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/ + # .. and to-table + s/$/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/ + # rotate to-table, lower and uppercase independently, removing one `d' at a time + : rotate + s/^d(.*\n[^Z]+Z)(.)(.{25})(.)(.{25})/\1\3\2\5\4/ + t rotate + s/\n// + h + d } # use \n to mark character to convert @@ -29,9 +29,9 @@ s/^/\n/ # append conversion table to pattern space G : loop - # look up converted character and place it instead of old one - s/\n(.)(.*\n.*\1.{51}(.))/\n\3\2/ - # advance \n even if prev. command fails, thus skip non-alphabetical characters - /\n\n/! s/\n([^\n])/\1\n/ + # look up converted character and place it instead of old one + s/\n(.)(.*\n.*\1.{51}(.))/\n\3\2/ + # advance \n even if prev. command fails, thus skip non-alphabetical characters + /\n\n/! s/\n([^\n])/\1\n/ t loop s/\n\n.*// diff --git a/Task/Caesar-cipher/SequenceL/caesar-cipher.sequencel b/Task/Caesar-cipher/SequenceL/caesar-cipher.sequencel index f075eb3691..3e23c88d8f 100644 --- a/Task/Caesar-cipher/SequenceL/caesar-cipher.sequencel +++ b/Task/Caesar-cipher/SequenceL/caesar-cipher.sequencel @@ -5,28 +5,28 @@ lowerAlphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; upperAlphabet := "abcdefghijklmnopqrstuvwxyz"; caesarEncrypt(ch, key) := - let - correctAlphabet := - lowerAlphabet when some(ch = lowerAlphabet) - else - upperAlphabet; - - index := Sequence::firstIndexOf(correctAlphabet, ch); - - newIndex := (index + key - 1) mod 26 + 1; - in - ch when not(some(ch = lowerAlphabet) or some(ch = upperAlphabet)) - else - correctAlphabet[newIndex]; - + let + correctAlphabet := + lowerAlphabet when some(ch = lowerAlphabet) + else + upperAlphabet; + + index := Sequence::firstIndexOf(correctAlphabet, ch); + + newIndex := (index + key - 1) mod 26 + 1; + in + ch when not(some(ch = lowerAlphabet) or some(ch = upperAlphabet)) + else + correctAlphabet[newIndex]; + caesarDecrypt(ch, key) := caesarEncrypt(ch, 26 - key); main(args(2)) := - let - key := Conversion::stringToInt(args[2]); - encrypted := caesarEncrypt(args[1], key); - decrypted := caesarDecrypt(encrypted, key); - in - "Input: \t" ++ args[1] ++ "\n" ++ - "Encrypted:\t" ++ encrypted ++ "\n" ++ - "Decrypted:\t" ++ decrypted; + let + key := Conversion::stringToInt(args[2]); + encrypted := caesarEncrypt(args[1], key); + decrypted := caesarDecrypt(encrypted, key); + in + "Input: \t" ++ args[1] ++ "\n" ++ + "Encrypted:\t" ++ encrypted ++ "\n" ++ + "Decrypted:\t" ++ decrypted; diff --git a/Task/Caesar-cipher/SheerPower-4GL/caesar-cipher.4gl b/Task/Caesar-cipher/SheerPower-4GL/caesar-cipher.4gl deleted file mode 100644 index 0e623ae1f1..0000000000 --- a/Task/Caesar-cipher/SheerPower-4GL/caesar-cipher.4gl +++ /dev/null @@ -1,46 +0,0 @@ -declare string plaintext$, ciphertext$, decrypted$ - -plaintext$ = 'The Quick Brown Fox Jumps Over The Lazy Dog' - -print 'Plaintext: '; plaintext$ - -ciphertext$ = caesar$(plaintext$, 13) -print 'ROT13: '; ciphertext$ - -decrypted$ = caesar$(ciphertext$, 13) -print 'Decrypted: '; decrypted$ - -print -print 'Shift 3 example (classic Caesar):' -ciphertext$ = caesar$('Attack at dawn', 3) -print 'Encrypted: '; ciphertext$ -print 'Decrypted: '; caesar$(ciphertext$, 23) - -! ============================================================================= -! Routine: caesar$(text$, shift%) -! -! Shift each letter in text$ by shift% positions. A–Z and a–z wrap -! within their own ranges; all other characters are copied unchanged. -! ============================================================================= -routine caesar$(text$, shift%) - declare string result$, ch$ - declare integer i%, code% - - result$ = '' - for i% = 1 to len(text$) - ch$ = mid$(text$, i%, 1) - code% = ord(ch$) - - if code% >= 65 and code% <= 90 then - ! Uppercase A–Z: rotate within 65–90 - result$ = result$ + chr$((code% - 65 + shift%) mod 26 + 65) - elseif code% >= 97 and code% <= 122 then - ! Lowercase a–z: rotate within 97–122 - result$ = result$ + chr$((code% - 97 + shift%) mod 26 + 97) - else - ! Non-letter: pass through unchanged - result$ = result$ + ch$ - end if - next i% - caesar$ = result$ -end routine diff --git a/Task/Caesar-cipher/Stata/caesar-cipher.stata b/Task/Caesar-cipher/Stata/caesar-cipher.stata index 781a4a32cb..823b54b67f 100644 --- a/Task/Caesar-cipher/Stata/caesar-cipher.stata +++ b/Task/Caesar-cipher/Stata/caesar-cipher.stata @@ -1,10 +1,10 @@ function caesar(s, k) { - u = ascii(s) - i = selectindex(u:>=65 :& u:<=90) - if (length(i)>0) u[i] = mod(u[i]:+(k-65), 26):+65 - i = selectindex(u:>=97 :& u:<=122) - if (length(i)>0) u[i] = mod(u[i]:+(k-97), 26):+97 - return(char(u)) + u = ascii(s) + i = selectindex(u:>=65 :& u:<=90) + if (length(i)>0) u[i] = mod(u[i]:+(k-65), 26):+65 + i = selectindex(u:>=97 :& u:<=122) + if (length(i)>0) u[i] = mod(u[i]:+(k-97), 26):+97 + return(char(u)) } caesar("layout", 20) diff --git a/Task/Caesar-cipher/Tcl/caesar-cipher-1.tcl b/Task/Caesar-cipher/Tcl/caesar-cipher-1.tcl index 78343594f8..27c85f38e0 100644 --- a/Task/Caesar-cipher/Tcl/caesar-cipher-1.tcl +++ b/Task/Caesar-cipher/Tcl/caesar-cipher-1.tcl @@ -3,21 +3,21 @@ package require Tcl 8.6; # Or TclOO package for 8.5 oo::class create Caesar { variable encryptMap decryptMap constructor shift { - for {set i 0} {$i < 26} {incr i} { - # Play fast and loose with string/list duality for shorter code - append encryptMap [format "%c %c %c %c " \ - [expr {$i+65}] [expr {($i+$shift)%26+65}] \ - [expr {$i+97}] [expr {($i+$shift)%26+97}]] - append decryptMap [format "%c %c %c %c " \ - [expr {$i+65}] [expr {($i-$shift)%26+65}] \ - [expr {$i+97}] [expr {($i-$shift)%26+97}]] - } + for {set i 0} {$i < 26} {incr i} { + # Play fast and loose with string/list duality for shorter code + append encryptMap [format "%c %c %c %c " \ + [expr {$i+65}] [expr {($i+$shift)%26+65}] \ + [expr {$i+97}] [expr {($i+$shift)%26+97}]] + append decryptMap [format "%c %c %c %c " \ + [expr {$i+65}] [expr {($i-$shift)%26+65}] \ + [expr {$i+97}] [expr {($i-$shift)%26+97}]] + } } method encrypt text { - string map $encryptMap $text + string map $encryptMap $text } method decrypt text { - string map $decryptMap $text + string map $decryptMap $text } } diff --git a/Task/Caesar-cipher/True-BASIC/caesar-cipher.basic b/Task/Caesar-cipher/True-BASIC/caesar-cipher.basic deleted file mode 100644 index 506d9002d2..0000000000 --- a/Task/Caesar-cipher/True-BASIC/caesar-cipher.basic +++ /dev/null @@ -1,32 +0,0 @@ -LET dec$ = "" -LET tipo$ = "cleartext " - -PRINT "If decrypting enter 'd' -- else press enter "; -INPUT dec$ -PRINT "Enter offset "; -INPUT llave - -IF dec$ = "d" THEN - LET llave = 26 - llave - LET tipo$ = "ciphertext " -END IF - -PRINT "Enter "; tipo$; -INPUT cadena$ - -LET cadena$ = UCASE$(cadena$) -LET longitud = LEN(cadena$) - -FOR i = 1 TO longitud - !LET iTemp = ASC(MID$(cadena$,i,1)) 'QBasic - LET itemp = ORD((cadena$)[i:i+1-1][1:1]) !'True BASIC - - IF iTemp > 64 AND iTemp < 91 THEN - !LET iTemp = ((iTemp - 65) + llave) MOD 26 'QBasic - LET iTemp = MOD(((iTemp - 65) + llave), 26) !'True BASIC - PRINT CHR$(iTemp + 65); - ELSE - PRINT CHR$(iTemp); - END IF -NEXT i -END diff --git a/Task/Caesar-cipher/TypeScript/caesar-cipher.ts b/Task/Caesar-cipher/TypeScript/caesar-cipher.ts index cee247c48a..2721324997 100644 --- a/Task/Caesar-cipher/TypeScript/caesar-cipher.ts +++ b/Task/Caesar-cipher/TypeScript/caesar-cipher.ts @@ -1,8 +1,8 @@ function replace(input: string, key: number) : string { - return input.replace(/([a-z])/g, - ($1) => String.fromCharCode(($1.charCodeAt(0) + key + 26 - 97) % 26 + 97) - ).replace(/([A-Z])/g, - ($1) => String.fromCharCode(($1.charCodeAt(0) + key + 26 - 65) % 26 + 65)); + return input.replace(/([a-z])/g, + ($1) => String.fromCharCode(($1.charCodeAt(0) + key + 26 - 97) % 26 + 97) + ).replace(/([A-Z])/g, + ($1) => String.fromCharCode(($1.charCodeAt(0) + key + 26 - 65) % 26 + 65)); } // test diff --git a/Task/Caesar-cipher/Uiua/caesar-cipher.uiua b/Task/Caesar-cipher/Uiua/caesar-cipher.uiua deleted file mode 100644 index 4f3720c52e..0000000000 --- a/Task/Caesar-cipher/Uiua/caesar-cipher.uiua +++ /dev/null @@ -1,7 +0,0 @@ -k ← 3 -m ← -:26 k -Rot ← +@A◿26+k-@A -Rrot ← +@A◿26+m-@A -&sc -&p. ⍥(¯≡(⍥Rot=1±.))2 -&p ⍥(¯≡(⍥Rrot=1±.))2 diff --git a/Task/Caesar-cipher/Ursa/caesar-cipher.ursa b/Task/Caesar-cipher/Ursa/caesar-cipher.ursa index 70ec888a94..0039e259da 100644 --- a/Task/Caesar-cipher/Ursa/caesar-cipher.ursa +++ b/Task/Caesar-cipher/Ursa/caesar-cipher.ursa @@ -1,7 +1,7 @@ decl string mode while (not (or (= mode "encode") (= mode "decode"))) - out "encode/decode: " console - set mode (lower (in string console)) + out "encode/decode: " console + set mode (lower (in string console)) end while decl string message @@ -12,17 +12,17 @@ decl int key out "key: " console set key (in int console) if (or (> key 26) (< key 0)) - out endl "invalid key" endl console - stop + out endl "invalid key" endl console + stop end if if (= mode "decode") - set key (int (- 26 key)) + set key (int (- 26 key)) end if for (decl int i) (< i (size message)) (inc i) - if (and (> (ord message) 64) (< (ord message) 91)) - out (chr (int (+ (mod (int (+ (- (ord message) 65) key)) 26) 65))) console - end if + if (and (> (ord message) 64) (< (ord message) 91)) + out (chr (int (+ (mod (int (+ (- (ord message) 65) key)) 26) 65))) console + end if end for out endl console diff --git a/Task/Caesar-cipher/V-(Vlang)/caesar-cipher.v b/Task/Caesar-cipher/V-(Vlang)/caesar-cipher.v index 6be2839b81..41f5a5ece3 100644 --- a/Task/Caesar-cipher/V-(Vlang)/caesar-cipher.v +++ b/Task/Caesar-cipher/V-(Vlang)/caesar-cipher.v @@ -1,35 +1,40 @@ import rand -const lo_abc = 'abcdefghijklmnopqrstuvwxyz' -const up_abc = 'ABCDEFGHIJKLMNIPQRSTUVWXYZ' +const +( + lo_abc = 'abcdefghijklmnopqrstuvwxyz' + up_abc = 'ABCDEFGHIJKLMNIPQRSTUVWXYZ' +) fn main() { - key := rand.int_in_range(2, 25) or {13} - encrypted := caesar_encrypt('The five boxing wizards jump quickly', key) - println(encrypted) - println(caesar_decrypt(encrypted, key)) + key := rand.int_in_range(2, 25) or {13} + encrypted := caesar_encrypt('The five boxing wizards jump quickly', key) + println(encrypted) + println(caesar_decrypt(encrypted, key)) } fn caesar_encrypt(str string, key int) string { - offset := key % 26 - if offset == 0 {return str} - mut nchr := u8(0) - mut chr_arr := []u8{} - for chr in str { - if chr.ascii_str() in up_abc.split('') { - nchr = chr + u8(offset) - if nchr > u8(90) {nchr -= 26} - } - else if chr.ascii_str() in lo_abc.split('') { - nchr = chr + u8(offset) - if nchr > u8(122) {nchr -= 26} - } - else {nchr = chr} - chr_arr << nchr - } - return chr_arr.bytestr() + offset := key % 26 + if offset == 0 {return str} + mut nchr := u8(0) + mut chr_arr := []u8{} + for chr in str { + if chr.ascii_str() in up_abc.split('') { + nchr = chr + u8(offset) + if nchr > u8(90) {nchr -= 26} + } + else if chr.ascii_str() in lo_abc.split('') { + nchr = chr + u8(offset) + if nchr > u8(122) {nchr -= 26} + } + else { + nchr = chr + } + chr_arr << nchr + } + return chr_arr.bytestr() } fn caesar_decrypt(str string, key int) string { - return caesar_encrypt(str, 26 - key) + return caesar_encrypt(str, 26 - key) } diff --git a/Task/Caesar-cipher/VBScript/caesar-cipher.vb b/Task/Caesar-cipher/VBScript/caesar-cipher.vb new file mode 100644 index 0000000000..80a55326d5 --- /dev/null +++ b/Task/Caesar-cipher/VBScript/caesar-cipher.vb @@ -0,0 +1,35 @@ + str = "IT WAS THE BEST OF TIMES, IT WAS THE WORST OF TIMES." + + Wscript.Echo str + Wscript.Echo Rotate(str,5) + Wscript.Echo Rotate(Rotate(str,5),-5) + + 'Rotate (Caesar encrypt/decrypt) test positions. + ' numpos < 0 - rotate left + ' numpos > 0 - rotate right + 'Left rotation is converted to equivalent right rotation + + Function Rotate (text, numpos) + + dim dic: set dic = CreateObject("Scripting.Dictionary") + dim ltr: ltr = Split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") + dim rot: rot = (26 + numpos Mod 26) Mod 26 'convert all to right rotation + dim ch + dim i + + for i = 0 to ubound(ltr) + dic(ltr(i)) = ltr((rot+i) Mod 26) + next + + Rotate = "" + + for i = 1 to Len(text) + ch = Mid(text,i,1) + if dic.Exists(ch) Then + Rotate = Rotate & dic(ch) + else + Rotate = Rotate & ch + end if + next + + End Function diff --git a/Task/Caesar-cipher/VBScript/caesar-cipher.vbs b/Task/Caesar-cipher/VBScript/caesar-cipher.vbs deleted file mode 100644 index 73b7fd082c..0000000000 --- a/Task/Caesar-cipher/VBScript/caesar-cipher.vbs +++ /dev/null @@ -1,35 +0,0 @@ - str = "IT WAS THE BEST OF TIMES, IT WAS THE WORST OF TIMES." - - Wscript.Echo str - Wscript.Echo Rotate(str,5) - Wscript.Echo Rotate(Rotate(str,5),-5) - - 'Rotate (Caesar encrypt/decrypt) test positions. - ' numpos < 0 - rotate left - ' numpos > 0 - rotate right - 'Left rotation is converted to equivalent right rotation - - Function Rotate (text, numpos) - - dim dic: set dic = CreateObject("Scripting.Dictionary") - dim ltr: ltr = Split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") - dim rot: rot = (26 + numpos Mod 26) Mod 26 'convert all to right rotation - dim ch - dim i - - for i = 0 to ubound(ltr) - dic(ltr(i)) = ltr((rot+i) Mod 26) - next - - Rotate = "" - - for i = 1 to Len(text) - ch = Mid(text,i,1) - if dic.Exists(ch) Then - Rotate = Rotate & dic(ch) - else - Rotate = Rotate & ch - end if - next - - End Function diff --git a/Task/Caesar-cipher/Vedit-macro-language/caesar-cipher.vedit b/Task/Caesar-cipher/Vedit-macro-language/caesar-cipher.vedit index 52623467cf..058a1d7857 100644 --- a/Task/Caesar-cipher/Vedit-macro-language/caesar-cipher.vedit +++ b/Task/Caesar-cipher/Vedit-macro-language/caesar-cipher.vedit @@ -6,6 +6,6 @@ while(Cur_Pos < Block_End) { if (Cur_Char >= 'A') { Ins_Char((Cur_Char - #11 + 26 + #10) % 26 + #11, OVERWRITE) } else { - Char(1) + Char(1) } } diff --git a/Task/Caesar-cipher/XBS/caesar-cipher.xbs b/Task/Caesar-cipher/XBS/caesar-cipher.xbs index 3b717a8a5f..79c542bd70 100644 --- a/Task/Caesar-cipher/XBS/caesar-cipher.xbs +++ b/Task/Caesar-cipher/XBS/caesar-cipher.xbs @@ -1,33 +1,33 @@ set letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"::split(); func caesar(text,shift:number=1){ - set res:string=""; - for(i=0;?text-1;1){ - set t=text::at(i); - set n=(letters::find(t::upper())+shift)%?letters; - while(n<0){ - n=?letters+n; - } - set l=letters[n]; - (t::upper()==t)|=>l=l::lower() - res+=l; - } - send res; + set res:string=""; + for(i=0;?text-1;1){ + set t=text::at(i); + set n=(letters::find(t::upper())+shift)%?letters; + while(n<0){ + n=?letters+n; + } + set l=letters[n]; + (t::upper()==t)|=>l=l::lower() + res+=l; + } + send res; } func decode(text,shift:number=1){ - set res:string=""; - for(i=0;?text-1;1){ - set t=text::at(i); - set n=(letters::find(t::upper())-shift)%?letters; - while(n<0){ - n=?letters+n; - } - set l=letters[n]; - (t::upper()==t)|=>l=l::lower() - res+=l; - } - send res; + set res:string=""; + for(i=0;?text-1;1){ + set t=text::at(i); + set n=(letters::find(t::upper())-shift)%?letters; + while(n<0){ + n=?letters+n; + } + set l=letters[n]; + (t::upper()==t)|=>l=l::lower() + res+=l; + } + send res; } set e=caesar("Hi",20); diff --git a/Task/Caesar-cipher/Yabasic/caesar-cipher.basic b/Task/Caesar-cipher/Yabasic/caesar-cipher.basic index 501b949c9b..a6563221c0 100644 --- a/Task/Caesar-cipher/Yabasic/caesar-cipher.basic +++ b/Task/Caesar-cipher/Yabasic/caesar-cipher.basic @@ -11,25 +11,25 @@ print encrypted$ : print print criptex$(encrypted$, key$, DECIPHER) sub criptex$(text$, key$, mode) - local i, k, delta, longtext, longPattern, longkey, pattern$, res$ + local i, k, delta, longtext, longPattern, longkey, pattern$, res$ + + pattern$ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 .,;:()-" + + longPattern = len(pattern$) + longtext = len(text$) + longkey = len(key$) + + for i = 1 to longtext + k = k + 1 : if k > longkey k = 1 + delta = instr(pattern$, mid$(text$, i, 1)) + delta = delta + (mode * instr(pattern$, mid$(key$, k, 1))) + if delta > longPattern then + delta = delta - longPattern + elseif delta < 1 then + delta = longPattern + delta + end if + res$ = res$ + mid$(pattern$, delta, 1) + next i - pattern$ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 .,;:()-" - - longPattern = len(pattern$) - longtext = len(text$) - longkey = len(key$) - - for i = 1 to longtext - k = k + 1 : if k > longkey k = 1 - delta = instr(pattern$, mid$(text$, i, 1)) - delta = delta + (mode * instr(pattern$, mid$(key$, k, 1))) - if delta > longPattern then - delta = delta - longPattern - elseif delta < 1 then - delta = longPattern + delta - end if - res$ = res$ + mid$(pattern$, delta, 1) - next i - - return res$ + return res$ end sub diff --git a/Task/Caesar-cipher/Zig/caesar-cipher.zig b/Task/Caesar-cipher/Zig/caesar-cipher.zig deleted file mode 100644 index d705cdd1c4..0000000000 --- a/Task/Caesar-cipher/Zig/caesar-cipher.zig +++ /dev/null @@ -1,23 +0,0 @@ -const std = @import("std"); -const stdout = @import("std").io.getStdOut().writer(); - -pub fn rot(txt: []u8, key: u8) void { - for (txt, 0..txt.len) |c, i| { - if (std.ascii.isLower(c)) { - txt[i] = (c - 'a' + key) % 26 + 'a'; - } else if (std.ascii.isUpper(c)) { - txt[i] = (c - 'A' + key) % 26 + 'A'; - } - } -} - -pub fn main() !void { - const key = 3; - var txt = "The five boxing wizards jump quickly".*; - - try stdout.print("Original: {s}\n", .{txt}); - rot(&txt, key); - try stdout.print("Encrypted: {s}\n", .{txt}); - rot(&txt, 26 - key); - try stdout.print("Decrypted: {s}\n", .{txt}); -} diff --git a/Task/Caesar-cipher/Zonnon/caesar-cipher.zonnon b/Task/Caesar-cipher/Zonnon/caesar-cipher.zonnon index e22a314696..0473b3a2dc 100644 --- a/Task/Caesar-cipher/Zonnon/caesar-cipher.zonnon +++ b/Task/Caesar-cipher/Zonnon/caesar-cipher.zonnon @@ -1,57 +1,57 @@ module Caesar; const - size = 25; + size = 25; type - Operation = (code,decode); + Operation = (code,decode); procedure C_D(s:string;k:integer;op: Operation): string; var - i,key: integer; - resp: string; - n,c: char; + i,key: integer; + resp: string; + n,c: char; begin - resp := ""; - if op = Operation.decode then key := k else key := (26 - k) end; - for i := 0 to len(s) - 1 do - c := cap(s[i]); - if (c >= 'A') & (c <= 'Z') then - resp := resp + - string(char(integer('A') + ((integer(c) - integer('A') + key )) mod 26)); - else - resp := resp + string(c) - end; - end; - return resp + resp := ""; + if op = Operation.decode then key := k else key := (26 - k) end; + for i := 0 to len(s) - 1 do + c := cap(s[i]); + if (c >= 'A') & (c <= 'Z') then + resp := resp + + string(char(integer('A') + ((integer(c) - integer('A') + key )) mod 26)); + else + resp := resp + string(c) + end; + end; + return resp end C_D; procedure {public} Cipher(s:string;k:integer):string; var - i: integer; - resp: string; - n,c: char; + i: integer; + resp: string; + n,c: char; begin - return C_D(s,k,Operation.code) + return C_D(s,k,Operation.code) end Cipher; procedure {public} Decipher(s:string;k:integer):string; var - i: integer; - resp: string; - n,c: char; + i: integer; + resp: string; + n,c: char; begin - return C_D(s,k,Operation.decode) + return C_D(s,k,Operation.decode) end Decipher; var - txt,cipher,decipher: string; + txt,cipher,decipher: string; begin - txt := "HI";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2); - writeln(txt," -c-> ",cipher," -d-> ",decipher); - txt := "ZA";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2); - writeln(txt," -c-> ",cipher," -d-> ",decipher); - txt := "The five boxing wizards jump quickly"; - cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2); - writeln(txt," -c-> ",cipher," -d-> ",decipher) + txt := "HI";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2); + writeln(txt," -c-> ",cipher," -d-> ",decipher); + txt := "ZA";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2); + writeln(txt," -c-> ",cipher," -d-> ",decipher); + txt := "The five boxing wizards jump quickly"; + cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2); + writeln(txt," -c-> ",cipher," -d-> ",decipher) end Caesar. diff --git a/Task/Calculating-the-value-of-e/AArch64-Assembly/calculating-the-value-of-e.aarch64 b/Task/Calculating-the-value-of-e/AArch64-Assembly/calculating-the-value-of-e.aarch64 deleted file mode 100644 index 9a78341a45..0000000000 --- a/Task/Calculating-the-value-of-e/AArch64-Assembly/calculating-the-value-of-e.aarch64 +++ /dev/null @@ -1,41 +0,0 @@ -#include - -.globl main -.section .text - -/* - eulers constant is the sum of the - series Σ_0 ^ ∞ 1/n! = 1 + 1/1 + 1/2 + 1/2*3 ... -*/ - -main: - stp x29, x30, [sp, #-16]! - - fmov d0, #1.0 - fadd d0, d0, d0 // sum accumulator = 2 to start - - fmov d1, #1.0 // fraction value - fmov d4, #1.0 // permanent 1.0 - - mov x0, #16 // max step - mov x1, #1 // start value - - 1: - add x1, x1, #1 - - scvtf d2, x1 - fmul d1, d1, d2 - fdiv d3, d4, d1 - fadd d0, d0, d3 - - cmp x1, x0 - b.lt 1b - - adr x0, string - bl printf - - ldp x29, x30, [sp], 16 - ret - -.section .rodata -string: .asciz "euler's constant e ≈ %18.16f\n" diff --git a/Task/Calculating-the-value-of-e/ALGOL-68/calculating-the-value-of-e.alg b/Task/Calculating-the-value-of-e/ALGOL-68/calculating-the-value-of-e.alg index fac6fe1652..44a167fc1a 100644 --- a/Task/Calculating-the-value-of-e/ALGOL-68/calculating-the-value-of-e.alg +++ b/Task/Calculating-the-value-of-e/ALGOL-68/calculating-the-value-of-e.alg @@ -1,14 +1,14 @@ BEGIN # calculate an approximation to e # LONG REAL epsilon = 1.0e-15; - LONG INT f := 1; - LONG REAL e := 2; - LONG INT n := 2; + LONG INT fact := 1; + LONG REAL e := 2; + LONG INT n := 2; WHILE LONG REAL e0 = e; - f *:= n; - n +:= 1; - e +:= 1.0 / f; + fact *:= n; + n +:= 1; + e +:= 1.0 / fact; ABS ( e - e0 ) >= epsilon DO SKIP OD; print( ( "e = ", fixed( e, -17, 15 ), newline ) ) diff --git a/Task/Calculating-the-value-of-e/ALGOL-W/calculating-the-value-of-e.alg b/Task/Calculating-the-value-of-e/ALGOL-W/calculating-the-value-of-e.alg deleted file mode 100644 index 2e559bfec8..0000000000 --- a/Task/Calculating-the-value-of-e/ALGOL-W/calculating-the-value-of-e.alg +++ /dev/null @@ -1,16 +0,0 @@ -begin % calculate an approximation to e % - long real epsilon; - long real e0, e, f; - integer n; - epsilon := 1'-14; f := 1; e := n := 2; - while begin - e0 := e; - f := f * n; - n := n + 1; - e := e + 1.0 / f; - abs ( e - e0 ) >= epsilon - end do begin end; - write( I_w := 1, s_w := 0, r_format := "A", r_w := 16, r_d := 14 % <-- sets output formatting % - , "e = ", e, " after ", n - 1, " iterations" - ) -end. diff --git a/Task/Calculating-the-value-of-e/Ada/calculating-the-value-of-e.adb b/Task/Calculating-the-value-of-e/Ada/calculating-the-value-of-e.ada similarity index 100% rename from Task/Calculating-the-value-of-e/Ada/calculating-the-value-of-e.adb rename to Task/Calculating-the-value-of-e/Ada/calculating-the-value-of-e.ada diff --git a/Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark b/Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark deleted file mode 100644 index a344a4416c..0000000000 --- a/Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark +++ /dev/null @@ -1,22 +0,0 @@ -(import std.Range :range) -(import std.List) - -(let fact (fun (n acc) { - (if (> n 0) - (fact (- n 1) (* acc n)) - acc) })) - -(let r (range 1 18)) -(let p - (list:sum - (list:map - (list:reverse (r.asList)) - (fun (n) - (/ 1 (fact n 1)) )))) - -(import std.Math :abs) - -(let my_e (+ p 1)) -(print my_e) -(print math:e) -(assert (< (abs (- my_e math:e)) (toNumber "1e-15")) "computed e is near the math:e") diff --git a/Task/Calculating-the-value-of-e/BBC-BASIC/calculating-the-value-of-e.basic b/Task/Calculating-the-value-of-e/BBC-BASIC/calculating-the-value-of-e.basic deleted file mode 100644 index fd02c1168e..0000000000 --- a/Task/Calculating-the-value-of-e/BBC-BASIC/calculating-the-value-of-e.basic +++ /dev/null @@ -1,14 +0,0 @@ - @%=&1302 - EPSILON = 1.0E-15 - Fact = 1 - E = 2.0 - E0 = 0.0 - N% = 2 - WHILE ABS(E - E0) >= EPSILON - E0 = E - Fact *= N% - N% += 1 - E += 1.0 / Fact - ENDWHILE - PRINT "e = ";E - END diff --git a/Task/Calculating-the-value-of-e/Ballerina/calculating-the-value-of-e.ballerina b/Task/Calculating-the-value-of-e/Ballerina/calculating-the-value-of-e.ballerina deleted file mode 100644 index 126270884a..0000000000 --- a/Task/Calculating-the-value-of-e/Ballerina/calculating-the-value-of-e.ballerina +++ /dev/null @@ -1,17 +0,0 @@ -import ballerina/io; - -const EPSILON = 1e-15; - -public function main() { - int fact = 1; - float e = 2.0; - int n = 2; - while true { - float e0 = e; - fact *= n; - n += 1; - e += 1.0 / fact; - if (e - e0).abs() < EPSILON { break; } - } - io:println("e = ", e); -} diff --git a/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cob b/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cob deleted file mode 100644 index d20ba6e3fe..0000000000 --- a/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cob +++ /dev/null @@ -1,23 +0,0 @@ - IDENTIFICATION DIVISION. - PROGRAM-ID. euler. - DATA DIVISION. - WORKING-STORAGE SECTION. - 77 epsilon USAGE FLOAT-LONG VALUE IS 1.0E-15. - 77 fact USAGE IS BINARY-DOUBLE UNSIGNED VALUE IS 1. - 77 n USAGE IS BINARY-LONG UNSIGNED. - 77 e USAGE IS FLOAT-LONG VALUE IS 2.0. - 77 e0 USAGE IS FLOAT-LONG VALUE IS 0.0. - 01 result-message. - 03 FILLER PICTURE IS X(4) VALUE IS 'e = '. - 03 result-value PICTURE IS 9.9(18) USAGE IS DISPLAY. - PROCEDURE DIVISION. - PERFORM WITH TEST BEFORE VARYING n FROM 2 BY 1 - UNTIL FUNCTION ABS(e - e0) IS LESS THAN epsilon - MOVE e TO e0 - MULTIPLY n BY fact - COMPUTE e = e + 1.0 / fact - END-PERFORM. - MOVE e TO result-value. - DISPLAY result-message. - STOP RUN. - END PROGRAM euler. diff --git a/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol b/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol new file mode 100644 index 0000000000..6a72c6a31e --- /dev/null +++ b/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol @@ -0,0 +1,25 @@ + >>SOURCE FORMAT IS FIXED + IDENTIFICATION DIVISION. + PROGRAM-ID. EULER. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 EPSILON USAGE COMPUTATIONAL-2 VALUE 1.0E-15. + 01 FACT USAGE BINARY-DOUBLE UNSIGNED VALUE 1. + 01 N USAGE BINARY-INT UNSIGNED. + 01 E USAGE COMPUTATIONAL-2 VALUE 2.0. + 01 E0 USAGE COMPUTATIONAL-2 value 0.0. + 01 RESULT-MESSAGE. + 03 FILLER PIC X(4) VALUE 'e = '. + 03 RESULT-VALUE PIC 9.9(18) USAGE DISPLAY. + PROCEDURE DIVISION. + MAIN SECTION. + PERFORM + VARYING N FROM 2 BY 1 + UNTIL FUNCTION ABS(E - E0) < EPSILON + MOVE E TO E0 + COMPUTE FACT = FACT * N + COMPUTE E = E + 1.0 / FACT + END-PERFORM. + MOVE E TO RESULT-VALUE. + DISPLAY RESULT-MESSAGE. + STOP RUN. diff --git a/Task/Calculating-the-value-of-e/Delphi/calculating-the-value-of-e.pas b/Task/Calculating-the-value-of-e/Delphi/calculating-the-value-of-e.delphi similarity index 100% rename from Task/Calculating-the-value-of-e/Delphi/calculating-the-value-of-e.pas rename to Task/Calculating-the-value-of-e/Delphi/calculating-the-value-of-e.delphi diff --git a/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac b/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac index d51b3a4a5e..84c31ea9eb 100644 --- a/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac +++ b/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac @@ -1,6 +1,5 @@ [Calculate e] [EDSAC program, Initial Orders 2] - [2024-12-25 Bug fix: ensure sandwich bit in 35-bit constant is 0] [Library subroutine M3. Prints header and is then overwritten] [Here, last character sets teleprinter to figures] @@ -30,8 +29,6 @@ GK [set @ (theta) for relative addresses] [0] PF PF [build sum 4*(1/3! + 1/4! + 1/5! + ...)] [2] PF PF [term in sum] - T4#ZPF [load time: clear whole of #4, including sandwich bit] - T4Z [load time: resume normal loading] [4] PD PF [2^-34, stop when term < this] [6] PF [divisor] [7] IF [1/2] diff --git a/Task/Calculating-the-value-of-e/EasyLang/calculating-the-value-of-e.easy b/Task/Calculating-the-value-of-e/EasyLang/calculating-the-value-of-e.easy index 2c5eb9d8bf..a233fa0c49 100644 --- a/Task/Calculating-the-value-of-e/EasyLang/calculating-the-value-of-e.easy +++ b/Task/Calculating-the-value-of-e/EasyLang/calculating-the-value-of-e.easy @@ -1,11 +1,11 @@ -numfmt 0 15 +numfmt 0 5 fact = 1 n = 2 e = 2 -while e - e0 > 1e-15 - e0 = e - fact = fact * n - e += 1 / fact - n += 1 +while abs (e - e0) > 0.0001 + e0 = e + fact = fact * n + n += 1 + e += 1 / fact . print e diff --git a/Task/Calculating-the-value-of-e/Emacs-Lisp/calculating-the-value-of-e.el b/Task/Calculating-the-value-of-e/Emacs-Lisp/calculating-the-value-of-e.l similarity index 100% rename from Task/Calculating-the-value-of-e/Emacs-Lisp/calculating-the-value-of-e.el rename to Task/Calculating-the-value-of-e/Emacs-Lisp/calculating-the-value-of-e.l diff --git a/Task/Calculating-the-value-of-e/Euphoria/calculating-the-value-of-e.eu b/Task/Calculating-the-value-of-e/Euphoria/calculating-the-value-of-e.eu deleted file mode 100644 index 19492b0e56..0000000000 --- a/Task/Calculating-the-value-of-e/Euphoria/calculating-the-value-of-e.eu +++ /dev/null @@ -1,23 +0,0 @@ -include std/math.e - --- native -? E -? exp(1) - --- calculated -atom n, n1 -atom e1, e - -n = 1.0 -n1 = 1.0 -e1 = 0.0 -e = 1.0 - -while (e != e1) do - e1 = e - e += (1.0 / n) - n1 += 1 - n *= n1 -end while - -? e diff --git a/Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e-2.f b/Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e-2.f deleted file mode 100644 index 6501cc105a..0000000000 --- a/Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e-2.f +++ /dev/null @@ -1,32 +0,0 @@ -program calculate_e - use iso_fortran_env, only: ep => real128 - implicit none - - integer :: n - real(kind=ep) :: sum_e, term, eps, c, y, t - real(kind=ep), parameter :: e_ref = 2.7182818284590452353602874713526624_ep - - sum_e = 0.0_ep - c = 0.0_ep - n = 0 - eps = epsilon(1.0_ep) - - do - term = 1.0_ep / gamma(real(n + 1, kind=ep)) - if (term < eps) exit - - ! Kahan summation to keep precision - y = term - c - t = sum_e + y - c = (t - sum_e) - y - sum_e = t - - n = n + 1 - end do - - write(*,'(a,t45,a)') 'Literature supplied value = ', & - '2.7182818284590452353602874713526624' - write(*,'(a,t41,F40.34)') 'Approximation of e using Taylor series = ', sum_e - write(*,'(a,t45,EN0.5)') 'Variance = ', abs(sum_e - e_ref) - write(*,*) 'Converged after', n, 'terms.' -end program calculate_e diff --git a/Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e-1.f b/Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e.f similarity index 100% rename from Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e-1.f rename to Task/Calculating-the-value-of-e/Fortran/calculating-the-value-of-e.f diff --git a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs index d43cad0693..e7ff6b2acd 100644 --- a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs +++ b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs @@ -1,7 +1,8 @@ ------ APPROXIMATION OF E OBTAINED AFTER N ITERATIONS ---- eApprox :: Int -> Double -eApprox n = sum . map (1 /) $ scanl (*) 1 [1..n] +eApprox n = + (sum . take n) $ (1 /) <$> scanl (*) 1 [1 ..] --------------------------- TEST ------------------------- main :: IO () diff --git a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs index a13155388a..3b9b856f95 100644 --- a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs +++ b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs @@ -1,4 +1,16 @@ -eApprox n = snd $ foldr f (1, 1) [n, pred n .. 1] - where - f x (fl, e) = - let y = fl * x in (y, e + 1 / y) +{-# LANGUAGE TupleSections #-} + +------------------- APPROXIMATIONS TO E ------------------ + +approximatEs :: [Double] +approximatEs = + fst + <$> iterate + ( \(e, (i, n)) -> + (,) . (e +) . (1 /) <*> (succ i,) $ i * n + ) + (1, (1, 1)) + +--------------------------- TEST ------------------------- +main :: IO () +main = print $ approximatEs !! 17 diff --git a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-4.hs b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-4.hs deleted file mode 100644 index 3b9b856f95..0000000000 --- a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-4.hs +++ /dev/null @@ -1,16 +0,0 @@ -{-# LANGUAGE TupleSections #-} - -------------------- APPROXIMATIONS TO E ------------------ - -approximatEs :: [Double] -approximatEs = - fst - <$> iterate - ( \(e, (i, n)) -> - (,) . (e +) . (1 /) <*> (succ i,) $ i * n - ) - (1, (1, 1)) - ---------------------------- TEST ------------------------- -main :: IO () -main = print $ approximatEs !! 17 diff --git a/Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-1.jl b/Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-1.julia similarity index 100% rename from Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-1.jl rename to Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-1.julia diff --git a/Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-2.jl b/Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-2.julia similarity index 100% rename from Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-2.jl rename to Task/Calculating-the-value-of-e/Julia/calculating-the-value-of-e-2.julia diff --git a/Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e-2.kts b/Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e-2.kts deleted file mode 100644 index 947bdcd030..0000000000 --- a/Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e-2.kts +++ /dev/null @@ -1,7 +0,0 @@ -fun main() { - val e = (1..17).runningFold(1L, Long::times) - .asReversed() // summing smaller values first improves accuracy - .sumOf { 1.0 / it } - println(e) - println(e == kotlin.math.E) -} diff --git a/Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e-1.kts b/Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e.kotlin similarity index 100% rename from Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e-1.kts rename to Task/Calculating-the-value-of-e/Kotlin/calculating-the-value-of-e.kotlin diff --git a/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur b/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur index b56040b204..1202af1ca2 100644 --- a/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur +++ b/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur @@ -1,14 +1,17 @@ mode divMaxScale = 104 -val epsilon = 1e-104 +val .epsilon = 1.0e-104 -var e = 2 +var .e = 2 -for fact, n = 1, 2 ; ; n += 1 { - val e0 = e - fact *= n - e += 1 / fact - if abs(e - e0) < epsilon: break +for .fact, .n = 1, 2 ; ; .n += 1 { + val .e0 = .e + .fact x= .n + .e += 1 / .fact + if abs(.e - .e0) < .epsilon: break } -writeln "e = ", e +writeln ".e = ", .e + +# compare to built-in constant e +writeln " e = ", e diff --git a/Task/Calculating-the-value-of-e/Liberty-BASIC/calculating-the-value-of-e.basic b/Task/Calculating-the-value-of-e/Liberty-BASIC/calculating-the-value-of-e.basic deleted file mode 100644 index 83db0832f4..0000000000 --- a/Task/Calculating-the-value-of-e/Liberty-BASIC/calculating-the-value-of-e.basic +++ /dev/null @@ -1,30 +0,0 @@ -' Cálculo de e con alta precisión visual usando Brother's formula -eFLB = exp(1) -euler = 0 - -print "Primeras 10 aproximaciones con Fórmula de Brother" -print -print "Iter.", "Valor (14 decim)", "Error" -print "----------------------------------------------------------" - -for n = 0 to 10 - numerador = 2*n + 2 - denominador = factorial(2*n + 1) - termino = numerador / denominador - euler = euler + termino - diferencia = abs(euler - eFLB) - print n, using("#.##############", euler), diferencia ' Ver 14 decimales -next n - -print "----------------------------------------------------------" -print -print "Valor de la función LB exp(1): "; using("#.##############", eFLB) -end - -function factorial(num) - f = 1 - for i = 1 to num - f = f*i - next i - factorial = f -end function diff --git a/Task/Calculating-the-value-of-e/M2000-Interpreter/calculating-the-value-of-e-1.m2000 b/Task/Calculating-the-value-of-e/M2000-Interpreter/calculating-the-value-of-e-1.m2000 index 25ce9e9897..3971cc6e8c 100644 --- a/Task/Calculating-the-value-of-e/M2000-Interpreter/calculating-the-value-of-e-1.m2000 +++ b/Task/Calculating-the-value-of-e/M2000-Interpreter/calculating-the-value-of-e-1.m2000 @@ -1,22 +1,17 @@ Module FindE { - Function comp_e (n, decimals ){ - unit=n:n/=decimals:For i=decimals-1 to 1:n=Unit+n/i:Next i:=n - } - p=1000 - k=comp_e(biginteger("1"+string$("0", p)), p) - string t1=str$(k), t=left$(t1, 39) - if len(t1)>39 then - for i=40 to len(t1) step 40 - t+={ - }+mid$(t1, i, 40) - next - end if - all=(comp_e(1@, 28))+" Decimal"+{ - }+(comp_e(1, 19))+" Double"+{ - }+(comp_e(1~, 11))+" Float"+{ - }+(comp_e(1#, 8))+" Currency"+{ - }+ left$(t,1)+locale$(14)+mid$(t,2) +" Arbitrary-precision :"+p - Clipboard all - Report all + Function comp_e (n){ + \\ max 28 for decimal (in one line with less spaces) + n/=28:For i=27to 1:n=1+n/i:Next i:=n + } + Clipboard Str$(comp_e(1@),"")+" Decimal"+{ + }+Str$(comp_e(1),"")+" Double"+{ + }+Str$(comp_e(1~),"")+" Float"+{ + }+Str$(comp_e(1#),"")+" Currency"+{ + } + Report Str$(comp_e(1@),"")+" Decimal"+{ + }+Str$(comp_e(1),"")+" Double"+{ + }+Str$(comp_e(1~),"")+" Float"+{ + }+Str$(comp_e(1#),"")+" Currency"+{ + } } FindE diff --git a/Task/Calculating-the-value-of-e/Maxima/calculating-the-value-of-e.maxima b/Task/Calculating-the-value-of-e/Maxima/calculating-the-value-of-e.maxima deleted file mode 100644 index d86f7a0058..0000000000 --- a/Task/Calculating-the-value-of-e/Maxima/calculating-the-value-of-e.maxima +++ /dev/null @@ -1,4 +0,0 @@ -block(cfexpand([2,1,2,1,1,4,1,1,6,1,1,8,1,1,10,1,1,12,1,1,14]),float(%%[1,1]/%%[2,1])); - -/* Comparing with built-in constant */ -%e,numer; diff --git a/Task/Calculating-the-value-of-e/Nu/calculating-the-value-of-e.nu b/Task/Calculating-the-value-of-e/Nu/calculating-the-value-of-e.nu deleted file mode 100644 index 43b7cf309b..0000000000 --- a/Task/Calculating-the-value-of-e/Nu/calculating-the-value-of-e.nu +++ /dev/null @@ -1 +0,0 @@ -let e = do {|n| (1 / $n + 1) ** $n } (2. ** 52) diff --git a/Task/Calculating-the-value-of-e/OCaml/calculating-the-value-of-e.ml b/Task/Calculating-the-value-of-e/OCaml/calculating-the-value-of-e.ocaml similarity index 100% rename from Task/Calculating-the-value-of-e/OCaml/calculating-the-value-of-e.ml rename to Task/Calculating-the-value-of-e/OCaml/calculating-the-value-of-e.ocaml diff --git a/Task/Calculating-the-value-of-e/Oberon-07/calculating-the-value-of-e.oberon b/Task/Calculating-the-value-of-e/Oberon-07/calculating-the-value-of-e.oberon deleted file mode 100644 index 82212e18c0..0000000000 --- a/Task/Calculating-the-value-of-e/Oberon-07/calculating-the-value-of-e.oberon +++ /dev/null @@ -1,25 +0,0 @@ -MODULE CalculateE; -IMPORT Out; - -VAR - fact,n : INTEGER; - e,e0 : REAL; - -BEGIN - fact := 1; - e := 2.0; - e0 := 0.0; - n := 2; - - WHILE e > e0 DO - e0 := e; - fact := fact * n; - INC(n); - e := e + 1.0 / FLT(fact) - END; - - Out.String("e = ");Out.Real(e, 0); - Out.String(", ");Out.Int(n,0); - Out.String(" iterations");Out.Ln - -END CalculateE. diff --git a/Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas b/Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas deleted file mode 100644 index e59efe7c9a..0000000000 --- a/Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas +++ /dev/null @@ -1,19 +0,0 @@ -function MyExp(x: real): real; -const eps = 1e-15; -begin - var y := 1.0; - var s := y; - var i := 1; - while y > eps do - begin - y *= x / i; - s += y; - i += 1; - end; - Result := s; -end; - -begin - Println(MyExp(1)); - Println(Exp(1)); -end. diff --git a/Task/Calculating-the-value-of-e/Phix/calculating-the-value-of-e.phix b/Task/Calculating-the-value-of-e/Phix/calculating-the-value-of-e.phix index 0dd9865010..01e06fe609 100644 --- a/Task/Calculating-the-value-of-e/Phix/calculating-the-value-of-e.phix +++ b/Task/Calculating-the-value-of-e/Phix/calculating-the-value-of-e.phix @@ -1,13 +1,15 @@ -with javascript_semantics -requires("1.0.2") -- (builtin constant E renamed as EULER) -atom e0 = 0, e = 2, n = 0, fact = 1 -while abs(e-e0)>=1e-15 do - e0 = e - n += 1 - fact *= 2*n*(2*n+1) - e += (2*n+2)/fact -end while -printf(1,"Computed e = %.15f\n",e) -printf(1," Real e = %.15f\n",EULER) -printf(1," Error = %g\n",EULER-e) -printf(1,"Number of iterations = %d\n",n) +(phixonline)--> + with javascript_semantics + requires("1.0.2") -- (builtin constant E renamed as EULER) + atom e0 = 0, e = 2, n = 0, fact = 1 + while abs(e-e0)>=1e-15 do + e0 = e + n += 1 + fact *= 2*n*(2*n+1) + e += (2*n+2)/fact + end while + printf(1,"Computed e = %.15f\n",e) + printf(1," Real e = %.15f\n",EULER) + printf(1," Error = %g\n",EULER-e) + printf(1,"Number of iterations = %d\n",n) + + return repeat(' ',left)&s&repeat(' ',right) + + return repeat(' ',left)&upper(s)&repeat(' ',right) + + initialSymEntry("integer", S_Type,"TI",opInt, E_none) -- #01 / 0b0001 integer + + Alias("INTEGER",symlimit) + + procedure tt_stringA(sequence text, integer alias) + tt_string(text,-2) + tt[pcurr] = alias + end procedure + + global constant T_include = 596 tt_stringF("include",T_include) + + tt_stringA("INCLUDE",T_include) + + Ch = find(Ch,escchar) + + Ch = find(lower(Ch),escchar) + + with javascript_semantics + constant year = 1969 -include builtins\timedate.e + include builtins\timedate.e -function centre(string s, integer width) - integer gap = width-length(s), - left = floor(gap/2), - right = gap-left - return repeat(' ',left) & s & repeat(' ',right) -end function + function centre(string s, integer width) + integer gap = width-length(s), + left = floor(gap/2), + right = gap-left + return repeat(' ',left) & s & repeat(' ',right) + end function -function one_month(integer year, integer month, bool sun_to_sat) - string weekdays = iff(sun_to_sat?"Su Mo Tu We Th Fr Sa" - :"Mo Tu We Th Fr Sa Su"), - line = repeat(' ',20) - sequence ldm = adjust_timedate(iff(month=12?{year+1,1,1,0,0,0,0,0} - :{year,month+1,1,0,0,0,0,0}), - timedelta(days:=-1)), - res = {centre(format_timedate(ldm,"Mmmm"),20),weekdays} - integer dow = day_of_week(year,month,1) - if sun_to_sat then dow = remainder(dow,7)+1 end if - integer lastday = ldm[DT_DAY], - p = dow*3-2 - for d=1 to lastday do - line[p..p+1] = sprintf("%2d",d) - p += 3 - if dow=7 or d=lastday then - res = append(res,line) - line = repeat(' ',20) - dow = 1 - p = 1 - else - dow += 1 - end if - end for - return res -end function + function one_month(integer year, integer month, bool sun_to_sat) + string weekdays = iff(sun_to_sat?"Su Mo Tu We Th Fr Sa" + :"Mo Tu We Th Fr Sa Su"), + line = repeat(' ',20) + sequence ldm = adjust_timedate(iff(month=12?{year+1,1,1,0,0,0,0,0} + :{year,month+1,1,0,0,0,0,0}), + timedelta(days:=-1)), + res = {centre(format_timedate(ldm,"Mmmm"),20),weekdays} + integer dow = day_of_week(year,month,1) + if sun_to_sat then dow = remainder(dow,7)+1 end if + integer lastday = ldm[DT_DAY], + p = dow*3-2 + for d=1 to lastday do + line[p..p+1] = sprintf("%2d",d) + p += 3 + if dow=7 or d=lastday then + res = append(res,line) + line = repeat(' ',20) + dow = 1 + p = 1 + else + dow += 1 + end if + end for + return res + end function -procedure print_calendar(integer year, width, bool sun_to_sat=false) - sequence months = repeat(0,12) - integer wide = floor((width+2)/22) - printf(1,centre("[Spot Reserved For Snoopy]",width)&"\n") - printf(1,centre(sprintf("%d",year),width)&"\n") - for month=1 to 12 do - months[month] = one_month(year,month,sun_to_sat) - end for - for month=1 to 12 by wide do - for k=1 to 9 do -- (more than enough) - integer any = 0 - string line = "" - for j=0 to wide-1 do - if length(line) then - line &= " " - end if - if k>length(months[month+j]) then - line &= repeat(' ',20) - else - line &= months[month+j][k] - any = 1 - end if - end for - if any=0 then exit end if - printf(1,centre(line,width)&"\n") - end for - end for -end procedure + procedure print_calendar(integer year, width, bool sun_to_sat=false) + sequence months = repeat(0,12) + integer wide = floor((width+2)/22) + printf(1,centre("[Spot Reserved For Snoopy]",width)&"\n") + printf(1,centre(sprintf("%d",year),width)&"\n") + for month=1 to 12 do + months[month] = one_month(year,month,sun_to_sat) + end for + for month=1 to 12 by wide do + for k=1 to 9 do -- (more than enough) + integer any = 0 + string line = "" + for j=0 to wide-1 do + if length(line) then + line &= " " + end if + if k>length(months[month+j]) then + line &= repeat(' ',20) + else + line &= months[month+j][k] + any = 1 + end if + end for + if any=0 then exit end if + printf(1,centre(line,width)&"\n") + end for + end for + end procedure -print_calendar(year,80) -printf(1,join(repeat("1234567890",8),"")&"\n") -print_calendar(year,132,true) -printf(1,join(repeat("1234567890",13),"")&"12\n") + print_calendar(year,80) + printf(1,join(repeat("1234567890",8),"")&"\n") + print_calendar(year,132,true) + printf(1,join(repeat("1234567890",13),"")&"12\n") + + without js -- not from a browser, mate! + string {libname,funcname} = iff(platform()=WINDOWS?{"user32","CharLowerA"}:{"libc","tolower"}) + atom lib = open_dll(libname) + integer func = define_c_func(lib,funcname,{C_INT},C_INT) + if func=-1 then + ?{{lower('A')}} -- (you don't //have// to crash!) + else + ?c_func(func,{'A'}) -- ('A'==65) + end if + + without js -- (no class in p2js) + class test + string msg = "this is a test" + procedure show() ?this.msg end procedure + procedure inst() ?"this is dynamic" end procedure + end class + test t = new() + t.show() -- prints "this is a test" + t.inst() -- prints "this is dynamic" + t.inst = t.show + t.inst() -- prints "this is a test" + " << to_snake_case(text) << std::endl; - } - - std::cout << std::endl; - std::cout << std::setw(48) << "=== To camelCase ===" << std::endl; - for ( std::string text : variable_names ) { - std::cout << std::setw(34) << text << " --> " << to_camel_case(text) << std::endl; - } -} diff --git a/Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs b/Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs deleted file mode 100644 index 672207f79b..0000000000 --- a/Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -public static class CamelCaseAndSnakeCase -{ - public static void Main(string[] args) - { - List variableNames = new List - { - "snakeCase", "snake_case", "variable_10_case", "variable10Case", - "ergo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces " - }; - - Console.WriteLine($"{"=== To snake_case ===",48}"); - foreach (string text in variableNames) - { - Console.WriteLine($"{text,34} --> {ToSnakeCase(text)}"); - } - - Console.WriteLine(); - Console.WriteLine($"{"=== To camelCase ===",48}"); - foreach (string text in variableNames) - { - Console.WriteLine($"{text,34} --> {ToCamelCase(text)}"); - } - } - - private static string ToSnakeCase(string aCamel) - { - aCamel = aCamel.Trim().Replace(SPACE, UNDERSCORE).Replace(HYPHEN, UNDERSCORE); - StringBuilder snake = new StringBuilder(); - bool first = true; - foreach (char ch in aCamel) - { - if (first) - { - snake.Append(ch); - first = false; - } - else if (!first && char.IsUpper(ch)) - { - if (snake.ToString().EndsWith(UNDERSCORE)) - { - snake.Append(char.ToLower(ch)); - } - else - { - snake.Append(UNDERSCORE + char.ToLower(ch)); - } - } - else - { - snake.Append(ch); - } - } - return snake.ToString(); - } - - private static string ToCamelCase(string aSnake) - { - aSnake = aSnake.Trim().Replace(SPACE, UNDERSCORE).Replace(HYPHEN, UNDERSCORE); - StringBuilder camel = new StringBuilder(); - bool underscore = false; - foreach (char ch in aSnake) - { - if (ch.ToString().Equals(UNDERSCORE)) - { - underscore = true; - } - else if (underscore) - { - camel.Append(char.ToUpper(ch)); - underscore = false; - } - else - { - camel.Append(ch); - } - } - return camel.ToString(); - } - - private static readonly string SPACE = " "; - private static readonly string UNDERSCORE = "_"; - private static readonly string HYPHEN = "-"; -} diff --git a/Task/Camel-case-and-snake-case/Crystal/camel-case-and-snake-case.cr b/Task/Camel-case-and-snake-case/Crystal/camel-case-and-snake-case.cr deleted file mode 100644 index 38a8fc567f..0000000000 --- a/Task/Camel-case-and-snake-case/Crystal/camel-case-and-snake-case.cr +++ /dev/null @@ -1,6 +0,0 @@ -["snakeCase", "snake_case", "variable_10_case", "variable10Case", "ɛrgo rE tHis", - "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces "].each do |ident| - print ident, " => " - print ident.strip.gsub(/[ -]/, "_").camelcase, ", " - puts ident.strip.gsub(/[ -]/, "_").underscore -end diff --git a/Task/Camel-case-and-snake-case/Delphi/camel-case-and-snake-case.pas b/Task/Camel-case-and-snake-case/Delphi/camel-case-and-snake-case.delphi similarity index 100% rename from Task/Camel-case-and-snake-case/Delphi/camel-case-and-snake-case.pas rename to Task/Camel-case-and-snake-case/Delphi/camel-case-and-snake-case.delphi diff --git a/Task/Camel-case-and-snake-case/EasyLang/camel-case-and-snake-case.easy b/Task/Camel-case-and-snake-case/EasyLang/camel-case-and-snake-case.easy deleted file mode 100644 index 52eb2646ce..0000000000 --- a/Task/Camel-case-and-snake-case/EasyLang/camel-case-and-snake-case.easy +++ /dev/null @@ -1,69 +0,0 @@ -func$ strip s$ . - a = 1 - while substr s$ a 1 = " " - a += 1 - . - b = len s$ - while substr s$ b 1 = " " - b -= 1 - . - return substr s$ a (b - a + 1) -. -func$ toupper c$ . - c = strcode c$ - if c >= 97 and c <= 122 - c$ = strchar (c - 32) - . - return c$ -. -func$ tolower c$ . - c = strcode c$ - if c >= 65 and c <= 90 - c$ = strchar (c + 32) - . - return c$ -. -func isupper c$ . - c = strcode c$ - if c >= 65 and c <= 90 - return 1 - . -. -delim$ = "_- " -func$ snakecase s$ . - s$ = strip s$ - for c$ in strchars s$ - if isupper c$ = 1 and prev$ <> "" - if strpos delim$ prev$ = 0 - r$ &= "_" - . - r$ &= tolower c$ - else - r$ &= c$ - . - prev$ = c$ - . - return r$ -. -func$ camelcase s$ . - s$ = strip s$ - prev$ = "x" - for c$ in strchars s$ - if strpos delim$ prev$ <> 0 - r$ &= toupper c$ - elif strpos delim$ c$ = 0 - r$ &= c$ - . - prev$ = c$ - . - return r$ -. -test$[] = [ "snakeCase" "snake_case" "variable_10_case" "variable10Case" "ɛrgo rE tHis" "hurry-up-joe!" "c://my-docs/happy_Flag-Day/12.doc" " spaces " ] -print "=== To snake_case ===" -for s$ in test$[] - print s$ & " -> " & snakecase s$ -. -print "\n=== To camelCase ===" -for s$ in test$[] - print s$ & " -> " & camelcase s$ -. diff --git a/Task/Camel-case-and-snake-case/Ed/camel-case-and-snake-case.ed b/Task/Camel-case-and-snake-case/Ed/camel-case-and-snake-case.ed deleted file mode 100644 index cd21f1e1b7..0000000000 --- a/Task/Camel-case-and-snake-case/Ed/camel-case-and-snake-case.ed +++ /dev/null @@ -1,7 +0,0 @@ -# by Artyom Bologov -H -g/.*/s/\([A-Z]\)/_&/g -g/^\<_*/s/// -g/^_*\>/s/// -,p -Q diff --git a/Task/Camel-case-and-snake-case/Fortran/camel-case-and-snake-case.f b/Task/Camel-case-and-snake-case/Fortran/camel-case-and-snake-case.f deleted file mode 100644 index 8d54399adc..0000000000 --- a/Task/Camel-case-and-snake-case/Fortran/camel-case-and-snake-case.f +++ /dev/null @@ -1,291 +0,0 @@ -! Camel case and snake case -! -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.04 -! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! -! -! U.B., August 2025 -! -program CaseConverter - -implicit none - -! sep is a marker to separate words within given strings. -! Selected "§" because this is never part of a legit text. -! -character, parameter :: sep='§' - -character (len=:), allocatable :: testWord - - -print *, ' ***** Converting test strings to Snake Case *****' - -testWord = 'snakeCase' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = 'snake_case' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = 'variable_10_case' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = 'variable10Case' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = 'ɛrgo rE tHis' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = 'hurry-up-joe!' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = 'c://my-docs/happy_Flag-Day/12.doc' -call printResult (testWord, toSnakeCase (testWord)) - -testWord = ' spaces ' -call printResult (testWord, toSnakeCase (testWord)) - -print * -print *, ' ***** Converting test strings to Camel Case *****' - -testWord = 'snakeCase' -call printResult ( testWord, toCamelCase (testWord) ) - -testWord = 'snake_case' -call printResult ( testWord, toCamelCase (testWord) ) - -testWord = 'variable_10_case' -call printResult ( testWord, toCamelCase (testWord) ) - -testWord = 'variable10Case' -call printResult ( testWord, toCamelCase (testWord) ) - -testWord = 'ɛrgo rE tHis' -call printResult (testWord, toCamelCase(testWord)) - -testWord = 'hurry-up-joe!' -call printResult ( testWord, toCamelCase (testWord) ) - -testWord = 'c://my-docs/happy_Flag-Day/12.doc' -call printResult ( testWord, toCamelCase (testWord) ) - -testWord = ' spaces ' -call printResult ( testWord, toCamelCase (testWord) ) - - - - -contains - - -! ---------------------------------------------------------- -! print with variable format to display the greek "ɛ" -! and the following text positioned correctly. -! Letter "ɛ" uses 2 bytes so len("ɛ") = 2 but ulen("ɛ") = 1 -! ---------------------------------------------------------- - -subroutine printResult (a,b) -character*(*), intent(in) :: a,b -character (len=100) ::fmt -write (fmt, *) '(A', 34+ (len(a)-ulen(a)) ,', " => ",A)' -print fmt, a, b - -end subroutine printResult - - -!--------------------------------------- -! change ASCII a...z to upper case a...z -!--------------------------------------- -function toupper (c) result(retc) - -character ::c -character :: retc - -if (c >='a' .and. c <= 'z') then - retc = achar (iachar('A') + (iachar(c)-iachar('a'))) -else - retc = c -end if - -end function toupper - -!--------------------------------------- -! change ASCII A...Z to lower case a...z -!--------------------------------------- -function tolower (c) result(retc) - -character ::c -character :: retc - -if (c >='A' .and. c <= 'Z') then ! is upper case - retc = achar (iachar('a') + (iachar(c)-iachar('A'))) -else - retc = c -end if - -end function tolower - -!--------------------------------------------------------------------------------- -! Scan input text, mark all positions between distinct words within the text -! so that later in the actual conversion these points can be rewritten accordingly. -!--------------------------------------------------------------------------------- -function prepare (txt) result (newtext) - -character (len=*), intent (in) :: txt -character (len=:), allocatable :: text, newtext -integer :: ip1, ip2, ip3, l -character :: beginword - - -newtext=''; - -! First remove leading and trailing spaces -text = trim (txt) -text = adjustl (text) -text = trim (text) -l = len_trim(text) - -ip1 = 1 -ip2 = 2 -ip3 = 1 -do while (ip2 <= l) - if (text(ip2:ip2) >= 'A' .and. text(ip2:ip2) <='Z' ) then ! upcase letter indicates beginning of a word - newtext = newtext(:len_trim(newtext)) // text(ip1:ip2-1) // sep - ip1 = ip2 - ip2 = ip1+1 - else if (text(ip2:ip2) .eq. '_' & - .or. text(ip2:ip2) .eq. '-' & - .or. text(ip2:ip2) .eq. ' ' ) then ! Separator is behind current word, new word following. - if (ip2 .lt. l) then ! ip2+1 still inside text - beginword = tolower (text(ip2+1:ip2+1)) - newtext = newtext(:len_trim(newtext)) // text (ip1:ip2-1) // sep // beginword - else - ! separator at ip2 is last character of text. Just drop it. - newtext = newtext(:len_trim(newtext)) // text (ip1:ip2-1) - endif - ip1 = ip2+2 ! skip separator and begin of next word - ip2 = ip1 - else - ip2 = ip2 + 1 - end if -end do - -newtext = newtext(:len_trim(newtext)) // text(ip1:) - -end function prepare - -!----------------------------------- -! Convert prepared text to CamelCase -!----------------------------------- -function toCamelCase (txt) result(newtext) -! -! 1st char is lowercase, all spaces removed and word beginnings upperCase -! -character (len=*), intent (in) :: txt -character (:), allocatable :: text, newtext -integer :: ip, l -character :: beginword - -newtext = '' -text = prepare (txt) - -l = len_trim(text) -newtext = newtext(:len_trim(newtext)) // tolower (text(1:1)) - -ip = 2 - -do while (ip <= l) - if (text(ip:ip) .eq. sep) then - ip = ip + 1 ! skip the separator - if (ip ( int(Z'C0') + 1)) .and. ( ich < int(Z'E0') )) THEN - retlen=2 - else if ( ich < int(Z'F0') ) THEN - retlen=3 - else if ( ich <= int(Z'F4') ) THEN - retlen=4 - else - retlen=1 !assume we process larger seqences, 1 by 1 bytes - end if -end function - - -end program diff --git a/Task/Camel-case-and-snake-case/FreeBASIC/camel-case-and-snake-case.basic b/Task/Camel-case-and-snake-case/FreeBASIC/camel-case-and-snake-case.basic deleted file mode 100644 index 3ebe202ce2..0000000000 --- a/Task/Camel-case-and-snake-case/FreeBASIC/camel-case-and-snake-case.basic +++ /dev/null @@ -1,65 +0,0 @@ -Function isDigit(ch As String) As Boolean - Return ch >= "0" And ch <= "9" -End Function - -Function to_snake_case(s As String) As String - Dim As Integer l = Len(s) - Dim As String snake = Trim(s), tmp = snake - - For i As Integer = 1 To Len(snake) - If isDigit(Mid(snake, i, 1)) Then - Continue For - Elseif Instr(Mid(snake, i, 1), " ") Then - Mid(snake, i) = "_" - Continue For - Elseif Instr(Mid(snake, i, 1), Any "\:/-_!.") Then - Continue For - Elseif Mid(snake, i, 1) = Ucase(Mid(snake, i, 1)) Then - tmp = Lcase(Mid(snake, i,1)) - Mid(snake, i) = "_" - snake = Left(snake, i) & tmp & Mid(snake, i+1) - End If - Next i - Return snake -End Function - -Function toCamelCase(s As String) As String - Dim As Integer l = Len(s) - Dim As String camel = Trim(s), tmp = camel - - For i As Integer = 1 To Len(camel) - If Instr(Mid(camel, i, 1), Any ":/!.") Then - Continue For - Elseif Instr(Mid(camel, i, 1), Any " _-") Then - camel = Left(camel, i-1) & Ucase(Mid(camel, i+1,1)) & Mid(camel, i+2) - End If - Next i - Return camel -End Function - -Dim Shared tests(1 To ...) As String*33 => {_ -"snakeCase", "snake_case", "variable_10_case", "variable10Case", _ -"\u025brgo rE tHis", "ergo rE tHis", "hurry-up-joe!", _ -"c://my-docs/happy_Flag-Day/12.doc", " spaces "} - -Sub test0(title As String, fn As String) - Print title - For i As Integer = 1 To Ubound(tests) - Dim As String texto = tests(i) & " ===> " & to_snake_case(tests(i)) - Locate i+1, 41 - Len(texto) / 2 : Print texto - Next i -End Sub - -Sub test1(title As String, fn As String) - Print title - For i As Integer = 1 To Ubound(tests) - Dim As String texto = tests(i) & " ===> " & toCamelCase(tests(i)) - Locate i+12, 41 - Len(texto) / 2 : Print texto - Next i -End Sub - -test0 "to_snake_case:", "to_snake_case" -Print -test1 "toCamelCase:", "toCamelCase" - -Sleep diff --git a/Task/Camel-case-and-snake-case/FutureBasic/camel-case-and-snake-case-1.basic b/Task/Camel-case-and-snake-case/FutureBasic/camel-case-and-snake-case-1.basic deleted file mode 100644 index 3956f8db63..0000000000 --- a/Task/Camel-case-and-snake-case/FutureBasic/camel-case-and-snake-case-1.basic +++ /dev/null @@ -1,47 +0,0 @@ -include "NSLog.incl" -local fn snake_toCamel( s as CFStringRef ) as CFStringRef - long r,f - s = fn StringByTrimmingCharactersInSet( s, fn CFCharacterSetGetPredefined(_kCFCharacterSetWhitespace )) - for r = 1 to len(s)-2 - f = instr(0, @"_- ", mid(s, r, 1)) - if f <> NSNotFound - s = fn stringwithformat(@"%@%@%@", left( s, r ), ucase(mid(s,r+1,1)), mid(s,r+2)) - end if - next -end fn = s - -local fn CamelTo_snake( s as CFStringRef ) as CFStringRef - long r,f - s = fn StringByTrimmingCharactersInSet( s, fn CFCharacterSetGetPredefined(_kCFCharacterSetWhitespace )) - s = fn StringByReplacingOccurrencesOfString( s, @" ", @"_") - s = fn StringByReplacingOccurrencesOfString( s, @"-", @"_") - for r = 1 to len(s)-2 - f = instr(0, @"ABCDEFGHIJKLMNOPQRSTUVWXYZ", mid(s, r, 1)) - if f <> NSNotFound - if fn StringIsEqual(@"_", mid(s, r-1, 1)) then continue - s = fn stringwithformat(@"%@%@%@", left( s, r ), @"_", mid(s,r)) - end if - next - s = fn stringwithformat(@"%@%@",left( s, 1), lcase(mid(s, 1))) -end fn = s - -local fn show( s1 as CFStringRef ) - CFStringRef s = @" " - CFStringRef s2 = fn snake_toCamel( s1 ) - CFStringRef s3 = fn CamelTo_snake( s1 ) - nslog(@" \"%@\"%@\"%@\"%@\"%@\"", s1, mid(s, len(s1)), s2, mid(s, len(s2)), s3) -end fn - -nslog( @"%@",@"String ¬ -fn snake_toCamel ¬ -fn CamelTo_snake") -fn show(@"snakeCase") -fn show(@"snake_case") -fn show(@"variable_10_case") -fn show(@"variable10Case") -fn show(@"ɛrgo rE tHis") -fn show(@"hurry-up-joe!") -fn show(@"c://my-docs/happy_Flag-Day/12.doc") -fn show(@" spaces ") - -handleevents diff --git a/Task/Camel-case-and-snake-case/FutureBasic/camel-case-and-snake-case-2.basic b/Task/Camel-case-and-snake-case/FutureBasic/camel-case-and-snake-case-2.basic deleted file mode 100644 index bce565d1b6..0000000000 --- a/Task/Camel-case-and-snake-case/FutureBasic/camel-case-and-snake-case-2.basic +++ /dev/null @@ -1,9 +0,0 @@ -String fn snake_toCamel fn CamelTo_snake - "snakeCase" "snakeCase" "snake_case" - "snake_case" "snakeCase" "snake_case" - "variable_10_case" "variable10Case" "variable_10_case" - "variable10Case" "variable10Case" "variable10_case" - "ɛrgo rE tHis" "ɛrgoRETHis" "ɛrgo_r_e_t_his" - "hurry-up-joe!" "hurryUpJoe!" "hurry_up_joe!" - " spaces " "spaces" "spaces" - "c://my-docs/happy_Flag-Day/12.doc" "c://myDocs/happyFlagDay/12.doc" "c://my_docs/happy_flag_day/12.doc" diff --git a/Task/Camel-case-and-snake-case/Go/camel-case-and-snake-case.go b/Task/Camel-case-and-snake-case/Go/camel-case-and-snake-case.go deleted file mode 100644 index 143ef584c5..0000000000 --- a/Task/Camel-case-and-snake-case/Go/camel-case-and-snake-case.go +++ /dev/null @@ -1,104 +0,0 @@ -package main - -import ( - "fmt" - "strings" - "unicode" -) - -func snakeCaseToCamelCase(word string, sep rune) string { - var sb strings.Builder - - wordRunes := []rune(strings.TrimSpace(word)) - wordLen := len(wordRunes) - - for i := 0; i < wordLen; i++ { - c := wordRunes[i] - - if c == sep { - if i+1 < wordLen && wordRunes[i+1] != sep { - sb.WriteRune(unicode.ToUpper(wordRunes[i+1])) - i++ - } - } else { - if i == 0 { - c = unicode.ToLower(c) - } - sb.WriteRune(c) - } - } - - return sb.String() -} - -func camelCaseToSnakeCase(word string, sep rune) string { - word = strings.TrimSpace(word) - var sb strings.Builder - var lastRune rune - - for i, c := range word { - if i != 0 && unicode.IsUpper(c) { - if lastRune != sep { - sb.WriteRune(sep) - } - } - sb.WriteRune(unicode.ToLower(c)) - lastRune = c - } - - return sb.String() -} - -func main() { - words := []string{ - "snakeCase", - "snake_case", - "variable_10_case", - "variable10Case", - "ɛrgo rE tHis", - "hurry-up-joe!", - "c://my-docs/happy_Flag-Day/12.doc", - " spaces ", - } - - fmt.Print("snake_case to camelCase:\n\n") - - for _, word := range words { - fmt.Println(word, "=>", snakeCaseToCamelCase(word, '_')) - } - - fmt.Println() - fmt.Print("kebab-case to camelCase:\n\n") - - for _, word := range words { - fmt.Println(word, "=>", snakeCaseToCamelCase(word, '-')) - } - - fmt.Println() - fmt.Print("space case to camelCase:\n\n") - - for _, word := range words { - fmt.Println(word, "=>", snakeCaseToCamelCase(word, ' ')) - } - - fmt.Println() - fmt.Print("camelCase to snake_case:\n\n") - - for _, word := range words { - fmt.Println(word, "=>", camelCaseToSnakeCase(word, '_')) - } - - fmt.Println() - fmt.Print("camelCase to kebab-case:\n\n") - - for _, word := range words { - fmt.Println(word, "=>", camelCaseToSnakeCase(word, '-')) - } - - fmt.Println() - fmt.Print("camelCase to space case:\n\n") - - for _, word := range words { - fmt.Println(word, "=>", camelCaseToSnakeCase(word, ' ')) - } -} diff --git a/Task/Camel-case-and-snake-case/Java/camel-case-and-snake-case.java b/Task/Camel-case-and-snake-case/Java/camel-case-and-snake-case.java deleted file mode 100644 index fe9e4f9a4a..0000000000 --- a/Task/Camel-case-and-snake-case/Java/camel-case-and-snake-case.java +++ /dev/null @@ -1,64 +0,0 @@ -import java.util.List; - -public final class CamelCaseAndSnakeCase { - - public static void main(String[] aArgs) { - List variableNames = List.of( "snakeCase", "snake_case", "variable_10_case", "variable10Case", - "ergo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces "); - - System.out.println(String.format("%48s", "=== To snake_case ===")); - for ( String text : variableNames ) { - System.out.println(String.format("%34s%s%s", text, " --> ", toSnakeCase(text))); - } - - System.out.println(); - System.out.println(String.format("%48s", "=== To camelCase ===")); - for ( String text : variableNames ) { - System.out.println(String.format("%34s%s%s", text, " --> ", toCamelCase(text))); - } - } - - private static String toSnakeCase(String aCamel) { - aCamel = aCamel.trim().replace(SPACE, UNDERSCORE).replace(HYPHEN, UNDERSCORE); - StringBuilder snake = new StringBuilder(); - boolean first = true; - for ( char ch : aCamel.toCharArray() ) { - if ( first ) { - snake.append(ch); - first = false; - } else if ( ! first && Character.isUpperCase(ch) ) { - if ( snake.toString().endsWith(UNDERSCORE) ) { - snake.append(Character.toLowerCase(ch)); - } else { - snake.append(UNDERSCORE + Character.toLowerCase(ch)); - } - } else { - snake.append(ch); - } - } - return snake.toString(); - - } - - private static String toCamelCase(String aSnake) { - aSnake = aSnake.trim().replace(SPACE, UNDERSCORE).replace(HYPHEN, UNDERSCORE); - StringBuilder camel = new StringBuilder(); - boolean underscore = false; - for ( char ch : aSnake.toCharArray() ) { - if ( Character.toString(ch).equals(UNDERSCORE) ) { - underscore = true; - } else if ( underscore ) { - camel.append(Character.toUpperCase(ch)); - underscore = false; - } else { - camel.append(ch); - } - } - return camel.toString(); - } - - private static final String SPACE = " "; - private static final String UNDERSCORE = "_"; - private static final String HYPHEN = "-"; - -} diff --git a/Task/Camel-case-and-snake-case/JavaScript/camel-case-and-snake-case.js b/Task/Camel-case-and-snake-case/JavaScript/camel-case-and-snake-case.js deleted file mode 100644 index 73b10c2641..0000000000 --- a/Task/Camel-case-and-snake-case/JavaScript/camel-case-and-snake-case.js +++ /dev/null @@ -1,82 +0,0 @@ -const HYPHEN = '-'; -const SPACE = ' '; -const UNDERSCORE = '_'; -const WHITESPACE = " \n\r\t\f\v"; - -function leftTrim(text) { - const start = text.search(/\S/); // Find the index of the first non-whitespace character - return start === -1 ? "" : text.substring(start); -} - -function rightTrim(text) { - const end = text.search(/\S(?![\s\S]*\S)/); // Find the index of the last non-whitespace character - return end === -1 ? "" : text.substring(0, end + 1); -} - -function trim(text) { - return leftTrim(rightTrim(text)); -} - -function prepareForConversion(text) { - text = trim(text); - text = text.replace(new RegExp(SPACE, 'g'), UNDERSCORE); - text = text.replace(new RegExp(HYPHEN, 'g'), UNDERSCORE); - return text; // Return the modified text -} - -function toSnakeCase(camel) { - camel = prepareForConversion(camel); - let snake = ""; - let first = true; - for (const ch of camel) { - if (first) { - snake += ch; - first = false; - } else if (!first && ch >= 'A' && ch <= 'Z') { - if (snake.slice(-1) === UNDERSCORE) { - snake += ch.toLowerCase(); - } else { - snake += UNDERSCORE; - snake += ch.toLowerCase(); - } - } else { - snake += ch; - } - } - return snake; -} - -function toCamelCase(snake) { - snake = prepareForConversion(snake); - let camel = ""; - let underscore = false; - for (const ch of snake) { - if (ch === UNDERSCORE) { - underscore = true; - } else if (underscore) { - camel += ch.toUpperCase(); - underscore = false; - } else { - camel += ch; - } - } - return camel; -} - -function main() { - const variableNames = ["snakeCase", "snake_case", "variable_10_case", - "variable10Case", "ergo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces "]; - - console.log("".padEnd(48, " ") + "=== To snake_case ==="); - for (const text of variableNames) { - console.log("".padEnd(34, " ") + text + " --> " + toSnakeCase(text)); - } - - console.log("\n"); - console.log("".padEnd(48, " ") + "=== To camelCase ==="); - for (const text of variableNames) { - console.log("".padEnd(34, " ") + text + " --> " + toCamelCase(text)); - } -} - -main(); diff --git a/Task/Camel-case-and-snake-case/Julia/camel-case-and-snake-case.jl b/Task/Camel-case-and-snake-case/Julia/camel-case-and-snake-case.julia similarity index 100% rename from Task/Camel-case-and-snake-case/Julia/camel-case-and-snake-case.jl rename to Task/Camel-case-and-snake-case/Julia/camel-case-and-snake-case.julia diff --git a/Task/Camel-case-and-snake-case/Kotlin/camel-case-and-snake-case.kts b/Task/Camel-case-and-snake-case/Kotlin/camel-case-and-snake-case.kts deleted file mode 100644 index 8159af38c2..0000000000 --- a/Task/Camel-case-and-snake-case/Kotlin/camel-case-and-snake-case.kts +++ /dev/null @@ -1,41 +0,0 @@ -fun main() { - val variableNames = listOf("snakeCase", "snake_case", "variable_10_case", "variable10Case", - "ergo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces ") - - println(" ".repeat(26) + "=== To snake_case ===") - variableNames.forEach { text -> - println("${text.padStart(34)} --> ${toSnakeCase(text)}") - } - - println("\n" + " ".repeat(26) + "=== To camelCase ===") - variableNames.forEach { text -> - println("${text.padStart(34)} --> ${toCamelCase(text)}") - } -} - -fun toSnakeCase(camel: String): String { - val snake = StringBuilder() - camel.trim().replace(" ", "_").replace("-", "_").forEach { ch -> - if (snake.isEmpty() || snake.last() != '_' || ch != '_') { - if (ch.isUpperCase() && snake.isNotEmpty() && snake.last() != '_') snake.append('_') - snake.append(ch.toLowerCase()) - } - } - return snake.toString() -} - -fun toCamelCase(snake: String): String { - val camel = StringBuilder() - var underscore = false - snake.trim().replace(" ", "_").replace("-", "_").forEach { ch -> - if (ch == '_') { - underscore = true - } else if (underscore) { - camel.append(ch.toUpperCase()) - underscore = false - } else { - camel.append(ch) - } - } - return camel.toString() -} diff --git a/Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math b/Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math deleted file mode 100644 index ecae1a970d..0000000000 --- a/Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math +++ /dev/null @@ -1,85 +0,0 @@ -(* String case conversion functions in Mathematica *) - -snakeToCamelCase[nam_String, sep_String : "[_]+", lcmiddle_ : False] := Module[{words}, - If[nam == "", Return[nam]]; - words = StringSplit[StringTrim[nam], RegularExpression[sep]]; - If[lcmiddle, words = ToLowerCase /@ words]; - words[[2 ;;]] = StringJoin[ToUpperCase[StringTake[#, 1]], StringDrop[#, 1]] & /@ Select[words[[2 ;;]], StringLength[#] > 0 &]; - StringJoin[words] -] - -spaceToCamelCase[nam_String] := snakeToCamelCase[nam, "\\s+"] - -kebabToCamelCase[nam_String] := snakeToCamelCase[nam, "[\\-]+"] - -periodToCamelCase[nam_String] := snakeToCamelCase[nam, "[\\.]+"] - -allsepToCamelCase[nam_String] := snakeToCamelCase[nam, "[ \\-_\\.]+"] - -lowermiddleAllsepToCamelCase[nam_String] := snakeToCamelCase[nam, "[ \\-_\\.]+", True] - -camelToSnakeCase[nam_String, sep_String : "_", allsep_String : "[_]+", lcmiddle_ : True] := Module[{result, sep1, words}, - result = StringReplace[StringTrim[nam], RegularExpression["([A-Z]+)"] -> sep <> "$1"]; - sep1 = If[sep == ".", "\\.", sep]; - If[lcmiddle, - words = Select[StringSplit[result, sep1], StringLength[#] > 0 &]; - result = StringRiffle[ToLowerCase /@ words, sep], - words = Select[StringSplit[result, sep1], StringLength[#] > 0 &]; - result = StringRiffle[StringJoin[ToLowerCase[StringTake[#, 1]], StringDrop[#, 1]] & /@ words, sep] - ]; - StringReplace[result, RegularExpression[allsep] -> sep] -] - -preserveMidcapsCamelToSnakeCase[nam_String] := camelToSnakeCase[nam, "_", "[_]+", False] - -allsepToSnakeCase[nam_String] := camelToSnakeCase[nam, "_", "[ \\-\\._]+"] - -allsepToKebabCase[nam_String] := camelToSnakeCase[nam, "-", "[ \\-\\._]+"] - -allsepToSpaceCase[nam_String] := camelToSnakeCase[nam, " ", "[ \\-\\._]+"] - -allsepToPeriodCase[nam_String] := camelToSnakeCase[nam, ".", "[ \\-\\._]+"] - -allsepToSlashCase[nam_String] := camelToSnakeCase[nam, "/", "[ \\-\\._]+"] - -(* Test the functions *) -testFunctions = { - snakeToCamelCase, - spaceToCamelCase, - kebabToCamelCase, - periodToCamelCase, - allsepToCamelCase, - lowermiddleAllsepToCamelCase, - camelToSnakeCase, - preserveMidcapsCamelToSnakeCase, - allsepToSnakeCase, - allsepToKebabCase, - allsepToSpaceCase, - allsepToPeriodCase, - allsepToSlashCase -}; - -testStrings = { - "snakeCase", - "snake_case", - "snake-case", - "snake case", - "snake CASE", - "snake.case", - "variable_10_case", - "variable10Case", - "ɛrgo rE tHis", - "hurry-up-joe!", - "c://my-docs/happy_Flag-Day/12.doc", - " spaces " -}; - -Do[ - Print["Testing function ", f, ":"]; - Do[ - Print[StringPadLeft[testString, 36], " => ", f[testString]], - {testString, testStrings} - ]; - Print[""], - {f, testFunctions} -] diff --git a/Task/Camel-case-and-snake-case/OmniMark/camel-case-and-snake-case.xom b/Task/Camel-case-and-snake-case/OmniMark/camel-case-and-snake-case.xom deleted file mode 100644 index 69c54a13fc..0000000000 --- a/Task/Camel-case-and-snake-case/OmniMark/camel-case-and-snake-case.xom +++ /dev/null @@ -1,58 +0,0 @@ -define stream function to_snake_case (value stream txt) as - local stream ls - open ls as buffer - repeat scan txt - match white-space* value-end - ; "trailing whitespace may be ignored" - match value-start white-space* - ; "leading ... whitespace may be ignored" - match (lc | digit) => char1 uc => char2 - put ls '%x(char1)_%lx(char2)' - match ('_' | space | "-" | '.') - ; normalise to underscore and lowercase letter - put ls '_' - match any => char - ; all other characters are lowercase - put ls '%lx(char)' - again - close ls - return ls - -define stream function toCamelCase (value stream txt) as - local stream ls - open ls as buffer - repeat scan txt - match white-space* value-end - ; "trailing whitespace may be ignored" - match value-start white-space* letter+ => word1 - ; "leading ... whitespace may be ignored" - put ls word1 - match ('_' | space | "-" | '.') any => makeUpper - ; consume dividing underscore, space, hyphen or full stop - put ls '%ux(makeUpper)' - match ([digit] letter) => chars - ; a letter preceded by a numeral should be uppercase - put ls '%ux(chars)' - match any => char - ; all other characters are lowercase - put ls '%lx(char)' - again - close ls - return ls - -process - local stream ls variable initial {"snakeCase", "snake_case", - "variable_10_case", "variable10Case", - "ɛrgo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", - " spaces "} - output 'to_snake_case%n' - output '=============%n' - repeat over ls - output ls || ' => ' || to_snake_case(ls) || '%n' - again - output '%n' - output 'toCamelCase%n' - output '===========%n' - repeat over ls - output ls || ' => ' || toCamelCase(ls) || '%n' - again diff --git a/Task/Camel-case-and-snake-case/Phix/camel-case-and-snake-case.phix b/Task/Camel-case-and-snake-case/Phix/camel-case-and-snake-case.phix index ff87c84e3a..c9a701e73d 100644 --- a/Task/Camel-case-and-snake-case/Phix/camel-case-and-snake-case.phix +++ b/Task/Camel-case-and-snake-case/Phix/camel-case-and-snake-case.phix @@ -1,31 +1,33 @@ -with javascript_semantics -function to_snake_case(string s) - string snake = substitute(trim(s)," ","_") - for i=length(snake) to 1 by -1 do - if isupper(snake[i]) then - snake[i..i] = '_'&lower(snake[i]) - end if - end for - return snake -end function +(phixonline)--> + with javascript_semantics + function to_snake_case(string s) + string snake = substitute(trim(s)," ","_") + for i=length(snake) to 1 by -1 do + if isupper(snake[i]) then + snake[i..i] = '_'&lower(snake[i]) + end if + end for + return snake + end function -function toCamelCase(string s) - string camel = substitute_all(trim(s),"- ","__") - for i=length(camel)-1 to 1 by -1 do - if camel[i]='_' then - camel[i..i+1] = upper(camel[i+1..i+1]) - end if - end for - return camel -end function + function toCamelCase(string s) + string camel = substitute_all(trim(s),"- ","__") + for i=length(camel)-1 to 1 by -1 do + if camel[i]='_' then + camel[i..i+1] = upper(camel[i+1..i+1]) + end if + end for + return camel + end function -constant tests = {"snakeCase", "snake_case", "variable_10_case", "variable10Case", "ergo rE tHis", - "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces "} -procedure test(string title, integer fn) - printf(1,title) - for i=1 to length(tests) do - printf(1,"%33s ===> %s\n", {tests[i], fn(tests[i])}) - end for -end procedure -test(" === to_snake_case ===\n",to_snake_case) -test("\n === toCamelCase ===\n",toCamelCase) + constant tests = {"snakeCase", "snake_case", "variable_10_case", "variable10Case", "ergo rE tHis", + "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces "} + procedure test(string title, integer fn) + printf(1,title) + for i=1 to length(tests) do + printf(1,"%33s ===> %s\n", {tests[i], fn(tests[i])}) + end for + end procedure + test(" === to_snake_case ===\n",to_snake_case) + test("\n === toCamelCase ===\n",toCamelCase) + {}", text, to_snake_case(text)); - } - - println!(); - println!("{:>48}", "=== To camelCase ==="); - for text in &variable_names { - println!("{:>34} --> {}", text, to_camel_case(text)); - } -} diff --git a/Task/Camel-case-and-snake-case/Scala/camel-case-and-snake-case.scala b/Task/Camel-case-and-snake-case/Scala/camel-case-and-snake-case.scala deleted file mode 100644 index 209ba2986b..0000000000 --- a/Task/Camel-case-and-snake-case/Scala/camel-case-and-snake-case.scala +++ /dev/null @@ -1,39 +0,0 @@ -object CamelCaseAndSnakeCase extends App { - - val variableNames = List("snakeCase", "snake_case", "variable_10_case", "variable10Case", - "ergo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces ") - - println(" " * 26 + "=== To snake_case ===") - variableNames.foreach { text => - println(f"$text%34s --> ${toSnakeCase(text)}") - } - - println("\n" + " " * 26 + "=== To camelCase ===") - variableNames.foreach { text => - println(f"$text%34s --> ${toCamelCase(text)}") - } - - def toSnakeCase(camel: String): String = { - val snake = new StringBuilder - camel.trim.replace(" ", "_").replace("-", "_").foreach { ch => - if (snake.isEmpty || snake.last != '_' || ch != '_') { - if (ch.isUpper && snake.nonEmpty && snake.last != '_') snake.append('_') - snake.append(ch.toLower) - } - } - snake.toString - } - - def toCamelCase(snake: String): String = { - val camel = new StringBuilder - var underscore = false - snake.trim.replace(" ", "_").replace("-", "_").foreach { ch => - if (ch == '_') underscore = true - else if (underscore) { - camel.append(ch.toUpper) - underscore = false - } else camel.append(ch) - } - camel.toString - } -} diff --git a/Task/Camel-case-and-snake-case/Wren/camel-case-and-snake-case.wren b/Task/Camel-case-and-snake-case/Wren/camel-case-and-snake-case.wren index 66d04c3e49..e7bdf59398 100644 --- a/Task/Camel-case-and-snake-case/Wren/camel-case-and-snake-case.wren +++ b/Task/Camel-case-and-snake-case/Wren/camel-case-and-snake-case.wren @@ -1,5 +1,5 @@ import "./str" for Char -import "./fmt" for Fmt +import "/fmt" for Fmt var toCamel = Fn.new { |snake| snake = snake.trim() diff --git a/Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig b/Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig deleted file mode 100644 index faee5b8822..0000000000 --- a/Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig +++ /dev/null @@ -1,134 +0,0 @@ -const std = @import("std"); -const print = std.debug.print; -const ArrayList = std.ArrayList; - -const HYPHEN: u8 = '-'; -const SPACE: u8 = ' '; -const UNDERSCORE: u8 = '_'; -const WHITESPACE = " \n\r\t\x0C\x0B"; - -fn isWhitespace(ch: u8) bool { - for (WHITESPACE) |ws| { - if (ch == ws) return true; - } - return false; -} - -fn leftTrim(text: []const u8) []const u8 { - var start: usize = 0; - while (start < text.len and isWhitespace(text[start])) { - start += 1; - } - return text[start..]; -} - -fn rightTrim(text: []const u8) []const u8 { - var end: usize = text.len; - while (end > 0 and isWhitespace(text[end - 1])) { - end -= 1; - } - return text[0..end]; -} - -fn trim(text: []const u8) []const u8 { - return rightTrim(leftTrim(text)); -} - -fn prepareForConversion(allocator: std.mem.Allocator, text: []const u8) ![]u8 { - const trimmed = trim(text); - var result = try ArrayList(u8).initCapacity(allocator, trimmed.len); - defer result.deinit(); - - for (trimmed) |ch| { - if (ch == SPACE or ch == HYPHEN) { - try result.append(UNDERSCORE); - } else { - try result.append(ch); - } - } - - return result.toOwnedSlice(); -} - -fn toSnakeCase(allocator: std.mem.Allocator, camel: []const u8) ![]u8 { - const text = try prepareForConversion(allocator, camel); - defer allocator.free(text); - - var snake = ArrayList(u8).init(allocator); - defer snake.deinit(); - - var first = true; - - for (text) |ch| { - if (first) { - try snake.append(ch); - first = false; - } else if (std.ascii.isUpper(ch)) { - if (snake.items.len > 0 and snake.items[snake.items.len - 1] == UNDERSCORE) { - try snake.append(std.ascii.toLower(ch)); - } else { - try snake.append(UNDERSCORE); - try snake.append(std.ascii.toLower(ch)); - } - } else { - try snake.append(ch); - } - } - - return snake.toOwnedSlice(); -} - -fn toCamelCase(allocator: std.mem.Allocator, snake: []const u8) ![]u8 { - const text = try prepareForConversion(allocator, snake); - defer allocator.free(text); - - var camel = ArrayList(u8).init(allocator); - defer camel.deinit(); - - var underscore = false; - - for (text) |ch| { - if (ch == UNDERSCORE) { - underscore = true; - } else if (underscore) { - try camel.append(std.ascii.toUpper(ch)); - underscore = false; - } else { - try camel.append(ch); - } - } - - return camel.toOwnedSlice(); -} - -pub fn main() !void { - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - defer _ = gpa.deinit(); - const allocator = gpa.allocator(); - - const variable_names = [_][]const u8{ - "snakeCase", - "snake_case", - "variable_10_case", - "variable10Case", - "ergo rE tHis", - "hurry-up-joe!", - "c://my-docs/happy_Flag-Day/12.doc", - " spaces " - }; - - print("{s:>48}\n", .{"=== To snake_case ==="}); - for (variable_names) |text| { - const snake = try toSnakeCase(allocator, text); - defer allocator.free(snake); - print("{s:>34} --> {s}\n", .{ text, snake }); - } - - print("\n", .{}); - print("{s:>48}\n", .{"=== To camelCase ==="}); - for (variable_names) |text| { - const camel = try toCamelCase(allocator, text); - defer allocator.free(camel); - print("{s:>34} --> {s}\n", .{ text, camel }); - } -} diff --git a/Task/Canny-edge-detector/FreeBASIC/canny-edge-detector.basic b/Task/Canny-edge-detector/FreeBASIC/canny-edge-detector.basic deleted file mode 100644 index 947ea3deca..0000000000 --- a/Task/Canny-edge-detector/FreeBASIC/canny-edge-detector.basic +++ /dev/null @@ -1,116 +0,0 @@ -#define MIN(a, b) iif((a) < (b), (a), (b)) -#define MAX(a, b) iif((a) > (b), (a), (b)) - -Const MaxBrightness = 255 - -' Función para leer un archivo PPM -Function readPPM(nombre As String, Byref ancho As Integer, Byref alto As Integer, image() As Ubyte) As Boolean - Dim As Integer ff - Dim As String t, dcol - - If nombre = "" Then - Print "No PPM file name indicated." - Return False - End If - - ff = Freefile - Open nombre For Binary As #ff - If Err Then - Print "File "; nombre; " not found." - Return False - End If - - Line Input #ff, t - If t <> "P6" Then - Print "File is NOT PPM P6 type." - Close #ff - Return False - End If - - Do - Line Input #ff, t - Loop While Left(t, 1) = "#" - - Dim As Integer posic = 1 - While Mid(t, posic, 1) = " " - posic += 1 - Wend - ancho = Val(Mid(t, posic)) - - While Mid(t, posic, 1) <> " " - posic += 1 - Wend - While Mid(t, posic, 1) = " " - posic += 1 - Wend - alto = Val(Mid(t, posic)) - - Line Input #ff, dcol - - Redim image(0 To ancho * alto * 3 - 1) - Get #ff, , image() - - Close #ff - Return True -End Function - -Dim As Integer ancho, alto -Dim image() As Ubyte - -If readPPM("i:\Lena.ppm", ancho, alto, image()) Then - Dim As Integer newAncho = ancho, newAlto = alto - Dim pixelsGray(newAncho - 1, newAlto - 1) As Integer - Dim C_E_D(2, 2) As Integer - - ' Define edge detection filter - Dim As Integer dato(8) => {-1, -1, -1, -1, 8, -1, -1, -1, -1} - Dim As Integer i, j - For i = 0 To 2 - For j = 0 To 2 - C_E_D(i, j) = dato(i * 3 + j) - Next j - Next i - - ' Convert image to grayscale - Dim As Integer x, y, r, g, b, lumin, k - For y = 0 To newAlto - 1 - For x = 0 To newAncho - 1 - r = image((y * newAncho + x) * 3) - g = image((y * newAncho + x) * 3 + 1) - b = image((y * newAncho + x) * 3 + 2) - lumin = Int(0.2126 * r + 0.7152 * g + 0.0722 * b) - pixelsGray(x, y) = lumin - Next x - Next y - - Dim new_image(newAncho - 1, newAlto - 1) As Integer - Dim As Integer divisor = 1 - - ' Apply edge detection filter - Dim As Integer newRGB - For y = 1 To newAlto - 2 - For x = 1 To newAncho - 2 - newRGB = 0 - For i = -1 To 1 - For j = -1 To 1 - newRGB += C_E_D(i + 1, j + 1) * pixelsGray(x + i, y + j) - Next j - Next i - new_image(x, y) = Max(Min(newRGB / divisor, 255), 0) - Next x - Next y - - ' Show the result - Screenres newAncho, newAlto, 32 - Windowtitle ("Canny edge detector") - For y = 0 To newAlto - 1 - For x = 0 To newAncho - 1 - k = new_image(x, y) - Pset (x, y), Rgb(k, k, k) - Next x - Next y -Else - Print "Error loading PPM file." -End If - -Sleep diff --git a/Task/Canny-edge-detector/Julia/canny-edge-detector.jl b/Task/Canny-edge-detector/Julia/canny-edge-detector.julia similarity index 100% rename from Task/Canny-edge-detector/Julia/canny-edge-detector.jl rename to Task/Canny-edge-detector/Julia/canny-edge-detector.julia diff --git a/Task/Canny-edge-detector/Wren/canny-edge-detector.wren b/Task/Canny-edge-detector/Wren/canny-edge-detector.wren index 788766699d..afd47fef7f 100644 --- a/Task/Canny-edge-detector/Wren/canny-edge-detector.wren +++ b/Task/Canny-edge-detector/Wren/canny-edge-detector.wren @@ -8,7 +8,7 @@ var MaxBrightness = 255 class Canny { construct new(inFile, outFile) { Window.title = "Canny edge detection" - var image1 = ImageData.load(inFile) + var image1 = ImageData.loadFromFile(inFile) var w = image1.width var h = image1.height Window.resize(w * 2 + 20, h) diff --git a/Task/Canonicalize-CIDR/11l/canonicalize-cidr.11l b/Task/Canonicalize-CIDR/11l/canonicalize-cidr.11l index b6ddd2a1f7..dcb2faf15e 100644 --- a/Task/Canonicalize-CIDR/11l/canonicalize-cidr.11l +++ b/Task/Canonicalize-CIDR/11l/canonicalize-cidr.11l @@ -8,7 +8,7 @@ F cidr_parse(str) | c < 0 | c > 255 | d < 0 | d > 255 R (0, 0) - V mask = ~((1 << (32 - m)) - 1) + V mask = (-)((1 << (32 - m)) - 1) V address = (a << 24) + (b << 16) + (c << 8) + d address [&]= mask R (address, m) diff --git a/Task/Canonicalize-CIDR/ALGOL-68/canonicalize-cidr.alg b/Task/Canonicalize-CIDR/ALGOL-68/canonicalize-cidr.alg index 6a3f49135f..7befa0b1eb 100644 --- a/Task/Canonicalize-CIDR/ALGOL-68/canonicalize-cidr.alg +++ b/Task/Canonicalize-CIDR/ALGOL-68/canonicalize-cidr.alg @@ -1,22 +1,22 @@ BEGIN # show IPv4 addresses in CIDR notation in canonical form # # mode to hold an IPv4 address in CIDR notation # - MODE CIDR = STRUCT( LONG BITS address - , INT network bits - , BOOL valid - , STRING error + MODE CIDR = STRUCT( BITS address + , INT network bits + , BOOL valid + , STRING error ); # returns a CIDR parsed from address # OP TOCIDR = ( STRING address text )CIDR: BEGIN - STRING addr = "." + address text + "$"; - STRING error := ""; - LONG BITS address := 16r0; - INT bits count := 0; - INT dot count := 0; - INT slash count := 0; - BOOL valid := TRUE; - INT s pos := LWB addr; - INT s max = UPB addr; + STRING addr = "." + address text + "$"; + STRING error := ""; + BITS address := 16r0; + INT bits count := 0; + INT dot count := 0; + INT slash count := 0; + BOOL valid := TRUE; + INT s pos := LWB addr; + INT s max = UPB addr; WHILE s pos < s max AND valid DO IF addr[ s pos ] = "." THEN # must have an octet next # @@ -70,7 +70,7 @@ BEGIN # show IPv4 addresses in CIDR notation in canonical form # address ELSE # valid address - retain the top most bits # - CIDR( address OF address AND ( LONG 16rffffffff + CIDR( address OF address AND ( 16rffffffff SHL ( 32 - network bits OF address ) ) , network bits OF address @@ -82,9 +82,9 @@ BEGIN # show IPv4 addresses in CIDR notation in canonical form # OP TOSTRING = ( CIDR address )STRING: BEGIN [ 1 : 4 ]INT octet; - LONG BITS addr := address OF address; + BITS addr := address OF address; FOR o pos FROM UPB octet BY -1 TO LWB octet DO - octet[ o pos ] := SHORTEN ABS ( addr AND 16rff ); + octet[ o pos ] := ABS ( addr AND 16rff ); addr := addr SHR 8 OD; STRING result := whole( octet[ LWB octet ], 0 ); diff --git a/Task/Canonicalize-CIDR/Ada/canonicalize-cidr.adb b/Task/Canonicalize-CIDR/Ada/canonicalize-cidr.adb deleted file mode 100644 index a138a754ae..0000000000 --- a/Task/Canonicalize-CIDR/Ada/canonicalize-cidr.adb +++ /dev/null @@ -1,105 +0,0 @@ -with Ada.Strings; -with Ada.Strings.Fixed; -with Ada.Strings.Maps; -with Ada.Text_IO; - -use Ada.Strings; -use Ada.Strings.Fixed; -use Ada.Strings.Maps; -use Ada.Text_IO; - -procedure Canonicalize_CIDR is - type IP_Octet_Type is mod 256; - - type IP_Record_Type is record - A, B, C, D : IP_Octet_Type; - end record - with Size => 32; - - for IP_Record_Type use record - -- Use little-endian ordering to match bit array - D at 0 range 0 .. 7; - C at 1 range 0 .. 7; - B at 2 range 0 .. 7; - A at 3 range 0 .. 7; - end record; - - type IP_Bitarray_Type is array (0 .. 31) of Boolean - with Component_Size => 1; - - subtype IP_Mask_Type is Natural range 0 .. 32; - - type IP_CIDR_Type is record - IP : IP_Record_Type; - Mask : IP_Mask_Type; - end record; - - function Parse_IP_CIDR (S : String) return IP_CIDR_Type is - IP_Record : IP_CIDR_Type; - Digit_Range : Character_Range := ('0', '9'); - Digit_Set : Character_Set := To_Set (Digit_Range); - Octets : array (1 .. 4) of IP_Octet_Type; - First : Positive; - Last : Natural := 0; - begin - for I in Octets'Range loop - Find_Token (S, Digit_Set, Last + 1, Inside, First, Last); - Octets (I) := IP_Octet_Type'Value (S (First .. Last)); - end loop; - IP_Record.IP.A := Octets (1); - IP_Record.IP.B := Octets (2); - IP_Record.IP.C := Octets (3); - IP_Record.IP.D := Octets (4); - - Find_Token (S, Digit_Set, Last + 1, Inside, First, Last); - IP_Record.Mask := IP_Mask_Type'Value (S (First .. Last)); - - return IP_Record; - end Parse_IP_CIDR; - - procedure Canonicalize_IP_CIDR (Addr : in out IP_CIDR_Type) is - -- Fun part. I can overlay different types over the same bits. - Bit_Overlay : IP_Bitarray_Type with Address => Addr.IP'Address; - begin - for I in Bit_Overlay'First .. Bit_Overlay'Last - Addr.Mask loop - Bit_Overlay (I) := False; - end loop; - end Canonicalize_IP_CIDR; - - procedure Put_IP_CIDR (Addr : IP_CIDR_TYPE) is - package Octet_IO is new Ada.Text_IO.Modular_IO (IP_Octet_Type); - package Mask_IO is new Ada.Text_IO.Integer_IO (IP_Mask_Type); - begin - Octet_IO.Put (Addr.IP.A, 0); - Put ("."); - Octet_IO.Put (Addr.IP.B, 0); - Put ("."); - Octet_IO.Put (Addr.IP.C, 0); - Put ("."); - Octet_IO.Put (Addr.IP.D, 0); - Put ("/"); - Mask_IO.Put (Addr.Mask, 0); - end Put_IP_CIDR; - - procedure Show_IP_Canonicalize (S : String) is - Canon : IP_CIDR_Type := Parse_IP_CIDR (S); - begin - Canonicalize_IP_Cidr (Canon); - Put (S & " -> "); - Put_IP_CIDR (Canon); - New_Line; - end Show_IP_Canonicalize; - - Test_IPs : array (1 .. 5) of String (1 .. 18) := - ( - "36.18.154.103/12 ", - "62.62.197.11/29 ", - "67.137.119.181/4 ", - "161.214.74.21/24 ", - "184.232.176.184/18" - ); -begin - for I of Test_IPs loop - Show_IP_Canonicalize (I); - end loop; -end Canonicalize_CIDR; diff --git a/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy b/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy deleted file mode 100644 index 7c1c9054e8..0000000000 --- a/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy +++ /dev/null @@ -1,30 +0,0 @@ -func$ can_cidr s$ . - n[] = number strtok s$ "./" - if len n[] <> 5 : return "" - for i to 4 - if n[i] < 0 or n[i] > 255 : return "" - ad = ad * 256 + n[i] - . - if n[5] > 31 or n[5] < 1 : return "" - mask = bitnot (bitshift 1 (32 - n[5]) - 1) - ad = bitand ad mask - for i to 4 - if r$ <> "" : r$ = "." & r$ - r$ = ad mod 256 & r$ - ad = ad div 256 - . - return r$ & "/" & n[5] -. -repeat - s$ = input - until s$ = "" - print s$ & " -> " & can_cidr s$ -. -# -input_data -87.70.141.1/22 -36.18.154.103/12 -62.62.197.11/29 -67.137.119.181/4 -161.214.74.21/24 -184.232.176.184/18 diff --git a/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic b/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic deleted file mode 100644 index bd4af5e919..0000000000 --- a/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic +++ /dev/null @@ -1,99 +0,0 @@ -Const MAX_OCTET = 255 -Const MIN_NETWORK = 1 -Const MAX_NETWORK = 32 -Const OCTET_BITS = 8 - -Type IPAddress - octets(3) As Integer -End Type - -Function isDigit(Byval ch As String) As Boolean - Return (Asc(ch) >= Asc("0")) And (Asc(ch) <= Asc("9")) -End Function - -Function ParseIPAddress(cidr As String, Byref networkWidth As Integer) As IPAddress - Dim As IPAddress ip - Dim As Integer slashPos = Instr(cidr, "/") - Dim As String ipPart = Left(cidr, slashPos - 1) - - networkWidth = Val(Mid(cidr, slashPos + 1)) - - Dim As Integer i, currentOctet = 0, octetValue = 0 - For i = 1 To Len(ipPart) - If Mid(ipPart, i, 1) = "." Then - ip.octets(currentOctet) = octetValue - currentOctet += 1 - octetValue = 0 - Elseif IsDigit(Mid(ipPart, i, 1)) Then - octetValue = octetValue * 10 + Val(Mid(ipPart, i, 1)) - End If - Next - ip.octets(currentOctet) = octetValue - - Return ip -End Function - -Function ApplyNetworkMask(ip As IPAddress, networkWidth As Integer) As IPAddress - Dim As IPAddress result = ip - Dim As Integer completeOctets = networkWidth \ OCTET_BITS - Dim As Integer remainingBits = networkWidth And 7 - - ' Apply mask to partial octet - If completeOctets < 4 Then - result.octets(completeOctets) And= (MAX_OCTET - 2^(OCTET_BITS-remainingBits) + 1) - ' Zero remaining octets - For i As Integer = completeOctets + 1 To 3 - result.octets(i) = 0 - Next - End If - - Return result -End Function - -Function ValidateInput(ip As IPAddress, networkWidth As Integer, cidr As String) As Boolean - If Instr(cidr, "/") = 0 Then - Print "INVALID CIDR STRING: '"; cidr; "'" - Return False - End If - - If networkWidth < MIN_NETWORK Or networkWidth > MAX_NETWORK Then - Print "INVALID NETWORK WIDTH:"; networkWidth - Return False - End If - - For i As Integer = 0 To 3 - If ip.octets(i) > MAX_OCTET Then - Print "INVALID OCTET VALUE:"; ip.octets(i) - Return False - End If - Next - - Return True -End Function - -Sub ProcessCIDR(cidr As String) - Dim As Integer networkWidth - Dim As IPAddress ip = ParseIPAddress(cidr, networkWidth) - - If Not ValidateInput(ip, networkWidth, cidr) Then Exit Sub - - ip = ApplyNetworkMask(ip, networkWidth) - - Dim As String result = Str(ip.octets(0)) - For i As Integer = 1 To 3 - result &= "." & Str(ip.octets(i)) - Next - Print result & "/" & networkWidth -End Sub - -' Main program -Dim As String cidr(9) = { _ -"87.70.141.1/22", "36.18.154.103/12", "62.62.197.11/29", _ -"67.137.119.181/4", "161.214.74.21/24", "184.232.176.184/18", _ -"127.0.0.1", "123.45.67.89/0", "98.76.54.32/100", "123.456.789.0/12" } - -For i As Integer = 0 To 9 - ProcessCIDR(cidr(i)) -Next - -Sleep diff --git a/Task/Canonicalize-CIDR/FutureBasic/canonicalize-cidr.basic b/Task/Canonicalize-CIDR/FutureBasic/canonicalize-cidr.basic deleted file mode 100644 index 8594d42eb7..0000000000 --- a/Task/Canonicalize-CIDR/FutureBasic/canonicalize-cidr.basic +++ /dev/null @@ -1,132 +0,0 @@ -// -// Canonicalize CIDR -// -// Using FutureBasic 7.0.34 -// August 25, R.W -// -// Given a Classless Inter-Domain Routing (CIDR) -// IPv4 address, returns the canonical form. -// - -Int networkWidth // network width in bits -CFStringRef errorCode // global err and CCIDR -CFStringRef CCIDR // canonical CIDR IPv4 - -// Type for IP address -begin record IPv4_Address - Int octets[3] // xxx.xxx.xxx.xx/xx -end record - -// Validate CIDR string -local fn ValidateCIDR(ip as IPv4_Address, SnetworkWidth as Int, cidr as CFStringRef) as Boolean - Int i - boolean result - result = _True - if instr(0, cidr, @"/") == NSNotFound - errorCode = concat(@"Bad CIDR ",cidr) - result = _False - return result - end if - if SnetworkWidth < 1 || SnetworkWidth > 32 //validate network width - errorCode = concat(@"Bad Net Width",str(networkWidth)) - result = _False - return result - end if - for i = 0 to 3 - if ip.octets[i] > 255 - errorCode = concat(@"Bad Octet ",str(ip.octets[i])) - result = _False - return result - end if - next -end fn = result - -// Check if a character is a digit -local fn IsDigit(ch as CFStringRef) as boolean - Boolean IsDigit - IsDigit = (ucc(ch) > 47) && (ucc(ch) < 58) -end fn = IsDigit - -// Parse CIDR string into IP structure and network width -local fn ParseIPv4_Address(cidr as CFStringRef) as IPv4_Address - IPv4_Address ip - Int i, slashPos, currentOctet, octetValue - CFStringRef ipPart - ipPart = @"" - slashPos = instr(0, cidr, @"/") - if slashPos > 0 - ipPart = left(cidr, slashPos) - networkWidth = Intval(mid(cidr, slashPos + 1)) - else - ipPart = cidr - networkWidth = -1 - end if - currentOctet = 0: octetValue = 0 - for i = 0 to len(ipPart)-1 - select case mid(ipPart, i, 1) - case @"." - ip.octets[currentOctet] = octetValue - currentOctet ++ - octetValue = 0 - case else - if fn IsDigit(mid(ipPart, i, 1)) - octetValue = octetValue * 10 + Intval(mid(ipPart, i, 1)) - end if - end select - next - ip.octets[currentOctet] = octetValue -end fn = ip - -// Apply network mask to IP -local fn ApplyNetworkMask(ip as IPv4_Address, SnetworkWidth as Int) as IPv4_Address - IPv4_Address result - Int completeOctets, remainingBits, i - result = ip - completeOctets = SnetworkWidth \ 8 //octet bits - remainingBits = SnetworkWidth AND 7 - if completeOctets < 4 - result.octets[completeOctets] = result.octets[completeOctets] AND (255 - 2^(8 - remainingBits) + 1) - for i = completeOctets + 1 to 3 - result.octets[i] = 0 - next - end if -end fn = result - -// Process a CIDR string, sets global CCIDR -local fn ProcessCIDR(cidr as CFStringRef) as CFStringRef - IPv4_Address ip - CFStringRef result - Int i - result = @"" - ip = fn ParseIPv4_Address(cidr) - if fn ValidateCIDR(ip, networkWidth, cidr) // validate - ip = fn ApplyNetworkMask(ip, networkWidth) - result = mid(str(ip.octets[0]),1) - for i = 1 to 3 - result = concat(result,@".",mid(str(ip.octets[i]),1)) - next - result = concat(result,@"/",mid(str(networkWidth),1)) - else - print@ errorCode - end if - CCIDR = result -end fn = result - -// -// Main - -Window 1,@"Canonicalize CIDR" -print@ - -// Test data from the Rosetta Stone task - -CFStringRef cidr(5) = {@"87.70.141.1/22", @"36.18.154.103/12", @"62.62.197.11/29", ¬ -@"67.137.119.181/4", @"161.214.74.21/24", @"184.232.176.184/18"} - -for Int i = 0 to 5 - print@ fn ProcessCIDR(cidr(i)) -next - -HandleEvents - -// diff --git a/Task/Canonicalize-CIDR/Julia/canonicalize-cidr.jl b/Task/Canonicalize-CIDR/Julia/canonicalize-cidr.julia similarity index 100% rename from Task/Canonicalize-CIDR/Julia/canonicalize-cidr.jl rename to Task/Canonicalize-CIDR/Julia/canonicalize-cidr.julia diff --git a/Task/Canonicalize-CIDR/MATLAB/canonicalize-cidr.m b/Task/Canonicalize-CIDR/MATLAB/canonicalize-cidr.m deleted file mode 100644 index debc175a80..0000000000 --- a/Task/Canonicalize-CIDR/MATLAB/canonicalize-cidr.m +++ /dev/null @@ -1,49 +0,0 @@ -clear all;close all;clc; -cidrCanonicalizer(); - -function cidrCanonicalizer - % Main function to test CIDR canonicalization - - % Define test cases - testCases = { - '36.18.154.103/12', '36.16.0.0/12'; - '62.62.197.11/29', '62.62.197.8/29'; - '67.137.119.181/4', '64.0.0.0/4'; - '161.214.74.21/24', '161.214.74.0/24'; - '184.232.176.184/18', '184.232.128.0/18' - }; - - % Run test cases - for i = 1:size(testCases, 1) - ip = testCases{i, 1}; - expected = testCases{i, 2}; - result = canonicalize(ip); - fprintf('%s -> %s\n', ip, result); - assert(strcmp(result, expected)); - end -end - -function result = dottedToInt(dotted) - % Convert dotted IP to integer representation - parts = str2double(strsplit(dotted, '.')); - result = sum(parts .* (256 .^ (3:-1:0))); -end - -function result = intToDotted(ip) - % Convert integer IP to dotted representation - result = strjoin(arrayfun(@(x) num2str(bitshift(bitand(ip, bitshift(255, x)), -x)), [24 16 8 0], 'UniformOutput', false), '.'); -end - -function result = networkMask(numberOfBits) - % Create a network mask for the given number of bits - result = bitshift((bitshift(1, numberOfBits) - 1), (32 - numberOfBits)); -end - -function result = canonicalize(ip) - % Canonicalize the given CIDR IP - [dotted, networkBits] = strtok(ip, '/'); - networkBits = str2double(strrep(networkBits, '/', '')); - i = dottedToInt(dotted); - mask = networkMask(networkBits); - result = strcat(intToDotted(bitand(i, mask)), '/', num2str(networkBits)); -end diff --git a/Task/Canonicalize-CIDR/OCaml/canonicalize-cidr.ml b/Task/Canonicalize-CIDR/OCaml/canonicalize-cidr.ocaml similarity index 100% rename from Task/Canonicalize-CIDR/OCaml/canonicalize-cidr.ml rename to Task/Canonicalize-CIDR/OCaml/canonicalize-cidr.ocaml diff --git a/Task/Canonicalize-CIDR/Phix/canonicalize-cidr.phix b/Task/Canonicalize-CIDR/Phix/canonicalize-cidr.phix index aca9dd0ac3..187988d1b3 100644 --- a/Task/Canonicalize-CIDR/Phix/canonicalize-cidr.phix +++ b/Task/Canonicalize-CIDR/Phix/canonicalize-cidr.phix @@ -1,31 +1,35 @@ -with javascript_semantics -function canonicalize_cidr(string cidr) - cidr = substitute(cidr,"."," ") -- (else %d eats 0.0 etc) - if not find('/',cidr) then cidr &= "/32" end if - sequence res = scanf(cidr,"%d %d %d %d/%d") - if length(res)=1 then - integer {a,b,c,d,m} = res[1] - if a>=0 and a<=255 - and b>=0 and b<=255 - and c>=0 and c<=255 - and d>=0 and d<=255 - and m>=1 and m<=32 then - atom mask = power(2,32-m)-1, - addr = bytes_to_int({d,c,b,a}) - addr -= and_bits(addr,mask) - {d,c,b,a} = int_to_bytes(addr) - return sprintf("%d.%d.%d.%d/%d",{a,b,c,d,m}) - end if - end if - return "???" -end function +(phixonline)--> + with javascript_semantics -- (not likely useful) + function canonicalize_cidr(string cidr) + cidr = substitute(cidr,"."," ") -- (else %d eats 0.0 etc) + if not find('/',cidr) then cidr &= "/32" end if + sequence res = scanf(cidr,"%d %d %d %d/%d") + if length(res)=1 then + integer {a,b,c,d,m} = res[1] + if a>=0 and a<=255 + and b>=0 and b<=255 + and c>=0 and c<=255 + and d>=0 and d<=255 + and m>=1 and m<=32 then + atom mask = power(2,32-m)-1, + addr = bytes_to_int({d,c,b,a}) + addr -= and_bits(addr,mask) + {d,c,b,a} = int_to_bytes(addr) + return sprintf("%d.%d.%d.%d/%d",{a,b,c,d,m}) + end if + end if + return "???" + end function -constant tests = {"87.70.141.1/22", - "36.18.154.103/12", - "62.62.197.11/29", - "67.137.119.181/4", - "161.214.74.21/24", - "184.232.176.184/18"} -for t in tests do - printf(1,"%-18s -> %s\n",{t,canonicalize_cidr(t)}) -end for + constant tests = {"87.70.141.1/22", + "36.18.154.103/12", + "62.62.197.11/29", + "67.137.119.181/4", + "161.214.74.21/24", + "184.232.176.184/18"} + + for i=1 to length(tests) do + string ti = tests[i] + printf(1,"%-18s -> %s\n",{ti,canonicalize_cidr(ti)}) + end for + + integer n = 5, + w = power(3,n-1), + len = w + string line = repeat('#',w)&"\n" + + while 1 do + puts(1,line) + if len=1 then exit end if + len /= 3 + integer pos = 1 + while pos<(w-len) do + pos += len + line[pos..pos+len-1] = ' ' + pos += len + end while + end while + + with javascript_semantics + integer count = 0 + for p1=1 to 61 do + if is_prime(p1) then + for h3=1 to p1 do + atom h3p1 = h3 + p1 + for d=1 to h3p1-1 do + if mod(h3p1*(p1-1),d)=0 + and mod(-(p1*p1),h3) = mod(d,h3) then + atom p2 := 1 + floor(((p1-1)*h3p1)/d), + p3 := 1 +floor(p1*p2/h3) + if is_prime(p2) + and is_prime(p3) + and mod(p2*p3,p1-1)=1 then + if count<5 or count>65 then + printf(1,"%d * %d * %d = %d\n",{p1,p2,p3,p1*p2*p3}) + elsif count=35 then puts(1,"...\n") end if + count += 1 + end if + end if + end for + end for + end if + end for + printf(1,"%d Carmichael numbers found\n",count) + [ ) + [ over witheach + [ over nested + swap nested join + nested dip rot join + unrot ] + drop ] drop ] is cartprod ( [ [ --> [ ) - [ behead swap witheach cart ] is n-cart ( [ --> [ ) - - ' [ 1 2 ] ' [ 3 4 ] cart echo cr cr - ' [ 1 2 ] ' [ ] cart echo cr cr - ' [ ] ' [ 1 2 ] cart echo cr cr - - ' [ [ 1776 1789 ] [ 7 12 ] [ 4 14 23 ] [ 0 1 ] ] n-cart - say "[ " - witheach - [ i^ 0 != if [ say " " ] - echo - i 0 = if [ say " ]" ] cr ] - cr - - ' [ [ 1 2 3 ] [ 30 ] [ 500 100 ] ] n-cart echo cr cr - ' [ [ 1 2 3 ] [ ] [ 500 100 ] ] n-cart echo cr cr + ' [ 1 2 ] ' [ 3 4 ] cartprod echo cr + ' [ 3 4 ] ' [ 1 2 ] cartprod echo cr + ' [ 1 2 ] ' [ ] cartprod echo cr + ' [ ] ' [ 1 2 ] cartprod echo cr diff --git a/Task/Cartesian-product-of-two-or-more-lists/Run-BASIC/cartesian-product-of-two-or-more-lists.basic b/Task/Cartesian-product-of-two-or-more-lists/Run-BASIC/cartesian-product-of-two-or-more-lists.basic deleted file mode 100644 index 43093c62c7..0000000000 --- a/Task/Cartesian-product-of-two-or-more-lists/Run-BASIC/cartesian-product-of-two-or-more-lists.basic +++ /dev/null @@ -1,34 +0,0 @@ -cls -dim array(2,2) -array(1,1) = 1 : array(1,2) = 2 -array(2,1) = 3 : array(2,2) = 4 -gosub [cartesian] -array(1,1) = 3 : array(1,2) = 4 -array(2,1) = 1 : array(2,2) = 2 -gosub [cartesian] -end - -[cartesian] -u1 = 2 : u2 = 2 -for i = 1 to u1 - print "{"; - for j = 1 to u2 - print array(i,j); - if j < u1 then print ","; - next j - print "}"; - if i < u2 then print " x "; -next i -print " = {"; -for i = 1 to u1 - for j = 1 to u2 - print "{"; array(1,i); ","; array(2,j); "}"; - if i < u2 then - print ","; - else - if j < u1 then print ","; - end if - next j -next i -print "}" -return diff --git a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-1.rs b/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-1.rs deleted file mode 100644 index 4bde4f9f43..0000000000 --- a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-1.rs +++ /dev/null @@ -1,42 +0,0 @@ -fn cartesian_product<'a, T>(lists: &[&'a [T]]) -> Vec> { - let mut res = vec![vec![]]; - - for &list in lists { - let mut tmp = Vec::new(); - - for r in res { - for item in list { - let mut r = r.clone(); - r.push(item); - tmp.push(r); - } - } - - res = tmp; - } - - res -} - -fn main() { - let cases: [&[&[u32]]; 7] = [ - &[&[1, 2], &[3, 4]], - &[&[3, 4], &[1, 2]], - &[&[1, 2], &[]], - &[&[], &[1, 2]], - &[&[1776, 1789], &[7, 12], &[4, 14, 23], &[0, 1]], - &[&[1, 2, 3], &[30], &[500, 100]], - &[&[1, 2, 3], &[], &[500, 100]], - ]; - - for case in cases { - println!( - "{}\n{:?}\n", - case.iter() - .map(|c| format!("{:?}", c)) - .collect::>() - .join(" × "), - cartesian_product(case) - ) - } -} diff --git a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-2.rs b/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-2.rs deleted file mode 100644 index 88f569f91f..0000000000 --- a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-2.rs +++ /dev/null @@ -1,2 +0,0 @@ -[dependencies] -itertools = { version = "0.14.0", features = ["use_alloc"] } diff --git a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-3.rs b/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-3.rs deleted file mode 100644 index e8d4eff8e3..0000000000 --- a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists-3.rs +++ /dev/null @@ -1,28 +0,0 @@ -use itertools::{Itertools, MultiProduct}; - -fn cartesian_product<'a, T>(inputs: &[&'a [T]]) -> MultiProduct> { - inputs - .iter() - .map(|slice| slice.iter()) - .multi_cartesian_product() -} - -fn main() { - let cases: [&[&[u32]]; 7] = [ - &[&[1, 2], &[3, 4]], - &[&[3, 4], &[1, 2]], - &[&[1, 2], &[]], - &[&[], &[1, 2]], - &[&[1776, 1789], &[7, 12], &[4, 14, 23], &[0, 1]], - &[&[1, 2, 3], &[30], &[500, 100]], - &[&[1, 2, 3], &[], &[500, 1000]], - ]; - - for case in cases { - println!( - "{:?}\n[{:?}]\n", - case.iter().format(" × "), - cartesian_product(case).format(", ") - ); - } -} diff --git a/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists.rust b/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists.rust new file mode 100644 index 0000000000..9345a4ad79 --- /dev/null +++ b/Task/Cartesian-product-of-two-or-more-lists/Rust/cartesian-product-of-two-or-more-lists.rust @@ -0,0 +1,41 @@ +fn cartesian_product(lists: &Vec>) -> Vec> { + let mut res = vec![]; + + let mut list_iter = lists.iter(); + if let Some(first_list) = list_iter.next() { + for &i in first_list { + res.push(vec![i]); + } + } + for l in list_iter { + let mut tmp = vec![]; + for r in res { + for &el in l { + let mut tmp_el = r.clone(); + tmp_el.push(el); + tmp.push(tmp_el); + } + } + res = tmp; + } + res +} + +fn main() { + let cases = vec![ + vec![vec![1, 2], vec![3, 4]], + vec![vec![3, 4], vec![1, 2]], + vec![vec![1, 2], vec![]], + vec![vec![], vec![1, 2]], + vec![vec![1776, 1789], vec![7, 12], vec![4, 14, 23], vec![0, 1]], + vec![vec![1, 2, 3], vec![30], vec![500, 100]], + vec![vec![1, 2, 3], vec![], vec![500, 100]], + ]; + for case in cases { + println!( + "{}\n{:?}\n", + case.iter().map(|c| format!("{:?}", c)).collect::>().join(" × "), + cartesian_product(&case) + ) + } +} diff --git a/Task/Cartesian-product-of-two-or-more-lists/Scheme/cartesian-product-of-two-or-more-lists.scm b/Task/Cartesian-product-of-two-or-more-lists/Scheme/cartesian-product-of-two-or-more-lists.ss similarity index 100% rename from Task/Cartesian-product-of-two-or-more-lists/Scheme/cartesian-product-of-two-or-more-lists.scm rename to Task/Cartesian-product-of-two-or-more-lists/Scheme/cartesian-product-of-two-or-more-lists.ss diff --git a/Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua b/Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua deleted file mode 100644 index 2895add665..0000000000 --- a/Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua +++ /dev/null @@ -1,9 +0,0 @@ -# Cartesian products - -☇1⊞⊂[1 2] [3 4] -☇1⊞⊂[3 4] [1 2] -☇1⊞⊂[3 4] [] -C ← /◇(☇1⊞⊂) -≡⍚C{{[1776 1789] [7 12] [4 14 23] [0 1]} - {[1 2 3] [30] [500 100]} - {[1 2 3] [] [500 100]}} diff --git a/Task/Cartesian-product-of-two-or-more-lists/Wren/cartesian-product-of-two-or-more-lists.wren b/Task/Cartesian-product-of-two-or-more-lists/Wren/cartesian-product-of-two-or-more-lists.wren index 513e4d875a..86ff4d5f86 100644 --- a/Task/Cartesian-product-of-two-or-more-lists/Wren/cartesian-product-of-two-or-more-lists.wren +++ b/Task/Cartesian-product-of-two-or-more-lists/Wren/cartesian-product-of-two-or-more-lists.wren @@ -1,4 +1,4 @@ -import "./seq" for Lst +import "/seq" for Lst var prod2 = Fn.new { |l1, l2| var res = [] diff --git a/Task/Case-sensitivity-of-identifiers/ALGOL-M/case-sensitivity-of-identifiers.alg b/Task/Case-sensitivity-of-identifiers/ALGOL-M/case-sensitivity-of-identifiers.alg deleted file mode 100644 index 5e25c79838..0000000000 --- a/Task/Case-sensitivity-of-identifiers/ALGOL-M/case-sensitivity-of-identifiers.alg +++ /dev/null @@ -1,13 +0,0 @@ -begin - -string dog; -comment - An attempt to declare Dog or DOG after declaring - dog will result in a compile-time error ("Doubly - Declared identifier"); -dog := "Benjamin"; -Dog := "Samba"; -DOG := "Bernie"; -write("There is just one dog named ", dog); - -end diff --git a/Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.adb b/Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.adb rename to Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada diff --git a/Task/Case-sensitivity-of-identifiers/Applesoft-BASIC/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/Applesoft-BASIC/case-sensitivity-of-identifiers.basic deleted file mode 100644 index f91b185404..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Applesoft-BASIC/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1 +0,0 @@ -dog$ = "Benjamin":Dog$ = "Samba":DOG$ = "Bernie":III = 254 * (DOG$ = dog$ AND Dog$ = DOG$) + 1: PRINT MID$ ("There is just one dog",256 - III) MID$ ("The three dogs are",III)" named " MID$ (dog$ + ", " + Dog$ + " and ",III)DOG$"." diff --git a/Task/Case-sensitivity-of-identifiers/QBasic/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/BASIC/case-sensitivity-of-identifiers.basic similarity index 100% rename from Task/Case-sensitivity-of-identifiers/QBasic/case-sensitivity-of-identifiers.basic rename to Task/Case-sensitivity-of-identifiers/BASIC/case-sensitivity-of-identifiers.basic diff --git a/Task/Case-sensitivity-of-identifiers/Ballerina/case-sensitivity-of-identifiers.ballerina b/Task/Case-sensitivity-of-identifiers/Ballerina/case-sensitivity-of-identifiers.ballerina deleted file mode 100644 index 6b87eea744..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Ballerina/case-sensitivity-of-identifiers.ballerina +++ /dev/null @@ -1,8 +0,0 @@ -import ballerina/io; - -public function main() { - string dog = "Benjamin"; - string Dog = "Samba"; - string DOG = "Bernie"; - io:println(`The three dogs are named ${dog}, ${Dog} and ${DOG}.`); -} diff --git a/Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cob b/Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cobol similarity index 100% rename from Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cob rename to Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cobol diff --git a/Task/Case-sensitivity-of-identifiers/Chipmunk-Basic/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/Chipmunk-Basic/case-sensitivity-of-identifiers.basic deleted file mode 100644 index 33a43f9953..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Chipmunk-Basic/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1,5 +0,0 @@ -10 dog$ = "Benjamin" -20 dog$ = "Smokey" -30 dog$ = "Samba" -40 dog$ = "Bernie" -50 print "There is just one dog, named ";dog$ diff --git a/Task/Case-sensitivity-of-identifiers/Cowgol/case-sensitivity-of-identifiers.cowgol b/Task/Case-sensitivity-of-identifiers/Cowgol/case-sensitivity-of-identifiers.cowgol deleted file mode 100644 index c2af2406d1..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Cowgol/case-sensitivity-of-identifiers.cowgol +++ /dev/null @@ -1,13 +0,0 @@ -include "cowgol.coh"; - -var dog := "Benjamin"; -var Dog := "Samba"; -var DOG := "Bernie"; - -print("There are three dogs named "); -print(dog); -print(", "); -print(Dog); -print(", and "); -print(DOG); -print(".\n"); diff --git a/Task/Case-sensitivity-of-identifiers/Crystal/case-sensitivity-of-identifiers.cr b/Task/Case-sensitivity-of-identifiers/Crystal/case-sensitivity-of-identifiers.crystal similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Crystal/case-sensitivity-of-identifiers.cr rename to Task/Case-sensitivity-of-identifiers/Crystal/case-sensitivity-of-identifiers.crystal diff --git a/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d b/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d index 549512886a..c140100011 100644 --- a/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d +++ b/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d @@ -5,6 +5,6 @@ void main() { // identifiers that start with capital letters are type names string Dog = "Samba"; string DOG = "Bernie"; - writeln("There are three dogs named ", - dog, ", ", Dog, ", and ", DOG, "."); + writefln("There are three dogs named ", + dog, ", ", Dog, ", and ", DOG, "'"); } diff --git a/Task/Case-sensitivity-of-identifiers/Dart/case-sensitivity-of-identifiers.dart b/Task/Case-sensitivity-of-identifiers/Dart/case-sensitivity-of-identifiers.dart deleted file mode 100644 index 86cc1b7f16..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Dart/case-sensitivity-of-identifiers.dart +++ /dev/null @@ -1,5 +0,0 @@ -void main() { - String dog = "Benjamin", doG = "Smokey", Dog = "Samba", DOG = "Bernie"; - - print("The four dogs are named $dog, $doG, $Dog and $DOG"); -} diff --git a/Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.pas b/Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.delphi similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.pas rename to Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.delphi diff --git a/Task/Case-sensitivity-of-identifiers/Draco/case-sensitivity-of-identifiers.draco b/Task/Case-sensitivity-of-identifiers/Draco/case-sensitivity-of-identifiers.draco deleted file mode 100644 index c91a462895..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Draco/case-sensitivity-of-identifiers.draco +++ /dev/null @@ -1,8 +0,0 @@ -proc main() void: - *char dog = "Benjamin", - Dog = "Samba", - DOG = "Bernie"; - - writeln("There are three dogs named ", - dog, ", ", Dog, ", and ", DOG, ".") -corp diff --git a/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb b/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb deleted file mode 100644 index 0b9cd57834..0000000000 --- a/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb +++ /dev/null @@ -1,3 +0,0 @@ -create or replace function task(dog, Dog, DOG) as ( - format('The three dogs are named {:s}, {:s} and {:s}.', dog, Dog, DOG) -); diff --git a/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb b/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb deleted file mode 100644 index d7c7d9bd1c..0000000000 --- a/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb +++ /dev/null @@ -1,2 +0,0 @@ -select format('The three dogs are named {:s}, {:s} and {:s}.', dog, Dog, DOG) as example -from (select 'Benjamin' as dog, 'Samba' as Dog, 'Bernie' as DOG); diff --git a/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena b/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena index 2deacb71ce..b33d071054 100644 --- a/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena +++ b/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena @@ -1,9 +1,9 @@ import extensions; -public Program() +public program() { var dog := "Benjamin"; var Dog := "Samba"; var DOG := "Bernie"; - Console.printLineFormatted("The three dogs are named {0}, {1} and {2}", dog, Dog, DOG) + console.printLineFormatted("The three dogs are named {0}, {1} and {2}", dog, Dog, DOG) } diff --git a/Task/Case-sensitivity-of-identifiers/Elixir/case-sensitivity-of-identifiers.ex b/Task/Case-sensitivity-of-identifiers/Elixir/case-sensitivity-of-identifiers.elixir similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Elixir/case-sensitivity-of-identifiers.ex rename to Task/Case-sensitivity-of-identifiers/Elixir/case-sensitivity-of-identifiers.elixir diff --git a/Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.eu b/Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.euphoria similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.eu rename to Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.euphoria diff --git a/Task/Case-sensitivity-of-identifiers/Joy/case-sensitivity-of-identifiers.joy b/Task/Case-sensitivity-of-identifiers/Joy/case-sensitivity-of-identifiers.joy deleted file mode 100644 index 5e074a15e6..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Joy/case-sensitivity-of-identifiers.joy +++ /dev/null @@ -1,17 +0,0 @@ -DEFINE dog == "Benjamin". -DEFINE Dog == "Samba". -DEFINE DOG == "Bernie". -"The three dogs are named" -"." DOG "and" Dog "," dog "The three dogs are named" -. -"The three dogs are named" -. -"Benjamin" -. -"," -. -"Samba" -. -"and" -. -"Bernie" diff --git a/Task/Case-sensitivity-of-identifiers/Julia/case-sensitivity-of-identifiers.jl b/Task/Case-sensitivity-of-identifiers/Julia/case-sensitivity-of-identifiers.julia similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Julia/case-sensitivity-of-identifiers.jl rename to Task/Case-sensitivity-of-identifiers/Julia/case-sensitivity-of-identifiers.julia diff --git a/Task/Case-sensitivity-of-identifiers/Kotlin/case-sensitivity-of-identifiers.kts b/Task/Case-sensitivity-of-identifiers/Kotlin/case-sensitivity-of-identifiers.kotlin similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Kotlin/case-sensitivity-of-identifiers.kts rename to Task/Case-sensitivity-of-identifiers/Kotlin/case-sensitivity-of-identifiers.kotlin diff --git a/Task/Case-sensitivity-of-identifiers/LOLCODE/case-sensitivity-of-identifiers.lol b/Task/Case-sensitivity-of-identifiers/LOLCODE/case-sensitivity-of-identifiers.lol deleted file mode 100644 index bbf2bc3047..0000000000 --- a/Task/Case-sensitivity-of-identifiers/LOLCODE/case-sensitivity-of-identifiers.lol +++ /dev/null @@ -1,12 +0,0 @@ -HAI 1.3 - -I HAS A dog ITZ "Benjamin" -I HAS A Dog ITZ "Samba" -I HAS A DOG ITZ "Bernie" - -EITHER OF DIFFRINT dog AN Dog AN DIFFRINT Dog AN DOG, O RLY? - YA RLY, VISIBLE "TEH 3 DOGZ R NAEMD :{dog}, :{Dog}, AN :{DOG}." - NO WAI, VISIBLE "THERE IZ JUST 1 DOG NAEMD :{DOG}." -OIC - -KTHXBYE diff --git a/Task/Case-sensitivity-of-identifiers/MSX-Basic/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/MSX-Basic/case-sensitivity-of-identifiers.basic deleted file mode 100644 index 33a43f9953..0000000000 --- a/Task/Case-sensitivity-of-identifiers/MSX-Basic/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1,5 +0,0 @@ -10 dog$ = "Benjamin" -20 dog$ = "Smokey" -30 dog$ = "Samba" -40 dog$ = "Bernie" -50 print "There is just one dog, named ";dog$ diff --git a/Task/Case-sensitivity-of-identifiers/Minimal-BASIC/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/Minimal-BASIC/case-sensitivity-of-identifiers.basic deleted file mode 100644 index 6a764ba550..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Minimal-BASIC/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1,4 +0,0 @@ -10 let d$ = "Benjamin" -20 let D$ = "Samba" -30 print "There is just one dog, named "; d$ -40 end diff --git a/Task/Case-sensitivity-of-identifiers/N-t-roff/case-sensitivity-of-identifiers.ntroff b/Task/Case-sensitivity-of-identifiers/N-t-roff/case-sensitivity-of-identifiers.ntroff deleted file mode 100644 index 3e984ae8e8..0000000000 --- a/Task/Case-sensitivity-of-identifiers/N-t-roff/case-sensitivity-of-identifiers.ntroff +++ /dev/null @@ -1,4 +0,0 @@ -.ds dog Benjamin -.ds Dog Samba -.ds DOG Bernie -The three dogs are named \*[dog], \*[Dog] and \*[DOG]. diff --git a/Task/Case-sensitivity-of-identifiers/Nim/case-sensitivity-of-identifiers.nim b/Task/Case-sensitivity-of-identifiers/Nim/case-sensitivity-of-identifiers.nim index 37894e4681..6968431516 100644 --- a/Task/Case-sensitivity-of-identifiers/Nim/case-sensitivity-of-identifiers.nim +++ b/Task/Case-sensitivity-of-identifiers/Nim/case-sensitivity-of-identifiers.nim @@ -3,7 +3,7 @@ var dog, Dog: string if dog == Dog: if dog == DOG: - echo "There is only one dog, ", DOG + echo "There is only one dog, ", DOG) else: echo "There are two dogs: ", dog, " and ", DOG elif Dog == DOG : diff --git a/Task/Case-sensitivity-of-identifiers/OCaml/case-sensitivity-of-identifiers.ml b/Task/Case-sensitivity-of-identifiers/OCaml/case-sensitivity-of-identifiers.ocaml similarity index 100% rename from Task/Case-sensitivity-of-identifiers/OCaml/case-sensitivity-of-identifiers.ml rename to Task/Case-sensitivity-of-identifiers/OCaml/case-sensitivity-of-identifiers.ocaml diff --git a/Task/Case-sensitivity-of-identifiers/Oberon/case-sensitivity-of-identifiers.oberon b/Task/Case-sensitivity-of-identifiers/Oberon-2/case-sensitivity-of-identifiers.oberon similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Oberon/case-sensitivity-of-identifiers.oberon rename to Task/Case-sensitivity-of-identifiers/Oberon-2/case-sensitivity-of-identifiers.oberon diff --git a/Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas b/Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas deleted file mode 100644 index d697568ba5..0000000000 --- a/Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas +++ /dev/null @@ -1,8 +0,0 @@ -var - dog: string; -begin - dog := 'Benjamin'; - Dog := 'Samba'; - DOG := 'Bernie'; - Writeln('There is just one dog named ' + dog); -end. diff --git a/Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto b/Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto deleted file mode 100644 index 79d19b3417..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto +++ /dev/null @@ -1,13 +0,0 @@ -do - local dog = "Benjamin"; - do - local Dog = "Samba"; - do - local DOG = "Bernie"; - if DOG != Dog or DOG != dog - then print( $"The three dogs are named: {dog}, {Dog} and {DOG}" ) - else print( $"There is just one dog named: {DOG}" ) - end - end - end -end diff --git a/Task/Case-sensitivity-of-identifiers/PowerShell/case-sensitivity-of-identifiers.ps1 b/Task/Case-sensitivity-of-identifiers/PowerShell/case-sensitivity-of-identifiers.psh similarity index 100% rename from Task/Case-sensitivity-of-identifiers/PowerShell/case-sensitivity-of-identifiers.ps1 rename to Task/Case-sensitivity-of-identifiers/PowerShell/case-sensitivity-of-identifiers.psh diff --git a/Task/Case-sensitivity-of-identifiers/Quite-BASIC/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/Quite-BASIC/case-sensitivity-of-identifiers.basic deleted file mode 100644 index 6a764ba550..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Quite-BASIC/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1,4 +0,0 @@ -10 let d$ = "Benjamin" -20 let D$ = "Samba" -30 print "There is just one dog, named "; d$ -40 end diff --git a/Task/Case-sensitivity-of-identifiers/Red/case-sensitivity-of-identifiers.red b/Task/Case-sensitivity-of-identifiers/Red/case-sensitivity-of-identifiers.red deleted file mode 100644 index 5d1432eea1..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Red/case-sensitivity-of-identifiers.red +++ /dev/null @@ -1,8 +0,0 @@ -dog: "Benjamin" -Dog: "Samba" -DOG: "Bernie" - -print [ "The three dogs are " dog "," Dog "," DOG ] - -;- as Red is not case sensitive, will ouput -;- The three dogs are Bernie , Bernie , Bernie diff --git a/Task/Case-sensitivity-of-identifiers/Refal/case-sensitivity-of-identifiers.refal b/Task/Case-sensitivity-of-identifiers/Refal/case-sensitivity-of-identifiers.refal deleted file mode 100644 index 11adce0813..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Refal/case-sensitivity-of-identifiers.refal +++ /dev/null @@ -1,6 +0,0 @@ -$ENTRY Go { - , 'Benjamin': e.dog - , 'Samba': e.Dog - , 'Bernie': e.DOG - = ; -}; diff --git a/Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-1.rs b/Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-1.rust similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-1.rs rename to Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-1.rust diff --git a/Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-2.rs b/Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-2.rust similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-2.rs rename to Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-2.rust diff --git a/Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-3.rs b/Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-3.rust similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-3.rs rename to Task/Case-sensitivity-of-identifiers/Rust/case-sensitivity-of-identifiers-3.rust diff --git a/Task/Case-sensitivity-of-identifiers/S-BASIC/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/S-BASIC/case-sensitivity-of-identifiers.basic deleted file mode 100644 index de5524ecca..0000000000 --- a/Task/Case-sensitivity-of-identifiers/S-BASIC/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1,13 +0,0 @@ -var dog = string -comment - An attempt to declare Dog or DOG after declaring dog - will result in a compile-time error ("One of these VAR - names in use") -end - -dog = "Benjamin" -Dog = "Samba" -DOG = "Bernie" -print "There is just one dog named "; dog - -end diff --git a/Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.scm b/Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.ss similarity index 100% rename from Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.scm rename to Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.ss diff --git a/Task/Case-sensitivity-of-identifiers/Swift/case-sensitivity-of-identifiers.swift b/Task/Case-sensitivity-of-identifiers/Swift/case-sensitivity-of-identifiers.swift index e0af4e9df0..b027c8aadd 100644 --- a/Task/Case-sensitivity-of-identifiers/Swift/case-sensitivity-of-identifiers.swift +++ b/Task/Case-sensitivity-of-identifiers/Swift/case-sensitivity-of-identifiers.swift @@ -1,4 +1,4 @@ let dog = "Benjamin" let Dog = "Samba" let DOG = "Bernie" -print("The three dogs are named \(dog), \(Dog), and \(DOG).") +println("The three dogs are named \(dog), \(Dog), and \(DOG).") diff --git a/Task/Case-sensitivity-of-identifiers/XBasic/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/XBasic/case-sensitivity-of-identifiers.basic deleted file mode 100644 index 4ee1be6618..0000000000 --- a/Task/Case-sensitivity-of-identifiers/XBasic/case-sensitivity-of-identifiers.basic +++ /dev/null @@ -1,14 +0,0 @@ -PROGRAM "Case-sensitivity" -VERSION "0.0000" - -DECLARE FUNCTION Entry () - -FUNCTION Entry () - dog$ = "Benjamin" - dog$ = "Smokey" - dog$ = "Samba" - dog$ = "Bernie" - - PRINT "There is just one dog, named "; dog$ -END FUNCTION -END PROGRAM diff --git a/Task/Case-sensitivity-of-identifiers/Yabasic/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/Yabasic/case-sensitivity-of-identifiers.basic index 4cbeda196b..2e3c195cdf 100644 --- a/Task/Case-sensitivity-of-identifiers/Yabasic/case-sensitivity-of-identifiers.basic +++ b/Task/Case-sensitivity-of-identifiers/Yabasic/case-sensitivity-of-identifiers.basic @@ -1,6 +1,5 @@ dog$ = "Benjamin" -doG$ = "Smokey" Dog$ = "Samba" DOG$ = "Bernie" -print "The four dogs are named ", dog$, ", ", doG$, ", ", Dog$, " and ", DOG$ +print "The three dogs are named ", dog$, ", ", Dog$, " and ", DOG$ end diff --git a/Task/Case-sensitivity-of-identifiers/Zig/case-sensitivity-of-identifiers.zig b/Task/Case-sensitivity-of-identifiers/Zig/case-sensitivity-of-identifiers.zig deleted file mode 100644 index 46dbdaaf75..0000000000 --- a/Task/Case-sensitivity-of-identifiers/Zig/case-sensitivity-of-identifiers.zig +++ /dev/null @@ -1,9 +0,0 @@ -const std = @import("std"); - -pub fn main() void { - const dog = "Benjamin"; - const Dog = "Samba"; - const DOG = "Bernie"; - - std.debug.print("The three dogs are named {s}, {s}, and {s}.\n", .{ dog, Dog, DOG }); -} diff --git a/Task/Casting-out-nines/ABC/casting-out-nines.abc b/Task/Casting-out-nines/ABC/casting-out-nines.abc deleted file mode 100644 index 72dd29d4b4..0000000000 --- a/Task/Casting-out-nines/ABC/casting-out-nines.abc +++ /dev/null @@ -1,12 +0,0 @@ -\ casting out nines - based on the Action! sample - -HOW TO ADD v TO n: PUT n + v IN n - -PUT 10, 2, 0, 0 IN base, n, count, total -FOR i IN { 1 .. base ** n }: - ADD 1 TO total - IF i mod ( base - 1 ) = ( i * i ) mod ( base - 1 ): - ADD 1 TO count - WRITE i -WRITE // "Trying", count, "numbers instead of", total, "numbers saves" -WRITE 100 - ( ( 100 * count ) / total ), "%" / diff --git a/Task/Casting-out-nines/BASIC256/casting-out-nines.basic b/Task/Casting-out-nines/BASIC256/casting-out-nines.basic deleted file mode 100644 index a11ff0fa58..0000000000 --- a/Task/Casting-out-nines/BASIC256/casting-out-nines.basic +++ /dev/null @@ -1,10 +0,0 @@ -base = 10 -c1 = 0 -c2 = 0 -for k = 1 to (base ^ 2) - 1 - c1 += 1 - if k % (base - 1) = (k * k) % (base - 1) then c2 += 1: print k; " "; -next k -print -print "Trying "; c2; " numbers instead of "; c1; " numbers saves "; 100 - (100 * c2 / c1); "%" -end diff --git a/Task/Casting-out-nines/Chipmunk-Basic/casting-out-nines.basic b/Task/Casting-out-nines/Chipmunk-Basic/casting-out-nines.basic deleted file mode 100644 index b605fc071d..0000000000 --- a/Task/Casting-out-nines/Chipmunk-Basic/casting-out-nines.basic +++ /dev/null @@ -1,9 +0,0 @@ -100 cls -110 bs = 10 : c1 = 0 : c2 = 0 -120 for k = 1 to (bs^2)-1 -130 c1 = c1+1 -140 if k mod (bs-1) = (k*k) mod (bs-1) then c2 = c2+1 : print k; -150 next k -160 print -170 print "Trying ";c2;"numbers instead of ";c1;"numbers saves ";100-(100*c2/c1);"%" -180 end diff --git a/Task/Casting-out-nines/EasyLang/casting-out-nines.easy b/Task/Casting-out-nines/EasyLang/casting-out-nines.easy deleted file mode 100644 index 46412c7702..0000000000 --- a/Task/Casting-out-nines/EasyLang/casting-out-nines.easy +++ /dev/null @@ -1,10 +0,0 @@ -base = 10 -for k = 1 to base * base - 1 - c1 += 1 - if k mod (base - 1) = (k * k) mod (base - 1) - c2 += 1 - write k & " " - . -. -print "" -print "Trying " & c2 & " numbers instead of " & c1 & " numbers saves " & 100 - 100 * c2 / c1 diff --git a/Task/Casting-out-nines/Fortran/casting-out-nines.f b/Task/Casting-out-nines/Fortran/casting-out-nines.f deleted file mode 100644 index a2e0705db8..0000000000 --- a/Task/Casting-out-nines/Fortran/casting-out-nines.f +++ /dev/null @@ -1,220 +0,0 @@ -program main - implicit none - - type :: test_case - integer :: base - character(len=10) :: begin, end_ - character(len=10), dimension(5) :: kaprekar - integer :: nkap - end type test_case - - type(test_case), dimension(2) :: testcases - type(test_case) :: tc - integer :: it, i, j - character(len=20), allocatable :: s(:) - logical :: found - - ! Initialize test cases - testcases(1)%base = 10 - testcases(1)%begin = '1' - testcases(1)%end_ = '100' - testcases(1)%kaprekar(1:5) = (/'1 ', '9 ', '45 ', '55 ', '99 '/) - testcases(1)%nkap = 5 - - testcases(2)%base = 17 - testcases(2)%begin = '10' - testcases(2)%end_ = 'gg' - testcases(2)%kaprekar(1:3) = (/'3d', 'd4', 'gg'/) - testcases(2)%nkap = 3 - - do it = 1, 2 - tc = testcases(it) - write(*, *) '' - write(*, '(A, I0, A, A, A, A)') 'Test case base = ', tc%base, ', begin = ', trim(tc%begin), ', end = ', trim(tc%end_) - call subset(tc%base, tc%begin, tc%end_, s) - write(*, '(A)', advance='no') 'Subset: ' - do i = 1, size(s) - write(*, '(A, A)', advance='no') trim(s(i)), ' ' - end do - write(*, *) - write(*, '(A)', advance='no') 'Kaprekar: ' - do i = 1, tc%nkap - write(*, '(A, A)', advance='no') trim(tc%kaprekar(i)), ' ' - end do - write(*, *) - - ! Check if all Kaprekar are in subset - j = 1 - do i = 1, tc%nkap - found = .false. - do while (j <= size(s)) - if (trim(s(j)) == trim(tc%kaprekar(i))) then - found = .true. - j = j + 1 - exit - end if - j = j + 1 - end do - if (.not. found) then - write(*, '(A, A, A)') 'Fail: ', trim(tc%kaprekar(i)), ' not in subset' - stop - end if - end do - write(*, *) 'Valid subset.' - if (allocated(s)) deallocate(s) - end do - -contains - - subroutine subset(base, begin, end_, s) - integer, intent(in) :: base - character(len=*), intent(in) :: begin, end_ - character(len=20), allocatable, intent(out) :: s(:) - integer(8) :: begin64, end64, k, kk - character(len=20) :: ks, kks - character(1) :: rk, rk2 - - begin64 = str_to_int(base, begin) - end64 = str_to_int(base, end_) - - allocate(s(0)) ! Start empty - - do k = begin64, end64 - ks = int_to_str(base, k) - rk = check_digit(base, ks) - kk = k * k - kks = int_to_str(base, kk) - rk2 = check_digit(base, kks) - if (rk == rk2) then - call append_str(s, ks) - end if - end do - end subroutine subset - - subroutine append_str(list, val) - character(len=20), allocatable, intent(inout) :: list(:) - character(len=*), intent(in) :: val - character(len=20), allocatable :: tmp(:) - - if (allocated(list)) then - allocate(tmp(size(list))) - tmp = list - deallocate(list) - allocate(list(size(tmp) + 1)) - list(1:size(tmp)) = tmp - list(size(tmp) + 1) = val - else - allocate(list(1)) - list(1) = val - end if - end subroutine append_str - - recursive function check_digit(base, n) result(r) - integer, intent(in) :: base - character(len=*), intent(in) :: n - character(1) :: r - character(1) :: d, b9 - character(len=20) :: s, s9 - integer :: i, v9 - - v9 = base - 1 - s9 = int_to_str(base, int(v9, 8)) - b9 = s9(1:1) ! Single digit - - r = '0' - do i = 1, len_trim(n) - d = n(i:i) - if (d == b9) cycle - if (r == '0') then - r = d - cycle - end if - s = add_digits(base, r, d) - if (trim(s) == trim(s9)) then - r = '0' - cycle - end if - if (len_trim(s) == 1) then - r = s(1:1) - cycle - end if - ! Recurse on two-digit sum - r = check_digit(base, trim(s)) - end do - end function check_digit - - function add_digits(base, a, b) result(res) - integer, intent(in) :: base - character(1), intent(in) :: a, b - character(len=20) :: res - integer :: ai, bi - - ai = digit_value(a, base) - bi = digit_value(b, base) - res = int_to_str(base, int(ai + bi, 8)) - end function add_digits - - function digit_value(c, base) result(v) - character(1), intent(in) :: c - integer, intent(in) :: base - integer :: v - - if (c >= '0' .and. c <= '9') then - v = iachar(c) - iachar('0') - else if (c >= 'a' .and. c <= 'z') then - v = 10 + iachar(c) - iachar('a') - else - stop 'invalid digit' - end if - if (v < 0 .or. v >= base) stop 'invalid digit for base' - end function digit_value - - function value_to_digit(v) result(c) - integer, intent(in) :: v - character(1) :: c - - if (v < 10) then - c = achar(iachar('0') + v) - else - c = achar(iachar('a') + v - 10) - end if - end function value_to_digit - - function int_to_str(base, k) result(s) - integer, intent(in) :: base - integer(8), intent(in) :: k - character(len=20) :: s - integer(8) :: kk - integer :: digit - - kk = k - if (kk < 0) kk = -kk ! But not handling negatives in this context - s = '' - if (kk == 0) then - s = '0' - return - end if - do while (kk > 0) - digit = mod(kk, int(base, 8)) - s = value_to_digit(digit) // s - kk = kk / int(base, 8) - end do - end function int_to_str - - function str_to_int(base, s) result(val) - integer, intent(in) :: base - character(len=*), intent(in) :: s - integer(8) :: val - integer :: i, lens, v - character(len=20) :: ss - - ss = adjustl(s) - lens = len_trim(ss) - val = 0 - do i = 1, lens - v = digit_value(ss(i:i), base) - val = val * int(base, 8) + int(v, 8) - end do - end function str_to_int - -end program main diff --git a/Task/Casting-out-nines/Free-Pascal-Lazarus/casting-out-nines.pas b/Task/Casting-out-nines/Free-Pascal/casting-out-nines.pas similarity index 100% rename from Task/Casting-out-nines/Free-Pascal-Lazarus/casting-out-nines.pas rename to Task/Casting-out-nines/Free-Pascal/casting-out-nines.pas diff --git a/Task/Casting-out-nines/Gambas/casting-out-nines.gambas b/Task/Casting-out-nines/Gambas/casting-out-nines.gambas deleted file mode 100644 index 64769e472e..0000000000 --- a/Task/Casting-out-nines/Gambas/casting-out-nines.gambas +++ /dev/null @@ -1,16 +0,0 @@ -Public Sub Main() - - Dim base10 As Integer = 10 - Dim c1 As Integer = 0, c2 As Integer = 0, k As Integer - - For k = 1 To base10 ^ 2 - c1 += 1 - If (k Mod (base10 - 1) = (k * k) Mod (base10 - 1)) Then - c2 += 1 - Print k; " "; - End If - Next - - Print "\nTrying "; c2; " numbers instead of "; c1; " numbers saves "; 100 - (100 * c2 / c1); "%" - -End diff --git a/Task/Casting-out-nines/Julia/casting-out-nines.jl b/Task/Casting-out-nines/Julia/casting-out-nines.julia similarity index 100% rename from Task/Casting-out-nines/Julia/casting-out-nines.jl rename to Task/Casting-out-nines/Julia/casting-out-nines.julia diff --git a/Task/Casting-out-nines/Kotlin/casting-out-nines.kts b/Task/Casting-out-nines/Kotlin/casting-out-nines.kotlin similarity index 100% rename from Task/Casting-out-nines/Kotlin/casting-out-nines.kts rename to Task/Casting-out-nines/Kotlin/casting-out-nines.kotlin diff --git a/Task/Casting-out-nines/MSX-Basic/casting-out-nines.basic b/Task/Casting-out-nines/MSX-Basic/casting-out-nines.basic deleted file mode 100644 index e8b2011dcd..0000000000 --- a/Task/Casting-out-nines/MSX-Basic/casting-out-nines.basic +++ /dev/null @@ -1,9 +0,0 @@ -100 CLS -110 BS = 10 : C1 = 0 : C2 = 0 -120 FOR K = 1 TO (BS^2)-1 -130 C1 = C1+1 -140 IF K MOD (BS-1) = (K*K) MOD (BS-1) THEN C2 = C2+1 : PRINT K; -150 NEXT K -160 PRINT -170 PRINT USING "Trying ## numbers instead of ### numbers saves ##.##%";C2;C1;100-(100*C2/C1) -180 END diff --git a/Task/Casting-out-nines/PascalABC.NET/casting-out-nines.pas b/Task/Casting-out-nines/PascalABC.NET/casting-out-nines.pas deleted file mode 100644 index 3c185151a6..0000000000 --- a/Task/Casting-out-nines/PascalABC.NET/casting-out-nines.pas +++ /dev/null @@ -1,16 +0,0 @@ -## -function co9(x: integer): integer; -begin - if x = 9 then result := 0 - else if x < 9 then result := x - else result := co9(x.ToString.select(x -> StrToInt(x)).sum); -end; - -var kaprekars := [1, 9, 45, 55, 99, 297, 703, 999]; - -Print('Checksums: '); (1..20).Select(x -> co9(x)).Println; -Print('co9(k) = co9(k*k): '); -Println((1..1000).Where(x -> co9(x) = co9(x * x))); -var part2 := (1..1000).Where(x -> co9(x) = co9(x * x)).ToSet; -Println('Kaprekars: ', kaprekars); -if kaprekars <= part2 then Println('Kaprekars are included.', part2.Count, 'numbers in range 1000'); diff --git a/Task/Casting-out-nines/Pluto/casting-out-nines.pluto b/Task/Casting-out-nines/Pluto/casting-out-nines.pluto deleted file mode 100644 index 123bf40ebc..0000000000 --- a/Task/Casting-out-nines/Pluto/casting-out-nines.pluto +++ /dev/null @@ -1,30 +0,0 @@ -local function cast_out(base, start, finish) - local b = base - 1 - local ran = range(0, b - 1):filter(|n| -> n % b == (n * n) % b) - local x = start // b - local result = {} - while true do - for ran as n do - local k = b * x + n - if k >= start then - if k > finish then return result end - result:insert(k) - end - end - ++x - end -end - -local function print_array(a, w = 3, n = 10) - for i = 1, #a do - io.write(string.format($"%{w}d ", a[i])) - if i % n == 0 then print() end - end - if #a % 10 != n then print() end -end - -print_array(cast_out(16, 1, 255)) -print() -print_array(cast_out(10, 1, 99)) -print() -print_array(cast_out(17, 1, 288)) diff --git a/Task/Casting-out-nines/PureBasic/casting-out-nines.basic b/Task/Casting-out-nines/PureBasic/casting-out-nines.basic deleted file mode 100644 index 5428d61c14..0000000000 --- a/Task/Casting-out-nines/PureBasic/casting-out-nines.basic +++ /dev/null @@ -1,18 +0,0 @@ -OpenConsole() -Define.i base, c1, c2, k - -base = 10 -c1 = 0 -c2 = 0 -For k = 1 To Pow(base, 2) - 1 - c1 + 1 - If k % (base - 1) = (k * k) % (base - 1) - c2 + 1 - Print(Str(k) + " ") - EndIf -Next k - -PrintN(#CRLF$ + "Trying " + Str(c2) + " numbers instead of " + Str(c1) + " numbers saves " + Str(100 - (100 * c2 / c1)) + "%") - -PrintN(#CRLF$ + "Press ENTER to exit"): Input() -CloseConsole() diff --git a/Task/Casting-out-nines/QBasic/casting-out-nines.basic b/Task/Casting-out-nines/QBasic/casting-out-nines.basic deleted file mode 100644 index 56d9ac30e9..0000000000 --- a/Task/Casting-out-nines/QBasic/casting-out-nines.basic +++ /dev/null @@ -1,8 +0,0 @@ -CLS -bs = 10: c1 = 0: c2 = 0 -FOR k = 1 TO (bs ^ 2) - 1 - c1 = c1 + 1 - IF k MOD (bs - 1) = (k * k) MOD (bs - 1) THEN c2 = c2 + 1: PRINT k; -NEXT k -PRINT -PRINT USING "Trying ## numbers instead of ### numbers saves ##.##%"; c2; c1; 100 - (100 * c2 / c1) diff --git a/Task/Casting-out-nines/R/casting-out-nines.r b/Task/Casting-out-nines/R/casting-out-nines.r deleted file mode 100644 index 6b66c9b2b5..0000000000 --- a/Task/Casting-out-nines/R/casting-out-nines.r +++ /dev/null @@ -1,5 +0,0 @@ -co9 <- function(base) { - x <- 1:(base^2-1) - x[(x %% (base-1)) == (x^2 %% (base-1))] -} -Map(co9,c(10,16,17)) diff --git a/Task/Casting-out-nines/Run-BASIC/casting-out-nines.basic b/Task/Casting-out-nines/Run-BASIC/casting-out-nines.basic deleted file mode 100644 index 037b9067c8..0000000000 --- a/Task/Casting-out-nines/Run-BASIC/casting-out-nines.basic +++ /dev/null @@ -1,10 +0,0 @@ -base = 10 -c1 = 0 -c2 = 0 -for k = 1 to (base ^ 2) - 1 - c1 = c1 + 1 - if k mod (base - 1) = (k * k) mod (base - 1) then c2 = c2 + 1: print k; " "; -next k -print -print "Trying "; using("##", c2); " numbers instead of "; using("###", c1); " numbers saves "; using("##.##", (100 - (100 * c2 / c1))); "%" -end diff --git a/Task/Casting-out-nines/Rust/casting-out-nines.rs b/Task/Casting-out-nines/Rust/casting-out-nines.rust similarity index 100% rename from Task/Casting-out-nines/Rust/casting-out-nines.rs rename to Task/Casting-out-nines/Rust/casting-out-nines.rust diff --git a/Task/Casting-out-nines/True-BASIC/casting-out-nines.basic b/Task/Casting-out-nines/True-BASIC/casting-out-nines.basic deleted file mode 100644 index b61f3b8db4..0000000000 --- a/Task/Casting-out-nines/True-BASIC/casting-out-nines.basic +++ /dev/null @@ -1,13 +0,0 @@ -LET bs = 10 -LET c1 = 0 -LET c2 = 0 -FOR k = 1 TO (bs^2)-1 - LET c1 = c1 + 1 - IF REMAINDER(k,(bs-1)) = REMAINDER((k*k),(bs-1)) THEN - LET c2 = c2 + 1 - PRINT k; - END IF -NEXT k -PRINT -PRINT USING "Trying ## numbers instead of ### numbers saves ##.##%": c2, c1, 100-(100*c2/c1) -END diff --git a/Task/Casting-out-nines/XBasic/casting-out-nines.basic b/Task/Casting-out-nines/XBasic/casting-out-nines.basic deleted file mode 100644 index 25621a5d46..0000000000 --- a/Task/Casting-out-nines/XBasic/casting-out-nines.basic +++ /dev/null @@ -1,17 +0,0 @@ -PROGRAM "Casting out nines" -VERSION "0.0000" - -DECLARE FUNCTION Entry () - -FUNCTION Entry () - bs = 10 - c1 = 0 - c2 = 0 - FOR k = 1 TO (bs ** 2) - 1 - INC c1 - IF k MOD (bs - 1) = (k * k) MOD (bs - 1) THEN INC c2: PRINT k; - NEXT k - PRINT - PRINT "Trying "; c2; " numbers instead of "; c1; " numbers saves "; 100 - (100 * c2 / c1); "%" -END FUNCTION -END PROGRAM diff --git a/Task/Casting-out-nines/Yabasic/casting-out-nines.basic b/Task/Casting-out-nines/Yabasic/casting-out-nines.basic deleted file mode 100644 index 502e8d6d5d..0000000000 --- a/Task/Casting-out-nines/Yabasic/casting-out-nines.basic +++ /dev/null @@ -1,9 +0,0 @@ -base = 10 -c1 = 0 -c2 = 0 -for k = 1 to (base ^ 2) - 1 - c1 = c1 + 1 - if mod(k, (base - 1)) = mod((k * k), (base - 1)) then c2 = c2 + 1: print k, " "; : fi -next k -print "\nTrying ", c2 using("##"), " numbers instead of ", c1 using("###"), " numbers saves ", (100 - (100 * c2 / c1)) using("##.##"), "%" -end diff --git a/Task/Catalan-numbers-Pascals-triangle/360-Assembly/catalan-numbers-pascals-triangle.360 b/Task/Catalan-numbers-Pascals-triangle/360-Assembly/catalan-numbers-pascals-triangle.360 index 633d55d35e..a0cc83dae1 100644 --- a/Task/Catalan-numbers-Pascals-triangle/360-Assembly/catalan-numbers-pascals-triangle.360 +++ b/Task/Catalan-numbers-Pascals-triangle/360-Assembly/catalan-numbers-pascals-triangle.360 @@ -68,7 +68,7 @@ ENLOOP2J EQU * MVC C,Z OI C+L'C-1,X'F0' MVC WTOBUF(8),C+8 - WTO MF=(E,WTOMSG) + WTO MF=(E,WTOMSG) B LOOPI ENDLOOPI EQU * * ---- END CODE diff --git a/Task/Catalan-numbers-Pascals-triangle/Ada/catalan-numbers-pascals-triangle.adb b/Task/Catalan-numbers-Pascals-triangle/Ada/catalan-numbers-pascals-triangle.ada similarity index 100% rename from Task/Catalan-numbers-Pascals-triangle/Ada/catalan-numbers-pascals-triangle.adb rename to Task/Catalan-numbers-Pascals-triangle/Ada/catalan-numbers-pascals-triangle.ada diff --git a/Task/Catalan-numbers-Pascals-triangle/Applesoft-BASIC/catalan-numbers-pascals-triangle.basic b/Task/Catalan-numbers-Pascals-triangle/Applesoft-BASIC/catalan-numbers-pascals-triangle.basic deleted file mode 100644 index 3c43ec09a4..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/Applesoft-BASIC/catalan-numbers-pascals-triangle.basic +++ /dev/null @@ -1,12 +0,0 @@ -10 HOME -20 n = 15 -30 DIM t(n+2) -50 t(1) = 1 -55 PRINT "The first 15 Catalan numbers are: "; CHR$(10) -60 FOR i = 1 TO n -70 FOR j = i TO 1 STEP -1 : t(j) = t(j) + t(j-1) : NEXT j -80 t(i+1) = t(i) -90 FOR j = i+1 TO 1 STEP -1 : t(j) = t(j) + t(j-1) : NEXT j -100 PRINT i; ": "; t(i+1) - t(i) -120 NEXT i -130 END diff --git a/Task/Catalan-numbers-Pascals-triangle/AutoHotkey/catalan-numbers-pascals-triangle.ahk b/Task/Catalan-numbers-Pascals-triangle/AutoHotkey/catalan-numbers-pascals-triangle.ahk index 67ce3c01c6..4921c4ed98 100644 --- a/Task/Catalan-numbers-Pascals-triangle/AutoHotkey/catalan-numbers-pascals-triangle.ahk +++ b/Task/Catalan-numbers-Pascals-triangle/AutoHotkey/catalan-numbers-pascals-triangle.ahk @@ -6,25 +6,25 @@ Array := [], Array[2,1] := Array[2,2] := 1 ; Array inititated and 2nd row of pas INI := 3 ; starts with calculating the 3rd row and as such the value Loop, 31 ; every odd row is taken for calculating catalan number as such to obtain 15 we need 2n+1 { - if ( A_index > 2 ) - { - Loop, % A_INDEX - { - old := ini-1, index := A_index, index_1 := A_index + 1 - Array[ini, index_1] := Array[old, index] + Array[old, index_1] - Array[ini, 1] := Array[ini, ini] := 1 - line .= Array[ini, A_index] " " - } - ;~ MsgBox % line ; gives rows of pascal's triangle - ; calculating every odd row starting from 1st so as to obtain catalan's numbers - if ( mod(ini,2) != 0) - { - StringSplit, res, line, %A_Space% - ans := res0//2, ans_1 := ans++ - result := result . res%ans_1% - res%ans% " " - } - line := - ini++ - } + if ( A_index > 2 ) + { + Loop, % A_INDEX + { + old := ini-1, index := A_index, index_1 := A_index + 1 + Array[ini, index_1] := Array[old, index] + Array[old, index_1] + Array[ini, 1] := Array[ini, ini] := 1 + line .= Array[ini, A_index] " " + } + ;~ MsgBox % line ; gives rows of pascal's triangle + ; calculating every odd row starting from 1st so as to obtain catalan's numbers + if ( mod(ini,2) != 0) + { + StringSplit, res, line, %A_Space% + ans := res0//2, ans_1 := ans++ + result := result . res%ans_1% - res%ans% " " + } + line := + ini++ + } } MsgBox % result diff --git a/Task/Catalan-numbers-Pascals-triangle/Batch-File/catalan-numbers-pascals-triangle.bat b/Task/Catalan-numbers-Pascals-triangle/Batch-File/catalan-numbers-pascals-triangle.bat index 9c096844a1..707de0dc95 100644 --- a/Task/Catalan-numbers-Pascals-triangle/Batch-File/catalan-numbers-pascals-triangle.bat +++ b/Task/Catalan-numbers-Pascals-triangle/Batch-File/catalan-numbers-pascals-triangle.bat @@ -8,15 +8,15 @@ for /L %%i in (1,1,%n%) do ( set /A ip=%%i+1 for /L %%j in (%%i,-1,1) do ( set /A jm=%%j-1 - set /A t.%%j=t.%%j+t.!jm! - ) - set /A t.!ip!=t.%%i + set /A t.%%j=t.%%j+t.!jm! + ) + set /A t.!ip!=t.%%i for /L %%j in (!ip!,-1,1) do ( set /A jm=%%j-1 - set /A t.%%j=t.%%j+t.!jm! - ) + set /A t.%%j=t.%%j+t.!jm! + ) set /A ci=t.!ip!-t.%%i - echo !ci! + echo !ci! ) ) pause diff --git a/Task/Catalan-numbers-Pascals-triangle/Chipmunk-Basic/catalan-numbers-pascals-triangle.basic b/Task/Catalan-numbers-Pascals-triangle/Chipmunk-Basic/catalan-numbers-pascals-triangle.basic deleted file mode 100644 index 1e968a5219..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/Chipmunk-Basic/catalan-numbers-pascals-triangle.basic +++ /dev/null @@ -1,13 +0,0 @@ -100 cls -110 n = 15 -120 dim t(n+2) -130 t(1) = 1 -140 print "The first 15 Catalan numbers are: ";chr$(10) -150 for i = 1 to n -160 for j = i to 1 step -1 : t(j) = t(j)+t(j-1) : next j -170 t(i+1) = t(i) -180 for j = i+1 to 1 step -1 : t(j) = t(j)+t(j-1) : next j -190 print using "###";i;": "; -200 print using "#########";t(i+1)-t(i) -210 next i -220 end diff --git a/Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb b/Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb deleted file mode 100644 index 90833b9fbe..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb +++ /dev/null @@ -1,20 +0,0 @@ -# Compute nCr naively using UHUGEINT -# The caller should ensure 2r < n -create or replace function nCr_(n, r) as - (with recursive cte as - (SELECT 1::UHUGEINT as c, n as numerator, 1::UHUGEINT as m - UNION ALL - SELECT (c * numerator / m) as c, - (numerator - 1) as numerator, - (m + 1) as m - FROM cte - WHERE m <= r) - SELECT last(c order by m) - FROM cte -); - -create or replace function nCr(n,r) as ( - if( n - N2=N*(S+S), - D2=D*S, - K = N2 div D2 ; + N2=N*(S+S), + D2=D*S, + K = N2 div D2 ; mul(N,D,S,L)-> - N2=N*(S+L), - D2=D*L, - K = mul(N2,D2,S,L+1). - + N2=N*(S+L), + D2=D*L, + K = mul(N2,D2,S,L+1). + catl(Ans,16) -> Ans; catl(D,S)-> - C=mul(1,1,S,2), - catl([D|C],S+1). + C=mul(1,1,S,2), + catl([D|C],S+1). main()-> - Ans=catl(1,2). + Ans=catl(1,2). diff --git a/Task/Catalan-numbers-Pascals-triangle/Fortran/catalan-numbers-pascals-triangle.f b/Task/Catalan-numbers-Pascals-triangle/Fortran/catalan-numbers-pascals-triangle.f deleted file mode 100644 index aeb18b829c..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/Fortran/catalan-numbers-pascals-triangle.f +++ /dev/null @@ -1,64 +0,0 @@ - ! Catalan numbers/Pascal's triangle - ! - ! tested with Intel ifx (IFX) 2025.2.0 20250605 on Kubuntu 25.04 - ! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 - ! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 - ! Note that VMS requires switch $Fortran/ccdefault=LIST - ! otherwise 1st character of each output line is interpreted as - ! Carriage Control character. - ! U.B., July 2025 - - program calc_catalan - implicit none - - integer, parameter :: nMax=15 ! Number of catalan numbers to print - integer :: catalan ! result of calculation - integer :: i, j ! Loop indices - integer :: t(nMax+3) ! 1 line of pascal's triangle - - ! straight copy of the algorithm presented in the C++ solution - ! - ! Try to explain what we are doing: - ! - ! Pascal's Triangle - ! # 1: 1 - ! # 2: 1 2 1 C1 = 2-1 = 1 - ! # 3: 1 3 3 1 - ! # 4: 1 4 6 4 1 C2 = 6-4 = 2 - ! # 5: 1 5 10 10 5 1 - ! # 6: 1 6 15 20 15 6 1 C3 = 20 - 15 = 5 - ! # 7: 1 7 21 35 35 21 7 1 - ! # 8: 1 8 28 56 70 56 28 8 1 C4 = 70 - 56 = 14 - ! t1 2 3 4 5 ... - ! etc. Note for Cn we need even row #(2*n) up to index n+1. - ! and we dont need to store all values, just go from row to row. - t(1) = 0 - t(2) = 1 ! first odd row (i.e. row #1) will be t(2)+t(1) - - do i=2, nMax+1 ! to calculate C(1)... C(nMax) - ! get entries of next odd row (at index 2...i). - ! currently t has values of previous even row - do j = i, 2, -1 - t(j) = t(j) + t(j-1) - end do - ! Now t has values of next odd row. - - ! shift index by 1 so that soon "t" will carry values of next even row - t(i+1) = t(i) - - ! combine values of previously odd row to become values of even row - do j=i+1, 2, -1 - t(j) = t(j) + t(j-1) - end do - ! Now t has values 1...n+1 of 2n'th row of pascals triangle. - - ! Result: catalan number is center number - (left of center)number - ! e. g. for C4 its t(5)-t(4) = 70-56 = 14 - ! (remember i is 5 to calculate C4.) - catalan = t(i+1) - t(i) - - write (*, '(I0,x) ', ADVANCE='NO') catalan ! all in 1 line - end do - - write (*,*) ' ' ! Terminate output line - end program calc_catalan diff --git a/Task/Catalan-numbers-Pascals-triangle/FutureBasic/catalan-numbers-pascals-triangle.basic b/Task/Catalan-numbers-Pascals-triangle/FutureBasic/catalan-numbers-pascals-triangle.basic deleted file mode 100644 index f8d7a51702..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/FutureBasic/catalan-numbers-pascals-triangle.basic +++ /dev/null @@ -1,20 +0,0 @@ - local fn CatalanNumbers( levels as int ) - int k, n - double num, den, cat - - printf @"1" - - for n = 2 to levels - num = 1 : den = 1 - for k = 2 to n - num *= ( n + k ) - den *= k - cat = num / den - next - printf @"%.f", cat - next -end fn - -fn CatalanNumbers( 30 ) - -HandleEvents diff --git a/Task/Catalan-numbers-Pascals-triangle/Julia/catalan-numbers-pascals-triangle.jl b/Task/Catalan-numbers-Pascals-triangle/Julia/catalan-numbers-pascals-triangle.julia similarity index 100% rename from Task/Catalan-numbers-Pascals-triangle/Julia/catalan-numbers-pascals-triangle.jl rename to Task/Catalan-numbers-Pascals-triangle/Julia/catalan-numbers-pascals-triangle.julia diff --git a/Task/Catalan-numbers-Pascals-triangle/Kotlin/catalan-numbers-pascals-triangle.kts b/Task/Catalan-numbers-Pascals-triangle/Kotlin/catalan-numbers-pascals-triangle.kotlin similarity index 100% rename from Task/Catalan-numbers-Pascals-triangle/Kotlin/catalan-numbers-pascals-triangle.kts rename to Task/Catalan-numbers-Pascals-triangle/Kotlin/catalan-numbers-pascals-triangle.kotlin diff --git a/Task/Catalan-numbers-Pascals-triangle/MSX-Basic/catalan-numbers-pascals-triangle.basic b/Task/Catalan-numbers-Pascals-triangle/MSX-Basic/catalan-numbers-pascals-triangle.basic deleted file mode 100644 index e801b9f952..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/MSX-Basic/catalan-numbers-pascals-triangle.basic +++ /dev/null @@ -1,12 +0,0 @@ -100 CLS -110 N = 15 -120 DIM T(N+2) -130 T(1) = 1 -140 PRINT "The first 15 Catalan numbers are: "; CHR$(10) -150 FOR I = 1 TO N -160 FOR J = I TO 1 STEP -1 : T(J) = T(J) + T(J-1) : NEXT J -170 T(I+1) = T(I) -180 FOR J = I+1 TO 1 STEP -1 : T(J) = T(J) + T(J-1) : NEXT J -190 PRINT USING "###: #########";I; T(I+1) - T(I) -200 NEXT I -210 END diff --git a/Task/Catalan-numbers-Pascals-triangle/Maxima/catalan-numbers-pascals-triangle.maxima b/Task/Catalan-numbers-Pascals-triangle/Maxima/catalan-numbers-pascals-triangle.maxima deleted file mode 100644 index dd02905ec7..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/Maxima/catalan-numbers-pascals-triangle.maxima +++ /dev/null @@ -1,5 +0,0 @@ -/* The Catalan triangle can be generated using genmatrix */ -genmatrix(lambda([n,k],if n>=k then binomial(n+k-1,k-1)-2*binomial(n+k-2,k-2) else 0),15,15)$ - -/* The Catalan numbers are in the main diagonal */ -makelist(%[i,i],i,1,15); diff --git a/Task/Catalan-numbers-Pascals-triangle/OCaml/catalan-numbers-pascals-triangle.ml b/Task/Catalan-numbers-Pascals-triangle/OCaml/catalan-numbers-pascals-triangle.ocaml similarity index 100% rename from Task/Catalan-numbers-Pascals-triangle/OCaml/catalan-numbers-pascals-triangle.ml rename to Task/Catalan-numbers-Pascals-triangle/OCaml/catalan-numbers-pascals-triangle.ocaml diff --git a/Task/Catalan-numbers-Pascals-triangle/Objeck/catalan-numbers-pascals-triangle.objeck b/Task/Catalan-numbers-Pascals-triangle/Objeck/catalan-numbers-pascals-triangle.objeck deleted file mode 100644 index 37ecabb22c..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/Objeck/catalan-numbers-pascals-triangle.objeck +++ /dev/null @@ -1,23 +0,0 @@ -class Test { - function : Main(args : String[]) ~ Nil { - N := 15; - t := Int->New[N + 2]; - t[1] := 1; - - for(i := 1; i <= N; i++) { - - for(j := i; j > 1; j--){ - t[j] := t[j] + t[j - 1]; - }; - - t[i + 1] := t[i]; - - for(j := i + 1; j > 1; j--) { - t[j] := t[j] + t[j - 1]; - }; - - v := t[i + 1] - t[i]; - "{$v} "->Print(); - }; - } -} diff --git a/Task/Catalan-numbers-Pascals-triangle/PascalABC.NET/catalan-numbers-pascals-triangle.pas b/Task/Catalan-numbers-Pascals-triangle/PascalABC.NET/catalan-numbers-pascals-triangle.pas deleted file mode 100644 index f031c01feb..0000000000 --- a/Task/Catalan-numbers-Pascals-triangle/PascalABC.NET/catalan-numbers-pascals-triangle.pas +++ /dev/null @@ -1,14 +0,0 @@ -const - n = 15; - -begin - var t: array[0..n + 1] of integer; - t[1] := 1; - for var i := 1 to n do - begin - for var j := i downto 1 do t[j] += t[j - 1]; - t[i + 1] := t[i]; - for var j := i + 1 downto 1 do t[j] += t[j - 1]; - print(t[i + 1] - t[i]); - end; -end. diff --git a/Task/Catalan-numbers-Pascals-triangle/Phix/catalan-numbers-pascals-triangle-1.phix b/Task/Catalan-numbers-Pascals-triangle/Phix/catalan-numbers-pascals-triangle-1.phix index 9df9e2a484..636407e5ea 100644 --- a/Task/Catalan-numbers-Pascals-triangle/Phix/catalan-numbers-pascals-triangle-1.phix +++ b/Task/Catalan-numbers-Pascals-triangle/Phix/catalan-numbers-pascals-triangle-1.phix @@ -1,12 +1,16 @@ -constant N = 15 -- accurate to 30, nan/inf for anything over 514 (gmp version is below). -sequence catalan = {}, -- (>=1 only) - p = repeat(1,N+1) -for i=1 to N do - atom p1 = p[1]*2 - catalan = append(catalan,p1-p[2]) - for j=1 to N-i+1 do - p1 += p[j+1] - p[j] = p1 - end for -end for -?catalan +(phixonline)--> + constant N = 15 -- accurate to 30, nan/inf for anything over 514 (gmp version is below). + sequence catalan = {}, -- (>=1 only) + p = repeat(1,N+1) + atom p1 + for i=1 to N do + p1 = p[1]*2 + catalan = append(catalan,p1-p[2]) + for j=1 to N-i+1 do + p1 += p[j+1] + p[j] = p1 + end for + -- ?p[1..N-i+1] + end for + ?catalan + + with javascript_semantics + include builtins\mpfr.e -function catalanB(integer n) -- very very fast! -sequence catalan = mpz_inits(n), - p = mpz_inits(n+1,1) -mpz p1 = mpz_init(1) - if n=0 then return p1 end if - for i=1 to n do - mpz_mul_si(p1,p[1],2) - mpz_sub(catalan[i],p1,p[2]) - for j=1 to n-i+1 do - mpz_add(p1,p1,p[j+1]) - mpz_set(p[j],p1) - end for - end for - return catalan[n] -end function + function catalanB(integer n) -- very very fast! + sequence catalan = mpz_inits(n), + p = mpz_inits(n+1,1) + mpz p1 = mpz_init(1) + if n=0 then return p1 end if + for i=1 to n do + mpz_mul_si(p1,p[1],2) + mpz_sub(catalan[i],p1,p[2]) + for j=1 to n-i+1 do + mpz_add(p1,p1,p[j+1]) + mpz_set(p[j],p1) + end for + end for + return catalan[n] + end function -printf(1,"%d: %s\n",{100,shorten(mpz_get_str(catalanB(100)))}) -printf(1,"%d: %s\n",{250,shorten(mpz_get_str(catalanB(250)))}) + printf(1,"%d: %s\n",{100,shorten(mpz_get_str(catalanB(100)))}) + printf(1,"%d: %s\n",{250,shorten(mpz_get_str(catalanB(250)))}) + + with javascript_semantics + -- returns inf/-nan for n>85, and needs the rounding for n>=14, accurate to n=29 + function catalan1(integer n) + return floor(factorial(2*n)/(factorial(n+1)*factorial(n))+0.5) + end function --- returns inf for n>519, accurate to n=30: -function catalan2(integer n) -- NB: very slow! -atom res = not n - n -= 1 - for i=0 to n do - res += catalan2(i)*catalan2(n-i) - end for - return res -end function + -- returns inf for n>519, accurate to n=30: + function catalan2(integer n) -- NB: very slow! + atom res = not n + n -= 1 + for i=0 to n do + res += catalan2(i)*catalan2(n-i) + end for + return res + end function --- returns inf for n>514, accurate to n=30: -function catalan3(integer n) - if n=0 then return 1 end if - return 2*(2*n-1)/(1+n)*catalan3(n-1) -end function + -- returns inf for n>514, accurate to n=30: + function catalan3(integer n) + if n=0 then return 1 end if + return 2*(2*n-1)/(1+n)*catalan3(n-1) + end function -sequence res = repeat(repeat(0,4),16), - times = repeat(0,3) -for t=1 to 4 do - atom t1 = time() - for i=0 to 15 do - switch t do - case 1: res[i+1][2] = catalan1(i) - case 2: res[i+1][3] = catalan2(i) - case 3: res[i+1][4] = catalan3(i) - case 4: res[i+1][1] = i; printf(1,"%2d: %10d %10d %10d\n",res[i+1]) - end switch - end for - if t=4 then exit end if - times[t] = elapsed(time()-t1) -end for -printf(1,"times:%8s %10s %10s\n",times) + sequence res = repeat(repeat(0,4),16), + times = repeat(0,3) + for t=1 to 4 do + atom t0 = time() + for i=0 to 15 do + switch t do + case 1: res[i+1][2] = catalan1(i) + case 2: res[i+1][3] = catalan2(i) + case 3: res[i+1][4] = catalan3(i) + case 4: res[i+1][1] = i; printf(1,"%2d: %10d %10d %10d\n",res[i+1]) + end switch + end for + if t=4 then exit end if + times[t] = elapsed(time()-t0) + end for + printf(1,"times:%8s %10s %10s\n",times) + + with javascript_semantics + include builtins\mpfr.e -sequence c2cache = {} + sequence c2cache = {} -function catalan2m(integer n) -- very fast! -object r -- result (a [cached/shared] mpz) - -- (nb: modifying result will mess up cache) - if n<=0 then return mpz_init(1) end if - if n<=length(c2cache) then - r = c2cache[n] - if r!=0 then return r end if - else - c2cache &= repeat(0,n-length(c2cache)) - end if - r = mpz_init(0) - mpz t = mpz_init() - for i=0 to n-1 do - mpz_mul(t,catalan2m(i),catalan2m(n-1-i)) - mpz_add(r,r,t) - end for - t = mpz_free(t) - c2cache[n] = r - return r -end function + function catalan2m(integer n) -- very fast! + object r -- result (a [cached/shared] mpz) + -- (nb: modifying result will mess up cache) + if n<=0 then return mpz_init(1) end if + if n<=length(c2cache) then + r = c2cache[n] + if r!=0 then return r end if + else + c2cache &= repeat(0,n-length(c2cache)) + end if + r = mpz_init(0) + mpz t = mpz_init() + for i=0 to n-1 do + mpz_mul(t,catalan2m(i),catalan2m(n-1-i)) + mpz_add(r,r,t) + end for + t = mpz_free(t) + c2cache[n] = r + return r + end function -sequence s = {} -for i=0 to 15 do s = append(s,mpz_get_str(catalan2m(i))) end for -printf(1,"0..15: %s\n",join(s,",")) -printf(1,"100: %s\n",{mpz_get_str(catalan2m(100))}) + sequence s = {} + for i=0 to 15 do s = append(s,mpz_get_str(catalan2m(i))) end for + printf(1,"0..15: %s\n",join(s,",")) + printf(1,"100: %s\n",{mpz_get_str(catalan2m(100))}) + int32) is native($glutlib) {*} - -# OpenGL Bindings -constant $gllib = 'GL'; -sub glClear(int32) is native($gllib) {*} -sub glClearColor(num32, num32, num32, num32) is native($gllib) {*} -sub glClearDepth(num64) is native($gllib) {*} -sub glEnable(int32) is native($gllib) {*} -sub glDisable(int32) is native($gllib) {*} -sub glViewport(int32, int32, int32, int32) is native($gllib) {*} -sub glMatrixMode(int32) is native($gllib) {*} -sub glLoadIdentity() is native($gllib) {*} -sub glBegin(int32) is native($gllib) {*} -sub glEnd() is native($gllib) {*} -sub glVertex3f(num32, num32, num32) is native($gllib) {*} -sub glVertex3fv(CArray[num32]) is native($gllib) {*} -sub glNormal3fv(CArray[num32]) is native($gllib) {*} -sub glColor3f(num32, num32, num32) is native($gllib) {*} -sub glPushAttrib(int32) is native($gllib) {*} -sub glPopAttrib() is native($gllib) {*} -sub glMaterialfv(int32, int32, CArray[num32]) is native($gllib) {*} -sub glLightfv(int32, int32, CArray[num32]) is native($gllib) {*} -sub glPolygonMode(int32, int32) is native($gllib) {*} -sub glFrustum(num64, num64, num64, num64, num64, num64) is native($gllib) {*} -sub glTranslatef(num32, num32, num32) is native($gllib) {*} -sub glRotatef(num32, num32, num32, num32) is native($gllib) {*} -sub glScalef(num32, num32, num32) is native($gllib) {*} - -# Vector Math -class Vec3 { has num32 ($.x, $.y, $.z); - method new(num32 $x = 0e0, num32 $y = 0e0, num32 $z = 0e0) { - self.bless(:$x, :$y, :$z) - } - method copy() { Vec3.new: $!x, $!y, $!z } - method add(Vec3 $v) { Vec3.new: $!x + $v.x, $!y + $v.y, $!z + $v.z } - method sub(Vec3 $v) { Vec3.new: $!x - $v.x, $!y - $v.y, $!z - $v.z } - method mul(num32 $s) { Vec3.new: $!x * $s, $!y * $s, $!z * $s } - method dot(Vec3 $v) { $!x * $v.x + $!y * $v.y + $!z * $v.z } - method len() { sqrt(self.dot(self)).Num } - method normalize() { do given self { .len > 0 ?? .mul(1e0/.len) !! .copy } } - method cross(Vec3 $v) { - Vec3.new: $!y*$v.z - $!z*$v.y, $!z*$v.x - $!x*$v.z, $!x*$v.y - $!y*$v.x - } - method to-array() { CArray[num32].new: $!x, $!y, $!z } -} - -# Mesh Data Structures -class Vertex { - has (@.edges, @.faces) is rw; - has Vec3 ($.pos, $.newpos) is rw; - method new(Vec3 :$pos!) { self.bless(:$pos, newpos => $pos.copy) } -} - -class Face { - has @.verts is rw; - has Int $.fvert is rw; -} - -class Edge { has Int ($.v0, $.v1, $.f0, $.f1, $.evert) is rw } - -class Mesh { has (@.vertices, @.normals, @.faces); - method add-vertex(Vec3 $v) { @!vertices.push($v) } - method add-normal(Vec3 $n) { @!normals.push($n) } - method add-face(@verts) { @!faces.push: Face.new(:verts(@verts),:fvert(-1)) } - - method compute-normals() { - @!normals = Vec3.new xx @!vertices.elems; - for @!faces -> $face { - for ^$face.verts.elems -> \j { - my $v0=@!vertices[$face.verts[j]]; - my $v1=@!vertices[$face.verts[(j+1) % +$face.verts]]; - my $v2=@!vertices[$face.verts[(j+ +$face.verts-1) % +$face.verts]]; - given $v1.sub($v0).cross($v2.sub($v0)) { - @!normals[$face.verts[j]] .= add: $_ - } - } - } - $_ .= normalize for @!normals - } -} - -# Subdivision -class SubdivMesh { has (@.verts, @.faces, @.edges); - method find-edge(Int $v0, Int $v1) { - for @!verts[$v0].edges -> $ei { - my $e = @!edges[$ei]; - return $ei if $e.v0==$v0 && $e.v1==$v1 or $e.v0==$v1 && $e.v1==$v0 - } - return -1; - } - - method update-links() { - for @!verts { ( .faces, .edges ) = | [] xx 2 } - @!edges = []; - for @!faces.kv -> $fi, $face { - for ^$face.verts.elems -> $j { - @!verts[ my $v0 = $face.verts[$j] ].faces.push: $fi; - my $v1 = $face.verts[ ($j+1) % $face.verts.elems ]; - if ( my $ei = self.find-edge($v0, $v1) ) == -1 { - @!edges.push: Edge.new( :v0($v0), :v1($v1), - :f0($fi), :f1(-1), :evert(-1)); - given $ei=+@!edges-1 { @!verts[$_].edges.push($ei) for $v0,$v1 } - } else { - @!edges[$ei].f1 = $fi - } - } - } - } - - method subdivide() { - my ($V, $F, $E) = [ @!verts, @!faces, @!edges].map: *.elems; - for @!faces -> $face { # Create face vertices - my $p = Vec3.new; - for $face.verts -> $vi { $p .= add: @!verts[$vi].pos } - @!verts.push: Vertex.new(pos => $p.mul(1e0 / $face.verts.elems)); - $face.fvert = @!verts.elems - 1 - } - for @!edges -> $edge { # Create edge vertices - my $p = Vec3.new; - $p .= add(@!verts[$edge.v0].pos); - $p .= add(@!verts[$edge.v1].pos); - $p .= add(@!verts[@!faces[$edge.f0].fvert].pos); - $p .= add(@!verts[@!faces[$edge.f1].fvert].pos); - @!verts.push: Vertex.new(pos => $p.mul(0.25e0)); - $edge.evert = @!verts.elems - 1 - } - for ^$V -> $vi { # Update original vertices - my $n = (my $v = @!verts[$vi]).faces.elems; - my ($newp,$p1) = $v.pos.mul(($n-2e0)/$n), Vec3.new; - - for $v.faces -> $fi { $p1 .= add(@!verts[@!faces[$fi].fvert].pos) } - $newp .= add($p1.mul(1e0 / ($n * $n))); - my $p2 = Vec3.new; - for $v.edges -> $ei { - given @!edges[$ei] { $p2 .= add(@!verts[.v0==$vi??.v1!!.v0].pos) } - } - $v.newpos = $newp .= add($p2.mul(1e0 / ($n * $n))) - } - for ^$V -> $vi { @!verts[$vi].pos = @!verts[$vi].newpos.copy } - - @!faces = gather for @!faces -> $face { # Create new faces - for ^$face.verts.elems -> $j { - my $v0 = $face.verts[($j-1+$face.verts.elems) % $face.verts.elems]; - my $v = $face.verts[$j]; - my $v1 = $face.verts[($j + 1) % $face.verts.elems]; - my $e0 = @!edges[self.find-edge($v0, $v)]; - my $e1 = @!edges[self.find-edge($v, $v1)]; - take Face.new(:verts($e0.evert,$v,$e1.evert,$face.fvert),:fvert(-1)) - } - } - self.update-links(); - } - - method to-mesh() { - my $mesh = Mesh.new; - for @!verts -> $v { $mesh.add-vertex($v.pos) } - for @!faces -> $face { $mesh.add-face($face.verts) } - $mesh.compute-normals; - return $mesh - } -} - -sub load-cube() { # Load Cube OBJ - my $mesh = Mesh.new; - for (-1,-1,1,1,-1,1,-1,1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1).rotor(3) { - $mesh.add-vertex(Vec3.new: | ($_ X* 0.5e0)) # 8 Corner vertices - } - for [0,1,3,2], [2,3,5,4], [4,5,7,6], [6,7,1,0], [1,7,5,3], [6,0,2,4] { - $mesh.add-face: $_ # 6 Faces - } - $mesh.compute-normals; - return $mesh -} - -sub create-subdivision-levels(Mesh $base, Int $levels) { - my @meshes = $base; - my $sd = SubdivMesh.new; - - for $base.vertices -> $v { $sd.verts.push(Vertex.new(pos => $v)) } - for $base.faces -> $face { - $sd.faces.push(Face.new(verts => $face.verts, fvert => -1)) - } - $sd.update-links; - return @meshes.append: ^($levels - 1) .map: { - $sd.subdivide; - $sd.to-mesh - } -} - -sub render-mesh(Mesh $mesh) { - for $mesh.faces -> $face { - glBegin(GL_POLYGON); - for $face.verts -> $vi { - glNormal3fv($mesh.normals[$vi].to-array); - glVertex3fv($mesh.vertices[$vi].to-array); - } - glEnd - } -} - -sub draw-xyz() { # Draw XYZ Axis Lines - glPushAttrib(GL_LIGHTING_BIT +| GL_ENABLE_BIT); - glDisable(GL_LIGHTING); - glBegin(GL_LINES); - for (1e0,0e0,0e0), (0e0,1e0,0e0), (0e0,0e0,1e0) -> @color { # XYZ <-> RGB - glColor3f(|@color); - glVertex3f(0e0, 0e0, 0e0); - glVertex3f(|@color) - } - glEnd; - glPopAttrib -} - -# Global State -my ( $auto-phase, $auto-dir, $auto-level, $cur-level, $y-rot, $x-rot ) = - 0, 1, 0, 0, 0e0, 0e0 ; -my ($wireframe, @meshes) = False; - -sub display() { - glClear(GL_COLOR_BUFFER_BIT +| GL_DEPTH_BUFFER_BIT); - - # Setup projection - glMatrixMode(GL_PROJECTION); - glLoadIdentity; - my ( $fovy, $near, $far, $aspect ) = - 60e0, 0.1e0, 1000e0, WIN-WIDTH.Num / WIN-HEIGHT.Num ; - my $top = $near * tan($fovy * pi / 360e0); - glFrustum(-$top * $aspect, $top * $aspect, -$top, $top, $near, 1000e0); - - # Setup modelview - glMatrixMode(GL_MODELVIEW); - glLoadIdentity; - - # Headlamp Lighting - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glLightfv(GL_LIGHT0, GL_DIFFUSE, CArray[num32].new(1e0, 1e0, 1e0, 1e0)); - glLightfv(GL_LIGHT0, GL_POSITION, CArray[num32].new(0e0, 0e0, 0e0, 1e0)); - - # Transformations - glTranslatef(0e0, 0e0, -5e0); # Move back from camera - glRotatef($x-rot, 1e0, 0e0, 0e0); # Rotate around X - glRotatef($y-rot, 0e0, 1e0, 0e0); # Rotate around Y - - # Scale Object - glScalef(OBJ-SCALE, OBJ-SCALE, OBJ-SCALE); - - # Render mesh - glPushAttrib(GL_LIGHTING_BIT +| GL_POLYGON_BIT); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, CArray[num32].new(1e0, 1e0, 1e0, 1e0)); - - if $wireframe { - glDisable(GL_LIGHTING); - glColor3f(0e0, 1e0, 0e0); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) - } - render-mesh(@meshes[$cur-level]); - glPopAttrib; - draw-xyz(); - glutSwapBuffers; -} - -sub reshape(int32 $w, int32 $h) { - glViewport(0, 0, $w, $h); - glClearDepth(1e0); - glClearColor(0e0, 0e0, 0e0, 0e0); - glEnable(GL_DEPTH_TEST) -} - -sub keyboard(uint8 $key, int32 $x, int32 $y) { - given $key.chr { when 'q' | 'Q' | "\x1b" { exit(0) } } # q, Q, or Esc -} - -sub auto-step() { - return unless @meshes.Bool; - ($wireframe, $cur-level) = ($auto-phase == 0), $auto-level; - - if $auto-dir > 0 { - $auto-level >= @meshes.elems - 1 ?? ( $auto-dir = -1 ) !! $auto-level++ - } else { - $auto-level <= 0 ?? (($auto-phase,$auto-dir) = ($auto-phase + 1) % 2, 1) - !! $auto-level-- - } -} - -sub idle() { - state ($last-ms, $last-auto-ms) = -1, -1; - my $now = glutGet(GLUT_ELAPSED_TIME); - if $last-ms < 0 { ($last-ms, $last-auto-ms) = $now xx 2 } - - given my $dt = ($now - $last-ms) / 1000e0 { - $last-ms = $now; - $y-rot += 35e0 * $dt; - $x-rot = 15e0 * sin($now * X-ROT-FREQ); - } - if ($now - $last-auto-ms) >= 500 { - auto-step(); - $last-auto-ms = $now; - } - glutPostRedisplay -} - -# Main -glutInit(CArray[uint32].new, CArray[Str].new); -glutInitDisplayMode(0x0000 +| 0x0002 +| 0x0010); -glutInitWindowSize(WIN-WIDTH, WIN-HEIGHT); -glutCreateWindow("Catmull-Clark (Raku)"); -glutReshapeFunc(&reshape); -glutDisplayFunc(&display); -glutKeyboardFunc(&keyboard); -glutIdleFunc(&idle); - -say "Generating meshes..."; -@meshes = create-subdivision-levels(load-cube(), 5); -say "Starting loop.\nPress , or to quit."; - -glutMainLoop; diff --git a/Task/Catmull-Clark-subdivision-surface/Rust/catmull-clark-subdivision-surface.rs b/Task/Catmull-Clark-subdivision-surface/Rust/catmull-clark-subdivision-surface.rust similarity index 100% rename from Task/Catmull-Clark-subdivision-surface/Rust/catmull-clark-subdivision-surface.rs rename to Task/Catmull-Clark-subdivision-surface/Rust/catmull-clark-subdivision-surface.rust diff --git a/Task/Catmull-Clark-subdivision-surface/Wren/catmull-clark-subdivision-surface.wren b/Task/Catmull-Clark-subdivision-surface/Wren/catmull-clark-subdivision-surface.wren index 79c0966aee..b96526a682 100644 --- a/Task/Catmull-Clark-subdivision-surface/Wren/catmull-clark-subdivision-surface.wren +++ b/Task/Catmull-Clark-subdivision-surface/Wren/catmull-clark-subdivision-surface.wren @@ -1,7 +1,7 @@ -import "./dynamic" for Tuple, Struct -import "./sort" for Sort -import "./math" for Int -import "./fmt" for Fmt +import "/dynamic" for Tuple, Struct +import "/sort" for Sort +import "/math" for Int +import "/fmt" for Fmt var Point = Tuple.create("Point", ["x", "y", "z"]) var fields = [ diff --git a/Task/Chaocipher/00-TASK.txt b/Task/Chaocipher/00-TASK.txt index d328256b71..73b60b4213 100644 --- a/Task/Chaocipher/00-TASK.txt +++ b/Task/Chaocipher/00-TASK.txt @@ -1,9 +1,9 @@ ;Description: The [[wp:Chaocipher|Chaocipher]] was invented by J.F.Byrne in 1918 and, although simple by modern cryptographic standards, does not appear to have been broken until the algorithm was finally disclosed by his family in 2010. -The algorithm is described in [http://www.chaocipher.com/ActualChaocipher/Chaocipher-Revealed-Algorithm.pdf this paper] by M.Rubin in 2010 and there is a C# implementation [https://www.c-sharpcorner.com/UploadFile/b942f9/implementing-the-chaocipher-in-C-Sharp/ here]. +The algorithm is described in [http://www.mountainvistasoft.com/chaocipher/ActualChaocipher/Chaocipher-Revealed-Algorithm.pdf this paper] by M.Rubin in 2010 and there is a C# implementation [https://www.c-sharpcorner.com/UploadFile/b942f9/implementing-the-chaocipher-in-C-Sharp/ here]. ;Task: -Code the algorithm in your language and test that it works with the plaintext 'WELLDONEISBETTERTHANWELLSAID' used in the paper itself. +Code the algorithm in your language and to test that it works with the plaintext 'WELLDONEISBETTERTHANWELLSAID' used in the paper itself.

diff --git a/Task/Chaocipher/ALGOL-68/chaocipher.alg b/Task/Chaocipher/ALGOL-68/chaocipher.alg deleted file mode 100644 index ceaedc0ca8..0000000000 --- a/Task/Chaocipher/ALGOL-68/chaocipher.alg +++ /dev/null @@ -1,75 +0,0 @@ -BEGIN # Chaocipher, translated from the Kotlin with permutations as in Ada # - - STRING lalphabet = "HXUCZVAMDSLKPEFJRIGTWOBNYQ"; - STRING ralphabet = "PTLNBQDEOYSFAVZKGJRIHWXUMC"; - - PROC chaocipher = ( STRING text in, BOOL encrypt, show steps )STRING: - BEGIN - STRING left := lalphabet[ AT 1 ]; - STRING right := ralphabet[ AT 1 ]; - STRING text = text in [ AT 1 ]; - OP LENGTH = ( STRING s )INT: UPB s - LWB s + 1; - [ 1 : LENGTH text ]CHAR e text; - [ 1 : LENGTH left ]CHAR temp; - - FOR i TO UPB text DO - IF show steps THEN print( ( left, " ", right, newline ) ) FI; - INT index; - IF encrypt THEN - VOID( char in string( text[ i ], index, right ) ); - e text[ i ] := IF index >= LWB left AND index <= UPB left - THEN left[ index ] - ELSE "?" - FI - ELSE - VOID( char in string( text[ i ], index, left ) ); - e text[ i ] := IF index >= LWB right AND index <= UPB right - THEN right[ index ] - ELSE "?" - FI - FI; - IF index > 1 THEN - CHAR store; - - # the permutations are performed using array slices # - # rather than explicit loops # - - # permute left # - - INT offset = 26 - index; - temp[ 1 : offset + 1 ] := left[ index : index + offset ]; - temp[ offset + 2 : 26 ] := left[ 1 : index - 1 ]; - store := temp[ 2 ]; - - temp[ 2 : 13 ] := temp[ 3 : 14 ]; - temp[ 14 ] := store; - left := temp; - - # permute right # - - temp[ 1 : offset + 1 ] := right[ index : index + offset ]; - temp[ offset + 2 : 26 ] := right[ 1 : index - 1 ]; - store := temp[ 1 ]; - - temp[ 1 : 25 ] := temp[ 2 : 26 ]; - temp[ 26 ] := store; - store := temp[ 3 ]; - - temp[ 3 : 13 ] := temp[ 4 : 14 ]; - temp[ 14 ] := store; - right := temp - FI - OD; - e text - END # chaocipher # ; - - STRING plaintext = "WELLDONEISBETTERTHANWELLSAID"; - print( ( "The original plaintext is : ", plaintext, newline ) ); - print( ( newline, "The left and right alphabets after each permutation" ) ); - print( ( " during encryption are :", newline, newline ) ); - STRING ciphertext = chaocipher( plaintext, TRUE, TRUE ); - print( ( newline, "The ciphertext is : ", ciphertext, newline ) ); - STRING plaintext2 = chaocipher( ciphertext, FALSE, FALSE ); - print( ( newline, "The recovered plaintext is : ", plaintext2 ) ); - print( ( " ", IF plaintext = plaintext2 THEN "" ELSE "NOT " FI, "as expected", newline ) ) -END diff --git a/Task/Chaocipher/Ada/chaocipher.adb b/Task/Chaocipher/Ada/chaocipher.ada similarity index 100% rename from Task/Chaocipher/Ada/chaocipher.adb rename to Task/Chaocipher/Ada/chaocipher.ada diff --git a/Task/Chaocipher/BASIC/chaocipher.basic b/Task/Chaocipher/BASIC/chaocipher.basic deleted file mode 100644 index 6b072d9972..0000000000 --- a/Task/Chaocipher/BASIC/chaocipher.basic +++ /dev/null @@ -1,137 +0,0 @@ -' Caocipher Example -' Rosetta Code -' This code was made in Power Basic 3.5 for DOS - -CLS - -' Left Alphabet -Function AlphaLeft(ct as String, pt as String, CharPos as Integer) as String - - Dim tStr as String: tStr=ct - - ' 1. Shift the entire left alphabet cyclically so the ciphertext letter - ' just enciphered is positioned at the zenith (i.e., position 1). - tStr=Right$(ct, Len(ct)-CharPos+1)+Left$(ct, CharPos-1) - - ' 2. Extract the letter found at position zenith+1 (i.e., the letter to - ' the right of the zenith), taking it out of the alphabet, temporarily - ' leaving an unfilled "hole" - - Dim Hole as String: Hole=Mid$(tStr, 2, 1): Mid$(tStr, 2, 1)=" " - - ' 3. Shift all letters in positions zenith+2 up to, and including, the - ' nadir (zenith+13), moving them one position to the left - - tStr=Left$(tStr, 1)+Mid$(tStr, 3, 12)+" "+Right$(tStr, 12) - - ' 4. Insert the just-extracted letter into the nadir position - ' (i.e., zenith+13) - - Mid$(tStr, 14, 1)=Hole - - AlphaLeft=tStr -End Function - -' Right Alphabet -Function AlphaRight(ct as String, pt as String, CharPos as Integer) as String - - Dim tStr as String: tStr=pt - - ' 1. Shift the entire right alphabet cyclically so the plaintext letter - ' just enciphered is positioned at the zenith. - - tStr=Right$(tStr, Len(tStr)-CharPos+1)+Left$(tStr, CharPos-1) - - ' 2. Now shift the entire alphabet one more position to the left (i.e., - ' the leftmost letter moves cyclically to the far right), moving a new - ' letter into the zenith position. - - tStr=Right$(tStr, 25)+Left$(tStr, 1) - - ' 3. Extract the letter at position zenith+2, taking it out of the - ' alphabet, temporarily leaving an unfilled "hole". - - Dim Hole as String: Hole=Mid$(tStr, 3, 1): Mid$(tStr, 3, 1)=" ": - - ' 4. Shift all letters beginning with zenith+3 up to, and including, the - ' nadir (zenith+13), moving them one position to the left. - - tStr=Left$(tStr, 2)+Mid$(tStr, 4, 11)+" "+Right$(tStr, 12) - - ' 5. Insert the just-extracted letter into the nadir position (zenith+13) - - Mid$(tStr, 14, 1)=Hole - - AlphaRight=tStr -End Function - -Function Encode(Text as String, ct as String, pt as String) as String - Dim t as Integer - Dim tStr as String: tStr="" - - For t=1 to Len(Text) - Dim Char as String: Char=Mid$(Text, t, 1) - Dim CharPos as Integer: CharPos=Instr(pt, Char) - - ct=AlphaLeft(ct, pt, CharPos) - pt=AlphaRight(ct, pt, CharPos) - - tStr=tStr+Left$(ct, 1) - Next - - Encode=tStr -End Function - -' Deciphering a Chaocipher-encrypted message is identical to the steps used -' for enciphering. The sole difference is that the decipherer locates the -' known ciphertext letter in the left (ct) alphabet, with the plaintext -' letter being the corresponding letter in the right (pt) alphabet -' -' Alphabet permuting is identical in enciphering and deciphering - -Function Decode(Text as String, ct as String, pt as String) as String - Dim t as Integer - Dim tStr as String: tStr="" - - For t=1 to Len(Text) - Dim Char as String: Char=Mid$(Text, t, 1) - Dim CharPos as Integer: CharPos=Instr(ct, Char) - - ct=AlphaLeft(ct, pt, CharPos) - pt=AlphaRight(ct, pt, CharPos) - - tStr=tStr+Right$(pt, 1) - Next - - Decode=tStr -End Function - -' Start of Main Code - -' LEFT (Cipher Text): HXUCZVAMDSLKPEFJRIGTWOBNYQ -Dim tLeft as String: tLeft="HXUCZVAMDSLKPEFJRIGTWOBNYQ" - -' RIGHT (Plain Text): PTLNBQDEOYSFAVZKGJRIHWXUMC -Dim tRight as String: tRight="PTLNBQDEOYSFAVZKGJRIHWXUMC" - -' Cipher Message (Used to verify a good encoding) -Dim cText as String: cText="OAHQHCNYNXTSZJRRHJBYHQKSOUJY" - -' Plain Text Message -Dim pText as String: pText="WELLDONEISBETTERTHANWELLSAID" -Print " Plain Text: "; pText: Print - -Dim ctLeft as String: ctLeft=tLeft -Dim ptRight as String: ptRight=tRight - -' Final Cipher Text -Dim eText as String: eText=Encode(pText, ctLeft, ptRight) -Print " Cipher Text: "; eText: Print - -If eText=cText then Print "Successful" else Print "Failed" - -ctLeft=tLeft: ptRight=tRight -Dim dText as String: dText=Decode(eText, ctLeft, ptRight) -Print: Print " Plain Text: "; dText: Print - -If dText=pText then Print "Successful" else Print "Failed" diff --git a/Task/Chaocipher/Crystal/chaocipher.cr b/Task/Chaocipher/Crystal/chaocipher.cr deleted file mode 100644 index 452e1edf99..0000000000 --- a/Task/Chaocipher/Crystal/chaocipher.cr +++ /dev/null @@ -1,40 +0,0 @@ -enum Chaoperation - Encode - Decode -end - -class Array - # useful method to work on parts of the array - def slice (start, length) - start = size - start if start < 0 - raise "Out of bounds" unless start >= 0 && length >= 0 && start + length <= size - Slice.new(to_unsafe + start, length) - end -end - -def chaocipher (message : String, left : String, right : String, - op : Chaoperation = Chaoperation::Encode) - ct = left.chars - pt = right.chars - String.build do |s| - message.each_char do |ch| - idx = (op == Chaoperation::Encode ? pt : ct).index! ch - s << (op == Chaoperation::Encode ? ct : pt)[idx] - # permute left - ct.rotate! idx - ct.slice(1, 13).rotate! 1 - # permute right - pt.rotate! idx+1 - pt.slice(2, 12).rotate! 1 - end - end -end - -left = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" -right = "PTLNBQDEOYSFAVZKGJRIHWXUMC" -message = "WELLDONEISBETTERTHANWELLSAID" - -encoded = chaocipher(message, left, right) -decoded = chaocipher(encoded, left, right, Chaoperation::Decode) - -print message, " -> ", encoded, " -> ", decoded, "\n" diff --git a/Task/Chaocipher/Delphi/chaocipher.pas b/Task/Chaocipher/Delphi/chaocipher.delphi similarity index 100% rename from Task/Chaocipher/Delphi/chaocipher.pas rename to Task/Chaocipher/Delphi/chaocipher.delphi diff --git a/Task/Chaocipher/EMal/chaocipher.emal b/Task/Chaocipher/EMal/chaocipher.emal index 968427b1f1..5409bcda5d 100644 --- a/Task/Chaocipher/EMal/chaocipher.emal +++ b/Task/Chaocipher/EMal/chaocipher.emal @@ -3,49 +3,49 @@ enum int ENCRYPT, DECRYPT end type Chaocipher -text L_ALPHABET ← "HXUCZVAMDSLKPEFJRIGTWOBNYQ" -text R_ALPHABET ← "PTLNBQDEOYSFAVZKGJRIHWXUMC" -fun exec ← text by text value, Chaocipher:Mode mode, logic showSteps +text L_ALPHABET = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" +text R_ALPHABET = "PTLNBQDEOYSFAVZKGJRIHWXUMC" +fun exec = text by text value, Chaocipher:Mode mode, logic showSteps ^|since texts are mutable, we can operate directly on them without the need of Lists|^ - text left ← *L_ALPHABET # by using the valueOf operator we are sure that the string is copied - text right ← *R_ALPHABET - text eText ← text(" ", value.length) - text temp ← text(" ", 26) - for int i ← 0; i < value.length; ++i + text left = *L_ALPHABET # by using the valueOf operator we are sure that the string is copied + text right = *R_ALPHABET + text eText = text(" ", value.length) + text temp = text(" ", 26) + for int i = 0; i < value.length; ++i if showSteps do writeLine(left + " " + right) end - int index ← 0 - if mode æ Chaocipher:Mode.ENCRYPT - index ← right.find(value[i]) - eText[i] ← left[index] + int index = 0 + if mode == Chaocipher:Mode.ENCRYPT + index = right.find(value[i]) + eText[i] = left[index] else - index ← left.find(value[i]) - eText[i] ← right[index] + index = left.find(value[i]) + eText[i] = right[index] end - if i æ value.length - 1 do break end + if i == value.length - 1 do break end # permute left - for int j ← index; j < 26; ++j do temp[j - index] ← left[j] end - for int j ← 0; j < index; ++j do temp[26 - index + j] ← left[j] end - var store ← temp[1] - for int j ← 2; j < 14; ++j do temp[j - 1] ← temp[j] end - temp[13] ← store - left ← *temp + for int j = index; j < 26; ++j do temp[j - index] = left[j] end + for int j = 0; j < index; ++j do temp[26 - index + j] = left[j] end + var store = temp[1] + for int j = 2; j < 14; ++j do temp[j - 1] = temp[j] end + temp[13] = store + left = *temp # permute right - for int j ← index; j < 26; ++j do temp[j - index] ← right[j] end - for int j ← 0; j < index; ++j do temp[26 - index + j] ← right[j] end - store ← temp[0] - for int j ← 1; j < 26; ++j do temp[j - 1] ← temp[j] end - temp[25] ← store - store ← temp[2] - for int j ← 3; j < 14; ++j do temp[j - 1] ← temp[j] end - temp[13] ← store - right ← *temp + for int j = index; j < 26; ++j do temp[j - index] = right[j] end + for int j = 0; j < index; ++j do temp[26 - index + j] = right[j] end + store = temp[0] + for int j = 1; j < 26; ++j do temp[j - 1] = temp[j] end + temp[25] = store + store = temp[2] + for int j = 3; j < 14; ++j do temp[j - 1] = temp[j] end + temp[13] = store + right = *temp end return eText end -var plainText ← "WELLDONEISBETTERTHANWELLSAID" -writeLine("The original plaintext is : ", plainText) -writeLine(EOL, "The left and right alphabets after each permutation during encryption are :", EOL) -var cipherText ← exec(plainText, Chaocipher:Mode.ENCRYPT, true) -writeLine(EOL, "The ciphertext is : ", cipherText) -var plainText2 ← exec(cipherText, Chaocipher:Mode.DECRYPT, false) -writeLine(EOL, "The recovered plaintext is : ", plainText2) +var plainText = "WELLDONEISBETTERTHANWELLSAID" +writeLine("The original plaintext is : " + plainText) +writeLine(EOL + "The left and right alphabets after each permutation during encryption are :" + EOL) +var cipherText = exec(plainText, Chaocipher:Mode.ENCRYPT, true) +writeLine(EOL + "The ciphertext is : " + cipherText) +var plainText2 = exec(cipherText, Chaocipher:Mode.DECRYPT, false) +writeLine(EOL + "The recovered plaintext is : " + plainText2) diff --git a/Task/Chaocipher/EasyLang/chaocipher.easy b/Task/Chaocipher/EasyLang/chaocipher.easy deleted file mode 100644 index f2eb029db7..0000000000 --- a/Task/Chaocipher/EasyLang/chaocipher.easy +++ /dev/null @@ -1,64 +0,0 @@ -func index a$[] c$ . - for ind = 1 to len a$[] - if a$[ind] = c$ : return ind - . - return 0 -. -left$ = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" -right$ = "PTLNBQDEOYSFAVZKGJRIHWXUMC" -# -func$ chao txt$ mode . - left$[] = strchars left$ - right$[] = strchars right$ - len tmp$[] 26 - for c$ in strchars txt$ - if mode = 1 - ind = index right$[] c$ - if ind = 0 : return "" - r$ &= left$[ind] - else - ind = index left$[] c$ - if ind = 0 - print c$ - return "" - . - r$ &= right$[ind] - . - # permute left - for j = ind to 26 - tmp$[j - ind + 1] = left$[j] - . - for j = 1 to ind - 1 - tmp$[26 - ind + j + 1] = left$[j] - . - h$ = tmp$[2] - for j = 3 to 14 - tmp$[j - 1] = tmp$[j] - . - tmp$[14] = h$ - swap tmp$[] left$[] - # - # permute right - for j = ind to 26 - tmp$[j - ind + 1] = right$[j] - . - for j = 1 to ind - 1 - tmp$[26 - ind + j + 1] = right$[j] - . - h$ = tmp$[1] - for j = 2 to 26 - tmp$[j - 1] = tmp$[j] - . - tmp$[26] = h$ - h$ = tmp$[3] - for j = 4 to 14 - tmp$[j - 1] = tmp$[j] - . - tmp$[14] = h$ - swap tmp$[] right$[] - . - return r$ -. -h$ = chao "WELLDONEISBETTERTHANWELLSAID" 1 -print h$ -print chao h$ 2 diff --git a/Task/Chaocipher/Forth/chaocipher.fth b/Task/Chaocipher/Forth/chaocipher.fth deleted file mode 100644 index 630e902613..0000000000 --- a/Task/Chaocipher/Forth/chaocipher.fth +++ /dev/null @@ -1,77 +0,0 @@ - \ triple words -: 3drop drop drop drop ; ( n1 n2 n3 ---) -: 3dup >r over over r@ rot rot r> ; ( n1 n2 n3 -- n1 n2 n3 n1 n2 n3) - \ ASCIIZ string words -: zstring create chars allot ; ( a1 -- a1 n1) -: zcount dup begin dup c@ while char+ repeat over - ; -: zplace over chars over + >r swap cmove 0 r> c! ; -: +zplace zcount chars + zplace ; ( a1 n1 a2 --) - \ find character in string -: where? ( c a1 n1 -- n2) - 0 ?do over over i chars + c@ = if drop i negate leave then loop nip negate ; - -64 constant /str \ size of input/output string -27 constant /alpha \ size of alphabet - -/str zstring {i} \ input string -/str zstring {o} \ output string - -/alpha zstring l \ left alphabet -/alpha zstring r \ right alphabet -/alpha zstring t \ temporary alphabet - -: [] chars + ; ( a n -- a+n) -: .tab 9 emit ; ( --) -: .list cr .tab zcount type cr ; ( a --) - -: PermuteLeft ( index --) - 26 over ?do t over negate i + [] l i [] c@ swap c! loop - dup 0 ?do t over negate 26 i + + [] l i [] c@ swap c! loop drop - t char+ c@ >r t 2 [] dup char- 12 cmove r> t 13 [] c! t zcount l zplace -; - -: PermuteRight ( index --) - 26 over ?do t over negate i + [] r i [] c@ swap c! loop - dup 0 ?do t over negate 26 i + + [] r i [] c@ swap c! loop drop - t c@ >r t char+ dup char- 25 cmove r> t 25 [] c! - t 2 [] c@ >r t 3 [] dup char- 11 cmove r> t 13 [] c! t zcount r zplace -; - -: Encrypt ( input output index1 -- index2) - >r swap r@ [] c@ r /alpha where? dup 0< abort" Corrupt right alphabet" - l over [] c@ rot r> [] c! -; - -: Decrypt ( input output index1 -- index2) - >r swap r@ [] c@ l /alpha where? dup 0< abort" Corrupt left alphabet" - r over [] c@ rot r> [] c! -; - -: chao ( i o xt f --) - s" HXUCZVAMDSLKPEFJRIGTWOBNYQ" l zplace - s" PTLNBQDEOYSFAVZKGJRIHWXUMC" r zplace - t /alpha erase >r \ erase temporary string - ( i o xt R: f) - r@ if cr ." The left and right alphabets after each permutation:" cr then - >r over r> swap zcount 1- nip >r ( i o xt R: f len) - - 0 begin ( i o xt 0 R: f len) - r> r@ if l zcount type 2 spaces r zcount type cr then >r - >r 3dup r@ swap execute r> dup r@ < - while ( i o xt 0 R: f len) - >r dup PermuteLeft PermuteRight r> 1+ - repeat rdrop rdrop drop drop 3drop -; - -: main - s" WELLDONEISBETTERTHANWELLSAID" {i} zplace - {o} /str erase \ initialize output string - - ." The original plaintext is :" {i} .list - {i} {o} ['] Encrypt true chao - cr ." The ciphertext is :" {o} .list - {o} {i} ['] Decrypt false chao - cr ." The recovered plaintext is :" {i} .list -; - -main diff --git a/Task/Chaocipher/Fortran/chaocipher.f b/Task/Chaocipher/Fortran/chaocipher.f deleted file mode 100644 index ef2f081da9..0000000000 --- a/Task/Chaocipher/Fortran/chaocipher.f +++ /dev/null @@ -1,190 +0,0 @@ -! -!This program implements the **Chaocipher encryption algorithm** in FORTRAN, extended to handle all printable ASCII characters (32-127). -! The Chaocipher is a polyalphabetic cipher invented by John F. Byrne in 1918, which dynamically permutes two alphabets after -! processing each character, making it highly secure and resistant to cryptanalysis. -! -!#### Key Features: -!1. **Initialization**: -! - Two alphabets (`left` and `right`) are initialized with shuffled ASCII characters (32-127). -! - The `plaintext` is set to "WELLDONEISBETTERTHANWELLSAID". -! -!2. **Enciphering**: -! - For each character in the plaintext: -! - Locate the character in the `right` alphabet. -! - Find the corresponding ciphertext character in the `left` alphabet. -! - Permute both alphabets based on the Chaocipher rules: -! - The `left` alphabet is rotated to bring the ciphertext character to the top, and a specific character is moved to a new position. -! - The `right` alphabet is similarly rotated, with an additional rotation step. -! -!3. **Deciphering**: -! - The ciphertext is decrypted back into plaintext using the reverse process: -! - Locate the ciphertext character in the `left` alphabet. -! - Find the corresponding plaintext character in the `right` alphabet. -! - Permute both alphabets identically as in enciphering. -! -!4. **Verification**: -! - After enciphering and deciphering, the program compares the original plaintext with the decrypted text to ensure correctness. -! -!#### Output: -!The program prints: -!- Initial left and right alphabets. -!- Enciphered ciphertext. -!- Deciphered plaintext. -!- A success message if decryption matches the original plaintext. -! -!#### Example Execution: -!For input plaintext "WELLDONEISBETTERTHANWELLSAID", the program outputs: -!- Ciphertext: `OAHQHCNYNXTSZJRRHJBYHQKSOUJY` -!- Decrypted Text: `WELLDONEISBETTERTHANWELLSAID` -!- Verification: "Decryption successful: plaintext matches decrypted text." -! -!This implementation demonstrates both encryption and decryption processes while adhering to Chaocipher's dynamic permutation rules, -!extended for modern ASCII characters. -! -! -PROGRAM Chaocipher - IMPLICIT NONE - CHARACTER(LEN=96) :: left, right, left_orig, right_orig - CHARACTER(LEN=1000) :: plaintext, ciphertext, decrypted - INTEGER :: i, len, ascii_start - LOGICAL :: trace - - ! Initialize alphabets and input - CALL initialize_alphabets(left, right) - left_orig = left - right_orig = right - plaintext = 'Well, when I was in Egypt, I had a conversation with the Sphinx! She taught me how to sew.' - ciphertext = '' - decrypted = '' - trace = .FALSE. - ascii_start = 32 ! ASCII start at space character - - len = LEN_TRIM(plaintext) - - PRINT *, 'Initial Left: ', left - PRINT *, 'Initial Right:', right - PRINT *, 'Plaintext: ', TRIM(plaintext) - - ! Encipher - DO i = 1, len - CALL encipher(plaintext(i:i), ciphertext(i:i), left, right, ascii_start) - IF (trace) THEN - PRINT *, 'Step ', i - PRINT *, 'Left: ', left - PRINT *, 'Right: ', right - END IF - END DO - - PRINT *, 'Ciphertext: ', TRIM(ciphertext) - - ! Reset alphabets for deciphering - left = left_orig - right = right_orig - - ! Decipher - DO i = 1, len - CALL decipher(ciphertext(i:i), decrypted(i:i), left, right, ascii_start) - END DO - - PRINT *, 'Decrypted: ', TRIM(decrypted) - - ! Check for correctness - IF (plaintext == decrypted) THEN - PRINT *, 'Decryption successful: plaintext matches decrypted text' - ELSE - PRINT *, 'Decryption failed: plaintext does not match decrypted text' - END IF - -CONTAINS - - SUBROUTINE initialize_alphabets(left, right) - CHARACTER(LEN=96), INTENT(OUT) :: left, right - INTEGER :: i, j - CHARACTER :: temp - REAL :: r - - ! Initialize alphabets with ASCII characters 32-127 - DO i = 1, 96 - left(i:i) = CHAR(i + 31) - right(i:i) = CHAR(i + 31) - END DO - - ! Fisher-Yates shuffle for left alphabet - DO i = 96, 2, -1 - CALL RANDOM_NUMBER(r) - j = 1 + FLOOR(i * r) - temp = left(i:i) - left(i:i) = left(j:j) - left(j:j) = temp - END DO - - ! Fisher-Yates shuffle for right alphabet - DO i = 96, 2, -1 - CALL RANDOM_NUMBER(r) - j = 1 + FLOOR(i * r) - temp = right(i:i) - right(i:i) = right(j:j) - right(j:j) = temp - END DO -END SUBROUTINE initialize_alphabets - - SUBROUTINE encipher(p, c, left, right, ascii_start) - CHARACTER(LEN=1), INTENT(IN) :: p - CHARACTER(LEN=1), INTENT(OUT) :: c - CHARACTER(LEN=96), INTENT(INOUT) :: left, right - INTEGER, INTENT(IN) :: ascii_start - INTEGER :: pos - - pos = INDEX(right, p) - c = left(pos:pos) - - CALL permute_left(left, c, ascii_start) - CALL permute_right(right, p, ascii_start) - END SUBROUTINE encipher - - SUBROUTINE decipher(c, p, left, right, ascii_start) - CHARACTER(LEN=1), INTENT(IN) :: c - CHARACTER(LEN=1), INTENT(OUT) :: p - CHARACTER(LEN=96), INTENT(INOUT) :: left, right - INTEGER, INTENT(IN) :: ascii_start - INTEGER :: pos - - pos = INDEX(left, c) - p = right(pos:pos) - - CALL permute_left(left, c, ascii_start) - CALL permute_right(right, p, ascii_start) - END SUBROUTINE decipher - - SUBROUTINE permute_left(alphabet, pivot, ascii_start) - CHARACTER(LEN=96), INTENT(INOUT) :: alphabet - CHARACTER(LEN=1), INTENT(IN) :: pivot - INTEGER, INTENT(IN) :: ascii_start - INTEGER :: pos - CHARACTER(LEN=1) :: temp - - pos = INDEX(alphabet, pivot) - alphabet = alphabet(pos:) // alphabet(:pos-1) - - temp = alphabet(2:2) - alphabet(2:49) = alphabet(3:50) - alphabet(50:50) = temp - END SUBROUTINE permute_left - - SUBROUTINE permute_right(alphabet, pivot, ascii_start) - CHARACTER(LEN=96), INTENT(INOUT) :: alphabet - CHARACTER(LEN=1), INTENT(IN) :: pivot - INTEGER, INTENT(IN) :: ascii_start - INTEGER :: pos - CHARACTER(LEN=1) :: temp - - pos = INDEX(alphabet, pivot) - alphabet = alphabet(pos:) // alphabet(:pos-1) - alphabet = alphabet(2:) // alphabet(1:1) - - temp = alphabet(3:3) - alphabet(3:49) = alphabet(4:50) - alphabet(50:50) = temp - END SUBROUTINE permute_right - -END PROGRAM Chaocipher diff --git a/Task/Chaocipher/FutureBasic/chaocipher.basic b/Task/Chaocipher/FutureBasic/chaocipher.basic deleted file mode 100644 index 567293f7cd..0000000000 --- a/Task/Chaocipher/FutureBasic/chaocipher.basic +++ /dev/null @@ -1,47 +0,0 @@ -begin enum - _encrypt - _decrypt -end enum - -local fn chaocipher(orig as str255, action as byte, show as bool) as str255 - str255 leftStr, rightStr, out - short i, index - leftStr = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" - rightStr = "PTLNBQDEOYSFAVZKGJRIHWXUMC" - orig = ucase$(orig) - out[0] = orig[0] - - if show then print:print,"The left and right alphabets during encryption are:":print - - for i = 1 to orig[0] - if show then print ,leftStr,,rightStr - if action == _encrypt - index = instr$(0, rightStr, mid$(orig, i, 1)) - out[i] = leftStr[index] - else - index = instr$(0, leftStr, mid$(orig, i, 1)) - out[i] = rightStr[index] - end if - - //leftStr permutation - leftStr = mid$(leftStr, index) + left$(leftStr, index-1) - leftStr = left$(leftStr, 1) + mid$(leftStr, 3, 12) + mid$(leftStr, 2, 1) + mid$(leftStr, 15) - - //rightStr permutation - rightStr = mid$(rightStr, index+1) + left$(rightStr, index-1) + mid$(rightStr, index, 1) - rightStr = left$(rightStr, 2) + mid$(rightStr, 4, 11) + mid$(rightStr, 3, 1) + mid$(rightStr, 15) - next - -end fn = out - - -str255 original, encrypted, decrypted -original = "WellDoneIsBetterThanWellSaid" - -window 1, @"Chaocipher", ( 0, 0, 475, 550 ) -print : print ,"The original text is: """; original; """" -encrypted = fn chaocipher(original, _encrypt, yes) -print : print ,"The encrypted text is: """; encrypted; """" -decrypted = fn chaocipher(encrypted, _decrypt, no) -print : print ,"The decrypted text is: """; decrypted; """" -handleevents diff --git a/Task/Chaocipher/Jq/chaocipher.jq b/Task/Chaocipher/Jq/chaocipher.jq deleted file mode 100644 index 8035df93a1..0000000000 --- a/Task/Chaocipher/Jq/chaocipher.jq +++ /dev/null @@ -1,58 +0,0 @@ -# If using jaq, then see remark above regarding `inform/1` -# Convenience function for emitting progress messages: -def inform(msg): - (msg | tostring | stderr | empty), .; - -# $encrypt should be one of true (for encryption) or false (for decryption) -def Chao($encrypt; $showSteps): - . as $text - | length as $len - | if any(explode[]; . > 128) - then "Text contains non-ASCII characters." | error - else {left: "HXUCZVAMDSLKPEFJRIGTWOBNYQ", - right: "PTLNBQDEOYSFAVZKGJRIHWXUMC", - eText: "", - temp: [range(0;26) | ""] - } - | reduce range(0; $len) as $i (.; - if $showSteps then inform("\(.left) \(.right)\n") end - - | if $encrypt - then .index = (.left|index($text[$i:$i+1])) - | .eText += .right[.index:.index+1] - else .index = (.right|index($text[$i:$i+1])) - | .eText += .left[.index:.index+1] - end - - | if $i == $len - 1 then . - else # permute left - reduce range(.index; 26) as $j (.; .temp[$j-.index] = .left[$j:$j+1]) - | reduce range(0; .index) as $j (.; .temp[26-.index+$j] = .left[$j:$j+1]) - | .store = .temp[1] - | reduce range(2; 14) as $j (.; .temp[$j-1] = .temp[$j]) - | .temp[13] = .store - | .left = (.temp | join("")) - - # permute right - | reduce range(.index; 26) as $j (.; .temp[$j-.index] = .right[$j:$j+1]) - | reduce range(0; .index) as $j (.; .temp[26-.index+$j] = .right[$j:$j+1]) - | .store = .temp[0] - | reduce range(1; 26) as $j (.; .temp[$j-1] = .temp[$j]) - | .temp[25] = .store - | .store = .temp[2] - | reduce range(3; 14) as $j (.; .temp[$j-1] = .temp[$j]) - | .temp[13] = .store - | .right = (.temp | join("")) - end ) - | .eText - end ; - -# Input: plaintext -def task: - "The original plaintext is : \(.)", - "The left and right alphabets after each permutation during encryption are:", - (Chao(true; true) - | "The ciphertext is : \(.)", - "The recovered plaintext is : \(Chao(false; false))" ); - -"WELLDONEISBETTERTHANWELLSAID" | task diff --git a/Task/Chaocipher/Julia/chaocipher.jl b/Task/Chaocipher/Julia/chaocipher.julia similarity index 100% rename from Task/Chaocipher/Julia/chaocipher.jl rename to Task/Chaocipher/Julia/chaocipher.julia diff --git a/Task/Chaocipher/Kotlin/chaocipher.kts b/Task/Chaocipher/Kotlin/chaocipher.kotlin similarity index 100% rename from Task/Chaocipher/Kotlin/chaocipher.kts rename to Task/Chaocipher/Kotlin/chaocipher.kotlin diff --git a/Task/Chaocipher/Pluto/chaocipher.pluto b/Task/Chaocipher/Pluto/chaocipher.pluto deleted file mode 100644 index 92add48042..0000000000 --- a/Task/Chaocipher/Pluto/chaocipher.pluto +++ /dev/null @@ -1,55 +0,0 @@ -require "table2" - -enum chao begin - encrypt, - decrypt -end - -local function exec(text, mode, show_steps) - local len = #text - local left = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" - local right = "PTLNBQDEOYSFAVZKGJRIHWXUMC" - local etext = table.rep(len, 0) - local temp = table.rep(26, "") - for i = 1, len do - if show_steps then print($"{left} {right}") end - local index - if mode == chao.encrypt then - index = right:find(text[i], 1, true) - etext[i] = left[index] - else - index = left:find(text[i], 1, true) - etext[i] = right[index] - end - if i == len then break end - - -- Permute left. - for j = index, 26 do temp[j - index + 1] = left[j] end - for j = 1, index - 1 do temp[27 - index + j] = left[j] end - local store = temp[2] - for j = 3, 14 do temp[j - 1] = temp[j] end - temp[14] = store - left = temp:concat("") - - -- Permute right. - for j = index, 26 do temp[j - index + 1] = right[j] end - for j = 1, index - 1 do temp[27 - index + j] = right[j] end - store = temp[1] - for j = 2, 26 do temp[j - 1] = temp[j] end - temp[26] = store - store = temp[3] - for j = 4, 14 do temp[j - 1] = temp[j] end - temp[14] = store - right = temp:concat("") - end - return etext:concat("") -end - -local plain_text = "WELLDONEISBETTERTHANWELLSAID" -print($"The original plaintext is : {plain_text}") -io.write("\nThe left and right alphabets after each permutation ") -print("during encryption are :\n") -local cipher_text = exec(plain_text, chao.encrypt, true) -print($"\nThe ciphertext is : {cipher_text}") -local plain_text2 = exec(cipher_text, chao.decrypt, false) -print($"\nThe recovered plaintext is : {plain_text2}") diff --git a/Task/Chaocipher/QBasic/chaocipher.basic b/Task/Chaocipher/QBasic/chaocipher.basic deleted file mode 100644 index 25bdb7945c..0000000000 --- a/Task/Chaocipher/QBasic/chaocipher.basic +++ /dev/null @@ -1,142 +0,0 @@ -DECLARE FUNCTION AlphaLeft$ (ct$, pt$, CharPos!) -DECLARE FUNCTION AlphaRight$ (ct$, pt$, CharPos!) -DECLARE FUNCTION Decode$ (Text$, ct$, pt$) -DECLARE FUNCTION Encode$ (Text$, ct$, pt$) - -CLS - -' Deciphering a Chaocipher-encrypted message is identical to the steps used -' for enciphering. The sole difference is that the decipherer locates the -' known ciphertext letter in the left (ct$) alphabet, with the plaintext -' letter being the corresponding letter in the right (pt$) alphabet -' -' Alphabet permuting is identical in enciphering and deciphering - -' Start of Main Code - -' LEFT (Cipher Text$): HXUCZVAMDSLKPEFJRIGTWOBNYQ -tLeft$ = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" - -' RIGHT (Plain Text$): PTLNBQDEOYSFAVZKGJRIHWXUMC -tRight$ = "PTLNBQDEOYSFAVZKGJRIHWXUMC" - -' Cipher Message (Used to verify a good encoding) -cText$ = "OAHQHCNYNXTSZJRRHJBYHQKSOUJY" - -' Plain Text$ Message -pText$ = "WELLDONEISBETTERTHANWELLSAID" -PRINT " Plain Text$: "; pText$ -PRINT - -ctLeft$ = tLeft$ -ptRight$ = tRight$ - -' Final Cipher Text$ -eText$ = Encode$(pText$, ctLeft$, ptRight$) -PRINT " Cipher Text$: "; eText$ -PRINT - -IF eText$ = cText$ THEN PRINT "Successful" ELSE PRINT "Failed" - -ctLeft$ = tLeft$ -ptRight$ = tRight$ -dText$ = Decode$(eText$, ctLeft$, ptRight$) -PRINT -PRINT " Plain Text$: "; dText$ -PRINT - -IF dText$ = pText$ THEN PRINT "Successful" ELSE PRINT "Failed" -END - -' Left Alphabet -FUNCTION AlphaLeft$ (ct$, pt$, CharPos) - tStr$ = ct$ - - ' 1. Shift the entire left alphabet cyclically so the ciphertext letter - ' just enciphered is positioned at the zenith (i.e., position 1). - tStr$ = RIGHT$(ct$, LEN(ct$) - CharPos + 1) + LEFT$(ct$, CharPos - 1) - - ' 2. Extract the letter found at position zenith+1 (i.e., the letter to - ' the right of the zenith), taking it out of the alphabet, temporarily - ' leaving an unfilled "Hole$" - - Hole$ = MID$(tStr$, 2, 1) - MID$(tStr$, 2, 1) = " " - - ' 3. Shift all letters in positions zenith+2 up to, and including, the - ' nadir (zenith+13), moving them one position to the left - - tStr$ = LEFT$(tStr$, 1) + MID$(tStr$, 3, 12) + " " + RIGHT$(tStr$, 12) - - ' 4. Insert the just-extracted letter into the nadir position - ' (i.e., zenith+13) - - MID$(tStr$, 14, 1) = Hole$ - - AlphaLeft$ = tStr$ -END FUNCTION - -' Right Alphabet -FUNCTION AlphaRight$ (ct$, pt$, CharPos) - tStr$ = pt$ - - ' 1. Shift the entire right alphabet cyclically so the plaintext letter - ' just enciphered is positioned at the zenith. - - tStr$ = RIGHT$(tStr$, LEN(tStr$) - CharPos + 1) + LEFT$(tStr$, CharPos - 1) - - ' 2. Now shift the entire alphabet one more position to the left (i.e., - ' the leftmost letter moves cyclically to the far right), moving a new - ' letter into the zenith position. - - tStr$ = RIGHT$(tStr$, 25) + LEFT$(tStr$, 1) - - ' 3. Extract the letter at position zenith+2, taking it out of the - ' alphabet, temporarily leaving an unfilled "Hole$". - - Hole$ = MID$(tStr$, 3, 1) - MID$(tStr$, 3, 1) = " ": - - ' 4. Shift all letters beginning with zenith+3 up to, and including, the - ' nadir (zenith+13), moving them one position to the left. - - tStr$ = LEFT$(tStr$, 2) + MID$(tStr$, 4, 11) + " " + RIGHT$(tStr$, 12) - - ' 5. Insert the just-extracted letter into the nadir position (zenith+13) - - MID$(tStr$, 14, 1) = Hole$ - - AlphaRight$ = tStr$ -END FUNCTION - -FUNCTION Decode$ (Text$, ct$, pt$) - tStr$ = "" - - FOR t = 1 TO LEN(Text$) - Char$ = MID$(Text$, t, 1) - CharPos = INSTR(ct$, Char$) - - ct$ = AlphaLeft$(ct$, pt$, CharPos) - pt$ = AlphaRight$(ct$, pt$, CharPos) - - tStr$ = tStr$ + RIGHT$(pt$, 1) - NEXT - - Decode$ = tStr$ -END FUNCTION - -FUNCTION Encode$ (Text$, ct$, pt$) - tStr$ = "" - - FOR t = 1 TO LEN(Text$) - Char$ = MID$(Text$, t, 1) - CharPos = INSTR(pt$, Char$) - - ct$ = AlphaLeft$(ct$, pt$, CharPos) - pt$ = AlphaRight$(ct$, pt$, CharPos) - - tStr$ = tStr$ + LEFT$(ct$, 1) - NEXT - - Encode$ = tStr$ -END FUNCTION diff --git a/Task/Chaocipher/Rust/chaocipher.rs b/Task/Chaocipher/Rust/chaocipher.rust similarity index 100% rename from Task/Chaocipher/Rust/chaocipher.rs rename to Task/Chaocipher/Rust/chaocipher.rust diff --git a/Task/Chaocipher/Swift/chaocipher.swift b/Task/Chaocipher/Swift/chaocipher.swift deleted file mode 100644 index ae0cc62b27..0000000000 --- a/Task/Chaocipher/Swift/chaocipher.swift +++ /dev/null @@ -1,84 +0,0 @@ -enum Mode { - case encrypt - case decrypt -} - -class Chaocipher { - private static let L_ALPHABET = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" - private static let R_ALPHABET = "PTLNBQDEOYSFAVZKGJRIHWXUMC" - - private static func indexOf(array: [Character], char: Character) -> Int { - for i in 0.. String { - var left = Array(L_ALPHABET) - var right = Array(R_ALPHABET) - var eText = [Character](repeating: " ", count: text.count) - var temp = [Character](repeating: " ", count: 26) - - let textChars = Array(text) - - for i in 0.. String { - return exec(text: text, mode: .encrypt, showSteps: showSteps) - } - - static func decrypt(text: String, showSteps: Bool = false) -> String { - return exec(text: text, mode: .decrypt, showSteps: showSteps) - } -} - -// Main program -let plainText = "WELLDONEISBETTERTHANWELLSAID" -print("The original plaintext is : \(plainText)") -print("\nThe left and right alphabets after each permutation during encryption are:") -let cipherText = Chaocipher.encrypt(text: plainText, showSteps: true) -print("\nThe cipher text is : \(cipherText)") -let plainText2 = Chaocipher.decrypt(text: cipherText) -print("\nThe recovered plaintext is : \(plainText2)") diff --git a/Task/Chaocipher/Tcl/chaocipher.tcl b/Task/Chaocipher/Tcl/chaocipher.tcl deleted file mode 100644 index a0fc593619..0000000000 --- a/Task/Chaocipher/Tcl/chaocipher.tcl +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env tclsh - -# Tcl implementation of Chaocipher -# (John F. Byrne, 1918) -# -# from paper "CHAOCIPHER REVEALED: THE ALGORITHM" -# (Moshe Rubin, 2010) -# http://www.mountainvistasoft.com/chaocipher/ActualChaocipher/Chaocipher-Revealed-Algorithm.pdf -# - -# ============ globals "wheels" ============ -variable l_key {HXUCZVAMDSLKPEFJRIGTWOBNYQ} -variable r_key {PTLNBQDEOYSFAVZKGJRIHWXUMC} - - - -# ============ procedures ================== - - -# swap range of n letters from end to front -proc permute {alpha n } { - - set A [string range $alpha 0 $n-1 ] - set B [string range $alpha $n end ] - - return "${B}${A}" -} - - -# rotate based on key in right alphabet -# (permute each by same amnount) -proc rotate { left right key } { - - set idx [string first $key $right] - - set L [permute $left $idx ] - - set R [permute $right $idx] - - return [list $L $R] -} - - -# split and rearrange each alphabet -# according to recipe -proc cycle { left right } { - - # (0)(2-13)(1)(14-25) - set l1 [string index $left 0 ] - set l2 [string range $left 2 13 ] - set l3 [string index $left 1 ] - set l4 [string range $left 14 end] - - set L [join [list $l1 $l2 $l3 $l4] ""] - - # (1-2)(4-14)(3)(15-25)(0) - set r1 [string range $right 1 2 ] - set r2 [string range $right 4 14 ] - set r3 [string index $right 3 ] - set r4 [string range $right 15 end] - set r5 [string index $right 0 ] - - set R [join [list $r1 $r2 $r3 $r4 $r5] ""] - - return [list $L $R] -} - - -# rotate wheels and generate cipher text or -# recover plain text -proc chao { input left right mode verbose } { - - set out {} - - set wheels {} - - set len [string length $input] - - if { $verbose } { - puts stdout "input\t$input\tLENGTH $len" - - set s [format "%-${len}s\t|\t%-${len}s" $left $right] - - puts stdout "keys:\t$s" - - puts stdout "\ncycled keys:" - } - - # string -> list - set input_list [split $input ""] - - set count 0 - # iterate each letter - foreach letter $input_list { - - incr count - - if {$mode eq "encrypt" } { - # encrypt - - # rotate and permute - set wheels [rotate $left $right $letter] - lassign $wheels left right - - # ciphered letter to output (left[0]) - lappend out [string index $left 0] - - } else { - - # decrypt - - # rotate and permute - set wheels [rotate $right $left $letter] - lassign $wheels right left - - # deciphered letter to output (right[0]) - lappend out [string index $right 0] - } - - # cycle the alphabets - set cycled [cycle $left $right] - lassign $cycled left right - - if {$verbose} { puts stderr "${count}\t${left}\t|\t${right}" } - - - } ; # foreach letter - - # list -> string - set out [join $out ""] - - return $out -} - - -# ============= main ================= -if { [info script] eq $::argv0 } { - - # --------- init ------------------ - set left $l_key - set right $r_key - set plain_text "WELLDONEISBETTERTHANWELLSAID" - - # ---------- encipher ------------- - - set cipher_text [chao $plain_text $left $right encrypt 1] - - # ---------- decipher ------------- - - set decrypted_text [chao $cipher_text $left $right decrypt 0] - # ----------- output -------------- - - puts stdout "\nplain text: \t ${plain_text}" - puts stdout "\ncipher text: \t ${cipher_text}" - puts stdout "\ndecrypted: \t ${decrypted_text}" - - return 0 -} - -# end diff --git a/Task/Chaos-game/Ada/chaos-game.adb b/Task/Chaos-game/Ada/chaos-game.adb deleted file mode 100644 index fe213c85fc..0000000000 --- a/Task/Chaos-game/Ada/chaos-game.adb +++ /dev/null @@ -1,45 +0,0 @@ -pragma Ada_2022; -with Ada.Numerics; use Ada.Numerics; -with Ada.Numerics.Discrete_Random; -with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; -with Easy_Graphics; use Easy_Graphics; - -procedure Chaos_Game is - Img : Easy_Image := New_Image ((1, 1), (512, 512), WHITE); - - procedure Chaos (Image : in out Easy_Image; - Vertex_Count : Positive; - Radius : Float; - Iters : Positive) is - type Vertex_Array is array (1 .. Vertex_Count) of Point; - Vertices : Vertex_Array; - subtype Vertex_Range is Integer range 1 .. Vertex_Count; - package Rand_V is new Ada.Numerics.Discrete_Random (Vertex_Range); - use Rand_V; - Gen : Generator; - Half_X : constant Integer := X_Last (Image) / 2; - Half_Y : constant Integer := Y_Last (Image) / 2; - Half_Pi : constant Float := Float (Pi) / 2.0; - Two_Pi : constant Float := Float (Pi) * 2.0; - V : Integer; - X : Integer := Half_X; - Y : Integer := Half_Y; - begin - for V in 1 .. Vertex_Count loop - Vertices (V).X := Half_X + Integer (Float (Half_X) * - Cos (Half_Pi + (Float (V - 1)) * Two_Pi / Float (Vertex_Count))); - Vertices (V).Y := Half_Y - Integer (Float (Half_Y) * - Sin (Half_Pi + (Float (V - 1)) * Two_Pi / Float (Vertex_Count))); - end loop; - for I in 1 .. Iters loop - V := Random (Gen); - X := X + Integer (Radius * Float (Vertices (V).X - X)); - Y := Y + Integer (Radius * Float (Vertices (V).Y - Y)); - Plot (Image, (X, Y), BLACK); - end loop; - end Chaos; - -begin - Chaos (Img, 3, 0.5, 250_000); - Write_GIF (Img, "chaos_game.gif"); -end Chaos_Game; diff --git a/Task/Chaos-game/AmigaBASIC/chaos-game.basic b/Task/Chaos-game/AmigaBASIC/chaos-game.basic deleted file mode 100644 index 637e89a1da..0000000000 --- a/Task/Chaos-game/AmigaBASIC/chaos-game.basic +++ /dev/null @@ -1,28 +0,0 @@ -DEFINT a-z -w=600:h=180:w2=300 -x=w*RND:y=h*RND - -FOR i=1 TO 32000 - v=2*RND+1 - ON v GOTO One, Two, Three - -One: - x=x/2 - y=y/2 - GOTO Draw - -Two: - x=w2+(w2-x)/2 - y=h-(h-y)/2 - GOTO Draw - -Three: - x=w-(w-x)/2 - y=y/2 - -Draw: - PSET (x,y),v -NEXT - -loop: - GOTO loop diff --git a/Task/Chaos-game/Atari-BASIC/chaos-game.basic b/Task/Chaos-game/Atari-BASIC/chaos-game.basic deleted file mode 100644 index b612f7a348..0000000000 --- a/Task/Chaos-game/Atari-BASIC/chaos-game.basic +++ /dev/null @@ -1,18 +0,0 @@ -10 GRAPHICS 7+16 -20 W=159:H=95:W2=79 -30 X=INT(W*RND(0)) -40 Y=INT(H*RND(0)) -50 FOR I=1 TO 5000 -60 V=INT(3*RND(0))+1 -70 GOTO 100*V -100 X=X/2:Y=Y/2 -110 GOTO 500 -200 X=W2+(W2-X)/2 -210 Y=H-(H-Y)/2 -220 GOTO 500 -300 X=W-(W-X)/2 -310 Y=Y/2 -500 COLOR V -510 PLOT X,Y -520 NEXT I -530 GOTO 530 diff --git a/Task/Chaos-game/Delphi/chaos-game.pas b/Task/Chaos-game/Delphi/chaos-game.delphi similarity index 100% rename from Task/Chaos-game/Delphi/chaos-game.pas rename to Task/Chaos-game/Delphi/chaos-game.delphi diff --git a/Task/Chaos-game/EasyLang/chaos-game.easy b/Task/Chaos-game/EasyLang/chaos-game.easy index ae10673f1b..b0a7b03aae 100644 --- a/Task/Chaos-game/EasyLang/chaos-game.easy +++ b/Task/Chaos-game/EasyLang/chaos-game.easy @@ -1,11 +1,12 @@ -gcolor 900 +color 900 x[] = [ 0 100 50 ] -y[] = [ 14 14 100 ] +y[] = [ 7 7 93 ] x = randomf * 100 y = randomf * 100 for i = 1 to 100000 - grect x y 0.3 0.3 - h = random 1 3 - x = (x + x[h]) / 2 - y = (y + y[h]) / 2 + move x y + rect 0.3 0.3 + h = random 3 + x = (x + x[h]) / 2 + y = (y + y[h]) / 2 . diff --git a/Task/Chaos-game/Emacs-Lisp/chaos-game.el b/Task/Chaos-game/Emacs-Lisp/chaos-game.l similarity index 100% rename from Task/Chaos-game/Emacs-Lisp/chaos-game.el rename to Task/Chaos-game/Emacs-Lisp/chaos-game.l diff --git a/Task/Chaos-game/FutureBasic/chaos-game.basic b/Task/Chaos-game/FutureBasic/chaos-game.basic deleted file mode 100644 index d864811fed..0000000000 --- a/Task/Chaos-game/FutureBasic/chaos-game.basic +++ /dev/null @@ -1,27 +0,0 @@ -void local fn DoIt - long w = 460, h = 400, i, x = rnd(w), y = rnd(h) - for i = 1 to 50000 - select ( rnd(3)-1 ) - case 1 - x = w/2+(w/2-x)/2 - y = h-(h-y)/2 - pen ,fn ColorRed - case 2 - x = w-(w-x)/2 - y = y/2 - pen ,fn ColorGreen - case else - x = x/2 - y = y/2 - pen ,fn ColorBlue - end select - line x-0.5,y-0.5,x+0.5,y+0.5 - next -end fn - -window 1, @"Chaos Game", (0,0,460,400) -WindowSetBackgroundColor( 1, fn ColorWhite ) - -fn DoIt - -HandleEvents diff --git a/Task/Chaos-game/GW-BASIC/chaos-game.basic b/Task/Chaos-game/GW-BASIC/chaos-game.basic deleted file mode 100644 index 73af477166..0000000000 --- a/Task/Chaos-game/GW-BASIC/chaos-game.basic +++ /dev/null @@ -1,19 +0,0 @@ -100 REM Chaos game -110 CLS -120 SCREEN 7 '320x200 EGA Color -130 X = INT(RND(1) * 200) -140 Y = INT(RND(1) * 173) -150 FOR I=1 TO 20000 -160 V = INT(RND(1) * 3) + 1 -170 ON V GOTO 180,210,240 -180 X = X/2 -190 Y = Y/2 -200 GOTO 260 -210 X = 100 + (100-X)/2 -220 Y = 173 - (173-Y)/2 -230 GOTO 260 -240 X = 200 - (200-X)/2 -250 Y = Y/2 -260 PSET(X,Y),V -270 NEXT I -280 END diff --git a/Task/Chaos-game/IS-BASIC/chaos-game.basic b/Task/Chaos-game/IS-BASIC/chaos-game.basic deleted file mode 100644 index ab560fabbf..0000000000 --- a/Task/Chaos-game/IS-BASIC/chaos-game.basic +++ /dev/null @@ -1,20 +0,0 @@ -100 PROGRAM "ChaosGam.bas" -110 RANDOMIZE -120 GRAPHICS HIRES 4 -130 LET X=RND(800):LET Y=RND(600) -140 FOR I=1 TO 20000 -150 LET VERTEX=RND(3) -160 SELECT CASE VERTEX -170 CASE 0 -180 LET X=X/2 -190 LET Y=Y/2 -200 CASE 1 -210 LET X=400+(400-X)/2 -220 LET Y=600-(600-Y)/2 -230 CASE 2 -240 LET X=800-(800-X)/2 -250 LET Y=Y/2 -260 END SELECT -270 SET INK VERTEX+1 -280 PLOT X,Y -290 NEXT diff --git a/Task/Chaos-game/J/chaos-game.j b/Task/Chaos-game/J/chaos-game.j index bad0f35b60..bdf828c34e 100644 --- a/Task/Chaos-game/J/chaos-game.j +++ b/Task/Chaos-game/J/chaos-game.j @@ -1,6 +1,33 @@ +Note 'plan, Working in complex plane' + Make an equilateral triangle. + Make a list of N targets + Starting with a random point near the triangle, + iteratively generate new points. + plot the new points. + + j has a particularly rich notation for numbers. + + 1ad_90 specifies a complex number with radius 1 + at an angle of negative 90 degrees. + + 2p1 is 2 times (pi raised to the first power). +) + +N=: 3000 + require'plot' -NB. equilateral triangle with vertices on unit circle. rotated for fun. -Triangle=: *1ad_90 1ad150 1ad30*j./2 1 o.(2p1%6)*?0 -Targets=: (?3000#3) { Triangle -Start=: j./2 1 o.2p1*?0 NB. start on unit circle -'marker' plot ((+/%#)@(,{.) , ])/Targets,Start +TAU=: 2p1 NB. tauday.com +mean=: +/ % # + +NB. equilateral triangle with vertices on unit circle +NB. rotated for fun. +TRIANGLE=: *(j./2 1 o.(TAU%6)*?0)*1ad_90 1ad150 1ad30 + +TARGETS=: (N ?@:# 3) { TRIANGLE + +NB. start on unit circle +START=: j./2 1 o.TAU*?0 + +NEW_POINTS=: (mean@:(, {.) , ])/ TARGETS , START + +'marker'plot NEW_POINTS diff --git a/Task/Chaos-game/Julia/chaos-game.jl b/Task/Chaos-game/Julia/chaos-game.julia similarity index 100% rename from Task/Chaos-game/Julia/chaos-game.jl rename to Task/Chaos-game/Julia/chaos-game.julia diff --git a/Task/Chaos-game/Kotlin/chaos-game.kts b/Task/Chaos-game/Kotlin/chaos-game.kotlin similarity index 100% rename from Task/Chaos-game/Kotlin/chaos-game.kts rename to Task/Chaos-game/Kotlin/chaos-game.kotlin diff --git a/Task/Chaos-game/MSX-Basic/chaos-game.basic b/Task/Chaos-game/MSX-Basic/chaos-game.basic deleted file mode 100644 index f5d3c3748e..0000000000 --- a/Task/Chaos-game/MSX-Basic/chaos-game.basic +++ /dev/null @@ -1,22 +0,0 @@ -100 REM Chaos game -110 CLS -120 SCREEN 2 -130 X = INT(RND(1) * 256) -140 Y = INT(RND(1) * 192) -150 FOR I=1 TO 20000 -160 V = INT(RND(1) * 3) + 1 -170 ON V GOTO 180,220,260 -180 X = X/2 -190 Y = Y/2 -200 V = 8 'red -210 GOTO 290 -220 X = 128 + (128-X)/2 -230 Y = 192 - (192-Y)/2 -240 V = 3 'green -250 GOTO 290 -260 X = 256 - (256-X)/2 -270 Y = Y/2 -280 V = 7 'blue -290 PSET(X,Y),V -300 NEXT I -310 END diff --git a/Task/Chaos-game/Rust/chaos-game.rs b/Task/Chaos-game/Rust/chaos-game.rust similarity index 100% rename from Task/Chaos-game/Rust/chaos-game.rs rename to Task/Chaos-game/Rust/chaos-game.rust diff --git a/Task/Chaos-game/Uiua/chaos-game.uiua b/Task/Chaos-game/Uiua/chaos-game.uiua deleted file mode 100644 index 23cfb68508..0000000000 --- a/Task/Chaos-game/Uiua/chaos-game.uiua +++ /dev/null @@ -1,20 +0,0 @@ -Dim ← 500 -Points ← [[50 ⌊÷2Dim] [-50Dim 50] [-50Dim -50Dim]] -# Uncomment to try different square or pentagonal references. -# Points ← [[50 50] [-50Dim 50] [50 -50Dim][-50Dim -50Dim]] -# Points ← [[50 ⌊÷2Dim] [⌊×0.4Dim 50] [⌊×0.4Dim -50Dim] [-50Dim 120] [-50Dim -120Dim]] -Colours ← [[1 0 0] [0 1 0] [0 0 1] [1 1 0] [1 0 1] [0 1 1]] -Rand ← ⌊×⚂ - -↯Dim_Dim_3 0 -∧(⍜(⊡|[1 1 1]◌))Points -⊟Rand Dim Rand Dim -⍥( - Rand⧻Points - # Set next point and colour based on target. - ⊃(⌊÷2+⊡:Points|⊙◌⊡:Colours) - ⟜⍜⊡◌⊙: -)10000 -◌ -# Uncomment to save image. -# &fwa "UiuaChaosGameSerpinski.png" &ime "png" diff --git a/Task/Chaos-game/Uxntal/chaos-game.uxnatl b/Task/Chaos-game/Uxntal/chaos-game.uxnatl deleted file mode 100644 index 13873818ad..0000000000 --- a/Task/Chaos-game/Uxntal/chaos-game.uxnatl +++ /dev/null @@ -1,82 +0,0 @@ -|00 @System/vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1 -|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 -|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 - -|00 - @State &x $2 &y $2 - -|0100 -@on-reset ( -> ) - .DateTime/minute DEI2 SWP #20 SFT2 lcg/ - - #0f0f DUP2k - .System/r DEO2 - .System/g DEO2 - .System/b DEO2 - - ( 256 x 222 fits all three reference points ) - #0100 .Screen/width DEO2 - #00de .Screen/height DEO2 - - start-point - .State/x STZ2 - .State/y STZ2 - - ;on-frame .Screen/vector DEO2 - BRK - -@on-frame ( -> ) - [ LIT2 00 -State/x ] LDZ .Screen/x DEO2 - [ LIT2 00 -State/y ] LDZ .Screen/y DEO2 - [ LIT2 01 -Screen/pixel ] DEO - - next-point - .State/x STZ2 - .State/y STZ2 - BRK - -@start-point ( -- y* x* ) - ( pick a random point in a square ) - lcg/next lcg/next - ( mirror point if needed to move point to top left triangle ) - ADD2k OVR2 GTH2 ?{ - #0000 SWP2 SUB2 SWP2 - #0000 SWP2 SUB2 - } - ( skew points so triangle has a point in the bottom middle ) - SWP2 OVR2 #01 SFT2 ADD2 - ( mirror points vertically to make the triangle point up ) - STH2 #0000 SWP2 SUB2 - ( fixed point multiply y by cos 30deg to make it equilateral ) - ( hi * hi ) OVR #00 SWP #00dd MUL2 STH2 - ( hi * lo ) SWP #00 SWP #00b4 MUL2 STH2 - ( lo * hi ) #00 SWP #00dd MUL2 - ( add low bytes ) STH2r ADD2 #08 SFT2 - ( add to high product ) STH2r ADD2 - STH2r - - JMP2r - -@next-point ( -- y* x* ) - ( midpoint of previous State and a random corner ) - random-corner - #01 SFT2 .State/x LDZ2 #01 SFT2 ADD2 - STH2 - #01 SFT2 .State/y LDZ2 #01 SFT2 ADD2 - STH2r JMP2r - -@random-corner ( -- y* x* ) - ( randomly pick one of the three corners ) - lcg/next - #0003 DIV2k INC2 MUL2 SUB2 NIP - INC DUP ?{ POP #0000 #8000 JMP2r } - INC DUP ?{ POP #ddb4 #0000 JMP2r } - POP #ddb4 #ffff JMP2r - -@lcg/ ( seed* -- ) - ,&State STR2 JMP2r - -@lcg/next ( -- x* ) - [ LIT2 &State $2 ] - #0815 MUL2 #1419 ADD2 DUP2 ,&State STR2 - JMP2r diff --git a/Task/Character-codes/Ada/character-codes.adb b/Task/Character-codes/Ada/character-codes.ada similarity index 100% rename from Task/Character-codes/Ada/character-codes.adb rename to Task/Character-codes/Ada/character-codes.ada diff --git a/Task/Character-codes/Agena/character-codes.agena b/Task/Character-codes/Agena/character-codes.agena deleted file mode 100644 index a1410f30ad..0000000000 --- a/Task/Character-codes/Agena/character-codes.agena +++ /dev/null @@ -1,2 +0,0 @@ -print( abs "a" ); # prints the character code of a (97 in ASCII) -print( char( 97 ) ); # prints the character corresponding to code 97 ("a" in ASCII) diff --git a/Task/Character-codes/ArkScript/character-codes.ark b/Task/Character-codes/ArkScript/character-codes.ark deleted file mode 100644 index d96abc35c4..0000000000 --- a/Task/Character-codes/ArkScript/character-codes.ark +++ /dev/null @@ -1,4 +0,0 @@ -(import std.String) - -(print (string:ord "a")) -(print (string:chr 97)) diff --git a/Task/Character-codes/Arturo/character-codes.arturo b/Task/Character-codes/Arturo/character-codes.arturo index f9ac1ae91b..e98e2586e9 100644 --- a/Task/Character-codes/Arturo/character-codes.arturo +++ b/Task/Character-codes/Arturo/character-codes.arturo @@ -1,3 +1,3 @@ print to :integer first "a" -print to :integer 'a' +print to :integer `a` print to :char 97 diff --git a/Task/Character-codes/Ballerina/character-codes.ballerina b/Task/Character-codes/Ballerina/character-codes.ballerina deleted file mode 100644 index c16ce85fc2..0000000000 --- a/Task/Character-codes/Ballerina/character-codes.ballerina +++ /dev/null @@ -1,15 +0,0 @@ -import ballerina/io; - -public function main() returns error? { - int[] cps = []; - foreach string c in ["a", "π", "字", "🐘"] { - int cp = c[0].toCodePointInt(); - cps.push(cp); - io:println(`${c} = ${cp}`); - } - io:println(); - foreach int i in cps { - var c = check string:fromCodePointInt(i); - io:println(`${i} = ${c}`); - } -} diff --git a/Task/Character-codes/COBOL/character-codes.cob b/Task/Character-codes/COBOL/character-codes.cobol similarity index 100% rename from Task/Character-codes/COBOL/character-codes.cob rename to Task/Character-codes/COBOL/character-codes.cobol diff --git a/Task/Character-codes/Chipmunk-Basic/character-codes.basic b/Task/Character-codes/Chipmunk-Basic/character-codes.basic deleted file mode 100644 index 14eb2171df..0000000000 --- a/Task/Character-codes/Chipmunk-Basic/character-codes.basic +++ /dev/null @@ -1,2 +0,0 @@ -10 print "a - > ";asc("a") -20 print "98 -> ";chr$(98) diff --git a/Task/Character-codes/Crystal/character-codes.cr b/Task/Character-codes/Crystal/character-codes.cr deleted file mode 100644 index 5fb1cfa9e7..0000000000 --- a/Task/Character-codes/Crystal/character-codes.cr +++ /dev/null @@ -1,2 +0,0 @@ -'Ω'.ord # => 937 -937.chr # => 'Ω' diff --git a/Task/Character-codes/Dart/character-codes.dart b/Task/Character-codes/Dart/character-codes.dart deleted file mode 100644 index b1b602f4bd..0000000000 --- a/Task/Character-codes/Dart/character-codes.dart +++ /dev/null @@ -1,6 +0,0 @@ -void main() { - const string = 'D'; - print(string.runes.first); - var out = String.fromCharCode(67); - print(out); -} diff --git a/Task/Character-codes/Delphi/character-codes.pas b/Task/Character-codes/Delphi/character-codes.delphi similarity index 100% rename from Task/Character-codes/Delphi/character-codes.pas rename to Task/Character-codes/Delphi/character-codes.delphi diff --git a/Task/Character-codes/EMal/character-codes.emal b/Task/Character-codes/EMal/character-codes.emal deleted file mode 100644 index f7b1fe0929..0000000000 --- a/Task/Character-codes/EMal/character-codes.emal +++ /dev/null @@ -1,14 +0,0 @@ -^|ord and chr work with Unicode code points|^ -writeLine(ord("a")) # prints "97" -writeLine(chr(97)) # prints "a" -writeLine(ord("π")) # prints "960" -writeLine(chr(960)) # prints "π" -writeLine() -var cps ← int[] -for each var c in text["a", "π", "字", "🐘"] - var cp ← ord(c) - cps.append(cp) - writeLine(c, " = ", cp) -end -writeLine() -cps.list( "; ASC("a") -20 PRINT "98 -> "; CHR$(98) diff --git a/Task/Character-codes/Gambas/character-codes.gambas b/Task/Character-codes/Gambas/character-codes-1.gambas similarity index 100% rename from Task/Character-codes/Gambas/character-codes.gambas rename to Task/Character-codes/Gambas/character-codes-1.gambas diff --git a/Task/Character-codes/GAP/character-codes.gap b/Task/Character-codes/Gambas/character-codes-2.gambas similarity index 100% rename from Task/Character-codes/GAP/character-codes.gap rename to Task/Character-codes/Gambas/character-codes-2.gambas diff --git a/Task/Character-codes/Haxe/character-codes.hx b/Task/Character-codes/Haxe/character-codes.hx deleted file mode 100644 index 3d1788b91d..0000000000 --- a/Task/Character-codes/Haxe/character-codes.hx +++ /dev/null @@ -1,7 +0,0 @@ -class Main { - static public function main():Void { - trace("a".code); - trace("∅".code); - trace("🍆".code); - } -} diff --git a/Task/Character-codes/Julia/character-codes.jl b/Task/Character-codes/Julia/character-codes.julia similarity index 100% rename from Task/Character-codes/Julia/character-codes.jl rename to Task/Character-codes/Julia/character-codes.julia diff --git a/Task/Character-codes/K/character-codes.k b/Task/Character-codes/K/character-codes.k index 8f4455a296..038c6a31d1 100644 --- a/Task/Character-codes/K/character-codes.k +++ b/Task/Character-codes/K/character-codes.k @@ -1,5 +1,5 @@ - `i$ "abcABC" + _ic "abcABC" 97 98 99 65 66 67 - `c$ 97 98 99 65 66 67 + _ci 97 98 99 65 66 67 "abcABC" diff --git a/Task/Character-codes/Kotlin/character-codes.kts b/Task/Character-codes/Kotlin/character-codes.kotlin similarity index 100% rename from Task/Character-codes/Kotlin/character-codes.kts rename to Task/Character-codes/Kotlin/character-codes.kotlin diff --git a/Task/Character-codes/Langur/character-codes.langur b/Task/Character-codes/Langur/character-codes.langur index 053f7ab322..25f711852a 100644 --- a/Task/Character-codes/Langur/character-codes.langur +++ b/Task/Character-codes/Langur/character-codes.langur @@ -1,11 +1,11 @@ -val a1 = 'a' -val a2 = 97 -val a3 = "a"[1] -val a4 = s2cp("a", of=1) -val a5 = [a1, a2, a3, a4] +val .a1 = 'a' +val .a2 = 97 +val .a3 = "a"[1] +val .a4 = s2cp "a", 1 +val .a5 = [.a1, .a2, .a3, .a4] -writeln a1 == a2 -writeln a2 == a3 -writeln a3 == a4 -writeln "numbers: ", join(map([a1, a2, a3, a4, a5], by=string), by=", ") -writeln "letters: ", join(map([a1, a2, a3, a4, a5], by=cp2s), by=", ") +writeln .a1 == .a2 +writeln .a2 == .a3 +writeln .a3 == .a4 +writeln "numbers: ", join ", ", [.a1, .a2, .a3, .a4, .a5] +writeln "letters: ", join ", ", [cp2s(.a1), cp2s(.a2), cp2s(.a3), cp2s(.a4), cp2s(.a5)] diff --git a/Task/Character-codes/M2000-Interpreter/character-codes.m2000 b/Task/Character-codes/M2000-Interpreter/character-codes.m2000 index 2f909d53d2..f334be9e7a 100644 --- a/Task/Character-codes/M2000-Interpreter/character-codes.m2000 +++ b/Task/Character-codes/M2000-Interpreter/character-codes.m2000 @@ -7,33 +7,16 @@ Print ChrCode$(ChrCode("a")) \\ (,) is an empty array. -Function Codes(a$, localeID=1033) { - If Len(A$)=0 then =(,) : Exit - \\ Str$(string) return one byte character - oldlocale=locale - locale localeID - a=Str$(a$) - locale oldlocale - Codes=(,) - locale 1033 - // 1 byte length returns 0.5 from len() ' 1 for 2 bytes. - // chr$(string) convert to UTF16LE with current LOCALE - For i=1 to len(a)*2 - Append Codes, (chrcode(chr$(mid$(a,i,1 as byte))),) - Next i - locale oldlocale - =Codes +Function Codes(a$) { + If Len(A$)=0 then =(,) : Exit + Buffer Mem as byte*Len(a$) + \\ Str$(string) return one byte character + Return Mem, 0:=Str$(a$) + Inventory Codes + For i=0 to len(Mem)-1 + Append Codes, i:=Eval(Mem, i) + Next i + =Codes } -Print Codes("abcdΩ", 1032)#str$(", ") -\\ 97, 98, 99, 100, 217 - -Function CodesUNICODE(a) { - If Len(a)=0 then =(,) : Exit - Codes=(,) - For i=1 to len(a) - Append Codes, (chrcode(mid$(a,i,1)),) - Next i - =Codes -} -Print CodesUNICODE("abcdΩ")#str$(", ") -\\ 97, 98, 99, 100, 937 +Print Codes("abcd") +\\ 97 98 99 100 diff --git a/Task/Character-codes/MSX-Basic/character-codes.basic b/Task/Character-codes/MSX-Basic/character-codes.basic deleted file mode 100644 index 340eaa4010..0000000000 --- a/Task/Character-codes/MSX-Basic/character-codes.basic +++ /dev/null @@ -1,2 +0,0 @@ -10 PRINT "a - > "; ASC("a") -20 PRINT "98 -> "; CHR$(98) diff --git a/Task/Character-codes/MiniScript/character-codes.mini b/Task/Character-codes/MiniScript/character-codes.mini deleted file mode 100644 index d204f9122c..0000000000 --- a/Task/Character-codes/MiniScript/character-codes.mini +++ /dev/null @@ -1,10 +0,0 @@ -cps = [] -for c in ["a", "π", "字", "🐘"] - cp = c.code - cps.push cp - print c + " = " + cp -end for -print -for i in cps - print i + " = " + char(i) -end for diff --git a/Task/Character-codes/OCaml/character-codes-1.ml b/Task/Character-codes/OCaml/character-codes-1.ocaml similarity index 100% rename from Task/Character-codes/OCaml/character-codes-1.ml rename to Task/Character-codes/OCaml/character-codes-1.ocaml diff --git a/Task/Character-codes/OCaml/character-codes-2.ml b/Task/Character-codes/OCaml/character-codes-2.ocaml similarity index 100% rename from Task/Character-codes/OCaml/character-codes-2.ml rename to Task/Character-codes/OCaml/character-codes-2.ocaml diff --git a/Task/Character-codes/OPL/character-codes.opl b/Task/Character-codes/OPL/character-codes.opl deleted file mode 100644 index 05ff6d3090..0000000000 --- a/Task/Character-codes/OPL/character-codes.opl +++ /dev/null @@ -1,5 +0,0 @@ -PROC main: - PRINT "a ->",ASC("a") - PRINT "97 ->",CHR$(97) - GET -ENDP diff --git a/Task/Character-codes/Oberon/character-codes.oberon b/Task/Character-codes/Oberon-2/character-codes.oberon similarity index 100% rename from Task/Character-codes/Oberon/character-codes.oberon rename to Task/Character-codes/Oberon-2/character-codes.oberon diff --git a/Task/Character-codes/Odin/character-codes.odin b/Task/Character-codes/Odin/character-codes.odin deleted file mode 100644 index 0acc50a345..0000000000 --- a/Task/Character-codes/Odin/character-codes.odin +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import "core:fmt" - -main :: proc() { - // No difference between chracters and ints - a:int=97 - fmt.println(rune(a)) - number:int='a' - fmt.println(number) -} diff --git a/Task/Character-codes/PL-I-80/character-codes.pli b/Task/Character-codes/PL-I-80/character-codes.pli deleted file mode 100644 index e41644b762..0000000000 --- a/Task/Character-codes/PL-I-80/character-codes.pli +++ /dev/null @@ -1,8 +0,0 @@ -char_codes: procedure options (main); - dcl ch char(1); - dcl n fixed bin; - ch = 'a'; - n = 97; - put skip edit (ch,' = ',rank(ch)) (a, a, f(2)); - put skip edit (n,' = ',ascii(n)) (f(2), a, a); -end char_codes; diff --git a/Task/Character-codes/PascalABC.NET/character-codes.pas b/Task/Character-codes/PascalABC.NET/character-codes.pas deleted file mode 100644 index deacfdd34e..0000000000 --- a/Task/Character-codes/PascalABC.NET/character-codes.pas +++ /dev/null @@ -1,6 +0,0 @@ -begin - var c := 'a'; - var i := c.Code; - Println(i); - Println(Chr(i)) -end. diff --git a/Task/Character-codes/Plain-English/character-codes.plain b/Task/Character-codes/Plain-English/character-codes.plain deleted file mode 100644 index e28e77ddc4..0000000000 --- a/Task/Character-codes/Plain-English/character-codes.plain +++ /dev/null @@ -1,4 +0,0 @@ -\ Obs: The little-a byte is a byte equal to 97. -Write the little-a byte's whereabouts on the console. -Put 97 into a number. -Write the number's target on the console. diff --git a/Task/Character-codes/PowerShell/character-codes-1.ps1 b/Task/Character-codes/PowerShell/character-codes-1.psh similarity index 100% rename from Task/Character-codes/PowerShell/character-codes-1.ps1 rename to Task/Character-codes/PowerShell/character-codes-1.psh diff --git a/Task/Character-codes/PowerShell/character-codes-2.ps1 b/Task/Character-codes/PowerShell/character-codes-2.psh similarity index 100% rename from Task/Character-codes/PowerShell/character-codes-2.ps1 rename to Task/Character-codes/PowerShell/character-codes-2.psh diff --git a/Task/Character-codes/PowerShell/character-codes-3.ps1 b/Task/Character-codes/PowerShell/character-codes-3.psh similarity index 100% rename from Task/Character-codes/PowerShell/character-codes-3.ps1 rename to Task/Character-codes/PowerShell/character-codes-3.psh diff --git a/Task/Character-codes/PowerShell/character-codes-4.ps1 b/Task/Character-codes/PowerShell/character-codes-4.psh similarity index 100% rename from Task/Character-codes/PowerShell/character-codes-4.ps1 rename to Task/Character-codes/PowerShell/character-codes-4.psh diff --git a/Task/Character-codes/PowerShell/character-codes-5.ps1 b/Task/Character-codes/PowerShell/character-codes-5.psh similarity index 100% rename from Task/Character-codes/PowerShell/character-codes-5.ps1 rename to Task/Character-codes/PowerShell/character-codes-5.psh diff --git a/Task/Character-codes/Rebol/character-codes.rebol b/Task/Character-codes/Rebol/character-codes.rebol deleted file mode 100644 index 8566b5bd09..0000000000 --- a/Task/Character-codes/Rebol/character-codes.rebol +++ /dev/null @@ -1,7 +0,0 @@ -print to integer! first "a" ;; == 97 -print to integer! #"a" ;; == 97 -print to binary! "a" ;; == #{61} -print to char! 97 ;; == a -print to char! 0#61 ;; == a ;; available only in Rebol3 -print #"^(61)" ;; == a -print to-hex #"a" ;; == 61 ;; since Rebol 3.20.0 diff --git a/Task/Character-codes/Retro/character-codes.retro b/Task/Character-codes/Retro/character-codes.retro index 783d9773d1..2272064c6f 100644 --- a/Task/Character-codes/Retro/character-codes.retro +++ b/Task/Character-codes/Retro/character-codes.retro @@ -1,2 +1 @@ -$a n:put nl -#97 c:put nl +'c putc diff --git a/Task/Character-codes/Rust/character-codes.rs b/Task/Character-codes/Rust/character-codes.rust similarity index 100% rename from Task/Character-codes/Rust/character-codes.rs rename to Task/Character-codes/Rust/character-codes.rust diff --git a/Task/Character-codes/S-BASIC/character-codes.basic b/Task/Character-codes/S-BASIC/character-codes.basic deleted file mode 100644 index c3a772f23b..0000000000 --- a/Task/Character-codes/S-BASIC/character-codes.basic +++ /dev/null @@ -1,14 +0,0 @@ -var ch = char -var n = integer - -ch = 'a' -n = ch -print ch; " = "; n -print ch; " = "; asc(ch) - -n = 97 -ch = n -print n; " = "; ch -print n; " = "; chr$(n) - -end diff --git a/Task/Character-codes/Scheme/character-codes.scm b/Task/Character-codes/Scheme/character-codes.ss similarity index 100% rename from Task/Character-codes/Scheme/character-codes.scm rename to Task/Character-codes/Scheme/character-codes.ss diff --git a/Task/Character-codes/TAV/character-codes.tav b/Task/Character-codes/TAV/character-codes.tav deleted file mode 100644 index 727bf15da6..0000000000 --- a/Task/Character-codes/TAV/character-codes.tav +++ /dev/null @@ -1,2 +0,0 @@ - print string 'a' code point at 1 \ print 'a'.Codepoint - print integer 97 code point as string \ print 97.Character diff --git a/Task/Character-codes/Tcl/character-codes.tcl b/Task/Character-codes/Tcl/character-codes.tcl new file mode 100644 index 0000000000..949c5ff094 --- /dev/null +++ b/Task/Character-codes/Tcl/character-codes.tcl @@ -0,0 +1,6 @@ +# ASCII +puts [scan "a" %c] ;# ==> 97 +puts [format %c 97] ;# ==> a +# Unicode is the same +puts [scan "π" %c] ;# ==> 960 +puts [format %c 960] ;# ==> π diff --git a/Task/Character-codes/Uiua/character-codes.uiua b/Task/Character-codes/Uiua/character-codes.uiua deleted file mode 100644 index 75f72c71f7..0000000000 --- a/Task/Character-codes/Uiua/character-codes.uiua +++ /dev/null @@ -1,2 +0,0 @@ --@\0@a -+@\097 diff --git a/Task/Character-codes/Uxntal/character-codes.uxnatl b/Task/Character-codes/Uxntal/character-codes.uxnatl deleted file mode 100644 index f2fd52e587..0000000000 --- a/Task/Character-codes/Uxntal/character-codes.uxnatl +++ /dev/null @@ -1,19 +0,0 @@ -%\n { 0a } -%newline { [ LIT2 \n -Console/write ] DEO } - -|18 @Console/write - -|100 - -[ LIT "a ] print/byte newline -#61 .Console/write DEO newline - -BRK - -@print/byte ( byte -- ) - DUP #04 SFT /nibble - ( >> ) - -@print/nibble ( byte -- ) - #0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD .Console/write DEO - JMP2r diff --git a/Task/Character-codes/VBScript/character-codes.vbs b/Task/Character-codes/VBScript/character-codes.vb similarity index 100% rename from Task/Character-codes/VBScript/character-codes.vbs rename to Task/Character-codes/VBScript/character-codes.vb diff --git a/Task/Character-codes/XBasic/character-codes.basic b/Task/Character-codes/XBasic/character-codes.basic deleted file mode 100644 index 216d2a45b9..0000000000 --- a/Task/Character-codes/XBasic/character-codes.basic +++ /dev/null @@ -1,10 +0,0 @@ -PROGRAM "Character codes" -VERSION "0.0000" - -DECLARE FUNCTION Entry () - -FUNCTION Entry () - PRINT "a - >"; ASC("a") - PRINT "98 -> "; CHR$(98) -END FUNCTION -END PROGRAM diff --git a/Task/Character-codes/Zig/character-codes.zig b/Task/Character-codes/Zig/character-codes.zig index 697afa9b08..59a034168e 100644 --- a/Task/Character-codes/Zig/character-codes.zig +++ b/Task/Character-codes/Zig/character-codes.zig @@ -1,38 +1,31 @@ const std = @import("std"); + +const debug = std.debug; const unicode = std.unicode; -pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - - try characterAsciiCodes(stdout); - try characterUnicodeCodes(stdout); -} - -fn characterAsciiCodes(writer: anytype) !void { - try writer.writeAll("Sample ASCII characters and codes:\n"); +test "character codes" { + debug.warn("\n", .{}); // Zig's string is just an array of bytes (u8). - const message: []const u8 = "ABCabc"; + const message = "ABCabc"; for (message) |val| { - try writer.print(" '{c}' code: {d} [hexa: 0x{x}]\n", .{ val, val, val }); + debug.warn(" '{c}' code: {} [hexa: 0x{x}]\n", .{ val, val, val }); } - try writer.writeByte('\n'); } -fn characterUnicodeCodes(writer: anytype) !void { - try writer.writeAll("Sample Unicode characters and codes:\n"); +test "character (uni)codes" { + debug.warn("\n", .{}); - const message: []const u8 = "あいうえお"; + const message = "あいうえお"; const utf8_view = unicode.Utf8View.initUnchecked(message); var iter = utf8_view.iterator(); while (iter.nextCodepoint()) |val| { var array: [4]u8 = undefined; - const slice = array[0..try unicode.utf8Encode(val, &array)]; + var slice = array[0..try unicode.utf8Encode(val, &array)]; - try writer.print(" '{s}' code: {d} [hexa: U+{x}]\n", .{ slice, val, val }); + debug.warn(" '{}' code: {} [hexa: U+{x}]\n", .{ slice, val, val }); } - try writer.writeByte('\n'); } diff --git a/Task/Chat-server/Ada/chat-server.adb b/Task/Chat-server/Ada/chat-server.ada similarity index 100% rename from Task/Chat-server/Ada/chat-server.adb rename to Task/Chat-server/Ada/chat-server.ada diff --git a/Task/Chat-server/FreeBASIC/chat-server.basic b/Task/Chat-server/FreeBASIC/chat-server.basic deleted file mode 100644 index 4070f9e3cd..0000000000 --- a/Task/Chat-server/FreeBASIC/chat-server.basic +++ /dev/null @@ -1,122 +0,0 @@ -#include once "windows.bi" -#include once "win/winsock2.bi" - -Type SOCKET As Ulongint -Type ThreadCallback As Sub(Byval As Any Ptr) - -Const MAX_CLIENTS = 10 -Const CRLF = Chr(13) & Chr(10) -Const BUFFER_SIZE = 256 - -Dim Shared clients(MAX_CLIENTS) As SOCKET -Dim Shared nicknames(MAX_CLIENTS) As String -Dim Shared clientCount As Integer = 0 - -' Initialize Winsock -Dim As WSADATA wsaData -If WSAStartup(&h0202, @wsaData) Then - Print "Error initializing Winsock" - End 1 -End If - -' Create server socket -Dim As SOCKET serverSocket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0) -If serverSocket = INVALID_SOCKET Then - Print "Error creating socket" - WSACleanup() - End 1 -End If - -' Configure server address -Dim As sockaddr_in serverAddr -With serverAddr - .sin_family = AF_INET - .sin_addr.s_addr = INADDR_ANY - .sin_port = htons(8080) -End With - -' Bind socket -If bind(serverSocket, Cast(sockaddr Ptr, @serverAddr), Sizeof(sockaddr_in)) = SOCKET_ERROR Then - Print "Error binding socket" - closesocket(serverSocket) - WSACleanup() - End 1 -End If - -' Listen for incoming connections -If listen(serverSocket, SOMAXCONN) = SOCKET_ERROR Then - Print "Error listening on socket" - closesocket(serverSocket) - WSACleanup() - End 1 -End If - -Print "Chat server is running on port 8080" - -Sub broadcastMessage(message As String) - Dim As String fullMsg = message - For i As Integer = 0 To clientCount - 1 - If clients(i) <> 0 Then - send(clients(i), Strptr(fullMsg), Len(fullMsg), 0) - End If - Next i -End Sub - -Sub handleClient(Byval param As Any Ptr) - Dim As Integer clientIndex = Cast(Integer, param) - Dim As SOCKET clientSocket = clients(clientIndex) - Dim As String nickname - Dim As ZString * BUFFER_SIZE buffer - Dim As Long bytesReceived - - ' Get nickname - Dim As String welcomeMsg = "Enter your nickname: " - send(clientSocket, Strptr(welcomeMsg), Len(welcomeMsg), 0) - bytesReceived = recv(clientSocket, @buffer, BUFFER_SIZE-1, 0) - If bytesReceived > 0 Then - nickname = Left(buffer, bytesReceived - 2) - nicknames(clientIndex) = nickname - - ' Announce new user - broadcastMessage(nickname & " has joined the chat." & CRLF) - - ' Message loop - Do - bytesReceived = recv(clientSocket, @buffer, BUFFER_SIZE-1, 0) - If bytesReceived <= 0 Then Exit Do - buffer[bytesReceived] = 0 - broadcastMessage(nickname & ": " & *Cast(ZString Ptr, @buffer) & CRLF) - Loop - - ' Announce departure - broadcastMessage(nickname & " has left the chat." & CRLF) - End If - - ' Cleanup - closesocket(clientSocket) - clients(clientIndex) = 0 - nicknames(clientIndex) = "" -End Sub - -' Main server loop -Do - Dim As sockaddr_in clientAddr - Dim As Long clientAddrLen = Sizeof(sockaddr_in) - - Dim As SOCKET clientSocket = accept(serverSocket, Cast(sockaddr Ptr, @clientAddr), @clientAddrLen) - If clientSocket <> INVALID_SOCKET Then - If clientCount < MAX_CLIENTS Then - clients(clientCount) = clientSocket - clientCount += 1 - Threadcreate(Cast(ThreadCallback, @handleClient), Cast(Any Ptr, clientCount - 1)) - Else - Dim As String fullMsg = "Server is full." & CRLF - send(clientSocket, Strptr(fullMsg), Len(fullMsg), 0) - closesocket(clientSocket) - End If - End If -Loop - -' Final cleaning -closesocket(serverSocket) -WSACleanup() diff --git a/Task/Chat-server/Julia/chat-server.jl b/Task/Chat-server/Julia/chat-server.julia similarity index 100% rename from Task/Chat-server/Julia/chat-server.jl rename to Task/Chat-server/Julia/chat-server.julia diff --git a/Task/Chat-server/Kotlin/chat-server.kts b/Task/Chat-server/Kotlin/chat-server.kotlin similarity index 100% rename from Task/Chat-server/Kotlin/chat-server.kts rename to Task/Chat-server/Kotlin/chat-server.kotlin diff --git a/Task/Chat-server/Rust/chat-server.rs b/Task/Chat-server/Rust/chat-server.rust similarity index 100% rename from Task/Chat-server/Rust/chat-server.rs rename to Task/Chat-server/Rust/chat-server.rust diff --git a/Task/Chat-server/Wren/chat-server-1.wren b/Task/Chat-server/Wren/chat-server-1.wren index 0dc19c6b84..c8e43d7b19 100644 --- a/Task/Chat-server/Wren/chat-server-1.wren +++ b/Task/Chat-server/Wren/chat-server-1.wren @@ -1,4 +1,4 @@ -/* Chat_server.wren */ +/* chat_server.wren */ class Clients { foreign static max diff --git a/Task/Chat-server/Wren/chat-server-2.wren b/Task/Chat-server/Wren/chat-server-2.wren index 783eca36b5..8df0f2373b 100644 --- a/Task/Chat-server/Wren/chat-server-2.wren +++ b/Task/Chat-server/Wren/chat-server-2.wren @@ -1,4 +1,4 @@ -/* gcc Chat_server.c -o Chat_server -lpthread -lwren -lm */ +/* gcc chat_server.c -o chat_server -lpthread -lwren -lm */ #include #include @@ -278,7 +278,7 @@ int main(int argc, char **argv) { config.errorFn = &errorFn; config.bindForeignMethodFn = &bindForeignMethod; const char* module = "main"; - const char* fileName = "Chat_server.wren"; + const char* fileName = "chat_server.wren"; script = readFile(fileName); /* config the VMs and interpret the script */ diff --git a/Task/Check-Machin-like-formulas/00-TASK.txt b/Task/Check-Machin-like-formulas/00-TASK.txt index c28978d512..d6db6e1191 100644 --- a/Task/Check-Machin-like-formulas/00-TASK.txt +++ b/Task/Check-Machin-like-formulas/00-TASK.txt @@ -35,7 +35,7 @@ These identities are useful in calculating the values:
You can store the equations in any convenient data structure, but for extra credit parse them from human-readable [[Check_Machin-like_formulas/text_equations|text input]]. -Note: to formally prove the formula correct, it would have to be shown that ''{-3 \pi \over 4} < right hand side < {5 \pi \over 4}'' due to ''\tan()'' periodicity. +Note: to formally prove the formula correct, it would have to be shown that ''{-3 pi \over 4} < right hand side < {5 pi \over 4}'' due to ''\tan()'' periodicity.

diff --git a/Task/Check-Machin-like-formulas/Julia/check-machin-like-formulas.jl b/Task/Check-Machin-like-formulas/Julia/check-machin-like-formulas.julia similarity index 100% rename from Task/Check-Machin-like-formulas/Julia/check-machin-like-formulas.jl rename to Task/Check-Machin-like-formulas/Julia/check-machin-like-formulas.julia diff --git a/Task/Check-Machin-like-formulas/Kotlin/check-machin-like-formulas.kts b/Task/Check-Machin-like-formulas/Kotlin/check-machin-like-formulas.kotlin similarity index 100% rename from Task/Check-Machin-like-formulas/Kotlin/check-machin-like-formulas.kts rename to Task/Check-Machin-like-formulas/Kotlin/check-machin-like-formulas.kotlin diff --git a/Task/Check-Machin-like-formulas/OCaml/check-machin-like-formulas.ml b/Task/Check-Machin-like-formulas/OCaml/check-machin-like-formulas.ocaml similarity index 100% rename from Task/Check-Machin-like-formulas/OCaml/check-machin-like-formulas.ml rename to Task/Check-Machin-like-formulas/OCaml/check-machin-like-formulas.ocaml diff --git a/Task/Check-Machin-like-formulas/Wren/check-machin-like-formulas.wren b/Task/Check-Machin-like-formulas/Wren/check-machin-like-formulas.wren index 444ac4e66a..1384ed0ff1 100644 --- a/Task/Check-Machin-like-formulas/Wren/check-machin-like-formulas.wren +++ b/Task/Check-Machin-like-formulas/Wren/check-machin-like-formulas.wren @@ -1,5 +1,5 @@ -import "./big" for BigRat -import "./fmt" for Fmt +import "/big" for BigRat +import "/fmt" for Fmt /** represents a term of the form: c * atan(n / d) */ class Term { diff --git a/Task/Check-input-device-is-a-terminal/Ada/check-input-device-is-a-terminal.adb b/Task/Check-input-device-is-a-terminal/Ada/check-input-device-is-a-terminal.ada similarity index 100% rename from Task/Check-input-device-is-a-terminal/Ada/check-input-device-is-a-terminal.adb rename to Task/Check-input-device-is-a-terminal/Ada/check-input-device-is-a-terminal.ada diff --git a/Task/Check-input-device-is-a-terminal/Batch-File/check-input-device-is-a-terminal.bat b/Task/Check-input-device-is-a-terminal/Batch-File/check-input-device-is-a-terminal.bat deleted file mode 100644 index 8fcd2d94e2..0000000000 --- a/Task/Check-input-device-is-a-terminal/Batch-File/check-input-device-is-a-terminal.bat +++ /dev/null @@ -1 +0,0 @@ -(timeout /t 0 >nul 2>nul && echo Stdin is a terminal || echo Stdin is not a terminal) b.out will write to b.out, and this contains unit 5 is a terminal but unit 6 ism't -! ./checktty < a.out >b.out will write to b.out, and both units 5 and 6 are not terminals. -! -! Check units 1...10 if they are connected to a terminal. -do unit=1,10 - if (isatty (unit)) then - write (*, '("Unit ", i2, " is a Terminal")') unit - else - write (*, '("Unit ", i2, " is NOT a Terminal")') unit - endif -enddo - -end program checkTTY diff --git a/Task/Check-input-device-is-a-terminal/Janet/check-input-device-is-a-terminal.janet b/Task/Check-input-device-is-a-terminal/Janet/check-input-device-is-a-terminal.janet deleted file mode 100644 index f0fb90c650..0000000000 --- a/Task/Check-input-device-is-a-terminal/Janet/check-input-device-is-a-terminal.janet +++ /dev/null @@ -1,3 +0,0 @@ -(if (os/isatty stdin) - (print "The input device is a terminal.") - (print "The input device is not a terminal.")) diff --git a/Task/Check-input-device-is-a-terminal/Julia/check-input-device-is-a-terminal.jl b/Task/Check-input-device-is-a-terminal/Julia/check-input-device-is-a-terminal.julia similarity index 100% rename from Task/Check-input-device-is-a-terminal/Julia/check-input-device-is-a-terminal.jl rename to Task/Check-input-device-is-a-terminal/Julia/check-input-device-is-a-terminal.julia diff --git a/Task/Check-input-device-is-a-terminal/Kotlin/check-input-device-is-a-terminal.kts b/Task/Check-input-device-is-a-terminal/Kotlin/check-input-device-is-a-terminal.kotlin similarity index 100% rename from Task/Check-input-device-is-a-terminal/Kotlin/check-input-device-is-a-terminal.kts rename to Task/Check-input-device-is-a-terminal/Kotlin/check-input-device-is-a-terminal.kotlin diff --git a/Task/Check-input-device-is-a-terminal/Lua/check-input-device-is-a-terminal.lua b/Task/Check-input-device-is-a-terminal/Lua/check-input-device-is-a-terminal.lua deleted file mode 100644 index 53aa2d1991..0000000000 --- a/Task/Check-input-device-is-a-terminal/Lua/check-input-device-is-a-terminal.lua +++ /dev/null @@ -1,6 +0,0 @@ -local posix = require"posix" -print( - posix.unistd.isatty(posix.stdio.fileno(io.stdin)) - and "stdin is a terminal" - or "stdin is not a terminal" -) diff --git a/Task/Check-input-device-is-a-terminal/Nu/check-input-device-is-a-terminal.nu b/Task/Check-input-device-is-a-terminal/Nu/check-input-device-is-a-terminal.nu deleted file mode 100644 index 0a1e81828c..0000000000 --- a/Task/Check-input-device-is-a-terminal/Nu/check-input-device-is-a-terminal.nu +++ /dev/null @@ -1 +0,0 @@ -$'stdin is a terminal: (is-terminal -i)' diff --git a/Task/Check-input-device-is-a-terminal/OCaml/check-input-device-is-a-terminal.ml b/Task/Check-input-device-is-a-terminal/OCaml/check-input-device-is-a-terminal.ocaml similarity index 100% rename from Task/Check-input-device-is-a-terminal/OCaml/check-input-device-is-a-terminal.ml rename to Task/Check-input-device-is-a-terminal/OCaml/check-input-device-is-a-terminal.ocaml diff --git a/Task/Check-input-device-is-a-terminal/PascalABC.NET/check-input-device-is-a-terminal.pas b/Task/Check-input-device-is-a-terminal/PascalABC.NET/check-input-device-is-a-terminal.pas deleted file mode 100644 index 0c5e7e3fdb..0000000000 --- a/Task/Check-input-device-is-a-terminal/PascalABC.NET/check-input-device-is-a-terminal.pas +++ /dev/null @@ -1,3 +0,0 @@ -## -uses system; -system.Console.IsInputRedirected.println; diff --git a/Task/Check-input-device-is-a-terminal/Phix/check-input-device-is-a-terminal.phix b/Task/Check-input-device-is-a-terminal/Phix/check-input-device-is-a-terminal.phix index 8f2a7843e3..a8e739efdc 100644 --- a/Task/Check-input-device-is-a-terminal/Phix/check-input-device-is-a-terminal.phix +++ b/Task/Check-input-device-is-a-terminal/Phix/check-input-device-is-a-terminal.phix @@ -1,2 +1,4 @@ -without js -- (no input redirection in a browser!) -printf(1,"stdin:%t, stdout:%t, stderr:%t\n",{isatty(0),isatty(1),isatty(2)}) +(notonline)--> + without js -- (no input redirection in a browser!) + printf(1,"stdin:%t, stdout:%t, stderr:%t\n",{isatty(0),isatty(1),isatty(2)}) + + without js -- (no input or output redirection in a browser!) + printf(1,"stdin:%t, stdout:%t, stderr:%t\n",{isatty(0),isatty(1),isatty(2)}) + + without js -- (file i/o) + procedure check(string name) + bool bExists = file_exists(name), + bDir = get_file_type(name)=FILETYPE_DIRECTORY + string exists = iff(bExists?"exists":"does not exist"), + dfs = iff(bExists?iff(bDir?"directory ":"file "):"") + printf(1,"%s%s %s.\n",{dfs,name,exists}) + end procedure -check("input.txt") -check("docs") -check("/input.txt") -check("/docs") -check("/pagefile.sys") -check("/Program Files (x86)") + check("input.txt") + check("docs") + check("/input.txt") + check("/docs") + check("/pagefile.sys") + check("/Program Files (x86)") + + with javascript_semantics + function chernick_carmichael_factors(integer n, m) + sequence res = {6*m + 1, 12*m + 1} + for i=1 to n-2 do + res &= power(2,i) * 9*m + 1 + end for + return res + end function + + include mpfr.e + mpz p = mpz_init() + + function m_prime(atom a) + mpz_set_d(p,a) + return mpz_prime(p) + end function + + function is_chernick_carmichael(integer n, m) + return iff(n==2 ? m_prime(6*m + 1) and m_prime(12*m + 1) + : m_prime(power(2,n-2) * 9*m + 1) and + is_chernick_carmichael(n-1, m)) + end function + + function chernick_carmichael_number(integer n) + integer m = iff(n>4 ? power(2,n-4) : 1), mm = m + while not is_chernick_carmichael(n, mm) do mm += m end while + return {chernick_carmichael_factors(n, mm),mm} + end function + + for n=3 to 9 do + {sequence f, integer m} = chernick_carmichael_number(n) + mpz_set_si(p,1) + for i=1 to length(f) do + mpz_mul_d(p,p,f[i]) + f[i] = sprintf("%d",f[i]) + end for + printf(1,"U(%d,%d): %s = %s\n",{n,m,mpz_get_str(p),join(f," * ")}) + end for + + with javascript_semantics + include mpfr.e + sequence ppp = {3,5,7,11,13,17,19,23} + function primality_pretest(atom k) + for i=1 to length(ppp) do + if remainder(k,ppp[i])=0 then return (k<=23) end if + end for + return true + end function + + function probprime(atom k, mpz n) + mpz_set_d(n, k) + return mpz_prime(n) + end function + + function is_chernick(integer n, atom m, mpz z) + atom t = 9 * m; + if primality_pretest(6 * m + 1) == false then return false end if + if primality_pretest(12 * m + 1) == false then return false end if + for i=1 to n-3 do + if primality_pretest(t*power(2,i) + 1) == false then return false end if + end for + if probprime(6 * m + 1, z) == false then return false end if + if probprime(12 * m + 1, z) == false then return false end if + for i=1 to n-2 do + if probprime(t*power(2,i) + 1, z) == false then return false end if + end for + return true + end function + + procedure main() + atom t0 = time() + mpz z = mpz_init(0) + + for n=3 to 10 do + atom multiplier = iff(n>4 ? power(2,n-4) : 1), k = 1 + if n>5 then multiplier *= 5 end if + + while true do + if n=10 then k += 12564168 end if -- cheat! + atom m = k * multiplier; + if is_chernick(n, m, z) then + printf(1,"a(%d) has m = %d\n", {n, m}) + exit + end if + k += 1 + end while + end for + ?elapsed(time()-t0) + end procedure + main() + + -- demo\rosetta\Cheryls_Birthday.exw + with javascript_semantics + sequence choices = {{5, 15}, {5, 16}, {5, 19}, {6, 17}, {6, 18}, + {7, 14}, {7, 16}, {8, 14}, {8, 15}, {8, 17}} -sequence mwud = repeat(false,12) -- months with unique days + sequence mwud = repeat(false,12) -- months with unique days -for step=1 to 4 do - sequence {months,days} = columnize(choices) - bool impossible = false - for i=length(choices) to 1 by -1 do - integer {m,d} = choices[i] - switch step do - case 1: mwud[m] += (sum(sq_eq(days,d))=1) - case 2: impossible = mwud[m] - case 3: impossible = (sum(sq_eq(days,d))!=1) - case 4: impossible = (sum(sq_eq(months,m))!=1) - end switch - if impossible then - choices[i..i] = {} - end if - end for -end for -?choices + for step=1 to 4 do + sequence {months,days} = columnize(choices) + bool impossible = false + for i=length(choices) to 1 by -1 do + integer {m,d} = choices[i] + switch step do + case 1: mwud[m] += (sum(sq_eq(days,d))=1) + case 2: impossible = mwud[m] + case 3: impossible = (sum(sq_eq(days,d))!=1) + case 4: impossible = (sum(sq_eq(months,m))!=1) + end switch + if impossible then + choices[i..i] = {} + end if + end for + end for + ?choices + + with javascript_semantics + enum MONTH, DAY -function unique_month(sequence si, months) - return sum(sq_eq(months,si[MONTH]))=1 -end function + function unique_month(sequence si, months) + return sum(sq_eq(months,si[MONTH]))=1 + end function -function unique_day(sequence si, days) - return sum(sq_eq(days,si[DAY]))=1 -end function + function unique_day(sequence si, days) + return sum(sq_eq(days,si[DAY]))=1 + end function -function month_without_unique_day(sequence si, months_with_unique_day) - return not find(si[MONTH],months_with_unique_day) -end function + function month_without_unique_day(sequence si, months_with_unique_day) + return not find(si[MONTH],months_with_unique_day) + end function -sequence choices = {{5, 15}, {5, 16}, {5, 19}, {6, 17}, {6, 18}, - {7, 14}, {7, 16}, {8, 14}, {8, 15}, {8, 17}} + sequence choices = {{5, 15}, {5, 16}, {5, 19}, {6, 17}, {6, 18}, + {7, 14}, {7, 16}, {8, 14}, {8, 15}, {8, 17}} --- Albert knows the month but does not know the day. --- So the month cannot be unique within the choices. --- However this step would change nothing, hence omit it. --- (obvs. non_unique_month() would be as above, but !=1) ---choices = filter(choices,non_unique_month,vslice(choices,MONTH)) + -- Albert knows the month but does not know the day. + -- So the month cannot be unique within the choices. + -- However this step would change nothing, hence omit it. + -- (obvs. non_unique_month() would be as above, but !=1) + --choices = filter(choices,non_unique_month,vslice(choices,MONTH)) --- Albert also knows that Bernard doesn't know the answer. --- So the month cannot have a unique day. -sequence unique_days = filter(choices,unique_day,vslice(choices,DAY)) -sequence months_with_unique_day = unique(vslice(unique_days,MONTH)) + -- Albert also knows that Bernard doesn't know the answer. + -- So the month cannot have a unique day. + sequence unique_days = filter(choices,unique_day,vslice(choices,DAY)) + sequence months_with_unique_day = unique(vslice(unique_days,MONTH)) -choices = filter(choices,month_without_unique_day,months_with_unique_day) + choices = filter(choices,month_without_unique_day,months_with_unique_day) --- Bernard now knows the answer. --- So the day must be unique within the remaining choices. -choices = filter(choices,unique_day,vslice(choices,DAY)) + -- Bernard now knows the answer. + -- So the day must be unique within the remaining choices. + choices = filter(choices,unique_day,vslice(choices,DAY)) --- Albert now knows the answer too. --- So the month must be unique within the remaining choices. -choices = filter(choices,unique_month,vslice(choices,MONTH)) + -- Albert now knows the answer too. + -- So the month must be unique within the remaining choices. + choices = filter(choices,unique_month,vslice(choices,MONTH)) -if length(choices)!=1 then crash("Something went wrong!") end if + if length(choices)!=1 then crash("Something went wrong!") end if -include builtins\timedate.e -timedate td = repeat(0,6) -{td[DT_MONTH],td[DT_DAY]} = choices[1] -printf(1,"Cheryl's birthday is %s\n", {format_timedate(td,"Mmmm ddth")}) + include builtins\timedate.e + timedate td = repeat(0,6) + {td[DT_MONTH],td[DT_DAY]} = choices[1] + printf(1,"Cheryl's birthday is %s\n", {format_timedate(td,"Mmmm ddth")}) + + with javascript_semantics + constant animals = {"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"}, + elements = {"Wood","Fire","Earth","Metal","Water"}, + yinyang = {"yang","yin"}, + years = {1935,1938,1968,1972,1976,2018} -for i=1 to length(years) do - integer year = years[i], - cycle = mod(year-4,60) - string element = elements[floor(mod(cycle,10)/2)+1], - animal = animals[mod(cycle,12)+1], - yy = yinyang[mod(cycle,2)+1] - printf(1,"%d: %s %s; %s, year %d of the cycle.\n", - {year,element,animal,yy,cycle+1}) -end for + for i=1 to length(years) do + integer year = years[i], + cycle = mod(year-4,60) + string element = elements[floor(mod(cycle,10)/2)+1], + animal = animals[mod(cycle,12)+1], + yy = yinyang[mod(cycle,2)+1] + printf(1,"%d: %s %s; %s, year %d of the cycle.\n", + {year,element,animal,yy,cycle+1}) + end for + ) - - ' [ 1935 1938 1968 1972 1976 1984 1985 2017 ] - witheach zodiac diff --git a/Task/Chinese-zodiac/R/chinese-zodiac.r b/Task/Chinese-zodiac/R/chinese-zodiac.r deleted file mode 100644 index 685d89597f..0000000000 --- a/Task/Chinese-zodiac/R/chinese-zodiac.r +++ /dev/null @@ -1,16 +0,0 @@ -animals <- c("Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", - "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig") -elements <- c("Wood", "Fire", "Earth", "Metal", "Water") - -get_element <- function(year) elements[1+((year-4)%%10)%/%2] - -get_animal <- function(year) animals[1+(year-4)%%12] - -get_yinyang <- function(year) ifelse(year%%2==0, "yang", "yin") - -years <- c(1935, 1938, 1968, 1972, 1976, 2017) - -writeLines(paste0(years, " is the year of the ", - get_element(years), " ", - get_animal(years), - " (", get_yinyang(years), ").")) diff --git a/Task/Chinese-zodiac/Rebol/chinese-zodiac.rebol b/Task/Chinese-zodiac/Rebol/chinese-zodiac.rebol deleted file mode 100644 index 0aef0d857e..0000000000 --- a/Task/Chinese-zodiac/Rebol/chinese-zodiac.rebol +++ /dev/null @@ -1,55 +0,0 @@ -Rebol [ - title: "Rosetta code: Chinese zodiac" - file: %Chinese_zodiac.r3 - url: https://rosettacode.org/wiki/Chinese_zodiac - note: "Translated from Julia" -] - -chinese: function/with [year [integer!]] [ - cycleyear: year - base - - stemnumber: 1 + cycleyear % 10 - stemhan: celestial/:stemnumber - stempinyin: pinyin/:stemhan - - elementnumber: 1 + stemnumber / 2 - element: elements/:elementnumber - - branchnumber: 1 + cycleyear % 12 - branchhan: terrestrial/:branchnumber - branchpinyin: pinyin/:branchhan - animal: animals/:branchnumber - - aspectnumber: 1 + cycleyear % 2 - aspect: aspects/:aspectnumber - - index: 1 + cycleyear % 60 - - rejoin [ - year ": " stemhan branchhan - " (" stempinyin "-" branchpinyin ", " - element " " animal "; " - aspect " - year " index " of the cycle)" - ] -][ - pinyin: make map! [ - "甲" "jiă" "乙" "yĭ" "丙" "bĭng" "丁" "dīng" - "戊" "wù" "己" "jĭ" "庚" "gēng" "辛" "xīn" - "壬" "rén" "癸" "gŭi" "子" "zĭ" "丑" "chŏu" - "寅" "yín" "卯" "măo" "辰" "chén" "巳" "sì" - "午" "wŭ" "未" "wèi" "申" "shēn" "酉" "yŏu" - "戌" "xū" "亥" "hài" - ] - - elements: ["Wood" "Fire" "Earth" "Metal" "Water"] - animals: ["Rat" "Ox" "Tiger" "Rabbit" "Dragon" "Snake" - "Horse" "Goat" "Monkey" "Rooster" "Dog" "Pig"] - celestial: ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"] - terrestrial: ["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"] - aspects: ["yang" "yin"] - base: 4 -] - -foreach year reduce [1935 1938 1968 1972 1976 now/year][ - print chinese year -] diff --git a/Task/Chinese-zodiac/Rust/chinese-zodiac.rs b/Task/Chinese-zodiac/Rust/chinese-zodiac.rust similarity index 100% rename from Task/Chinese-zodiac/Rust/chinese-zodiac.rs rename to Task/Chinese-zodiac/Rust/chinese-zodiac.rust diff --git a/Task/Chinese-zodiac/Tbas/chinese-zodiac.tbas b/Task/Chinese-zodiac/Tbas/chinese-zodiac.tbas index f4dd93a3bb..57d1da8b6c 100644 --- a/Task/Chinese-zodiac/Tbas/chinese-zodiac.tbas +++ b/Task/Chinese-zodiac/Tbas/chinese-zodiac.tbas @@ -1,70 +1,70 @@ - DATA "甲","乙","丙","丁","戊","己","庚","辛","壬","癸" - DECLARE celestial$(10) - MAT READ celestial$ - - DATA "子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥" - DECLARE terrestrial$(12) - MAT READ terrestrial$ - - DATA "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" - DECLARE animals$(12) - MAT READ animals$ + DATA "甲","乙","丙","丁","戊","己","庚","辛","壬","癸" + DECLARE celestial$(10) + MAT READ celestial$ + + DATA "子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥" + DECLARE terrestrial$(12) + MAT READ terrestrial$ + + DATA "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" + DECLARE animals$(12) + MAT READ animals$ DATA "Wood","Fire","Earth","Metal","Water" - DECLARE elements$(5) - MAT READ elements$ + DECLARE elements$(5) + MAT READ elements$ - DATA "yang","yin" - DECLARE aspects$(2) - MAT READ aspects$ - - DATA "jiă","yĭ","bĭng","dīng","wù","jĭ","gēng","xīn","rén","gŭi" - DATA "zĭ","chŏu","yín","măo","chén","sì","wŭ","wèi","shēn","yŏu","xū","hài" - DECLARE celestialpinyin$(UBOUND(celestial$(),1)) - DECLARE terrestrialpinyin$(UBOUND(terrestrial$(),1)) - MAT READ celestialpinyin$ - MAT READ terrestrialpinyin$ - - DATA 1935,1938,1931,1961,1963,1991,1993,1996,2001 - DECLARE years(9) - MAT READ years - - DECLARE _base = 4 - DECLARE _year - DECLARE cycleyear - DECLARE stemnumber - DECLARE stemhan$ - DECLARE stempinyin$ - DECLARE elementnumber - DECLARE element$ - DECLARE branchnumber - DECLARE branchhan$ - DECLARE branchpinyin$ - DECLARE animal$ - DECLARE aspectnumber - DECLARE aspect$ - DECLARE index - - DECLARE i - DECLARE top = ubound(years(),1) - FOR i = 1 TO top - _year = years(i) - cycleyear = _year - _base - stemnumber = MOD(cycleyear, 10) - stemhan$ = celestial$(stemnumber + 1) - stempinyin$ = celestialpinyin$(stemnumber + 1) - elementnumber = div(stemnumber, 2) + 1 - element$ = elements$(elementnumber) - branchnumber = MOD(cycleyear, 12) - branchhan$ = terrestrial$(branchnumber + 1) - branchpinyin$ = terrestrialpinyin$(branchnumber + 1) - animal$ = animals$(branchnumber + 1) - aspectnumber = MOD(cycleyear, 2) - aspect$ = aspects$(aspectnumber + 1) - index = MOD(cycleyear, 60) + 1 - PRINT _year; - PRINT TAB(5);stemhan$+branchhan$; - PRINT TAB(12);stempinyin$;"-";branchpinyin$; - PRINT TAB(25);element$;" ";animal$;" ("+aspect$+")"; - PRINT TAB(50);"year";index;"of the cycle" - NEXT + DATA "yang","yin" + DECLARE aspects$(2) + MAT READ aspects$ + + DATA "jiă","yĭ","bĭng","dīng","wù","jĭ","gēng","xīn","rén","gŭi" + DATA "zĭ","chŏu","yín","măo","chén","sì","wŭ","wèi","shēn","yŏu","xū","hài" + DECLARE celestialpinyin$(UBOUND(celestial$(),1)) + DECLARE terrestrialpinyin$(UBOUND(terrestrial$(),1)) + MAT READ celestialpinyin$ + MAT READ terrestrialpinyin$ + + DATA 1935,1938,1931,1961,1963,1991,1993,1996,2001 + DECLARE years(9) + MAT READ years + + DECLARE _base = 4 + DECLARE _year + DECLARE cycleyear + DECLARE stemnumber + DECLARE stemhan$ + DECLARE stempinyin$ + DECLARE elementnumber + DECLARE element$ + DECLARE branchnumber + DECLARE branchhan$ + DECLARE branchpinyin$ + DECLARE animal$ + DECLARE aspectnumber + DECLARE aspect$ + DECLARE index + + DECLARE i + DECLARE top = ubound(years(),1) + FOR i = 1 TO top + _year = years(i) + cycleyear = _year - _base + stemnumber = MOD(cycleyear, 10) + stemhan$ = celestial$(stemnumber + 1) + stempinyin$ = celestialpinyin$(stemnumber + 1) + elementnumber = div(stemnumber, 2) + 1 + element$ = elements$(elementnumber) + branchnumber = MOD(cycleyear, 12) + branchhan$ = terrestrial$(branchnumber + 1) + branchpinyin$ = terrestrialpinyin$(branchnumber + 1) + animal$ = animals$(branchnumber + 1) + aspectnumber = MOD(cycleyear, 2) + aspect$ = aspects$(aspectnumber + 1) + index = MOD(cycleyear, 60) + 1 + PRINT _year; + PRINT TAB(5);stemhan$+branchhan$; + PRINT TAB(12);stempinyin$;"-";branchpinyin$; + PRINT TAB(25);element$;" ";animal$;" ("+aspect$+")"; + PRINT TAB(50);"year";index;"of the cycle" + NEXT diff --git a/Task/Chinese-zodiac/VBScript/chinese-zodiac.vb b/Task/Chinese-zodiac/VBScript/chinese-zodiac.vb new file mode 100644 index 0000000000..cf4c24c8e0 --- /dev/null +++ b/Task/Chinese-zodiac/VBScript/chinese-zodiac.vb @@ -0,0 +1,16 @@ +' Chinese zodiac - VBS + +Animals = array( "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" ) +Elements = array( "Wood","Fire","Earth","Metal","Water" ) +YinYang = array( "Yang","Yin" ) +Years = array( 1935, 1938, 1968, 1972, 1976, 1984, 2017 ) + +for i = LBound(Years) to UBound(Years) + xYear = Years(i) + yElement = Elements(((xYear - 4) mod 10) \ 2) + yAnimal = Animals( (xYear - 4) mod 12 ) + yYinYang = YinYang( xYear mod 2 ) + nn = ((xYear - 4) mod 60) + 1 + msgbox xYear & " is the year of the " & yElement & " " & yAnimal & " (" & yYinYang & ").",, _ + xYear & " : " & nn & "/60" +next diff --git a/Task/Chinese-zodiac/VBScript/chinese-zodiac.vbs b/Task/Chinese-zodiac/VBScript/chinese-zodiac.vbs deleted file mode 100644 index 2691f02178..0000000000 --- a/Task/Chinese-zodiac/VBScript/chinese-zodiac.vbs +++ /dev/null @@ -1,16 +0,0 @@ -' Chinese zodiac - VBS - -Animals = array( "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" ) -Elements = array( "Wood","Fire","Earth","Metal","Water" ) -YinYang = array( "Yang","Yin" ) -Years = array( 1935, 1938, 1968, 1972, 1976, 1984, 2017 ) - -for i = LBound(Years) to UBound(Years) - xYear = Years(i) - yElement = Elements(((xYear - 4) mod 10) \ 2) - yAnimal = Animals( (xYear - 4) mod 12 ) - yYinYang = YinYang( xYear mod 2 ) - nn = ((xYear - 4) mod 60) + 1 - msgbox xYear & " is the year of the " & yElement & " " & yAnimal & " (" & yYinYang & ").",, _ - xYear & " : " & nn & "/60" -next diff --git a/Task/Chinese-zodiac/Wren/chinese-zodiac.wren b/Task/Chinese-zodiac/Wren/chinese-zodiac.wren index 086a55ddc5..098a0cf6f5 100644 --- a/Task/Chinese-zodiac/Wren/chinese-zodiac.wren +++ b/Task/Chinese-zodiac/Wren/chinese-zodiac.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt class ChineseZodiac { static init() { diff --git a/Task/Chinese-zodiac/Yabasic/chinese-zodiac.basic b/Task/Chinese-zodiac/Yabasic/chinese-zodiac.basic index 8b74729638..37870724f1 100644 --- a/Task/Chinese-zodiac/Yabasic/chinese-zodiac.basic +++ b/Task/Chinese-zodiac/Yabasic/chinese-zodiac.basic @@ -4,12 +4,12 @@ dim YinYang$(2) : for a = 0 to 1 : read YinYang$(a) : next a dim Years(7) : for a = 0 to 6 : read Years(a) : next a for i = 0 to arraysize(Years(),1)-1 - xYear = Years(i) - yElement$ = Elements$((Mod((xYear - 4), 10)) / 2) - yAnimal$ = Animals$( Mod((xYear - 4), 12)) - yYinYang$ = YinYang$( Mod(xYear, 2) ) - nn = ( Mod((xYear - 4), 60)) + 1 - print xYear, " is the year of the ", yElement$, " ", yAnimal$, " (", yYinYang$, ")." + xYear = Years(i) + yElement$ = Elements$((Mod((xYear - 4), 10)) / 2) + yAnimal$ = Animals$( Mod((xYear - 4), 12)) + yYinYang$ = YinYang$( Mod(xYear, 2) ) + nn = ( Mod((xYear - 4), 60)) + 1 + print xYear, " is the year of the ", yElement$, " ", yAnimal$, " (", yYinYang$, ")." next i print end diff --git a/Task/Chinese-zodiac/Zkl/chinese-zodiac-1.zkl b/Task/Chinese-zodiac/Zkl/chinese-zodiac-1.zkl index af739982e9..a4d9df40a8 100644 --- a/Task/Chinese-zodiac/Zkl/chinese-zodiac-1.zkl +++ b/Task/Chinese-zodiac/Zkl/chinese-zodiac-1.zkl @@ -1,4 +1,4 @@ -fcn ceToChineseZodiac(ce_year){ // --> list of strings +fcn ceToChineseZodiac(ce_year){ // --> list of strings # encoding: utf-8 var [const] pinyin=SD( // create some static variables, SD is small fixed dictionary "甲","jiă", "乙","yĭ", "丙","bĭng", "丁","dīng", "戊","wù", "己","jĭ", @@ -11,7 +11,7 @@ fcn ceToChineseZodiac(ce_year){ // --> list of strings celestial =T("甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"), terrestrial=T("子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"), animals =T("Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", - "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"), + "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"), elements =T("Wood", "Fire", "Earth", "Metal", "Water"), aspects =T("yang","yin"), ; @@ -28,5 +28,5 @@ fcn ceToChineseZodiac(ce_year){ // --> list of strings branch_han,branch_pinyin := terrestrial[branch_number], pinyin[branch_han]; return(stem_han,branch_han, - stem_pinyin,branch_pinyin, element,animal,aspect) + stem_pinyin,branch_pinyin, element,animal,aspect) } diff --git a/Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.adb b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.ada similarity index 100% rename from Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.adb rename to Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.ada diff --git a/Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.adb b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.ada similarity index 100% rename from Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.adb rename to Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.ada diff --git a/Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.adb b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.ada similarity index 100% rename from Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.adb rename to Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.ada diff --git a/Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy b/Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy deleted file mode 100644 index f06a3216a5..0000000000 --- a/Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy +++ /dev/null @@ -1,19 +0,0 @@ -func[][] cholesky a[][] . - n = len a[][] - len r[][] n - for i to n - len r[i][] n - for j to i - s = 0 - for k to j : s += r[i][k] * r[j][k] - if i = j - r[i][j] = sqrt (a[i][i] - s) - else - r[i][j] = 1 / r[j][j] * (a[i][j] - s) - . - . - . - return r[][] -. -print cholesky [ [ 25 15 -5 ] [ 15 18 0 ] [ -5 0 11 ] ] -print cholesky [ [ 18 22 54 42 ] [ 22 70 86 62 ] [ 54 86 174 134 ] [ 42 62 134 106 ] ] diff --git a/Task/Cholesky-decomposition/Excel/cholesky-decomposition.excel b/Task/Cholesky-decomposition/Excel/cholesky-decomposition.excel deleted file mode 100644 index 1586be05f1..0000000000 --- a/Task/Cholesky-decomposition/Excel/cholesky-decomposition.excel +++ /dev/null @@ -1,38 +0,0 @@ -=LAMBDA(A, - LET( - r, ROWS(A), - sqa, SQRT(INDEX(A,1,1)), - IF( - r=1, - sqa, - REDUCE( - VSTACK(sqa, DROP(TAKE(A,,1),1)/sqa), - SEQUENCE(r-1,,2), - LAMBDA(s, t, - LET( - diag, SQRT(INDEX(A,t,t) - SUMSQ(INDEX(s,t))), - HSTACK( - s, - VSTACK( - EXPAND(0,t-1,1,0), - IF( - t=r, - diag, - REDUCE( - diag, - SEQUENCE(r-t,1,t+1), - LAMBDA(x,y, - VSTACK( - x, - (INDEX(A,y,t) - SUM(INDEX(s,t)*INDEX(s,y))) / diag - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) -) diff --git a/Task/Cholesky-decomposition/Julia/cholesky-decomposition.jl b/Task/Cholesky-decomposition/Julia/cholesky-decomposition.julia similarity index 100% rename from Task/Cholesky-decomposition/Julia/cholesky-decomposition.jl rename to Task/Cholesky-decomposition/Julia/cholesky-decomposition.julia diff --git a/Task/Cholesky-decomposition/Kotlin/cholesky-decomposition.kts b/Task/Cholesky-decomposition/Kotlin/cholesky-decomposition.kotlin similarity index 100% rename from Task/Cholesky-decomposition/Kotlin/cholesky-decomposition.kts rename to Task/Cholesky-decomposition/Kotlin/cholesky-decomposition.kotlin diff --git a/Task/Cholesky-decomposition/OCaml/cholesky-decomposition.ml b/Task/Cholesky-decomposition/OCaml/cholesky-decomposition.ocaml similarity index 100% rename from Task/Cholesky-decomposition/OCaml/cholesky-decomposition.ml rename to Task/Cholesky-decomposition/OCaml/cholesky-decomposition.ocaml diff --git a/Task/Cholesky-decomposition/PascalABC.NET/cholesky-decomposition.pas b/Task/Cholesky-decomposition/PascalABC.NET/cholesky-decomposition.pas deleted file mode 100644 index 94dfe940b1..0000000000 --- a/Task/Cholesky-decomposition/PascalABC.NET/cholesky-decomposition.pas +++ /dev/null @@ -1,51 +0,0 @@ -function Cholesky(a: array of real): array of real; -begin - var n := Round(Sqrt(a.Length)); - Result := new real[n * n]; - for var i := 0 to n - 1 do - begin - for var j := 0 to i do - begin - var s := 0.0; - for var k := 0 to j - 1 do - s += Result[i * n + k] * Result[j * n + k]; - if i = j then - Result[i * n + j] := Sqrt(a[i * n + i] - s) - else Result[i * n + j] := 1 / Result[j * n + j] * (a[i * n + j] - s); - end; - end; -end; - -procedure ShowMatrix(a: array of real); -begin - var n := Round(Sqrt(a.Length)); - for var i := 0 to n - 1 do - begin - for var j := 0 to n - 1 do - write(a[i * n + j]:10:5); - PrintLn(''); - end; -end; - -begin - var m1 := new real[9]; - m1 := |25.0, 15.0, -5.0, - 15.0, 18.0, 0.0, - -5.0, 0.0, 11.0 |; - var c1 := Cholesky(m1); - ShowMatrix(m1); - println('=>'); - ShowMatrix(c1); - - PrintLn(''); - - var m2: array of real := - |18.0, 22.0, 54.0, 42.0, - 22.0, 70.0, 86.0, 62.0, - 54.0, 86.0, 174.0, 134.0, - 42.0, 62.0, 134.0, 106.0 |; - var c2 := Cholesky(m2); - Showmatrix(m2); - println('=>'); - ShowMatrix(c2); -end. diff --git a/Task/Cholesky-decomposition/Pluto/cholesky-decomposition.pluto b/Task/Cholesky-decomposition/Pluto/cholesky-decomposition.pluto deleted file mode 100644 index 5a31f92f26..0000000000 --- a/Task/Cholesky-decomposition/Pluto/cholesky-decomposition.pluto +++ /dev/null @@ -1,21 +0,0 @@ -require "matrix" - -local arrays = { - { {25, 15, -5}, - {15, 18, 0}, - {-5, 0, 11} }, - - { {18, 22, 54, 42}, - {22, 70, 86, 62}, - {54, 86, 174, 134}, - {42, 62, 134, 106} } -} - -for arrays as array do - local m = matrix.from(array) - print("Original:") - print(m) - print("\nLower Cholesky factor:") - print(m:cholesky():format("%8.5f")) - print() -end diff --git a/Task/Cholesky-decomposition/PowerShell/cholesky-decomposition.ps1 b/Task/Cholesky-decomposition/PowerShell/cholesky-decomposition.psh similarity index 100% rename from Task/Cholesky-decomposition/PowerShell/cholesky-decomposition.ps1 rename to Task/Cholesky-decomposition/PowerShell/cholesky-decomposition.psh diff --git a/Task/Cholesky-decomposition/Rust/cholesky-decomposition.rs b/Task/Cholesky-decomposition/Rust/cholesky-decomposition.rust similarity index 100% rename from Task/Cholesky-decomposition/Rust/cholesky-decomposition.rs rename to Task/Cholesky-decomposition/Rust/cholesky-decomposition.rust diff --git a/Task/Cholesky-decomposition/Scheme/cholesky-decomposition.scm b/Task/Cholesky-decomposition/Scheme/cholesky-decomposition.scm deleted file mode 100644 index fbe516a678..0000000000 --- a/Task/Cholesky-decomposition/Scheme/cholesky-decomposition.scm +++ /dev/null @@ -1,55 +0,0 @@ -(import srfi/231) - -(define (Cholesky A) - ;; Assumes the domain of A is [0,n)\\times [0,n) - (let ((n (interval-upper-bound (array-domain A) 0)) - (A_ (array-getter A)) - (A! (array-setter A))) - (do ((i 0 (+ i 1))) - ((= i n) A) - (let* ((pivot (sqrt (A_ i i))) - (column/row-domain - ;; both will be one-dimensional - (make-interval (vector (+ i 1)) (vector n))) - (column - ;; the column below the (i,i) entry - (specialized-array-share A - column/row-domain - (lambda (k) (values k i)))) - (row - ;; the row to the right of the (i,i) entry - (specialized-array-share A - column/row-domain - (lambda (k) (values i k)))) - (subarray - ;; the subarray to the right and below the (i,i) entry - (array-extract A (make-interval (vector (+ i 1) (+ i 1)) (vector n n))))) - ;; set diagonal value - (A! pivot i i) - ;; compute multipliers - (array-assign! column (array-map (lambda (x) (/ x pivot)) column)) - ;; zero the rest of the ith row, preserving exactness - (array-assign! row (make-array column/row-domain - ;; a zero with the same exactness as pivot - (lambda (j) (- pivot pivot)))) - ;; subtract the outer product of i'th - ;; row and column from the subarray - (array-assign! subarray - (array-map - - subarray - (array-outer-product * column column))))))) - -(define Example-1 - (list*->array 2 '((25 15 -5) - (15 18 0) - (-5 0 11)))) - -(define Example-2 - (list*->array 2 '((18 22 54 42) - (22 70 86 62) - (54 86 174 134) - (42 62 134 106)))) - -(pretty-print (array->list* (Cholesky Example-1))) -(newline) -(pretty-print (array->list* (Cholesky Example-2))) diff --git a/Task/Cholesky-decomposition/Wren/cholesky-decomposition.wren b/Task/Cholesky-decomposition/Wren/cholesky-decomposition.wren index afd5b0c961..b166ba0f51 100644 --- a/Task/Cholesky-decomposition/Wren/cholesky-decomposition.wren +++ b/Task/Cholesky-decomposition/Wren/cholesky-decomposition.wren @@ -1,5 +1,5 @@ -import "./matrix" for Matrix -import "./fmt" for Fmt +import "/matrix" for Matrix +import "/fmt" for Fmt var arrays = [ [ [25, 15, -5], diff --git a/Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig b/Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig deleted file mode 100644 index 39a4ebad30..0000000000 --- a/Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig +++ /dev/null @@ -1,64 +0,0 @@ -const std = @import("std"); - -fn cholesky(mat: []const f64, n: usize, allocator: std.mem.Allocator) ![]f64 { - const res = try allocator.alloc(f64, mat.len); - @memset(res, 0.0); - - for (0..n) |i| { - for (0..i+1) |j| { - var s: f64 = 0.0; - for (0..j) |k| { - s += res[i * n + k] * res[j * n + k]; - } - - res[i * n + j] = if (i == j) - std.math.sqrt(mat[i * n + i] - s) - else - (1.0 / res[j * n + j] * (mat[i * n + j] - s)); - } - } - return res; -} - -fn showMatrix(matrix: []const f64, n: usize) void { - for (0..n) |i| { - for (0..n) |j| { - std.debug.print("{d:.4}\t", .{matrix[i * n + j]}); - } - std.debug.print("\n", .{}); - } - std.debug.print("\n", .{}); -} - -pub fn main() !void { - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - const allocator = gpa.allocator(); - defer _ = gpa.deinit(); - - { - const dimension: usize = 3; - const m1 = [_]f64{ - 25.0, 15.0, -5.0, - 15.0, 18.0, 0.0, - -5.0, 0.0, 11.0 - }; - - const res1 = try cholesky(&m1, dimension, allocator); - defer allocator.free(res1); - showMatrix(res1, dimension); - } - - { - const dimension: usize = 4; - const m2 = [_]f64{ - 18.0, 22.0, 54.0, 42.0, - 22.0, 70.0, 86.0, 62.0, - 54.0, 86.0, 174.0, 134.0, - 42.0, 62.0, 134.0, 106.0 - }; - - const res2 = try cholesky(&m2, dimension, allocator); - defer allocator.free(res2); - showMatrix(res2, dimension); - } -} diff --git a/Task/Chowla-numbers/ALGOL-68/chowla-numbers.alg b/Task/Chowla-numbers/ALGOL-68/chowla-numbers.alg index 6fefcfb901..641726dfd2 100644 --- a/Task/Chowla-numbers/ALGOL-68/chowla-numbers.alg +++ b/Task/Chowla-numbers/ALGOL-68/chowla-numbers.alg @@ -1,33 +1,16 @@ BEGIN # find some Chowla numbers ( Chowla n = sum of divisors of n exclusing n and 1 ) # - - # returns the divisor sums of [1 n], the sums exclude 1 and n # - PROC sum divisors = ( INT n )[]INT: - BEGIN - [ 1 : n ]INT sums; - FOR i TO n DO sums[ i ] := 0 OD; - FOR i FROM 2 TO n DO - FOR j FROM i + i BY i TO n DO sums[ j ] +:= i OD - OD; - sums - END # sum divisors # ; - - []INT ds = sum divisors( 10 000 000 ); # get a table of divisor sums for 1..n # - # returs the Chowla number of n # PROC chowla = ( INT n )INT: - IF n < 2 - THEN 0 - ELIF n <= UPB ds - LWB ds + 1 - THEN ds[ n ] - ELSE INT sum := 0; - FOR i FROM 2 WHILE i * i <= n DO - IF n MOD i = 0 THEN - INT j = n OVER i; - sum +:= i + IF i = j THEN 0 ELSE j FI - FI - OD; - sum - FI # chowla # ; + BEGIN + INT sum := 0; + FOR i FROM 2 WHILE i * i <= n DO + IF n MOD i = 0 THEN + INT j = n OVER i; + sum +:= i + IF i = j THEN 0 ELSE j FI + FI + OD; + sum + END # chowla # ; FOR n TO 37 DO print( ( "chowla(", whole( n, 0 ), ") = ", whole( chowla( n ), 0 ), newline ) ) OD; @@ -40,7 +23,7 @@ BEGIN # find some Chowla numbers ( Chowla n = sum of divisors of n exclusing n a FI OD; count := 0; - INT limit = 35 000 000; + INT limit = 350 000 000; INT k := 2, kk := 3; WHILE INT p = k * kk; p <= limit diff --git a/Task/Chowla-numbers/Ada/chowla-numbers.ada b/Task/Chowla-numbers/Ada/chowla-numbers.ada new file mode 100644 index 0000000000..8b9451b145 --- /dev/null +++ b/Task/Chowla-numbers/Ada/chowla-numbers.ada @@ -0,0 +1,70 @@ +with Ada.Text_IO; + +procedure Chowla_Numbers is + + function Chowla (N : Positive) return Natural is + Sum : Natural := 0; + I : Positive := 2; + J : Positive; + begin + while I * I <= N loop + if N mod I = 0 then + J := N / I; + Sum := Sum + I + (if I = J then 0 else J); + end if; + I := I + 1; + end loop; + return Sum; + end Chowla; + + procedure Put_37_First is + use Ada.Text_IO; + begin + for A in Positive range 1 .. 37 loop + Put_Line ("chowla(" & A'Image & ") = " & Chowla (A)'Image); + end loop; + end Put_37_First; + + procedure Put_Prime is + use Ada.Text_IO; + Count : Natural := 0; + Power : Positive := 100; + begin + for N in Positive range 2 .. 10_000_000 loop + if Chowla (N) = 0 then + Count := Count + 1; + end if; + if N mod Power = 0 then + Put_Line ("There is " & Count'Image & " primes < " & Power'Image); + Power := Power * 10; + end if; + end loop; + end Put_Prime; + + procedure Put_Perfect is + use Ada.Text_IO; + Count : Natural := 0; + Limit : constant := 350_000_000; + K : Natural := 2; + Kk : Natural := 3; + P : Natural; + begin + loop + P := K * Kk; + exit when P > Limit; + + if Chowla (P) = P - 1 then + Put_Line (P'Image & " is a perfect number"); + Count := Count + 1; + end if; + K := Kk + 1; + Kk := Kk + K; + end loop; + Put_Line ("There are " & Count'Image & " perfect numbers < " & Limit'Image); + end Put_Perfect; + +begin + Put_37_First; + Put_Prime; + Put_Perfect; +end Chowla_Numbers; diff --git a/Task/Chowla-numbers/Ada/chowla-numbers.adb b/Task/Chowla-numbers/Ada/chowla-numbers.adb deleted file mode 100644 index 4f48ba270c..0000000000 --- a/Task/Chowla-numbers/Ada/chowla-numbers.adb +++ /dev/null @@ -1,70 +0,0 @@ -with Ada.Text_IO; - -procedure Chowla_Numbers is - - function Chowla (N : Positive) return Natural is - Sum : Natural := 0; - I : Positive := 2; - J : Positive; - begin - while I * I <= N loop - if N mod I = 0 then - J := N / I; - Sum := Sum + I + (if I = J then 0 else J); - end if; - I := I + 1; - end loop; - return Sum; - end Chowla; - - procedure Put_37_First is - use Ada.Text_IO; - begin - for A in Positive range 1 .. 37 loop - Put_Line ("chowla(" & A'Image & ") = " & Chowla (A)'Image); - end loop; - end Put_37_First; - - procedure Put_Prime is - use Ada.Text_IO; - Count : Natural := 0; - Power : Positive := 100; - begin - for N in Positive range 2 .. 10_000_000 loop - if Chowla (N) = 0 then - Count := Count + 1; - end if; - if N mod Power = 0 then - Put_Line ("There are " & Count'Image & " primes < " & Power'Image); - Power := Power * 10; - end if; - end loop; - end Put_Prime; - - procedure Put_Perfect is - use Ada.Text_IO; - Count : Natural := 0; - Limit : constant := 350_000_000; - K : Natural := 2; - Kk : Natural := 3; - P : Natural; - begin - loop - P := K * Kk; - exit when P > Limit; - - if Chowla (P) = P - 1 then - Put_Line (P'Image & " is a perfect number"); - Count := Count + 1; - end if; - K := Kk + 1; - Kk := Kk + K; - end loop; - Put_Line ("There are " & Count'Image & " perfect numbers < " & Limit'Image); - end Put_Perfect; - -begin - Put_37_First; - Put_Prime; - Put_Perfect; -end Chowla_Numbers; diff --git a/Task/Chowla-numbers/Agena/chowla-numbers.agena b/Task/Chowla-numbers/Agena/chowla-numbers.agena deleted file mode 100644 index f483192c9a..0000000000 --- a/Task/Chowla-numbers/Agena/chowla-numbers.agena +++ /dev/null @@ -1,57 +0,0 @@ -scope # find some Chowla numbers ( Chowla n = sum of divisors of n exclusing n and 1 ) - - # returns the divisor sums of [1 n], the sums exclude 1 and n - local proc sumDivisors( n :: number ) :: sequence - local constant sums := seq(); - for i to n do sums[ i ] := 0 od; - for i from 2 to n do - for j from i + i to n by i do sums[ j ] +:= i od - od; - return sums - end; - - local constant ds := sumDivisors( 10_000_000 ); - - local proc chowla( n :: number ) :: number # returns the Chowla number of n - local sum := 0; - if n > 0 then - if n <= size ds then - sum := ds[ n ] - else - for i from 2 while i * i <= n do - if n mod i = 0 then - local constant j := n \ i; - sum +:= i + if i = j then 0 else j fi - fi - od - fi - fi; - return sum - end; - - # first 37 chowla numbers - for n to 37 do printf( "chowla(%d) = %d\n", n, chowla( n ) ) od; - - # number of primes up to 10_000_000 - local count, power := 0, 100; - for n from 2 to 10_000_000 do - if chowla( n ) = 0 then count +:= 1 fi; - if n mod power = 0 then - printf( "There are %6d primes < %d\n", count, power ); - power *:= 10 - fi - od; - - # perfect numbers to 35_000_000 - local constant perfectMax := 35_000_000; - count := 0; - local k, kk, p := 2, 3, 6; # p is k * kk; - while p <= perfectMax do - if chowla( p ) = p - 1 then - printf( " %8d is a perfect number\n", p ); - count +:= 1 - fi; - k := kk + 1; kk +:= k; p := k * kk - od; - printf( "There are %d perfect numbers < %d\n", count, perfectMax ) -end diff --git a/Task/Chowla-numbers/EMal/chowla-numbers.emal b/Task/Chowla-numbers/EMal/chowla-numbers.emal index cd3aa6dcee..ae58e913ba 100644 --- a/Task/Chowla-numbers/EMal/chowla-numbers.emal +++ b/Task/Chowla-numbers/EMal/chowla-numbers.emal @@ -1,44 +1,44 @@ -fun chowla ← int by int n - int sum ← 0 - int j ← 0 - for int i ← 2; i * i ≤ n; ++i do - if n % i æ 0 do sum += i + when(i æ (j ← n / i), 0, j) end +fun chowla = int by int n + int sum = 0 + int j = 0 + for int i = 2; i * i <= n; i++ do + if n % i == 0 do sum += i + when(i == (j = n / i), 0, j) end end return sum end -fun sieve ← List by int limit - List c ← logic[].with(limit) - for int i ← 3; i * 3 < limit; i += 2 - if c[i] or chowla(i) ≠ 0 do continue end - for int j ← 3 * i; j < limit; j += 2 * i do c[j] ← true end +fun sieve = List by int limit + List c = logic[].with(limit) + for int i = 3; i * 3 < limit; i += 2 + if c[i] or chowla(i) != 0 do continue end + for int j = 3 * i; j < limit; j += 2 * i do c[j] = true end end return c end # find and display (1 per line) for the 1st 37 integers -for int i ← 1; i ≤ 37; ++i do writeLine("chowla(" + i + ") = ", chowla(i)) end -int count ← 1 -int limit ← 10000000 -int power ← 100 -List c ← sieve(limit) -for int i ← 3; i < limit; i += 2 - if not c[i] do ++count end - if i æ power - 1 - writeLine("Count of primes up to ", power, " = ", count) +for int i = 1; i <= 37; i++ do writeLine("chowla(" + i + ") = " + chowla(i)) end +int count = 1 +int limit = 10000000 +int power = 100 +List c = sieve(limit) +for int i = 3; i < limit; i += 2 + if not c[i] do count++ end + if i == power - 1 + writeLine("Count of primes up to " + power + " = " + count) power *= 10 end end -count ← 0 -limit ← 35000000 -int k ← 2 -int kk ← 3 +count = 0 +limit = 35000000 +int k = 2 +int kk = 3 int p -for int i ← 2; ; ++i - if (p ← k * kk) > limit do break end - if chowla(p) æ p - 1 - writeLine(p, " is a number that is perfect") - ++count +for int i = 2; ; i++ + if (p = k * kk) > limit do break end + if chowla(p) == p - 1 + writeLine(p + " is a number that is perfect") + count++ end - k ← kk + 1 + k = kk + 1 kk += k end -writeLine("There are ", count, " perfect numbers ≤ 35,000,000") +writeLine("There are " + count + " perfect numbers <= 35,000,000") diff --git a/Task/Chowla-numbers/EasyLang/chowla-numbers.easy b/Task/Chowla-numbers/EasyLang/chowla-numbers.easy index 3cecf7520f..829ae64303 100644 --- a/Task/Chowla-numbers/EasyLang/chowla-numbers.easy +++ b/Task/Chowla-numbers/EasyLang/chowla-numbers.easy @@ -1,80 +1,90 @@ -fastfunc chowla n . - i = 2 - while i * i <= n - if n mod i = 0 - j = n div i - if i = j - sum += i - else - sum += i + j - . +proc chowla n . sum . + sum = 0 + i = 2 + while i * i <= n + if n mod i = 0 + j = n div i + if i = j + sum += i + else + sum += i + j . - i += 1 - . - return sum + . + i += 1 + . . -proc sieve &c[] . - i = 3 - while i * 3 <= len c[] - if c[i] = 0 - if chowla i = 0 - j = 3 * i - while j <= len c[] - c[j] = 1 - j += 2 * i - . - . +proc sieve . c[] . + i = 3 + while i * 3 <= len c[] + if c[i] = 0 + call chowla i h + if h = 0 + j = 3 * i + while j <= len c[] + c[j] = 1 + j += 2 * i + . . - i += 2 - . + . + i += 2 + . . -func$ comma n . - s$[] = strchars n - s$ = "" - l = len s$[] - for i = 1 to len s$[] - if i > 1 and l mod 3 = 0 : s$ &= "," - l -= 1 - s$ &= s$[i] - . - return s$ +proc commatize n . s$ . + s$[] = strchars n + s$ = "" + l = len s$[] + for i = 1 to len s$[] + if i > 1 and l mod 3 = 0 + s$ &= "," + . + l -= 1 + s$ &= s$[i] + . . print "chowla number from 1 to 37" for i = 1 to 37 - print " " & i & ": " & chowla i + call chowla i h + print " " & i & ": " & h . -proc main . - print "" - len c[] 10000000 - count = 1 - sieve c[] - power = 100 - i = 3 - while i <= len c[] - if c[i] = 0 : count += 1 - if i = power - 1 - print "There are " & comma count & " primes up to " & comma power - power *= 10 - . - i += 2 - . - print "" - limit = 35000000 - count = 0 - i = 2 - k = 2 - kk = 3 - repeat - p = k * kk - until p > limit - if chowla p = p - 1 - print comma p & " is a perfect number" - count += 1 - . - k = kk + 1 - kk += k - i += 1 - . - print "There are " & count & " perfect mumbers up to " & comma limit +proc main . . + print "" + len c[] 10000000 + count = 1 + call sieve c[] + power = 100 + i = 3 + while i <= len c[] + if c[i] = 0 + count += 1 + . + if i = power - 1 + call commatize power p$ + call commatize count c$ + print "There are " & c$ & " primes up to " & p$ + power *= 10 + . + i += 2 + . + print "" + limit = 35000000 + count = 0 + i = 2 + k = 2 + kk = 3 + repeat + p = k * kk + until p > limit + call chowla p h + if h = p - 1 + call commatize p s$ + print s$ & " is a perfect number" + count += 1 + . + k = kk + 1 + kk += k + i += 1 + . + call commatize limit s$ + print "There are " & count & " perfect mumbers up to " & s$ . -main +call main diff --git a/Task/Chowla-numbers/Fennel/chowla-numbers.fennel b/Task/Chowla-numbers/Fennel/chowla-numbers.fennel deleted file mode 100644 index 5bfb4bd8c4..0000000000 --- a/Task/Chowla-numbers/Fennel/chowla-numbers.fennel +++ /dev/null @@ -1,61 +0,0 @@ -(do ;;; find some Chowla numbers ( Chowla n = sum of divisors of n exclusing n and 1 ) - - (fn sum-divisors [n] - (local sums {}) - (for [i 1 n] (tset sums i 0)) - (for [i 2 n] - (for [j (+ i i) n i] (tset sums j (+ (. sums j) i))) - ) - sums - ) - - (local ds (sum-divisors 10_000_000)) - - (fn chowla [n] ; returns the Chowla number of n - (var sum 0) - (when (> n 0) - (if (<= n (length ds)) - (set sum (. ds n)) - ;else - (for [i 2 (math.floor (math.sqrt n))] - (when (= 0 (% n i)) - (local j (math.floor (/ n i))) - (set sum (+ sum i (if (= i j) 0 j))) - ) - ) - ) - ) - sum - ) - - - ; first 37 chowla numbers - (for [n 1 37] (print (.. "chowla(" n ") = " (chowla n)))) - - ; number of primes up to 10_000_000 - (var (count power) (values 0 100)) - (for [n 2 10_000_000] - (when (= 0 (chowla n)) - (set count (+ count 1)) - ) - (when (= 0 (% n power)) - (print (string.format "There are %6d primes < %d" count power)) - (set power (* power 10)) - ) - ) - - ; perfect numbers to 35_000_000 - (local perfect-max 35_000_000) - (set count 0) - (var (k kk p) (values 2 3 6)) ; p is k * kk - (while (<= p perfect-max) - (when (= (chowla p) (- p 1)) - (print (string.format " %8d is a perfect number" p)) - (set count (+ count 1)) - ) - (set k (+ kk 1)) - (set kk (+ kk k)) - (set p (* kk k)) - ) - (print (.. "There are " count " perfect numbers < " perfect-max)) -) diff --git a/Task/Chowla-numbers/Fortran/chowla-numbers.f b/Task/Chowla-numbers/Fortran/chowla-numbers.f deleted file mode 100644 index 9da7c28d01..0000000000 --- a/Task/Chowla-numbers/Fortran/chowla-numbers.f +++ /dev/null @@ -1,114 +0,0 @@ - PROGRAM CHOWLA - - CALL PUT_1ST_37 - CALL PUT_PRIME - CALL PUT_PERFECT - - END - - INTEGER*4 FUNCTION CHOWLA1(N) - -C The Chowla number of N is the sum of the divisors of N -C excluding unity and N where N is a positive integer - - IMPLICIT INTEGER*4 (A-Z) - - IF (N .LE. 0) STOP 'Argument to Chowla function must be > 0' - - SUM = 0 - I = 2 - - 100 CONTINUE - IF (I * I .GT. N) GOTO 200 - - IF (MOD(N, I) .NE. 0) GOTO 110 - J = N / I - SUM = SUM + I - IF ( I .NE. J) SUM = SUM + J - 110 CONTINUE - - I = I + 1 - GOTO 100 - - 200 CONTINUE - - CHOWLA1 = SUM - - RETURN - - END - - SUBROUTINE PUT_1ST_37 - IMPLICIT INTEGER*4 (A-Z) - - DO 100 I = 1, 37 - PRINT 900, I, CHOWLA1(I) - 100 CONTINUE - - RETURN - - 900 FORMAT(1H , 'CHOWLA(', I2, ') = ', I2) - - END - - SUBROUTINE PUT_PRIME - IMPLICIT INTEGER*4 (A-Z) - PARAMETER LIMIT = 10000000 - - COUNT = 0 - POWER = 100 - - DO 200 N = 2, LIMIT - - IF (CHOWLA1(N) .EQ. 0) COUNT = COUNT + 1 - - IF (MOD(N, POWER) .NE. 0) GOTO 100 - - PRINT 900, COUNT, POWER - POWER = POWER * 10 - - 100 CONTINUE - - 200 CONTINUE - - RETURN - - 900 FORMAT(1H ,'There are ', I12, ' primes < ', I12) - - END - - SUBROUTINE PUT_PERFECT - IMPLICIT INTEGER*4 (A-Z) - PARAMETER LIMIT = 35000000 - - COUNT = 0 - K = 2 - KK = 3 - - 100 CONTINUE - - P = K * KK - - IF (P .GT. LIMIT) GOTO 300 - - IF (CHOWLA1(P) .NE. P - 1) GOTO 200 - PRINT 900, P - COUNT = COUNT + 1 - - 200 CONTINUE - - K = KK + 1 - KK = KK + K - - GOTO 100 - - 300 CONTINUE - - PRINT 910, COUNT, LIMIT - - RETURN - - 900 FORMAT(1H , I10, ' is a perfect number') - 910 FORMAT(1H , 'There are ', I10, ' perfect numbers < ', I10) - - END diff --git a/Task/Chowla-numbers/FutureBasic/chowla-numbers.basic b/Task/Chowla-numbers/FutureBasic/chowla-numbers.basic deleted file mode 100644 index 426b5f4722..0000000000 --- a/Task/Chowla-numbers/FutureBasic/chowla-numbers.basic +++ /dev/null @@ -1,46 +0,0 @@ -local fn Chowla( n as NSUInteger ) as NSUInteger - NSUInteger i, j, r = 0 - - i = 2 - while ( i * i <= n ) - j = n / i - if ( n mod i == 0 ) - r += i - if ( i != j ) - r += j - end if - end if - i++ - wend -end fn = r - -local fn DoIt - NSUInteger n, count = 0, power = 100, limit, k, kk, p = 0 - - for n = 1 to 37 - printf @"chowla(%u) = %u", n, fn Chowla( n ) - next - - for n = 2 to 10000000 - if ( fn Chowla(n) == 0 ) then count ++ - if ( n mod power == 0 ) then printf @"There are %u primes < %-7u", count, power : power *= 10 - next - - count = 0 - limit = 350000000 - k = 2 : kk = 3 - do - p = k * kk - if ( fn Chowla( p ) == p - 1 ) - printf @"%9u is a perfect number", p - count++ - end if - k = kk + 1 - kk = kk + k - until ( p > limit ) - printf @"There are %u perfect numbers < %u", count, limit -end fn - -fn DoIt - -HandleEvents diff --git a/Task/Chowla-numbers/JavaScript/chowla-numbers.js b/Task/Chowla-numbers/JavaScript/chowla-numbers.js deleted file mode 100644 index 1ff725b65f..0000000000 --- a/Task/Chowla-numbers/JavaScript/chowla-numbers.js +++ /dev/null @@ -1,79 +0,0 @@ -// Chowla function: calculates sum of proper divisors of n (excluding n itself) -function chowla(n) { - let sum = 0; - for (let i = 2; i * i <= n; i++) { - if (n % i === 0) { - const j = n / i; - sum += i + (i === j ? 0 : j); - } - } - return sum; -} - -// Sieve function: returns array where true denotes composite, false denotes prime -// Only interested in odd numbers >= 3 -function sieve(limit) { - // True denotes composite, false denotes prime - const c = new Array(limit).fill(false); - - for (let i = 3; i * 3 < limit; i += 2) { - if (!c[i] && chowla(i) === 0) { - for (let j = 3 * i; j < limit; j += 2 * i) { - c[j] = true; - } - } - } - return c; -} - -// Main execution -function main() { - // Part 1: Print chowla values for 1-37 - console.log("Chowla function values for 1-37:"); - for (let i = 1; i <= 37; i++) { - console.log(`chowla(${i}) = ${chowla(i)}`); - } - console.log("\n"); - - // Part 2: Count primes up to powers of 10 - console.log("Prime counting using Chowla's sieve:"); - let count = 1; - const limit = 10000000; // 1e7 - let power = 100; - - const c = sieve(limit); - - for (let i = 3; i < limit; i += 2) { - if (!c[i]) count++; - - if (i === power - 1) { - console.log(`Count of primes up to ${power.toLocaleString()} = ${count.toLocaleString()}`); - power *= 10; - } - } - console.log("\n"); - - // Part 3: Find perfect numbers - console.log("Perfect numbers <= 35,000,000:"); - count = 0; - const perfectLimit = 35000000; - - let k = 2, kk = 3, p; - for (let i = 2; ; i++) { - p = k * kk; - if (p > perfectLimit) break; - - if (chowla(p) === p - 1) { - console.log(`${p.toLocaleString()} is a perfect number`); - count++; - } - - k = kk + 1; - kk += k; - } - - console.log(`\nThere are ${count} perfect numbers <= 35,000,000`); -} - -// Execute the main function -main(); diff --git a/Task/Chowla-numbers/Julia/chowla-numbers.jl b/Task/Chowla-numbers/Julia/chowla-numbers.jl deleted file mode 100644 index 1402756727..0000000000 --- a/Task/Chowla-numbers/Julia/chowla-numbers.jl +++ /dev/null @@ -1,40 +0,0 @@ -using Primes, Format - -function chowla(n) - if n < 1 - throw("Chowla function argument must be positive") - elseif n < 4 - return zero(n) - else - f = [one(n)] - for (p,e) in factor(n) - f = reduce(vcat, [f*p^j for j in 1:e], init=f) - end - return sum(f) - one(n) - n - end -end - -function countchowlas(n, asperfect=false, verbose=false) - count = 0 - for i in 2:n # 1 is not prime or perfect so skip - chow = chowla(i) - if (asperfect && chow == i - 1) || (!asperfect && chow == 0) - count += 1 - verbose && println("The number $(format(i, commas=true)) is ", asperfect ? "perfect." : "prime.") - end - end - count -end - -function testchowla() - println("The first 37 chowla numbers are:") - for i in 1:37 - println("Chowla($i) is ", chowla(i)) - end - for i in [100, 1000, 10000, 100000, 1000000, 10000000] - println("The count of the primes up to $(format(i, commas=true)) is $(format(countchowlas(i), commas=true))") - end - println("The count of perfect numbers up to 35,000,000 is $(countchowlas(35000000, true, true)).") -end - -testchowla() diff --git a/Task/Chowla-numbers/Julia/chowla-numbers.julia b/Task/Chowla-numbers/Julia/chowla-numbers.julia new file mode 100644 index 0000000000..cc27df514d --- /dev/null +++ b/Task/Chowla-numbers/Julia/chowla-numbers.julia @@ -0,0 +1,40 @@ +using Primes, Formatting + +function chowla(n) + if n < 1 + throw("Chowla function argument must be positive") + elseif n < 4 + return zero(n) + else + f = [one(n)] + for (p,e) in factor(n) + f = reduce(vcat, [f*p^j for j in 1:e], init=f) + end + return sum(f) - one(n) - n + end +end + +function countchowlas(n, asperfect=false, verbose=false) + count = 0 + for i in 2:n # 1 is not prime or perfect so skip + chow = chowla(i) + if (asperfect && chow == i - 1) || (!asperfect && chow == 0) + count += 1 + verbose && println("The number $(format(i, commas=true)) is ", asperfect ? "perfect." : "prime.") + end + end + count +end + +function testchowla() + println("The first 37 chowla numbers are:") + for i in 1:37 + println("Chowla($i) is ", chowla(i)) + end + for i in [100, 1000, 10000, 100000, 1000000, 10000000] + println("The count of the primes up to $(format(i, commas=true)) is $(format(countchowlas(i), commas=true))") + end + println("The count of perfect numbers up to 35,000,000 is $(countchowlas(35000000, true, true)).") +end + +testchowla() diff --git a/Task/Chowla-numbers/Kotlin/chowla-numbers.kts b/Task/Chowla-numbers/Kotlin/chowla-numbers.kotlin similarity index 100% rename from Task/Chowla-numbers/Kotlin/chowla-numbers.kts rename to Task/Chowla-numbers/Kotlin/chowla-numbers.kotlin diff --git a/Task/Chowla-numbers/Maxima/chowla-numbers.maxima b/Task/Chowla-numbers/Maxima/chowla-numbers.maxima deleted file mode 100644 index be58f3e5ab..0000000000 --- a/Task/Chowla-numbers/Maxima/chowla-numbers.maxima +++ /dev/null @@ -1,13 +0,0 @@ -chowla(n) := if(n=1) then 0 else divsum(n)-n-1$ -chowla_seq(n, start) := map(chowla, makelist(i,i,start,n))$ -chowla_seq(37, 1); - -chowla_numprimes(n) := length(sublist_indices(chowla_seq(n, 2), lambda([x], x=0)))$ -map(chowla_numprimes, makelist(10^i, i, 2, 7)); - -chowla_perfects(n) := block( - chowla_list: chowla_seq(n, 1), - is_perfect(x) := if(x>n or x=0) then false else x=chowla_list[x+1], - unique(sublist(chowla_list, is_perfect)+1))$ - -chowla_perfects(10000); diff --git a/Task/Chowla-numbers/PARI-GP/chowla-numbers.parigp b/Task/Chowla-numbers/PARI-GP/chowla-numbers.parigp deleted file mode 100644 index a3b5237301..0000000000 --- a/Task/Chowla-numbers/PARI-GP/chowla-numbers.parigp +++ /dev/null @@ -1,28 +0,0 @@ -chowla(n) = { - if (n < 1, error("Chowla function argument must be positive")); - if (n < 4, return(0)); - my(divs = divisors(n)); - sum(i=1, #divs, divs[i]) - n - 1; -} - -\\ Function to count Chowla numbers -countchowlas(n, asperfect = 1, verbose = 1) = { - my(count = 0, chow, i); - for (i = 2, n, - chow = chowla(i); - if ( (asperfect && (chow == i - 1)) || ((!asperfect) && (chow == 0)), - count++; - if (verbose, print("The number " i " is " if (asperfect, "perfect.", "prime."))); - ); - ); - count; -} - -\\ Main execution block -{ - print("The first 37 chowla numbers are:"); - for (i = 1, 37, printf("Chowla(%s) is %s\n", Str(i), Str(chowla(i)) ) ); - m=100; - while(m<=10000000, print("The count of the primes up to " m " is " countchowlas(m, 0, 0)); m=m*10); - print("The count of perfect numbers up to 35,000,000 is " countchowlas(35000000, 1, 1)); -} diff --git a/Task/Chowla-numbers/PascalABC.NET/chowla-numbers.pas b/Task/Chowla-numbers/PascalABC.NET/chowla-numbers.pas deleted file mode 100644 index 7274f05fc9..0000000000 --- a/Task/Chowla-numbers/PascalABC.NET/chowla-numbers.pas +++ /dev/null @@ -1,54 +0,0 @@ -function chowla(n: Integer): Integer; -begin - result := 0; - var i := 2; - while i * i <= n do - begin - if n mod i = 0 then - result += i + (if i = n div i then 0 else n div i); - i += 1 - end; -end; - -function sieve(limit: Integer): array of Boolean; -begin - result := new Boolean[limit]; - for var i := 3 to limit div 3 step 2 do - if not result[i] and (chowla(i) = 0) Then - for var j := 3 * i to limit step 2 * i do - result[j] := true; -end; - -begin - for var i := 1 To 37 do - WriteLn('chowla(', i, ') = ', chowla(i)); - - var count := 1; - var limit := 10_000_000; - var power := 100; - var c := sieve(limit); - for var i := 3 To limit Step 2 do - begin - if not c[i] Then count += 1; - if i = power - 1 Then begin - WriteLn('Count of primes up to ', power:8, ' = ', count); - power *= 10; - end; - end; - - count := 0; - limit := 35_000_000; - var k := 2; var kk := 3; - while True do - begin - var p := k * kk; - if p > limit Then break; - if chowla(p) = p - 1 Then begin - WriteLn(p:8, ' is a number that is perfect'); - count += 1; - end; - k := kk + 1; - kk += k; - end; - WriteLn('There are ', count, ' perfect numbers <= 35,000,000') -end. diff --git a/Task/Chowla-numbers/Pluto/chowla-numbers.pluto b/Task/Chowla-numbers/Pluto/chowla-numbers.pluto deleted file mode 100644 index 7170013ac8..0000000000 --- a/Task/Chowla-numbers/Pluto/chowla-numbers.pluto +++ /dev/null @@ -1,57 +0,0 @@ -do -- find some Chowla numbers ( Chowla n = sum of divisors of n exclusing n and 1 ) - - -- returns the divisor sums of [1 n], the sums exclude 1 and n - local function sumDivisors( n : number ) : table - local sums = {} - for i = 1, n do sums[ i ] = 0 end - for i = 2, n do - for j = i + i, n, i do sums[ j ] += i end - end - return sums - end - - local ds = sumDivisors( 10_000_000 ) - - local function chowla( n : number ) : number -- returns the Chowla number of n - local sum = 0 - if n > 0 then - if n <= # ds then - sum = ds[ n ] - else - for i = 2, math.floor( math.sqrt( n ) ) do - if n % i == 0 then - local j = n // i - sum += i + if i == j then 0 else j end - end - end - end - end - return sum - end - - -- first 37 chowla numbers - for n = 1, 37 do print( $"chowla({n}) = {chowla(n)}" ) end - - -- number of primes up to 10_000_000 - local count, power = 0, 100 - for n = 2, 10_000_000 do - if chowla( n ) == 0 then count += 1 end - if n % power == 0 then - print( string.format( "There are %6d primes < %d", count, power ) ) - power *= 10 - end - end - - -- perfect numbers to 35_000_000 - local perfectMax = 35_000_000 - count = 0 - local k, kk, p = 2, 3, 6 -- p is k * kk - while p <= perfectMax do - if chowla( p ) == p - 1 then - print( string.format( " %8d is a perfect number", p ) ) - count += 1 - end - k = kk + 1; kk += k; p = k * kk - end - print( $"There are {count} perfect numbers < {perfectMax}" ) -end diff --git a/Task/Chowla-numbers/Quackery/chowla-numbers.quackery b/Task/Chowla-numbers/Quackery/chowla-numbers.quackery deleted file mode 100644 index 6fc47e0c39..0000000000 --- a/Task/Chowla-numbers/Quackery/chowla-numbers.quackery +++ /dev/null @@ -1,31 +0,0 @@ - [ 2 max - dup sqrt+ - iff 0 else [ dup negate ] - unrot - times - [ dup i^ 1+ /mod - 0 = iff - [ i^ 1+ + - swap dip + ] - else drop ] - 1+ - ] is chowla ( n --> n ) - - 37 times - [ say "chowla(" - i^ 1+ dup echo - say ")= " - chowla echo cr ] - cr - ' [ 100 1000 10000 100000 1000000 10000000 ] - witheach - [ 0 over 2 - times - [ i^ 2 + chowla 0 = + ] - say "There are " echo - say " primes less than " - echo cr ] - cr - 35000000 2 - times - [ i^ 2 + dup chowla 1+ = if - [ i^ 2 + echo - say " is perfect" - cr ] ] diff --git a/Task/Chowla-numbers/REXX/chowla-numbers.rexx b/Task/Chowla-numbers/REXX/chowla-numbers.rexx index 7f52a942e8..54447064f1 100644 --- a/Task/Chowla-numbers/REXX/chowla-numbers.rexx +++ b/Task/Chowla-numbers/REXX/chowla-numbers.rexx @@ -1,73 +1,29 @@ --- 21 Feb 2026 -include Setting -numeric digits 12 +/*REXX program computes/displays chowla numbers (and may count primes & perfect numbers.*/ +parse arg LO HI . /*obtain optional arguments from the CL*/ +if LO=='' | LO=="," then LO= 1 /*Not specified? Then use the default.*/ +perf= LO<0; LO= abs(LO) /*Negative? Then determine if perfect.*/ +if HI=='' | HI=="," then HI= LO /*Not specified? Then use the default.*/ +prim= HI<0; HI= abs(HI) /*Negative? Then determine if a prime.*/ +numeric digits max(9, length(HI) + 1 ) /*use enough decimal digits for // */ +w= length( commas(HI) ) /*W: used in aligning output numbers.*/ +tell= \(prim | perf) /*set boolean value for showing chowlas*/ +p= 0 /*the number of primes found (so far).*/ + do j=LO to HI; #= chowla(j) /*compute the cholwa number for J. */ + if tell then say right('chowla('commas(j)")", w+9) ' = ' right( commas(#), w) + else if #==0 then if j>1 then p= p+1 + if perf then if j-1==# & j>1 then say right(commas(j), w) ' is a perfect number.' + end /*j*/ -say 'CHOWLA NUMBERS' -say version -say -call ChowlaNumbers -call Timer 'R' -call PrimeCount -call Timer 'R' -call PerfectNumbers -call Timer 'R' -exit - -ChowlaNumbers: -procedure expose Memo. -call Time('r'); sep = Copies('-',12) -say sep; say ' n Chowla(n)'; say sep -m = 37 -do i = 1 to m - say Right(i,2) Right(Chowla(i),9) -end -say sep -return - -PrimeCount: -procedure expose Memo. work. -sep = Copies('-',17) -say sep; say Right('n',8) Right('Primes d then do - say Right(10**e,8) Right(n,8) - d = e - end - if work.i = 0 then - iterate i - if Chowla(i) = 0 then do - n = n+1 - if i > 1 then do - j = i+i - do while j < m - work.j = 0; j = j+i - end - end - end -end -say sep -return - -PerfectNumbers: -procedure expose Divi. Memo. -sep = Copies('-',12) -say sep; say Right('Perfect',12); say sep -k = 2; kk = 3; m = 140e9; n = 0 -do forever - p = k * kk - if p > 140e9 then - leave - if Chowla(p) = p-1 then do - n = n+1 - say Right(p,12) - end - k = kk+1; kk = kk+k -end -say sep -say n 'perfect numbers found below 140e9' -return - --- Chowla; Xpon; Timer -include Math +if prim & \perf then say 'number of primes found for the range ' commas(LO) " to " , + commas(HI) " (inclusive) is: " commas(p) +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +chowla: procedure; parse arg x; if x<2 then return 0; odd= x // 2 + s=0 /* [↓] use EVEN or ODD integers. ___*/ + do k=2+odd by 1+odd while k*k usize { - let mut sum = 0; - let mut i = 2; - while i * i <= n { - if n % i == 0 { - sum += i; - let j = n / i; - if i != j { - sum += j; - } - } - i += 1; - } - sum -} - -fn sieve(limit: usize) -> Vec { - let mut c = vec![false; limit]; - let mut i = 3; - while i * i < limit { - if !c[i] && chowla(i) == 0 { - let mut j = 3 * i; - while j < limit { - c[j] = true; - j += 2 * i; - } - } - i += 2; - } - c -} - -fn main() { - for i in 1..=37 { - println!("chowla({}) = {}", i, chowla(i)); - } - - let mut count = 1; - let limit = 1e7 as usize; - let mut power = 100; - let c = sieve(limit); - for i in (3..limit).step_by(2) { - if !c[i] { - count += 1; - } - if i == power - 1 { - println!("Count of primes up to {} = {}", power, count); - power *= 10; - } - } - - count = 0; - let limit = 35000000; - let mut k = 2; - let mut kk = 3; - loop { - let p = k * kk; - if p > limit { - break; - } - if chowla(p) == p - 1 { - println!("{} is a number that is perfect", p); - count += 1; - } - k = kk + 1; - kk += k; - } - println!("There are {} perfect numbers <= 35,000,000", count); -} diff --git a/Task/Chowla-numbers/Zig/chowla-numbers.zig b/Task/Chowla-numbers/Zig/chowla-numbers.zig deleted file mode 100644 index 2aac5c07f3..0000000000 --- a/Task/Chowla-numbers/Zig/chowla-numbers.zig +++ /dev/null @@ -1,77 +0,0 @@ -const std = @import("std"); - -/// Calculates the sum of proper divisors of n (excluding n itself) -fn chowla(n: usize) usize { - var sum: usize = 0; - var i: usize = 2; - while (i * i <= n) : (i += 1) { - if (n % i == 0) { - const j = n / i; - sum += i; - if (i != j) sum += j; - } - } - return sum; -} - -/// Creates a sieve of Eratosthenes for finding primes -/// Returns a slice where true denotes composite, false denotes prime -fn sieve(limit: usize) []bool { - const allocator = std.heap.page_allocator; - const c = allocator.alloc(bool, limit) catch unreachable; - @memset(c, false); - - var i: usize = 3; - while (i * 3 < limit) : (i += 2) { - if (!c[i] and chowla(i) == 0) { - var j: usize = 3 * i; - while (j < limit) : (j += 2 * i) { - c[j] = true; - } - } - } - return c; -} - -pub fn main() void { - // Demonstrate chowla function for numbers 1-37 - var i: usize = 1; - while (i <= 37) : (i += 1) { - std.debug.print("chowla({}) = {}\n", .{ i, chowla(i) }); - } - - // Count primes up to 10 million - const limit = 10_000_000; - const c = sieve(limit); - var count: usize = 1; - var power: usize = 100; - - i = 3; - while (i < limit) : (i += 2) { - if (!c[i]) count += 1; - if (i == power - 1) { - std.debug.print("Count of primes up to {} = {}\n", .{ power, count }); - power *= 10; - } - } - - // Find perfect numbers using the formula: p = k * (k+1) / 2 where - // p is perfect if and only if 2^k - 1 is prime (Mersenne prime) - const perfect_limit = 35_000_000; - var perfect_count: usize = 0; - var k: usize = 2; - var kk: usize = 3; - - while (true) { - const p = k * kk; - if (p > perfect_limit) break; - if (chowla(p) == p - 1) { - std.debug.print("{} is a number that is perfect\n", .{p}); - perfect_count += 1; - } - k = kk + 1; - kk += k; - } - - std.debug.print("There are {} perfect numbers <= 35,000,000\n", .{perfect_count}); -} diff --git a/Task/Church-numerals/Acornsoft-Lisp/church-numerals.lisp b/Task/Church-numerals/Acornsoft-Lisp/church-numerals.lisp deleted file mode 100644 index 1a5aa882c5..0000000000 --- a/Task/Church-numerals/Acornsoft-Lisp/church-numerals.lisp +++ /dev/null @@ -1,38 +0,0 @@ -(setq zero '(lambda (f x) x)) - -(defun succ (n) - (freeze '(n) '(lambda (f x) (f (n f x))))) - -(defun add (m n) - (freeze '(m n) '(lambda (f x) (m f (n f x))))) - -(defun mul (m n) - (n (freeze '(m) '(lambda (sum) (add m sum))) zero)) - -(defun pow (m n) - (n (freeze '(m) '(lambda (product) (mul m product))) one)) - -(defun church (i) - (cond ((zerop i) zero) - (t (succ (church (sub1 i)))))) - -(defun unchurch (n) - (n add1 0)) - -(setq one (succ zero)) -(setq two (succ one)) -(setq three (succ two)) -(setq four (succ three)) - -(defun show (example) - (prin example) - (princ '! =>! ) - (print (unchurch (eval example)))) - -(defun examples () - (show '(church 3)) - (show '(add three four)) - (show '(mul three four)) - (show '(pow three four)) - (show '(pow four three)) - (show '(pow (pow two two) (add two one)))) diff --git a/Task/Church-numerals/Applesoft-BASIC/church-numerals.basic b/Task/Church-numerals/Applesoft-BASIC/church-numerals.basic deleted file mode 100644 index 954ef14625..0000000000 --- a/Task/Church-numerals/Applesoft-BASIC/church-numerals.basic +++ /dev/null @@ -1,29 +0,0 @@ - 0 DIM OP(13),N(13),X(13,1):READ OP(ZERO),N(ZERO),X(ZERO,0),X(ZERO,1):CN = CN + 1:DATA1,0,0,1 - 1 C = ZERO:GOSUB 10:C=R:GOSUB 10:C=R:GOSUB 10:THREE = R - 2 C = THREE :GOSUB 10:FOUR = R - 3 C = THREE :GOSUB 80:PRINT "THREE -> "R - 4 C = FOUR :GOSUB 80:PRINT "FOUR -> "R - 5 C = THREE:D = FOUR :GOSUB 50:C = R:GOSUB 80:PRINT "THREE + FOUR -> "R - 6 C = THREE:D = FOUR :GOSUB 60:C = R:GOSUB 80:PRINT "THREE * FOUR -> "R - 7 C = THREE:D = FOUR :GOSUB 70:C = R:GOSUB 80:PRINT "THREE ^ FOUR -> "R - 8 C = FOUR :D = THREE:GOSUB 70:C = R:GOSUB 80:PRINT "FOUR ^ THREE -> "R - 9 I = 5 :GOSUB 90:C = R:GOSUB 80:PRINT "5 -> FIVE -> "R;:END -REM SUCC - 10 R = CN:OP(R) = OP(C):N(R) = N(C) + 1:X(R,0) = X(C,0):X(R,1) = X(C,1):CN = CN + 1:RETURN -REM SUM - 20 FOR I = 1 TO N:A = A + B:NEXT I:R = A:RETURN -REM MUL - 30 FOR I = 1 TO N:A = A * B:NEXT I:R = A:RETURN -REM POW - 40 FOR I = 1 TO N:A = A ^ B:NEXT I:R = INT (A):RETURN -REM CHURCH SUM - 50 RES = CN:OP(RES) = 1:N(RES) = 1:X(RES,0) = N(C):X(RES,1) = N(D):CN = CN + 1:R = RES:RETURN -REM CHURCH MUL - 60 RES = CN:OP(RES) = 2:N(RES) = 1:X(RES,0) = N(C):X(RES,1) = N(D):CN = CN + 1:R = RES:RETURN -REM CHURCH POW - 70 RES = CN:OP(RES) = 3:N(RES) = 1:X(RES,0) = N(C):X(RES,1) = N(D):CN = CN + 1:R = RES:RETURN -REM CHURCH TO NUM - 80 N = N(C):A = X(C,0):B = X(C,1):ON OP(C) GOTO 20,30,40:STOP -REM NUM TO CHURCH - 90 R = ZERO:IF I = 0 THEN RETURN - 91 I = I - 1:GOSUB 90:C = R:GOTO 10"SUCC diff --git a/Task/Church-numerals/Binary-Lambda-Calculus/church-numerals.blc b/Task/Church-numerals/Binary-Lambda-Calculus/church-numerals.blc deleted file mode 100644 index d228e6480d..0000000000 --- a/Task/Church-numerals/Binary-Lambda-Calculus/church-numerals.blc +++ /dev/null @@ -1,27 +0,0 @@ -(let ((zero 0) - (succ (lambda (n f x) - (f (n f x)))) - (one (succ zero)) - (two (succ one)) - (three (succ two)) - (four (succ three)) - (plus (lambda (m n f x) - (m f (n f x)))) - (times (lambda (m n f) - (m (n f)))) - (power (lambda (m n) - (n m))) - (cons (lambda (x y f) - (f x y)))) - (lambda (in) - (cons - (plus three four) - (cons - (times three four) - (cons - (power three four) - (cons - (power four three) - (cons - (power (power two two) (plus two one)) - nil))))))) diff --git a/Task/Church-numerals/Chapel/church-numerals.chpl b/Task/Church-numerals/Chapel/church-numerals.chapel similarity index 100% rename from Task/Church-numerals/Chapel/church-numerals.chpl rename to Task/Church-numerals/Chapel/church-numerals.chapel diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-1.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-1.lisp deleted file mode 100644 index 16d61e3a89..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-1.lisp +++ /dev/null @@ -1,34 +0,0 @@ -(defvar zero (lambda (f x) x)) - -(defun succ (n) (lambda (f x) (funcall f (funcall n f x)))) - -(defun plus (m n) - (lambda (f x) (funcall m f (funcall n f x)))) - -(defun times (m n) - (funcall n (lambda (sum) (plus m sum)) zero)) - -(defun power (m n) - (funcall n (lambda (product) (times m product)) one)) - -(defun church (i) ; int -> Church - (if (zerop i) zero (succ (church (1- i))))) - -(defun unchurch (n) ; Church -> int - (funcall n #'1+ 0)) - -(defun show (example) - (format t "~(~S => ~S~)~%" - example (unchurch (eval example)))) - -(defvar one (succ zero)) -(defvar two (succ one)) -(defvar three (succ two)) -(defvar four (succ three)) - -(show '(church 3)) -(show '(plus three four)) -(show '(times three four)) -(show '(power three four)) -(show '(power four three)) -(show '(power (power two two) (plus two one))) diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-2.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-2.lisp deleted file mode 100644 index a48017a748..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-2.lisp +++ /dev/null @@ -1,21 +0,0 @@ -(defvar zero (lambda (f) (lambda (x) x))) - -(defun succ (n) (lambda (f) (compose f (funcall n f)))) - -(defun plus (m n) - (lambda (f) (compose (funcall m f) (funcall n f)))) - -(defun times (m n) - (compose m n)) - -(defun power (m n) - (funcall n m)) - -(defun compose (f g) - (lambda (x) (funcall f (funcall g x)))) - -(defun church (i) ; int -> Church - (if (zerop i) zero (succ (church (1- i))))) - -(defun unchurch (n) ; Church -> int - (funcall (funcall n #'1+) 0)) diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-3.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-3.lisp deleted file mode 100644 index d4ea88113f..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-3.lisp +++ /dev/null @@ -1,10 +0,0 @@ -(defun pred (n) - (flet ((value (v) (lambda (h) (funcall h v))) - (extract (k) (funcall k (lambda (u) u)))) - (lambda (f x) - (let ((inc (lambda (g) (value (funcall g f)))) - (const (lambda (u) x))) - (extract (funcall n inc const)))))) - -(defun minus (m n) - (funcall n #'pred m)) diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-4.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-4.lisp deleted file mode 100644 index 129936e655..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-4.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(defmacro church-if (test then else) - `(funcall ,test (lambda () ,then) (lambda () ,else))) - -(defvar true (lambda (f g) (funcall f))) -(defvar false (lambda (f g) (funcall g))) diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-5.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-5.lisp deleted file mode 100644 index 1c209d0e91..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-5.lisp +++ /dev/null @@ -1,11 +0,0 @@ -(defun is-zero (n) - (funcall n (lambda (x) false) true)) - -(defun divide (m n) - (divide1 (succ m) n)) - -(defun divide1 (m n) - (let ((d (minus m n))) - (church-if (is-zero d) - zero - (succ (divide1 d n))))) diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-6.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-6.lisp deleted file mode 100644 index cd635c51d0..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-6.lisp +++ /dev/null @@ -1,4 +0,0 @@ -(show '(pred four)) -(show '(minus (church 11) three)) -(show '(divide (church 11) three)) -(show '(divide (church 12) three)) diff --git a/Task/Church-numerals/Common-Lisp/church-numerals-7.lisp b/Task/Church-numerals/Common-Lisp/church-numerals-7.lisp deleted file mode 100644 index 3086f0efc7..0000000000 --- a/Task/Church-numerals/Common-Lisp/church-numerals-7.lisp +++ /dev/null @@ -1,18 +0,0 @@ -(defun pred (n) - (flet ((value (v) (lambda (h) (funcall h v))) - (extract (k) (funcall k (lambda (u) u)))) - (lambda (f) - (lambda (x) - (let ((inc (lambda (g) (value (funcall g f)))) - (const (lambda (u) x))) - (extract (funcall (funcall n inc) const))))))) - -(defun minus (m n) - (funcall (funcall n #'pred) m)) - -... - -(defun is-zero (n) - (funcall (funcall n (lambda (x) false)) true)) - -... diff --git a/Task/Church-numerals/Crystal/church-numerals.cr b/Task/Church-numerals/Crystal/church-numerals.crystal similarity index 100% rename from Task/Church-numerals/Crystal/church-numerals.cr rename to Task/Church-numerals/Crystal/church-numerals.crystal diff --git a/Task/Church-numerals/FreeBASIC/church-numerals.basic b/Task/Church-numerals/FreeBASIC/church-numerals.basic deleted file mode 100644 index a53eccda1c..0000000000 --- a/Task/Church-numerals/FreeBASIC/church-numerals.basic +++ /dev/null @@ -1,93 +0,0 @@ -Type church - ' eg {r_add,1,{a,b}} - op As Integer - n As Integer - x(1 To 2) As Integer -End Type - -Dim Shared As church zero = Type(1, 0, {0, 1}) - -Function succ(c As church) As church - ' eg {r_add,1,{a,b}} => {r_add,2,{a,b}} aka a+b -> a+b+b - c.n += 1 - Return c -End Function - -' three normal integer-handling routines... -Function sum(n As Integer, a As Integer, b As Integer) As Integer - For i As Integer = 1 To n - a += b - Next i - Return a -End Function - -Function mul(n As Integer, a As Integer, b As Integer) As Integer - For i As Integer = 1 To n - a *= b - Next i - Return a -End Function - -Function pow(n As Integer, a As Integer, b As Integer) As Integer - For i As Integer = 1 To n - a = a ^ b - Next i - Return a -End Function - -' ...and three church constructors to match -' (no maths here, just pure static data) -Function churchSum(c As church, d As church) As church - Dim res As church - res.op = 1 ' 1 for add - res.n = 1 - res.x(1) = c.n - res.x(2) = d.n - Return res -End Function - -Function churchMul(c As church, d As church) As church - Dim res As church - res.op = 2 ' 2 for mul - res.n = 1 - res.x(1) = c.n - res.x(2) = d.n - Return res -End Function - -Function churchPow(c As church, d As church) As church - Dim res As church - res.op = 3 ' 3 for pow - res.n = 1 - res.x(1) = c.n - res.x(2) = d.n - Return res -End Function - -Function churchToNum(c As church) As Integer - ' note this is where the bulk of any processing happens - Select Case c.op - Case 1 - Return sum(c.n, c.x(1), c.x(2)) - Case 2 - Return mul(c.n, c.x(1), c.x(2)) - Case 3 - Return pow(c.n, c.x(1), c.x(2)) - End Select -End Function - -Function numToChurch(i As Integer) As church - Return Iif(i = 0, zero, succ(numToChurch(i - 1))) -End Function - -Dim As church three = succ(succ(succ(zero))) -Dim As church four = succ(three) -Print "three -> "; churchToNum(three) -Print "four -> "; churchToNum(four) -Print "three + four -> "; churchToNum(churchSum(three, four)) -Print "three * four -> "; churchToNum(churchMul(three, four)) -Print "three ^ four -> "; churchToNum(churchPow(three, four)) -Print "four ^ three -> "; churchToNum(churchPow(four, three)) -Print "5 -> five -> "; churchToNum(numToChurch(5)) - -Sleep diff --git a/Task/Church-numerals/Go/church-numerals-2.go b/Task/Church-numerals/Go/church-numerals-2.go deleted file mode 100644 index 0b8a0724a4..0000000000 --- a/Task/Church-numerals/Go/church-numerals-2.go +++ /dev/null @@ -1,88 +0,0 @@ -package main - -import "fmt" - -type Church func(Church) Church - -func id[X any](x X) X { - return x -} - -func compose[X any, Y any, Z any](f func(Y) Z, g func(X) Y) func(X) Z { - return func(x X) Z { - return f(g(x)) - } -} - -func zero() Church { - return func(f Church) Church { - return id[Church] - } -} - -func one() Church { - return id[Church] -} - -func succ(n Church) Church { - return func(f Church) Church { - return compose(f, n(f)) - } -} - -func plus(m, n Church) Church { - return func(f Church) Church { - return compose(m(f), n(f)) - } -} - -func mult(m, n Church) Church { - return compose(m, n) -} - -func exp(m, n Church) Church { - return n(m) -} - -func toInt(x Church) int { - counter := 0 - fCounter := func(f Church) Church { - counter++ - return f - } - - x(fCounter)(id[Church]) - return counter -} - -func toStr(x Church) string { - counter := "" - fCounter := func(f Church) Church { - counter += "|" - return f - } - - x(fCounter)(id[Church]) - return counter -} - -func main() { - fmt.Println("zero =", toInt(zero())) - - one := one() - fmt.Println("one =", toInt(one)) - - two := succ(succ(zero())) - fmt.Println("two =", toInt(two)) - - three := plus(one, two) - fmt.Println("three =", toInt(three)) - - four := mult(two, two) - fmt.Println("four =", toInt(four)) - - eight := exp(two, three) - fmt.Println("eight =", toInt(eight)) - - fmt.Println("toStr(four) =", toStr(four)) -} diff --git a/Task/Church-numerals/Go/church-numerals-1.go b/Task/Church-numerals/Go/church-numerals.go similarity index 100% rename from Task/Church-numerals/Go/church-numerals-1.go rename to Task/Church-numerals/Go/church-numerals.go diff --git a/Task/Church-numerals/Julia/church-numerals-1.jl b/Task/Church-numerals/Julia/church-numerals-1.julia similarity index 100% rename from Task/Church-numerals/Julia/church-numerals-1.jl rename to Task/Church-numerals/Julia/church-numerals-1.julia diff --git a/Task/Church-numerals/Julia/church-numerals-2.jl b/Task/Church-numerals/Julia/church-numerals-2.julia similarity index 100% rename from Task/Church-numerals/Julia/church-numerals-2.jl rename to Task/Church-numerals/Julia/church-numerals-2.julia diff --git a/Task/Church-numerals/OCaml/church-numerals.ml b/Task/Church-numerals/OCaml/church-numerals.ocaml similarity index 100% rename from Task/Church-numerals/OCaml/church-numerals.ml rename to Task/Church-numerals/OCaml/church-numerals.ocaml diff --git a/Task/Church-numerals/Phix/church-numerals.phix b/Task/Church-numerals/Phix/church-numerals.phix index 3f885e80e9..3765569a3c 100644 --- a/Task/Church-numerals/Phix/church-numerals.phix +++ b/Task/Church-numerals/Phix/church-numerals.phix @@ -1,86 +1,91 @@ -with javascript_semantics +(phixonline)--> + with javascript_semantics -type church(object c) --- eg {r_add,1,{a,b}} - return sequence(c) and length(c)=3 - and integer(c[1]) and integer(c[2]) - and sequence(c[3]) and length(c[3])=2 -end type + type church(object c) + -- eg {r_add,1,{a,b}} + return sequence(c) and length(c)=3 + and integer(c[1]) and integer(c[2]) + and sequence(c[3]) and length(c[3])=2 + end type -function succ(church c) --- eg {add,1,{a,b}} => {add,2,{a,b}} aka a+b => a+b+b - c = deep_copy(c) - c[2] += 1 - return c -end function + function succ(church c) + -- eg {r_add,1,{a,b}} => {r_add,2,{a,b}} aka a+b -> a+b+b + c = deep_copy(c) + c[2] += 1 + return c + end function --- three normal integer-handling routines... -function add(integer n, a, b) - for i=1 to n do - a += b - end for - return a -end function + -- three normal integer-handling routines... + function add(integer n, a, b) + for i=1 to n do + a += b + end for + return a + end function + constant r_add = routine_id("add") -function mul(integer n, a, b) - for i=1 to n do - a *= b - end for - return a -end function + function mul(integer n, a, b) + for i=1 to n do + a *= b + end for + return a + end function + constant r_mul = routine_id("mul") -function pow(integer n, a, b) - for i=1 to n do - a = power(a,b) - end for - return a -end function + function pow(integer n, a, b) + for i=1 to n do + a = power(a,b) + end for + return a + end function + constant r_pow = routine_id("pow") --- ...and three church constructors to match --- (no maths here, just pure static data) -function addch(church c, d) - church res = {add,1,{c,d}} - return res -end function + -- ...and three church constructors to match + -- (no maths here, just pure static data) + function addch(church c, d) + church res = {r_add,1,{c,d}} + return res + end function -function mulch(church c, d) - church res = {mul,1,{c,d}} - return res -end function + function mulch(church c, d) + church res = {r_mul,1,{c,d}} + return res + end function -function powch(church c, d) - church res = {pow,1,{c,d}} - return res -end function + function powch(church c, d) + church res = {r_pow,1,{c,d}} + return res + end function -function tointch(church c) --- note this is where the bulk of any processing happens - {integer rid, integer n, object x} = c - x = deep_copy(x) - for i=1 to length(x) do - if church(x[i]) then x[i] = tointch(x[i]) end if - end for --- return call_func(rid,n&x) - x = deep_copy({n})&deep_copy(x) - return call_func(rid,x) -end function + function tointch(church c) + -- note this is where the bulk of any processing happens + {integer rid, integer n, object x} = c + x = deep_copy(x) + for i=1 to length(x) do + if church(x[i]) then x[i] = tointch(x[i]) end if + end for + -- return call_func(rid,n&x) + x = deep_copy({n})&deep_copy(x) + return call_func(rid,x) + end function -constant church zero = {add,0,{0,1}} + constant church zero = {r_add,0,{0,1}} -function inttoch(integer i) - if i=0 then - return zero - else - return succ(inttoch(i-1)) - end if -end function + function inttoch(integer i) + if i=0 then + return zero + else + return succ(inttoch(i-1)) + end if + end function -church three = succ(succ(succ(zero))), - four = succ(three) -printf(1,"three -> %d\n",tointch(three)) -printf(1,"four -> %d\n",tointch(four)) -printf(1,"three + four -> %d\n",tointch(addch(three,four))) -printf(1,"three * four -> %d\n",tointch(mulch(three,four))) -printf(1,"three ^ four -> %d\n",tointch(powch(three,four))) -printf(1,"four ^ three -> %d\n",tointch(powch(four,three))) -printf(1,"5 -> five -> %d\n",tointch(inttoch(5))) + church three = succ(succ(succ(zero))), + four = succ(three) + printf(1,"three -> %d\n",tointch(three)) + printf(1,"four -> %d\n",tointch(four)) + printf(1,"three + four -> %d\n",tointch(addch(three,four))) + printf(1,"three * four -> %d\n",tointch(mulch(three,four))) + printf(1,"three ^ four -> %d\n",tointch(powch(three,four))) + printf(1,"four ^ three -> %d\n",tointch(powch(four,three))) + printf(1,"5 -> five -> %d\n",tointch(inttoch(5))) + + with javascript_semantics + constant tests = {{0.1234, 0.9876, 0.8765, 0.2345, 2.0}, + {0.0000, 2.0000, 0.0000, 0.0000, 1.0}, + {0.1234, 0.9876, 0.1234, 0.9876, 2.0}, + {0.1234, 0.9876, 0.8765, 0.2345, 0.5}, + {0.1234, 0.9876, 0.1234, 0.9876, 0.0}} + for i=1 to length(tests) do + atom {x1,y1,x2,y2,r} = tests[i], + xd = x2-x1, yd = y1-y2, + s2 = xd*xd+yd*yd, sep = sqrt(s2), + xh = (x1+x2)/2, yh = (y1+y2)/2 + string txt + if sep=0 then + txt = "same points/"&iff(r=0?"radius is zero":"infinite solutions") + elsif sep=2*r then + txt = sprintf("opposite ends of diameter with centre {%.4f,%.4f}",{xh,yh}) + elsif sep>2*r then + txt = sprintf("too far apart (%.4f > %.4f)",{sep,2*r}) + else + atom md = sqrt(r*r-s2/4), xs = md*xd/sep, ys = md*yd/sep + txt = sprintf("{%.4f,%.4f} and {%.4f,%.4f}",{xh+ys,yh+xs,xh-ys,yh-xs}) + end if + printf(1,"points {%.4f,%.4f}, {%.4f,%.4f} with radius %.1f ==> %s\n",{x1,y1,x2,y2,r,txt}) + end for + + with javascript_semantics + function circular(integer p) + integer len = length(sprintf("%d",p)), + pow = power(10,len-1), + p0 = p + for i=1 to len-1 do + p = pow*remainder(p,10)+floor(p/10) + if p<p0 or not is_prime(p) then return false end if + end for + return true + end function -sequence c = {} -integer n = 1 -while length(c)<19 do - integer p = get_prime(n) - if circular(p) then c &= p end if - n += 1 -end while -printf(1,"The first 19 circular primes are:\n%v\n\n",{c}) + sequence c = {} + integer n = 1 + while length(c)<19 do + integer p = get_prime(n) + if circular(p) then c &= p end if + n += 1 + end while + printf(1,"The first 19 circular primes are:\n%v\n\n",{c}) -include mpfr.e -c = {} -n = 7 -mpz z = mpz_init() -while length(c)<4 do - mpz_set_str(z,repeat('1',n)) - if mpz_prime(z) then - c = append(c,sprintf("R(%d)",n)) - end if - n += 1 -end while -printf(1,"The next 4 circular primes, in repunit format, are:\n%s\n\n",{join(c)}) + include mpfr.e + procedure repunit(mpz z, integer n) + mpz_set_str(z,repeat('1',n)) + end procedure + + c = {} + n = 7 + mpz z = mpz_init() + while length(c)<4 do + repunit(z,n) + if mpz_prime(z) then + c = append(c,sprintf("R(%d)",n)) + end if + n += 1 + end while + printf(1,"The next 4 circular primes, in repunit format, are:\n%s\n\n",{join(c)}) + + constant t = {5003, 9887, 15073, 25031, 35317, 49081} + printf(1,"The following repunits are probably circular primes:\n") + for i=1 to length(t) do + integer ti = t[i] + atom t0 = time() + repunit(z,ti) + bool bPrime = mpz_prime(z,1) + printf(1,"R(%d) : %t (%s)\n", {ti, bPrime, elapsed(time()-t0)}) + end for + + with javascript_semantics + function bruteForceClosestPair(sequence s) + atom {x1,y1} = s[1], {x2,y2} = s[2], + dx = x1-x2, dy = y1-y2, + mind = dx*dx+dy*dy + sequence minp = s[1..2] + for i=1 to length(s)-1 do + {x1,y1} = s[i] + for j=i+1 to length(s) do + {x2,y2} = s[j] + dx = x1-x2 + dx = dx*dx + if dx<mind then + dy = y1-y2 + dx += dy*dy + if dx<mind then + mind = dx + minp = {s[i],s[j]} + end if + end if + end for + end for + return {sqrt(mind),minp} + end function -sequence testset = sq_rnd(repeat({1,1},10000)) -atom t0 = time() -atom {d, {{x1,y1},{x2,y2}}} = bruteForceClosestPair(testset) --- (Sorting the final point pair makes brute/dc more likely to tally. Note however --- when >1 equidistant pairs exist, brute and dc may well return different pairs; --- it is only a problem if they decide to return different minimum distances.) -printf(1,"Closest pair: {%f,%f} {%f,%f}, distance=%f (%3.2fs)\n",{x1,y2,x2,y2,d,time()-t0}) + sequence testset = sq_rnd(repeat({1,1},10000)) + atom t0 = time() + {atom d, sequence points} = bruteForceClosestPair(testset) + -- (Sorting the final point pair makes brute/dc more likely to tally. Note however + -- when >1 equidistant pairs exist, brute and dc may well return different pairs; + -- it is only a problem if they decide to return different minimum distances.) + atom {{x1,y1},{x2,y2}} = sort(deep_copy(points)) + printf(1,"Closest pair: {%f,%f} {%f,%f}, distance=%f (%3.2fs)\n",{x1,y2,x2,y2,d,time()-t0}) -t0 = time() -constant X = 1, Y = 2 -sequence xP = sort(deep_copy(testset)), - yP = sort_columns(deep_copy(testset),{Y}) + t0 = time() + constant X = 1, Y = 2 + sequence xP = sort(deep_copy(testset)) -function distsq(sequence p1,p2) - atom {x1,y1} = p1, {x2,y2} = p2 - x1 -= x2 - y1 -= y2 - return x1*x1 + y1*y1 -end function + function byY(sequence p1, p2) + return compare(p1[Y],p2[Y]) + end function + sequence yP = custom_sort(routine_id("byY"),deep_copy(testset)) -function closestPair(sequence xP, yP) --- where xP is P(1) .. P(N) sorted by x coordinate, and --- yP is P(1) .. P(N) sorted by y coordinate (ascending order) - integer N = length(xP), - midN = floor(N/2) - assert(length(yP)=N) - if N<=3 then - return bruteForceClosestPair(xP) - end if - sequence xL = xP[1..midN], - xR = xP[midN+1..N], - yL = {}, - yR = {} - atom xm = xP[midN][X] - for yi in yP do - if yi[X]<=xm then - yL = append(yL,yi) - else - yR = append(yR,yi) - end if - end for - {atom dmin, sequence pairMin} = min(closestPair(xL, yL), - closestPair(xR, yR)) - sequence yS = {} - for yi in yP do - if abs(xm-yi[X])=dmin then exit end if - d = distsq(yk,yi) - if dfunction distsq(sequence p1,p2) + atom {x1,y1} = p1, {x2,y2} = p2 + x1 -= x2 + y1 -= y2 + return x1*x1 + y1*y1 + end function -{d,{{x1,y1},{x2,y2}}} = closestPair(xP,yP) -printf(1,"Closest pair: {%f,%f} {%f,%f}, distance=%f (%3.2fs)\n",{x1,y2,x2,y2,d,time()-t0}) + function closestPair(sequence xP, yP) + -- where xP is P(1) .. P(N) sorted by x coordinate, and + -- yP is P(1) .. P(N) sorted by y coordinate (ascending order) + integer N = length(xP), + midN = floor(N/2) + assert(length(yP)=N) + if N<=3 then + return bruteForceClosestPair(xP) + end if + sequence xL = xP[1..midN], + xR = xP[midN+1..N], + yL = {}, + yR = {} + atom xm = xP[midN][X] + for i=1 to N do + if yP[i][X]<=xm then + yL = append(yL,yP[i]) + else + yR = append(yR,yP[i]) + end if + end for + {atom dL, sequence pairL} = closestPair(xL, yL) + {atom dR, sequence pairR} = closestPair(xR, yR) + {atom dmin, sequence pairMin} = min({dL, pairL},{dR, pairR}) + sequence yS = {} + for i=1 to length(yP) do + if abs(xm-yP[i][X])<dmin then + yS = append(yS,yP[i]) + end if + end for + integer nS = length(yS) + {atom closest, sequence cPair} = {dmin*dmin, pairMin} + for i=1 to nS-1 do + integer k = i + 1 + while k<=nS and (yS[k][Y]-yS[i][Y])<dmin do + d = distsq(yS[k],yS[i]) + if d<closest then + {closest, cPair} = {d, {yS[k], yS[i]}} + end if + k += 1 + end while + end for + return {sqrt(closest), cPair} + end function + + {d,points} = closestPair(xP,yP) + {{x1,y1},{x2,y2}} = sort(deep_copy(points)) -- (see note above) + printf(1,"Closest pair: {%f,%f} {%f,%f}, distance=%f (%3.2fs)\n",{x1,y2,x2,y2,d,time()-t0}) + with javascript_semantics sequence collection = {} collection = append(collection,"one") collection = prepend(collection,2) ? collection -- {2,"one"} + with javascript_semantics setd("one",0) setd(2,0) @@ -7,3 +7,4 @@ return 1 end function traverse_dict(routine_id("visitor")) -- shows 2, "one" + + with javascript_semantics + function colourful(integer n) + if n<10 then return n>=0 end if + sequence digits = sq_sub(sprintf("%d",n),'0'), + ud = unique(deep_copy(digits)) + integer ln = length(digits) + if ud[1]<=1 or length(ud)!=ln then return false end if + for i=1 to ln-1 do + for j=i+1 to ln do + atom prod = product(digits[i..j]) + if find(prod,ud) then return false end if + ud &= prod + end for + end for + return true + end function -atom t0 = time() -sequence cn = apply(true,sprintf,{{"%2d"},filter(tagset(100,0),colourful)}) -printf(1,"The %d colourful numbers less than 100 are:\n%s\n", - {length(cn),join_by(cn,1,10," ")}) + atom t0 = time() + sequence cn = apply(true,sprintf,{{"%2d"},filter(tagset(100,0),colourful)}) + printf(1,"The %d colourful numbers less than 100 are:\n%s\n", + {length(cn),join_by(cn,1,10," ")}) -sequence count = repeat(0,8), - used = repeat(false,10) -integer largestcn = 0 + sequence count = repeat(0,8), + used = repeat(false,10) + integer largestcn = 0 -procedure count_colourful(integer taken=0, string n="") - if taken=0 then - for digit='0' to '9' do - integer dx = digit-'0'+1 - used[dx] = true - count_colourful(iff(digit<'2'?9:1),""&digit) - used[dx] = false - end for - else - integer nn = to_integer(n) - if colourful(nn) then - integer ln = length(n) - count[ln] += 1 - if nn>largestcn then largestcn = nn end if - end if - if taken<9 then - for digit='2' to '9' do - integer dx = digit-'0'+1 - if not used[dx] then - used[dx] = true - count_colourful(taken+1,n&digit) - used[dx] = false - end if - end for - end if - end if -end procedure -count_colourful() -printf(1,"The largest possible colourful number is: %,d\n\n",largestcn) -atom pow = 10 -for dc=1 to length(count) do - printf(1," %d digit colourful number count: %,6d - %7.3f%%\n", - {dc, count[dc], 100*count[dc]/pow}) - pow = iff(pow=10?90:pow*10) -end for -printf(1,"\nTotal colourful numbers: %,d\n", sum(count)) -?elapsed(time()-t0) + procedure count_colourful(integer taken=0, string n="") + if taken=0 then + for digit='0' to '9' do + integer dx = digit-'0'+1 + used[dx] = true + count_colourful(iff(digit<'2'?9:1),""&digit) + used[dx] = false + end for + else + integer nn = to_integer(n) + if colourful(nn) then + integer ln = length(n) + count[ln] += 1 + if nn>largestcn then largestcn = nn end if + end if + if taken<9 then + for digit='2' to '9' do + integer dx = digit-'0'+1 + if not used[dx] then + used[dx] = true + count_colourful(taken+1,n&digit) + used[dx] = false + end if + end for + end if + end if + end procedure + count_colourful() + printf(1,"The largest possible colourful number is: %,d\n\n",largestcn) + atom pow = 10 + for dc=1 to length(count) do + printf(1," %d digit colourful number count: %,6d - %7.3f%%\n", + {dc, count[dc], 100*count[dc]/pow}) + pow = iff(pow=10?90:pow*10) + end for + printf(1,"\nTotal colourful numbers: %,d\n", sum(count)) + ?elapsed(time()-t0) + n ) - - [ dip dup - ! dip ! / ] is p ( n n --> n ) - - [ tuck p swap ! / ] is c ( n n --> n ) - - ' [ [ 1 0 ] [ 12 4 ] [ 60 20 ] [ 105 103 ] [ 15000 333 ] ] - witheach - [ unpack 2dup - say " P(" - swap echo say "," echo - say ") = " - p shorten echo$ cr ] - cr - ' [ [ 10 5 ] [ 60 30 ] [ 50 48 ] [ 900 675 ] [ 970 730 ] ] - witheach - [ unpack 2dup - say " C(" - swap echo say "," echo - say ") = " - c shorten echo$ cr ] diff --git a/Task/Combinations-and-permutations/Rust/combinations-and-permutations.rs b/Task/Combinations-and-permutations/Rust/combinations-and-permutations.rs deleted file mode 100644 index ef42c1512d..0000000000 --- a/Task/Combinations-and-permutations/Rust/combinations-and-permutations.rs +++ /dev/null @@ -1,34 +0,0 @@ -fn perm(n: f64, k: f64) -> f64 { - let mut result: f64 = 1.0; - let mut i: f64 = 0.0; - - while i < k { - result *= n - i; - i += 1.0; - } - - result -} - -fn comb(n: f64, k: f64) -> f64 { - perm(n, k) / perm(k, k) -} - -fn main() { - const P: f64 = 12.0; - const C: f64 = 60.0; - - let mut j: f64 = 1.0; - let mut k: f64 = 10.0; - - while j < P { - println!("P({},{}) = {}", P, j, perm(P, j).floor()); - j += 1.0; - } - - while k < C { - println!("C({},{}) = {}", C, k, comb(C, k).floor()); - k += 10.0; - } - -} diff --git a/Task/Combinations-and-permutations/Scheme/combinations-and-permutations.scm b/Task/Combinations-and-permutations/Scheme/combinations-and-permutations.ss similarity index 100% rename from Task/Combinations-and-permutations/Scheme/combinations-and-permutations.scm rename to Task/Combinations-and-permutations/Scheme/combinations-and-permutations.ss diff --git a/Task/Combinations-and-permutations/Uiua/combinations-and-permutations.uiua b/Task/Combinations-and-permutations/Uiua/combinations-and-permutations.uiua deleted file mode 100644 index ec81fca266..0000000000 --- a/Task/Combinations-and-permutations/Uiua/combinations-and-permutations.uiua +++ /dev/null @@ -1,15 +0,0 @@ -P ← /×+1˜↙⇡⊙¯ # Simple Perm calc. -C ← ÷/×+1⇡⤙P # Simple Comb calc. -# Better version: casts out common factors first. -C ← ( - AllFactors ← map⊕(⊃⊢⧻)⊸⊛▽⊸>₁/⊂(°/×) - ⊃(+1⇡◌|+1˜↙⇡⊙¯) # Collect numerator, denominator terms. - ⍆◴⊂◡∩(⊙◌°map)∩AllFactors # Identify common factors. - /×ⁿ⤚(-∩⌞≡⬚0get⊙¤⊙⊙¤) # Cast out, mult -) -≡⌞P 12 ↘1⇡12 -≡⌞C 60 ×10↘1⇡6 - -P 105 103 -P 15000 333 -C 900 674 diff --git a/Task/Combinations-and-permutations/VBScript/combinations-and-permutations.vbs b/Task/Combinations-and-permutations/VBScript/combinations-and-permutations.vb similarity index 100% rename from Task/Combinations-and-permutations/VBScript/combinations-and-permutations.vbs rename to Task/Combinations-and-permutations/VBScript/combinations-and-permutations.vb diff --git a/Task/Combinations-and-permutations/Wren/combinations-and-permutations.wren b/Task/Combinations-and-permutations/Wren/combinations-and-permutations.wren index 5577af47a2..352e2b0af1 100644 --- a/Task/Combinations-and-permutations/Wren/combinations-and-permutations.wren +++ b/Task/Combinations-and-permutations/Wren/combinations-and-permutations.wren @@ -1,6 +1,6 @@ -import "./big" for BigInt -import "./fmt" for Fmt -import "./iterate" for Stepped +import "/big" for BigInt +import "/fmt" for Fmt +import "/iterate" for Stepped var perm = Fn.new { |n, k| if (n <= 0 || k < 0) Fiber.abort("Invalid argument(s).") diff --git a/Task/Combinations-and-permutations/Zig/combinations-and-permutations.zig b/Task/Combinations-and-permutations/Zig/combinations-and-permutations.zig deleted file mode 100644 index 63ea74739c..0000000000 --- a/Task/Combinations-and-permutations/Zig/combinations-and-permutations.zig +++ /dev/null @@ -1,32 +0,0 @@ - const std = @import("std"); - const num = f64; - - pub fn perm(n: num, k: num) num { - var result: num = 1; - var i: num = 0; - while (i < k) : (i += 1) { - result *= n - i; - } - return result; - } - - pub fn comb(n: num, k: num) num { - return perm(n, k) / perm(k, k); - } - - pub fn main() !void { - var stdout = std.io.getStdOut().writer(); - - const p: num = 12; - const c: num = 60; - var j: num = 1; - var k: num = 10; - - while (j < p) : (j += 1) { - try stdout.print("P({d},{d}) = {d}\n", .{ p, j, @floor(perm(p, j)) }); - } - - while (k < c) : (k += 10) { - try stdout.print("C({d},{d}) = {d}\n", .{ c, k, @floor(comb(c, k)) }); - } - } diff --git a/Task/Combinations-with-repetitions/Acornsoft-Lisp/combinations-with-repetitions.lisp b/Task/Combinations-with-repetitions/Acornsoft-Lisp/combinations-with-repetitions.lisp deleted file mode 100644 index 9c4ae3114a..0000000000 --- a/Task/Combinations-with-repetitions/Acornsoft-Lisp/combinations-with-repetitions.lisp +++ /dev/null @@ -1,17 +0,0 @@ -(defun samples (k items) - (cond - ((zerop k) '(())) - ((null items) '()) - (t (append - (mapc '(lambda (c) (cons (car items) c)) - (samples (sub1 k) items)) - (samples k (cdr items)))))) - -(defun append (a b) - (cond ((null a) b) - (t (cons (car a) (append (cdr a) b))))) - -(defun length (list (len . 0)) - (map '(lambda (e) (setq len (add1 len))) - list) - len) diff --git a/Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.adb b/Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.ada similarity index 100% rename from Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.adb rename to Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.ada diff --git a/Task/Combinations-with-repetitions/Crystal/combinations-with-repetitions.cr b/Task/Combinations-with-repetitions/Crystal/combinations-with-repetitions.crystal similarity index 100% rename from Task/Combinations-with-repetitions/Crystal/combinations-with-repetitions.cr rename to Task/Combinations-with-repetitions/Crystal/combinations-with-repetitions.crystal diff --git a/Task/Combinations-with-repetitions/DuckDB/combinations-with-repetitions.duckdb b/Task/Combinations-with-repetitions/DuckDB/combinations-with-repetitions.duckdb deleted file mode 100644 index b2312e949b..0000000000 --- a/Task/Combinations-with-repetitions/DuckDB/combinations-with-repetitions.duckdb +++ /dev/null @@ -1,49 +0,0 @@ -create or replace function choose(lst,k) as table ( - with recursive cte as ( - select 0 as ix, - lst[0:0] as combination -- i.e. an empty array of the correct type - union all - select ix+1, combination || [ lst[j] ] - from cte, range(ix+1, 1+length(lst) ) _(j) - where length(combination) < k - ) - select combination - from cte - where ix = k -); - -# Assume 0 0 - s$ = "" - for i = 1 to k - s$ &= items$[result[i]] & " " - . - print s$ - . +proc combine pos val . . + if pos > k + call output + else + for i = val to n + result[pos] = i + call combine pos + 1 i + . + . . -proc combine pos val . - if pos > k - output - else - for i = val to n - result[pos] = i - combine pos + 1 i - . - . -. -combine 1 1 +call combine 1 1 # n = 10 k = 3 len result[] k items$[] = [ ] n_results = 0 -combine 1 1 +call combine 1 1 print "" print n_results & " results with 10 donuts" diff --git a/Task/Combinations-with-repetitions/Elixir/combinations-with-repetitions.ex b/Task/Combinations-with-repetitions/Elixir/combinations-with-repetitions.elixir similarity index 100% rename from Task/Combinations-with-repetitions/Elixir/combinations-with-repetitions.ex rename to Task/Combinations-with-repetitions/Elixir/combinations-with-repetitions.elixir diff --git a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq index bb25c96913..3972206ac5 100644 --- a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq +++ b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq @@ -6,5 +6,3 @@ def pick(n): else ([.[m]] + pick(n-1; m)), pick(n; m+1) end; pick(n;0) ; - -def count(s): reduce s as $_ (0; .+1); diff --git a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq index 50f06bd1e4..6c2692b448 100644 --- a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq +++ b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq @@ -1,4 +1,4 @@ -"Pick 2:", + "Pick 2:", (["iced", "jam", "plain"] | pick(2)), - (count( [range(0;10)] | pick(3)) as $n - | "There are \($n) ways to pick 3 objects with replacement from 10.") + ([[range(0;10)] | pick(3)] | length) as $n + | "There are \($n) ways to pick 3 objects with replacement from 10." diff --git a/Task/Combinations-with-repetitions/Julia/combinations-with-repetitions.jl b/Task/Combinations-with-repetitions/Julia/combinations-with-repetitions.julia similarity index 100% rename from Task/Combinations-with-repetitions/Julia/combinations-with-repetitions.jl rename to Task/Combinations-with-repetitions/Julia/combinations-with-repetitions.julia diff --git a/Task/Combinations-with-repetitions/Kotlin/combinations-with-repetitions.kts b/Task/Combinations-with-repetitions/Kotlin/combinations-with-repetitions.kotlin similarity index 100% rename from Task/Combinations-with-repetitions/Kotlin/combinations-with-repetitions.kts rename to Task/Combinations-with-repetitions/Kotlin/combinations-with-repetitions.kotlin diff --git a/Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-1.ml b/Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-1.ocaml similarity index 100% rename from Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-1.ml rename to Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-1.ocaml diff --git a/Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-2.ml b/Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-2.ocaml similarity index 100% rename from Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-2.ml rename to Task/Combinations-with-repetitions/OCaml/combinations-with-repetitions-2.ocaml diff --git a/Task/Combinations-with-repetitions/PascalABC.NET/combinations-with-repetitions.pas b/Task/Combinations-with-repetitions/PascalABC.NET/combinations-with-repetitions.pas deleted file mode 100644 index be42b9c098..0000000000 --- a/Task/Combinations-with-repetitions/PascalABC.NET/combinations-with-repetitions.pas +++ /dev/null @@ -1,8 +0,0 @@ -## -var t:=|'iced', 'jam', 'plain'|; -var p:=t.CartesianPower(2).Where(t->t[0]<=t[1]); -write($'{p.Count}'); -Print(':'); -p.Println; -write((1..10).CartesianPower(3).Where(t->(t[0]<=t[1])and(t[1]<=t[2])).count); -Print(': Choices of 3 from 10'); diff --git a/Task/Combinations-with-repetitions/Phix/combinations-with-repetitions-3.phix b/Task/Combinations-with-repetitions/Phix/combinations-with-repetitions-3.phix deleted file mode 100644 index 345317e20b..0000000000 --- a/Task/Combinations-with-repetitions/Phix/combinations-with-repetitions-3.phix +++ /dev/null @@ -1,4 +0,0 @@ -(phixonline)--> - ?join(combinations_with_repetitions("ijp",2),',') - ?length(combinations_with_repetitions(tagset(10),3)) - - ?join(combinations("12345",3),',') - n ) + + [ [] unrot + bit times + [ i bits + over = if + [ dip + [ i join ] ] ] + drop ] is combnums ( n n --> [ ) + + [ [] 0 rot + [ dup 0 != while + dup 1 & if + [ dip + [ dup dip join ] ] + dip 1+ + 1 >> + again ] + 2drop ] is makecomb ( n --> [ ) + [ over 0 = iff - [ 2drop ' [ [ ] ] ] - done - dup [] = iff nip done - 1 split rot tuck - 1 - over recurse - dip [ rot [] ] - witheach - [ dip over join - nested join ] - nip unrot recurse join ] is comb ( n [ --> [ ) + [ 2drop [] ] done + combnums + [] swap witheach + [ makecomb + nested join ] ] is comb ( n n --> [ ) - [ [] swap times - [ i^ join ] - comb - witheach - [ witheach - [ echo sp ] - cr ] ] is task ( n n --> ) + [ behead swap witheach max ] is largest ( [ --> n ) - 3 5 task + [ 0 rot witheach + [ [ dip [ over * ] ] + ] + nip ] is comborder ( [ n --> n ) + + [ dup [] != while + sortwith + [ 2dup join + largest 1+ dup dip + [ comborder swap ] + comborder < ] ] is sortcombs ( [ --> [ ) + + 3 5 comb + sortcombs + witheach [ witheach [ echo sp ] cr ] diff --git a/Task/Combinations/Quackery/combinations-2.quackery b/Task/Combinations/Quackery/combinations-2.quackery index 697808559d..5626470d75 100644 --- a/Task/Combinations/Quackery/combinations-2.quackery +++ b/Task/Combinations/Quackery/combinations-2.quackery @@ -1,48 +1,31 @@ - [ 0 swap - [ dup 0 != while - dup 1 & if - [ dip 1+ ] - 1 >> again ] - drop ] is bits ( n --> n ) + [ stack ] is comb.stack + [ stack ] is comb.items + [ stack ] is comb.required + [ stack ] is comb.result - [ [] unrot - bit times - [ i bits - over = if - [ dip - [ i join ] ] ] - drop ] is combnums ( n n --> [ ) - - [ [] 0 rot - [ dup 0 != while - dup 1 & if - [ dip - [ dup dip join ] ] - dip 1+ - 1 >> - again ] - 2drop ] is makecomb ( n --> [ ) - - [ over 0 = iff - [ 2drop [] ] done - combnums - [] swap witheach - [ makecomb - nested join ] ] is comb ( n n --> [ ) - - [ behead swap witheach max ] is largest ( [ --> n ) - - [ 0 rot witheach - [ [ dip [ over * ] ] + ] - nip ] is comborder ( [ n --> n ) - - [ dup [] != while - sortwith - [ 2dup join - largest 1+ dup dip - [ comborder swap ] - comborder < ] ] is sortcombs ( [ --> [ ) + [ 1 - comb.items put + 1+ comb.required put + 0 comb.stack put + [] comb.result put + [ comb.required share + comb.stack size = if + [ comb.result take + comb.stack behead + drop nested join + comb.result put ] + comb.stack take + dup comb.items share + = iff + [ drop + comb.stack size 1 > iff + [ 1 comb.stack tally ] ] + else + [ dup comb.stack put + 1+ comb.stack put ] + comb.stack size 1 = until ] + comb.items release + comb.required release + comb.result take ] is comb ( n n --> ) 3 5 comb - sortcombs witheach [ witheach [ echo sp ] cr ] diff --git a/Task/Combinations/Quackery/combinations-3.quackery b/Task/Combinations/Quackery/combinations-3.quackery index 5626470d75..721a651555 100644 --- a/Task/Combinations/Quackery/combinations-3.quackery +++ b/Task/Combinations/Quackery/combinations-3.quackery @@ -1,31 +1,16 @@ - [ stack ] is comb.stack - [ stack ] is comb.items - [ stack ] is comb.required - [ stack ] is comb.result - - [ 1 - comb.items put - 1+ comb.required put - 0 comb.stack put - [] comb.result put - [ comb.required share - comb.stack size = if - [ comb.result take - comb.stack behead - drop nested join - comb.result put ] - comb.stack take - dup comb.items share - = iff - [ drop - comb.stack size 1 > iff - [ 1 comb.stack tally ] ] - else - [ dup comb.stack put - 1+ comb.stack put ] - comb.stack size 1 = until ] - comb.items release - comb.required release - comb.result take ] is comb ( n n --> ) + [ dup size dip + [ witheach + [ over swap peek swap ] ] + nip pack ] is arrange ( [ [ --> [ ) + ' [ 10 20 30 40 50 ] 3 5 comb - witheach [ witheach [ echo sp ] cr ] + witheach + [ dip dup arrange + witheach [ echo sp ] + cr ] + drop + cr + $ "zero one two three four" nest$ + ' [ 4 3 1 0 1 4 3 ] arrange + witheach [ echo$ sp ] diff --git a/Task/Combinations/Quackery/combinations-4.quackery b/Task/Combinations/Quackery/combinations-4.quackery deleted file mode 100644 index 721a651555..0000000000 --- a/Task/Combinations/Quackery/combinations-4.quackery +++ /dev/null @@ -1,16 +0,0 @@ - [ dup size dip - [ witheach - [ over swap peek swap ] ] - nip pack ] is arrange ( [ [ --> [ ) - - ' [ 10 20 30 40 50 ] - 3 5 comb - witheach - [ dip dup arrange - witheach [ echo sp ] - cr ] - drop - cr - $ "zero one two three four" nest$ - ' [ 4 3 1 0 1 4 3 ] arrange - witheach [ echo$ sp ] diff --git a/Task/Combinations/REXX/combinations-2.rexx b/Task/Combinations/REXX/combinations-2.rexx deleted file mode 100644 index e5a275eaf5..0000000000 --- a/Task/Combinations/REXX/combinations-2.rexx +++ /dev/null @@ -1,47 +0,0 @@ -/*REXX program displays combination sets for X things taken Y at a time. */ -Parse Arg things size characters -If things='?' Then Do - Say 'rexx combi2 things size characters' - Say ' defaults: 5 3 123456789...' - Say 'example rexx combi2 , , xyzuvw' - Say 'size<0 shows only the number of possible combinations' - Exit - End -If things==''|things=="," Then things=5 /* No things specified? Then use default*/ -If size=='' |size=="," Then size=3 /* No size specified? Then use default*/ -Numeric Digits 20 -show=sign(size) -size=abs(size) -If things'' then - c=substr(characters,i,1) - Else - c=i - If substr(ub,i,1)=1 Then res=res c - End - If show=1 then - Say res - Return 1 - End - Else - Return 0 -exit: - Say '*****error*****' arg(1) - Exit 13 diff --git a/Task/Combinations/REXX/combinations-1.rexx b/Task/Combinations/REXX/combinations.rexx similarity index 100% rename from Task/Combinations/REXX/combinations-1.rexx rename to Task/Combinations/REXX/combinations.rexx diff --git a/Task/Combinations/Refal/combinations.refal b/Task/Combinations/Refal/combinations.refal deleted file mode 100644 index 8b8d5ce984..0000000000 --- a/Task/Combinations/Refal/combinations.refal +++ /dev/null @@ -1,23 +0,0 @@ -$ENTRY Go { - = >; -}; - -Comb { - s.M s.N = >>; -}; - -Comb1 { - 0 e.X = (); - s.M = ; - s.M s.X e.X = e.X>> ; -}; - -PfxEach { - s.X = ; - s.X (e.X) e.Y = (s.X e.X) ; -}; - -Iota { - s.E s.E = s.E; - s.S s.E = s.S s.E>; -}; diff --git a/Task/Combinations/Rust/combinations-1.rs b/Task/Combinations/Rust/combinations-1.rust similarity index 100% rename from Task/Combinations/Rust/combinations-1.rs rename to Task/Combinations/Rust/combinations-1.rust diff --git a/Task/Combinations/Rust/combinations-2.rs b/Task/Combinations/Rust/combinations-2.rust similarity index 100% rename from Task/Combinations/Rust/combinations-2.rs rename to Task/Combinations/Rust/combinations-2.rust diff --git a/Task/Combinations/Rust/combinations-3.rs b/Task/Combinations/Rust/combinations-3.rust similarity index 100% rename from Task/Combinations/Rust/combinations-3.rs rename to Task/Combinations/Rust/combinations-3.rust diff --git a/Task/Combinations/Scheme/combinations.scm b/Task/Combinations/Scheme/combinations.ss similarity index 100% rename from Task/Combinations/Scheme/combinations.scm rename to Task/Combinations/Scheme/combinations.ss diff --git a/Task/Combinations/Tailspin/combinations.tailspin b/Task/Combinations/Tailspin/combinations.tailspin deleted file mode 100644 index 9f728e50c4..0000000000 --- a/Task/Combinations/Tailspin/combinations.tailspin +++ /dev/null @@ -1,7 +0,0 @@ -operator (m comb n) - [by 0..~$n] -> # - when <[](..~$m)> do [$..., by $(last)~..~$n] -> # - otherwise $! -end comb - -(3 comb 5) -> !OUT::write diff --git a/Task/Combinations/Uiua/combinations.uiua b/Task/Combinations/Uiua/combinations.uiua deleted file mode 100644 index e0d299cce6..0000000000 --- a/Task/Combinations/Uiua/combinations.uiua +++ /dev/null @@ -1,3 +0,0 @@ -3 5 # 3 combo 5 -⊙⇡ # Create the array of numbers -⧅< # Get the permutations diff --git a/Task/Combinations/VBScript/combinations.vbs b/Task/Combinations/VBScript/combinations.vb similarity index 100% rename from Task/Combinations/VBScript/combinations.vbs rename to Task/Combinations/VBScript/combinations.vb diff --git a/Task/Comma-quibbling/00-TASK.txt b/Task/Comma-quibbling/00-TASK.txt index 6e334a374a..4e431d60f7 100644 --- a/Task/Comma-quibbling/00-TASK.txt +++ b/Task/Comma-quibbling/00-TASK.txt @@ -1,4 +1,4 @@ -Comma quibbling is a task originally set by Eric Lippert in his [https://web.archive.org/web/20190202111812/https://blogs.msdn.microsoft.com/ericlippert/2009/04/15/comma-quibbling/ blog]. +Comma quibbling is a task originally set by Eric Lippert in his [http://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx blog]. ;Task: @@ -11,15 +11,12 @@ Write a function to generate a string output which is the concatenation of input
Test your function with the following series of inputs showing your output here on this page: -* [] # (No input words). +* [] # (No input words). * ["ABC"] * ["ABC", "DEF"] * ["ABC", "DEF", "G", "H"]
Note: Assume words are non-empty strings of uppercase characters for this task. - - -{{Template:Strings}}

diff --git a/Task/Comma-quibbling/AArch64-Assembly/comma-quibbling.aarch64 b/Task/Comma-quibbling/AArch64-Assembly/comma-quibbling.aarch64 deleted file mode 100644 index 50ff3b829d..0000000000 --- a/Task/Comma-quibbling/AArch64-Assembly/comma-quibbling.aarch64 +++ /dev/null @@ -1,270 +0,0 @@ -/* ARM assembly AARCH64 Raspberry PI 3B */ -/* program Comma quibbling */ - -/*******************************************/ -/* Constantes */ -/*******************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeConstantesARM64.inc" -.equ BUFFERSIZE, 80 - -/*******************************************/ -/* macros */ -/*******************************************/ -//.include "../../ficmacros64.inc" // for developper debugging - -/*********************************/ -/* Initialized data */ -/*********************************/ -.data -szMessDebutPgm: .asciz "Program 64 bits start. \n" -szCarriageReturn: .asciz "\n" -szMessFinOK: .asciz "Program normal end. \n" -szMessStringError: .asciz "Error : Empty string !!!\n" -szMessBufferError: .asciz "Error : Buffer too small !!\n" -szMessEndStringError: .asciz "Error: End string, not ].\n" -szMessWordErr: .asciz "Error word empty.\n" -szAnd: .asciz " and " -szString1: .asciz "[]" -szString2: .asciz "[\"ABC\"]" -szString3: .asciz "[\"ABC\",\"DEF\"]" -szString4: .asciz "[\"ABC\",\"DEF\",\"G\",\"H\"]" -szString5: .asciz "[\"AB" -szString6: .asciz "[\"ABC\",,\"DEF\"]" - -.align 4 -/*********************************/ -/* UnInitialized data */ -/*********************************/ -.bss -sBuffer: .skip BUFFERSIZE -.align 4 - -/*********************************/ -/* code section */ -/*********************************/ -.text -.global main -main: - ldr x0,qAdrszMessDebutPgm - bl affichageMess // start message - - ldr x0,qAdrszString1 - bl execTest - ldr x0,qAdrszString2 - bl execTest - ldr x0,qAdrszString3 - bl execTest - ldr x0,qAdrszString4 - bl execTest - ldr x0,qAdrszString5 - bl execTest - ldr x0,qAdrszString6 - bl execTest - - ldr x0,qAdrszMessFinOK - bl affichageMess - -100: - mov x8,EXIT - svc #0 // system call -qAdrszMessDebutPgm: .quad szMessDebutPgm -qAdrszMessFinOK: .quad szMessFinOK -qAdrszCarriageReturn: .quad szCarriageReturn -qAdrszString1: .quad szString1 -qAdrszString2: .quad szString2 -qAdrszString3: .quad szString3 -qAdrszString4: .quad szString4 -qAdrszString5: .quad szString5 -qAdrszString6: .quad szString6 -qAdrsBuffer: .quad sBuffer -/******************************************************************/ -/* test execution */ -/******************************************************************/ -/* x0 contains string address */ -execTest: - stp x1,lr,[sp,-16]! - stp x2,x4,[sp,-16]! - mov x4,x0 - bl affichageMess // display start string - ldr x0,qAdrszCarriageReturn - bl affichageMess - mov x0,x4 // string address - ldr x1,qAdrsBuffer // buffer address - mov x2,#BUFFERSIZE - bl stringAnalyse - cmp x0,#-1 // error ? - beq 100f - ldr x0,qAdrsBuffer // buffer display - bl affichageMess - ldr x0,qAdrszCarriageReturn - bl affichageMess -100: - ldp x2,x4,[sp],16 - ldp x1,lr,[sp],16 - ret -/******************************************************************/ -/* string conversion */ -/******************************************************************/ -/* x0 contains string address */ -/* x1 contains buffer address */ -/* x2 contains buffer length */ -stringAnalyse: - stp x1,lr,[sp,-16]! - stp x2,x3,[sp,-16]! - stp x4,x5,[sp,-16]! - stp x6,x7,[sp,-16]! - stp x8,x9,[sp,-16]! - sub sp,sp,#BUFFERSIZE // reserve area on stack for temporary buffer - mov fp,sp - mov x7,#0 // indice write buffer - mov x5,#0 // word counter - mov x6,#0 // word char count - - mov x3,#0 // indice string -1: - ldrb w4,[x0,x3] // load string char - cmp x4,#0 // end ? - bne 2f - cmp x3,#0 // first char ? - beq 97f // error empty string - b 97f // end string error -2: - cmp x4,#'[' // first symbol ? - bne 3f - mov x4,#'{' // write symbol - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - add x3,x3,#1 // increment indice - b 1b // and loop - 3: - cmp x4,#']' // end symbol ? - bne 8f - cmp x5,#0 // no word ? - beq 7f - cmp x5,#1 - beq 5f // last and first word - - mov x9,#0 - ldr x12,qAdrszAnd -4: // loop write and - ldrb w4,[x12,x9] - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - add x9,x9,#1 - cmp x9,#5 - blt 4b - -5: // last word - mov x9,#0 -6: // loop write temporary buffer - ldrb w4,[fp,x9] - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - add x9,x9,#1 - cmp x9,x6 - blt 6b - mov x6,#0 // raz indice temporary buffer -7: - mov x4,#'}' - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - mov x4,#0 - strb w4,[x1,x7] // final 0 - b 100f -8: - cmp x4,#',' // comma ? - beq 9f - cmp x6,#0 - cinc x5,x5,eq // new word increment word counter - //addeq x5,x5,#1 // new word increment word counter - strb w4,[fp,x6] // store char in temporary buffer - add x6,x6,#1 - add x3,x3,#1 - b 1b // loop - -9: - cmp x6,#0 // word empty ? - beq 96f - cmp x5,#1 // first word ? - bne 11f - // first word, write only the word - mov x9,#0 -10: // loop write temporary buffer - ldrb w4,[fp,x9] - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - add x9,x9,#1 - cmp x9,x6 - blt 10b - mov x6,#0 // raz indice temporary buffer - add x3,x3,#1 - b 1b // loop -11: - mov x4,#',' - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - - mov x9,#0 -12: // loop write temporary buffer - ldrb w4,[fp,x9] - strb w4,[x1,x7] - add x7,x7,#1 - cmp x7,x2 - bge 99f // buffer error - add x9,x9,#1 - cmp x9,x6 - blt 12b - mov x6,#0 // raz indice temporary buffer - add x3,x3,#1 - b 1b // loop - -96: // errors messages - ldr x0,qAdrszMessWordErr - bl affichageMess - mov x0,#-1 - b 100f -97: - ldr x0,qAdrszMessEndStringErr - bl affichageMess - mov x0,#-1 - b 100f -98: - ldr x0,qAdrszMessStringError - bl affichageMess - mov x0,#-1 - b 100f -99: - ldr x0,qAdrszMessBufferError - bl affichageMess - mov x0,#-1 -100: - add sp,sp,#BUFFERSIZE - ldp x8,x9,[sp],16 - ldp x6,x7,[sp],16 - ldp x4,x5,[sp],16 - ldp x2,x3,[sp],16 - ldp x1,lr,[sp],16 - ret -qAdrszMessStringError: .quad szMessStringError -qAdrszMessBufferError: .quad szMessBufferError -qAdrszMessEndStringErr: .quad szMessEndStringError -qAdrszMessWordErr: .quad szMessWordErr -qAdrszAnd: .quad szAnd -/***************************************************/ -/* ROUTINES INCLUDE */ -/***************************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeARM64.inc" diff --git a/Task/Comma-quibbling/ABC/comma-quibbling.abc b/Task/Comma-quibbling/ABC/comma-quibbling.abc deleted file mode 100644 index 42fb869f67..0000000000 --- a/Task/Comma-quibbling/ABC/comma-quibbling.abc +++ /dev/null @@ -1,17 +0,0 @@ -HOW TO RETURN quibble words: - PUT "" IN result - PUT #words IN remaining - FOR word IN words: - PUT result^word IN result - PUT remaining-1 IN remaining - IF remaining = 1: PUT result^" and " IN result - IF remaining > 1: PUT result^", " IN result - RETURN "{" ^ result ^ "}" - -PUT {} IN tests -INSERT {} IN tests -INSERT {[1]: "ABC"} IN tests -INSERT {[1]: "ABC"; [2]: "DEF"} IN tests -INSERT {[1]: "ABC"; [2]: "DEF"; [3]: "G"; [4]: "H"} IN tests -FOR test IN tests: - WRITE quibble test/ diff --git a/Task/Comma-quibbling/ARM-Assembly/comma-quibbling.arm b/Task/Comma-quibbling/ARM-Assembly/comma-quibbling.arm deleted file mode 100644 index ebbae869ca..0000000000 --- a/Task/Comma-quibbling/ARM-Assembly/comma-quibbling.arm +++ /dev/null @@ -1,260 +0,0 @@ -/* ARM assembly Raspberry PI */ -/* program Comma quibbling */ - -/* REMARK 1 : this program use routines in a include file - see task Include a file language arm assembly - for the routine affichageMess conversion10 - see at end of this program the instruction include */ - -/*******************************************/ -/* Constantes */ -/*******************************************/ -.include "../constantes.inc" -.equ BUFFERSIZE, 80 - -/*******************************************/ -/* macros */ -/*******************************************/ -//.include "../../ficmacros32.inc" @ for developper debugging - -/*********************************/ -/* Initialized data */ -/*********************************/ -.data -szMessDebutPgm: .asciz "Program 32 bits start. \n" -szCarriageReturn: .asciz "\n" -szMessFinOK: .asciz "Program normal end. \n" -szMessStringError: .asciz "Error : Empty string !!!\n" -szMessBufferError: .asciz "Error : Buffer too small !!\n" -szMessEndStringError: .asciz "Error: End string, not ].\n" -szMessWordErr: .asciz "Error word empty.\n" -szAnd: .asciz " and " -szString1: .asciz "[]" -szString2: .asciz "[\"ABC\"]" -szString3: .asciz "[\"ABC\",\"DEF\"]" -szString4: .asciz "[\"ABC\",\"DEF\",\"G\",\"H\"]" -szString5: .asciz "[\"AB" -szString6: .asciz "[\"ABC\",,\"DEF\"]" - -.align 4 -/*********************************/ -/* UnInitialized data */ -/*********************************/ -.bss -sBuffer: .skip BUFFERSIZE -.align 4 - -/*********************************/ -/* code section */ -/*********************************/ -.text -.global main -main: - ldr r0,iAdrszMessDebutPgm - bl affichageMess @ start message - - ldr r0,iAdrszString1 - bl execTest - ldr r0,iAdrszString2 - bl execTest - ldr r0,iAdrszString3 - bl execTest - ldr r0,iAdrszString4 - bl execTest - ldr r0,iAdrszString5 - bl execTest - ldr r0,iAdrszString6 - bl execTest - - ldr r0,iAdrszMessFinOK - bl affichageMess - -100: - mov r7,#EXIT @ program end - svc #0 @ system call -iAdrszMessDebutPgm: .int szMessDebutPgm -iAdrszMessFinOK: .int szMessFinOK -iAdrszCarriageReturn: .int szCarriageReturn -iAdrszString1: .int szString1 -iAdrszString2: .int szString2 -iAdrszString3: .int szString3 -iAdrszString4: .int szString4 -iAdrszString5: .int szString5 -iAdrszString6: .int szString6 -iAdrsBuffer: .int sBuffer -/******************************************************************/ -/* test execution */ -/******************************************************************/ -/* r0 contains string address */ -execTest: - push {r1-r4,lr} @ save registers - mov r4,r0 - bl affichageMess @ display start string - ldr r0,iAdrszCarriageReturn - bl affichageMess - mov r0,r4 @ string address - ldr r1,iAdrsBuffer @ buffer address - mov r2,#BUFFERSIZE - bl stringAnalyse - cmp r0,#-1 @ error ? - beq 100f - ldr r0,iAdrsBuffer @ buffer display - bl affichageMess - ldr r0,iAdrszCarriageReturn - bl affichageMess -100: - pop {r1-r4,pc} -/******************************************************************/ -/* string conversion */ -/******************************************************************/ -/* r0 contains string address */ -/* r1 contains buffer address */ -/* r2 contains buffer length */ -stringAnalyse: - push {r1-r9,fp,lr} @ save registers - sub sp,sp,#BUFFERSIZE @ reserve area on stack for temporary buffer - mov fp,sp - mov r7,#0 @ indice write buffer - mov r5,#0 @ word counter - mov r6,#0 @ word char count - - mov r3,#0 @ indice string -1: - ldrb r4,[r0,r3] @ load string char - cmp r4,#0 @ end ? - bne 2f - cmp r3,#0 @ first char ? - beq 97f @ error empty string - b 97f @ end string error -2: - cmp r4,#'[' @ first symbol ? - bne 3f - mov r4,#'{' @ write symbol - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - add r3,r3,#1 @ increment indice - b 1b @ and loop - 3: - cmp r4,#']' @ end symbol ? - bne 8f - cmp r5,#0 @ no word ? - beq 7f - cmp r5,#1 - beq 5f @ last and first word - - mov r9,#0 - ldr r12,iAdrszAnd -4: @ loop write and - ldrb r4,[r12,r9] - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - add r9,r9,#1 - cmp r9,#5 - blt 4b - -5: @ last word - mov r9,#0 -6: @ loop write temporary buffer - ldrb r4,[fp,r9] - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - add r9,r9,#1 - cmp r9,r6 - blt 6b - mov r6,#0 @ raz indice temporary buffer -7: - mov r4,#'}' - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - mov r4,#0 - strb r4,[r1,r7] @ final 0 - b 100f -8: - cmp r4,#',' @ comma ? - beq 9f - cmp r6,#0 - addeq r5,r5,#1 @ new word increment word counter - strb r4,[fp,r6] @ store char in temporary buffer - add r6,r6,#1 - add r3,r3,#1 - b 1b @ loop - -9: - cmp r6,#0 @ word empty ? - beq 96f - cmp r5,#1 @ first word ? - bne 11f - @ first word, write only the word - mov r9,#0 -10: @ loop write temporary buffer - ldrb r4,[fp,r9] - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - add r9,r9,#1 - cmp r9,r6 - blt 10b - mov r6,#0 @ raz indice temporary buffer - add r3,r3,#1 - b 1b @ loop -11: - mov r4,#',' - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - - mov r9,#0 -12: @ loop write temporary buffer - ldrb r4,[fp,r9] - strb r4,[r1,r7] - add r7,r7,#1 - cmp r7,r2 - bge 99f @ buffer error - add r9,r9,#1 - cmp r9,r6 - blt 12b - mov r6,#0 @ raz indice temporary buffer - add r3,r3,#1 - b 1b @ loop - -96: @ errors messages - ldr r0,iAdrszMessWordErr - bl affichageMess - mov r0,#-1 - b 100f -97: - ldr r0,iAdrszMessEndStringErr - bl affichageMess - mov r0,#-1 - b 100f -98: - ldr r0,iAdrszMessStringError - bl affichageMess - mov r0,#-1 - b 100f -99: - ldr r0,iAdrszMessBufferError - bl affichageMess - mov r0,#-1 -100: - add sp,sp,#BUFFERSIZE - pop {r1-r9,fp,pc} -iAdrszMessStringError: .int szMessStringError -iAdrszMessBufferError: .int szMessBufferError -iAdrszMessEndStringErr: .int szMessEndStringError -iAdrszMessWordErr: .int szMessWordErr -iAdrszAnd: .int szAnd -/***************************************************/ -/* ROUTINES INCLUDE */ -/***************************************************/ -.include "../affichage.inc" diff --git a/Task/Comma-quibbling/Acornsoft-Lisp/comma-quibbling.lisp b/Task/Comma-quibbling/Acornsoft-Lisp/comma-quibbling.lisp deleted file mode 100644 index 8a4bc795d9..0000000000 --- a/Task/Comma-quibbling/Acornsoft-Lisp/comma-quibbling.lisp +++ /dev/null @@ -1,20 +0,0 @@ -(defun examples () - (map '(lambda (words) (printc (quibble words))) - '(() (ABC) (ABC DEF) (ABC DEF G H)))) - -(defun quibble (words) - (implode (list '{ (quibbles words) '}))) - -(defun quibbles (words) - (implode (conjunction words))) - -(defun conjunction (words) - (cond ((null words) - '()) - ((null (cdr words)) - words) - ((null (cddr words)) - (list (car words) '! and! (cadr words))) - (t - (cons (car words) - (cons ',! (conjunction (cdr words))))))) diff --git a/Task/Comma-quibbling/Ada/comma-quibbling.adb b/Task/Comma-quibbling/Ada/comma-quibbling.ada similarity index 100% rename from Task/Comma-quibbling/Ada/comma-quibbling.adb rename to Task/Comma-quibbling/Ada/comma-quibbling.ada diff --git a/Task/Comma-quibbling/Arturo/comma-quibbling.arturo b/Task/Comma-quibbling/Arturo/comma-quibbling.arturo index a427253a6f..e34a1676ac 100644 --- a/Task/Comma-quibbling/Arturo/comma-quibbling.arturo +++ b/Task/Comma-quibbling/Arturo/comma-quibbling.arturo @@ -1,9 +1,9 @@ quibble: $[sequence :block][ - if 0 = size sequence - -> return "{}" + if? 0 = size sequence + -> return "{}" - if 1 = size sequence - -> return ~"{|sequence\0|}" + if? 1 = size sequence + -> return ~"{|sequence\0|}" last: pop 'sequence return ~« {|join.with: ", " sequence| and |last|} diff --git a/Task/Comma-quibbling/COBOL/comma-quibbling.cob b/Task/Comma-quibbling/COBOL/comma-quibbling.cobol similarity index 100% rename from Task/Comma-quibbling/COBOL/comma-quibbling.cob rename to Task/Comma-quibbling/COBOL/comma-quibbling.cobol diff --git a/Task/Comma-quibbling/Commodore-BASIC/comma-quibbling.basic b/Task/Comma-quibbling/Commodore-BASIC/comma-quibbling.basic deleted file mode 100644 index b0011e5f3b..0000000000 --- a/Task/Comma-quibbling/Commodore-BASIC/comma-quibbling.basic +++ /dev/null @@ -1,25 +0,0 @@ -100 DIM A$(3) -110 FOR TC=1 TO 4 -120 : READ A: IF A=0 THEN 160 -130 : FOR I=0 TO A-1 -140 : READ A$(I) -150 : NEXT I -160 : GOSUB 200 -170 : PRINT CQ$ -180 NEXT TC -190 END -200 CQ$="[" -210 IF A < 1 THEN 290 -220 CQ$ = CQ$ + A$(0) -230 IF A < 2 THEN 290 -240 IF A < 3 THEN 280 -250 FOR I=1 TO A - 2 -260 : CQ$ = CQ$ + ", " + A$(I) -270 NEXT I -280 CQ$ = CQ$ + " AND " + A$(A - 1) -290 CQ$ = CQ$ + "]" -300 RETURN -310 DATA 0 -320 DATA 1, ABC -330 DATA 2, ABC, DEF -340 DATA 4, ABC, DEF, G, H diff --git a/Task/Comma-quibbling/Crystal/comma-quibbling.cr b/Task/Comma-quibbling/Crystal/comma-quibbling.cr deleted file mode 100644 index c9464e6016..0000000000 --- a/Task/Comma-quibbling/Crystal/comma-quibbling.cr +++ /dev/null @@ -1,19 +0,0 @@ -def comma_quibble (arr) - "{" + - case arr.size - when 0 - "" - when 1 - arr[0] - else - arr[..-2].join(", ") + " and #{arr[-1]}" - end + "}" -end - -[[] of String, # (No input words). - ["ABC"], - ["ABC", "DEF"], - ["ABC", "DEF", "G", "H"], -].each do |input| - puts comma_quibble(input) -end diff --git a/Task/Comma-quibbling/Dc/comma-quibbling.dc b/Task/Comma-quibbling/Dc/comma-quibbling.dc deleted file mode 100644 index 33bb18889b..0000000000 --- a/Task/Comma-quibbling/Dc/comma-quibbling.dc +++ /dev/null @@ -1,32 +0,0 @@ -[(q)uibble: main entry point. print brackets, calling n in between if stack not - empty.]sx -[ [{]n z 0 !=n [}]pR ]sq - -[(n)onempty: if more than 1 item, call m. then print top of stack.]sx -[ z 1 !=m n ]sn - -[(m)ore: call f to flip stack into r register, call p to print most of it, - then pop the last item back onto the main stack so it's there to be printed - after we return]sx -[ lfx lpx Lr ]sm - -[(f)lip: utility routine to reverse the stack into the r register]sx -[ Sr z 0 !=f ]sf - -[(p)rint: get next item from stack in r register and print it. If there are - more than 2 items left on the register stack (which never drops below one - item), print a comma (c) and recurse. If there are exactly two items left, - print " and " (a) and return.]sx -[ Lr n 2 yr >c 2 yr =a 2 yr >p]sp - -[(c)omma: utility routine to print a comma followed by a space]sx -[ [, ]n ]sc - -[(a)and: utility routine to print " and "]sx -[ [ and ]n ]sa - -[run tests]sx -lqx -[ABC] lqx -[ABC] [DEF] lqx -[ABC] [DEF] [G] [H] lqx diff --git a/Task/Comma-quibbling/EasyLang/comma-quibbling.easy b/Task/Comma-quibbling/EasyLang/comma-quibbling.easy deleted file mode 100644 index 9241769aeb..0000000000 --- a/Task/Comma-quibbling/EasyLang/comma-quibbling.easy +++ /dev/null @@ -1,16 +0,0 @@ -func$ tolist s$ . - s$[] = strsplit s$ " " - r$ = "{" - n = len s$[] - for i = 1 to n - 2 : r$ &= s$[i] & ", " - if n > 0 - if n > 1 : r$ &= s$[n - 1] & " and " - r$ &= s$[n] - . - r$ &= "}" - return r$ -. -print tolist "" -print tolist "ABC" -print tolist "ABC DEF" -print tolist "ABC DEF G H" diff --git a/Task/Comma-quibbling/Ed/comma-quibbling.ed b/Task/Comma-quibbling/Ed/comma-quibbling.ed deleted file mode 100644 index ac9da0cba8..0000000000 --- a/Task/Comma-quibbling/Ed/comma-quibbling.ed +++ /dev/null @@ -1,8 +0,0 @@ -# by Artyom Bologov -H -,p -g/.*/s/ /, /g -g/[,]/s/,\([^,]*\)$/ and\1/ -g/.*/s//{&}/ -,p -Q diff --git a/Task/Comma-quibbling/Elena/comma-quibbling-1.elena b/Task/Comma-quibbling/Elena/comma-quibbling-1.elena deleted file mode 100644 index 7d110e9b1f..0000000000 --- a/Task/Comma-quibbling/Elena/comma-quibbling-1.elena +++ /dev/null @@ -1,23 +0,0 @@ -import system'routines; -import extensions; -import extensions'text; - -public extension QuibbleOp : Array -{ - string quibble() - { - ^ self.zipBy( - self.Length.coundDown().selectBy::(n => (n == self.Length) ? EmptyString : ((n == 1) ? " and " : ", ") ), - (word, prefix => prefix + word) - ) - .summarize(StringWriter.load("{")) + "}" - } -} - -public Program() -{ - Console.printLine(new string[] { }.quibble()); - Console.printLine(new string[] { "ABC" }.quibble()); - Console.printLine(new string[] { "ABC", "ADF" }.quibble()); - Console.printLine(new string[] { "ABC", "DEF", "G", "H" }.quibble()) -} diff --git a/Task/Comma-quibbling/Elena/comma-quibbling-2.elena b/Task/Comma-quibbling/Elena/comma-quibbling-2.elena deleted file mode 100644 index f59b89451f..0000000000 --- a/Task/Comma-quibbling/Elena/comma-quibbling-2.elena +++ /dev/null @@ -1,31 +0,0 @@ -import extensions; -import textgen; - -const string Script = "<={{=>for (var i := 0; i < self.Length; i := i + 1) { - if (i > 0) { - if (i == self.Length - 1) { - <= and => - } - else { - <=, => - } - }; - - <={self[i]}=> - }; <=}}=>"; - -public extension QuibbleOp : Array -{ - string quibble() - { - ^ self.generateFrom(Script); - } -} - -public Program() -{ - Console.printLine(new string[] { }.quibble()); - Console.printLine(new string[] { "ABC" }.quibble()); - Console.printLine(new string[] { "ABC", "ADF" }.quibble()); - Console.printLine(new string[] { "ABC", "DEF", "G", "H" }.quibble()) -} diff --git a/Task/Comma-quibbling/Elixir/comma-quibbling.ex b/Task/Comma-quibbling/Elixir/comma-quibbling.elixir similarity index 100% rename from Task/Comma-quibbling/Elixir/comma-quibbling.ex rename to Task/Comma-quibbling/Elixir/comma-quibbling.elixir diff --git a/Task/Comma-quibbling/FutureBasic/comma-quibbling-2.basic b/Task/Comma-quibbling/FutureBasic/comma-quibbling-2.basic deleted file mode 100644 index 8462cf8d46..0000000000 --- a/Task/Comma-quibbling/FutureBasic/comma-quibbling-2.basic +++ /dev/null @@ -1,20 +0,0 @@ -local fn CommaQuibbler( s as CFArrayRef ) as CFStringRef - CFStringRef result = NULL - - select ( len(s) ) - case 0: exit fn = @"{}" - case 1: exit fn = fn StringWithFormat( @"{%@}", s[0] ) - case 2: exit fn = fn StringWithFormat( @"{%@ and %@}", s[0], s[1] ) - case else - result = fn StringWithFormat( @"{%@}", fn ArrayComponentsJoinedByString( s, @", " ) ) - CFRange lastComma = fn StringRangeOfStringWithOptions( result, @",", NSBackwardsSearch ) - result = fn StringByReplacingCharactersInRange( result, lastComma, @" and" ) - end select -end fn = result - -print fn CommaQuibbler( @[] ) -print fn CommaQuibbler( @[@"ABC"] ) -print fn CommaQuibbler( @[@"ABC", @"DEF"] ) -print fn CommaQuibbler( @[@"ABC", @"DEF", @"G", @"H"] ) - -HandleEvents diff --git a/Task/Comma-quibbling/FutureBasic/comma-quibbling-3.basic b/Task/Comma-quibbling/FutureBasic/comma-quibbling-3.basic deleted file mode 100644 index aca32cb04f..0000000000 --- a/Task/Comma-quibbling/FutureBasic/comma-quibbling-3.basic +++ /dev/null @@ -1,16 +0,0 @@ -local fn Quibble( string as CFStringRef ) as CFStringRef - CfArrayRef arr = fn StringComponentsSeparatedByString( string, @" " ) - CFStringRef rst - if ( len(arr) == 0 ) then rst = @"" else rst = fn StringWithFormat( @"%@", fn ArrayLastObject( arr ) ) - if ( len(arr) > 1 ) - CFArrayRef subArray = fn ArraySubarrayWithRange( arr, fn CFRangeMake( 0, len(arr) - 1 ) ) - rst = fn StringWithFormat( @"%@ and %@", fn ArrayComponentsJoinedByString( subArray, @", " ), rst ) - end if -end fn = fn StringWithFormat( @"{%@}", rst ) - -print fn Quibble( @"" ) -print fn Quibble( @"ABC") -print fn Quibble( @"ABC DEF" ) -print fn Quibble( @"ABC DEF G H" ) - -HandleEvents diff --git a/Task/Comma-quibbling/FutureBasic/comma-quibbling-1.basic b/Task/Comma-quibbling/FutureBasic/comma-quibbling.basic similarity index 100% rename from Task/Comma-quibbling/FutureBasic/comma-quibbling-1.basic rename to Task/Comma-quibbling/FutureBasic/comma-quibbling.basic diff --git a/Task/Comma-quibbling/Haskell/comma-quibbling-2.hs b/Task/Comma-quibbling/Haskell/comma-quibbling-2.hs index e2855e4bdd..de5525b228 100644 --- a/Task/Comma-quibbling/Haskell/comma-quibbling-2.hs +++ b/Task/Comma-quibbling/Haskell/comma-quibbling-2.hs @@ -1,25 +1,15 @@ import Data.List (intercalate) ---------------------- COMMA QUIBBLING -------------------- - quibble :: [String] -> String -quibble ws@(_ : _ : _) = - intercalate - " and " - ( [intercalate ", " . reverse . tail, head] - <*> [reverse ws] - ) -quibble xs = concat xs +quibble ws + | length ws > 1 = + intercalate + " and " + ([intercalate ", " . reverse . tail, head] <*> [reverse ws]) + | otherwise = concat ws ---------------------------- TEST ------------------------- main :: IO () main = mapM_ (putStrLn . (`intercalate` ["{", "}"]) . quibble) $ - [[], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]] - <> ( words - <$> [ "One two three four", - "Me myself I", - "Jack Jill", - "Loner" - ] - ) + [[], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]] ++ + (words <$> ["One two three four", "Me myself I", "Jack Jill", "Loner"]) diff --git a/Task/Comma-quibbling/Julia/comma-quibbling.jl b/Task/Comma-quibbling/Julia/comma-quibbling.julia similarity index 100% rename from Task/Comma-quibbling/Julia/comma-quibbling.jl rename to Task/Comma-quibbling/Julia/comma-quibbling.julia diff --git a/Task/Comma-quibbling/Kotlin/comma-quibbling.kts b/Task/Comma-quibbling/Kotlin/comma-quibbling.kotlin similarity index 100% rename from Task/Comma-quibbling/Kotlin/comma-quibbling.kts rename to Task/Comma-quibbling/Kotlin/comma-quibbling.kotlin diff --git a/Task/Comma-quibbling/Nu/comma-quibbling.nu b/Task/Comma-quibbling/Nu/comma-quibbling.nu deleted file mode 100644 index 1af48327db..0000000000 --- a/Task/Comma-quibbling/Nu/comma-quibbling.nu +++ /dev/null @@ -1,13 +0,0 @@ -def quibble [] { - if ($in | length) < 3 { $in } else [($in | drop | str join ', ') ($in | last)] - | $'{($in | str join " and ")}' -} - -# test -[ - [] - [ABC] - [ABC DEF] - [ABC DEF G H] -] -| each { quibble } diff --git a/Task/Comma-quibbling/OCaml/comma-quibbling-1.ml b/Task/Comma-quibbling/OCaml/comma-quibbling-1.ocaml similarity index 100% rename from Task/Comma-quibbling/OCaml/comma-quibbling-1.ml rename to Task/Comma-quibbling/OCaml/comma-quibbling-1.ocaml diff --git a/Task/Comma-quibbling/OCaml/comma-quibbling-2.ml b/Task/Comma-quibbling/OCaml/comma-quibbling-2.ocaml similarity index 100% rename from Task/Comma-quibbling/OCaml/comma-quibbling-2.ml rename to Task/Comma-quibbling/OCaml/comma-quibbling-2.ocaml diff --git a/Task/Comma-quibbling/Oberon/comma-quibbling.oberon b/Task/Comma-quibbling/Oberon-2/comma-quibbling.oberon similarity index 100% rename from Task/Comma-quibbling/Oberon/comma-quibbling.oberon rename to Task/Comma-quibbling/Oberon-2/comma-quibbling.oberon diff --git a/Task/Comma-quibbling/PHP/comma-quibbling.php b/Task/Comma-quibbling/PHP/comma-quibbling.php index 8562b6bafd..296c9e2c0f 100644 --- a/Task/Comma-quibbling/PHP/comma-quibbling.php +++ b/Task/Comma-quibbling/PHP/comma-quibbling.php @@ -1,21 +1,18 @@ diff --git a/Task/Comma-quibbling/Pluto/comma-quibbling.pluto b/Task/Comma-quibbling/Pluto/comma-quibbling.pluto deleted file mode 100644 index ae82288a57..0000000000 --- a/Task/Comma-quibbling/Pluto/comma-quibbling.pluto +++ /dev/null @@ -1,10 +0,0 @@ -local function quibbling(w) - local c = #w - if c == 0 then return "{}" end - if c == 1 then return $"\{{w[1]}}" end - if c == 2 then return $"\{{w[1]} and {w[2]}}" end - return $"\{{w:slice(1, #w - 1):concat(", ")} and {w[#w]}}" -end - -local words = { {}, {"ABC"}, {"ABC", "DEF"}, {"ABC", "DEF", "G", "H"} } -for words as w do print(quibbling(w)) end diff --git a/Task/Comma-quibbling/PowerShell/comma-quibbling-1.ps1 b/Task/Comma-quibbling/PowerShell/comma-quibbling-1.psh similarity index 100% rename from Task/Comma-quibbling/PowerShell/comma-quibbling-1.ps1 rename to Task/Comma-quibbling/PowerShell/comma-quibbling-1.psh diff --git a/Task/Comma-quibbling/PowerShell/comma-quibbling-2.ps1 b/Task/Comma-quibbling/PowerShell/comma-quibbling-2.psh similarity index 100% rename from Task/Comma-quibbling/PowerShell/comma-quibbling-2.ps1 rename to Task/Comma-quibbling/PowerShell/comma-quibbling-2.psh diff --git a/Task/Comma-quibbling/PowerShell/comma-quibbling-3.ps1 b/Task/Comma-quibbling/PowerShell/comma-quibbling-3.psh similarity index 100% rename from Task/Comma-quibbling/PowerShell/comma-quibbling-3.ps1 rename to Task/Comma-quibbling/PowerShell/comma-quibbling-3.psh diff --git a/Task/Comma-quibbling/Rebol/comma-quibbling-2.rebol b/Task/Comma-quibbling/REBOL/comma-quibbling-1.rebol similarity index 100% rename from Task/Comma-quibbling/Rebol/comma-quibbling-2.rebol rename to Task/Comma-quibbling/REBOL/comma-quibbling-1.rebol diff --git a/Task/Comma-quibbling/REBOL/comma-quibbling-2.rebol b/Task/Comma-quibbling/REBOL/comma-quibbling-2.rebol new file mode 100644 index 0000000000..42c9c25002 --- /dev/null +++ b/Task/Comma-quibbling/REBOL/comma-quibbling-2.rebol @@ -0,0 +1,24 @@ +Rebol [] + +; builds string instead of using an intermediate block + +comma-quibbling: func [block /oxford /local s length] [ + length: length? block + rejoin [ + "^{" + + either length < 2 [to-string block] [ + s: to-string block/1 + for n 2 (length - 1) 1 [repend s [", " pick block n]] + if all [oxford (length > 2)] [append s ","] + repend s [" and " last block] + ] + + "^}" + ] +] + +test: [[] [ABC] [ABC DEF] [ABC DEF G H]] +foreach t test [print comma-quibbling t] +print "Now with Oxford comma" +foreach t test [print comma-quibbling/oxford t] diff --git a/Task/Comma-quibbling/Rebol/comma-quibbling-1.rebol b/Task/Comma-quibbling/Rebol/comma-quibbling-1.rebol deleted file mode 100644 index 9adf877190..0000000000 --- a/Task/Comma-quibbling/Rebol/comma-quibbling-1.rebol +++ /dev/null @@ -1,2 +0,0 @@ -head change/part find/last combine/with [ABC DEF G H] ", " #"," " and" 1 -;== "ABC, DEF, G and H" diff --git a/Task/Comma-quibbling/Rebol/comma-quibbling-3.rebol b/Task/Comma-quibbling/Rebol/comma-quibbling-3.rebol deleted file mode 100644 index 1680b96b7d..0000000000 --- a/Task/Comma-quibbling/Rebol/comma-quibbling-3.rebol +++ /dev/null @@ -1,24 +0,0 @@ -Rebol [] - -; builds string instead of using an intermediate block - -comma-quibbling: func [block /oxford /local s length] [ - length: length? block - rejoin [ - "^{" - - either length < 2 [to string! block] [ - s: to string! block/1 - for n 2 (length - 1) 1 [repend s [", " pick block n]] - if all [oxford (length > 2)] [append s ","] - repend s [" and " last block] - ] - - "^}" - ] -] - -test: [[] [ABC] [ABC DEF] [ABC DEF G H]] -foreach t test [print comma-quibbling t] -print "Now with Oxford comma" -foreach t test [print comma-quibbling/oxford t] diff --git a/Task/Comma-quibbling/Refal/comma-quibbling.refal b/Task/Comma-quibbling/Refal/comma-quibbling.refal deleted file mode 100644 index 5c52faa392..0000000000 --- a/Task/Comma-quibbling/Refal/comma-quibbling.refal +++ /dev/null @@ -1,17 +0,0 @@ -$ENTRY Go { - = > - > - > - >; -}; - -Quibble { - e.X = '{' '}'; -}; - -Quibble1 { - = ; - (e.Word) = e.Word; - (e.Word1) (e.Word2) = e.Word1 ' and ' e.Word2; - (e.Word) e.Words = e.Word ', ' ; -}; diff --git a/Task/Comma-quibbling/Rust/comma-quibbling.rs b/Task/Comma-quibbling/Rust/comma-quibbling.rust similarity index 100% rename from Task/Comma-quibbling/Rust/comma-quibbling.rs rename to Task/Comma-quibbling/Rust/comma-quibbling.rust diff --git a/Task/Comma-quibbling/SETL/comma-quibbling.setl b/Task/Comma-quibbling/SETL/comma-quibbling.setl deleted file mode 100644 index 8d332e3245..0000000000 --- a/Task/Comma-quibbling/SETL/comma-quibbling.setl +++ /dev/null @@ -1,27 +0,0 @@ -program comma_quibbling; - tests := [ - [], - ["ABC"], - ["ABC","DEF"], - ["ABC","DEF","G","H"] - ]; - - loop for t in tests do - print(t, "=", quibble(t)); - end loop; - - proc quibble(words); - ret := '{'; - loop while words /= [] do - word fromb words; - ret +:= word; - case of - (#words = 1): - ret +:= " and "; - (#words > 1): - ret +:= ", "; - end case; - end loop; - return ret + '}'; - end proc; -end program; diff --git a/Task/Comma-quibbling/Scheme/comma-quibbling.scm b/Task/Comma-quibbling/Scheme/comma-quibbling.ss similarity index 100% rename from Task/Comma-quibbling/Scheme/comma-quibbling.scm rename to Task/Comma-quibbling/Scheme/comma-quibbling.ss diff --git a/Task/Comma-quibbling/Sidef/comma-quibbling.sidef b/Task/Comma-quibbling/Sidef/comma-quibbling.sidef index c41b243099..a683c3d8f2 100644 --- a/Task/Comma-quibbling/Sidef/comma-quibbling.sidef +++ b/Task/Comma-quibbling/Sidef/comma-quibbling.sidef @@ -1,7 +1,7 @@ func comma_quibbling(words) { - '{' + ([words.first(-1).join(', ')]-[''] + [words.last] -> join(' and ')) + '}' + '{' + ([words.ft(0, -2).join(', ')]-[''] + [words.last] -> join(' and ')) + '}'; } [<>, , , ].each { |w| - say comma_quibbling(w) + say comma_quibbling(w); } diff --git a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-1.sh b/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-1.sh deleted file mode 100644 index 2d01c5e9a7..0000000000 --- a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-1.sh +++ /dev/null @@ -1,15 +0,0 @@ -quibble() { - printf '{' - while (( $# > 2 )); do - printf '%s, ' "$1" - shift - done - if (( $# )); then - printf '%s' "$1" - shift - fi - if (( $# )); then - printf ' and %s' "$1" - fi - printf '%s\n' '}' -} diff --git a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-2.sh b/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-2.sh deleted file mode 100644 index 1f9d5837f0..0000000000 --- a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-2.sh +++ /dev/null @@ -1,15 +0,0 @@ -quibble() { - printf '{' - while [ $# -gt 2 ]; do - printf '%s, ' "$1" - shift - done - if [ $# -gt 0 ]; then - printf '%s' "$1" - shift - fi - if [ $# -gt 0 ]; then - printf ' and %s' "$1" - fi - printf '%s\n' '}' -} diff --git a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-3.sh b/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-3.sh deleted file mode 100644 index ee2aec6306..0000000000 --- a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-3.sh +++ /dev/null @@ -1,5 +0,0 @@ -quibble() { - printf '{' - if (( $# > 1 )) printf '%s and ' ${(j:, :)@[1,-2]} - printf '%s}\n' $@[-1] -} diff --git a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-4.sh b/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-4.sh deleted file mode 100644 index 9dd8361285..0000000000 --- a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-4.sh +++ /dev/null @@ -1,4 +0,0 @@ -quibble -quibble ABC -quibble ABC DEF -quibble ABC DEF G H diff --git a/Task/Comma-quibbling/UNIX-Shell/comma-quibbling.sh b/Task/Comma-quibbling/UNIX-Shell/comma-quibbling.sh new file mode 100644 index 0000000000..0753bac442 --- /dev/null +++ b/Task/Comma-quibbling/UNIX-Shell/comma-quibbling.sh @@ -0,0 +1,15 @@ +quibble() { + # Here awk(1) is easier than sed(1). + awk 'BEGIN { + for (i = 1; i < ARGC - 2; i++) s = s ARGV[i] ", " + i = ARGC - 2; if (i > 0) s = s ARGV[i] " and " + i = ARGC - 1; if (i > 0) s = s ARGV[i] + printf "{%s}\n", s + exit 0 + }' "$@" +} + +quibble +quibble ABC +quibble ABC DEF +quibble ABC DEF G H diff --git a/Task/Comma-quibbling/Uiua/comma-quibbling.uiua b/Task/Comma-quibbling/Uiua/comma-quibbling.uiua deleted file mode 100644 index 318a769baa..0000000000 --- a/Task/Comma-quibbling/Uiua/comma-quibbling.uiua +++ /dev/null @@ -1,6 +0,0 @@ -Tests ← {{} - {"ABC"} - {"ABC" "DEF"} - {"ABC" "DEF" "G" "H"}} -Quibble ← |1 ⨬(⋅""|°□⊢|$"_ and _"°⊟|Quibble⊂⊃(□$"_, _"°⊟↙2)↘₂)↧3⊸⧻ -⍚(&p$"{_}"Quibble) Tests diff --git a/Task/Comma-quibbling/V-(Vlang)/comma-quibbling.v b/Task/Comma-quibbling/V-(Vlang)/comma-quibbling.v index 6d8c5779ea..dbfb561110 100644 --- a/Task/Comma-quibbling/V-(Vlang)/comma-quibbling.v +++ b/Task/Comma-quibbling/V-(Vlang)/comma-quibbling.v @@ -1,15 +1,23 @@ fn q(s []string) string { match s.len { - 0 { return "{}" } - 1 { return "{${s[0]}}" } - 2 { return "{${s[0]} and ${s[1]}}" } - else { return "{${s[0..s.len-1].join(", ")} and ${s[s.len-1]}}" } + 0 { + return '{}' + } + 1 { + return '{${s[0]}}' + } + 2 { + return '{${s[0]} and ${s[1]}}' + } + else{ + return '{${s[0..s.len-1].join(', ')} and ${s[s.len-1]}}' + } } } fn main(){ println(q([])) - println(q(["ABC"])) - println(q(["ABC","DEF"])) - println(q(["ABC","DEF","G","H"])) + println(q(['ABC'])) + println(q(['ABC','DEF'])) + println(q(['ABC','DEF','G','H'])) } diff --git a/Task/Comma-quibbling/VBScript/comma-quibbling.vbs b/Task/Comma-quibbling/VBScript/comma-quibbling.vb similarity index 100% rename from Task/Comma-quibbling/VBScript/comma-quibbling.vbs rename to Task/Comma-quibbling/VBScript/comma-quibbling.vb diff --git a/Task/Command-line-arguments/AArch64-Assembly/command-line-arguments-1.aarch64 b/Task/Command-line-arguments/AArch64-Assembly/command-line-arguments-1.aarch64 deleted file mode 100644 index bd8f30b055..0000000000 --- a/Task/Command-line-arguments/AArch64-Assembly/command-line-arguments-1.aarch64 +++ /dev/null @@ -1,49 +0,0 @@ -/* ARM assembly AARCH64 Raspberry PI 3B */ -/* program commandLine64.s */ -/************************************/ -/* Constantes */ -/************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeConstantesARM64.inc" - -/************************************/ -/* Initialized data */ -/************************************/ -.data -szCarriageReturn: .asciz "\n" -/************************************/ -/* UnInitialized data */ -/************************************/ -.bss -.align 4 -/************************************/ -/* code section */ -/************************************/ -.text -.global main -main: // entry of program - mov fp,sp // fp <- start address - ldr x4,[fp] // number of Command line arguments - add x5,fp,#8 // first parameter address - mov x2,#0 // init loop counter -1: - ldr x0,[x5,x2,lsl #3] // string address parameter - bl affichageMess // display string - ldr x0,qAdrszCarriageReturn - bl affichageMess // display carriage return - add x2,x2,#1 // increment counter - cmp x2,x4 // number parameters ? - blt 1b // loop - -100: // standard end of the program - mov x0, #0 // return code - mov x8,EXIT - svc 0 // perform the system call - -qAdrszCarriageReturn: .quad szCarriageReturn - -/***************************************************/ -/* ROUTINES INCLUDE */ -/***************************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeARM64.inc" diff --git a/Task/Command-line-arguments/AArch64-Assembly/command-line-arguments-2.aarch64 b/Task/Command-line-arguments/AArch64-Assembly/command-line-arguments-2.aarch64 deleted file mode 100644 index 134551fb07..0000000000 --- a/Task/Command-line-arguments/AArch64-Assembly/command-line-arguments-2.aarch64 +++ /dev/null @@ -1,26 +0,0 @@ -.global _start -.text -_start: - mov x9, sp // move stack pointer to x9 - 0: ldr x0, [x9, #8]! // add 8 to x9, load long int value at x9 into x0 - cbz x0, 9f // if x0 is zero (null pointer) jump forward to 9: - bl writez // call our function that prints a null terminated string - adr x0, lfz // load address of lfz (line feed, zero) into x0 - bl writez // print it - b 0b // jump backward to label 0: - 9: mov x8, #93 // 93 is exit - mov x0, xzr // return (0); - svc #0 // syscall - // If using as a function in C declare it as -writez: // extern long writez(char *str); - mov x1, x0 // address of str needs to be in x1 for syscall - sub x0, x0, #1 // decrement x0, because the next statement increments it first. - 0: ldrb w2, [x0, #1]! // increment x0, load byte value at x0 in w2 - cbnz w2, 0b // if w2 is not zero jump back to 0: label - sub x2, x0, x1 // subtract x1 from x0, load into x2. length of str - mov x0, #1 // mov into x0 1. stdout - mov x8, #64 // mov into x8 64. write - svc #0 // syscall - ret // return from function. - // return value is number of characters written. -lfz: .byte 10, 0 // line feed (0x0a), zero (null character) diff --git a/Task/Command-line-arguments/Ada/command-line-arguments-1.adb b/Task/Command-line-arguments/Ada/command-line-arguments-1.ada similarity index 100% rename from Task/Command-line-arguments/Ada/command-line-arguments-1.adb rename to Task/Command-line-arguments/Ada/command-line-arguments-1.ada diff --git a/Task/Command-line-arguments/Ada/command-line-arguments-2.adb b/Task/Command-line-arguments/Ada/command-line-arguments-2.ada similarity index 100% rename from Task/Command-line-arguments/Ada/command-line-arguments-2.adb rename to Task/Command-line-arguments/Ada/command-line-arguments-2.ada diff --git a/Task/Command-line-arguments/ArkScript/command-line-arguments.ark b/Task/Command-line-arguments/ArkScript/command-line-arguments.ark deleted file mode 100644 index c7a36a1db6..0000000000 --- a/Task/Command-line-arguments/ArkScript/command-line-arguments.ark +++ /dev/null @@ -1,2 +0,0 @@ -(import std.Sys) -(print sys:args) diff --git a/Task/Command-line-arguments/C3/command-line-arguments.c3 b/Task/Command-line-arguments/C3/command-line-arguments.c3 deleted file mode 100644 index 13a39760aa..0000000000 --- a/Task/Command-line-arguments/C3/command-line-arguments.c3 +++ /dev/null @@ -1,10 +0,0 @@ -import std::io; - -fn void main(String[] args) -{ - io::printfn("This program is named %s.", args[0]); - for (int i = 1; i < args.len; i++) - { - io::printfn("the argument #%d is %s\n", i, args[i]); - } -} diff --git a/Task/Command-line-arguments/COBOL/command-line-arguments-1.cob b/Task/Command-line-arguments/COBOL/command-line-arguments-1.cobol similarity index 100% rename from Task/Command-line-arguments/COBOL/command-line-arguments-1.cob rename to Task/Command-line-arguments/COBOL/command-line-arguments-1.cobol diff --git a/Task/Command-line-arguments/COBOL/command-line-arguments-2.cob b/Task/Command-line-arguments/COBOL/command-line-arguments-2.cobol similarity index 100% rename from Task/Command-line-arguments/COBOL/command-line-arguments-2.cob rename to Task/Command-line-arguments/COBOL/command-line-arguments-2.cobol diff --git a/Task/Command-line-arguments/COBOL/command-line-arguments-3.cob b/Task/Command-line-arguments/COBOL/command-line-arguments-3.cobol similarity index 100% rename from Task/Command-line-arguments/COBOL/command-line-arguments-3.cob rename to Task/Command-line-arguments/COBOL/command-line-arguments-3.cobol diff --git a/Task/Command-line-arguments/Delphi/command-line-arguments.pas b/Task/Command-line-arguments/Delphi/command-line-arguments.delphi similarity index 100% rename from Task/Command-line-arguments/Delphi/command-line-arguments.pas rename to Task/Command-line-arguments/Delphi/command-line-arguments.delphi diff --git a/Task/Command-line-arguments/Elena/command-line-arguments.elena b/Task/Command-line-arguments/Elena/command-line-arguments.elena index 5fc9385721..f2b40e0a6f 100644 --- a/Task/Command-line-arguments/Elena/command-line-arguments.elena +++ b/Task/Command-line-arguments/Elena/command-line-arguments.elena @@ -1,8 +1,8 @@ import system'routines; import extensions; -public Program() +public program() { - Program_arguments.forEvery::(int i) - { Console.printLine("Argument ",i," is ",Program_arguments[i]) } + program_arguments.forEvery:(int i) + { console.printLine("Argument ",i," is ",program_arguments[i]) } } diff --git a/Task/Command-line-arguments/Elixir/command-line-arguments-1.ex b/Task/Command-line-arguments/Elixir/command-line-arguments-1.elixir similarity index 100% rename from Task/Command-line-arguments/Elixir/command-line-arguments-1.ex rename to Task/Command-line-arguments/Elixir/command-line-arguments-1.elixir diff --git a/Task/Command-line-arguments/Elixir/command-line-arguments-2.ex b/Task/Command-line-arguments/Elixir/command-line-arguments-2.elixir similarity index 100% rename from Task/Command-line-arguments/Elixir/command-line-arguments-2.ex rename to Task/Command-line-arguments/Elixir/command-line-arguments-2.elixir diff --git a/Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.el b/Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.l similarity index 100% rename from Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.el rename to Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.l diff --git a/Task/Command-line-arguments/Euphoria/command-line-arguments.eu b/Task/Command-line-arguments/Euphoria/command-line-arguments.euphoria similarity index 100% rename from Task/Command-line-arguments/Euphoria/command-line-arguments.eu rename to Task/Command-line-arguments/Euphoria/command-line-arguments.euphoria diff --git a/Task/Command-line-arguments/Free-Pascal-Lazarus/command-line-arguments.pas b/Task/Command-line-arguments/Free-Pascal/command-line-arguments.pas similarity index 100% rename from Task/Command-line-arguments/Free-Pascal-Lazarus/command-line-arguments.pas rename to Task/Command-line-arguments/Free-Pascal/command-line-arguments.pas diff --git a/Task/Command-line-arguments/FutureBasic/command-line-arguments.basic b/Task/Command-line-arguments/FutureBasic/command-line-arguments.basic deleted file mode 100644 index ed30014088..0000000000 --- a/Task/Command-line-arguments/FutureBasic/command-line-arguments.basic +++ /dev/null @@ -1,14 +0,0 @@ -include "NSLog.incl" - -void local fn DoCommandLineArguments - CFArrayRef args = fn ProcessInfoArguments - NSLog(@"This program is named %@.",args[0]) - NSLog(@"There are %d arguments.",len(args)-1) - for long i = 1 to len(args)-1 - NSLog(@"the argument #%d is %@", i, args[i]) - next -end fn - -fn DoCommandLineArguments - -HandleEvents diff --git a/Task/Command-line-arguments/Julia/command-line-arguments.jl b/Task/Command-line-arguments/Julia/command-line-arguments.julia similarity index 100% rename from Task/Command-line-arguments/Julia/command-line-arguments.jl rename to Task/Command-line-arguments/Julia/command-line-arguments.julia diff --git a/Task/Command-line-arguments/Kotlin/command-line-arguments.kts b/Task/Command-line-arguments/Kotlin/command-line-arguments.kotlin similarity index 100% rename from Task/Command-line-arguments/Kotlin/command-line-arguments.kts rename to Task/Command-line-arguments/Kotlin/command-line-arguments.kotlin diff --git a/Task/Command-line-arguments/LDPL/command-line-arguments-1.ldpl b/Task/Command-line-arguments/LDPL/command-line-arguments-1.ldpl deleted file mode 100644 index 26aa218485..0000000000 --- a/Task/Command-line-arguments/LDPL/command-line-arguments-1.ldpl +++ /dev/null @@ -1,10 +0,0 @@ -DATA: - argument_count IS NUMBER - -PROCEDURE: - GET LENGTH OF argv IN argument_count - IF argument_count IS EQUAL TO 0 THEN - DISPLAY "No arguments!" CRLF - ELSE - DISPLAY argv:0 CRLF - END IF diff --git a/Task/Command-line-arguments/LDPL/command-line-arguments-2.ldpl b/Task/Command-line-arguments/LDPL/command-line-arguments-2.ldpl deleted file mode 100644 index 6cc4b9df78..0000000000 --- a/Task/Command-line-arguments/LDPL/command-line-arguments-2.ldpl +++ /dev/null @@ -1,6 +0,0 @@ -$ ldpl argv.ldpl -* Loading argv.ldpl -* Compiling argv.ldpl -* Building argv-bin -* Saved as argv-bin -* File(s) compiled successfully. diff --git a/Task/Command-line-arguments/LDPL/command-line-arguments-3.ldpl b/Task/Command-line-arguments/LDPL/command-line-arguments-3.ldpl deleted file mode 100644 index ff51e1fe0c..0000000000 --- a/Task/Command-line-arguments/LDPL/command-line-arguments-3.ldpl +++ /dev/null @@ -1,4 +0,0 @@ -$ ./argv-bin test -test -$ ./argv-bin -No arguments! diff --git a/Task/Command-line-arguments/Nu/command-line-arguments.nu b/Task/Command-line-arguments/Nu/command-line-arguments.nu deleted file mode 100644 index dfa5746f77..0000000000 --- a/Task/Command-line-arguments/Nu/command-line-arguments.nu +++ /dev/null @@ -1,3 +0,0 @@ -def main [...argv] { - $argv | print -} diff --git a/Task/Command-line-arguments/OCaml/command-line-arguments-1.ml b/Task/Command-line-arguments/OCaml/command-line-arguments-1.ocaml similarity index 100% rename from Task/Command-line-arguments/OCaml/command-line-arguments-1.ml rename to Task/Command-line-arguments/OCaml/command-line-arguments-1.ocaml diff --git a/Task/Command-line-arguments/OCaml/command-line-arguments-2.ml b/Task/Command-line-arguments/OCaml/command-line-arguments-2.ocaml similarity index 100% rename from Task/Command-line-arguments/OCaml/command-line-arguments-2.ml rename to Task/Command-line-arguments/OCaml/command-line-arguments-2.ocaml diff --git a/Task/Command-line-arguments/Oberon/command-line-arguments.oberon b/Task/Command-line-arguments/Oberon-2/command-line-arguments.oberon similarity index 100% rename from Task/Command-line-arguments/Oberon/command-line-arguments.oberon rename to Task/Command-line-arguments/Oberon-2/command-line-arguments.oberon diff --git a/Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas b/Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas deleted file mode 100644 index 657c2b12b1..0000000000 --- a/Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas +++ /dev/null @@ -1,4 +0,0 @@ -begin - for var i:=1 to ParamCount do - Print(ParamStr(i)); -end. diff --git a/Task/Command-line-arguments/Pluto/command-line-arguments.pluto b/Task/Command-line-arguments/Pluto/command-line-arguments.pluto deleted file mode 100644 index b002fdaeb6..0000000000 --- a/Task/Command-line-arguments/Pluto/command-line-arguments.pluto +++ /dev/null @@ -1 +0,0 @@ -arg:slice(1):foreach(print) diff --git a/Task/Command-line-arguments/PowerShell/command-line-arguments.ps1 b/Task/Command-line-arguments/PowerShell/command-line-arguments.psh similarity index 100% rename from Task/Command-line-arguments/PowerShell/command-line-arguments.ps1 rename to Task/Command-line-arguments/PowerShell/command-line-arguments.psh diff --git a/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx b/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx index 7d8785a1c8..2355afa823 100644 --- a/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx +++ b/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx @@ -1,32 +1,2 @@ --- 12 Sep 2025 -include Setting - --- Use arguments -c "alpha beta" -h "gamma" -say 'COMMAND-LINE ARGUMENTS (SPACE SEPARATED)' -say version -say -say 'parse arg xx:' -parse arg xx; say 'xx='xx -say -say 'arg xx:' -arg xx; say 'xx='xx -say -say 'arg x1 x2 x3 x4 x5:' -arg x1 x2 x3 x4 x5; say 'x1='x1 'x2='x2 'x3='x3 'x4='x4 'x5='x5 -say -say 'parse arg x1 x2 x3 x4 x5:' -parse arg x1 x2 x3 x4 x5; say 'x1='x1 'x2='x2 'x3='x3 'x4='x4 'x5='x5 -say -say 'arg x1 . x3 (placeholder):' -arg x1 . x3; say 'x1='x1 'x3='x3 -say -say 'Arg(1):' -say Arg(1) -say -say 'Words:' -do n = 1 to Words(Arg(1)) - say 'n='n 'Word(Arg(1),n)='Word(Arg(1),n) -end -exit - -include Abend +say 'command arguments:' +say arg(1) diff --git a/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx b/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx index 3b97099b75..bd43c95964 100644 --- a/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx +++ b/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx @@ -1,27 +1,22 @@ --- 12 Sep 2025 -include Setting +parse arg aaa /*get the arguments. */ + /*another version: */ + /* aaa=arg(1) */ +say 'command arguments:' +say aaa --- Use arguments -c,alpha beta,-h,gamma -say 'COMMAND-LINE ARGUMENTS (COMMA SEPARATED)' -say version -say -say 'parse arg xx:' -parse arg xx; say xx -say -say 'arg xx:' -arg xx; say xx -say -say 'parse arg x1,x2,x3,x4:' -parse arg x1','x2','x3','x4; say 'x1' x1 'x2' x2 'x3' x3 'x4' x4 -say -say 'arg x1,x2,x3,x4:' -arg x1','x2','x3','x4; say 'x1' x1 'x2' x2 'x3' x3 'x4' x4 -say -say 'parse arg x1,.,x3 (placeholder):' -parse arg x1','.','x3; say 'x1' x1 'x3' x3 -say -say 'arg(1):' -say arg(1) -exit +opts='' /*placeholder for options. */ +data='' /*placeholder for data. */ -include Abend + do j=1 to words(aaa) + x=word(aaa,j) + if left(x,1)=='-' then opts=opts x /*Option? Then add to opts.*/ + else data=data x /*Must be data. Add to data.*/ + end + + /*the above process adds a leading blank to OPTS and DATA*/ + +opts=strip(opts,'L') /*strip leading blanks. */ +data=strip(data,'l') /*strip leading blanks. */ +say +say 'options='opts +say ' data='data diff --git a/Task/Command-line-arguments/Rust/command-line-arguments-1.rs b/Task/Command-line-arguments/Rust/command-line-arguments-1.rust similarity index 100% rename from Task/Command-line-arguments/Rust/command-line-arguments-1.rs rename to Task/Command-line-arguments/Rust/command-line-arguments-1.rust diff --git a/Task/Command-line-arguments/Rust/command-line-arguments-2.rs b/Task/Command-line-arguments/Rust/command-line-arguments-2.rust similarity index 100% rename from Task/Command-line-arguments/Rust/command-line-arguments-2.rs rename to Task/Command-line-arguments/Rust/command-line-arguments-2.rust diff --git a/Task/Command-line-arguments/Scheme/command-line-arguments.scm b/Task/Command-line-arguments/Scheme/command-line-arguments.ss similarity index 100% rename from Task/Command-line-arguments/Scheme/command-line-arguments.scm rename to Task/Command-line-arguments/Scheme/command-line-arguments.ss diff --git a/Task/Command-line-arguments/TAV/command-line-arguments.tav b/Task/Command-line-arguments/TAV/command-line-arguments.tav deleted file mode 100644 index 9586ed1181..0000000000 --- a/Task/Command-line-arguments/TAV/command-line-arguments.tav +++ /dev/null @@ -1,3 +0,0 @@ -main (parms):+ - ?# i =: give keys parms - print i __ parms[i] diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments-1.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments-1.tcl deleted file mode 100644 index 3e39085837..0000000000 --- a/Task/Command-line-arguments/Tcl/command-line-arguments-1.tcl +++ /dev/null @@ -1,3 +0,0 @@ -if { $argc >= 1 } { - puts [lindex $argv 0] -} diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments-2.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments-2.tcl deleted file mode 100644 index 8db1f98495..0000000000 --- a/Task/Command-line-arguments/Tcl/command-line-arguments-2.tcl +++ /dev/null @@ -1,2 +0,0 @@ -$ tclsh file.tcl test -test diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments.tcl new file mode 100644 index 0000000000..0827817f9e --- /dev/null +++ b/Task/Command-line-arguments/Tcl/command-line-arguments.tcl @@ -0,0 +1,3 @@ +if { $argc > 1 } { + puts [lindex $argv 1] +} diff --git a/Task/Command-line-arguments/Uiua/command-line-arguments.uiua b/Task/Command-line-arguments/Uiua/command-line-arguments.uiua deleted file mode 100644 index 6d3c8fe5b3..0000000000 --- a/Task/Command-line-arguments/Uiua/command-line-arguments.uiua +++ /dev/null @@ -1 +0,0 @@ -&args diff --git a/Task/Command-line-arguments/VBScript/command-line-arguments.vbs b/Task/Command-line-arguments/VBScript/command-line-arguments.vb similarity index 100% rename from Task/Command-line-arguments/VBScript/command-line-arguments.vbs rename to Task/Command-line-arguments/VBScript/command-line-arguments.vb diff --git a/Task/Command-line-arguments/X86-64-Assembly/command-line-arguments.x86-64 b/Task/Command-line-arguments/X86-64-Assembly/command-line-arguments.x86-64 deleted file mode 100644 index 42af33fb12..0000000000 --- a/Task/Command-line-arguments/X86-64-Assembly/command-line-arguments.x86-64 +++ /dev/null @@ -1,58 +0,0 @@ -format ELF64 executable 3 -entry start - -segment executable readable -start: - pop rax ; pop argc off stack. It should be at least 1 - .loop0: - pop rdi ; pop the pointer to argument string off stack - call prints ; call a function to print a string - mov rdi, 0x0a ; parameter to next function. 0x0a = line feed = 10 - call printc ; call a function to print a single character - dec rax ; decrement RAX. - jnz .loop0 ; get next argument if RAX is not yet 0 - .exit: - mov rax, 60 - mov rdi, 0 - syscall - -prints: ; function that prints a zero terminated string - push rax - push rdi - push rsi - push rdx - xor rdx, rdx - cmp byte [rdi + rdx], 0 - je .return - .stloop: - cmp byte [rdi + rdx], 0 - je .printit - inc rdx - jmp .stloop - .printit: - mov rax, 1 - mov rsi, rdi - mov rdi, 1 - syscall - .return: - pop rdx - pop rsi - pop rdi - pop rax - ret - -printc: ;function that prints a single character in rdi (dil). - push rax - push rsi - push rdx - push rdi - mov rax, 1 - mov rdi, 1 - mov rsi, rsp - mov rdx, 1 - syscall - pop rdi - pop rdx - pop rsi - pop rax - ret diff --git a/Task/Command-line-arguments/Zig/command-line-arguments.zig b/Task/Command-line-arguments/Zig/command-line-arguments.zig deleted file mode 100644 index 5b35ff255c..0000000000 --- a/Task/Command-line-arguments/Zig/command-line-arguments.zig +++ /dev/null @@ -1,13 +0,0 @@ -const std = @import("std"); - -pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - - var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); - defer arena.deinit(); - const allocator = arena.allocator(); - - const args = try std.process.argsAlloc(allocator); - - try stdout.print("{s}\n", .{args}); -} diff --git a/Task/Commatizing-numbers/ALGOL-68/commatizing-numbers.alg b/Task/Commatizing-numbers/ALGOL-68/commatizing-numbers.alg index 161b62d233..290bfb3719 100644 --- a/Task/Commatizing-numbers/ALGOL-68/commatizing-numbers.alg +++ b/Task/Commatizing-numbers/ALGOL-68/commatizing-numbers.alg @@ -53,48 +53,35 @@ PROC commatize = ( STRING text, INT location, INT period, STRING separator )STRI # commatizing procedure # MODE COMMATIZINGOPTIONS = STRUCT( STRING text, INT location, INT period, STRING separator ); PRIO LOCATION = 9; -OP LOCATION = ( STRING text, INT location )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text, location, 0, "" ); +OP LOCATION = ( STRING text, INT location )COMMATIZINGOPTIONS: COMMATIZINGOPTIONS( text, location, 0, "" ); PRIO PERIOD = 9; -OP PERIOD = ( STRING text, INT period )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text, 0, period, "" ); +OP PERIOD = ( STRING text, INT period )COMMATIZINGOPTIONS: COMMATIZINGOPTIONS( text, 0, period, "" ); PRIO SEPARATOR = 9; -OP SEPARATOR = ( STRING text, CHAR separator )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text, 0, 0, separator ); -OP SEPARATOR = ( STRING text, STRING separator )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text, 0, 0, separator ); +OP SEPARATOR = ( STRING text, CHAR separator )COMMATIZINGOPTIONS: COMMATIZINGOPTIONS( text, 0, 0, separator ); +OP SEPARATOR = ( STRING text, STRING separator )COMMATIZINGOPTIONS: COMMATIZINGOPTIONS( text, 0, 0, separator ); OP LOCATION = ( COMMATIZINGOPTIONS opts, INT location )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text OF opts, location, period OF opts, separator OF opts ); + COMMATIZINGOPTIONS( text OF opts, location, period OF opts, separator OF opts ); OP PERIOD = ( COMMATIZINGOPTIONS opts, INT period )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text OF opts, location OF opts, period, separator OF opts ); + COMMATIZINGOPTIONS( text OF opts, location OF opts, period, separator OF opts ); OP SEPARATOR = ( COMMATIZINGOPTIONS opts, CHAR separator )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text OF opts, location OF opts, period OF opts, separator ); + COMMATIZINGOPTIONS( text OF opts, location OF opts, period OF opts, separator ); OP SEPARATOR = ( COMMATIZINGOPTIONS opts, STRING separator )COMMATIZINGOPTIONS: - COMMATIZINGOPTIONS( text OF opts, location OF opts, period OF opts, separator ); + COMMATIZINGOPTIONS( text OF opts, location OF opts, period OF opts, separator ); OP COMMATIZE = ( STRING text )STRING: commatize( text, 0, 0, "" ); OP COMMATIZE = ( COMMATIZINGOPTIONS opts )STRING: - commatize( text OF opts, location OF opts, period OF opts, separator OF opts ); + commatize( text OF opts, location OF opts, period OF opts, separator OF opts ); # test the commatization procedure and operators # -print( ( COMMATIZE( "pi=3.14159265358979323846264338327950288419716939937510582097494459231" - PERIOD 5 SEPARATOR " " LOCATION 6 ), newline ) ); -print( ( COMMATIZE( "The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." - SEPARATOR "." ), newline ) ); -print( ( COMMATIZE( "The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." - SEPARATOR "." PERIOD 6 ), newline ) ); -print( ( COMMATIZE( "The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." - SEPARATOR "__" ), newline ) ); -print( ( COMMATIZE( "The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." - LOCATION 26 PERIOD 1 SEPARATOR "::" ), newline ) ); -print( ( COMMATIZE """-in Aus$+1411.8millions""", newline ) ); -print( ( COMMATIZE "===US$0017440 millions=== (in 2000 dollars)", newline ) ); -print( ( COMMATIZE "123.e8000 is pretty big.", newline ) ); -print( ( COMMATIZE "The land area of the earth is 57268900(29% of the surface) square miles.", newline ) ); -print( ( COMMATIZE "Ain't no numbers in this here words, nohow, no way, Jose.", newline ) ); -print( ( COMMATIZE "James was never known as 0000000007", newline ) ); -print( ( COMMATIZE ( "Arthur Eddington wrote: I believe there are " - + "15747724136275002577605653961181555468044717914527116709366231425076185631031296 " - + "protons in the universe." - ), newline ) ); -print( ( COMMATIZE " $-140000±100 millions.", newline ) ); -print( ( COMMATIZE "6/9/1946 was a good year for some.", newline ) ) +print( ( COMMATIZE( "pi=3.14159265358979323846264338327950288419716939937510582097494459231" PERIOD 5 SEPARATOR " " LOCATION 6 ), + newline ) ); +print( ( COMMATIZE( "The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." SEPARATOR "." ), newline ) ); +print( ( COMMATIZE """-in Aus$+1411.8millions""", newline ) ); +print( ( COMMATIZE "===US$0017440 millions=== (in 2000 dollars)", newline ) ); +print( ( COMMATIZE "123.e8000 is pretty big.", newline ) ); +print( ( COMMATIZE "The land area of the earth is 57268900(29% of the surface) square miles.", newline ) ); +print( ( COMMATIZE "Ain't no numbers in this here words, nohow, no way, Jose.", newline ) ); +print( ( COMMATIZE "James was never known as 0000000007", newline ) ); +print( ( COMMATIZE "Arthur Eddington wrote: I believe there are 15747724136275002577605653961181555468044717914527116709366231425076185631031296 protons in the universe.", + newline ) ); +print( ( COMMATIZE " $-140000±100 millions.", newline ) ); +print( ( COMMATIZE "6/9/1946 was a good year for some.", newline ) ) diff --git a/Task/Commatizing-numbers/Ballerina/commatizing-numbers.ballerina b/Task/Commatizing-numbers/Ballerina/commatizing-numbers.ballerina deleted file mode 100644 index 9b5aaf9eca..0000000000 --- a/Task/Commatizing-numbers/Ballerina/commatizing-numbers.ballerina +++ /dev/null @@ -1,90 +0,0 @@ -import ballerina/io; - -function commatize(string s, int begin = 0, int step = 3, string sep = ",") { - var invert = function(string n) returns string { - string t = ""; - foreach int i in int:range(n.length() - 1, -1, -1) { t += n[i]; } - return t; - }; - - var addSeps = function(string nn, boolean dp) returns string { - string n = nn; - string lz = ""; - if !dp && n.startsWith("0") && n != "0" { - string:RegExp pattern = re `^0+`; - string k = pattern.replace(n, ""); - if k == "" { k = "0"; } - foreach int i in 1 ... n.length() - k.length() { lz += "0"; } - n = k; - } - if dp { n = invert(n); } // invert if after decimal point - int i = n.length() - step; - while i >= 1 { - n = n.substring(0, i) + sep + n.substring(i); - i -= step; - } - if dp { n = invert(n); } // invert back - return lz + n; - }; - - var isExponent = function(string:Char c) returns boolean { - return "eEdDpP^∙x↑*⁰¹²³⁴⁵⁶⁷⁸⁹".includes(c); - }; - - string t = s; - string acc = (begin == 0) ? "" : t.substring(0, begin); - string n = ""; - boolean dp = false; - foreach int j in begin ..< t.length() { - string:Char c = t[j]; - if c >= "0" && c <= "9" { - n += t[j]; - if j == t.length() - 1 { - if acc != "" && isExponent(acc[acc.length() - 1]) { - acc = s; - } else { - acc += addSeps(n, dp); - } - } - } else if n != "" { - if acc != "" && isExponent(acc[acc.length() - 1]) { - acc = s; - break; - } else if t[j] != "." { - acc += addSeps(n, dp) + t.substring(j); - break; - } else { - acc += addSeps(n, dp) + t[j]; - dp = true; - n = ""; - } - } else { - acc += t[j]; - } - } - io:println(s); - io:println(acc); - io:println(); -} - -public function main() { - commatize("123456789.123456789", 0, 2, "*"); - commatize(".123456789", 0, 3, "-"); - commatize("57256.1D-4", 0, 4, "__"); - commatize("pi=3.14159265358979323846264338327950288419716939937510582097494459231", 0, 5, " "); - commatize("The author has two Z$100000000000000 Zimbabwe notes (100 trillion).", 0, 3, "."); - - string[] defaults = [ - "\"-in Aus$+1411.8millions\"", - "===US$0017440 millions=== (in 2000 dollars)", - "123.e8000 is pretty big.", - "The land area of the earth is 57268900(29% of the surface) square miles.", - "Ain't no numbers in this here words, nohow, no way, Jose.", - "James was never known as 0000000007", - "Arthur Eddington wrote: I believe there are 15747724136275002577605653961181555468044717914527116709366231425076185631031296 protons in the universe.", - " $-140000±100 millions.", - "6/9/1946 was a good year for some." - ]; - - foreach string d in defaults { commatize(d); } -} diff --git a/Task/Commatizing-numbers/C++/commatizing-numbers.cpp b/Task/Commatizing-numbers/C++/commatizing-numbers.cpp deleted file mode 100644 index f9e7ce9e09..0000000000 --- a/Task/Commatizing-numbers/C++/commatizing-numbers.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include - -bool contains(const std::string& haystack, const char needle) { - return haystack.find(needle) != std::string::npos; -} - -void commatize(std::string text, const int32_t& start_index = 0, - const int32_t& step = 3, const std::string& separator = ",") { - std::cout << "Before: " << text << std::endl; - const int32_t size = text.size(); - - for ( int32_t i = start_index; i < size; ++i ) { - if ( contains("123456789", text[i]) ) { - for ( int32_t j = i + 1; j <= size; ++j ) { - if ( j > size || ! contains("0123456789", text[j]) ) { - for ( int32_t k = j - 1 - step; k >= i; k -= step ) { - text.insert(k + 1, separator); - } - break; - } - } - break; - } - } - - std::cout << " After: " << text << std::endl << std::endl; -} - -int main() { - commatize("pi=3.14159265358979323846264338327950288419716939937510582097494459231", 6, 5, " "); - commatize("The author has two Z$100000000000000 Zimbabwe notes (100 trillion)."); - commatize("\"-in Aus$+1411.8millions\""); - commatize("===US$0017440 millions=== (in 2000 dollars)"); - commatize("123.e8000 is pretty big."); - commatize("The land area of the earth is 57268900(29% of the surface) square miles."); - commatize("Ain't no numbers in this here words, nohow, no way, Jose."); - commatize("James was never known as 0000000007"); - commatize("Arthur Eddington wrote: I believe there are " - "15747724136275002577605653961181555468044717914527116709366231425076185631031296" - " protons in the universe."); - commatize(" $-140000±100 millions."); - commatize("6/9/1946 was a good year for some."); -} diff --git a/Task/Commatizing-numbers/Delphi/commatizing-numbers.pas b/Task/Commatizing-numbers/Delphi/commatizing-numbers.delphi similarity index 100% rename from Task/Commatizing-numbers/Delphi/commatizing-numbers.pas rename to Task/Commatizing-numbers/Delphi/commatizing-numbers.delphi diff --git a/Task/Commatizing-numbers/Fortran/commatizing-numbers.f b/Task/Commatizing-numbers/Fortran/commatizing-numbers.f deleted file mode 100644 index 626b9ccf8f..0000000000 --- a/Task/Commatizing-numbers/Fortran/commatizing-numbers.f +++ /dev/null @@ -1,207 +0,0 @@ -! Commatizing numbers -! -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.04 -! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! Note that VSI Fortran on VMS does not compile this code because its current version -! cannot handle allocatable character strings -! -! U.B., August 2025 -! -program commatisator - -implicit none - -logical, parameter ::DEBUG=.false. - - -call commatize("pi=3.14159265358979323846264338327950288419716939937510582097494459231", 3, 5) -call commatize("The author has two Z$100000000000000 Zimbabwe notes (100 trillion).", 1,3, '.') ! Use decimal point as separator -call commatize('"-in Aus$+1411.8millions"') ! Here the double quotes (") are part of the text. -call commatize("===US$0017440 millions=== (in 2000 dollars)") -call commatize("123.e8000 is pretty big.") -call commatize("The land area of the earth is 57268900(29% of the surface) square miles.") -call commatize("Ain't no numbers in this here words, nohow, no way, Jose.") -call commatize("James was never known as 0000000007", 0,3) -call commatize("Arthur Eddington wrote: I believe there are " // & - "15747724136275002577605653961181555468044717914527116709366231425076185631031296" // & - " protons in the universe.") -call commatize(" $-140000±100 millions.") -call commatize("6/9/1946 was a good year for some.") - -contains - -subroutine commatize (text, astartIdx, agroupSize, aseparator) - ! Arguments - character(*), intent(in) :: text - integer, intent(in), optional :: astartIdx - integer, intent(in), optional :: agroupSize - character, intent(in), optional :: aseparator - - ! These variables are there even if optional args are omitted. - integer :: startIdx - integer :: groupSize - character :: separator - - integer :: sz, ii - integer :: ipBegin, ipPoint, ipEnd - - character(:), allocatable :: newtext - ! - ! Defaults for optional arguments - ! and protect against invalid arguments - if (present (astartIdx)) then - startIDx = max (1, astartidx) - else - startIdx = 1 - endif - if (present (agroupSize)) then - groupsize = max(1, agroupsize) - else - groupsize = 3 - endif - if (present (aseparator)) then - separator = aseparator - else - separator = ',' - endif - - sz = len (text) - ipBegin = 0 - ipPoint = 0 - ipEnd = 0 - - ! Find beginning and end of the first numeric part of the string - do ii=startidx,sz - if (isadigit (text(ii:ii), '1','9')) then ! ignoring leading zeroes - ipBegin = ii - exit ! Only the very first number is of any interest. - else if (text(ii:ii) .eq. '.') then ! Leading Decimal point - if (ii .lt. sz) then - if (isadigit (text(ii+1:ii+1), '0','9')) then ! must be followed by a valid digit - ! Entire number starts here, it is something valid like ".123" - if (DEBUG) print *, 'Decimal point detected at ii,sz= ', ii, sz - ipBegin = ii - ipPoint = ii - exit - endif - endif - end if - end do - - ! Any number detected? Search for the end and, if necessary, the decimal point - if (ipBegin .gt. 0 .and. ipBegin .le. sz) then - do ii=ipBegin+1, sz+1 - if (ii > sz) then - ipEnd = sz - else if (text(ii:ii) .eq. '.' .and. ipPoint .eq. 0 .and. ii .lt. sz ) then - if (isadigit (text(ii+1:ii+1), '0','9')) then ! Decimal point must be followed by valid digit - ipPoint = ii - else - ipEnd = ii-1 ! Might be valid decimal point, but terminates the number. - exit ! no need to continue, have found the end. - endif - else if (.not. isadigit (text(ii:ii), '0','9')) then ! Anything other than a digit or point terminated the number. - ipEnd = ii-1 - exit - end if - enddo - end if - - ! Found a number? - ! Three possibe cases: real number (>=1) with decimal point and digits before and after - ! real number (<1) starting with decimal point such as .71 - ! integer number without decimal point. - if (ipBegin .ne. 0) then ! Any nmumber - if (ipPoint .gt. ipbegin) then ! Not starting with a decimal point but decimal point inside - if (ipBegin .gt. 1) then - newtext = text (:ipBegin-1) ! copy entire text before the numeric - else - newtext = '' ! In any case variable 'newtext' must be initialized - end if - newtext = newtext // setSeparators (text, ipPoint-1, ipBegin, & - groupsize, separator , requiredSize (ipPoint-1, ipBegin, groupsize)) // '.' - newtext = newtext // setSeparators (text, ipPoint+1, ipEnd, & - groupsize, separator, requiredSize (ipPoint+1, ipEnd ,groupsize)) - else if (ipPoint .ne. 0 .and. ipPoint .lt. sz) then ! Starting with decimal point - newtext = '.' // setSeparators (text, ipPoint+1, ipEnd, & - groupsize, separator, requiredSize (ipPoint+1, ipEnd,groupsize) ) - else ! Integer number - newtext = text (:ipBegin-1) // setSeparators (text, ipEnd, ipBegin, & - groupsize, separator, requiredSize (ipEnd, ipBegin, groupsize) ) - endif - if (ipEnd .lt. sz) then - newtext = newtext // text (ipend+1:) ! Append alltext behind the number - endif - else ! No number, just print straight copy - newtext = text - endif - - print '("Before: ", A)' , text - print '(" After: ", A/)', newtext - - -end subroutine commatize - - ! estimate how many separators wii be needed in a given range of digits - ! and calculate the new tring length therefrom. - function requiredSize (i0,i1,step) result (size) - integer, intent(in) :: i0, i1, step - integer :: size - integer :: l,c - - l = iabs (i1-i0) + 1 ! Length of the string to be considered - c = (l-1) / step ! Number of separators to insert - - size = l + c - end function requiredSize - - ! Insert separators into a numerical string - function setSeparators (text, i0, i1, step, separator, resSize ) result (ntext ) - character(*), intent(in) :: text ! entire text - integer, intent(in) :: i0,i1 ! The numeric part goes from i0 to i1 (incl) - integer, intent(in) :: step ! the group size between separators - character, intent(in) :: separator ! the separator character - integer, intent(in) :: resSize ! New size of result string - character(len=resSize) :: ntext ! The resultant string, including th e separators - integer :: ii, jj, cnt, direction ! Helpers - - ! character-wise copy the old text into new text - ! Loop index can go into either direction - if (i0 .gt. i1 ) then - direction = -1 - else - direction = 1 - end if - - ! Position of text(ii:ii) inside the resultant text - if (i0 .lt. i1) then - jj = 1 - else - jj = resSize - end if - - cnt = 0 - do ii = i0, i1, direction - ntext (jj:jj) = text (ii:ii) ! Copy characters - jj = jj + direction - cnt = cnt + 1 ! count copied characters - ! Group complete? Insert separator - if (cnt .eq. step .and. jj .gt. 0 .and. jj .lt. resSize) then - ntext(jj:jj) = separator - jj = jj + direction - cnt = 0 - end if - end do - end function setSeparators - -! Decide if a given character c is a digit in the range from "from" to "to". -function isadigit (c, from, to) result (YN) - character, intent(in) :: c, from, to - logical :: YN - - YN = c>= from .and. c<=to -end function isadigit - - - -end program commatisator diff --git a/Task/Commatizing-numbers/JavaScript/commatizing-numbers.js b/Task/Commatizing-numbers/JavaScript/commatizing-numbers.js deleted file mode 100644 index ab6c8185ab..0000000000 --- a/Task/Commatizing-numbers/JavaScript/commatizing-numbers.js +++ /dev/null @@ -1,42 +0,0 @@ -function contains(haystack, needle) { - return haystack.indexOf(needle) !== -1; -} - -function commatize(text, start_index = 0, step = 3, separator = ",") { - console.log("Before: " + text); - const size = text.length; - - for (let i = start_index; i < size; ++i) { - if (contains("123456789", text[i])) { - for (let j = i + 1; j <= size; ++j) { - if (j > size || !contains("0123456789", text[j])) { - for (let k = j - 1 - step; k >= i; k -= step) { - text = text.slice(0, k + 1) + separator + text.slice(k + 1); - } - break; - } - } - break; - } - } - - console.log(" After: " + text + "\n"); -} - -function main() { - commatize("pi=3.14159265358979323846264338327950288419716939937510582097494459231", 6, 5, " "); - commatize("The author has two Z$100000000000000 Zimbabwe notes (100 trillion)."); - commatize("\"-in Aus$+1411.8millions\""); - commatize("===US$0017440 millions=== (in 2000 dollars)"); - commatize("123.e8000 is pretty big."); - commatize("The land area of the earth is 57268900(29% of the surface) square miles."); - commatize("Ain't no numbers in this here words, nohow, no way, Jose."); - commatize("James was never known as 0000000007"); - commatize("Arthur Eddington wrote: I believe there are " + - "15747724136275002577605653961181555468044717914527116709366231425076185631031296" + - " protons in the universe."); - commatize(" $-140000±100 millions."); - commatize("6/9/1946 was a good year for some."); -} - -main(); diff --git a/Task/Commatizing-numbers/Julia/commatizing-numbers.jl b/Task/Commatizing-numbers/Julia/commatizing-numbers.julia similarity index 100% rename from Task/Commatizing-numbers/Julia/commatizing-numbers.jl rename to Task/Commatizing-numbers/Julia/commatizing-numbers.julia diff --git a/Task/Commatizing-numbers/Kotlin/commatizing-numbers.kts b/Task/Commatizing-numbers/Kotlin/commatizing-numbers.kotlin similarity index 100% rename from Task/Commatizing-numbers/Kotlin/commatizing-numbers.kts rename to Task/Commatizing-numbers/Kotlin/commatizing-numbers.kotlin diff --git a/Task/Commatizing-numbers/Pluto/commatizing-numbers.pluto b/Task/Commatizing-numbers/Pluto/commatizing-numbers.pluto deleted file mode 100644 index a364a0fa06..0000000000 --- a/Task/Commatizing-numbers/Pluto/commatizing-numbers.pluto +++ /dev/null @@ -1,78 +0,0 @@ -require "uchar" - -local function commatize(s, start = 1, step = 3, sep = ",") - local function add_seps(n, dp) - local lz = "" - if !dp and n:startswith("0") and n != "0" then - local k = n:lstrip("0") - if k == "" then k = "0" end - lz = "0":rep(#n - #k) - n = k - end - if dp then n = n:reverse() end -- invert if after decimal point - local i = #n - step + 1 - while i >= 2 do - n = n:sub(1, i - 1) .. sep .. n:sub(i) - i -= step - end - if dp then n = n:reverse() end -- invert back - return lz .. n - end - - local function is_exponent(c) return c in "eEdDpP^∙x↑*⁰¹²³⁴⁵⁶⁷⁸⁹" end - - local t = uchar.of(s) - local acc = start == 1 ? "" : t:sub(1, start - 1) - local n = "" - local dp = false - for j = start, t:len() do - local c = t:get(j) - if c >= "0" and c <= "9" then - n ..= t:get(j) - if j == t:len() do - if acc != "" and is_exponent(acc[-1]) then - acc = s - else - acc ..= add_seps(n, dp) - end - end - elseif n != "" then - if acc != "" and is_exponent(acc[-1]) then - acc = s - break - elseif t:get(j) != "." then - acc ..= add_seps(n, dp) .. t:sub(j) - break - else - acc ..= add_seps(n, dp) .. t:get(j) - dp = true - n = "" - end - else - acc ..= t:get(j) - end - end - print(s); - print(acc); - print() -end - -commatize("123456789.123456789", 1, 2, "*") -commatize(".123456789", 1, 3, "-") -commatize("57256.1D-4", 1, 4, "__") -commatize("pi=3.14159265358979323846264338327950288419716939937510582097494459231", 1, 5, " ") -commatize("The author has two Z$100000000000000 Zimbabwe notes (100 trillion).", 1, 3, ".") - -local defaults = { - "\"-in Aus$+1411.8millions\"", - "===US$0017440 millions=== (in 2000 dollars)", - "123.e8000 is pretty big.", - "The land area of the earth is 57268900(29% of the surface) square miles.", - "Ain't no numbers in this here words, nohow, no way, Jose.", - "James was never known as 0000000007", - "Arthur Eddington wrote: I believe there are 15747724136275002577605653961181555468044717914527116709366231425076185631031296 protons in the universe.", - " $-140000±100 millions.", - "6/9/1946 was a good year for some." -} - -for defaults as d do commatize(d) end diff --git a/Task/Commatizing-numbers/Rust/commatizing-numbers.rs b/Task/Commatizing-numbers/Rust/commatizing-numbers.rs deleted file mode 100644 index cc7751fc9f..0000000000 --- a/Task/Commatizing-numbers/Rust/commatizing-numbers.rs +++ /dev/null @@ -1,45 +0,0 @@ -use itertools::Itertools; - -fn commatize(old_text: &str, start_index: usize, step: usize, sep: &str) -> String { - let mut text = old_text.to_string(); - let len = text.len(); - let textchars = text.chars().collect_vec(); - for i in start_index..len { - if "123456789".contains(textchars[i]) { - for j in i + 1..=len { - if j >= len || !"0123456789".contains(textchars[j]) { //start at end - if step <= j - i { - for k in (i..j - step).rev().step_by(step) { - text.insert_str(k + 1, sep); - } - break; - } - } - } - break; - } - } - return text; -} - -fn main() { - let tests = [ - ("pi=3.14159265358979323846264338327950288419716939937510582097494459231", 6, 5, " "), - ("The author has two Z$100000000000000 Zimbabwe notes (100 trillion).", 0, 3, ","), - ("\"-in Aus$+1411.8millions\"", 0, 3, ","), - ("===US$0017440 millions=== (in 2000 dollars)", 0, 3, ","), - ("123.e8000 is pretty big.", 0, 3, ","), - ("The land area of the earth is 57268900(29% of the surface) square miles.", 0, 3, ","), - ("Ain't no numbers in this here words, nohow, no way, Jose.", 0, 3, ","), - ("James was never known as 0000000007", 0, 3, ","), - ("Arthur Eddington wrote: I believe there are 15747724136275002577605653961181555468044717914527116709366231425076185631031296 protons in the universe.", 0, 3, ","), - (" $-140000±100 millions.", 0, 3, ","), - ("6/9/1946 was a good year for some.", 0, 3, ","),]; - for t in tests { - println!( - "Before: {}\nAfter: {}\n", - t.0, - commatize(t.0, t.1, t.2, t.3) - ); - } -} diff --git a/Task/Commatizing-numbers/VBScript/commatizing-numbers.vbs b/Task/Commatizing-numbers/VBScript/commatizing-numbers.vb similarity index 100% rename from Task/Commatizing-numbers/VBScript/commatizing-numbers.vbs rename to Task/Commatizing-numbers/VBScript/commatizing-numbers.vb diff --git a/Task/Comments/11l/comments.11l b/Task/Comments/11l/comments.11l new file mode 100644 index 0000000000..93be840d01 --- /dev/null +++ b/Task/Comments/11l/comments.11l @@ -0,0 +1,15 @@ +// Single line comment +\\ Also single line comment (continuation of the comment in previous line) + +\[ This is +a multi line +comment ] + +\{ And +this } + +\( And +this ) + +\‘ And +this ’ diff --git a/Task/Comments/Ada/comments.adb b/Task/Comments/Ada/comments.ada similarity index 100% rename from Task/Comments/Ada/comments.adb rename to Task/Comments/Ada/comments.ada diff --git a/Task/Comments/ArkScript/comments.ark b/Task/Comments/ArkScript/comments.ark deleted file mode 100644 index 3c09c8229b..0000000000 --- a/Task/Comments/ArkScript/comments.ark +++ /dev/null @@ -1,4 +0,0 @@ -# this is a comment - -# another comment -# with another below diff --git a/Task/Comments/AutoIt/comments.au3 b/Task/Comments/AutoIt/comments.au3 deleted file mode 100644 index 3fcfacc68f..0000000000 --- a/Task/Comments/AutoIt/comments.au3 +++ /dev/null @@ -1,5 +0,0 @@ -#cs -Everything between the cs and the ce is commented. -Commented code is not used by the computer. -#ce -;individual lines after a semicolon are commented. diff --git a/Task/Comments/AutoIt/comments.autoit b/Task/Comments/AutoIt/comments.autoit new file mode 100644 index 0000000000..260be4b084 --- /dev/null +++ b/Task/Comments/AutoIt/comments.autoit @@ -0,0 +1,5 @@ +#cs +Everything between the cs and and the ce is commented. +Commented code is not used by the computer. +#ce +;individual lines after a semicolon are commented. diff --git a/Task/Comments/Ballerina/comments.ballerina b/Task/Comments/Ballerina/comments.ballerina deleted file mode 100644 index 42158b75f2..0000000000 --- a/Task/Comments/Ballerina/comments.ballerina +++ /dev/null @@ -1,10 +0,0 @@ -// This is a single-line comment -int x = 10; // This is an inline comment - -# Represents a user record. -type User record { - # User's ID. - int id; - # User's name. - string name; -}; diff --git a/Task/Comments/Brainf---/comments-2.bf b/Task/Comments/Brainf---/comments-2.bf deleted file mode 100644 index 9b682b9f35..0000000000 --- a/Task/Comments/Brainf---/comments-2.bf +++ /dev/null @@ -1,3 +0,0 @@ -[ This is a header comment ] - -++++++++[->++++++++<]>. diff --git a/Task/Comments/Brainf---/comments-1.bf b/Task/Comments/Brainf---/comments.bf similarity index 100% rename from Task/Comments/Brainf---/comments-1.bf rename to Task/Comments/Brainf---/comments.bf diff --git a/Task/Comments/Bruijn/comments.bruijn b/Task/Comments/Bruijn/comments.bruijn deleted file mode 100644 index 7dd15c1854..0000000000 --- a/Task/Comments/Bruijn/comments.bruijn +++ /dev/null @@ -1 +0,0 @@ -# This is a comment diff --git a/Task/Comments/CMake/comments-1.cmake b/Task/Comments/CMake/comments-1.cmake deleted file mode 100644 index 3e26cd948c..0000000000 --- a/Task/Comments/CMake/comments-1.cmake +++ /dev/null @@ -1 +0,0 @@ -# A single-line comment diff --git a/Task/Comments/CMake/comments-2.cmake b/Task/Comments/CMake/comments-2.cmake deleted file mode 100644 index 8b9706c974..0000000000 --- a/Task/Comments/CMake/comments-2.cmake +++ /dev/null @@ -1,4 +0,0 @@ -#[[A multi-line - comment ]] -#[==[A multi-line comment - with [[nested brackets]]. ]==] diff --git a/Task/Comments/COBOL/comments-1.cob b/Task/Comments/COBOL/comments-1.cobol similarity index 100% rename from Task/Comments/COBOL/comments-1.cob rename to Task/Comments/COBOL/comments-1.cobol diff --git a/Task/Comments/COBOL/comments-2.cob b/Task/Comments/COBOL/comments-2.cobol similarity index 100% rename from Task/Comments/COBOL/comments-2.cob rename to Task/Comments/COBOL/comments-2.cobol diff --git a/Task/Comments/COBOL/comments-3.cob b/Task/Comments/COBOL/comments-3.cobol similarity index 100% rename from Task/Comments/COBOL/comments-3.cob rename to Task/Comments/COBOL/comments-3.cobol diff --git a/Task/Comments/COBOL/comments-4.cob b/Task/Comments/COBOL/comments-4.cobol similarity index 100% rename from Task/Comments/COBOL/comments-4.cob rename to Task/Comments/COBOL/comments-4.cobol diff --git a/Task/Comments/COBOL/comments-5.cob b/Task/Comments/COBOL/comments-5.cobol similarity index 100% rename from Task/Comments/COBOL/comments-5.cob rename to Task/Comments/COBOL/comments-5.cobol diff --git a/Task/Comments/COBOL/comments-6.cob b/Task/Comments/COBOL/comments-6.cobol similarity index 100% rename from Task/Comments/COBOL/comments-6.cob rename to Task/Comments/COBOL/comments-6.cobol diff --git a/Task/Comments/Chapel/comments.chpl b/Task/Comments/Chapel/comments.chapel similarity index 100% rename from Task/Comments/Chapel/comments.chpl rename to Task/Comments/Chapel/comments.chapel diff --git a/Task/Comments/Crystal/comments.cr b/Task/Comments/Crystal/comments.crystal similarity index 100% rename from Task/Comments/Crystal/comments.cr rename to Task/Comments/Crystal/comments.crystal diff --git a/Task/Comments/Delphi/comments.pas b/Task/Comments/Delphi/comments.delphi similarity index 100% rename from Task/Comments/Delphi/comments.pas rename to Task/Comments/Delphi/comments.delphi diff --git a/Task/Comments/Dragonstone/comments.dragonstone b/Task/Comments/Dragonstone/comments.dragonstone deleted file mode 100644 index e8359c75d5..0000000000 --- a/Task/Comments/Dragonstone/comments.dragonstone +++ /dev/null @@ -1,19 +0,0 @@ -#[ - Multi-Line Comment. -]# - -#[ - Nested Multi-Line Comment. - #[ - Inner comment. - #[ - It can go deep. - ]# - ]# - Outer comment. -]# - -# Single Line Comment - -#[ Multi-Line Comment on line ]# message = "Hello!" #[ Inside or Outside ]# -echo message # Another Trailing Comment. diff --git a/Task/Comments/EMal/comments.emal b/Task/Comments/EMal/comments.emal deleted file mode 100644 index 0742232c4f..0000000000 --- a/Task/Comments/EMal/comments.emal +++ /dev/null @@ -1,9 +0,0 @@ -# This is a line comment. -^|This is a single line block comment.|^ - -^| This is - | a multi-line - | block comment. - |^ - -^|This is a ^|nested|^ block comment.|^ diff --git a/Task/Comments/Ed/comments.ed b/Task/Comments/Ed/comments.ed deleted file mode 100644 index 8ae6029f77..0000000000 --- a/Task/Comments/Ed/comments.ed +++ /dev/null @@ -1,3 +0,0 @@ -# A single-line comment. -# The only type of comment, really. -# No block comments in ed diff --git a/Task/Comments/Elixir/comments.ex b/Task/Comments/Elixir/comments.elixir similarity index 100% rename from Task/Comments/Elixir/comments.ex rename to Task/Comments/Elixir/comments.elixir diff --git a/Task/Comments/Emacs-Lisp/comments-1.el b/Task/Comments/Emacs-Lisp/comments-1.l similarity index 100% rename from Task/Comments/Emacs-Lisp/comments-1.el rename to Task/Comments/Emacs-Lisp/comments-1.l diff --git a/Task/Comments/Emacs-Lisp/comments-2.el b/Task/Comments/Emacs-Lisp/comments-2.l similarity index 100% rename from Task/Comments/Emacs-Lisp/comments-2.el rename to Task/Comments/Emacs-Lisp/comments-2.l diff --git a/Task/Comments/Emacs-Lisp/comments-3.el b/Task/Comments/Emacs-Lisp/comments-3.l similarity index 100% rename from Task/Comments/Emacs-Lisp/comments-3.el rename to Task/Comments/Emacs-Lisp/comments-3.l diff --git a/Task/Comments/Euphoria/comments-1.eu b/Task/Comments/Euphoria/comments-1.euphoria similarity index 100% rename from Task/Comments/Euphoria/comments-1.eu rename to Task/Comments/Euphoria/comments-1.euphoria diff --git a/Task/Comments/Euphoria/comments-2.eu b/Task/Comments/Euphoria/comments-2.euphoria similarity index 100% rename from Task/Comments/Euphoria/comments-2.eu rename to Task/Comments/Euphoria/comments-2.euphoria diff --git a/Task/Comments/Fennel/comments.fennel b/Task/Comments/Fennel/comments.fennel deleted file mode 100644 index 082426ebfe..0000000000 --- a/Task/Comments/Fennel/comments.fennel +++ /dev/null @@ -1 +0,0 @@ -; This is a single-line comment diff --git a/Task/Comments/FutureBasic/comments.basic b/Task/Comments/FutureBasic/comments.basic index 52cd38da36..d05a6c06d6 100644 --- a/Task/Comments/FutureBasic/comments.basic +++ b/Task/Comments/FutureBasic/comments.basic @@ -1,4 +1,5 @@ // Single line comment +' Single line comment rem Single line comment /* Single line comment */ diff --git a/Task/Comments/Gleam/comments.gleam b/Task/Comments/Gleam/comments.gleam deleted file mode 100644 index cc85cea83d..0000000000 --- a/Task/Comments/Gleam/comments.gleam +++ /dev/null @@ -1 +0,0 @@ -// comments start with "//" and continue to the end of the line. diff --git a/Task/Comments/Haxe/comments.hx b/Task/Comments/Haxe/comments.haxe similarity index 100% rename from Task/Comments/Haxe/comments.hx rename to Task/Comments/Haxe/comments.haxe diff --git a/Task/Comments/Idris/comments.idris b/Task/Comments/Idris/comments.idris deleted file mode 100644 index 6494468b7c..0000000000 --- a/Task/Comments/Idris/comments.idris +++ /dev/null @@ -1,9 +0,0 @@ -(according to Gemini AI): - -Idris2 uses comment characters similar to Haskell: - -Single-line comments: Start with -- (two hyphens). Everything from -- to the end of the line is a comment. - -Multi-line comments: Enclosed by {- and -}. These can span multiple lines and can also be nested. - -Additionally, Idris2 supports inline documentation comments which begin with ||| (three pipe symbols). These are parsed by the compiler and can be used to generate documentation. diff --git a/Task/Comments/Insitux/comments.insitux b/Task/Comments/Insitux/comments.insitux deleted file mode 100644 index d201b5ca4e..0000000000 --- a/Task/Comments/Insitux/comments.insitux +++ /dev/null @@ -1,10 +0,0 @@ -;this is a comment; and using semicolons here is fine - -(+ 2 2) ;this is a comment - -"this string will be ignored if in the top scope -which can also stretch across -multiple lines" - -(do "if you're desperate, using do will make sure this string will not be returned also" - (+ 2 2)) diff --git a/Task/Comments/Janet/comments.janet b/Task/Comments/Janet/comments.janet deleted file mode 100644 index c72e9ad78b..0000000000 --- a/Task/Comments/Janet/comments.janet +++ /dev/null @@ -1,7 +0,0 @@ -(according to Gemini AI): - -The Janet programming language uses the # character for comments. - -Single-line comments: Everything from # to the end of the line is treated as a comment. - -Janet does not have built-in multi-line comments in the same way some other languages do (like {- ... -} in Idris2 or /* ... */ in C-like languages). However, because Janet is expression-oriented, you can often use multi-line strings as a form of "comment" if you put them in a context where their value isn't used. diff --git a/Task/Comments/Julia/comments.jl b/Task/Comments/Julia/comments.julia similarity index 100% rename from Task/Comments/Julia/comments.jl rename to Task/Comments/Julia/comments.julia diff --git a/Task/Comments/Kotlin/comments.kts b/Task/Comments/Kotlin/comments.kotlin similarity index 100% rename from Task/Comments/Kotlin/comments.kts rename to Task/Comments/Kotlin/comments.kotlin diff --git a/Task/Comments/MiniScript/comments.mini b/Task/Comments/MiniScript/comments.mini deleted file mode 100644 index 225d3cd667..0000000000 --- a/Task/Comments/MiniScript/comments.mini +++ /dev/null @@ -1,2 +0,0 @@ -// How many roads must a man walk down? -x = 6 * 7 // forty-two diff --git a/Task/Comments/Modula-2/comments.mod2 b/Task/Comments/Modula-2/comments.mod2 index c6c4b9311c..0d7a59997a 100644 --- a/Task/Comments/Modula-2/comments.mod2 +++ b/Task/Comments/Modula-2/comments.mod2 @@ -1,4 +1,3 @@ -(* Modula-2/Modula-3 use the same style of comments *) -(* ...and comments (* can nest *) +(* Comments (* can nest *) and they can span multiple lines. *) diff --git a/Task/Comments/Modula-3/comments.mod3 b/Task/Comments/Modula-3/comments.mod3 new file mode 100644 index 0000000000..0d7a59997a --- /dev/null +++ b/Task/Comments/Modula-3/comments.mod3 @@ -0,0 +1,3 @@ +(* Comments (* can nest *) + and they can span multiple lines. + *) diff --git a/Task/Comments/OCaml/comments.ml b/Task/Comments/OCaml/comments.ocaml similarity index 100% rename from Task/Comments/OCaml/comments.ml rename to Task/Comments/OCaml/comments.ocaml diff --git a/Task/Comments/OPL/comments.opl b/Task/Comments/OPL/comments.opl deleted file mode 100644 index 901aa3e30b..0000000000 --- a/Task/Comments/OPL/comments.opl +++ /dev/null @@ -1,2 +0,0 @@ -REM This is a comment. -PAUSE 20 REM Can be placed behind statements, too. diff --git a/Task/Comments/Oberon-2/comments.oberon b/Task/Comments/Oberon-2/comments.oberon new file mode 100644 index 0000000000..0af8c335d3 --- /dev/null +++ b/Task/Comments/Oberon-2/comments.oberon @@ -0,0 +1,6 @@ +(* this is a comment *) +(* + and this is a + multiline comment + (* with a nested comment *) +*) diff --git a/Task/Comments/Oberon/comments.oberon b/Task/Comments/Oberon/comments.oberon deleted file mode 100644 index 1177dbb75c..0000000000 --- a/Task/Comments/Oberon/comments.oberon +++ /dev/null @@ -1,6 +0,0 @@ -(* Oberon-07/Oberon-2 use the same style of comments as Modula-2: this is a comment *) -(* - and this is a - multiline comment - (* with a nested comment *) -*) diff --git a/Task/Comments/Odin/comments.odin b/Task/Comments/Odin/comments.odin deleted file mode 100644 index f8e21d0d05..0000000000 --- a/Task/Comments/Odin/comments.odin +++ /dev/null @@ -1,17 +0,0 @@ -(According to Gemini AI): - -The Odin programming language supports two types of comment characters: - -Single-line comments: Begin with //. - -Code snippet -// This is a single-line comment -my_variable: int // A comment for documentation -Multi-line comments: Begin with /* and end with */. Multi-line comments can also be nested. - -Code snippet -/* -This is a multi-line comment. -/* NOTE: comments can be nested! */ -You can have any text or code here and have it be commented. -*/ diff --git a/Task/Comments/PascalABC.NET/comments.pas b/Task/Comments/PascalABC.NET/comments.pas deleted file mode 100644 index 3af3369dfc..0000000000 --- a/Task/Comments/PascalABC.NET/comments.pas +++ /dev/null @@ -1,7 +0,0 @@ -(* This is a - multiline comment *) - -{ This is also a - multiline comment } - -// This is a single line comment diff --git a/Task/Comments/Phix/comments-1.phix b/Task/Comments/Phix/comments-1.phix index c1dc925cba..25289e8d1d 100644 --- a/Task/Comments/Phix/comments-1.phix +++ b/Task/Comments/Phix/comments-1.phix @@ -1,4 +1,3 @@ -(phixonline)--> - -- this is a comment. - // this is also a comment. +--> + -- This is a comment + with javascript_semantics + function allsame(sequence s) + for i=2 to length(s) do + if s[i]!=s[1] then return false end if + end for + return true + end function -function strict_order(sequence s) - for i=2 to length(s) do - if s[i]<=s[i-1] then return false end if - end for - return true -end function + function strict_order(sequence s) + for i=2 to length(s) do + if s[i]<=s[i-1] then return false end if + end for + return true + end function -procedure test(sequence s) - printf(1,"%-22V allsame:%5t, strict_order:%5t\n",{s,allsame(s),strict_order(s)}) -end procedure + procedure test(sequence s) + printf(1,"%-22V allsame:%5t, strict_order:%5t\n",{s,allsame(s),strict_order(s)}) + end procedure -test({"AA","BB","CC"}) -test({"AA","AA","AA"}) -test({"AA","CC","BB"}) -test({"AA","ACB","BB","CC"}) -test({"single_element"}) + test({"AA","BB","CC"}) + test({"AA","AA","AA"}) + test({"AA","CC","BB"}) + test({"AA","ACB","BB","CC"}) + test({"single_element"}) + + integer a,b + a = 10*9*8*7*6*5*4*3*2*1 + b = factorial(10) + ?{a,b} + + -- + -- demo\rosetta\Compiler\interp.exw + -- ================================ + -- + with javascript_semantics + include parse.e -sequence vars = {}, - vals = {} + sequence vars = {}, + vals = {} -function var_idx(sequence inode) - if inode[1]!=tk_Identifier then ?9/0 end if - string ident = inode[2] - integer n = find(ident,vars) - if n=0 then - vars = append(vars,ident) - vals = append(vals,0) - n = length(vars) - end if - return n -end function + function var_idx(sequence inode) + if inode[1]!=tk_Identifier then ?9/0 end if + string ident = inode[2] + integer n = find(ident,vars) + if n=0 then + vars = append(vars,ident) + vals = append(vals,0) + n = length(vars) + end if + return n + end function -function interp(object t) - if t!=NULL then - integer ntype = t[1] - object t2 = t[2], - t3 = iff(length(t)=3?t[3]:0) - switch ntype do - case tk_Sequence: {} = interp(t2) {} = interp(t3) - case tk_assign: vals[var_idx(t2)] = interp(t3) - case tk_Identifier: return vals[var_idx(t)] - case tk_Integer: return t2 - case tk_String: return t2 - case tk_lt: return interp(t2) < interp(t3) - case tk_add: return interp(t2) + interp(t3) - case tk_sub: return interp(t2) - interp(t3) - case tk_while: while interp(t2) do {} = interp(t3) end while - case tk_Prints: puts(1,interp(t2)) - case tk_Printi: printf(1,"%d",interp(t2)) - case tk_putc: printf(1,"%c",interp(t2)) - case tk_and: return interp(t2) and interp(t3) - case tk_or: return interp(t2) or interp(t3) - case tk_le: return interp(t2) <= interp(t3) - case tk_ge: return interp(t2) >= interp(t3) - case tk_ne: return interp(t2) != interp(t3) - case tk_gt: return interp(t2) > interp(t3) - case tk_mul: return interp(t2) * interp(t3) - case tk_div: return trunc(interp(t2)/interp(t3)) - case tk_mod: return remainder(interp(t2),interp(t3)) - case tk_if: {} = interp(t3[iff(interp(t2)?2:3)]) - case tk_not: return not interp(t2) - case tk_neg: return - interp(t2) - else - error("unknown node type") - end switch - end if - return NULL -end function + function interp(object t) + if t!=NULL then + integer ntype = t[1] + object t2 = t[2], + t3 = iff(length(t)=3?t[3]:0) + switch ntype do + case tk_Sequence: {} = interp(t2) {} = interp(t3) + case tk_assign: vals[var_idx(t2)] = interp(t3) + case tk_Identifier: return vals[var_idx(t)] + case tk_Integer: return t2 + case tk_String: return t2 + case tk_lt: return interp(t2) < interp(t3) + case tk_add: return interp(t2) + interp(t3) + case tk_sub: return interp(t2) - interp(t3) + case tk_while: while interp(t2) do {} = interp(t3) end while + case tk_Prints: puts(1,interp(t2)) + case tk_Printi: printf(1,"%d",interp(t2)) + case tk_putc: printf(1,"%c",interp(t2)) + case tk_and: return interp(t2) and interp(t3) + case tk_or: return interp(t2) or interp(t3) + case tk_le: return interp(t2) <= interp(t3) + case tk_ge: return interp(t2) >= interp(t3) + case tk_ne: return interp(t2) != interp(t3) + case tk_gt: return interp(t2) > interp(t3) + case tk_mul: return interp(t2) * interp(t3) + case tk_div: return trunc(interp(t2)/interp(t3)) + case tk_mod: return remainder(interp(t2),interp(t3)) + case tk_if: {} = interp(t3[iff(interp(t2)?2:3)]) + case tk_not: return not interp(t2) + case tk_neg: return - interp(t2) + else + error("unknown node type") + end switch + end if + return NULL + end function -procedure main(sequence cl) - open_files(cl) - toks = lex() - object t = parse() - {} = interp(t) - close_files() -end procedure + procedure main(sequence cl) + open_files(cl) + toks = lex() + object t = parse() + {} = interp(t) + close_files() + end procedure ---main(command_line()) -main({0,0,"primes.c"}) + --main(command_line()) + main({0,0,"primes.c"}) + + -- + -- demo\rosetta\Compiler\cgen.e + -- ============================ + -- + -- The reusable part of cgen.exw + -- + without js -- (machine code!) + include parse.e -global sequence vars = {}, - strings = {}, - stringptrs = {} + global sequence vars = {}, + strings = {}, + stringptrs = {} -global integer chain = 0 -global sequence code = {} + global integer chain = 0 + global sequence code = {} -function var_idx(sequence inode) - if inode[1]!=tk_Identifier then ?9/0 end if - string ident = inode[2] - integer n = find(ident,vars) - if n=0 then - vars = append(vars,ident) - n = length(vars) - end if - return n -end function + function var_idx(sequence inode) + if inode[1]!=tk_Identifier then ?9/0 end if + string ident = inode[2] + integer n = find(ident,vars) + if n=0 then + vars = append(vars,ident) + n = length(vars) + end if + return n + end function -function string_idx(sequence inode) - if inode[1]!=tk_String then ?9/0 end if - string s = inode[2] - integer n = find(s,strings) - if n=0 then - strings = append(strings,s) - stringptrs = append(stringptrs,0) - n = length(strings) - end if - return n -end function + function string_idx(sequence inode) + if inode[1]!=tk_String then ?9/0 end if + string s = inode[2] + integer n = find(s,strings) + if n=0 then + strings = append(strings,s) + stringptrs = append(stringptrs,0) + n = length(strings) + end if + return n + end function -function gen_size(object t) --- note: must be kept precisely in sync with gen_rec! --- (relentlessly tested via estsize/actsize) -integer size = 0 - if t!=NULL then - integer n_type = t[1] - string node_type = tkNames[n_type] - switch n_type do - case tk_Sequence: - size += gen_size(t[2]) - size += gen_size(t[3]) - case tk_assign: - size += gen_size(t[3])+6 - case tk_Integer: - size += 5 - case tk_Identifier: - size += 6 - case tk_String: - size += 5 - case tk_while: - -- emit: @@:@@: - size += gen_size(t[2])+3 - integer body = gen_size(t[3]) - integer stail = iff(size+body+2>128?5:2) - integer stop = iff(body+stail >127?6:2) - size += stop+body+stail - case tk_lt: - case tk_le: - case tk_ne: - case tk_eq: - case tk_gt: - case tk_ge: - size += gen_size(t[2]) - size += gen_size(t[3]) - size += 10 - case tk_and: - case tk_or: - size += gen_size(t[2]) - size += gen_size(t[3]) - size += 15 - case tk_add: - case tk_sub: - size += gen_size(t[2]) - size += gen_size(t[3]) - size += 4 - case tk_mul: - size += gen_size(t[2]) - size += gen_size(t[3]) - size += 5 - case tk_div: - case tk_mod: - size += gen_size(t[2]) - size += gen_size(t[3]) - size += 6 - case tk_putc: - case tk_Printi: - case tk_Prints: - size += gen_size(t[2]) - size += 5 - case tk_if: - size += gen_size(t[2])+3 - if t[3][1]!=tk_if then ?9/0 end if - integer truesize = gen_size(t[3][2]) - integer falsesize = gen_size(t[3][3]) - integer elsejmp = iff(falsesize=0?0:iff(falsesize>127?5:2)) - integer mainjmp = iff(truesize+elsejmp>127?6:2) - size += mainjmp+truesize+elsejmp+falsesize - case tk_not: - size += gen_size(t[2]) - size += 9 - case tk_neg: - size += gen_size(t[2]) - size += 4 - else: - ?9/0 - end switch - end if - return size -end function + function gen_size(object t) + -- note: must be kept precisely in sync with gen_rec! + -- (relentlessly tested via estsize/actsize) + integer size = 0 + if t!=NULL then + integer n_type = t[1] + string node_type = tkNames[n_type] + switch n_type do + case tk_Sequence: + size += gen_size(t[2]) + size += gen_size(t[3]) + case tk_assign: + size += gen_size(t[3])+6 + case tk_Integer: + size += 5 + case tk_Identifier: + size += 6 + case tk_String: + size += 5 + case tk_while: + -- emit: @@:<condition><topjmp(@f)><body><tailjmp(@b)>@@: + size += gen_size(t[2])+3 + integer body = gen_size(t[3]) + integer stail = iff(size+body+2>128?5:2) + integer stop = iff(body+stail >127?6:2) + size += stop+body+stail + case tk_lt: + case tk_le: + case tk_ne: + case tk_eq: + case tk_gt: + case tk_ge: + size += gen_size(t[2]) + size += gen_size(t[3]) + size += 10 + case tk_and: + case tk_or: + size += gen_size(t[2]) + size += gen_size(t[3]) + size += 15 + case tk_add: + case tk_sub: + size += gen_size(t[2]) + size += gen_size(t[3]) + size += 4 + case tk_mul: + size += gen_size(t[2]) + size += gen_size(t[3]) + size += 5 + case tk_div: + case tk_mod: + size += gen_size(t[2]) + size += gen_size(t[3]) + size += 6 + case tk_putc: + case tk_Printi: + case tk_Prints: + size += gen_size(t[2]) + size += 5 + case tk_if: + size += gen_size(t[2])+3 + if t[3][1]!=tk_if then ?9/0 end if + integer truesize = gen_size(t[3][2]) + integer falsesize = gen_size(t[3][3]) + integer elsejmp = iff(falsesize=0?0:iff(falsesize>127?5:2)) + integer mainjmp = iff(truesize+elsejmp>127?6:2) + size += mainjmp+truesize+elsejmp+falsesize + case tk_not: + size += gen_size(t[2]) + size += 9 + case tk_neg: + size += gen_size(t[2]) + size += 4 + else: + ?9/0 + end switch + end if + return size + end function -procedure gen_rec(object t) --- the recursive part of code_gen - if t!=NULL then - integer initsize = length(code) - integer estsize = gen_size(t) -- (test the gen_size function) - integer n_type = t[1] - string node_type = tkNames[n_type] - switch n_type do - case tk_Sequence: - gen_rec(t[2]) - gen_rec(t[3]) - case tk_assign: - integer n = var_idx(t[2]) - gen_rec(t[3]) - code &= {0o217,0o005,chain,1,n,0} -- pop [i] - chain = length(code)-3 - case tk_Integer: - integer n = t[2] - code &= 0o150&int_to_bytes(n) -- push imm32 - case tk_while: - -- emit: @@:@@: - integer looptop = length(code) - gen_rec(t[2]) - code &= {0o130, -- pop eax - 0o205,0o300} -- test eax,eax - integer bodysize = gen_size(t[3]) - -- can we use short jumps? - -- disclaimer: size calcs are not heavily tested; if in - -- doubt reduce 128/7 by 8, and if that works - -- then yep, you just found a boundary case. - integer stail = iff(length(code)+bodysize+4-looptop>128?5:2) - integer offset = bodysize+stail - integer stop = iff(offset>127?6:2) - if stop=2 then - code &= {0o164,offset} -- jz (short) end - else - code &= {0o017,0o204}&int_to_bytes(offset) -- jz (long) end - end if - gen_rec(t[3]) - offset = looptop-(length(code)+stail) - if stail=2 then - code &= 0o353&offset -- jmp looptop (short) - else - code &= 0o351&int_to_bytes(offset) -- jmp looptop (long) - end if - case tk_lt: - case tk_le: - case tk_gt: - case tk_ge: - case tk_ne: - case tk_eq: - gen_rec(t[2]) - gen_rec(t[3]) - integer xrm - if n_type=tk_ne then xrm = 0o225 -- (#95) - elsif n_type=tk_lt then xrm = 0o234 -- (#9C) - elsif n_type=tk_ge then xrm = 0o235 -- (#9D) - elsif n_type=tk_le then xrm = 0o236 -- (#9E) - elsif n_type=tk_gt then xrm = 0o237 -- (#9F) - else ?9/0 - end if - code &= { 0o061,0o300, -- xor eax,eax - 0o132, -- pop edx - 0o131, -- pop ecx - 0o071,0o321, -- cmp ecx,edx - 0o017,xrm,0o300, -- setcc al - 0o120} -- push eax - case tk_or: - case tk_and: - gen_rec(t[2]) - gen_rec(t[3]) - integer op = find(n_type,{tk_or,0,0,tk_and}) - op *= 0o010 - code &= { 0o130, -- pop eax - 0o131, -- pop ecx - 0o205,0o300, -- test eax,eax - 0o017,0o225,0o300, -- setne al - 0o205,0o311, -- test ecx,ecx - 0o017,0o225,0o301, -- setne cl - op,0o310, -- or/and al,cl - 0o120} -- push eax - case tk_add: - case tk_sub: - gen_rec(t[2]) - gen_rec(t[3]) - integer op = find(n_type,{tk_add,0,0,0,0,tk_sub}) - op = 0o001 + (op-1)*0o010 - code &= { 0o130, -- pop eax - op,0o004,0o044} -- add/or/and/sub [esp],eax - case tk_mul: - gen_rec(t[2]) - gen_rec(t[3]) - code &= { 0o131, -- pop ecx - 0o130, -- pop eax - 0o367,0o341, -- mul ecx - 0o120} -- push eax - case tk_div: - case tk_mod: - gen_rec(t[2]) - gen_rec(t[3]) - integer push = 0o120+(n_type=tk_mod)*2 - code &= { 0o131, -- pop ecx - 0o130, -- pop eax - 0o231, -- cdq (eax -> edx:eax) - 0o367,0o371, -- idiv ecx - push} -- push eax|edx - case tk_Identifier: - integer n = var_idx(t) - code &= {0o377,0o065,chain,1,n,0} -- push [n] - chain = length(code)-3 - case tk_putc: - case tk_Printi: - case tk_Prints: - gen_rec(t[2]) - integer n = find(n_type,{tk_putc,tk_Printi,tk_Prints}) - code &= {0o350,chain,3,n,0} -- call :printc/i/s - chain = length(code)-3 - case tk_String: - integer n = string_idx(t) - code &= {0o150,chain,2,n,0} -- push RawStringPtr(string) - chain = length(code)-3 - case tk_if: - -- emit: [] - gen_rec(t[2]) - code &= {0o130, -- pop eax - 0o205,0o300} -- test eax,eax - if t[3][1]!=tk_if then ?9/0 end if - integer truesize = gen_size(t[3][2]) - integer falsesize = gen_size(t[3][3]) - integer elsejmp = iff(falsesize=0?0:iff(falsesize>127?5:2)) - integer offset = truesize+elsejmp - integer mainjmp = iff(offset>127?6:2) - if mainjmp=2 then - code &= {0o164,offset} -- jz (short) else/end - else - code &= {0o017,0o204}&int_to_bytes(offset) -- jz (long) else/end - end if - gen_rec(t[3][2]) - if falsesize!=0 then - offset = falsesize - if elsejmp=2 then - code &= 0o353&offset -- jmp end if (short) - else - code &= 0o351&int_to_bytes(offset) -- jmp end if (long) - end if - gen_rec(t[3][3]) - end if - case tk_not: - gen_rec(t[2]) - code &= {0o132, -- pop edx - 0o061,0o300, -- xor eax,eax - 0o205,0o322, -- test edx,edx - 0o017,0o224,0o300, -- setz al - 0o120} -- push eax - case tk_neg: - gen_rec(t[2]) - code &= {0o130, -- pop eax - 0o367,0o330, -- neg eax - 0o120} -- push eax - else: - error("error in code generator - found %d, expecting operator\n", {n_type}) - end switch - integer actsize = length(code) - if initsize+estsize!=actsize then ?"9/0" end if -- (test gen_size) - end if -end procedure + procedure gen_rec(object t) + -- the recursive part of code_gen + if t!=NULL then + integer initsize = length(code) + integer estsize = gen_size(t) -- (test the gen_size function) + integer n_type = t[1] + string node_type = tkNames[n_type] + switch n_type do + case tk_Sequence: + gen_rec(t[2]) + gen_rec(t[3]) + case tk_assign: + integer n = var_idx(t[2]) + gen_rec(t[3]) + code &= {0o217,0o005,chain,1,n,0} -- pop [i] + chain = length(code)-3 + case tk_Integer: + integer n = t[2] + code &= 0o150&int_to_bytes(n) -- push imm32 + case tk_while: + -- emit: @@:<condition><topjmp(@f)><body><tailjmp(@b)>@@: + integer looptop = length(code) + gen_rec(t[2]) + code &= {0o130, -- pop eax + 0o205,0o300} -- test eax,eax + integer bodysize = gen_size(t[3]) + -- can we use short jumps? + -- disclaimer: size calcs are not heavily tested; if in + -- doubt reduce 128/7 by 8, and if that works + -- then yep, you just found a boundary case. + integer stail = iff(length(code)+bodysize+4-looptop>128?5:2) + integer offset = bodysize+stail + integer stop = iff(offset>127?6:2) + if stop=2 then + code &= {0o164,offset} -- jz (short) end + else + code &= {0o017,0o204}&int_to_bytes(offset) -- jz (long) end + end if + gen_rec(t[3]) + offset = looptop-(length(code)+stail) + if stail=2 then + code &= 0o353&offset -- jmp looptop (short) + else + code &= 0o351&int_to_bytes(offset) -- jmp looptop (long) + end if + case tk_lt: + case tk_le: + case tk_gt: + case tk_ge: + case tk_ne: + case tk_eq: + gen_rec(t[2]) + gen_rec(t[3]) + integer xrm + if n_type=tk_ne then xrm = 0o225 -- (#95) + elsif n_type=tk_lt then xrm = 0o234 -- (#9C) + elsif n_type=tk_ge then xrm = 0o235 -- (#9D) + elsif n_type=tk_le then xrm = 0o236 -- (#9E) + elsif n_type=tk_gt then xrm = 0o237 -- (#9F) + else ?9/0 + end if + code &= { 0o061,0o300, -- xor eax,eax + 0o132, -- pop edx + 0o131, -- pop ecx + 0o071,0o321, -- cmp ecx,edx + 0o017,xrm,0o300, -- setcc al + 0o120} -- push eax + case tk_or: + case tk_and: + gen_rec(t[2]) + gen_rec(t[3]) + integer op = find(n_type,{tk_or,0,0,tk_and}) + op *= 0o010 + code &= { 0o130, -- pop eax + 0o131, -- pop ecx + 0o205,0o300, -- test eax,eax + 0o017,0o225,0o300, -- setne al + 0o205,0o311, -- test ecx,ecx + 0o017,0o225,0o301, -- setne cl + op,0o310, -- or/and al,cl + 0o120} -- push eax + case tk_add: + case tk_sub: + gen_rec(t[2]) + gen_rec(t[3]) + integer op = find(n_type,{tk_add,0,0,0,0,tk_sub}) + op = 0o001 + (op-1)*0o010 + code &= { 0o130, -- pop eax + op,0o004,0o044} -- add/or/and/sub [esp],eax + case tk_mul: + gen_rec(t[2]) + gen_rec(t[3]) + code &= { 0o131, -- pop ecx + 0o130, -- pop eax + 0o367,0o341, -- mul ecx + 0o120} -- push eax + case tk_div: + case tk_mod: + gen_rec(t[2]) + gen_rec(t[3]) + integer push = 0o120+(n_type=tk_mod)*2 + code &= { 0o131, -- pop ecx + 0o130, -- pop eax + 0o231, -- cdq (eax -> edx:eax) + 0o367,0o371, -- idiv ecx + push} -- push eax|edx + case tk_Identifier: + integer n = var_idx(t) + code &= {0o377,0o065,chain,1,n,0} -- push [n] + chain = length(code)-3 + case tk_putc: + case tk_Printi: + case tk_Prints: + gen_rec(t[2]) + integer n = find(n_type,{tk_putc,tk_Printi,tk_Prints}) + code &= {0o350,chain,3,n,0} -- call :printc/i/s + chain = length(code)-3 + case tk_String: + integer n = string_idx(t) + code &= {0o150,chain,2,n,0} -- push RawStringPtr(string) + chain = length(code)-3 + case tk_if: + -- emit: <condition><mainjmp><truepart>[<elsejmp><falsepart>] + gen_rec(t[2]) + code &= {0o130, -- pop eax + 0o205,0o300} -- test eax,eax + if t[3][1]!=tk_if then ?9/0 end if + integer truesize = gen_size(t[3][2]) + integer falsesize = gen_size(t[3][3]) + integer elsejmp = iff(falsesize=0?0:iff(falsesize>127?5:2)) + integer offset = truesize+elsejmp + integer mainjmp = iff(offset>127?6:2) + if mainjmp=2 then + code &= {0o164,offset} -- jz (short) else/end + else + code &= {0o017,0o204}&int_to_bytes(offset) -- jz (long) else/end + end if + gen_rec(t[3][2]) + if falsesize!=0 then + offset = falsesize + if elsejmp=2 then + code &= 0o353&offset -- jmp end if (short) + else + code &= 0o351&int_to_bytes(offset) -- jmp end if (long) + end if + gen_rec(t[3][3]) + end if + case tk_not: + gen_rec(t[2]) + code &= {0o132, -- pop edx + 0o061,0o300, -- xor eax,eax + 0o205,0o322, -- test edx,edx + 0o017,0o224,0o300, -- setz al + 0o120} -- push eax + case tk_neg: + gen_rec(t[2]) + code &= {0o130, -- pop eax + 0o367,0o330, -- neg eax + 0o120} -- push eax + else: + error("error in code generator - found %d, expecting operator\n", {n_type}) + end switch + integer actsize = length(code) + if initsize+estsize!=actsize then ?"9/0" end if -- (test gen_size) + end if + end procedure -global procedure code_gen(object t) --- --- Generates proper machine code. --- --- Example: i=10; print "\n"; print i; print "\n" --- Result in vars, strings, chain, code (declared above) --- where vars is: {"i"}, --- strings is {"\n"}, --- code is { 0o150,#0A,#00,#00,#00, -- 1: push 10 --- 0o217,0o005,0,1,1,0 -- 6: pop [i] --- 0o150,8,2,1,0, -- 12: push ("\n") --- 0o350,13,3,3,0, -- 17: call :prints --- 0o377,0o065,18,1,1,0, -- 22: push [i] --- 0o350,24,3,2,0, -- 28: call :printi --- 0o150,29,2,1,0, -- 33: push ("\n") --- 0o350,34,3,3,0, -- 38: call :prints --- 0o303} -- 43: ret --- and chain is 39 (->34->29->24->18->13->8->0) --- The chain connects all places where we need an actual address before --- the code is executed, with the byte after the link differentiating --- between var(1), string(2), and builtin(3), and the byte after that --- determining the instance of the given type - not that any of them --- are actually limited to a byte in the above intermediate form, and --- of course the trailing 0 of each {link,type,id,0} is just there to --- reserve the space we will need. --- - gen_rec(t) - code = append(code,0o303) -- ret (0o303=#C3) -end procedure + global procedure code_gen(object t) + -- + -- Generates proper machine code. + -- + -- Example: i=10; print "\n"; print i; print "\n" + -- Result in vars, strings, chain, code (declared above) + -- where vars is: {"i"}, + -- strings is {"\n"}, + -- code is { 0o150,#0A,#00,#00,#00, -- 1: push 10 + -- 0o217,0o005,0,1,1,0 -- 6: pop [i] + -- 0o150,8,2,1,0, -- 12: push ("\n") + -- 0o350,13,3,3,0, -- 17: call :prints + -- 0o377,0o065,18,1,1,0, -- 22: push [i] + -- 0o350,24,3,2,0, -- 28: call :printi + -- 0o150,29,2,1,0, -- 33: push ("\n") + -- 0o350,34,3,3,0, -- 38: call :prints + -- 0o303} -- 43: ret + -- and chain is 39 (->34->29->24->18->13->8->0) + -- The chain connects all places where we need an actual address before + -- the code is executed, with the byte after the link differentiating + -- between var(1), string(2), and builtin(3), and the byte after that + -- determining the instance of the given type - not that any of them + -- are actually limited to a byte in the above intermediate form, and + -- of course the trailing 0 of each {link,type,id,0} is just there to + -- reserve the space we will need. + -- + gen_rec(t) + code = append(code,0o303) -- ret (0o303=#C3) + end procedure -include builtins/VM/puts1.e -- low-level console i/o routines + include builtins/VM/puts1.e -- low-level console i/o routines -function setbuiltins() -atom printc,printi,prints - #ilASM{ - jmp :setbuiltins - ::printc - lea edi,[esp+4] - mov esi,1 - call :%puts1ediesi -- (edi=raw text, esi=length) - ret 4 - ::printi - mov eax,[esp+4] - push 0 -- no cr - call :%putsint -- (nb limited to +/-9,999,999,999) - ret 4 - ::prints - mov edi,[esp+4] - mov esi,[edi-12] - call :%puts1ediesi -- (edi=raw text, esi=length) - ret 4 - ::setbuiltins - mov eax,:printc - lea edi,[printc] - call :%pStoreMint - mov eax,:printi - lea edi,[printi] - call :%pStoreMint - mov eax,:prints - lea edi,[prints] - call :%pStoreMint - } - return {printc,printi,prints} -end function + function setbuiltins() + atom printc,printi,prints + #ilASM{ + jmp :setbuiltins + ::printc + lea edi,[esp+4] + mov esi,1 + call :%puts1ediesi -- (edi=raw text, esi=length) + ret 4 + ::printi + mov eax,[esp+4] + push 0 -- no cr + call :%putsint -- (nb limited to +/-9,999,999,999) + ret 4 + ::prints + mov edi,[esp+4] + mov esi,[edi-12] + call :%puts1ediesi -- (edi=raw text, esi=length) + ret 4 + ::setbuiltins + mov eax,:printc + lea edi,[printc] + call :%pStoreMint + mov eax,:printi + lea edi,[printi] + call :%pStoreMint + mov eax,:prints + lea edi,[prints] + call :%pStoreMint + } + return {printc,printi,prints} + end function -global constant builtin_names = {"printc","printi","prints"} -global constant builtins = setbuiltins() + global constant builtin_names = {"printc","printi","prints"} + global constant builtins = setbuiltins() -global atom var_mem, code_mem + global atom var_mem, code_mem -function RawStringPtr(integer n) -- (based on IupRawStringPtr from pGUI.e) --- --- Returns a raw string pointer for s, somewhat like allocate_string(s), but using the existing memory. --- NOTE: The return is only valid as long as the value passed as the parameter remains in existence. --- -atom res - string s = strings[n] - #ilASM{ - mov eax,[s] - lea edi,[res] - shl eax,2 - call :%pStoreMint - } - stringptrs[n] = res - return res -end function + function RawStringPtr(integer n) -- (based on IupRawStringPtr from pGUI.e) + -- + -- Returns a raw string pointer for s, somewhat like allocate_string(s), but using the existing memory. + -- NOTE: The return is only valid as long as the value passed as the parameter remains in existence. + -- + atom res + string s = strings[n] + #ilASM{ + mov eax,[s] + lea edi,[res] + shl eax,2 + call :%pStoreMint + } + stringptrs[n] = res + return res + end function -global procedure fixup() - var_mem = allocate(length(vars)*4) - mem_set(var_mem,0,length(vars)*4) - code_mem = allocate(length(code)) - poke(code_mem,code) - while chain!=0 do - integer this = chain - chain = code[this] - integer ftype = code[this+1] - integer id = code[this+2] - switch ftype do - case 1: -- vars - poke4(code_mem+this-1,var_mem+(id-1)*4) - case 2: -- strings - poke4(code_mem+this-1,RawStringPtr(id)) - case 3: -- builtins - poke4(code_mem+this-1,builtins[id]-(code_mem+this+3)) - end switch - end while -end procedure + global procedure fixup() + var_mem = allocate(length(vars)*4) + mem_set(var_mem,0,length(vars)*4) + code_mem = allocate(length(code)) + poke(code_mem,code) + while chain!=0 do + integer this = chain + chain = code[this] + integer ftype = code[this+1] + integer id = code[this+2] + switch ftype do + case 1: -- vars + poke4(code_mem+this-1,var_mem+(id-1)*4) + case 2: -- strings + poke4(code_mem+this-1,RawStringPtr(id)) + case 3: -- builtins + poke4(code_mem+this-1,builtins[id]-(code_mem+this+3)) + end switch + end while + end procedure + + -- + -- demo\rosetta\Compiler\cgen.exw + -- ============================== + -- + -- Generates 32-bit machine code (see note in vm.exw) + -- + without js -- (machine code!) + include cgen.e -function get_var_name(atom addr) - integer n = (addr-var_mem)/4+1 - if n<1 or n>length(vars) then ?9/0 end if - return vars[n] -end function + function get_var_name(atom addr) + integer n = (addr-var_mem)/4+1 + if n<1 or n>length(vars) then ?9/0 end if + return vars[n] + end function -function hxl(integer pc, object oh, string fmt, sequence args={}) --- helper routine to display the octal/hex bytes just decoded, --- along with the code offset and the human-readable text. - if length(args) then fmt = sprintf(fmt,args) end if - sequence octhex = {} - atom base = code_mem+pc - integer len = 0 - if integer(oh) then -- all octal - for i=1 to oh do - octhex = append(octhex,sprintf("0o%03o",peek(base))) - base += 1 - end for - len = oh - else -- some octal and some hex - for i=1 to length(oh) by 2 do - for j=1 to oh[i] do - octhex = append(octhex,sprintf("0o%03o",peek(base))) - base += 1 - end for - len += oh[i] - for j=1 to oh[i+1] do - octhex = append(octhex,sprintf("#%02x",peek(base))) - base += 1 - end for - len += oh[i+1] - end for - end if - printf(output_file,"%4d: %-30s %s\n",{pc+1,join(octhex,","),fmt}) - return len -end function + function hxl(integer pc, object oh, string fmt, sequence args={}) + -- helper routine to display the octal/hex bytes just decoded, + -- along with the code offset and the human-readable text. + if length(args) then fmt = sprintf(fmt,args) end if + sequence octhex = {} + atom base = code_mem+pc + integer len = 0 + if integer(oh) then -- all octal + for i=1 to oh do + octhex = append(octhex,sprintf("0o%03o",peek(base))) + base += 1 + end for + len = oh + else -- some octal and some hex + for i=1 to length(oh) by 2 do + for j=1 to oh[i] do + octhex = append(octhex,sprintf("0o%03o",peek(base))) + base += 1 + end for + len += oh[i] + for j=1 to oh[i+1] do + octhex = append(octhex,sprintf("#%02x",peek(base))) + base += 1 + end for + len += oh[i+1] + end for + end if + printf(output_file,"%4d: %-30s %s\n",{pc+1,join(octhex,","),fmt}) + return len + end function -constant cccodes = {"o?" ,"no?","b?" ,"ae?","z" ,"ne" ,"be?","a?", --- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , - "s?" ,"ns?","pe?","po?","l" ,"ge" ,"le" ,"g" } --- 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 + constant cccodes = {"o?" ,"no?","b?" ,"ae?","z" ,"ne" ,"be?","a?", + -- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , + "s?" ,"ns?","pe?","po?","l" ,"ge" ,"le" ,"g" } + -- 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 -constant regs = {"eax","ecx","edx"} -- (others as/when needed) + constant regs = {"eax","ecx","edx"} -- (others as/when needed) -procedure decode() --- for a much more complete (and better organised) disassembler, see p2asm.e -integer pc = 0, -- nb 0-based - opcode, xrm + procedure decode() + -- for a much more complete (and better organised) disassembler, see p2asm.e + integer pc = 0, -- nb 0-based + opcode, xrm - while pcwhile pc<length(code) do + opcode = peek(code_mem+pc) + xrm = -1 + switch opcode do + case 0o150: + atom vaddr = peek4s(code_mem+pc+1) + integer n = find(vaddr,stringptrs) + object arg = iff(n?enquote(strings[n]) + :sprintf("%d",vaddr)) + pc += hxl(pc,{1,4},"push %s",{arg}) + case 0o217: + case 0o377: + integer n = find(opcode,{0o217,0o377}) + string op = {"pop","push"}[n] + xrm = peek(code_mem+pc+1) + if n!=find(xrm,{0o005,0o065}) then exit end if + atom addr = peek4u(code_mem+pc+2) + pc += hxl(pc,{2,4},"%s [%s]",{op,get_var_name(addr)}) + case 0o061: + case 0o071: + case 0o205: + integer n = find(opcode,{0o061,0o071,0o205}) + string op = {"xor","cmp","test"}[n] + xrm = peek(code_mem+pc+1) + if and_bits(xrm,0o300)!=0o300 then exit end if + string r1 = regs[and_bits(xrm,0o070)/0o010+1] + string r2 = regs[and_bits(xrm,0o007)+1] + pc += hxl(pc,2,"%s %s,%s",{op,r1,r2}) + case 0o017: + xrm = peek(code_mem+pc+1) + switch xrm do + case 0o224: + case 0o225: + case 0o234: + case 0o235: + case 0o236: + case 0o237: + string cc = cccodes[and_bits(xrm,0o017)+1] + xrm = peek(code_mem+pc+2) + if xrm=0o300 then + pc += hxl(pc,3,"set%s al",{cc}) + elsif xrm=0o301 then + pc += hxl(pc,3,"set%s cl",{cc}) + else + exit + end if + case 0o204: + integer offset = peek4s(code_mem+pc+2) + pc += hxl(pc,{2,4},"jz %d",{pc+6+offset+1}) + else + exit + end switch + case 0o010: + case 0o040: + xrm = peek(code_mem+pc+1) + if xrm=0o310 then + string lop = {"or","and"}[find(opcode,{0o010,0o040})] + pc += hxl(pc,2,"%s al,cl",{lop}) + else + exit + end if + case 0o120: + case 0o122: + case 0o130: + case 0o131: + case 0o132: + string op = {"push","pop"}[find(and_bits(opcode,0o070),{0o020,0o030})] + string reg = regs[and_bits(opcode,0o007)+1] + pc += hxl(pc,1,"%s %s",{op,reg}) + case 0o231: + pc += hxl(pc,1,"cdq") + case 0o164: + case 0o353: + string jop = iff(opcode=0o164?"jz":"jmp") + integer offset = peek1s(code_mem+pc+1) + pc += hxl(pc,{1,1},"%s %d",{jop,pc+2+offset+1}) + case 0o351: + integer offset = peek4s(code_mem+pc+1) + pc += hxl(pc,{1,4},"jmp %d",{pc+5+offset+1}) + case 0o303: + pc += hxl(pc,1,"ret") + case 0o350: + integer offset = peek4s(code_mem+pc+1) + atom addr = offset+code_mem+pc+5 + integer n = find(addr,builtins) + pc += hxl(pc,{1,4},"call :%s",{builtin_names[n]}) + case 0o001: + case 0o041: + case 0o051: + integer n = find(opcode,{0o001,0o041,0o051}) + string op = {"add","and","sub"}[n] + xrm = peek(code_mem+pc+1) + switch xrm do + case 0o004: + if peek(code_mem+pc+2)=0o044 then + pc += hxl(pc,3,"%s [esp],eax",{op}) + else + exit + end if + else + exit + end switch + case 0o367: + xrm = peek(code_mem+pc+1) + if and_bits(xrm,0o300)!=0o300 then exit end if + integer n = find(and_bits(xrm,0o070),{0o030,0o040,0o070}) + if n=0 then exit end if + string op = {"neg","mul","idiv"}[n] + string reg = regs[and_bits(xrm,0o007)+1] + pc += hxl(pc,2,"%s %s",{op,reg}) + else + exit + end switch + end while + if pc<length(code) then + ?"incomplete:" + if xrm=-1 then + ?{pc+1,sprintf("0o%03o",opcode)} + else + ?{pc+1,sprintf("0o%03o 0o%03o",{opcode,xrm})} + end if + end if + end procedure -procedure main(sequence cl) - open_files(cl) - toks = lex() - object t = parse() - code_gen(t) - fixup() - decode() - free({var_mem,code_mem}) - close_files() -end procedure + procedure main(sequence cl) + open_files(cl) + toks = lex() + object t = parse() + code_gen(t) + fixup() + decode() + free({var_mem,code_mem}) + close_files() + end procedure ---main(command_line()) -main({0,0,"gcd.c"}) + --main(command_line()) + main({0,0,"gcd.c"}) + + -- + -- demo\rosetta\Compiler\core.e + -- ============================ + -- + -- Standard declarations and routines used by lex.exw, parse.exw, cgen.exw, and interp.exw + -- (included in distribution as above, which contains some additional sanity checks) + -- + with javascript_semantics + global constant EOF = -1, STDIN = 0, STDOUT = 1 -global enum NONE=0, UNARY=1, BINARY=2 -global type nary(integer n) return n=NONE or n=UNARY or n=BINARY end type + global enum NONE=0, UNARY=1, BINARY=2 + global type nary(integer n) return n=NONE or n=UNARY or n=BINARY end type -global sequence tkNames = {} -- eg/ie {"Op_multiply","Op_divide",..} -global sequence precedences = {} -global sequence narys = {} -- NONE/UNARY/BINARY -global sequence operators = {} -- eg/ie {"*","/","+","-","<","<=",..} -global sequence opcodes = {} -- idx to tkNames, matching operators + global sequence tkNames = {} -- eg/ie {"Op_multiply","Op_divide",..} + global sequence precedences = {} + global sequence narys = {} -- NONE/UNARY/BINARY + global sequence operators = {} -- eg/ie {"*","/","+","-","<","<=",..} + global sequence opcodes = {} -- idx to tkNames, matching operators -global constant KEYWORDS = new_dict() -- eg/ie {"if"=>idx to tkNames} + global constant KEYWORDS = new_dict() -- eg/ie {"if"=>idx to tkNames} -global enum OPERATOR=1, DIGIT, LETTER -- character classes + global enum OPERATOR=1, DIGIT, LETTER -- character classes -global sequence charmap = repeat(0,255) - charmap['0'..'9'] = DIGIT - charmap['A'..'Z'] = LETTER - charmap['a'..'z'] = LETTER - charmap['_'] = LETTER + global sequence charmap = repeat(0,255) + charmap['0'..'9'] = DIGIT + charmap['A'..'Z'] = LETTER + charmap['a'..'z'] = LETTER + charmap['_'] = LETTER -function tkName(string s, nary n = NONE, integer precedence = -1) - tkNames = append(tkNames,s) - narys = append(narys,n) - precedences = append(precedences,precedence) - return length(tkNames) -end function + function tkName(string s, nary n = NONE, integer precedence = -1) + tkNames = append(tkNames,s) + narys = append(narys,n) + precedences = append(precedences,precedence) + return length(tkNames) + end function -function tkOp(string s, string op, nary n, integer precedence) - integer res = tkName(s, n, precedence) - operators = append(operators,op) - opcodes = append(opcodes,res) - for i=1 to length(op) do - charmap[op[i]] = OPERATOR - end for - return res -end function + function tkOp(string s, string op, nary n, integer precedence) + integer res = tkName(s, n, precedence) + operators = append(operators,op) + opcodes = append(opcodes,res) + for i=1 to length(op) do + charmap[op[i]] = OPERATOR + end for + return res + end function -function tkKw(string s, string keyword) - integer res = tkName(s) - putd(keyword, res, KEYWORDS) - return res -end function + function tkKw(string s, string keyword) + integer res = tkName(s) + putd(keyword, res, KEYWORDS) + return res + end function -global constant - tk_EOI = tkName("End_of_input"), --1 - tk_mul = tkOp("Op_multiply", "*", BINARY,13), --2 - tk_div = tkOp("Op_divide", "/", BINARY,13), --3 - tk_mod = tkOp("Op_mod", "%", BINARY,13), --4 - tk_add = tkOp("Op_add", "+", BINARY,12), --5 - tk_sub = tkOp("Op_subtract", "-", BINARY,12), --6 - tk_neg = tkName("Op_negate", UNARY, 14), --7 - tk_not = tkOp("Op_not", "!", UNARY, 14), --8 - tk_lt = tkOp("Op_less", "<", BINARY,10), --9 - tk_le = tkOp("Op_lessequal", "<=",BINARY,10), --10 - tk_gt = tkOp("Op_greater", ">", BINARY,10), --11 - tk_ge = tkOp("Op_greaterequal", ">=",BINARY,10), --12 - tk_eq = tkOp("Op_equal", "==",BINARY, 9), --13 - tk_ne = tkOp("Op_notequal", "!=",BINARY, 9), --14 - tk_assign = tkOp("Op_assign", "=", NONE, -1), --15 - tk_and = tkOp("Op_and", "&&",BINARY, 5), --16 - tk_or = tkOp("Op_or", "||",BINARY, 4), --17 - tk_if = tkKw("Keyword_if", "if"), --18 - tk_else = tkKw("Keyword_else", "else"), --19 - tk_while = tkKw("Keyword_while","while"), --20 - tk_print = tkKw("Keyword_print","print"), --21 - tk_putc = tkKw("Keyword_putc", "putc"), --22 - tk_LeftParen = tkOp("LeftParen", "(", NONE, -1), --23 - tk_RightParen = tkOp("RightParen", ")", NONE, -1), --24 - tk_LeftBrace = tkOp("LeftBrace", "{", NONE, -1), --25 - tk_RightBrace = tkOp("RightBrace", "}", NONE, -1), --26 - tk_Semicolon = tkOp("Semicolon", ";", NONE, -1), --27 - tk_Comma = tkOp("Comma", ",", NONE, -1), --28 - tk_Identifier = tkName("Identifier"), --29 - tk_Integer = tkName("Integer"), --30 - tk_String = tkName("String"), --31 - tk_Sequence = tkName("Sequence"), --32 - tk_Prints = tkName("tk_Prints"), --33 - tk_Printi = tkName("tk_Printi") --34 + global constant + tk_EOI = tkName("End_of_input"), --1 + tk_mul = tkOp("Op_multiply", "*", BINARY,13), --2 + tk_div = tkOp("Op_divide", "/", BINARY,13), --3 + tk_mod = tkOp("Op_mod", "%", BINARY,13), --4 + tk_add = tkOp("Op_add", "+", BINARY,12), --5 + tk_sub = tkOp("Op_subtract", "-", BINARY,12), --6 + tk_neg = tkName("Op_negate", UNARY, 14), --7 + tk_not = tkOp("Op_not", "!", UNARY, 14), --8 + tk_lt = tkOp("Op_less", "<", BINARY,10), --9 + tk_le = tkOp("Op_lessequal", "<=",BINARY,10), --10 + tk_gt = tkOp("Op_greater", ">", BINARY,10), --11 + tk_ge = tkOp("Op_greaterequal", ">=",BINARY,10), --12 + tk_eq = tkOp("Op_equal", "==",BINARY, 9), --13 + tk_ne = tkOp("Op_notequal", "!=",BINARY, 9), --14 + tk_assign = tkOp("Op_assign", "=", NONE, -1), --15 + tk_and = tkOp("Op_and", "&&",BINARY, 5), --16 + tk_or = tkOp("Op_or", "||",BINARY, 4), --17 + tk_if = tkKw("Keyword_if", "if"), --18 + tk_else = tkKw("Keyword_else", "else"), --19 + tk_while = tkKw("Keyword_while","while"), --20 + tk_print = tkKw("Keyword_print","print"), --21 + tk_putc = tkKw("Keyword_putc", "putc"), --22 + tk_LeftParen = tkOp("LeftParen", "(", NONE, -1), --23 + tk_RightParen = tkOp("RightParen", ")", NONE, -1), --24 + tk_LeftBrace = tkOp("LeftBrace", "{", NONE, -1), --25 + tk_RightBrace = tkOp("RightBrace", "}", NONE, -1), --26 + tk_Semicolon = tkOp("Semicolon", ";", NONE, -1), --27 + tk_Comma = tkOp("Comma", ",", NONE, -1), --28 + tk_Identifier = tkName("Identifier"), --29 + tk_Integer = tkName("Integer"), --30 + tk_String = tkName("String"), --31 + tk_Sequence = tkName("Sequence"), --32 + tk_Prints = tkName("tk_Prints"), --33 + tk_Printi = tkName("tk_Printi") --34 -global integer input_file = STDIN, - output_file = STDOUT + global integer input_file = STDIN, + output_file = STDOUT -type strint(object o) - return string(o) or integer(o) -end type + type strint(object o) + return string(o) or integer(o) + end type -global strint tok_line, -- save of line/col at the start of - tok_col -- token/comment, for result/errors + global strint tok_line, -- save of line/col at the start of + tok_col -- token/comment, for result/errors -global object oneline = "" + global object oneline = "" -constant errfmt = "Line %s column %s:\n%s%s" + constant errfmt = "Line %s column %s:\n%s%s" -function errline() - oneline = substitute(trim(oneline,"\r\n"),'\t',' ') - string padding = repeat(' ',tok_col) - return sprintf("%s\n%s^ ",{oneline,padding}) -end function + function errline() + oneline = substitute(trim(oneline,"\r\n"),'\t',' ') + string padding = repeat(' ',tok_col) + return sprintf("%s\n%s^ ",{oneline,padding}) + end function -global procedure error(sequence msg, sequence args={}) - if length(args) then - msg = sprintf(msg,args) - end if - string el = iff(atom(oneline)?"":errline()) - if integer(tok_line) then tok_line = sprintf("%d",tok_line) end if - if integer(tok_col) then tok_col = sprintf("%d",tok_col) end if - printf(STDOUT,errfmt,{tok_line,tok_col,el,msg}) - {} = wait_key() - abort(1) -end procedure + global procedure error(sequence msg, sequence args={}) + if length(args) then + msg = sprintf(msg,args) + end if + string el = iff(atom(oneline)?"":errline()) + if integer(tok_line) then tok_line = sprintf("%d",tok_line) end if + if integer(tok_col) then tok_col = sprintf("%d",tok_col) end if + printf(STDOUT,errfmt,{tok_line,tok_col,el,msg}) + {} = wait_key() + abort(1) + end procedure -include js_io.e -- fake file i/o for running under pwa/p2js + include js_io.e -- fake file i/o for running under pwa/p2js -function open_file(string file_name, string mode) - integer fn = iff(platform()=JS?js_open(file_name) - :open(file_name, mode)) - if fn<=0 then - printf(STDOUT, "Could not open %s", {file_name}) - {} = wait_key() - abort(1) - end if - return fn -end function + function open_file(string file_name, string mode) + integer fn = iff(platform()=JS?js_open(file_name) + :open(file_name, mode)) + if fn<=0 then + printf(STDOUT, "Could not open %s", {file_name}) + {} = wait_key() + abort(1) + end if + return fn + end function -global procedure open_files(sequence cl) - if length(cl)>2 then - input_file = open_file(cl[3],"r") - if length(cl)>3 then - output_file = open_file(cl[4],"w") - end if - end if -end procedure + global procedure open_files(sequence cl) + if length(cl)>2 then + input_file = open_file(cl[3],"r") + if length(cl)>3 then + output_file = open_file(cl[4],"w") + end if + end if + end procedure -global procedure close_files() - if platform()!=JS then - if input_file!=STDIN then close(input_file) end if - if output_file!=STDOUT then close(output_file) end if - end if -end procedure + global procedure close_files() + if platform()!=JS then + if input_file!=STDIN then close(input_file) end if + if output_file!=STDOUT then close(output_file) end if + end if + end procedure -global function enquote(string s) - return sprintf(`"%s"`,substitute(s,"\n","\\n")) -end function + global function enquote(string s) + return sprintf(`"%s"`,substitute(s,"\n","\\n")) + end function -global function unquote(string s) - if s[1]!='\"' then ?9/0 end if - if s[$]!='\"' then ?9/0 end if - s = substitute(s[2..-2],"\\n","\n") - return s -end function + global function unquote(string s) + if s[1]!='\"' then ?9/0 end if + if s[$]!='\"' then ?9/0 end if + s = substitute(s[2..-2],"\\n","\n") + return s + end function + + -- + -- demo\rosetta\Compiler\js_io.e + -- ============================= + -- + -- Fake file i/o for running under pwa/p2js in a browser + -- Does not cover the human readable reload parts of extra.e + -- + with javascript_semantics + sequence {known_files,kfc} = columnize({ + {"test3.c",split(""" + /* + All lexical tokens - not syntactically correct, but that will + have to wait until syntax analysis + */ + /* Print */ print /* Sub */ - + /* Putc */ putc /* Lss */ < + /* If */ if /* Gtr */ > + /* Else */ else /* Leq */ <= + /* While */ while /* Geq */ >= + /* Lbrace */ { /* Eq */ == + /* Rbrace */ } /* Neq */ != + /* Lparen */ ( /* And */ && + /* Rparen */ ) /* Or */ || + /* Uminus */ - /* Semi */ ; + /* Not */ ! /* Comma */ , + /* Mul */ * /* Assign */ = + /* Div */ / /* Integer */ 42 + /* Mod */ % /* String */ "String literal" + /* Add */ + /* Ident */ variable_name + /* character literal */ '\n' + /* character literal **/ '\\' + /* character literal */ ' ' + ""","\n")}, + {"test4.c",split(""" + /*** test printing, embedded \n and comments with lots of '*' ***/ + print(42); + print("\nHello World\nGood Bye\nok\n"); + print("Print a slash n - \\n.\n"); + ""","\n")}, + {"primes.c",split(""" + /* + Simple prime number generator + */ + count = 1; + n = 1; + limit = 100; + while (n < limit) { + k=3; + p=1; + n=n+2; + while ((k*k<=n) && (p)) { + p=n/k*k!=n; + k=k+2; + } + if (p) { + print(n, " is prime\n"); + count = count + 1; + } + } + print("Total primes found: ", count, "\n"); + ""","\n")}, + {"gcd.c",split(""" + /* Compute the gcd of 1071, 1029: 21 */ -a = 1071; -b = 1029; + a = 1071; + b = 1029; -while (b != 0) { - new_a = b; - b = a % b; - a = new_a; -} -print(a); -`,"\n")}, -{"Header.h",split(` -#define area(h, w) h * w -`,"\n")}, -{"Source.t",split(` -#include "Header.h" -#define width 5 -#define height 6 -area = #area(height, width)#; -`,"\n")}}) + while (b != 0) { + new_a = b; + b = a % b; + a = new_a; + } + print(a); + ""","\n")}, + {"Header.h",split(""" + #define area(h, w) h * w + ""","\n")}, + {"Source.t",split(""" + #include "Header.h" + #define width 5 + #define height 6 + area = #area(height, width)#; + ""","\n")}}) -sequence linenos = repeat(-1,length(known_files)) + sequence linenos = repeat(-1,length(known_files)) -global function js_open(string filename) - integer fn = find(filename,known_files) - assert(fn!=0) - linenos[fn] = 0 - return fn -end function + global function js_open(string filename) + integer fn = find(filename,known_files) + assert(fn!=0) + linenos[fn] = 0 + return fn + end function -global function js_gets(integer fn) - integer lineno = linenos[fn]+1 - if lineno<=length(kfc[fn]) then - linenos[fn] = lineno - return kfc[fn][lineno] - end if - return EOF -end function + global function js_gets(integer fn) + integer lineno = linenos[fn]+1 + if lineno<=length(kfc[fn]) then + linenos[fn] = lineno + return kfc[fn][lineno] + end if + return EOF + end function + + -- + -- demo\\rosetta\\Compiler\\lex.e + -- ============================== + -- + -- The reusable part of lex.exw + -- This is only kept separate from core.e for consistency with later modules. -integer ch = ' ', - line = 0, - col = 0 + with javascript_semantics + include core.e -procedure eof(string s) - error("%s in %s literal",{iff(ch=EOF?"EOF":"EOL"),s}) -end procedure + integer ch = ' ', + line = 0, + col = 0 -function next_ch() - while 1 do - col += 1 - if oneline=EOF then - ch = EOF - exit - elsif col>length(oneline) then - line += 1 - col = 0 - oneline = iff(platform()=JS?js_gets(input_file) - :gets(input_file)) - else - ch = oneline[col] - exit - end if - end while - return ch -end function + procedure eof(string s) + error("%s in %s literal",{iff(ch=EOF?"EOF":"EOL"),s}) + end procedure --- for pwa/p2js (JavaScript *really* dislikes tabs in strings): ---constant whitespace = " \t\r\n\x0B\xA0" -constant whitespace = {' ','\t','\r','\n',#0B,#A0} --- (0x0B is Vertical Tab, 0xA0 is Non-breaking space) + function next_ch() + while 1 do + col += 1 + if oneline=EOF then + ch = EOF + exit + elsif col>length(oneline) then + line += 1 + col = 0 + oneline = iff(platform()=JS?js_gets(input_file) + :gets(input_file)) + else + ch = oneline[col] + exit + end if + end while + return ch + end function -procedure skipspacesandcomments() - while 1 do - if not find(ch,whitespace) then - if ch='/' and col-- for pwa/p2js (JavaScript *really* dislikes tabs in strings): + --constant whitespace = " \t\r\n\x0B\xA0" + constant whitespace = {' ','\t','\r','\n',#0B,#A0} + -- (0x0B is Vertical Tab, 0xA0 is Non-breaking space) -function escape_char(string s) - ch = next_ch() -- (discard the '\\') - if ch='n' then - ch = '\n' - elsif ch='\\' then - ch = '\\' - elsif ch=EOF - or ch='\n' then - eof(s) - else - error(`unknown escape sequence \%c`, {ch}) - end if - return ch -end function + procedure skipspacesandcomments() + while 1 do + if not find(ch,whitespace) then + if ch='/' and col<length(oneline) and oneline[col+1]='*' then + tok_line = line -- (in case of EOF error) + tok_col = col + ch = next_ch() -- (can be EOF) + ch = next_ch() -- ( "" ) + while 1 do + if ch='*' then + ch = next_ch() + if ch='/' then exit end if + elsif ch=EOF then + error("EOF in comment") + else + ch = next_ch() + end if + end while + else + exit + end if + end if + ch = next_ch() + end while + end procedure -function char_lit() - integer startch = ch, - res = next_ch() -- (skip opening quote, save res) - if ch=startch then - error("empty character constant") - elsif ch='\\' then - res = escape_char("character") - end if - ch = next_ch() - if ch=EOF - or ch='\n' then - eof("character") - elsif ch!=startch then - error("multi-character constant") - end if - ch = next_ch() - return {tk_Integer, res} -end function + function escape_char(string s) + ch = next_ch() -- (discard the '\\') + if ch='n' then + ch = '\n' + elsif ch='\\' then + ch = '\\' + elsif ch=EOF + or ch='\n' then + eof(s) + else + error(`unknown escape sequence \%c`, {ch}) + end if + return ch + end function -function string_lit() - integer startch = ch - string text = "" - while next_ch()!=startch do - if ch=EOF - or ch='\n' then - eof("string") - elsif ch='\\' then - ch = escape_char("string") - end if - text &= ch - end while - ch = next_ch() - return {tk_String, text} -end function + function char_lit() + integer startch = ch, + res = next_ch() -- (skip opening quote, save res) + if ch=startch then + error("empty character constant") + elsif ch='\\' then + res = escape_char("character") + end if + ch = next_ch() + if ch=EOF + or ch='\n' then + eof("character") + elsif ch!=startch then + error("multi-character constant") + end if + ch = next_ch() + return {tk_Integer, res} + end function -function get_op() --- sequence operator = {ch} - string operator = ""&ch - ch = next_ch() - while charmap[ch]=OPERATOR - and find(operator&ch,operators) do - -- (^ ie/eg merge ">=", but not ");") - operator &= ch - ch = next_ch() - end while - integer k = find(operator,operators) - if k=0 then error("unknown operator") end if - return {opcodes[k], 0} -- (0 unused) -end function + function string_lit() + integer startch = ch + string text = "" + while next_ch()!=startch do + if ch=EOF + or ch='\n' then + eof("string") + elsif ch='\\' then + ch = escape_char("string") + end if + text &= ch + end while + ch = next_ch() + return {tk_String, text} + end function -function get_int() - integer i = 0 - while charmap[ch]=DIGIT do - i = i*10 + (ch-'0') - ch = next_ch() - end while - if charmap[ch]=LETTER then - error("invalid number") - end if - return {tk_Integer, i} -end function + function get_op() + -- sequence operator = {ch} + string operator = ""&ch + ch = next_ch() + while charmap[ch]=OPERATOR + and find(operator&ch,operators) do + -- (^ ie/eg merge ">=", but not ");") + operator &= ch + ch = next_ch() + end while + integer k = find(operator,operators) + if k=0 then error("unknown operator") end if + return {opcodes[k], 0} -- (0 unused) + end function -function get_ident() - string text = "" - while find(charmap[ch],{LETTER,DIGIT}) do - text &= ch - ch = next_ch() - end while - integer keyword = getd(text,KEYWORDS) - if keyword!=NULL then - return {keyword, 0} -- (0 unused) - end if - return {tk_Identifier, text} -end function + function get_int() + integer i = 0 + while charmap[ch]=DIGIT do + i = i*10 + (ch-'0') + ch = next_ch() + end while + if charmap[ch]=LETTER then + error("invalid number") + end if + return {tk_Integer, i} + end function -function get_token() - skipspacesandcomments() - tok_line = line - tok_col = col - switch ch do - case EOF then return {tk_EOI, 0} -- (0 unused) - case '\'' then return char_lit() - case '"' then return string_lit() - else - switch charmap[ch] do - case OPERATOR then return get_op() - case DIGIT then return get_int() - case LETTER then return get_ident() - else error("unrecognized character: (%d)", {ch}) - end switch - end switch -end function + function get_ident() + string text = "" + while find(charmap[ch],{LETTER,DIGIT}) do + text &= ch + ch = next_ch() + end while + integer keyword = getd(text,KEYWORDS) + if keyword!=NULL then + return {keyword, 0} -- (0 unused) + end if + return {tk_Identifier, text} + end function -global function lex() - sequence toks = {} - integer tok = -1 - object v - while tok!=tk_EOI do - {tok,v} = get_token() - toks = append(toks,{tok_line,tok_col,tok,v}) - end while - return toks -end function + function get_token() + skipspacesandcomments() + tok_line = line + tok_col = col + switch ch do + case EOF then return {tk_EOI, 0} -- (0 unused) + case '\'' then return char_lit() + case '"' then return string_lit() + else + switch charmap[ch] do + case OPERATOR then return get_op() + case DIGIT then return get_int() + case LETTER then return get_ident() + else error("unrecognized character: (%d)", {ch}) + end switch + end switch + end function + + global function lex() + sequence toks = {} + integer tok = -1 + object v + while tok!=tk_EOI do + {tok,v} = get_token() + toks = append(toks,{tok_line,tok_col,tok,v}) + end while + return toks + end function + + -- + -- demo\rosetta\Compiler\extra.e + -- ============================= + -- + -- Routines to reload human-readable files (deviation from task requirement) + -- + without js -- (file i/o) ---The following can be used to load .lex files, as created by lex.exw: --- (in place of the existing get_tok() in parse.e) -function get_tok() - string line = trim(gets(input_file)) - sequence tok = split(line,' ',limit:=4,no_empty:=1) - integer k = find(tok[3],tkNames) - if k=0 then ?9/0 end if - tok[3] = k - return tok -end function + --The following can be used to load .lex files, as created by lex.exw: + -- (in place of the existing get_tok() in parse.e) + function get_tok() + string line = trim(gets(input_file)) + sequence tok = split(line,' ',limit:=4,no_empty:=1) + integer k = find(tok[3],tkNames) + if k=0 then ?9/0 end if + tok[3] = k + return tok + end function ---The following can be used to load .ast files, as created by parse.exw: --- (in place of the existing lex()/parse() pairs in cgen.exw and interp.exw) -function load_ast() - string line = trim(gets(input_file)) - -- Each line has at least one token - sequence node = split(line,' ',limit:=2,no_empty:=1) + --The following can be used to load .ast files, as created by parse.exw: + -- (in place of the existing lex()/parse() pairs in cgen.exw and interp.exw) + function load_ast() + string line = trim(gets(input_file)) + -- Each line has at least one token + sequence node = split(line,' ',limit:=2,no_empty:=1) - string node_type = node[1] + string node_type = node[1] - if node_type == ";" then -- a terminal node - return NULL - end if + if node_type == ";" then -- a terminal node + return NULL + end if - integer n_type = find(node_type,tkNames) - if n_type=0 then ?9/0 end if + integer n_type = find(node_type,tkNames) + if n_type=0 then ?9/0 end if - -- A line with two tokens is a leaf node - -- Leaf nodes are: Identifier, Integer, String - -- The 2nd token is the value - if length(node)>1 then - node[1] = n_type - if n_type=tk_Integer then - node[2] = to_integer(node[2]) - elsif n_type=tk_String then - node[2] = unquote(node[2]) - end if - return node - end if - object left = load_ast() - object right = load_ast() - return {n_type, left, right} -end function + -- A line with two tokens is a leaf node + -- Leaf nodes are: Identifier, Integer, String + -- The 2nd token is the value + if length(node)>1 then + node[1] = n_type + if n_type=tk_Integer then + node[2] = to_integer(node[2]) + elsif n_type=tk_String then + node[2] = unquote(node[2]) + end if + return node + end if + object left = load_ast() + object right = load_ast() + return {n_type, left, right} + end function + + -- + -- demo\rosetta\Compiler\lex.exw + -- ============================= + -- + with javascript_semantics + include lex.e -procedure main(sequence cl) - open_files(cl) - sequence toks = lex() - integer tok - object v - for i=1 to length(toks) do - {tok_line,tok_col,tok,v} = toks[i] - switch tok do - case tk_Identifier: v = sprintf(" %s",v) - case tk_Integer: v = sprintf(" %5d",v) - case tk_String: v = sprintf(" %s",enquote(v)) - else v = "" - end switch - printf(output_file, "%5d %5d %-10s%s\n", {tok_line,tok_col,tkNames[tok],v}) - end for - close_files() -end procedure + procedure main(sequence cl) + open_files(cl) + sequence toks = lex() + integer tok + object v + for i=1 to length(toks) do + {tok_line,tok_col,tok,v} = toks[i] + switch tok do + case tk_Identifier: v = sprintf(" %s",v) + case tk_Integer: v = sprintf(" %5d",v) + case tk_String: v = sprintf(" %s",enquote(v)) + else v = "" + end switch + printf(output_file, "%5d %5d %-10s%s\n", {tok_line,tok_col,tkNames[tok],v}) + end for + close_files() + end procedure ---main(command_line()) -main({0,0,"test4.c"}) + --main(command_line()) + main({0,0,"test4.c"}) + + -- + -- demo\rosetta\Compiler\parse.e + -- ============================= + -- + -- The reusable part of parse.exw + -- + with javascript_semantics + include lex.e -sequence tok + sequence tok -procedure errd(sequence msg, sequence args={}) - {tok_line,tok_col} = tok - error(msg,args) -end procedure + procedure errd(sequence msg, sequence args={}) + {tok_line,tok_col} = tok + error(msg,args) + end procedure -global sequence toks -integer next_tok = 1 + global sequence toks + integer next_tok = 1 -function get_tok() - sequence tok = toks[next_tok] - next_tok += 1 - return tok -end function + function get_tok() + sequence tok = toks[next_tok] + next_tok += 1 + return tok + end function -procedure expect(string msg, integer s) - integer tk = tok[3] - if tk!=s then - errd("%s: Expecting '%s', found '%s'\n", {msg, tkNames[s], tkNames[tk]}) - end if - tok = get_tok() -end procedure + procedure expect(string msg, integer s) + integer tk = tok[3] + if tk!=s then + errd("%s: Expecting '%s', found '%s'\n", {msg, tkNames[s], tkNames[tk]}) + end if + tok = get_tok() + end procedure -function expr(integer p) - object x = NULL, node - integer op = tok[3] + function expr(integer p) + object x = NULL, node + integer op = tok[3] - switch op do - case tk_LeftParen: - tok = get_tok() - x = expr(0) - expect("expr",tk_RightParen) - case tk_sub: - case tk_add: - tok = get_tok() - node = expr(precedences[tk_neg]); - x = iff(op==tk_sub?{tk_neg, node, NULL}:node) - case tk_not: - tok = get_tok(); - x = {tk_not, expr(precedences[tk_not]), NULL} - case tk_Identifier: - x = {tk_Identifier, tok[4]} - tok = get_tok(); - case tk_Integer: - x = {tk_Integer, tok[4]} - tok = get_tok(); - default: - errd("Expecting a primary, found: %s\n", tkNames[op]) - end switch + switch op do + case tk_LeftParen: + tok = get_tok() + x = expr(0) + expect("expr",tk_RightParen) + case tk_sub: + case tk_add: + tok = get_tok() + node = expr(precedences[tk_neg]); + x = iff(op==tk_sub?{tk_neg, node, NULL}:node) + case tk_not: + tok = get_tok(); + x = {tk_not, expr(precedences[tk_not]), NULL} + case tk_Identifier: + x = {tk_Identifier, tok[4]} + tok = get_tok(); + case tk_Integer: + x = {tk_Integer, tok[4]} + tok = get_tok(); + default: + errd("Expecting a primary, found: %s\n", tkNames[op]) + end switch - op = tok[3] - while narys[op]=BINARY - and precedences[op]>=p do - tok = get_tok() - x = {op, x, expr(precedences[op]+1)} - op = tok[3] - end while - return x; -end function + op = tok[3] + while narys[op]=BINARY + and precedences[op]>=p do + tok = get_tok() + x = {op, x, expr(precedences[op]+1)} + op = tok[3] + end while + return x; + end function -function paren_expr(string msg) - expect(msg, tk_LeftParen); - object t = expr(0) - expect(msg, tk_RightParen); - return t -end function + function paren_expr(string msg) + expect(msg, tk_LeftParen); + object t = expr(0) + expect(msg, tk_RightParen); + return t + end function -function stmt() - object t = NULL, e, s + function stmt() + object t = NULL, e, s - switch tok[3] do - case tk_if: - tok = get_tok(); - object condition = paren_expr("If-cond"); - object ifblock = stmt(); - object elseblock = NULL; - if tok[3] == tk_else then - tok = get_tok(); - elseblock = stmt(); - end if - t = {tk_if, condition, {tk_if, ifblock, elseblock}} - case tk_putc: - tok = get_tok(); - e = paren_expr("Prtc") - t = {tk_putc, e, NULL} - expect("Putc", tk_Semicolon); - case tk_print: - tok = get_tok(); - expect("Print",tk_LeftParen) - while 1 do - if tok[3] == tk_String then - e = {tk_Prints, {tk_String, tok[4]}, NULL} - tok = get_tok(); - else - e = {tk_Printi, expr(0), NULL} - end if - t = {tk_Sequence, t, e} - if tok[3]!=tk_Comma then exit end if - expect("Print", tk_Comma) - end while - expect("Print", tk_RightParen); - expect("Print", tk_Semicolon); - case tk_Semicolon: - tok = get_tok(); - case tk_Identifier: - object v - v = {tk_Identifier, tok[4]} - tok = get_tok(); - expect("assign", tk_assign); - e = expr(0); - t = {tk_assign, v, e} - expect("assign", tk_Semicolon); - case tk_while: - tok = get_tok(); - e = paren_expr("while"); - s = stmt(); - t = {tk_while, e, s} - case tk_LeftBrace: /* {stmt} */ - expect("LeftBrace", tk_LeftBrace) - while not find(tok[3],{tk_RightBrace,tk_EOI}) do - t = {tk_Sequence, t, stmt()} - end while - expect("LeftBrace", tk_RightBrace); - break; - case tk_EOI: - break; - default: - errd("expecting start of statement, found '%s'\n", tkNames[tok[3]]); - end switch - return t -end function + switch tok[3] do + case tk_if: + tok = get_tok(); + object condition = paren_expr("If-cond"); + object ifblock = stmt(); + object elseblock = NULL; + if tok[3] == tk_else then + tok = get_tok(); + elseblock = stmt(); + end if + t = {tk_if, condition, {tk_if, ifblock, elseblock}} + case tk_putc: + tok = get_tok(); + e = paren_expr("Prtc") + t = {tk_putc, e, NULL} + expect("Putc", tk_Semicolon); + case tk_print: + tok = get_tok(); + expect("Print",tk_LeftParen) + while 1 do + if tok[3] == tk_String then + e = {tk_Prints, {tk_String, tok[4]}, NULL} + tok = get_tok(); + else + e = {tk_Printi, expr(0), NULL} + end if + t = {tk_Sequence, t, e} + if tok[3]!=tk_Comma then exit end if + expect("Print", tk_Comma) + end while + expect("Print", tk_RightParen); + expect("Print", tk_Semicolon); + case tk_Semicolon: + tok = get_tok(); + case tk_Identifier: + object v + v = {tk_Identifier, tok[4]} + tok = get_tok(); + expect("assign", tk_assign); + e = expr(0); + t = {tk_assign, v, e} + expect("assign", tk_Semicolon); + case tk_while: + tok = get_tok(); + e = paren_expr("while"); + s = stmt(); + t = {tk_while, e, s} + case tk_LeftBrace: /* {stmt} */ + expect("LeftBrace", tk_LeftBrace) + while not find(tok[3],{tk_RightBrace,tk_EOI}) do + t = {tk_Sequence, t, stmt()} + end while + expect("LeftBrace", tk_RightBrace); + break; + case tk_EOI: + break; + default: + errd("expecting start of statement, found '%s'\n", tkNames[tok[3]]); + end switch + return t + end function -global function parse() - object t = NULL - tok = get_tok() - while 1 do - object s = stmt() - if s=NULL then exit end if - t = {tk_Sequence, t, s} - end while - return t -end function -And a simple test driver for the specific task: + global function parse() + object t = NULL + tok = get_tok() + while 1 do + object s = stmt() + if s=NULL then exit end if + t = {tk_Sequence, t, s} + end while + return t + end function + + -- + -- demo\rosetta\Compiler\parse.exw + -- =============================== + -- + with javascript_semantics + include parse.e -procedure print_ast(object t) - if t == NULL then - printf(output_file,";\n") - else - integer ttype = t[1] - printf(output_file,tkNames[ttype]) - if ttype=tk_Identifier then - printf(output_file," %s\n",t[2]) - elsif ttype=tk_Integer then - printf(output_file," %d\n",t[2]) - elsif ttype=tk_String then - printf(output_file," %s\n",enquote(t[2])) - else - printf(output_file,"\n") - print_ast(t[2]) - print_ast(t[3]) - end if - end if -end procedure + procedure print_ast(object t) + if t == NULL then + printf(output_file,";\n") + else + integer ttype = t[1] + printf(output_file,tkNames[ttype]) + if ttype=tk_Identifier then + printf(output_file," %s\n",t[2]) + elsif ttype=tk_Integer then + printf(output_file," %d\n",t[2]) + elsif ttype=tk_String then + printf(output_file," %s\n",enquote(t[2])) + else + printf(output_file,"\n") + print_ast(t[2]) + print_ast(t[3]) + end if + end if + end procedure -function ptree(object t) - if sequence(t) then - integer t1 = t[1] - t = deep_copy(t) - t[1] = tkNames[t1] - if not find(t1,{tk_Identifier,tk_String}) then - for i=2 to length(t) do - if t1=tk_Sequence and t[i]=NULL then - t[i] = "NULL" - else - t[i] = ptree(t[i]) - end if - end for - end if - end if - return t -end function + function ptree(object t) + if sequence(t) then + integer t1 = t[1] + t = deep_copy(t) + t[1] = tkNames[t1] + if not find(t1,{tk_Identifier,tk_String}) then + for i=2 to length(t) do + if t1=tk_Sequence and t[i]=NULL then + t[i] = "NULL" + else + t[i] = ptree(t[i]) + end if + end for + end if + end if + return t + end function -procedure main(sequence cl) - open_files(cl) - toks = lex() - object t = parse() - print_ast(t) -pp(ptree(t),{pp_Nest,10,pp_Pause,0,pp_IntCh,false}) - close_files() -end procedure + procedure main(sequence cl) + open_files(cl) + toks = lex() + object t = parse() + print_ast(t) + pp(ptree(t),{pp_Nest,10,pp_Pause,0,pp_IntCh,false}) + close_files() + end procedure ---main(command_line()) -main({0,0,"test3.c"}) -- not parseable! ---main({0,0,"primes.c"}) -- as Algol, C, Python (apart from spacing) ---main({0,0,"count.c"}) -- as AWK ( "" ) + --main(command_line()) + main({0,0,"test3.c"}) -- not parseable! + --main({0,0,"primes.c"}) -- as Algol, C, Python (apart from spacing) + --main({0,0,"count.c"}) -- as AWK ( "" ) + + -- + -- demo\rosetta\Compiler\vm.exw + -- ============================ + -- + -- Since we have generated executable machine code, the virtual machine, such as it is, is just + -- the higher level implementations of printc/i/s, see setbuiltins() in cgen.e + -- Otherwise the only difference between this and cgen.exw is call(code_mem) instead of decode(). + -- + -- A quick test (calculating fib(44) 10^6 times) suggests ~500 times faster than interp.exw - + -- which is to be expected given that a single add instruction (1 clock) here is implemented as + -- at least three (and quite possibly five!) resursive calls to interp() in the other. -procedure main(sequence cl) - open_files(cl) - toks = lex() - object t = parse() - code_gen(t) - fixup() - if machine_bits()=32 then - -- ^ as per note above - call(code_mem) - end if - free({var_mem,code_mem}) - close_files() -end procedure + format PE32 + --format ELF32 + -- Note: cgen generates 32-bit machine code, which cannot be executed directly from a 64-bit interpreter. + -- You can however, via the magic of either the above format directives, use a 64-bit version of + -- Phix to compile this (just add a -c command line option) to a 32-bit executable, which can. + -- It would not be particularly difficult to emit 32 or 64 bit code, but some source code files + -- would, fairly obviously, then be very nearly twice as long, and a fair bit harder to read. ---main(command_line()) -main({0,0,"count.c"}) + without js -- (machine code!) + include cgen.e + + procedure main(sequence cl) + open_files(cl) + toks = lex() + object t = parse() + code_gen(t) + fixup() + if machine_bits()=32 then + -- ^ as per note above + call(code_mem) + end if + free({var_mem,code_mem}) + close_files() + end procedure + + --main(command_line()) + main({0,0,"count.c"}) + + with javascript_semantics + integer count = 0, n = 11*11, + limit = iff(platform()=JS?10:20) + atom t0 = time(), t1 = time() + while count<limit do + if gcd(n,3*5*7)=1 then + sequence f = prime_factors(n,true,-1) + if length(f)>1 then + string s = sprintf("%d",n) + bool valid = true + for i=1 to length(f) do + if (i=1 or f[i]!=f[i-1]) + and not match(sprintf("%d",f[i]),s) then + valid = false + exit + end if + end for + if valid then + count += 1 + string t = join(apply(f,sprint),"x"), + e = elapsed(time()-t1) + printf(1,"%2d: %,10d = %-17s (%s)\n",{count,n,t,e}) + t1 = time() + end if + end if + end if + n += 2 + end while + printf(1,"Total time:%s\n",{elapsed(time()-t0)}) + + with javascript_semantics + integer count = 0, n = 11*11, + limit = iff(platform()=JS?10:20) + atom t0 = time(), t1 = time() + while count<limit do + string s = sprintf("%d",n) + integer l = floor(sqrt(n)), k = n, f = 3 + bool valid = true + while true do + if remainder(k,f)=0 then + if f<10 or not match(sprintf("%d",f),s) then + valid = false + exit + end if + if f=k then exit end if + k /= f + else + f += 2 + if f>l then + if k=n or not match(sprintf("%d",k),s) then + valid = false + end if + exit + end if + end if + end while + if valid then + count += 1; + string t = join(apply(prime_factors(n,true,-1),sprint),"x"), + e = elapsed(time()-t1) + printf(1,"%2d: %,10d = %-17s (%s)\n",{count,n,t,e}) + t1 = time() + end if + n += 2 + end while + printf(1,"Total time:%s\n",{elapsed(time()-t0)}) + + without js -- (threads) + procedure echo(string s) + sleep(rand(100)/100) + enter_cs() + puts(1,s) + puts(1,'\n') + leave_cs() + end procedure -constant threads = {create_thread(routine_id("echo"),{"Enjoy"}), - create_thread(routine_id("echo"),{"Rosetta"}), - create_thread(routine_id("echo"),{"Code"})} + constant threads = {create_thread(routine_id("echo"),{"Enjoy"}), + create_thread(routine_id("echo"),{"Rosetta"}), + create_thread(routine_id("echo"),{"Code"})} -wait_thread(threads) -puts(1,"done") -{} = wait_key() + wait_thread(threads) + puts(1,"done") + {} = wait_key() + + with javascript_semantics + constant precision = 10000 -function continued_fraction(integer f, steps=precision) - atom a, b, res = 0 - for n=steps to 1 by -1 do - {a, b} = f(n) - res := b / (a + res) - end for - {a} = f(0) - return a + res -end function + function continued_fraction(integer f, steps=precision) + atom a, b, res = 0 + for n=steps to 1 by -1 do + {a, b} = f(n) + res := b / (a + res) + end for + {a} = f(0) + return a + res + end function -function sqr2(integer n) return {iff(n=0?1:2),1} end function + function sqr2(integer n) return {iff(n=0?1:2),1} end function -function nap(integer n) return {iff(n=0?2:n),iff(n=1?1:n-1)} end function + function nap(integer n) return {iff(n=0?2:n),iff(n=1?1:n-1)} end function -function pi(integer n) return {iff(n=0?3:6),power(2*n-1,2)} end function + function pi(integer n) return {iff(n=0?3:6),power(2*n-1,2)} end function -printf(1,"Precision: %d\n", {precision}) -printf(1,"Sqr(2): %.10g\n", {continued_fraction(sqr2)}) -printf(1,"Napier: %.10g\n", {continued_fraction(nap)}) -printf(1,"Pi: %.10g\n", {continued_fraction(pi)}) + printf(1,"Precision: %d\n", {precision}) + printf(1,"Sqr(2): %.10g\n", {continued_fraction(sqr2)}) + printf(1,"Napier: %.10g\n", {continued_fraction(nap)}) + printf(1,"Pi: %.10g\n", {continued_fraction(pi)}) + + with javascript_semantics + function decrat(string s) + integer nom = 0, + denom = 1 + assert(s[1..2]="0.") + for i=3 to length(s) do + integer ch = s[i] + assert(ch>='0' and ch<='9') + nom = nom*10 + ch-'0' + denom *= 10 + end for + return sq_div({nom,denom},gcd(nom,denom)) + end function -?decrat("0.9054054") -?decrat("0.518518") -?decrat("0.75") + ?decrat("0.9054054") + ?decrat("0.518518") + ?decrat("0.75") + + with javascript_semantics + ?elapsed(7259) + ?elapsed(86400) + ?elapsed(6000000) + + with javascript_semantics + include timedate.e + ?elapsed(6000000-timedelta(days:=6,hours:=10)) + ) - - [ dup 1 - [ 2dup > while + 1 >> 2dup / again ] - drop nip ] is sqrt ( n --> n ) - - [ stack ] is width ( --> s ) - - [ tuck witheach - [ over i^ peek + rot i^ poke swap ] - drop ] is add ( [ [ --> [ ) - - [ 1 split swap join ] is left ( [ --> [ ) - - [ -1 split swap join ] is right ( [ --> [ ) - - [ width share split swap join ] is up ( [ --> [ ) - - [ width share negate split swap join ] is down ( [ --> [ ) - - [ left dup up tuck add - swap right tuck add - swap right tuck add - swap down tuck add - swap down tuck add - swap left tuck add - swap left add ] is neighbours ( [ --> [ ) - - [ [] swap - width share times - [ width share split - dip [ 0 swap 0 join join join ] ] - drop - 2 width tally - 0 width share of tuck join join ] is makeborder ( [ --> [ ) - - [ dup size times - [ 0 swap i^ poke - 0 swap i^ width share + 1 - poke - width share step ] - width share times - [ 0 swap i^ poke - 0 swap i^ 1 + negate poke ] ] is clearborder ( [ --> [ ) - - [ dup neighbours - witheach - [ over i^ peek iff - [ 1 | 3 != if - [ 0 swap i^ poke ] ] - done - 3 = if [ 1 swap i^ poke ] ] - clearborder ] is nextgen ( [ --> [ ) - - [ 6 random - [ table - [ 200 200 255 ] [ 200 255 200 ] - [ 255 200 200 ] [ 200 255 255 ] - [ 255 200 255 ] [ 255 255 200 ] ] - fill - [ 4 times - [ 20 1 walk -1 4 turn ] ] ] is block ( --> ) - - - [ clear - width share 10 * - dup negate - 4 - 1 fly - -1 4 turn - 16 - 1 fly - 1 4 turn - 20 1 fly - ' [ 200 200 200 ] colour - 4 times - [ width share 2 - 20 * 1 walk - 1 4 turn ] - -20 1 fly - ' [ 63 63 63 ] colour - width share times - [ width share split - swap witheach - [ if block - 20 1 fly ] - width share -20 * 1 fly - 1 4 turn - 20 1 fly - -1 4 turn ] - drop wait frame ] is draw ( [ --> ) - - [ turtle 0 frames 2 wide - dup size sqrt width put - makeborder - dup - [ dup draw nextgen - dip [ nextgen nextgen ] - 2dup = until ] - 5 times - [ dup draw nextgen 2dup = until ] - 2drop width release ] is life ( [ --> ) - - ' [ 0 0 0 - 1 1 1 - 0 0 0 ] life ( task requirement ) - - ' [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] life ( more interesting ) - - randomise - [ [] - 1089 times - [ 2 random join ] - life - again ] ( ... runs forever ) diff --git a/Task/Conways-Game-of-Life/Rebol/conways-game-of-life.rebol b/Task/Conways-Game-of-Life/Rebol/conways-game-of-life.rebol deleted file mode 100644 index 081d04e55e..0000000000 --- a/Task/Conways-Game-of-Life/Rebol/conways-game-of-life.rebol +++ /dev/null @@ -1,81 +0,0 @@ -Rebol [ - title: "Rosetta code: Conway's Game of Life" - file: %Conway's_Game_of_Life.r3 - url: https://rosettacode.org/wiki/Conway%27s_Game_of_Life - note: "Based on Joe Smith's Red language implementation!" -] -conway: function/with [ - "Conway's Game of Life" - petri [block!] "Current grid (Petri dish) as a block of rows, each row a block of 0/1" - /display "Print the grid" -][ - if display [print-table petri] ;; optionally render current generation - new-petri: copy/deep petri ;; prepare next generation grid - repeat row length? petri [ ;; iterate rows - repeat col length? petri [ ;; iterate columns (assumes square grid; adjust if rectangular) - live-neigh: 0 ;; count of live neighbors - ;; Accumulate live neighbors using relative offsets; ignore out-of-bounds via try - foreach cell neigh [ - try [ - if petri/(:row + cell/1)/(:col + cell/2) = 1 [ - live-neigh: live-neigh + 1 - ] - ] - ] - ;; Apply Conway's Game of Life rules - switch petri/:row/:col [ - 1 [ ;; live cell - if any [live-neigh < 2 live-neigh > 3] [ - new-petri/:row/:col: 0 ;; underpopulation or overcrowding -> dies - ] - ] - 0 [ ;; dead cell - if live-neigh = 3 [ - new-petri/:row/:col: 1 ;; reproduction -> becomes alive - ] - ] - ] - ] - ] - ;; Replace current grid with the newly computed one (in-place update) - clear insert petri new-petri -][ - ;; Neighbor offsets: N, S, E, W, and four diagonals - neigh: [[0 1] [0 -1] [1 0] [-1 0] [1 1] [1 -1] [-1 1] [-1 -1]] - - ;; Render a binary grid using buffered terminal output, with simple ANSI escapes - print-table: function [table] [ - buf: clear "" ;; output buffer (reduces flicker) - append buf "^[[H^[[2J^[[3J^/" ;; clear screen and home cursor - foreach row table [ - append buf replace/all (replace/all to-string row "0" "_") "1" "#" - append buf LF - ] - print buf - wait 0.2 ;; small delay for animation pacing - table - ] -] - -;- DEMO: - -*3-3: [ ;; a 3x3 blinker oscillator - [0 1 0] - [0 1 0] - [0 1 0] -] -*8-8: [ ;; an 8x8 glider pattern (top-left) - [0 0 1 0 0 0 0 0] - [0 0 0 1 0 0 0 0] - [0 1 1 1 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] -] - -print "^[[?25l" ;; hide cursor for animation -loop 10 [ conway/display *3-3 ] ;; run 10 generations of the blinker -loop 23 [ conway/display *8-8 ] ;; run 23 generations of the glider -print "^[[?25h" ;; show cursor after animation diff --git a/Task/Conways-Game-of-Life/Red/conways-game-of-life-1.red b/Task/Conways-Game-of-Life/Red/conways-game-of-life-1.red deleted file mode 100644 index 60c6fb2278..0000000000 --- a/Task/Conways-Game-of-Life/Red/conways-game-of-life-1.red +++ /dev/null @@ -1,56 +0,0 @@ -Red [ - Purpose: "Conway's Game of Life" - Author: "Joe Smith" -] - -neigh: [[0 1] [0 -1] [1 0] [-1 0] [1 1] [1 -1] [-1 1] [-1 -1]] -conway: function [petri] [ - new-petri: copy/deep petri - repeat row length? petri [ - repeat col length? petri [ - live-neigh: 0 - foreach cell neigh [ - try [ - if petri/(:row + cell/1)/(:col + cell/2) = 1 [live-neigh: live-neigh + 1] - ] - ] - switch petri/:row/:col [ - 1 [if any [live-neigh < 2 live-neigh > 3] - [new-petri/:row/:col: 0] - ] - 0 [if live-neigh = 3 [new-petri/:row/:col: 1]] - ]]] - clear insert petri new-petri -] - -*3-3: [ - [0 1 0] - [0 1 0] - [0 1 0] -] - -*8-8: [ - [0 0 1 0 0 0 0 0] - [0 0 0 1 0 0 0 0] - [0 1 1 1 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] - [0 0 0 0 0 0 0 0] -] - -display: function [table] [ - foreach row table [ - print replace/all (replace/all to-string row "0" "_") "1" "#" - ] print "" -] - -loop 5 [ - display *3-3 - conway *3-3 -] -loop 23 [ - display *8-8 - conway *8-8 -] diff --git a/Task/Conways-Game-of-Life/Red/conways-game-of-life-2.red b/Task/Conways-Game-of-Life/Red/conways-game-of-life-2.red deleted file mode 100644 index 1b28ee8f37..0000000000 --- a/Task/Conways-Game-of-Life/Red/conways-game-of-life-2.red +++ /dev/null @@ -1,130 +0,0 @@ -Red [ - title: "Conway's Game of Life (graphical view)" - author: "hinjolicious" - needs: 'view -] - -func-to-string: func [f][rejoin ["func [" form spec-of :f "] [" body-of :f "]"]] ; not used! - -PLOTTER: make object! [ - ; just some defaults: - display-size: 500x500 - x-range: [-4.0 4.0] y-range: [-4.0 4.0] - x1: -1.0 x2: 1.0 y1: -1.0 y2: 1.0 x-step: 0.01 - color: blue background-color: black line-size: 1 - fn: func [x][sin x] ; a function - draws: none - header: none - - ; Internal function to map a math coordinate (x,y) to a pixel pair (xp, yp) - MAP-TO-PIXELS: function [x y][ - xp: (x - x1) * (display-size/1 / (x2 - x1)) - ; Invert y because screen origin is top-left - yp: display-size/2 - ((y - y1) * (display-size/2 / (y2 - y1))) - as-point2D xp yp - ] - - DRAW: func [/local points x y][ - x-step: 0.01 - points: collect [ - x: x1 while [x <= x2][ - y: fn x - keep map-to-pixels x y - x: x + x-step] - ] - draws: compose [line-width (line-size) pen (color) line (points)] - ] - - SHOW: func [][ - if none? header [header: func-to-string :fn] - view/tight/flags [ - title header - canv: base display-size - background-color - draw draws - rate 100 ; for on-time func! - on-time [CHANGER] - [quit] ; mouse click = quit - ][no-border] - ] - - CHANGER: func[/local x y xy s n t][ - clear skip draws 5 ; clear display - ; display update and process next generation - repeat x xmax [ - repeat y ymax [ - s: mat/:x/:y ; current status? 1=live 0=dead - n: nb x y ; neigbours - - ; display current states with color indicators - color: case [ - all [s = 1 n < 2] [00.127.00] ; lonely - all [s = 1 n > 3] [127.00.00] ; crowded - s = 1 [00.127.00] ; n would be 2,3 --> stable - all [s = 0 n = 3] [00.00.127] ; new birth - true [black] ; barren - ] - xy: map-to-pixels x y - append draws compose [fill-pen (color) circle (xy) (rad)] - - ; process next generation - nxt/:x/:y: either any [ - all [mat/:x/:y = 1 n > 1 n < 4] ; lives on - all [mat/:x/:y = 0 n = 3] ; birth - ][1][0] - ] - ] - ; swap matrix - t: mat mat: nxt nxt: t - if (gen: gen + 1) > maxgen [init] - ] ; changer -] - -matrix-rand: func [a b][collect [loop a [keep/only collect [loop b [keep random/only [0 1]]]]]] -matrix-zero: func [a b][collect [loop a [keep/only collect [loop b [keep 0]]]]] - -; neighbour counting in a wrapped world! -nb: func [x y][ - xm1: x - 1 if xm1 < 1 [xm1: xmax] - xp1: x + 1 if xp1 > xmax [xp1: 1] - ym1: y - 1 if ym1 < 1 [ym1: ymax] - yp1: y + 1 if yp1 > ymax [yp1: 1] - mat/:xm1/:ym1 + mat/:xm1/:y + mat/:xm1/:yp1 + - mat/:x/:ym1 + mat/:x/:yp1 + - mat/:xp1/:ym1 + mat/:xp1/:y + mat/:xp1/:yp1 -] - -xmax: 100 ; number of cells, horiz -ymax: 100 ; vert -dispx: xmax * 10 ; display size for 10 pixels cell size -dispy: ymax * 10 ; vert -rad: 0 ; radial size for cells (calculated) - -; matrixes for generations: -mat: matrix-rand xmax ymax -nxt: matrix-zero xmax ymax - -; counters: -gen: 0 -maxgen: 500 - -init: does [ - mat: matrix-rand xmax ymax - nxt: matrix-zero xmax ymax - gen: 0 -] - -main: func [/local p][ - p: make plotter [] - p/header "Conway's Game of Life" - p/display-size: to-pair reduce [dispx dispy] ; display size regardless for x and y range - p/x1: 1 p/x2: xmax - p/y1: 1 p/y2: ymax - p/fn: func [x][x] ; dummy, not used - rad: (min (dispx / xmax) (dispy / ymax)) / 2 - p/draw ; generate drawing - p/draws/line-width: 0 - ;p/draws/pen: white - p/show ; display it -] -main diff --git a/Task/Conways-Game-of-Life/Red/conways-game-of-life.red b/Task/Conways-Game-of-Life/Red/conways-game-of-life.red new file mode 100644 index 0000000000..e72164f9bc --- /dev/null +++ b/Task/Conways-Game-of-Life/Red/conways-game-of-life.red @@ -0,0 +1,56 @@ +Red [ + Purpose: "Conway's Game of Life" + Author: "Joe Smith" +] + +neigh: [[0 1] [0 -1] [1 0] [-1 0] [1 1] [1 -1] [-1 1] [-1 -1]] +conway: function [petri] [ + new-petri: copy/deep petri + repeat row length? petri [ + repeat col length? petri [ + live-neigh: 0 + foreach cell neigh [ + try [ + if petri/(:row + cell/1)/(:col + cell/2) = 1 [live-neigh: live-neigh + 1] + ] + ] + switch petri/:row/:col [ + 1 [if any [live-neigh < 2 live-neigh > 3] + [new-petri/:row/:col: 0] + ] + 0 [if live-neigh = 3 [new-petri/:row/:col: 1]] + ]]] + clear insert petri new-petri +] + +*3-3: [ + [0 1 0] + [0 1 0] + [0 1 0] +] + +*8-8: [ + [0 0 1 0 0 0 0 0] + [0 0 0 1 0 0 0 0] + [0 1 1 1 0 0 0 0] + [0 0 0 0 0 0 0 0] + [0 0 0 0 0 0 0 0] + [0 0 0 0 0 0 0 0] + [0 0 0 0 0 0 0 0] + [0 0 0 0 0 0 0 0] +] + +display: function [table] [ + foreach row table [ + print replace/all (replace/all to-string row "0" "_") "1" "#" + ] print "" +] + +loop 5 [ + display *3-3 + conway *3-3 +] +loop 23 [ + display *8-8 + conway *8-8 +] diff --git a/Task/Conways-Game-of-Life/Rust/conways-game-of-life.rs b/Task/Conways-Game-of-Life/Rust/conways-game-of-life.rust similarity index 100% rename from Task/Conways-Game-of-Life/Rust/conways-game-of-life.rs rename to Task/Conways-Game-of-Life/Rust/conways-game-of-life.rust diff --git a/Task/Conways-Game-of-Life/Scheme/conways-game-of-life-2.scm b/Task/Conways-Game-of-Life/Scheme/conways-game-of-life-2.scm deleted file mode 100644 index b692b693b0..0000000000 --- a/Task/Conways-Game-of-Life/Scheme/conways-game-of-life-2.scm +++ /dev/null @@ -1,62 +0,0 @@ -(import (srfi 231)) - -(define (pad-array-with-zeros a N) - - ;; Pad two-dimensional array with N rows and columns of zeros, - ;; top and bottom, left and right. - ;; Assumes that the domain of a has zero lower bounds. - - (let* ((domain (array-domain a)) - (m (interval-upper-bound domain 0)) - (n (interval-upper-bound domain 1)) - (a_ (array-getter a))) - (make-array (interval-dilate domain (vector (- N) (- N)) (vector N N)) - (lambda (i j) - (or (and (< -1 i m) (< -1 j n) (a_ i j)) - 0))))) - -(define (neighbor-count a) - - ;; Returns a generalized array that contains the number - ;; of 1s in the 8 cells surrounding each cell in the original array. - - (let* ((big-a (array-copy! (pad-array-with-zeros a 1) - (array-storage-class a))) - (domain (array-domain a)) - (translates (map (lambda (translation) - (array-extract (array-translate big-a translation) domain)) - '(#(1 0) #(0 1) #(-1 0) #(0 -1) - #(1 1) #(1 -1) #(-1 1) #(-1 -1))))) - (apply array-map + translates))) - -(define (game-rules a neighbor-count) - - ;; a is the value in a single cell, neighbor-count is the count of 1s in - ;; its 8 neighboring cells. - - (if (zero? a) - (if (eqv? neighbor-count 3) 1 0) - (if (<= 2 neighbor-count 3) 1 0))) - -(define (advance a) - (array-copy! (array-map game-rules a (neighbor-count a)) - (array-storage-class a))) - -(define life-storage-class u1-storage-class) - -(define glider - (list*->array - 2 - '((0 0 0 0 0 0) - (0 0 1 0 0 0) - (0 0 0 1 0 0) - (0 1 1 1 0 0) - (0 0 0 0 0 0) - (0 0 0 0 0 0)) - life-storage-class)) - -(do ((i 0 (+ i 1)) - (pattern glider (advance pattern))) - ((= i 5)) - (pretty-print (array->list* pattern)) - (newline)) diff --git a/Task/Conways-Game-of-Life/Scheme/conways-game-of-life-1.scm b/Task/Conways-Game-of-Life/Scheme/conways-game-of-life.ss similarity index 100% rename from Task/Conways-Game-of-Life/Scheme/conways-game-of-life-1.scm rename to Task/Conways-Game-of-Life/Scheme/conways-game-of-life.ss diff --git a/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-1.sequencel b/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-1.sequencel index f4b1ca088b..3307c338b7 100644 --- a/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-1.sequencel +++ b/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-1.sequencel @@ -1,21 +1,21 @@ life(Cells(2))[I, J] := - let - numNeighbors := Cells[I-1,J-1] + Cells[I-1,J] + Cells[I-1,J+1] + - Cells[I,J-1] +/*current cell*/Cells[I,J+1] + - Cells[I+1,J-1] + Cells[I+1,J] + Cells[I+1,J+1]; - in - 0 when I=1 or J=1 or I=size(Cells) or J=size(Cells[I]) //On Border - else - 0 when numNeighbors < 2 or numNeighbors > 3 //Cell Dies - else - 1 when Cells[I,J] = 1 and numNeighbors = 2 or numNeighbors = 3 //Cell lives on or is born. - else - Cells[I,J]; //No Change - - + let + numNeighbors := Cells[I-1,J-1] + Cells[I-1,J] + Cells[I-1,J+1] + + Cells[I,J-1] +/*current cell*/Cells[I,J+1] + + Cells[I+1,J-1] + Cells[I+1,J] + Cells[I+1,J+1]; + in + 0 when I=1 or J=1 or I=size(Cells) or J=size(Cells[I]) //On Border + else + 0 when numNeighbors < 2 or numNeighbors > 3 //Cell Dies + else + 1 when Cells[I,J] = 1 and numNeighbors = 2 or numNeighbors = 3 //Cell lives on or is born. + else + Cells[I,J]; //No Change + + stressTestInput(n(0))[y,x] := - 0 when not y = n / 2 - else - 1 - foreach y within 1 ... n, - x within 1 ... n; + 0 when not y = n / 2 + else + 1 + foreach y within 1 ... n, + x within 1 ... n; diff --git a/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-2.sequencel b/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-2.sequencel index 54e33fabc0..5c10981d9f 100644 --- a/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-2.sequencel +++ b/Task/Conways-Game-of-Life/SequenceL/conways-game-of-life-2.sequencel @@ -17,150 +17,150 @@ std::string get_file_contents(const char*); int main(int argc, char ** argv) { - int cores = 0; - int maxSize = 700; + int cores = 0; + int maxSize = 700; - int drawSkip = 1; - int drawWait = 0; + int drawSkip = 1; + int drawWait = 0; - string inputFile = "test"; + string inputFile = "test"; - if(argc > 1) - { - inputFile = argv[1]; - } - if(argc > 2) - { - cores = atoi(argv[2]); - } + if(argc > 1) + { + inputFile = argv[1]; + } + if(argc > 2) + { + cores = atoi(argv[2]); + } - if(argc > 3) - { - maxSize = atoi(argv[3]); - } + if(argc > 3) + { + maxSize = atoi(argv[3]); + } - if(argc > 4) - { - drawSkip = atoi(argv[4]); + if(argc > 4) + { + drawSkip = atoi(argv[4]); - if(drawSkip < 0) - { - drawWait = abs(drawSkip); - drawSkip = 1; - } - } + if(drawSkip < 0) + { + drawWait = abs(drawSkip); + drawSkip = 1; + } + } - sl_init(cores); + sl_init(cores); - SLTimer drawTimer; + SLTimer drawTimer; - sprintf(titleBuffer, "Conway's Game of Life in SequenceL: %d Cores", cores); + sprintf(titleBuffer, "Conway's Game of Life in SequenceL: %d Cores", cores); - int width = 0; - int height = 0; + int width = 0; + int height = 0; - //Read input file-------------- - Sequence> initialGrid; + //Read input file-------------- + Sequence> initialGrid; - if(inputFile != "test") - { - stringstream ss(get_file_contents(inputFile.c_str())); - string stringItem; - vector elems; - char delim = ','; + if(inputFile != "test") + { + stringstream ss(get_file_contents(inputFile.c_str())); + string stringItem; + vector elems; + char delim = ','; - getline(ss, stringItem, delim); - width = atoi(stringItem.c_str()); - getline(ss, stringItem, delim); - height = atoi(stringItem.c_str()); + getline(ss, stringItem, delim); + width = atoi(stringItem.c_str()); + getline(ss, stringItem, delim); + height = atoi(stringItem.c_str()); - while(getline(ss, stringItem, delim)) - { - elems.push_back(atoi(stringItem.c_str())); - } + while(getline(ss, stringItem, delim)) + { + elems.push_back(atoi(stringItem.c_str())); + } - //Sequence Pointer Constructor---- - int gridDims[] = {height, width, 0}; - Sequence> tempGrid( (void*)&elems[0], gridDims); - initialGrid.hard_copy(tempGrid, 0); - //----------------------------- - } - else - { - width = maxSize; - height = maxSize; - sl_stressTestInput(maxSize, cores, initialGrid); - } - //-------- + //Sequence Pointer Constructor---- + int gridDims[] = {height, width, 0}; + Sequence> tempGrid( (void*)&elems[0], gridDims); + initialGrid.hard_copy(tempGrid, 0); + //----------------------------- + } + else + { + width = maxSize; + height = maxSize; + sl_stressTestInput(maxSize, cores, initialGrid); + } + //-------- - Sequence> result; + Sequence> result; - const unsigned char black[] = {0}; + const unsigned char black[] = {0}; - CImg visu(width * 4, height * 4, 1, 1, 0); - CImgDisplay draw_disp(visu, titleBuffer); - cout << "Conway's Game of Life in SequenceL" << endl << "Cores: " << cores << endl; + CImg visu(width * 4, height * 4, 1, 1, 0); + CImgDisplay draw_disp(visu, titleBuffer); + cout << "Conway's Game of Life in SequenceL" << endl << "Cores: " << cores << endl; - int generations = 0; - double compTime = 0; - double drawTime = 0; - SLTimer t; + int generations = 0; + double compTime = 0; + double drawTime = 0; + SLTimer t; - while(!draw_disp.is_closed()) - { - t.start(); - sl_life(initialGrid, cores, result); - generations++; - initialGrid.hard_copy(result, 0); - t.stop(); - compTime += t.getTime(); + while(!draw_disp.is_closed()) + { + t.start(); + sl_life(initialGrid, cores, result); + generations++; + initialGrid.hard_copy(result, 0); + t.stop(); + compTime += t.getTime(); - drawTimer.start(); + drawTimer.start(); - if(drawSkip > 0 && generations % drawSkip == 0) - { + if(drawSkip > 0 && generations % drawSkip == 0) + { - visu.fill(255); + visu.fill(255); - for(int i = 1; i <= result.size(); i++) - { - for(int j = 1; j <= result[i].size(); j++) - { - if(result[i][j] == 1) visu.draw_circle((j-1) * 4, (i - 1) * 4, 2, black, 1); - } - } + for(int i = 1; i <= result.size(); i++) + { + for(int j = 1; j <= result[i].size(); j++) + { + if(result[i][j] == 1) visu.draw_circle((j-1) * 4, (i - 1) * 4, 2, black, 1); + } + } - visu.display(draw_disp); + visu.display(draw_disp); - int drawWidth = maxSize; - int drawHeight = maxSize; + int drawWidth = maxSize; + int drawHeight = maxSize; - if(width < height) - { - drawWidth = ((double)drawHeight * ((double)width / (double)height)); - } - else - { - drawHeight = ((double)drawWidth * ((double)height / (double)width)); - } + if(width < height) + { + drawWidth = ((double)drawHeight * ((double)width / (double)height)); + } + else + { + drawHeight = ((double)drawWidth * ((double)height / (double)width)); + } - draw_disp.resize(drawWidth, drawHeight, false); + draw_disp.resize(drawWidth, drawHeight, false); - draw_disp.wait(drawWait); - drawTimer.stop(); - drawTime += drawTimer.getTime(); - } - } + draw_disp.wait(drawWait); + drawTimer.stop(); + drawTime += drawTimer.getTime(); + } + } - cout << "Total Generations: " << generations << endl; + cout << "Total Generations: " << generations << endl; - cout << "Average Compute Time: " << compTime / generations << " seconds" << endl; + cout << "Average Compute Time: " << compTime / generations << " seconds" << endl; - cout << "Average Draw Time: " << drawTime / generations << " seconds" << endl; + cout << "Average Draw Time: " << drawTime / generations << " seconds" << endl; - sl_done(); + sl_done(); - return 0; + return 0; } std::string get_file_contents(const char *filename) diff --git a/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-2.st b/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-2.st index 444c414241..2819d03b89 100644 --- a/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-2.st +++ b/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-2.st @@ -9,7 +9,7 @@ GameOfLife class>>withAliveCells: aCollectionOfCells ofSize: aBoardSize ^self new initializeWithAliveCells: aCollectionOfCells ofSize: aBoardSize GameOfLife class>>assertAll: aCollectionOfAliveCells areInside: aSize - | origin | + | origin | origin := 0@0. aCollectionOfAliveCells do: [:aCell | (aCell between: origin and: aSize) ifFalse: [ self error: 'Cell ', aCell printString,' out of range' ]] diff --git a/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-4.st b/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-4.st index aec636a5e2..dcdbda1181 100644 --- a/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-4.st +++ b/Task/Conways-Game-of-Life/Smalltalk/conways-game-of-life-4.st @@ -12,7 +12,7 @@ GameOfLifeView class>>openFor: aGameOfLife GameOfLifeView class>>blinker ^GameOfLife withAliveCells: { 4@2. 4@3. 4@4. 3@3. 4@3. 5@3 } ofSize: 10@10 - + GameOfLifeView class>>toad ^GameOfLife withAliveCells: { 2@4. 3@4. 4@4. 3@3. 4@3. 5@3 } ofSize: 10@10 @@ -20,7 +20,7 @@ GameOfLifeView class>>openBlinker ^self openFor: self blinker GameOfLifeView class>>openToad - ^self openFor: self toad + ^self openFor: self toad initializeFor: aGameOfLife game := aGameOfLife. diff --git a/Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua b/Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua deleted file mode 100644 index fe9d89fede..0000000000 --- a/Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua +++ /dev/null @@ -1,4 +0,0 @@ -Life ← ↥⊙↧∩=3⊃⋅∘⊙∘2⊸˜-/+≡↻♭₂-1⇡3_3⊸¤ -⁅×0.6 ≡₀⋅⚂ ↯⟜⊚ 50 # Init -⇌◌⍥(⟜⊂Life)300⟜¤ # Run -≡(▽⟜≡▽4) # Upscale diff --git a/Task/Conways-Game-of-Life/V-(Vlang)/conways-game-of-life.v b/Task/Conways-Game-of-Life/V-(Vlang)/conways-game-of-life.v index bb952499d4..5406961503 100644 --- a/Task/Conways-Game-of-Life/V-(Vlang)/conways-game-of-life.v +++ b/Task/Conways-Game-of-Life/V-(Vlang)/conways-game-of-life.v @@ -4,95 +4,95 @@ import time struct Field { mut: - s [][]bool - w int - h int + s [][]bool + w int + h int } fn new_field(w int, h int) Field { - s := [][]bool{len: h, init: []bool{len: w}} - return Field{s, w, h} + s := [][]bool{len: h, init: []bool{len: w}} + return Field{s, w, h} } fn (mut f Field) set(x int, y int, b bool) { - f.s[y][x] = b + f.s[y][x] = b } fn (f Field) next(x int, y int) bool { - mut on := 0 - for i := -1; i <= 1; i++ { - for j := -1; j <= 1; j++ { - if f.state(x+i, y+j) && !(j == 0 && i == 0) { - on++ - } - } - } - return on == 3 || (on == 2 && f.state(x, y)) + mut on := 0 + for i := -1; i <= 1; i++ { + for j := -1; j <= 1; j++ { + if f.state(x+i, y+j) && !(j == 0 && i == 0) { + on++ + } + } + } + return on == 3 || (on == 2 && f.state(x, y)) } fn (f Field) state(xx int, yy int) bool { - mut x, mut y := xx, yy - for y < 0 { - y += f.h - } - for x < 0 { - x += f.w - } - return f.s[y%f.h][x%f.w] + mut x, mut y := xx, yy + for y < 0 { + y += f.h + } + for x < 0 { + x += f.w + } + return f.s[y%f.h][x%f.w] } struct Life { mut: - w int - h int - a Field - b Field + w int + h int + a Field + b Field } fn new_life(w int, h int) Life { - mut a := new_field(w, h) - for _ in 0..(w * h / 2) { - a.set(rand.intn(w) or {0}, rand.intn(h) or {0}, true) - } - return Life{ - a: a, - b: new_field(w, h), - w: w - h: h, - } + mut a := new_field(w, h) + for _ in 0..(w * h / 2) { + a.set(rand.intn(w) or {0}, rand.intn(h) or {0}, true) + } + return Life{ + a: a, + b: new_field(w, h), + w: w + h: h, + } } fn (mut l Life) step() { - for y in 0..l.h { - for x in 0.. l.w { - l.b.set(x, y, l.a.next(x, y)) - } - } - l.a, l.b = l.b, l.a + for y in 0..l.h { + for x in 0.. l.w { + l.b.set(x, y, l.a.next(x, y)) + } + } + l.a, l.b = l.b, l.a } fn (l Life) str() string { - mut buf := strings.new_builder(128) - for y in 0..l.h { - for x in 0..l.w { - mut b := ' ' - if l.a.state(x, y) { - b = '*' - } - buf.write_string(b) - } - buf.write_string('\n') - } - return buf.str() + mut buf := strings.new_builder(128) + for y in 0..l.h { + for x in 0..l.w { + mut b := ' ' + if l.a.state(x, y) { + b = '*' + } + buf.write_string(b) + } + buf.write_string('\n') + } + return buf.str() } fn main() { - mut l := new_life(80, 15) - for i := 0; i < 300; i++ { - l.step() - //println("------------------------------------------------") - print('\x0c') - println(l) - time.sleep(time.second / 30) - } + mut l := new_life(80, 15) + for i := 0; i < 300; i++ { + l.step() + //println("------------------------------------------------") + print('\x0c') + println(l) + time.sleep(time.second / 30) + } } diff --git a/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-1.vb b/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-1.vb new file mode 100644 index 0000000000..3f97b566c7 --- /dev/null +++ b/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-1.vb @@ -0,0 +1,85 @@ +option explicit +const tlcr=3, tlcc=3 +const maxdim=15 + +dim a(15,15) +dim b(15,15) +dim ans0:ans0=chr(27)&"[" +dim gen,n + +erase a +'glider +a(0,1)=true:a(1,2)=true:a(2,0)=true:a(2,1)=true:a(2,2)=true +'blinker +a(3,13)=true:a(4,13)=true:a(5,13)=true +'beacon +a(11,1)=true:a(11,2)=true: a(12,1)=true:a(12,2)=true +a(13,3)=true:a(13,4)=true: a(14,3)=true:a(14,4)=true + +gen=0 +doframe + +do + display + wscript.sleep(100) + n=newgen +loop until n=0 +display + +sub cls() wscript.StdOut.Write ans0 &"2J"&ans0 &"?25l":end sub 'hide cursor too +sub toxy(r,c,s) wscript.StdOut.Write ans0 & r & ";" & c & "f" & s :end sub +function iif(a,b,c) if a then iif=b else iif=c end if :end function + +sub doframe + dim r,c,s + const frame="@" + cls + toxy 1,tlcc-1, "Conway's Game of Life" + toxy tlcr-1,tlcc-1,string(maxdim+3,frame) + s=frame&space(maxdim+1)&frame + for r=0 to maxdim + toxy tlcr+r,tlcc-1,s + next + toxy tlcr+maxdim+1,tlcc-1,string(maxdim+3,frame) +end sub + +sub display +dim r,c +const pix="#" +for r=0 to maxdim + for c=0 to maxdim + toxy tlcr+r,tlcc+c,iif (a(r,c),pix," ") + next +next +toxy tlcr+maxdim+2,tlcc-1,gen & " " & n +toxy tlcr+maxdim+3,tlcc-1,"" +gen=gen+1 +end sub + +function newgen + dim r,c,cnt,cp,cm,rp,rm + for r=0 to maxdim + for c=0 to maxdim + cp=(c+1) and maxdim 'wrap around + cm=(c-1) and maxdim + rp=(r+1) and maxdim + rm=(r-1) and maxdim + cnt=0 + cnt=- a(rp,cp) - a(rp,c) - a(rp,cm) 'true =-1 + cnt=cnt- a(r,cp)- a(r,cm) + cnt=cnt- a(rm,cp)- a(rm,c) - a(rm,cm) + + if a(r,c) then + b(r,c)=iif (cnt=2 or cnt=3,true,false) + else + b(r,c)=iif (cnt=3,true,false) + end if + next + next + for r=0 to maxdim + for c=0 to maxdim + a(r,c)=b(r,c) + newgen=newgen- b(r,c) + next + next +end function diff --git a/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-1.vbs b/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-1.vbs deleted file mode 100644 index 66315d235d..0000000000 --- a/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-1.vbs +++ /dev/null @@ -1,85 +0,0 @@ -option explicit -const tlcr=3, tlcc=3 -const maxdim=15 - -dim a(15,15) -dim b(15,15) -dim ans0:ans0=chr(27)&"[" -dim gen,n - -erase a -'glider -a(0,1)=true:a(1,2)=true:a(2,0)=true:a(2,1)=true:a(2,2)=true -'blinker -a(3,13)=true:a(4,13)=true:a(5,13)=true -'beacon -a(11,1)=true:a(11,2)=true: a(12,1)=true:a(12,2)=true -a(13,3)=true:a(13,4)=true: a(14,3)=true:a(14,4)=true - -gen=0 -doframe - -do - display - wscript.sleep(100) - n=newgen -loop until n=0 -display - -sub cls() wscript.StdOut.Write ans0 &"2J"&ans0 &"?25l":end sub 'hide cursor too -sub toxy(r,c,s) wscript.StdOut.Write ans0 & r & ";" & c & "f" & s :end sub -function iif(a,b,c) if a then iif=b else iif=c end if :end function - -sub doframe - dim r,c,s - const frame="@" - cls - toxy 1,tlcc-1, "Conway's Game of Life" - toxy tlcr-1,tlcc-1,string(maxdim+3,frame) - s=frame&space(maxdim+1)&frame - for r=0 to maxdim - toxy tlcr+r,tlcc-1,s - next - toxy tlcr+maxdim+1,tlcc-1,string(maxdim+3,frame) -end sub - -sub display -dim r,c -const pix="#" -for r=0 to maxdim - for c=0 to maxdim - toxy tlcr+r,tlcc+c,iif (a(r,c),pix," ") - next -next -toxy tlcr+maxdim+2,tlcc-1,gen & " " & n -toxy tlcr+maxdim+3,tlcc-1,"" -gen=gen+1 -end sub - -function newgen - dim r,c,cnt,cp,cm,rp,rm - for r=0 to maxdim - for c=0 to maxdim - cp=(c+1) and maxdim 'wrap around - cm=(c-1) and maxdim - rp=(r+1) and maxdim - rm=(r-1) and maxdim - cnt=0 - cnt=- a(rp,cp) - a(rp,c) - a(rp,cm) 'true =-1 - cnt=cnt- a(r,cp)- a(r,cm) - cnt=cnt- a(rm,cp)- a(rm,c) - a(rm,cm) - - if a(r,c) then - b(r,c)=iif (cnt=2 or cnt=3,true,false) - else - b(r,c)=iif (cnt=3,true,false) - end if - next - next - for r=0 to maxdim - for c=0 to maxdim - a(r,c)=b(r,c) - newgen=newgen- b(r,c) - next - next -end function diff --git a/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-2.vbs b/Task/Conways-Game-of-Life/VBScript/conways-game-of-life-2.vb similarity index 100% rename from Task/Conways-Game-of-Life/VBScript/conways-game-of-life-2.vbs rename to Task/Conways-Game-of-Life/VBScript/conways-game-of-life-2.vb diff --git a/Task/Conways-Game-of-Life/Vedit-macro-language/conways-game-of-life.vedit b/Task/Conways-Game-of-Life/Vedit-macro-language/conways-game-of-life.vedit index 069dd75cfb..c1f5784b3a 100644 --- a/Task/Conways-Game-of-Life/Vedit-macro-language/conways-game-of-life.vedit +++ b/Task/Conways-Game-of-Life/Vedit-macro-language/conways-game-of-life.vedit @@ -3,7 +3,7 @@ IT(".O.") IN IT(".O.") IN IT(".O.") -#9 = 2 // number of generations to calculate +#9 = 2 // number of generations to calculate #10 = Cur_Line #11 = Cur_Col-1 for (#2 = 1; #2 <= #9; #2++) { @@ -20,24 +20,24 @@ Return :calculate: Goto_Line(2) While (At_EOF == 0) { - Search("|A",ERRBREAK) // find next living cell + Search("|A",ERRBREAK) // find next living cell #3 = Cur_Line #4 = #7 = #8 = Cur_Col - if (#4 > 1) { // increment cell at left + if (#4 > 1) { // increment cell at left #7 = #4-1 Goto_Col(#7) Ins_Char(Cur_Char+1,OVERWRITE) } - if (#4 < #11) { // increment cell at right + if (#4 < #11) { // increment cell at right #8 = #4+1 Goto_Col(#8) Ins_Char(Cur_Char+1,OVERWRITE) } - if (#3 > 2) { // increment 3 cells above + if (#3 > 2) { // increment 3 cells above Goto_Line(#3-1) Call("inc_3") } - if (#3 < #10) { // increment 3 cells below + if (#3 < #10) { // increment 3 cells below Goto_Line(#3+1) Call("inc_3") } @@ -45,7 +45,7 @@ While (At_EOF == 0) { Goto_Col(#4+1) } -Replace("[1QR]", "O", REGEXP+BEGIN+ALL) // these cells alive +Replace("[1QR]", "O", REGEXP+BEGIN+ALL) // these cells alive Replace("[/-7P-X]", ".", REGEXP+BEGIN+ALL) // these cells dead Return diff --git a/Task/Conways-Game-of-Life/YAMLScript/conways-game-of-life.ys b/Task/Conways-Game-of-Life/YAMLScript/conways-game-of-life.ys deleted file mode 100644 index ae2f9357d5..0000000000 --- a/Task/Conways-Game-of-Life/YAMLScript/conways-game-of-life.ys +++ /dev/null @@ -1,42 +0,0 @@ -!YS-v0 - -glider =: \{[1 0] [2 1] [0 2] [1 2] [2 2]} -blinker =: \{[1 2] [2 2] [3 2]} - -defn main(): - game-of-life 10 40: glider - -defn game-of-life(size steps cells): - loop s steps, cells cells: - shell:: clear - print-world: cells size - sleep: 0.25 - when 0 < s: - recur s.--: step(cells) - -defn print-world: - (cells): - print-world: cells 10 - - (cells size): - each y (0 .. size): - row =: - join: - for x (0 .. size): - cells([x y]).if('* ' ' ') - say: "| $row|" - -defn step(cells): - set: - ? for [cell count] - neighborhood.mapcat(cells):frequencies - :when ((3 == count) || - ((2 == count) && - cell.in?(cells))) - : cell - -defn neighborhood([x y]): - ? for dx [-1 0 1] - dy [-1 0 1] - :when [dx dy].ne([0 0]) - : vector: (x + dx) (y + dy) diff --git a/Task/Conways-Game-of-Life/Zig/conways-game-of-life.zig b/Task/Conways-Game-of-Life/Zig/conways-game-of-life.zig deleted file mode 100644 index 524afe1ece..0000000000 --- a/Task/Conways-Game-of-Life/Zig/conways-game-of-life.zig +++ /dev/null @@ -1,85 +0,0 @@ -const std = @import("std"); -const mem = std.mem; - -pub fn main() !void { - // ---------------------------- pseudo random number generator - var prng = std.Random.DefaultPrng.init(blk: { - var seed: u64 = undefined; - std.posix.getrandom(mem.asBytes(&seed)) catch unreachable; - break :blk seed; - }); - const random = prng.random(); - // ---------------------------------------------------------- - const stdout = std.io.getStdOut(); - var bw = std.io.bufferedWriter(stdout.writer()); - const writer = bw.writer(); - // ---------------------------------------------------------- - var life = Life(80, 15).init(random); - for (0..300) |_| { - life.step(); - try writer.writeByte('\x0c'); - try writer.print("{}", .{life}); - try bw.flush(); - std.time.sleep(comptime (1_000_000_000 / 30)); // 1/30th second - } -} -fn Life(comptime w: usize, comptime h: usize) type { - return struct { - const Self = @This(); - a: Field(w, h), - b: Field(w, h), - - fn init(random: std.Random) Self { - var life = Self{ - .a = Field(w, h).init(), - .b = Field(w, h).init(), - }; - for (0..w * h / 2) |_| { - const x = random.uintLessThan(usize, w); - const y = random.uintLessThan(usize, h); - life.a.set(x, y, true); - } - return life; - } - fn step(self: *Self) void { - for (0..h) |y| - for (0..w) |x| - self.b.set(x, y, self.a.next(x, y)); - mem.swap(Field(w, h), &self.a, &self.b); - } - pub fn format(self: *const Self, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - for (0..h) |y| { - for (0..w) |x| - try writer.writeByte(if (self.a.state(x, y)) '*' else ' '); - try writer.writeByte('\n'); - } - } - }; -} -fn Field(comptime w: usize, comptime h: usize) type { - return struct { - const Self = @This(); - s: std.StaticBitSet(w * h), - - fn init() Self { - return .{ .s = std.StaticBitSet(w * h).initEmpty() }; - } - fn set(self: *Self, x: usize, y: usize, b: bool) void { - self.s.setValue(y * w + x, b); - } - fn next(self: *const Self, x_: usize, y_: usize) bool { - var on: usize = 0; - // Use wraparound arithmetic, i.e. -% - inline for ([3]usize{ x_ -% 1, x_, x_ + 1 }) |x| - inline for ([3]usize{ y_ -% 1, y_, y_ + 1 }) |y| - if (self.state(x, y)) { - on += 1; - }; - return on == 3 or on == 2 and self.state(x_, y_); - } - fn state(self: *const Self, x: usize, y: usize) bool { - if (x >= w or y >= h) return false; - return self.s.isSet(y * w + x); - } - }; -} diff --git a/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-1.zkl b/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-1.zkl index 73b0d9723d..da3f4350f4 100644 --- a/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-1.zkl +++ b/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-1.zkl @@ -3,7 +3,7 @@ class Life{ var N=n, cells=Data(n*n), tmp=Data(n*n), ds=T(T(-1,-1),T(-1,0),T(-1,1), T(0,-1),T(0,1), T(1,-1),T(1,0),T(1,1)); icells:=vm.arglist[1,*]; - (N*N).pump(Void,cells.append.fpM("1-",0)); // clear board + (N*N).pump(Void,cells.append.fpM("1-",0)); // clear board icells.pump(Void,Void.Read,fcn(row,col){ cells[row*N+col]=1 }); } fcn get(row,col){ diff --git a/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-2.zkl b/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-2.zkl index ca7561ab4d..7d59e7b5c2 100644 --- a/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-2.zkl +++ b/Task/Conways-Game-of-Life/Zkl/conways-game-of-life-2.zkl @@ -1,4 +1,4 @@ -cells:=Life(4, 0,1, 1,1, 2,1); // blinker +cells:=Life(4, 0,1, 1,1, 2,1); // blinker do(3){ cells.println("="*4); cells.cycle(); } cells:=Life(30, 0,1, 1,2, 2,0, 2,1, 2,2); // glider diff --git a/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000 b/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000 index 10041191cb..7f91645c39 100644 --- a/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000 +++ b/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000 @@ -7,7 +7,10 @@ LEA myString,A3 LEA StringRam,A4 CopyString: -MOVE.B (A3)+,(A4)+ ;Copy one byte. -BNE CopyString ;Not zero, do more bytes. +MOVE.B (A3)+,D0 +MOVE.B D0,(A4)+ ;we could have used "MOVE.B (A3)+,(A4)+" but this makes it easier to check for the terminator. +BEQ Terminated +BRA CopyString +Terminated: ;the null terminator is already stored along with the string itself, so we are done. ;program ends here. diff --git a/Task/Copy-a-string/ALGOL-W/copy-a-string.alg b/Task/Copy-a-string/ALGOL-W/copy-a-string.alg new file mode 100644 index 0000000000..24bae16956 --- /dev/null +++ b/Task/Copy-a-string/ALGOL-W/copy-a-string.alg @@ -0,0 +1,9 @@ +begin + % strings are (fixed length) values in algol W. Assignment makes a copy % + string(10) a, copyOfA; + a := "some text"; + copyOfA := a; + % assignment to a will not change copyOfA % + a := "new value"; + write( a, copyOfA ) +end. diff --git a/Task/Copy-a-string/Ada/copy-a-string-1.adb b/Task/Copy-a-string/Ada/copy-a-string-1.ada similarity index 100% rename from Task/Copy-a-string/Ada/copy-a-string-1.adb rename to Task/Copy-a-string/Ada/copy-a-string-1.ada diff --git a/Task/Copy-a-string/Ada/copy-a-string-2.adb b/Task/Copy-a-string/Ada/copy-a-string-2.ada similarity index 100% rename from Task/Copy-a-string/Ada/copy-a-string-2.adb rename to Task/Copy-a-string/Ada/copy-a-string-2.ada diff --git a/Task/Copy-a-string/Ada/copy-a-string-3.adb b/Task/Copy-a-string/Ada/copy-a-string-3.ada similarity index 100% rename from Task/Copy-a-string/Ada/copy-a-string-3.adb rename to Task/Copy-a-string/Ada/copy-a-string-3.ada diff --git a/Task/Copy-a-string/Ada/copy-a-string-4.adb b/Task/Copy-a-string/Ada/copy-a-string-4.ada similarity index 100% rename from Task/Copy-a-string/Ada/copy-a-string-4.adb rename to Task/Copy-a-string/Ada/copy-a-string-4.ada diff --git a/Task/Copy-a-string/ArkScript/copy-a-string.ark b/Task/Copy-a-string/ArkScript/copy-a-string.ark deleted file mode 100644 index 4ceafe0b2d..0000000000 --- a/Task/Copy-a-string/ArkScript/copy-a-string.ark +++ /dev/null @@ -1,7 +0,0 @@ -(mut str "hello world") -(mut copy str) - -(set copy "clone destroyed") - -(print str) -(print copy) diff --git a/Task/Copy-a-string/Arturo/copy-a-string.arturo b/Task/Copy-a-string/Arturo/copy-a-string.arturo index 0001140d7d..41cb6efd44 100644 --- a/Task/Copy-a-string/Arturo/copy-a-string.arturo +++ b/Task/Copy-a-string/Arturo/copy-a-string.arturo @@ -1,4 +1,4 @@ -a: "Hello" +a: new "Hello" b: a ; reference the same string ; changing one string in-place diff --git a/Task/Copy-a-string/AutoIt/copy-a-string.au3 b/Task/Copy-a-string/AutoIt/copy-a-string.autoit similarity index 100% rename from Task/Copy-a-string/AutoIt/copy-a-string.au3 rename to Task/Copy-a-string/AutoIt/copy-a-string.autoit diff --git a/Task/Copy-a-string/Applesoft-BASIC/copy-a-string-4.basic b/Task/Copy-a-string/BaCon/copy-a-string-1.bacon similarity index 100% rename from Task/Copy-a-string/Applesoft-BASIC/copy-a-string-4.basic rename to Task/Copy-a-string/BaCon/copy-a-string-1.bacon diff --git a/Task/Copy-a-string/Applesoft-BASIC/copy-a-string-5.basic b/Task/Copy-a-string/BaCon/copy-a-string-2.bacon similarity index 100% rename from Task/Copy-a-string/Applesoft-BASIC/copy-a-string-5.basic rename to Task/Copy-a-string/BaCon/copy-a-string-2.bacon diff --git a/Task/Copy-a-string/Ballerina/copy-a-string.ballerina b/Task/Copy-a-string/Ballerina/copy-a-string.ballerina deleted file mode 100644 index ed5f916660..0000000000 --- a/Task/Copy-a-string/Ballerina/copy-a-string.ballerina +++ /dev/null @@ -1,7 +0,0 @@ -import ballerina/io; - -public function main() { - string s = "ballerina"; - string t = s; - io:println(`Are s and t equal? ${t == s}`); -} diff --git a/Task/Copy-a-string/COBOL/copy-a-string.cob b/Task/Copy-a-string/COBOL/copy-a-string.cobol similarity index 100% rename from Task/Copy-a-string/COBOL/copy-a-string.cob rename to Task/Copy-a-string/COBOL/copy-a-string.cobol diff --git a/Task/Copy-a-string/Crystal/copy-a-string.cr b/Task/Copy-a-string/Crystal/copy-a-string.crystal similarity index 100% rename from Task/Copy-a-string/Crystal/copy-a-string.cr rename to Task/Copy-a-string/Crystal/copy-a-string.crystal diff --git a/Task/Copy-a-string/Delphi/copy-a-string.pas b/Task/Copy-a-string/Delphi/copy-a-string.delphi similarity index 100% rename from Task/Copy-a-string/Delphi/copy-a-string.pas rename to Task/Copy-a-string/Delphi/copy-a-string.delphi diff --git a/Task/Copy-a-string/DuckDB/copy-a-string.duckdb b/Task/Copy-a-string/DuckDB/copy-a-string.duckdb deleted file mode 100644 index b039bd2ade..0000000000 --- a/Task/Copy-a-string/DuckDB/copy-a-string.duckdb +++ /dev/null @@ -1,40 +0,0 @@ -D create or replace table t as (select 'This is a string' as s); - -D from t; -┌──────────────────┐ -│ s │ -│ varchar │ -├──────────────────┤ -│ This is a string │ -└──────────────────┘ - -# Now make two copies. -D create or replace table tt as (select s as s1, s as s2 from t); - -D from tt; -┌──────────────────┬──────────────────┐ -│ s1 │ s2 │ -│ varchar │ varchar │ -├──────────────────┼──────────────────┤ -│ This is a string │ This is a string │ -└──────────────────┴──────────────────┘ - -# Change s2 and then verify that s1 is unaltered -D UPDATE tt SET s2 = s2[1]; - -D from tt; -┌──────────────────┬─────────┐ -│ s1 │ s2 │ -│ varchar │ varchar │ -├──────────────────┼─────────┤ -│ This is a string │ T │ -└──────────────────┴─────────┘ - -# Check that s and s1 are also still equal -D select s = s1 from t positional join tt; -┌──────────┐ -│ (s = s1) │ -│ boolean │ -├──────────┤ -│ true │ -└──────────┘ diff --git a/Task/Copy-a-string/EMal/copy-a-string.emal b/Task/Copy-a-string/EMal/copy-a-string.emal index 81e78bf2e8..c7d403d343 100644 --- a/Task/Copy-a-string/EMal/copy-a-string.emal +++ b/Task/Copy-a-string/EMal/copy-a-string.emal @@ -1,10 +1,11 @@ -^|in EMal strings are mutable|^ -text original ← "Yellow world" -text ref ← original # copying the reference -text copied ← *original # copying the content -original[0] ← "H" # texts are indexable and mutable -original[5] ← "," +text original = "Yellow world" +text ref = original # copying the reference +text copied = *original # copying the content +original[0] = "H" # texts are indexable and mutable +original[5] = "," ref.append("!") # texts are coercible and growable copied += "?" -writeLine(original æ ref and original æ "Hello, world!") -writeLine(copied æ "Yellow world?") +^| + | original == ref == "Hello, world!" + | copied == "Yellow world?" + |^ diff --git a/Task/Copy-a-string/EasyLang/copy-a-string.easy b/Task/Copy-a-string/EasyLang/copy-a-string.easy index 17fa4c005b..cdd6ff5789 100644 --- a/Task/Copy-a-string/EasyLang/copy-a-string.easy +++ b/Task/Copy-a-string/EasyLang/copy-a-string.easy @@ -1,5 +1,2 @@ a$ = "hello" b$ = a$ -a$ &= " a" -print a$ -print b$ diff --git a/Task/Copy-a-string/Ed/copy-a-string.ed b/Task/Copy-a-string/Ed/copy-a-string.ed deleted file mode 100644 index a2732d422d..0000000000 --- a/Task/Copy-a-string/Ed/copy-a-string.ed +++ /dev/null @@ -1 +0,0 @@ -,t diff --git a/Task/Copy-a-string/Elixir/copy-a-string.ex b/Task/Copy-a-string/Elixir/copy-a-string.elixir similarity index 100% rename from Task/Copy-a-string/Elixir/copy-a-string.ex rename to Task/Copy-a-string/Elixir/copy-a-string.elixir diff --git a/Task/Copy-a-string/Emacs-Lisp/copy-a-string.el b/Task/Copy-a-string/Emacs-Lisp/copy-a-string.l similarity index 100% rename from Task/Copy-a-string/Emacs-Lisp/copy-a-string.el rename to Task/Copy-a-string/Emacs-Lisp/copy-a-string.l diff --git a/Task/Copy-a-string/Euphoria/copy-a-string.eu b/Task/Copy-a-string/Euphoria/copy-a-string.euphoria similarity index 100% rename from Task/Copy-a-string/Euphoria/copy-a-string.eu rename to Task/Copy-a-string/Euphoria/copy-a-string.euphoria diff --git a/Task/Copy-a-string/Extended-Color-BASIC/copy-a-string.basic b/Task/Copy-a-string/Extended-Color-BASIC/copy-a-string.basic deleted file mode 100644 index 5f6527cb7a..0000000000 --- a/Task/Copy-a-string/Extended-Color-BASIC/copy-a-string.basic +++ /dev/null @@ -1,7 +0,0 @@ -10 A$ = "HELLO" -20 REM COPY CONTENTS OF A$ TO B$ -30 B$ = A$ -40 REM CHANGE CONTENTS OF A$ -50 A$ = "WORLD" -60 REM DISPLAY CONTENTS -70 PRINT A$, B$ diff --git a/Task/Copy-a-string/Gleam/copy-a-string.gleam b/Task/Copy-a-string/Gleam/copy-a-string.gleam deleted file mode 100644 index cfe412774e..0000000000 --- a/Task/Copy-a-string/Gleam/copy-a-string.gleam +++ /dev/null @@ -1,2 +0,0 @@ -let src = "Hello" -let dest = src diff --git a/Task/Copy-a-string/Julia/copy-a-string.jl b/Task/Copy-a-string/Julia/copy-a-string.julia similarity index 100% rename from Task/Copy-a-string/Julia/copy-a-string.jl rename to Task/Copy-a-string/Julia/copy-a-string.julia diff --git a/Task/Copy-a-string/Kotlin/copy-a-string.kts b/Task/Copy-a-string/Kotlin/copy-a-string.kotlin similarity index 100% rename from Task/Copy-a-string/Kotlin/copy-a-string.kts rename to Task/Copy-a-string/Kotlin/copy-a-string.kotlin diff --git a/Task/Copy-a-string/LOLCODE/copy-a-string.lol b/Task/Copy-a-string/LOLCODE/copy-a-string.lol deleted file mode 100644 index eaa7cf013b..0000000000 --- a/Task/Copy-a-string/LOLCODE/copy-a-string.lol +++ /dev/null @@ -1,10 +0,0 @@ -HAI 1.3 - - I HAS A FRANK ITZ "Hello," - I HAS A PAUL ITZ "World!" - VISIBLE FRANK " " PAUL - - FRANK R PAUL - VISIBLE FRANK " " PAUL - -KTHXBYE diff --git a/Task/Copy-a-string/OCaml/copy-a-string-1.ml b/Task/Copy-a-string/OCaml/copy-a-string-1.ocaml similarity index 100% rename from Task/Copy-a-string/OCaml/copy-a-string-1.ml rename to Task/Copy-a-string/OCaml/copy-a-string-1.ocaml diff --git a/Task/Copy-a-string/OCaml/copy-a-string-2.ml b/Task/Copy-a-string/OCaml/copy-a-string-2.ocaml similarity index 100% rename from Task/Copy-a-string/OCaml/copy-a-string-2.ml rename to Task/Copy-a-string/OCaml/copy-a-string-2.ocaml diff --git a/Task/Copy-a-string/OCaml/copy-a-string-3.ml b/Task/Copy-a-string/OCaml/copy-a-string-3.ocaml similarity index 100% rename from Task/Copy-a-string/OCaml/copy-a-string-3.ml rename to Task/Copy-a-string/OCaml/copy-a-string-3.ocaml diff --git a/Task/Copy-a-string/OCaml/copy-a-string-4.ml b/Task/Copy-a-string/OCaml/copy-a-string-4.ocaml similarity index 100% rename from Task/Copy-a-string/OCaml/copy-a-string-4.ml rename to Task/Copy-a-string/OCaml/copy-a-string-4.ocaml diff --git a/Task/Copy-a-string/OPL/copy-a-string.opl b/Task/Copy-a-string/OPL/copy-a-string.opl deleted file mode 100644 index db34e40a63..0000000000 --- a/Task/Copy-a-string/OPL/copy-a-string.opl +++ /dev/null @@ -1,8 +0,0 @@ -PROC main: - LOCAL src$(6),dst$(5) - src$="Hello" - dst$=src$ - src$="world!" - PRINT dst$,src$ - GET -ENDP diff --git a/Task/Copy-a-string/Oberon/copy-a-string.oberon b/Task/Copy-a-string/Oberon-2/copy-a-string.oberon similarity index 100% rename from Task/Copy-a-string/Oberon/copy-a-string.oberon rename to Task/Copy-a-string/Oberon-2/copy-a-string.oberon diff --git a/Task/Copy-a-string/Pascal/copy-a-string.pas b/Task/Copy-a-string/Pascal/copy-a-string.pas index 6fc5be060c..90fe98f704 100644 --- a/Task/Copy-a-string/Pascal/copy-a-string.pas +++ b/Task/Copy-a-string/Pascal/copy-a-string.pas @@ -1,16 +1,28 @@ -program copyAString; - var - { The Extended Pascal `string` schema data type - is essentially a `packed array[1..capacity] of char`. } - source, destination: string(80); - begin - source := 'Hello world!'; - { In Pascal _whole_ array data type values can be copied by assignment. } - destination := source; - { Provided `source` is a _non-empty_ string value - you can copy in Extended Pascal sub-ranges _of_ _string_ types, too. - Note, the sub-range notation is not permitted for a `bindable` data type. } - destination := source[1..length(source)]; - { You can also employ Extended Pascal’s `writeStr` routine: } - writeStr(destination, source); - end. +program in,out; + +type + + pString = ^string; + +var + + s1,s2 : string ; + pStr : pString ; + +begin + + /* direct copy */ + s1 := 'Now is the time for all good men to come to the aid of their party.' + s2 := s1 ; + + writeln(s1); + writeln(s2); + + /* By Reference */ + pStr := @s1 ; + writeln(pStr^); + + pStr := @s2 ; + writeln(pStr^); + +end; diff --git a/Task/Copy-a-string/PascalABC.NET/copy-a-string.pas b/Task/Copy-a-string/PascalABC.NET/copy-a-string.pas deleted file mode 100644 index 92afc0925c..0000000000 --- a/Task/Copy-a-string/PascalABC.NET/copy-a-string.pas +++ /dev/null @@ -1,4 +0,0 @@ -begin - var s: string := 'Hello'; - var s1 := s; -end. diff --git a/Task/Copy-a-string/PowerShell/copy-a-string-1.ps1 b/Task/Copy-a-string/PowerShell/copy-a-string-1.psh similarity index 100% rename from Task/Copy-a-string/PowerShell/copy-a-string-1.ps1 rename to Task/Copy-a-string/PowerShell/copy-a-string-1.psh diff --git a/Task/Copy-a-string/PowerShell/copy-a-string-2.ps1 b/Task/Copy-a-string/PowerShell/copy-a-string-2.psh similarity index 100% rename from Task/Copy-a-string/PowerShell/copy-a-string-2.ps1 rename to Task/Copy-a-string/PowerShell/copy-a-string-2.psh diff --git a/Task/Copy-a-string/Rebol/copy-a-string.rebol b/Task/Copy-a-string/REBOL/copy-a-string.rebol similarity index 98% rename from Task/Copy-a-string/Rebol/copy-a-string.rebol rename to Task/Copy-a-string/REBOL/copy-a-string.rebol index 02d96fc778..07ad9d7e8b 100644 --- a/Task/Copy-a-string/Rebol/copy-a-string.rebol +++ b/Task/Copy-a-string/REBOL/copy-a-string.rebol @@ -1,4 +1,4 @@ -Rebol [ +REBOL [ Title: "String Copy" URL: http://rosettacode.org/wiki/Copy_a_string ] diff --git a/Task/Copy-a-string/REXX/copy-a-string.rexx b/Task/Copy-a-string/REXX/copy-a-string.rexx index 9db0cf1336..6d7223de5c 100644 --- a/Task/Copy-a-string/REXX/copy-a-string.rexx +++ b/Task/Copy-a-string/REXX/copy-a-string.rexx @@ -1,16 +1,2 @@ --- 8 Nov 2025 -include Setting - -say 'COPY A STRING' -say version -say -say 'Just assign the string variable to a new one.' -a='This is a string.' -b=a -say a b -c="This is also a string." -d=c -say d c -exit - -include Abend +src = "this is a string" +dst = src diff --git a/Task/Copy-a-string/Rust/copy-a-string-1.rs b/Task/Copy-a-string/Rust/copy-a-string-1.rust similarity index 100% rename from Task/Copy-a-string/Rust/copy-a-string-1.rs rename to Task/Copy-a-string/Rust/copy-a-string-1.rust diff --git a/Task/Copy-a-string/Rust/copy-a-string-2.rs b/Task/Copy-a-string/Rust/copy-a-string-2.rust similarity index 100% rename from Task/Copy-a-string/Rust/copy-a-string-2.rs rename to Task/Copy-a-string/Rust/copy-a-string-2.rust diff --git a/Task/Copy-a-string/Rye/copy-a-string.rye b/Task/Copy-a-string/Rye/copy-a-string.rye deleted file mode 100644 index 39ec8eac96..0000000000 --- a/Task/Copy-a-string/Rye/copy-a-string.rye +++ /dev/null @@ -1,8 +0,0 @@ -str:: "Hello" -;Returns [String: Hello] -str2:: str -;Returns [String: Hello] -str:: "World" -;Returns [String: World] -str2 -;Returns [String: Hello] diff --git a/Task/Copy-a-string/S-BASIC/copy-a-string.basic b/Task/Copy-a-string/S-BASIC/copy-a-string.basic deleted file mode 100644 index 81d04da265..0000000000 --- a/Task/Copy-a-string/S-BASIC/copy-a-string.basic +++ /dev/null @@ -1,23 +0,0 @@ -var original, copy = string -based referenced = string -var strloc = integer - -rem - position referenced string on top of original string -location var strloc = original -base referenced at strloc - -original = "Hello, World" -copy = original - -print "Original : ", original -print "Copy : ", copy -print "Referenced: ", referenced -print - -original = "Goodbye, World" - -print "Original : ", original rem - changed -print "Copy : ", copy rem - unchanged -print "Referenced: ", referenced rem - changed - -end diff --git a/Task/Copy-a-string/Scheme/copy-a-string.scm b/Task/Copy-a-string/Scheme/copy-a-string.ss similarity index 100% rename from Task/Copy-a-string/Scheme/copy-a-string.scm rename to Task/Copy-a-string/Scheme/copy-a-string.ss diff --git a/Task/Copy-a-string/TAV/copy-a-string.tav b/Task/Copy-a-string/TAV/copy-a-string.tav deleted file mode 100644 index c885d727e1..0000000000 --- a/Task/Copy-a-string/TAV/copy-a-string.tav +++ /dev/null @@ -1,6 +0,0 @@ - s =: "hello" - print s.Usecount - t =: s \ reference copy - print s.Usecount - u =: string (s _ 'x') clip upto -2 - print (quote u), u.Usecount, s.Usecount diff --git a/Task/Copy-a-string/Tcl/copy-a-string-2.tcl b/Task/Copy-a-string/Tcl/copy-a-string-2.tcl deleted file mode 100644 index 2b6c1980c5..0000000000 --- a/Task/Copy-a-string/Tcl/copy-a-string-2.tcl +++ /dev/null @@ -1,28 +0,0 @@ -set A "a string" - -set B $A ; # B is a reference to the string - -Set C "$A" ; # a new string is created - -set D "This is $C" ; # the string bound to C is copied into a new string. - - -# the append command is internally optimized -# for adding to the end of a string or list -# as is string index for returning a letter - -# reverse a string -proc reverse {s} { - set len [string length $s] - set r "" - for { set i $len} { $i >= 0} {incr i -1} { - append r [string index $s $i] - } - return $r -} - -set a 12345 - -set b [reverse $a] - -puts stdout "b: $b" diff --git a/Task/Copy-a-string/Tcl/copy-a-string-3.tcl b/Task/Copy-a-string/Tcl/copy-a-string-3.tcl deleted file mode 100644 index cfbdcf9402..0000000000 --- a/Task/Copy-a-string/Tcl/copy-a-string-3.tcl +++ /dev/null @@ -1,4 +0,0 @@ -# replace substrings in a string - -set rep [string map {"apple" "orange"} "I like apples."] -puts stdout $rep diff --git a/Task/Copy-a-string/Tcl/copy-a-string-1.tcl b/Task/Copy-a-string/Tcl/copy-a-string.tcl similarity index 100% rename from Task/Copy-a-string/Tcl/copy-a-string-1.tcl rename to Task/Copy-a-string/Tcl/copy-a-string.tcl diff --git a/Task/Copy-a-string/Uiua/copy-a-string.uiua b/Task/Copy-a-string/Uiua/copy-a-string.uiua deleted file mode 100644 index be6db2389c..0000000000 --- a/Task/Copy-a-string/Uiua/copy-a-string.uiua +++ /dev/null @@ -1,2 +0,0 @@ -."hello" -first diff --git a/Task/Copy-a-string/Uxntal/copy-a-string.uxnatl b/Task/Copy-a-string/Uxntal/copy-a-string.uxnatl deleted file mode 100644 index 0b7adb7b1a..0000000000 --- a/Task/Copy-a-string/Uxntal/copy-a-string.uxnatl +++ /dev/null @@ -1,25 +0,0 @@ -%\n { 0a } %\0 { 00 } - -|18 @Console/write - -|100 - -;str2 ;str1 copy-str -;str2 print-str - -BRK - -@copy/str ( dest* src* -: ) - STH2 - &loop - LDAkr STH2k STAr INC2 LDAkr STHr INC2r ?/loop - POP2 POP2r - JMP2r - -@print/str_ ( str* -: ) - LDAk .Console/write DEO - INC2 @print/str LDAk ?/str_ - POP2 JMP2r - -@str1 "Uxntal \n \0 -@str2 diff --git a/Task/Copy-stdin-to-stdout/Ada/copy-stdin-to-stdout.adb b/Task/Copy-stdin-to-stdout/Ada/copy-stdin-to-stdout.ada similarity index 100% rename from Task/Copy-stdin-to-stdout/Ada/copy-stdin-to-stdout.adb rename to Task/Copy-stdin-to-stdout/Ada/copy-stdin-to-stdout.ada diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-1.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-1.bat deleted file mode 100644 index c395545bf5..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-1.bat +++ /dev/null @@ -1 +0,0 @@ -findstr ^^ diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-2.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-2.bat deleted file mode 100644 index 4993fe87a3..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-2.bat +++ /dev/null @@ -1 +0,0 @@ -findstr "^" diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-3.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-3.bat deleted file mode 100644 index b4d82224f4..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-3.bat +++ /dev/null @@ -1 +0,0 @@ -findstr $ diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-4.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-4.bat deleted file mode 100644 index e45275e17e..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-4.bat +++ /dev/null @@ -1 +0,0 @@ -find/v "" diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-5.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-5.bat deleted file mode 100644 index ef49dd86a6..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-5.bat +++ /dev/null @@ -1 +0,0 @@ -more diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-6.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-6.bat deleted file mode 100644 index 6482121afa..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-6.bat +++ /dev/null @@ -1 +0,0 @@ -copy con[:] con[:] diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-7.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-7.bat deleted file mode 100644 index bd13d6aad4..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-7.bat +++ /dev/null @@ -1 +0,0 @@ -type con[:] diff --git a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-8.bat b/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-8.bat deleted file mode 100644 index 2cc3128981..0000000000 --- a/Task/Copy-stdin-to-stdout/Batch-File/copy-stdin-to-stdout-8.bat +++ /dev/null @@ -1,2 +0,0 @@ -@setlocal enabledelayedexpansion -@ -int main() { - int c; - while ((c = getchar()) != EOF) { +int main(){ + char c; + while ( (c=getchar()) != EOF ){ putchar(c); } return 0; diff --git a/Task/Copy-stdin-to-stdout/Crystal/copy-stdin-to-stdout.cr b/Task/Copy-stdin-to-stdout/Crystal/copy-stdin-to-stdout.crystal similarity index 100% rename from Task/Copy-stdin-to-stdout/Crystal/copy-stdin-to-stdout.cr rename to Task/Copy-stdin-to-stdout/Crystal/copy-stdin-to-stdout.crystal diff --git a/Task/Copy-stdin-to-stdout/Fortran/copy-stdin-to-stdout-1.f b/Task/Copy-stdin-to-stdout/Fortran/copy-stdin-to-stdout-1.f deleted file mode 100644 index 892373388e..0000000000 --- a/Task/Copy-stdin-to-stdout/Fortran/copy-stdin-to-stdout-1.f +++ /dev/null @@ -1,20 +0,0 @@ -! Copy stdin to stdout -! tested with GNU Fortran (Ubuntu 15.2.0-4ubuntu4) 15.2.0 on Kubuntu 25.10 -! uses non-standard function fget and gput, both are available in gfortran only. -! ------------------------------------------------------------------------------------------ -! -program cp - -implicit none - -character :: c ! The chcaracter to read -integer :: ios ! IO Status - - -do - ios = fget (c) ! gfortran only - if (ios .ne. 0) exit - call fput(c) ! gfortran only -end do - -end program cp diff --git a/Task/Copy-stdin-to-stdout/Fortran/copy-stdin-to-stdout-2.f b/Task/Copy-stdin-to-stdout/Fortran/copy-stdin-to-stdout-2.f deleted file mode 100644 index 8a0d0d80df..0000000000 --- a/Task/Copy-stdin-to-stdout/Fortran/copy-stdin-to-stdout-2.f +++ /dev/null @@ -1,20 +0,0 @@ -! Copy stdin to stdout -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.10 -! -! can also be compiled with gfortran but fails at run-time because it cannot change the access parameter -! ------------------------------------------------------------------------------------------------------- -! -program cp -character :: c -integer:: ios - -open (unit=5, form='unformatted', access='stream', action ='read') -open (unit=6, form='unformatted', access='stream', action ='write') - -do - read (5, iostat=ios) c - if (ios .ne. 0) exit - write (6) c -end do - -end program cp diff --git a/Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic b/Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic deleted file mode 100644 index 277e5331b6..0000000000 --- a/Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic +++ /dev/null @@ -1,13 +0,0 @@ -// Create file handles for standard input and output -FileHandleRef stdIn = fn FileHandleWithStandardInput -FileHandleRef stdOut = fn FileHandleWithStandardOutput - -// Continuously read from standard input… -while (YES) - CFDataRef availableData = fn FileHandleAvailableData( stdIn ) - if ( fn DataLength( availableData ) == 0 ) - break // End of input - end if - // … and write to standard output - fn FileHandleWriteData( stdOut, availableData, NULL ) -wend diff --git a/Task/Copy-stdin-to-stdout/Icon/copy-stdin-to-stdout.icon b/Task/Copy-stdin-to-stdout/Icon/copy-stdin-to-stdout.icon deleted file mode 100644 index ceec19034b..0000000000 --- a/Task/Copy-stdin-to-stdout/Icon/copy-stdin-to-stdout.icon +++ /dev/null @@ -1,3 +0,0 @@ -procedure main() - every write(!&input) -end diff --git a/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java b/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java deleted file mode 100644 index df4b2adbe3..0000000000 --- a/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java +++ /dev/null @@ -1,5 +0,0 @@ -public class CopyStdinToStdout { - public static void main(String[] args) throws java.io.IOException { - System.in.transferTo(System.out); - } -} diff --git a/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-1.java b/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout.java similarity index 100% rename from Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-1.java rename to Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout.java diff --git a/Task/Copy-stdin-to-stdout/Julia/copy-stdin-to-stdout.jl b/Task/Copy-stdin-to-stdout/Julia/copy-stdin-to-stdout.julia similarity index 100% rename from Task/Copy-stdin-to-stdout/Julia/copy-stdin-to-stdout.jl rename to Task/Copy-stdin-to-stdout/Julia/copy-stdin-to-stdout.julia diff --git a/Task/Copy-stdin-to-stdout/Kotlin/copy-stdin-to-stdout.kts b/Task/Copy-stdin-to-stdout/Kotlin/copy-stdin-to-stdout.kotlin similarity index 100% rename from Task/Copy-stdin-to-stdout/Kotlin/copy-stdin-to-stdout.kts rename to Task/Copy-stdin-to-stdout/Kotlin/copy-stdin-to-stdout.kotlin diff --git a/Task/Copy-stdin-to-stdout/OCaml/copy-stdin-to-stdout.ml b/Task/Copy-stdin-to-stdout/OCaml/copy-stdin-to-stdout.ocaml similarity index 100% rename from Task/Copy-stdin-to-stdout/OCaml/copy-stdin-to-stdout.ml rename to Task/Copy-stdin-to-stdout/OCaml/copy-stdin-to-stdout.ocaml diff --git a/Task/Copy-stdin-to-stdout/Oberon-07/copy-stdin-to-stdout.oberon b/Task/Copy-stdin-to-stdout/Oberon-07/copy-stdin-to-stdout.oberon deleted file mode 100644 index 32bc3ee1b1..0000000000 --- a/Task/Copy-stdin-to-stdout/Oberon-07/copy-stdin-to-stdout.oberon +++ /dev/null @@ -1,10 +0,0 @@ -MODULE CopyStdinToStdout; - IMPORT In, Out; - VAR c : CHAR; -BEGIN - In.Char( c ); - WHILE In.Done DO - Out.Char( c ); - In.Char( c ) - END -END CopyStdinToStdout. diff --git a/Task/Copy-stdin-to-stdout/Objeck/copy-stdin-to-stdout.objeck b/Task/Copy-stdin-to-stdout/Objeck/copy-stdin-to-stdout.objeck deleted file mode 100644 index 05e460ff31..0000000000 --- a/Task/Copy-stdin-to-stdout/Objeck/copy-stdin-to-stdout.objeck +++ /dev/null @@ -1,9 +0,0 @@ -class StdInToOut { - function : Main(args : String[]) ~ Nil { - do { - input := System.IO.Console->ReadLine(); - System.IO.Console->PrintLine(input); - } - while(<>input->IsEmpty()); - } -} diff --git a/Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas b/Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas deleted file mode 100644 index 1b297471d0..0000000000 --- a/Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas +++ /dev/null @@ -1,2 +0,0 @@ -## -Console.OpenStandardInput().CopyTo(Console.OpenStandardOutput()); diff --git a/Task/Copy-stdin-to-stdout/Phix/copy-stdin-to-stdout.phix b/Task/Copy-stdin-to-stdout/Phix/copy-stdin-to-stdout.phix index f1b2eaf38c..6d08a056ab 100644 --- a/Task/Copy-stdin-to-stdout/Phix/copy-stdin-to-stdout.phix +++ b/Task/Copy-stdin-to-stdout/Phix/copy-stdin-to-stdout.phix @@ -1,6 +1,8 @@ -without js -while true do - integer ch = wait_key() - if ch=#1B then exit end if - puts(1,ch) -end while +(notonline)--> + without js + while true do + integer ch = wait_key() + if ch=#1B then exit end if + puts(1,ch) + end while + + with javascript_semantics + procedure factorise(integer n) + sequence res = prime_factors(n,true) + res = join(apply(res,sprint)," x ") + printf(1,"%2d: %s\n",{n,res}) + end procedure -papply(tagset(10)&{2144,1_000_000_000},factorise) - --- And this is how you deal with larger numbers - you'd have to cap maxprime --- for anything larger, and in fact I had to do just that for this to work on --- 32-bit (295593 found by binary chop), and of course some numbers will get --- incredibly slow, or you could try using mpz_pollard_rho() instead. -puts(1,"\n") -include mpfr.e -for i=0 to 35 by 5 do - string s = "1"&repeat('0',i) - if even(i) then s[$] = '1' end if - integer maxprime = iff(machine_bits()=32?295593: - floor(sqrt(power(10,i)))) - sequence res = mpz_prime_factors(s,maxprime) - printf(1,"%s: %s\n",{s,mpz_factorstring(res)}) -end for + papply(tagset(10)&{2144,1000000000},factorise) + + sequence tests = {{"the three truths","th"}, + {"ababababab","abab"}, + {"ababababab","aba"}, + {"ababababab","ab"}, + {"ababababab","a"}, + {"ababababab",""}} + integer start, count + string test, substring + for i=1 to length(tests) do + start = 1 + count = 0 + {test, substring} = tests[i] + while 1 do + start = match(substring,test,start) + if start=0 then exit end if + start += length(substring) + count += 1 + end while + printf(1,"The string \"%s\" occurs as a non-overlapping substring %d times in \"%s\"\n",{substring,count,test}) + end for + - integer fn +integer fn - -- In the current working directory - system("mkdir docs",2) - fn = open("output.txt","w") - close(fn) +-- In the current working directory +system("mkdir docs",2) +fn = open("output.txt","w") +close(fn) - -- In the filesystem root - system("mkdir \\docs",2) - fn = open("\\output.txt","w") - if fn=-1 then - puts(1,"unable to create \\output.txt\n") - else - close(fn) - end if -') !Disclaiming responsibility... - INDEEP = 1 !Finishing the content of the header. - CALL HTML("") !Enough of that. - CALL HTML("") !A fresh line seems polite. - INDEEP = 2 !Its content follows.. - END SUBROUTINE HTMLSTART !Others will follow on. Hopefully, correctly. - SUBROUTINE HTMLSTOP !And hopefully, this will be a good closure. + CALL HTML('') !But said to be worthy. + CALL HTML(METAH//'Description" Content="'//DESC//'">') !Hopefully, helpful. + CALL HTML(METAH//'Generator" Content="'//I AM//'">') !I said. + CALL DATE_AND_TIME(DATE = D,TIME = T) !Not assignments, but attachments. + CALL HTML(METAH//'Created" Content="' !Convert the timestamp + 1 //D(1:4)//"-"//D(5:6)//"-"//D(7:8) !Into an international standard. + 2 //" "//T(1:2)//":"//T(3:4)//":"//T(5:10)//'">') !For date and time. + IF (LUSERCODE.GT.0) CALL HTML(METAH !Possibly, the user's code is known. + 1 //'Author" Content="'//USERCODE(1:LUSERCODE) !If so, reveal. + 2 //'"> ') !Disclaiming responsibility... + INDEEP = 1 !Finishing the content of the header. + CALL HTML("") !Enough of that. + CALL HTML("") !A fresh line seems polite. + INDEEP = 2 !Its content follows.. + END SUBROUTINE HTMLSTART !Others will follow on. Hopefully, correctly. + SUBROUTINE HTMLSTOP !And hopefully, this will be a good closure. Could be more sophisticated and track the stack via INDEEP+- and names, to enable a desperate close-off if INDEEP is not 2. - IF (INDEEP.NE.2) CALL ECART("Misclosure! InDeep not 2 but" !But, - 1 //I8FMT(INDEEP)) !It may not be. - INDEEP = 1 !Retreat to the first level. - CALL HTML("") !End the "body". - INDEEP = 0 !Retreat to the start level. - CALL HTML("") !End the whole thing. - END SUBROUTINE HTMLSTOP !Ah... + IF (INDEEP.NE.2) CALL ECART("Misclosure! InDeep not 2 but" !But, + 1 //I8FMT(INDEEP)) !It may not be. + INDEEP = 1 !Retreat to the first level. + CALL HTML("") !End the "body". + INDEEP = 0 !Retreat to the start level. + CALL HTML("") !End the whole thing. + END SUBROUTINE HTMLSTOP !Ah... - SUBROUTINE HTMLTSTART(B,SUMMARY) !Start a table. - INTEGER B !Border thickness. - CHARACTER*(*) SUMMARY !Some well-chosen words. - CALL HTML("') !Not displayed, but potentially used by non-display agencies... - INDEEP = INDEEP + 1 !Another level dug. + SUBROUTINE HTMLTSTART(B,SUMMARY) !Start a table. + INTEGER B !Border thickness. + CHARACTER*(*) SUMMARY !Some well-chosen words. + CALL HTML("
') !Not displayed, but potentially used by non-display agencies... + INDEEP = INDEEP + 1 !Another level dug. END SUBROUTINE HTMLTSTART!That part was easy. - SUBROUTINE HTMLTSTOP !And the ending is easy too. - INDEEP = INDEEP - 1 !Withdraw a level. - CALL HTML("
") !Hopefully, aligning. - END SUBROUTINE HTMLTSTOP !The bounds are easy. + SUBROUTINE HTMLTSTOP !And the ending is easy too. + INDEEP = INDEEP - 1 !Withdraw a level. + CALL HTML("") !Hopefully, aligning. + END SUBROUTINE HTMLTSTOP !The bounds are easy. - SUBROUTINE HTMLTHEADSTART !Start a table's heading. - CALL HTML("") !Thus. - INDEEP = INDEEP + 1 !Dig deeper. - END SUBROUTINE HTMLTHEADSTART !Content should follow. - SUBROUTINE HTMLTHEADSTOP !And now, enough. - INDEEP = INDEEP - 1 !Retreat a level. - CALL HTML("") !And end the head. - END SUBROUTINE HTMLTHEADSTOP !At the neck of the body? + SUBROUTINE HTMLTHEADSTART !Start a table's heading. + CALL HTML("") !Thus. + INDEEP = INDEEP + 1 !Dig deeper. + END SUBROUTINE HTMLTHEADSTART !Content should follow. + SUBROUTINE HTMLTHEADSTOP !And now, enough. + INDEEP = INDEEP - 1 !Retreat a level. + CALL HTML("") !And end the head. + END SUBROUTINE HTMLTHEADSTOP !At the neck of the body? - SUBROUTINE HTMLTHEAD(N,TEXT) !Cast forth a whole-span table heading. - INTEGER N !The count of columns to be spanned. - CHARACTER*(*) TEXT !A brief description to place there. - CALL HTML3("',"") !Start the specification. - CALL HTML3("",TEXT(1:LSTNB(TEXT)),"") !This text, possibly verbose. - END SUBROUTINE HTMLTHEAD !Thus, all contained on one line. + SUBROUTINE HTMLTHEAD(N,TEXT) !Cast forth a whole-span table heading. + INTEGER N !The count of columns to be spanned. + CHARACTER*(*) TEXT !A brief description to place there. + CALL HTML3("',"") !Start the specification. + CALL HTML3("",TEXT(1:LSTNB(TEXT)),"") !This text, possibly verbose. + END SUBROUTINE HTMLTHEAD !Thus, all contained on one line. - SUBROUTINE HTMLTBODYSTART !Start on the table body. - CALL HTML(' ') !And I don't think much of the "comment" formalism, either. - INDEEP = INDEEP + 1 !Anyway, we're ready with the alignment. - END SUBROUTINE HTMLTBODYSTART !Others will provide the body. - SUBROUTINE HTMLTBODYSTOP !And, they've had enough. - INDEEP = INDEEP - 1 !So, up out of the hole. - CALL HTML("") !Take a breath. - END SUBROUTINE HTMLTBODYSTOP !And wander off. - SUBROUTINE HTMLTROWTEXT(TEXT,N) !Roll a row of column headings. - CHARACTER*(*) TEXT(:) !The headings. - INTEGER N !Their number. - INTEGER I,L !Assistants. - CALL HTML3("","","") !Start a row of headings-to-come, and don't end the line. - DO I = 1,N !Step through the headings. - L = LSTNB(TEXT(I)) !Trailing spaces are to be ignored. - IF (L.LE.0) THEN !Thus discovering blank texts. - CALL HTML3(""," ","") !This prevents the cell being collapsed. - ELSE !But for those with text, - CALL HTML3("",""//TEXT(I)(1:L)//"","") !Roll it. - END IF !So much for that text. - END DO !On to the next. - CALL HTML3("","","") !Finish the row, and thus the line. - END SUBROUTINE HTMLTROWTEXT !So much for texts. - SUBROUTINE HTMLTROWINTEGER(V,N) !Now for all integers. - INTEGER V(:) !The integers. - INTEGER N !Their number. - INTEGER I !A stepper. - CALL HTML3('',"","") !Start a row of entries. - DO I = 1,N !Work through the row's values. - CALL HTML3("",""//I8FMT(V(I))//"","") !One by one. - END DO !On to the next. - CALL HTML3("","","") !Finish the row, and thus the line. - END SUBROUTINE HTMLTROWINTEGER !All the same type is not troublesome. - END MODULE HTMLSTUFF !Enough already. + SUBROUTINE HTMLTBODYSTART !Start on the table body. + CALL HTML(' ') !And I don't think much of the "comment" formalism, either. + INDEEP = INDEEP + 1 !Anyway, we're ready with the alignment. + END SUBROUTINE HTMLTBODYSTART !Others will provide the body. + SUBROUTINE HTMLTBODYSTOP !And, they've had enough. + INDEEP = INDEEP - 1 !So, up out of the hole. + CALL HTML("") !Take a breath. + END SUBROUTINE HTMLTBODYSTOP !And wander off. + SUBROUTINE HTMLTROWTEXT(TEXT,N) !Roll a row of column headings. + CHARACTER*(*) TEXT(:) !The headings. + INTEGER N !Their number. + INTEGER I,L !Assistants. + CALL HTML3("","","") !Start a row of headings-to-come, and don't end the line. + DO I = 1,N !Step through the headings. + L = LSTNB(TEXT(I)) !Trailing spaces are to be ignored. + IF (L.LE.0) THEN !Thus discovering blank texts. + CALL HTML3(""," ","") !This prevents the cell being collapsed. + ELSE !But for those with text, + CALL HTML3("",""//TEXT(I)(1:L)//"","") !Roll it. + END IF !So much for that text. + END DO !On to the next. + CALL HTML3("","","") !Finish the row, and thus the line. + END SUBROUTINE HTMLTROWTEXT !So much for texts. + SUBROUTINE HTMLTROWINTEGER(V,N) !Now for all integers. + INTEGER V(:) !The integers. + INTEGER N !Their number. + INTEGER I !A stepper. + CALL HTML3('',"","") !Start a row of entries. + DO I = 1,N !Work through the row's values. + CALL HTML3("",""//I8FMT(V(I))//"","") !One by one. + END DO !On to the next. + CALL HTML3("","","") !Finish the row, and thus the line. + END SUBROUTINE HTMLTROWINTEGER !All the same type is not troublesome. + END MODULE HTMLSTUFF !Enough already. PROGRAM MAKETABLE USE PARAMETERS USE ASSISTANCE USE HTMLSTUFF INTEGER KBD,MSG - INTEGER NCOLS !The usage of V must conform to this! - PARAMETER (NCOLS = 4) !Specified number of columns. - CHARACTER*3 COLNAME(NCOLS) !And they have names. - PARAMETER (COLNAME = (/"","X","Y","Z"/)) !As specified. - INTEGER V(NCOLS) !A scratchpad for a line's worth. - COMMON KBD,MSG !I/O units. - KBD = 5 !Keyboard. - MSG = 6 !Screen. - CALL GETLOG(USERCODE) !Who has poked me into life? - LUSERCODE = LSTNB(USERCODE) !Ah, text gnashing. + INTEGER NCOLS !The usage of V must conform to this! + PARAMETER (NCOLS = 4) !Specified number of columns. + CHARACTER*3 COLNAME(NCOLS) !And they have names. + PARAMETER (COLNAME = (/"","X","Y","Z"/)) !As specified. + INTEGER V(NCOLS) !A scratchpad for a line's worth. + COMMON KBD,MSG !I/O units. + KBD = 5 !Keyboard. + MSG = 6 !Screen. + CALL GETLOG(USERCODE) !Who has poked me into life? + LUSERCODE = LSTNB(USERCODE) !Ah, text gnashing. - CALL HTMLSTART(MSG,"Powers","Table of integer powers") !Output to the screen will do. - CALL HTMLTSTART(1,"Successive powers of successive integers") !Start the table. - CALL HTMLTHEADSTART !The table heading. - CALL HTMLTHEAD(NCOLS,"Successive powers") !A full-width heading. - CALL HTMLTROWTEXT(COLNAME,NCOLS) !Headings for each column. - CALL HTMLTHEADSTOP !So much for the heading. - CALL HTMLTBODYSTART !Now for the content. - DO I = 1,10 !This should be enough. - V(1) = I !The unheaded row number. - V(2) = I**2 !Its square. - V(3) = I**3 !Cube. - V(4) = I**4 !Fourth power. - CALL HTMLTROWINTEGER(V,NCOLS) !Show a row's worth.. - END DO !On to the next line. - CALL HTMLTBODYSTOP !No more content. - CALL HTMLTSTOP !End the table. + CALL HTMLSTART(MSG,"Powers","Table of integer powers") !Output to the screen will do. + CALL HTMLTSTART(1,"Successive powers of successive integers") !Start the table. + CALL HTMLTHEADSTART !The table heading. + CALL HTMLTHEAD(NCOLS,"Successive powers") !A full-width heading. + CALL HTMLTROWTEXT(COLNAME,NCOLS) !Headings for each column. + CALL HTMLTHEADSTOP !So much for the heading. + CALL HTMLTBODYSTART !Now for the content. + DO I = 1,10 !This should be enough. + V(1) = I !The unheaded row number. + V(2) = I**2 !Its square. + V(3) = I**3 !Cube. + V(4) = I**4 !Fourth power. + CALL HTMLTROWINTEGER(V,NCOLS) !Show a row's worth.. + END DO !On to the next line. + CALL HTMLTBODYSTOP !No more content. + CALL HTMLTSTOP !End the table. CALL HTMLSTOP END diff --git a/Task/Create-an-HTML-table/Java/create-an-html-table-3.java b/Task/Create-an-HTML-table/Java/create-an-html-table-3.java index 3c85302f31..f5306aa7ac 100644 --- a/Task/Create-an-HTML-table/Java/create-an-html-table-3.java +++ b/Task/Create-an-HTML-table/Java/create-an-html-table-3.java @@ -1,25 +1,25 @@ public class HTML { - public static String array2HTML(Object[][] array){ - StringBuilder html = new StringBuilder( - ""); - for(Object elem:array[0]){ - html.append(""); - } - for(int i = 1; i < array.length; i++){ - Object[] row = array[i]; - html.append(""); - for(Object elem:row){ - html.append(""); - } - html.append(""); - } - html.append("
" + elem.toString() + "
" + elem.toString() + "
"); - return html.toString(); - } - - public static void main(String[] args){ - Object[][] ints = {{"","X","Y","Z"},{1,1,2,3},{2,4,5,6},{3,7,8,9},{4,10,11,12}}; - System.out.println(array2HTML(ints)); - } + public static String array2HTML(Object[][] array){ + StringBuilder html = new StringBuilder( + ""); + for(Object elem:array[0]){ + html.append(""); + } + for(int i = 1; i < array.length; i++){ + Object[] row = array[i]; + html.append(""); + for(Object elem:row){ + html.append(""); + } + html.append(""); + } + html.append("
" + elem.toString() + "
" + elem.toString() + "
"); + return html.toString(); + } + + public static void main(String[] args){ + Object[][] ints = {{"","X","Y","Z"},{1,1,2,3},{2,4,5,6},{3,7,8,9},{4,10,11,12}}; + System.out.println(array2HTML(ints)); + } } diff --git a/Task/Create-an-HTML-table/JavaScript/create-an-html-table-1.js b/Task/Create-an-HTML-table/JavaScript/create-an-html-table-1.js index 9ba8c08860..02d28e0f6d 100644 --- a/Task/Create-an-HTML-table/JavaScript/create-an-html-table-1.js +++ b/Task/Create-an-HTML-table/JavaScript/create-an-html-table-1.js @@ -4,32 +4,32 @@ Node.prototype.a = function (e) { this.appendChild(e); return this } function ce(tag, txt) { - var x = document.createElement(tag); - x.textContent = (txt === undefined) ? '' : txt; - return x; + var x = document.createElement(tag); + x.textContent = (txt === undefined) ? '' : txt; + return x; } function make_table(cols, rows) { - var tbl = ce('table', ''), tr = ce('tr'), th; + var tbl = ce('table', ''), tr = ce('tr'), th; - tbl.a(tr.a(ce('th'))); + tbl.a(tr.a(ce('th'))); - var z = 'Z'.charCodeAt(0); - for (var l = z - cols + 1; l <= z; l++) - tr.a(ce('th', String.fromCharCode(l))); + var z = 'Z'.charCodeAt(0); + for (var l = z - cols + 1; l <= z; l++) + tr.a(ce('th', String.fromCharCode(l))); - for (var r = 1; r <= rows; r++) { - tbl.a(tr = ce('tr').a(ce('th', r))); - for (var c = 0; c < cols; c++) - tr.a(ce('td', Math.floor(Math.random() * 10000))); - } + for (var r = 1; r <= rows; r++) { + tbl.a(tr = ce('tr').a(ce('th', r))); + for (var c = 0; c < cols; c++) + tr.a(ce('td', Math.floor(Math.random() * 10000))); + } - document.body - .a(ce('style', - 'td, th {border: 1px solid #696;' + - 'padding:.4ex} td {text-align: right }' + - 'table { border-collapse: collapse}')) - .a(tbl); + document.body + .a(ce('style', + 'td, th {border: 1px solid #696;' + + 'padding:.4ex} td {text-align: right }' + + 'table { border-collapse: collapse}')) + .a(tbl); } diff --git a/Task/Create-an-HTML-table/Julia/create-an-html-table-1.jl b/Task/Create-an-HTML-table/Julia/create-an-html-table-1.julia similarity index 100% rename from Task/Create-an-HTML-table/Julia/create-an-html-table-1.jl rename to Task/Create-an-HTML-table/Julia/create-an-html-table-1.julia diff --git a/Task/Create-an-HTML-table/Julia/create-an-html-table-2.jl b/Task/Create-an-HTML-table/Julia/create-an-html-table-2.julia similarity index 100% rename from Task/Create-an-HTML-table/Julia/create-an-html-table-2.jl rename to Task/Create-an-HTML-table/Julia/create-an-html-table-2.julia diff --git a/Task/Create-an-HTML-table/Kotlin/create-an-html-table-1.kts b/Task/Create-an-HTML-table/Kotlin/create-an-html-table-1.kotlin similarity index 100% rename from Task/Create-an-HTML-table/Kotlin/create-an-html-table-1.kts rename to Task/Create-an-HTML-table/Kotlin/create-an-html-table-1.kotlin diff --git a/Task/Create-an-HTML-table/Kotlin/create-an-html-table-2.kts b/Task/Create-an-HTML-table/Kotlin/create-an-html-table-2.kotlin similarity index 100% rename from Task/Create-an-HTML-table/Kotlin/create-an-html-table-2.kts rename to Task/Create-an-HTML-table/Kotlin/create-an-html-table-2.kotlin diff --git a/Task/Create-an-HTML-table/Lasso/create-an-html-table.lasso b/Task/Create-an-HTML-table/Lasso/create-an-html-table.lasso index bac8e0748f..738052d5ac 100644 --- a/Task/Create-an-HTML-table/Lasso/create-an-html-table.lasso +++ b/Task/Create-an-HTML-table/Lasso/create-an-html-table.lasso @@ -1,20 +1,20 @@ define rand4dig => integer_random(9999, 1) local( - output = '\n' + output = '
\n' ) with el in (' ,X,Y,Z') -> split(',') do { - #output -> append('') + #output -> append('') } #output -> append('\n') loop(5) => { - #output -> append('\n') - loop(3) => { - #output -> append('') - } - #output -> append('\n') + #output -> append('\n') + loop(3) => { + #output -> append('') + } + #output -> append('\n') } #output -> append('
' + #el + '' + #el + '
' + loop_count + '' + rand4dig + '
' + loop_count + '' + rand4dig + '
\n') diff --git a/Task/Create-an-HTML-table/M2000-Interpreter/create-an-html-table.m2000 b/Task/Create-an-HTML-table/M2000-Interpreter/create-an-html-table.m2000 index e212abd32f..a4f9c77305 100644 --- a/Task/Create-an-HTML-table/M2000-Interpreter/create-an-html-table.m2000 +++ b/Task/Create-an-HTML-table/M2000-Interpreter/create-an-html-table.m2000 @@ -1,36 +1,36 @@ MODULE HtmlTable { - tag$=LAMBDA$ (a$)-> { - =LAMBDA$ a$ -> { - IF ISNUM THEN w$=STR$(NUMBER,0) ELSE w$=LETTER$ - READ ? part$ - ="<"+a$+IF$(LEN(part$)>0->" "+part$,"")+">"+w$+""+CHR$(13)+CHR$(10) - } - } - INVENTORY Fun - STACK NEW { - DATA "html", "head", "body", "table", "tr", "th", "td" - WHILE NOT EMPTY - OVER ' duplicate top of stack - APPEND Fun, LETTER$:=tag$(LETTER$) - END WHILE - } - DEF body0$="",body$="" - STACK NEW { - DATA "", "X", "Y", "Z" - FOR i=1 TO 4 - body0$+=Fun$("th")(LETTER$) - z$="" - FOR j=1 TO 3 : z$+=Fun$("td")(RANDOM(0, 9999), {align="right"}) : NEXT j - body$+=Fun$("tr")(Fun$("th")(i)+z$) - NEXT i - } - table$=fun$("table")(fun$("tr")(body0$)+body$,"border=1 cellpadding=10 cellspacing=0") - DOCUMENT final$=""+CHR$(13)+CHR$(10) - final$=fun$("html")(fun$("head")("")+fun$("body")(table$), {lang="en"}) - file$="c:\doc.html" - REPORT final$ - CLIPBOARD final$ - SAVE.DOC final$, file$ - WIN file$ ' execute, no wait + tag$=LAMBDA$ (a$)-> { + =LAMBDA$ a$ -> { + IF ISNUM THEN w$=STR$(NUMBER,0) ELSE w$=LETTER$ + READ ? part$ + ="<"+a$+IF$(LEN(part$)>0->" "+part$,"")+">"+w$+""+CHR$(13)+CHR$(10) + } + } + INVENTORY Fun + STACK NEW { + DATA "html", "head", "body", "table", "tr", "th", "td" + WHILE NOT EMPTY + OVER ' duplicate top of stack + APPEND Fun, LETTER$:=tag$(LETTER$) + END WHILE + } + DEF body0$="",body$="" + STACK NEW { + DATA "", "X", "Y", "Z" + FOR i=1 TO 4 + body0$+=Fun$("th")(LETTER$) + z$="" + FOR j=1 TO 3 : z$+=Fun$("td")(RANDOM(0, 9999), {align="right"}) : NEXT j + body$+=Fun$("tr")(Fun$("th")(i)+z$) + NEXT i + } + table$=fun$("table")(fun$("tr")(body0$)+body$,"border=1 cellpadding=10 cellspacing=0") + DOCUMENT final$=""+CHR$(13)+CHR$(10) + final$=fun$("html")(fun$("head")("")+fun$("body")(table$), {lang="en"}) + file$="c:\doc.html" + REPORT final$ + CLIPBOARD final$ + SAVE.DOC final$, file$ + WIN file$ ' execute, no wait } HtmlTable diff --git a/Task/Create-an-HTML-table/Modula-3/create-an-html-table.mod3 b/Task/Create-an-HTML-table/Modula-3/create-an-html-table.mod3 index a78a020685..86b0df0df1 100644 --- a/Task/Create-an-HTML-table/Modula-3/create-an-html-table.mod3 +++ b/Task/Create-an-HTML-table/Modula-3/create-an-html-table.mod3 @@ -5,16 +5,16 @@ FROM Fmt IMPORT Int, F; BEGIN IO.Put("" - & "" + & "" - & "", - Int(I), - Int(rand.integer(0, 1000)), - Int(rand.integer(0, 1000)), - Int(rand.integer(0, 1000)))); - END; + FOR I := 0 TO 3 DO + IO.Put(F("" + & "", + Int(I), + Int(rand.integer(0, 1000)), + Int(rand.integer(0, 1000)), + Int(rand.integer(0, 1000)))); + END; END; END Table. diff --git a/Task/Create-an-HTML-table/Nanoquery/create-an-html-table.nanoquery b/Task/Create-an-HTML-table/Nanoquery/create-an-html-table.nanoquery index b5ff55121d..e3c367c973 100644 --- a/Task/Create-an-HTML-table/Nanoquery/create-an-html-table.nanoquery +++ b/Task/Create-an-HTML-table/Nanoquery/create-an-html-table.nanoquery @@ -9,11 +9,11 @@ println "" // generate five rows for i in range(1, 5) - println "" - println "" - println "" - println "" - println "" + println "" + println "" + println "" + println "" + println "" end for println "
XY"); + & "border: 1px solid\">XY"); WITH rand = NEW(Random.Default).init() DO - FOR I := 0 TO 3 DO - IO.Put(F("
%s%s%s%s
%s%s%s%s
XYZ
" + i + "" + int($random.getInt(8999) + 1000) + "" + int($random.getInt(8999) + 1000) + "" + int($random.getInt(8999) + 1000) + "
" + i + "" + int($random.getInt(8999) + 1000) + "" + int($random.getInt(8999) + 1000) + "" + int($random.getInt(8999) + 1000) + "
" diff --git a/Task/Create-an-HTML-table/OCaml/create-an-html-table-1.ml b/Task/Create-an-HTML-table/OCaml/create-an-html-table-1.ocaml similarity index 100% rename from Task/Create-an-HTML-table/OCaml/create-an-html-table-1.ml rename to Task/Create-an-HTML-table/OCaml/create-an-html-table-1.ocaml diff --git a/Task/Create-an-HTML-table/OCaml/create-an-html-table-2.ml b/Task/Create-an-HTML-table/OCaml/create-an-html-table-2.ocaml similarity index 100% rename from Task/Create-an-HTML-table/OCaml/create-an-html-table-2.ml rename to Task/Create-an-HTML-table/OCaml/create-an-html-table-2.ocaml diff --git a/Task/Create-an-HTML-table/OCaml/create-an-html-table-3.ml b/Task/Create-an-HTML-table/OCaml/create-an-html-table-3.ocaml similarity index 100% rename from Task/Create-an-HTML-table/OCaml/create-an-html-table-3.ml rename to Task/Create-an-HTML-table/OCaml/create-an-html-table-3.ocaml diff --git a/Task/Create-an-HTML-table/OCaml/create-an-html-table-4.ml b/Task/Create-an-HTML-table/OCaml/create-an-html-table-4.ocaml similarity index 100% rename from Task/Create-an-HTML-table/OCaml/create-an-html-table-4.ml rename to Task/Create-an-HTML-table/OCaml/create-an-html-table-4.ocaml diff --git a/Task/Create-an-HTML-table/Oz/create-an-html-table.oz b/Task/Create-an-HTML-table/Oz/create-an-html-table.oz index e7695d8b19..8d353080da 100644 --- a/Task/Create-an-HTML-table/Oz/create-an-html-table.oz +++ b/Task/Create-an-HTML-table/Oz/create-an-html-table.oz @@ -5,30 +5,30 @@ declare fun {Table Session} html( head(title("Show a table with row and column headings") - style(type:"text/css" - css(td 'text-align':center) - )) + style(type:"text/css" + css(td 'text-align':center) + )) body( - {TagFromList table - tr(th th("X") th("Y") th("Z")) - | - {CreateRows 3 5} - })) + {TagFromList table + tr(th th("X") th("Y") th("Z")) + | + {CreateRows 3 5} + })) end fun {CreateRows NumCols NumRows} {List.map {List.number 1 NumRows 1} fun {$ Row} {TagFromList tr - td( {Int.toString Row} ) - | - {List.map {List.number 1 NumCols 1} - fun {$ Col} - SequentialNumber = (Row-1)*NumCols + Col - in - td( {Int.toString SequentialNumber} ) - end - }} + td( {Int.toString Row} ) + | + {List.map {List.number 1 NumCols 1} + fun {$ Col} + SequentialNumber = (Row-1)*NumCols + Col + in + td( {Int.toString SequentialNumber} ) + end + }} end } end diff --git a/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php b/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php index 78ddb2115b..f7fc655559 100644 --- a/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php +++ b/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php @@ -9,27 +9,27 @@ $rows = 3; $html = ''; foreach($cols as $col) { - $html .= ''; + $html .= ''; } unset($col); $html .= ''; foreach($cols as $col) { - $html .= ""; + $html .= ""; } unset($col); $html .= ''; for($r = 1; $r <= $rows; $r++) { - $html .= ''; - foreach($cols as $key => $col) - { - $html .= ''; - } - unset($col); - $html .= ''; + $html .= ''; + foreach($cols as $key => $col) + { + $html .= ''; + } + unset($col); + $html .= ''; } $html .= '
{$col}{$col}
' . (($key > 0) ? rand(1, 9999) : $r) . '
' . (($key > 0) ? rand(1, 9999) : $r) . '
'; diff --git a/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php b/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php index 3abf9fd3ee..a13b5fb1b9 100644 --- a/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php +++ b/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php @@ -9,27 +9,27 @@ $rows = 3; - - - - - - - - - - - - - - - - $col): ?> - - - - - + + + + + + + + + + + + + + + + $col): ?> + + + + +
0) ? rand(1, 9999) : $r ?>
0) ? rand(1, 9999) : $r ?>
diff --git a/Task/Create-an-HTML-table/Peloton/create-an-html-table.peloton b/Task/Create-an-HTML-table/Peloton/create-an-html-table.peloton index 37ba932a85..45b01ab02e 100644 --- a/Task/Create-an-HTML-table/Peloton/create-an-html-table.peloton +++ b/Task/Create-an-HTML-table/Peloton/create-an-html-table.peloton @@ -1,17 +1,17 @@ <@ SDCLIT> - <@ DTBLIT> - <@ DTRLITLIT> - <@ DTDLITLIT>|[style]background-color:white - <@ DTD>X - <@ DTD>Y - <@ DTD>Z|[style]width:100%; background-color:brown;color:white; text-align:center - <@ ITEFORLIT>10| - <@ DTRLITCAP> - <@ DTDPOSFORLIT>...|[style]background-color:Brown; color:white; text-align:right - <@ DTDCAPLIT><@ SAYR!ILI2>1|9999|[style]width:50;text-align:right - <@ DTDCAPLIT><@ SAYR!ILI2>1|9999|[style]width:50;text-align:right - <@ DTDCAPLIT><@ SAYR!ILI2>1|9999|[style]width:50;text-align:right - |[style]background-color:white;color:black - - + <@ DTBLIT> + <@ DTRLITLIT> + <@ DTDLITLIT>|[style]background-color:white + <@ DTD>X + <@ DTD>Y + <@ DTD>Z|[style]width:100%; background-color:brown;color:white; text-align:center + <@ ITEFORLIT>10| + <@ DTRLITCAP> + <@ DTDPOSFORLIT>...|[style]background-color:Brown; color:white; text-align:right + <@ DTDCAPLIT><@ SAYR!ILI2>1|9999|[style]width:50;text-align:right + <@ DTDCAPLIT><@ SAYR!ILI2>1|9999|[style]width:50;text-align:right + <@ DTDCAPLIT><@ SAYR!ILI2>1|9999|[style]width:50;text-align:right + |[style]background-color:white;color:black + + |Number Table diff --git a/Task/Create-an-HTML-table/PowerShell/create-an-html-table-1.ps1 b/Task/Create-an-HTML-table/PowerShell/create-an-html-table-1.psh similarity index 100% rename from Task/Create-an-HTML-table/PowerShell/create-an-html-table-1.ps1 rename to Task/Create-an-HTML-table/PowerShell/create-an-html-table-1.psh diff --git a/Task/Create-an-HTML-table/PowerShell/create-an-html-table-2.ps1 b/Task/Create-an-HTML-table/PowerShell/create-an-html-table-2.psh similarity index 100% rename from Task/Create-an-HTML-table/PowerShell/create-an-html-table-2.ps1 rename to Task/Create-an-HTML-table/PowerShell/create-an-html-table-2.psh diff --git a/Task/Create-an-HTML-table/PowerShell/create-an-html-table-3.ps1 b/Task/Create-an-HTML-table/PowerShell/create-an-html-table-3.psh similarity index 100% rename from Task/Create-an-HTML-table/PowerShell/create-an-html-table-3.ps1 rename to Task/Create-an-HTML-table/PowerShell/create-an-html-table-3.psh diff --git a/Task/Create-an-HTML-table/Prolog/create-an-html-table-1.pro b/Task/Create-an-HTML-table/Prolog/create-an-html-table-1.pro index cac87a0a7f..b84bdb97ae 100644 --- a/Task/Create-an-HTML-table/Prolog/create-an-html-table-1.pro +++ b/Task/Create-an-HTML-table/Prolog/create-an-html-table-1.pro @@ -5,12 +5,12 @@ trows([],_) --> []. trows([R|T], N) --> html(tr([td(N),\trow(R)])), { N1 is N + trow([]) --> []. trow([E|T]) --> html(td(E)), trow(T). table :- - Header = ['X','Y','Z'], - Rows = [ - [7055,5334,5795], - [2895,3019,7747], - [140,7607,8144], - [7090,475,4140] - ], - phrase(html(table([tr(\theader(Header)), \trows(Rows,1)])), Out, []), - print_html(Out). + Header = ['X','Y','Z'], + Rows = [ + [7055,5334,5795], + [2895,3019,7747], + [140,7607,8144], + [7090,475,4140] + ], + phrase(html(table([tr(\theader(Header)), \trows(Rows,1)])), Out, []), + print_html(Out). diff --git a/Task/Create-an-HTML-table/R/create-an-html-table.r b/Task/Create-an-HTML-table/R/create-an-html-table.r deleted file mode 100644 index 4818c382a0..0000000000 --- a/Task/Create-an-HTML-table/R/create-an-html-table.r +++ /dev/null @@ -1,15 +0,0 @@ -html_table <- function(headings, nrows){ - ncols <- length(headings) - pad_table <- function(s, char2="d"){ - pad <- paste0("", s, "", collapse="") - paste0("", pad, "", collapse="") - } - theader <- pad_table(c("", headings), char2="h") - gen_row <- function(n) c(n, sample(9999, ncols)) - tbody <- lapply(1:nrows, gen_row) |> sapply(pad_table) - cat("", theader, sep="\n") - writeLines(tbody) - cat("
\n") -} - -html_table(c("X", "Y", "Z"), 3) diff --git a/Task/Create-an-HTML-table/Rascal/create-an-html-table-1.rascal b/Task/Create-an-HTML-table/Rascal/create-an-html-table-1.rascal index 47f6edacf3..6d7cfdfdd8 100644 --- a/Task/Create-an-HTML-table/Rascal/create-an-html-table-1.rascal +++ b/Task/Create-an-HTML-table/Rascal/create-an-html-table-1.rascal @@ -8,11 +8,11 @@ str tr(str content) = item("tr", content); str td(str content) = item("td", content); public str generateTable(int rows){ - int i(){return arbInt(10000);}; - rows = (tr(td("")+td("X")+td("Y")+td("Z")) - | it + tr(td("")+td("")+td("")+td("")) - | x <- [1..rows]); - writeFile(|file:///location|, - html("Rosetta Code Table", table(rows))); - return "written"; + int i(){return arbInt(10000);}; + rows = (tr(td("")+td("X")+td("Y")+td("Z")) + | it + tr(td("")+td("")+td("")+td("")) + | x <- [1..rows]); + writeFile(|file:///location|, + html("Rosetta Code Table", table(rows))); + return "written"; } diff --git a/Task/Create-an-HTML-table/Rebol/create-an-html-table-1.rebol b/Task/Create-an-HTML-table/Rebol/create-an-html-table-1.rebol deleted file mode 100644 index 6460883556..0000000000 --- a/Task/Create-an-HTML-table/Rebol/create-an-html-table-1.rebol +++ /dev/null @@ -1,37 +0,0 @@ -Rebol [ - title: "Rosetta code: Create an HTML table" - file: %Create_an_HTML_table.r3 - url: https://rosettacode.org/wiki/Create_an_HTML_table - note: "Based on Red language implementation!" -] -table-rows: func [][rejoin [ - first-tr newline - rand-tr 1 newline - rand-tr 2 newline - rand-tr 3 newline - rand-tr 4 newline - rand-tr 5 newline -]] -td-data: does [999 + random 9000] -rand-td: does [form-tag 'td td-data] -rand-tr: func [i][rejoin [ - form-tag 'tr - rejoin [(form-tag 'td i) rand-td rand-td rand-td] -]] -first-tr: func[][rejoin [ - form-tag 'tr rejoin [ - form-tag 'th "" - form-tag 'th "X" - form-tag 'th "Y" - form-tag 'th "Z" - ] -]] -form-tag: func [tag contents /attr a][ - ajoin [ - "<" tag (if attr [ajoin [" " a/1 "=" {"} a/2 {"}]]) ">" - contents - "" - ] -] - -print form-tag 'table table-rows diff --git a/Task/Create-an-HTML-table/Rebol/create-an-html-table-2.rebol b/Task/Create-an-HTML-table/Rebol/create-an-html-table-2.rebol deleted file mode 100644 index c3c7cbc8af..0000000000 --- a/Task/Create-an-HTML-table/Rebol/create-an-html-table-2.rebol +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - -
XYZ
1209634429408
2967939177056
3215143569440
4274197384967
5237771907304
diff --git a/Task/Create-an-HTML-table/Rust/create-an-html-table-1.rs b/Task/Create-an-HTML-table/Rust/create-an-html-table-1.rust similarity index 100% rename from Task/Create-an-HTML-table/Rust/create-an-html-table-1.rs rename to Task/Create-an-HTML-table/Rust/create-an-html-table-1.rust diff --git a/Task/Create-an-HTML-table/Rust/create-an-html-table-2.rs b/Task/Create-an-HTML-table/Rust/create-an-html-table-2.rust similarity index 100% rename from Task/Create-an-HTML-table/Rust/create-an-html-table-2.rs rename to Task/Create-an-HTML-table/Rust/create-an-html-table-2.rust diff --git a/Task/Create-an-HTML-table/SNOBOL4/create-an-html-table.sno b/Task/Create-an-HTML-table/SNOBOL4/create-an-html-table.sno index 496e49d4ba..df2ca8af52 100644 --- a/Task/Create-an-HTML-table/SNOBOL4/create-an-html-table.sno +++ b/Task/Create-an-HTML-table/SNOBOL4/create-an-html-table.sno @@ -1,12 +1,12 @@ * HTML Table - output = "" - output = " " - i = 1 -o1 output = "" - j = 1 -o2 output = "" - j = lt(j,3) j + 1 :s(o2) - output = "" - i = lt(i,3) i + 1 :s(o1) - output = "
XYZ
" i "" i j "
" + output = "" + output = " " + i = 1 +o1 output = "" + j = 1 +o2 output = "" + j = lt(j,3) j + 1 :s(o2) + output = "" + i = lt(i,3) i + 1 :s(o1) + output = "
XYZ
" i "" i j "
" end diff --git a/Task/Create-an-HTML-table/Scheme/create-an-html-table.scm b/Task/Create-an-HTML-table/Scheme/create-an-html-table.ss similarity index 100% rename from Task/Create-an-HTML-table/Scheme/create-an-html-table.scm rename to Task/Create-an-HTML-table/Scheme/create-an-html-table.ss diff --git a/Task/Create-an-HTML-table/Standard-ML/create-an-html-table.ml b/Task/Create-an-HTML-table/Standard-ML/create-an-html-table.ml index 4446dc7c10..9ffc1b1e25 100644 --- a/Task/Create-an-HTML-table/Standard-ML/create-an-html-table.ml +++ b/Task/Create-an-HTML-table/Standard-ML/create-an-html-table.ml @@ -1,34 +1,34 @@ (* * val mkHtmlTable : ('a list * 'b list) -> ('a -> string * 'b -> string) - * -> (('a * 'b) -> string) -> string + * -> (('a * 'b) -> string) -> string * The int list is list of colums, the function returns the values * at a given colum and row. * returns the HTML code of the generated table. *) fun mkHtmlTable (columns, rows) (rowToStr, colToStr) values = - let - val text = ref "\n" - in - (* Add headers *) - map (fn colum => text := !text ^ "") columns; + let + val text = ref "
" ^ (colToStr colum) ^ "
\n" + in + (* Add headers *) + map (fn colum => text := !text ^ "") columns; - text := !text ^ "\n"; - (* Add data rows *) - map (fn row => - (* row name *) - (text := !text ^ ""; - (* data *) - map (fn col => text := !text ^ "") columns; - text := !text ^ "\n") - ) rows; - !text ^ "
" ^ (colToStr colum) ^ "
" ^ (rowToStr row) ^ "" ^ (values (row, col)) ^ "
" - end + text := !text ^ "\n"; + (* Add data rows *) + map (fn row => + (* row name *) + (text := !text ^ "" ^ (rowToStr row) ^ ""; + (* data *) + map (fn col => text := !text ^ "" ^ (values (row, col)) ^ "") columns; + text := !text ^ "\n") + ) rows; + !text ^ "" + end fun mkHtmlWithBody (title, body) = "\n\n" ^ title ^ "\n\n\n" ^ body ^ "\n\n\n" fun samplePage () = mkHtmlWithBody ("Sample Page", - mkHtmlTable ([1.0,2.0,3.0,4.0,5.0], [1.0,2.0,3.0,4.0]) - (Real.toString, Real.toString) - (fn (a, b) => Real.toString (Math.pow (a, b)))) + mkHtmlTable ([1.0,2.0,3.0,4.0,5.0], [1.0,2.0,3.0,4.0]) + (Real.toString, Real.toString) + (fn (a, b) => Real.toString (Math.pow (a, b)))) val _ = print (samplePage ()) diff --git a/Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata b/Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata index 0bca7e1ec7..e0aac840d1 100644 --- a/Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata +++ b/Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata @@ -16,19 +16,19 @@ file write `f' `""' _n file write `f' "" _n file write `f' "" _n forv j = 1/`nc' { - local s `: word `j' of `cn'' - file write `f' `""' _n + local s `: word `j' of `cn'' + file write `f' `""' _n } file write `f' "" _n * write row names & data forv i = 1/`nr' { - file write `f' "" _n - local s `: word `i' of `rn'' - file write `f' `""' _n - forv j = 1/`nc' { - file write `f' `""' _n - } - file write `f' "" _n + file write `f' "" _n + local s `: word `i' of `rn'' + file write `f' `""' _n + forv j = 1/`nc' { + file write `f' `""' _n + } + file write `f' "" _n } file write `f' "
`s'`s'
`s'`=el(`1',`i',`j')'
`s'`=el(`1',`i',`j')'
" _n file write `f' "" _n diff --git a/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl b/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl index 0c28ec5b37..0a25494ed2 100644 --- a/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl +++ b/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl @@ -3,7 +3,7 @@ proc TAG {name args} { set body [lindex $args end] set result "<$name" foreach {t v} [lrange $args 0 end-1] { - append result " $t=\"" $v "\"" + append result " $t=\"" $v "\"" } append result ">" [string trim [uplevel 1 [list subst $body]]] "" } @@ -21,21 +21,21 @@ set data {} for {set x 0} {$x < 4} {incr x} { # Inspired by the Go solution, but with extra arbitrary digits to show 4-char wide values lappend data [list \ - [expr {$x+1}] [expr {$x*3010}] [expr {$x*3+1298}] [expr {$x*2579+2182}]] + [expr {$x+1}] [expr {$x*3010}] [expr {$x*3+1298}] [expr {$x*2579+2182}]] } # Write the table to standard out puts [TAG table border 1 { [TAG tr bgcolor #f0f0f0 { - [FOREACH head $titles { - [TAG th {$head}] - }] + [FOREACH head $titles { + [TAG th {$head}] + }] }] [FOREACH row $data { - [TAG tr bgcolor #ffffff { - [FOREACH col $row { - [TAG td align right {$col}] - }] - }] + [TAG tr bgcolor #ffffff { + [FOREACH col $row { + [TAG td align right {$col}] + }] + }] }] }] diff --git a/Task/Create-an-HTML-table/VBScript/create-an-html-table.vb b/Task/Create-an-HTML-table/VBScript/create-an-html-table.vb new file mode 100644 index 0000000000..35deed3f02 --- /dev/null +++ b/Task/Create-an-HTML-table/VBScript/create-an-html-table.vb @@ -0,0 +1,40 @@ +Set objFSO = CreateObject("Scripting.FileSystemObject") + +'Open the input csv file for reading. The file is in the same folder as the script. +Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ + "\in.csv",1) + +'Create the output html file. +Set objOutHTML = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ + "\out.html",2,True) + +'Write the html opening tags. +objOutHTML.Write "" & vbCrLf + +'Declare table properties. +objOutHTML.Write "" & vbCrLf + +'Write column headers. +objOutHTML.Write "" & vbCrLf + +'Go through each line of the input csv file and write to the html output file. +n = 1 +Do Until objInFile.AtEndOfStream + line = objInFile.ReadLine + If Len(line) > 0 Then + token = Split(line,",") + objOutHTML.Write "" + For i = 0 To UBound(token) + objOutHTML.Write "" + Next + objOutHTML.Write "" & vbCrLf + End If + n = n + 1 +Loop + +'Write the html closing tags. +objOutHTML.Write "
XYZ
" & n & "" & token(i) & "
" + +objInFile.Close +objOutHTML.Close +Set objFSO = Nothing diff --git a/Task/Create-an-HTML-table/VBScript/create-an-html-table.vbs b/Task/Create-an-HTML-table/VBScript/create-an-html-table.vbs deleted file mode 100644 index 488b88273f..0000000000 --- a/Task/Create-an-HTML-table/VBScript/create-an-html-table.vbs +++ /dev/null @@ -1,40 +0,0 @@ -Set objFSO = CreateObject("Scripting.FileSystemObject") - -'Open the input csv file for reading. The file is in the same folder as the script. -Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ - "\in.csv",1) - -'Create the output html file. -Set objOutHTML = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ - "\out.html",2,True) - -'Write the html opening tags. -objOutHTML.Write "" & vbCrLf - -'Declare table properties. -objOutHTML.Write "" & vbCrLf - -'Write column headers. -objOutHTML.Write "" & vbCrLf - -'Go through each line of the input csv file and write to the html output file. -n = 1 -Do Until objInFile.AtEndOfStream - line = objInFile.ReadLine - If Len(line) > 0 Then - token = Split(line,",") - objOutHTML.Write "" - For i = 0 To UBound(token) - objOutHTML.Write "" - Next - objOutHTML.Write "" & vbCrLf - End If - n = n + 1 -Loop - -'Write the html closing tags. -objOutHTML.Write "
XYZ
" & n & "" & token(i) & "
" - -objInFile.Close -objOutHTML.Close -Set objFSO = Nothing diff --git a/Task/Create-an-HTML-table/Wren/create-an-html-table.wren b/Task/Create-an-HTML-table/Wren/create-an-html-table.wren index 3ec9fa84b4..995fe7255f 100644 --- a/Task/Create-an-HTML-table/Wren/create-an-html-table.wren +++ b/Task/Create-an-HTML-table/Wren/create-an-html-table.wren @@ -1,5 +1,5 @@ import "random" for Random -import "./fmt" for Fmt +import "/fmt" for Fmt var r = Random.new() var sb = "" diff --git a/Task/Create-an-HTML-table/X86-64-Assembly/create-an-html-table.x86-64 b/Task/Create-an-HTML-table/X86-64-Assembly/create-an-html-table.x86-64 deleted file mode 100644 index 1df6b26b15..0000000000 --- a/Task/Create-an-HTML-table/X86-64-Assembly/create-an-html-table.x86-64 +++ /dev/null @@ -1,323 +0,0 @@ -; creating html table -; assembly X86 window -; download and install visual studio 2022 free site microsoft -; search and open X64 native tools command prompt -; compil and link program with this command : -; ml64 .asm /link /ENTRY:main /SUBSYSTEM:console kernel32.lib user32.lib Shell32.lib -; this program respects the 64-bit calling convention : -; registers arguments : rcx rdx r8 r9 and stack -; registers saved : rbx,rbp,rdi,rsi, r12-r15 -; ATTENTION les registres rax,rcx,rdx,r8-r11 peuvent être -; perdus lors d'un appel de fonction -;********************************* -; constantes -;********************************* -STD_OUTPUT_HANDLE equ -11 - -NBLIGNES equ 5 -BUFFERSIZE equ 200 - -;********************************* -; MACROS -;********************************* -afficherLib MACRO messa -local mess1,LGMESS1C -.data - mess1 db messa,10,0 - LGMESS1C equ $ - mess1 -.code - push rax - push rcx - push rdx - push r8 - push r9 - push r10 - push r11 - mov rcx, offset mess1 - mov rdx,LGMESS1C - call afficherConsole - pop r11 - pop r10 - pop r9 - pop r8 - pop rdx - pop rcx - pop rax - -ENDM - -;********************************* -; user data -;********************************* -.data -szarrayheader db " ",10,0 -LGSZARRAYHEADER equ $ - szarrayheader -1 -szarrayend db "
",10,0 -LGSZARRAYEND equ $ - szarrayend -1 -szLine1 db "XYZ",10,0 -LGSZLINE1 equ $ - szLine1 - 1 -szDebLine db "",0 -LGSZDEBLINE equ $ - szDebLine - 1 -szEndLine db "",10,0 -LGSZENDLINE equ $ - szEndLine - 1 -szEndCol db "",0 -LGSZENDCOL equ $ - szEndCol - 1 - -sBuffer db BUFFERSIZE dup (' ') - -szRetourLigne db 10,0 -sZoneConv db 24 dup (' ') -sZoneConv1 db 24 dup (' ') -sZoneConv2 db 24 dup (' ') -sZoneConv3 db 24 dup (' ') - -align 8 -qgraine dq 123456789 -qNbDep1 dq 0019660dh -qNbDep2 dq 3c6ef35fh -hConsole dq 0 - -;********************************* -; user code fonction principale -;********************************* -.code - -extern WriteFile : proc, GetStdHandle : proc, ExitProcess : proc -extern GetLastError : proc - -main PROC public - afficherLib "Program start." - mov rcx, offset szarrayheader - mov rdx,LGSZARRAYHEADER - call afficherConsole - - mov rcx, offset szLine1 - mov rdx,LGSZLINE1 - call afficherConsole - - mov rbx,1 ; indice loop -lineLoop: ; line loop begin - mov rcx,rbx - mov rdx,offset sZoneConv - call conversion10 - mov rax, offset szDebLine - push rax - mov rax,LGSZDEBLINE - push rax - mov rax,offset sZoneConv - push rax - push 1 - mov rax,offset szEndCol - push rax - mov rax,LGSZENDCOL - push rax - mov rcx,10000 - call randomNumber - mov rcx,rax - mov rdx,offset sZoneConv1 - call conversion10 - mov rcx,offset sZoneConv1 - push rcx - push rax - mov rax,offset szEndCol - push rax - mov rax,LGSZENDCOL - push rax - mov rcx,10000 - call randomNumber - mov rcx,rax - mov rdx,offset sZoneConv2 - call conversion10 - mov rcx,offset sZoneConv2 - push rcx - push rax - - mov rax,offset szEndCol - push rax - mov rax,LGSZENDCOL - push rax - mov rcx,10000 - call randomNumber - mov rcx,rax - mov rdx,offset sZoneConv3 - call conversion10 - mov rcx,offset sZoneConv3 - push rcx - push rax - - mov rax, offset szEndLine - push rax - mov rax,LGSZENDLINE - push rax - mov rcx, offset sBuffer - mov rdx,BUFFERSIZE - mov r8,9 - call grouperChaines - add rsp,8 * 2 * 9 - - mov rcx, offset sBuffer - mov rdx,rax - call afficherConsole - - inc rbx - cmp rbx,NBLIGNES - jle lineLoop - - mov rcx, offset szarrayend - mov rdx,LGSZARRAYEND - call afficherConsole - - - mov rcx, offset szRetourLigne - mov rdx,1 - call afficherConsole - - -finProgramme: - afficherLib "Programm end." - sub rsp,28h - mov rcx,0 ; return code - call ExitProcess -main ENDP - -;************************************** -; console display -;************************************** -; rcx : string address -; rdx : length string -afficherConsole: - push rbx - push r12 - sub rsp,28h ; 40 bytes on stack (shadow variables) - mov rbx,rcx ; string address - mov r12,rdx ; size string - - cmp QWORD ptr hConsole,0 ; console handle ? - jne @B3 - mov rcx,STD_OUTPUT_HANDLE - call GetStdHandle ; load console handle - mov hConsole, rax ; save in data -@B3: - mov rcx,hconsole ; handle - mov rdx,rbx ; string address - mov r8,r12 ; string length - mov r9,0 ; - - sub rsp,8 ; stack alignement (one push) - push 0 - sub rsp,20h ; stack for shadow variable - call WriteFile ; winapi function - add rsp,20h - add rsp,10h ; 1 push and alignement - add rsp,28h ; stack alignement - pop r12 - pop rbx - ret -;*************************************************** -;conversion to unsigned base 10 -;with removal of unnecessary zeros -;and left shift -;**************************************************** -; rcx : value to convert -; rdx : conversion area address length > 22 -LONGUEUR equ 24 -conversion10: - push rbx - push rdi - mov rdi,rdx ; conversion area address - mov BYTE ptr [rdi+LONGUEUR],0 ; 0 final conversion area - mov rax,rcx ; value - mov rcx,LONGUEUR-1 - mov rbx ,10 -CA1: ; loop begin - mov rdx,0 ; division rax by 10 - div rbx - add rdx,'0' ; remainder conversion ascii - mov byte ptr [rdi+rcx],dl - dec rcx - cmp rax,0 ; end ? - jne CA1 - xor rax,rax - inc rcx -CA5: ; copy loop - mov dl,[rdi+rcx] ; load a result character - mov byte ptr [rdi+rax],dl ; and store at conversion area begin - inc rcx - inc rax - cmp rcx,LONGUEUR ; loop if not zero final - jle CA5 - pop rdi - pop rbx - ret -;************************************** -; generate random number -;************************************** -; rcx number limit -randomNumber: - mov rax,0 - cmp rcx,0 - je randfin - mov rax, qGraine ; load seed - mov r8,qNbDep1 - mov rdx,qNbDep2 - mul r8 - add rax,rdx - mov qGraine,rax ; store new seed - inc rcx - mov rdx,0 - div rcx - mov rax,rdx ; result = remainder -randfin: - ret -;*************************************************** -; string concatenation -;************************************************** -; rcx destination area address -; rdx destination area length -; r8 strings number -; r9 0 -; on stack address and length of each string -; in order of insertion -grouperChaines: - enter 0,0 - push rbx - push r12 - push r13 - cmp r8,0 - je fingrp - mov r12,rdx - mov r9,0 ; indice strings - mov r10,0 ; number of characters inserted -bouclezone: - mov r13,r8 - shl r13,1 - mov rbx,[rbp+8+(r13 * 8)] ; string address - mov rax,[rbp+(r13 * 8)] ; sring length - mov r11,0 -bouclecopie: ; loop string copy - mov dl,byte ptr[rbx+r11] - mov byte ptr[rcx+r10],dl - inc r11 - cmp r11,rax - jg finbouclecopie - inc r10 ;number of characters inserted - cmp r10,r12 ; max? - jge erreur - jmp bouclecopie -finbouclecopie: - dec r8 ; other string - jnz bouclezone - - mov rax,r10 ; return size final string - jmp fingrp -erreur: - afficherLib "reception area too small" - mov rax,0 -fingrp: - pop r13 - pop r12 - pop rbx - leave - ret - -end diff --git a/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.adb b/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.ada similarity index 100% rename from Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.adb rename to Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.ada diff --git a/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.adb b/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.ada similarity index 100% rename from Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.adb rename to Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.ada diff --git a/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cob b/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cob deleted file mode 100644 index b785bd467c..0000000000 --- a/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cob +++ /dev/null @@ -1,18 +0,0 @@ -IDENTIFICATION DIVISION. -PROGRAM-ID. object-address-test. -DATA DIVISION. -LOCAL-STORAGE SECTION. -77 int-space PICTURE IS 9(5) VALUE IS 12345. -77 addr PICTURE IS 9(5) BASED VALUE IS ZERO. -77 point USAGE IS POINTER. -PROCEDURE DIVISION. - DISPLAY "Value of integer object : " int-space - SET point TO ADDRESS OF int-space - DISPLAY "Machine address of object : " point - SET ADDRESS OF addr TO point - DISPLAY "Value of referent object : " addr - MOVE 65535 TO int-space - DISPLAY "New value of original : " addr - DISPLAY "New value of reference : " int-space - GOBACK. -END PROGRAM object-address-test. diff --git a/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol b/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol new file mode 100644 index 0000000000..a0967cf614 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol @@ -0,0 +1,20 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. object-address-test. + DATA DIVISION. + LOCAL-STORAGE SECTION. + 01 int-space. + 05 val PICTURE 9(5) VALUE 12345. + 01 addr BASED. + 05 val PICTURE 9(5) VALUE ZERO. + 01 point USAGE POINTER. + PROCEDURE DIVISION. + DISPLAY val OF int-space END-DISPLAY + SET point TO ADDRESS OF int-space + DISPLAY point END-DISPLAY + SET ADDRESS OF addr TO point + DISPLAY val OF addr END-DISPLAY + MOVE 65535 TO val OF addr + DISPLAY val OF addr END-DISPLAY + DISPLAY val OF int-space END-DISPLAY + STOP RUN. + END PROGRAM object-address-test. diff --git a/Task/Create-an-object-at-a-given-address/Delphi/create-an-object-at-a-given-address.pas b/Task/Create-an-object-at-a-given-address/Delphi/create-an-object-at-a-given-address.delphi similarity index 100% rename from Task/Create-an-object-at-a-given-address/Delphi/create-an-object-at-a-given-address.pas rename to Task/Create-an-object-at-a-given-address/Delphi/create-an-object-at-a-given-address.delphi diff --git a/Task/Create-an-object-at-a-given-address/FutureBasic/create-an-object-at-a-given-address.basic b/Task/Create-an-object-at-a-given-address/FutureBasic/create-an-object-at-a-given-address.basic deleted file mode 100644 index c3b79eb3b6..0000000000 --- a/Task/Create-an-object-at-a-given-address/FutureBasic/create-an-object-at-a-given-address.basic +++ /dev/null @@ -1,24 +0,0 @@ -include "NSLog.incl" - - -local fn DoIt - NSLog( @"Dimension in integer \"x\", but do not assign it a value.\n" ) - long x - // Note that the @ (at sign) prefixing x is a pointer to its machine address - NSLog( @"The machine address of x is: %p", @x ) - NSLog( @"While x is unassigned, the machine address will contain a garbage value: %ld\n", x ) - - // Assign x a value of 1234 - x = 1234 - NSLog( @"When x is assigned a value of %ld, that value will be stored in the machine address: %p", x, @x ) - NSLog( @"The machine address now contains the value: %ld\n", x ) - - // Reassign x a value of 5678 - x = 5678 - NSLog( @"Wnen x is reassigned the new value %ld, that value will be stored in the existing machine address: %p", x, @x ) - NSLog( @"The machine address now contains the value: %ld\n", x ) -end fn - -fn DoIt - -HandleEvents diff --git a/Task/Create-an-object-at-a-given-address/Julia/create-an-object-at-a-given-address.jl b/Task/Create-an-object-at-a-given-address/Julia/create-an-object-at-a-given-address.julia similarity index 100% rename from Task/Create-an-object-at-a-given-address/Julia/create-an-object-at-a-given-address.jl rename to Task/Create-an-object-at-a-given-address/Julia/create-an-object-at-a-given-address.julia diff --git a/Task/Create-an-object-at-a-given-address/Kotlin/create-an-object-at-a-given-address.kts b/Task/Create-an-object-at-a-given-address/Kotlin/create-an-object-at-a-given-address.kotlin similarity index 100% rename from Task/Create-an-object-at-a-given-address/Kotlin/create-an-object-at-a-given-address.kts rename to Task/Create-an-object-at-a-given-address/Kotlin/create-an-object-at-a-given-address.kotlin diff --git a/Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas b/Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas deleted file mode 100644 index 1feef12947..0000000000 --- a/Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas +++ /dev/null @@ -1,12 +0,0 @@ -begin - var pi: ^integer; - New(pi); - pi^ := 3; - Writeln(pi,' ',pi^); - pi^ := 5; - Writeln(pi,' ',pi^); - var pi1: ^integer := pi; - pi1^ := 666; - Writeln(pi1,' ',pi1^); - Writeln(pi,' ',pi^); -end. diff --git a/Task/Create-an-object-at-a-given-address/Rust/create-an-object-at-a-given-address.rs b/Task/Create-an-object-at-a-given-address/Rust/create-an-object-at-a-given-address.rust similarity index 100% rename from Task/Create-an-object-at-a-given-address/Rust/create-an-object-at-a-given-address.rs rename to Task/Create-an-object-at-a-given-address/Rust/create-an-object-at-a-given-address.rust diff --git a/Task/Create-an-object-at-a-given-address/V-(Vlang)/create-an-object-at-a-given-address.v b/Task/Create-an-object-at-a-given-address/V-(Vlang)/create-an-object-at-a-given-address.v deleted file mode 100644 index f0895f2e33..0000000000 --- a/Task/Create-an-object-at-a-given-address/V-(Vlang)/create-an-object-at-a-given-address.v +++ /dev/null @@ -1,22 +0,0 @@ -fn main() { - // create an integer object - - mut target := 42 - mut target_ref := &target - - println("Here is an integer: ${target}") - - // print the machine address of the object - - println("And its reference is: ${target_ref}") - - // take the address of the object and create another integer object at this address - - unsafe{(*target_ref) = 69} - - println("Newly assigned value is: ${*target_ref}") - - // print the value of this object to verify that it is same as one of the origin - - println("Compared with referent: ${target}") -} diff --git a/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-1.wren b/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-1.wren index a0686fcbd8..d71d23fd4c 100644 --- a/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-1.wren +++ b/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-1.wren @@ -1,4 +1,4 @@ -/* Create_an_object_at_a_given_address.wren */ +/* create_object_at_given_address.wren */ import "./fmt" for Fmt diff --git a/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-2.wren b/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-2.wren index cb93454cc9..ce8f1e121b 100644 --- a/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-2.wren +++ b/Task/Create-an-object-at-a-given-address/Wren/create-an-object-at-a-given-address-2.wren @@ -1,4 +1,4 @@ -/* gcc Create_an_object_at_a_given_address.c -o Create_an_object_at_a_given_address -lwren -lm */ +/* gcc create_object_at_given_address.c -o create_object_at_given_address -lwren -lm */ #include #include @@ -113,7 +113,7 @@ int main(int argc, char **argv) { config.loadModuleFn = &loadModule; WrenVM* vm = wrenNewVM(&config); const char* module = "main"; - const char* fileName = "Create_an_object_at_a_given_address.wren"; + const char* fileName = "create_object_at_given_address.wren"; char *script = readFile(fileName); WrenInterpretResult result = wrenInterpret(vm, module, script); switch (result) { diff --git a/Task/Create-an-object-at-a-given-address/XPL0/create-an-object-at-a-given-address.xpl0 b/Task/Create-an-object-at-a-given-address/XPL0/create-an-object-at-a-given-address.xpl0 deleted file mode 100644 index fd3ff6cb00..0000000000 --- a/Task/Create-an-object-at-a-given-address/XPL0/create-an-object-at-a-given-address.xpl0 +++ /dev/null @@ -1,15 +0,0 @@ -int Obj; \create an integer object -char Addr; -[HexOut(0, @Obj); \print the machine address of the object (relative to some base) -CrLf(0); -Addr:= @Obj; \take the address of the object and -Addr(0):= $78; \ create another integer object at this address -Addr(1):= $56; -Addr(2):= $34; -Addr(3):= $12; -HexOut(0, Obj); \print the value of this object to verify that -CrLf(0); \ it is same as one of the origin -Obj:= $DEADBEEF; \change the value of the origin and verify it again -HexOut(0, Obj); -CrLf(0); -] diff --git a/Task/Cuban-primes/ALGOL-68/cuban-primes.alg b/Task/Cuban-primes/ALGOL-68/cuban-primes.alg index d3121f0c9c..781a845dec 100644 --- a/Task/Cuban-primes/ALGOL-68/cuban-primes.alg +++ b/Task/Cuban-primes/ALGOL-68/cuban-primes.alg @@ -2,7 +2,7 @@ BEGIN # find some cuban primes (using the definition: a prime p is a cuban prime if # # p = n^3 - ( n - 1 )^3 # # for some n > 0) # - PR read "primes.incl.a68" PR # include prime utilities # + # returns a string representation of n with commas # PROC commatise = ( LONG INT n )STRING: BEGIN @@ -18,15 +18,32 @@ BEGIN result END # commatise # ; + # sieve the primes # INT sieve max = 2 000 000; - []BOOL sieve = PRIMESIEVE sieve max; # sieve the primes to max sieve # + [ sieve max ]BOOL sieve; FOR i TO UPB sieve DO sieve[ i ] := TRUE OD; + sieve[ 1 ] := FALSE; + FOR s FROM 2 TO ENTIER sqrt( sieve max ) DO + IF sieve[ s ] THEN + FOR p FROM s * s BY s TO sieve max DO sieve[ p ] := FALSE OD + FI + OD; + # count the primes, we can ignore 2, as we know it isn't a cuban prime # + sieve[ 2 ] := FALSE; + INT prime count := 0; + FOR s TO UPB sieve DO IF sieve[ s ] THEN prime count +:= 1 FI OD; + # construct a list of the primes # + [ 1 : prime count ]INT primes; + INT prime pos := LWB primes; + FOR s FROM LWB sieve TO UPB sieve DO + IF sieve[ s ] THEN primes[ prime pos ] := s; prime pos +:= 1 FI + OD; # find the cuban primes # INT cuban count := 0; LONG INT final cuban := 0; INT max cuban = 100 000; # mximum number of cubans to find # INT print limit = 200; # show all cubans up to this one # - print( ( "First ", commatise( print limit ), " cuban primes:", newline ) ); + print( ( "First ", commatise( print limit ), " cuban primes: ", newline ) ); LONG INT prev cube := 1; FOR n FROM 2 WHILE LONG INT this cube = ( LENG n * n ) * n; @@ -34,10 +51,15 @@ BEGIN prev cube := this cube; IF ODD p THEN # 2 is not a cuban prime so we only test odd numbers # - IF IF p <= UPB sieve THEN sieve[ SHORTEN p ] ELSE is probably prime( p ) FI - THEN + BOOL is prime := TRUE; + INT max factor = SHORTEN ENTIER long sqrt( p ); + FOR f FROM LWB primes WHILE is prime AND primes[ f ] <= max factor DO + is prime := p MOD primes[ f ] /= 0 + OD; + IF is prime THEN # have a cuban prime # - IF ( cuban count +:= 1 ) <= print limit THEN + cuban count +:= 1; + IF cuban count <= print limit THEN # must show this cuban # STRING p formatted = commatise( p ); print( ( " "[ UPB p formatted : ], p formatted ) ); diff --git a/Task/Cuban-primes/AWK/cuban-primes.awk b/Task/Cuban-primes/AWK/cuban-primes.awk deleted file mode 100644 index 93acddba9e..0000000000 --- a/Task/Cuban-primes/AWK/cuban-primes.awk +++ /dev/null @@ -1,28 +0,0 @@ -# syntax: GAWK -f CUBAN_PRIMES.AWK -# converted from EasyLang -BEGIN { - limit = 200 - printf("The first %d cuban primes are:\n",limit) - while (count < 10000 ) { - i++ - di = 3 * i * (i + 1) + 1 - if (is_prime(di) == 1) { - if (++count <= limit) { - printf("%8d%s",di,count%10?"":"\n") - } - } - } - printf("\ncuban prime # %d is: %'d\n",count,di) - exit(0) -} -function is_prime(x, i) { - if (x <= 1) { - return(0) - } - for (i=2; i<=int(sqrt(x)); i++) { - if (x % i == 0) { - return(0) - } - } - return(1) -} diff --git a/Task/Cuban-primes/Ada/cuban-primes.adb b/Task/Cuban-primes/Ada/cuban-primes.adb deleted file mode 100644 index d824856bc4..0000000000 --- a/Task/Cuban-primes/Ada/cuban-primes.adb +++ /dev/null @@ -1,136 +0,0 @@ --- Rosetta Code Task written in Ada --- Cuban primes (related to "Cubes", not "Cubans") --- https://rosettacode.org/wiki/Cuban_primes --- July 2024, R. B. E. - --- Using this Cuban Primes Definition: primes of the form: n^3 - (n-1)^3. - --- ToDo: --- Commatize the results (an advanced subtask) --- Could replace the "activity dots" generated during the big calculations with a spinner - --- NOTE: Using GNAT Big_Numbers package. --- Takes a very long time to generate the 100_000th cuban prime: about 75 minutes on a M1 Mac Mini. - -pragma Ada_2022; -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; -with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; -with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers; -with Ada.Strings; use Ada.Strings; -with Ada.Strings.Fixed; use Ada.Strings.Fixed; -with Ada.Strings.Maps; use Ada.Strings.Maps; -with Ada.Real_Time; use Ada.Real_Time; - -procedure Cuban_Primes is - - function Is_Prime (A : Positive) return Boolean is - D : Positive; - begin - if A < 2 then - return False; - end if; - if A in 2 .. 3 then - return True; - end if; - if A mod 2 = 0 then - return False; - end if; - if A mod 3 = 0 then - return False; - end if; - D := 5; - while D * D <= A loop - if A mod D = 0 then - return False; - end if; - D := D + 2; - if A mod D = 0 then - return False; - end if; - D := D + 4; - end loop; - return True; - end Is_Prime; - - function Is_Prime (A : Big_Natural) return Boolean is - D : Big_Natural; - B0 : constant Big_Natural := To_Big_Integer (0); - B1 : constant Big_Natural := To_Big_Integer (1); - B2 : constant Big_Natural := To_Big_Integer (2); - B3 : constant Big_Natural := To_Big_Integer (3); - B4 : constant Big_Natural := To_Big_Integer (4); - B5 : constant Big_Natural := To_Big_Integer (5); - begin - if A < B2 then - return False; - end if; - if (A = B2) or (A = B3) then - return True; - end if; - if A mod B2 = B0 then - return False; - end if; - if A mod B3 = B0 then - return False; - end if; - D := B5; - while D * D <= A loop - if A mod D = B0 then - return False; - end if; - D := D + B2; - if A mod D = B0 then - return False; - end if; - D := D + B4; - end loop; - return True; - end Is_Prime; - - Cuban_Count : Natural := 1; - Candidate : Natural; - Big_Candidate : Big_Natural; - Max_Cuban_for_the_Table : constant Integer := 200; - Max_Cuban_below_the_Table : constant Integer := 100_000; - Start_Time, Stop_Time : Time; - Elapsed_Time : Time_Span; - -begin - Put ("The first "); - Put (Max_Cuban_for_the_Table, 1); - Put_Line (" Cuban Primes..."); - for I in 1 .. Integer'Last loop - Candidate := ((I + 1) ** 3) - (I ** 3); - if Is_Prime (Candidate) then - Put (Candidate, 8); - if ((Cuban_Count rem 14) = 0) then - New_Line; - end if; - Cuban_Count := Cuban_Count + 1; - end if; - exit when Cuban_Count > Max_Cuban_for_the_Table; - end loop; - New_Line (2); - Cuban_Count := 1; - Start_Time := Clock; - Put ("The "); - Put (Max_Cuban_below_the_Table, 1); - Put ("th Cuban Prime is: "); - for I in 1 .. Integer'Last loop - Big_Candidate := (((To_Big_Integer (I) + 1) ** 3) - (To_Big_Integer (I) ** 3)); - if Is_Prime (Big_Candidate) then - Cuban_Count := Cuban_Count + 1; - if (Cuban_Count rem 10_000) = 0 then - Put ("."); - end if; - end if; - exit when Cuban_Count = Max_Cuban_below_the_Table; - end loop; - New_Line; - Put (Trim (To_String (Big_Candidate), Right)); - Stop_Time := Clock; - Elapsed_Time := Stop_Time - Start_Time; - New_Line; - Put_Line ("Elapsed time to calculate: " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds"); -end Cuban_Primes; diff --git a/Task/Cuban-primes/EasyLang/cuban-primes.easy b/Task/Cuban-primes/EasyLang/cuban-primes.easy deleted file mode 100644 index 8140fa46a5..0000000000 --- a/Task/Cuban-primes/EasyLang/cuban-primes.easy +++ /dev/null @@ -1,24 +0,0 @@ -fastfunc isprim num . - if num mod 2 = 0 : return 0 - if num mod 3 = 0 : return 0 - i = 5 - while i <= sqrt num - if num mod i = 0 : return 0 - i += 2 - if num mod i = 0 : return 0 - i += 4 - . - return 1 -. -i = 1 -while cnt < 50000 - di = 3 * i * (i + 1) + 1 - if isprim di = 1 - cnt += 1 - if cnt <= 200 : write di & " " - . - i += 1 -. -print "" -print "" -print di diff --git a/Task/Cuban-primes/Fortran/cuban-primes.f b/Task/Cuban-primes/Fortran/cuban-primes.f deleted file mode 100644 index d2dcee4458..0000000000 --- a/Task/Cuban-primes/Fortran/cuban-primes.f +++ /dev/null @@ -1,201 +0,0 @@ -! Cuban Prime Numbers -! tested with GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! -! Note that both intel ifx and VSI Fortran do not compile this code because they do not -! support 16-byte-integers. -! -! U.B., September 2025 -! - -program CubanPrimes - implicit none - - integer, parameter :: llint=16 - integer, parameter ::strLen = 20 - - integer (kind=llint) :: nc = 0, i=0, di - character (len=strLen) :: sdi ! for formatted output of di - - write (*, *) 'The first 200 cuban prime numbers are:' - do while (nc .lt. 100001) - di = diff_cubes(i) - if (isprime(di)) then - nc = nc + 1 - if (nc .le. 200) then - sdi = GroupedDigits (di, 10) - write (*, '(A10)', advance='no') sdi - if (mod (nc,10) .eq. 0 ) then - write (*,*) - end if - end if - if (nc .eq. 100000) then - sdi = GroupedDigits (di, 18) - write (*,'(//"The 100000th cuban prime number is: ", A)') sdi - exit - end if - end if - i = i + 1 - end do - - - contains - - !------------------------------------------------ - ! Calculate difference (n+1)³ - n³ = 3n² + 3n + 1 - !------------------------------------------------ - function diff_cubes( n ) result (n3) - integer (kind=llint),intent(in) ::n - integer (kind=llint) :: n3 - n3 = 3*n*(n+1) + 1 - end function - - - ! ---------------------------------------------------------------- - ! Fortran does not have a way to use locales for output. - ! Manual insert of separating commas such as 1,345,678 for 1345678 - ! ---------------------------------------------------------------- - function GroupedDigits (n, width) result (outStr) - integer(kind=llint), intent (in) :: n - integer :: width - character (len=width) :: outStr - character (len=2*strLen) :: workStr - integer :: ii, jj, cnt, trueLen - - - ! Write n into a string, then copy the digits to a second string, - ! inserting separater after every 3 digits. - write (workStr, '(i0)') n - ! Adjust left, then cutoff trailing blanks - workstr = adjustl (workstr) - trueLen = len_trim (workStr) - - outStr = ' ' - jj = width - cnt = 0 - do ii=trueLen, 1, -1 ! Copy backwards for correct grouping. - outStr (jj:jj) = workStr (ii:ii) - jj = jj -1 - cnt = cnt + 1 - ! Insert comma after 3 digits, but only if more digits follow. - if (mod (cnt, 3) .eq. 0 .and. ii .gt. 1 .and. workStr(ii-1:ii-1) .ne. ' ') then - outStr (jj:jj) = ',' - jj = jj - 1 - endif - end do - - end function GroupedDigits - - - - - - - ! ---------------------------------------- - ! Miller-Rabin test if n is a prime number - ! ---------------------------------------- - function isPrime(n) result (YN) - - integer(kind=llint), intent(in) ::n - logical :: YN - integer (kind=llint) :: ar (5), i - - ! Early return in most trivial cases - if (n .le. 1) then ! Too small - YN=.false. - return - endif - if (n .eq. 2) then ! 2 is prime - YN=.true. - return - endif - if (mod (n , 2) .eq. 0) then ! all other even number are not prime - YN=.false. - return - endif - if (n .lt. 9) then ! all odd numbers < 9 are prime - YN=.true. - return - endif - if (mod (n , 3) .eq. 0) then ! multiples of 3 aren't prime - YN=.false. - return - endif - if (mod (n , 5) .eq. 0) then ! multiples of 5 aren't prime - YN=.false. - return - endif - - ! these 5 bases are required and sufficient to test numbers up to 2,152,302,898,747 - ar(1) = 2 - ar(2) = 3 - ar(3) = 5 - ar(4) = 7 - ar(5) = 11 - do i = 1, 5 - if (Witness(ar(i), n)) then - YN=.false. ! Not prime - return - endif - end do - YN= .true. ! prime - - end function isPrime - - ! ------------------------------------- - ! helper function for Miller Rabin test - ! ------------------------------------- - function Witness(a, n) result (YN) - - integer (kind=llint) , intent(in) :: a - integer (kind=llint) , intent(in) :: n - - - integer (kind=llint) :: t, u, i - logical :: YN - integer (kind=llint) :: xi1, xi2 - - t = 0 - u = n - 1 - do while (iand(u , 1_llint) .eq. 0) - t = t + 1 - u = u / 2 - end do - - xi1 = ModularExp(a, u, n); - do i = 0, t-1 - xi2 = mod (xi1 * xi1 , n) - if ((xi2 .eq. 1) .and. (xi1 .ne. 1) .and. (xi1 .ne. (n - 1))) then - YN = .true. - return - endif - xi1 = xi2 - end do - if (xi1 .ne. 1) then - YN=.true. - else - YN = .false. - endif - end function Witness - - ! ------------------------------------- - ! helper function for Miller Rabin test - ! ------------------------------------- - function ModularExp(a, b, n) result(d) - - integer(kind=llint) , intent(in) :: a,b,n - integer (kind=llint) :: d - integer (kind=llint) :: i, k - d = 1 - k = 0 - do while (ishft (b, -k) .gt. 0) - k = k + 1 - end do - do i = k - 1, 0, -1 - d = mod (d*d, n) - if (iand (ishft (b, -i) , 1_llint) .gt. 0) d = mod (d*a ,n); - end do - - end function ModularExp - - -end program diff --git a/Task/Cuban-primes/FutureBasic/cuban-primes.basic b/Task/Cuban-primes/FutureBasic/cuban-primes.basic deleted file mode 100644 index 3bbad2af09..0000000000 --- a/Task/Cuban-primes/FutureBasic/cuban-primes.basic +++ /dev/null @@ -1,40 +0,0 @@ -BBOOL local fn IsPrime( p as UInt64 ) - if ( p < 2 ) then return NO - if ( p % 2 == 0 ) then return ( p == 2 ) - UInt64 limit = fn sqrt( (double)p ) - for UInt64 i = 3 to limit step 2 - if ( p % i == 0 ) then return NO - next -end fn = YES - -local fn CubanPrimes( howMany as NSUInteger ) - CFMutableArrayRef cubanPrimes = fn MutableArrayNew - UInt64 n = 1 - - while ( fn ArrayCount( cubanPrimes ) < howMany ) - UInt64 p = 3 * n * n + 3 * n + 1 - if ( fn IsPrime( p ) ) - MutableArrayAddObject( cubanPrimes, @(p) ) - end if - n++ - wend - - printf @"\nFirst 200 Cuban primes:\n" - for NSUInteger i = 0 to fn ArrayCount( cubanPrimes ) - 1 - printf @"%7lu\b", fn NumberUnsignedLongValue( cubanPrimes[i] ) - if ( i < fn ArrayCount( cubanPrimes ) - 1 ) - if ( i % 8 == 7 ) - print - else - print @"\t" - end if - end if - next - print -end fn - -window 1, @"cuban Primes", ( 0, 0, 630, 440 ) - -fn CubanPrimes( 200 ) - -HandleEvents diff --git a/Task/Cuban-primes/JavaScript/cuban-primes.js b/Task/Cuban-primes/JavaScript/cuban-primes.js deleted file mode 100644 index 86fd7b9358..0000000000 --- a/Task/Cuban-primes/JavaScript/cuban-primes.js +++ /dev/null @@ -1,68 +0,0 @@ -const MAX = 1400000; -const primes = new Array(MAX); - -function preCompute() { - // Initialize sieve - for (let i = 2; i < MAX; i++) { - primes[i] = true; - } - - // Sieve of Eratosthenes - for (let i = 2; i < MAX; i++) { - if (primes[i]) { - for (let j = 2 * i; j < MAX; j += i) { - primes[j] = false; - } - } - } -} - -function isPrime(n) { - if (n < MAX) { - return primes[n]; - } - const max = Math.floor(Math.sqrt(n)); - for (let i = 3; i <= max; i++) { - if (primes[i] && n % i === 0) { - return false; - } - } - return true; -} - -function cubanPrime(n, display) { - let count = 0; - let result = 0; - let output = ''; - - for (let i = 0; count < n; i++) { - const test = 1 + 3 * i * (i + 1); - if (isPrime(test)) { - count++; - result = test; - if (display) { - const formatted = test.toLocaleString('en-US').padStart(10); - output += formatted + (count % 10 === 0 ? '\n' : ''); - } - } - } - - if (display) { - console.log(output); - } - return result; -} - -// Main execution -preCompute(); - -// First 200 Cuban primes -cubanPrime(200, true); -console.log(); - -// Specific Cuban primes -for (let i = 1; i <= 5; i++) { - const max = Math.pow(10, i); - const prime = cubanPrime(max, false); - console.log(`${max.toLocaleString('en-US')}-th cuban prime = ${prime.toLocaleString('en-US')}`); -} diff --git a/Task/Cuban-primes/Julia/cuban-primes.jl b/Task/Cuban-primes/Julia/cuban-primes.julia similarity index 100% rename from Task/Cuban-primes/Julia/cuban-primes.jl rename to Task/Cuban-primes/Julia/cuban-primes.julia diff --git a/Task/Cuban-primes/Kotlin/cuban-primes.kts b/Task/Cuban-primes/Kotlin/cuban-primes.kotlin similarity index 100% rename from Task/Cuban-primes/Kotlin/cuban-primes.kts rename to Task/Cuban-primes/Kotlin/cuban-primes.kotlin diff --git a/Task/Cuban-primes/OCaml/cuban-primes.ml b/Task/Cuban-primes/OCaml/cuban-primes.ml deleted file mode 100644 index af8c106059..0000000000 --- a/Task/Cuban-primes/OCaml/cuban-primes.ml +++ /dev/null @@ -1,51 +0,0 @@ -let is_prime (n : int) : bool = - if n = 2 then true else if n < 2 || n mod 2 = 0 then false else - let lim = (n |> float_of_int |> sqrt |> int_of_float) + 1 in - let rec loop = function - | i when i > lim -> true - | i when n mod i = 0 -> false - | i -> loop (i + 2) - in loop 3 - -let char_list_of_string s = List.init (String.length s) (String.get s) - -let commatize (str : string) : string = - let revchars = List.rev (char_list_of_string str) in - let rec take_threes = function - | s, c1 :: c2 :: c3 :: rest -> - take_threes ([c3; c2; c1] :: s, rest) - | ss, rest -> if rest = [] then ss else List.rev rest :: ss - in take_threes ([], List.map Char.escaped revchars) - |> List.map (String.concat "") |> String.concat "," - -let cube (n: int) : int = n * n * n - -let scan_for_cubans (num : int) : int list = - let rec loop = function - | n, ps when List.length ps >= num -> ps - | n, ps -> - let c = cube (n + 1) - cube n in - if is_prime c then loop (n + 1, c :: ps) - else loop (n + 1, ps) in - loop (1, []) |> List.rev - -let nth_cuban (n : int) : int = - let rec loop = function - | i, c, p when c = n -> p - | i, c, p -> - let k = cube (i + 1) - cube i in - if is_prime k then loop (i + 1, c + 1, k) - else loop (i + 1, c, p) in - loop (0, 0, 0) - -let () = - print_endline "The first 200 cuban primes are: "; - scan_for_cubans 200 - |> List.map string_of_int - |> List.map commatize - |> String.concat " | " - |> Printf.printf "[%s]\n\n"; - nth_cuban 100_000 - |> string_of_int - |> commatize - |> Printf.printf "The 100,000th cuban prime is %s\n" diff --git a/Task/Cuban-primes/PARI-GP/cuban-primes.parigp b/Task/Cuban-primes/PARI-GP/cuban-primes.parigp deleted file mode 100644 index 8a6da33165..0000000000 --- a/Task/Cuban-primes/PARI-GP/cuban-primes.parigp +++ /dev/null @@ -1,25 +0,0 @@ -cubanprimes(N) = -{ - cubans = vector(N); - cube1 = 1; count = 1; cube100k = 0; - for (i=1, +oo, - cube2 = (i + 1)^3; - diff = cube2 - cube1; - if (isprime(diff), - if (count <= N, cubans[count] = diff); - if (count == 100000, cube100k = diff; break); - count++; - ); - cube1 = cube2; - ); - print("The first " N " Cuban primes are: "); - for (i=1, N, - if (cubans[i] != 0, - print1(cubans[i], " "); - if (i % 8 == 0, print); - ); - ); - print("\nThe 100,000th Cuban prime is " cube100k); -} - -cubanprimes(200); diff --git a/Task/Cuban-primes/PascalABC.NET/cuban-primes.pas b/Task/Cuban-primes/PascalABC.NET/cuban-primes.pas deleted file mode 100644 index f54de0f00f..0000000000 --- a/Task/Cuban-primes/PascalABC.NET/cuban-primes.pas +++ /dev/null @@ -1,67 +0,0 @@ -const - cutOff = 200; - bigUn = 100000; - chunks = 50; - little = bigUn div chunks; - -begin - writeln('The first ', cutOff, ' cuban primes:'); - var primes := |int64(3), int64(5)|.ToList; - var c := 0; - var u: int64 := 0; - var v: int64 := 1; - var showEach := true; - while true do - begin - var found := false; - u += 6; - v += u; - var mx := real(v).sqrt.ceil; - foreach var item in primes do - begin - if item > mx then break; - if v mod item = 0 then - begin - found := true; - break - end; - end; - if not found then - begin - c += 1; - if showEach then - begin - for var z := primes.last + 2 to v - 2 step 2 do - begin - var fnd := false; - foreach var item in primes do - begin - if item > mx then break; - if z mod item = 0 then - begin - fnd := true; - break - end; - end; - if not fnd then primes.Add(z); - end; - primes.Add(v); - write(v:9); - if c mod 10 = 0 then writeln; - if c = cutOff then - begin - showEach := false; - write('Progress to the ', bigUn, 'th cuban prime: ') - end; - end; - if c mod little = 0 then - begin - write('.'); - if c = bigUn then break; - end; - end; - end; - writeln(); - writeln('The ', c, 'th cuban prime is ', v); - writeln('Computation time was ', milliseconds / 1000, ' seconds'); -end. diff --git a/Task/Cuban-primes/Phix/cuban-primes.phix b/Task/Cuban-primes/Phix/cuban-primes.phix index 7aa90398b7..29da36d962 100644 --- a/Task/Cuban-primes/Phix/cuban-primes.phix +++ b/Task/Cuban-primes/Phix/cuban-primes.phix @@ -1,32 +1,34 @@ -with javascript_semantics -include mpfr.e -integer np = 0, - i = 2 -mpz p3 = mpz_init(1*1*1), - i3 = mpz_init(), - p = mpz_init(), - pn = mpz_init() +(phixonline)--> + with javascript_semantics + include mpfr.e + integer np = 0, + i = 2 + mpz p3 = mpz_init(1*1*1), + i3 = mpz_init(), + p = mpz_init(), + pn = mpz_init() -printf(1,"The first 200 cuban primes are:\n") -sequence first200 = {} -atom t0 = time() -constant lim = iff(platform()=JS?10000:100000) -while npprintf(1,"The first 200 cuban primes are:\n") + sequence first200 = {} + atom t0 = time() + constant lim = iff(platform()=JS?10000:100000) + while np<lim do + mpz_ui_pow_ui(i3,i,3) + mpz_sub(p,i3,p3) + if mpz_prime(p) then + mpz_set(pn,p) + np += 1 + if np<=200 then + first200 = append(first200,sprintf("%,9d",mpz_get_integer(pn))) + if mod(np,10)=0 then + printf(1,"%s\n",join(first200[-10..-1])) + end if + end if + end if + mpz_set(p3,i3) + i += 1 + end while + printf(1,"\nThe %,dth cuban prime is %s\n",{np,mpz_get_str(pn,comma_fill:=true)}) + {p3,i3,p} = mpz_free({p3,i3,p}) + ?elapsed(time()-t0) + + with javascript_semantics + + atom sdn = 0, sdsum = 0, sdsumsq = 0 + + procedure sdadd(atom n) + sdn += 1 + sdsum += n + sdsumsq += n*n + end procedure + + function sdavg() + return sdsum/sdn + end function + + function sddev() + return sqrt(sdsumsq/sdn - power(sdsum/sdn,2)) + end function + + --test code: + constant testset = {2, 4, 4, 4, 5, 5, 7, 9} + integer ti + for i=1 to length(testset) do + ti = testset[i] + sdadd(ti) + printf(1,"N=%d Item=%d Avg=%5.3f StdDev=%5.3f\n",{i,ti,sdavg(),sddev()}) + end for + - requires("1.0.4") -- (mpfr_get_fixed() busted in 1.0.2|3) - include mpfr.e - mpfr_set_default_precision(-20) -- ensure accuracy to at least 20 d.p. - - mpfr total_price = mpfr_init("4000000000000000"), - tmp = mpfr_init("5.5"), - tax = mpfr_init("0.0765"), - total = mpfr_init() - mpfr_mul(total_price,total_price,tmp) - mpfr_set_str(tmp,"2.86") - mpfr_mul_si(tmp,tmp,2) - mpfr_add(total_price,total_price,tmp) - mpfr_mul(tax,total_price,tax) - mpfr_add(total,total_price,tax) - printf(1,"Total before tax:%26s\n",{mpfr_get_fixed(total_price,2,comma_fill:=true)}) - printf(1," Tax:%26s\n",{mpfr_get_fixed(tax,2,comma_fill:=true)}) - printf(1," Total:%26s\n",{mpfr_get_fixed(total,2,comma_fill:=true)}) - - requires(64) - atom total_price = 4000000000000000*5.5+2.86*2, - tax = total_price*0.0765, - total = total_price+tax - printf(1,"Total before tax:%,26.2f\n",{total_price}) - printf(1," Tax:%,26.2f\n",{tax}) - printf(1," Total:%,26.2f\n",{total}) - + with javascript_semantics + requires("1.0.0") -- (mpfr_set_default_prec[ision] has been renamed) + include mpfr.e + mpfr_set_default_precision(-20) -- ensure accuracy to at least 20 d.p. + + mpfr total_price = mpfr_init("4000000000000000"), + tmp = mpfr_init("5.5"), + tax = mpfr_init("0.0765"), + total = mpfr_init() + mpfr_mul(total_price,total_price,tmp) + mpfr_set_str(tmp,"2.86") + mpfr_mul_si(tmp,tmp,2) + mpfr_add(total_price,total_price,tmp) + mpfr_mul(tax,total_price,tax) + mpfr_add(total,total_price,tax) + printf(1,"Total before tax:%21s\n",{mpfr_get_fixed(total_price,2)}) + printf(1," Tax:%21s\n",{mpfr_get_fixed(tax,2)}) + printf(1," Total:%21s\n",{mpfr_get_fixed(total,2)}) + n/d ) - - [ n->v v+ ] is cents ( n/d n --> n/d ) - - [ rot n->v v* ] is cost ( n n/d --> n/d ) - - [ $->v drop v* 100 n->v v/ ] is tax ( n/d $ --> n/d ) - - [ 100 n->v v/ - 2 point$ - $ " $" swap join - ' [ 2 split nip ] ]do[ - dup -3 peek - char . = if done - dup -2 peek - char . = iff - [ char 0 join ] - done - $ ".00" join ] is currency$ ( n/d --> $ ) - - [ currency$ echo$ ] is echocurrency ( n/d --> ) - - - 4000000000000000 5 dollars 50 cents cost - 2 2 dollars 86 cents cost v+ - - say "Total price before tax: " 2dup echocurrency cr - - 2dup $ "7.65" tax - - say "Tax: " 2dup echocurrency cr - - v+ - say "Total price with tax: " echocurrency cr diff --git a/Task/Currency/Rebol/currency.rebol b/Task/Currency/Rebol/currency.rebol deleted file mode 100644 index 1231a914f8..0000000000 --- a/Task/Currency/Rebol/currency.rebol +++ /dev/null @@ -1,20 +0,0 @@ -Rebol [ - title: "Rosetta code: Currency" - file: %Currency.r3 - url: https://rosettacode.org/wiki/Currency - needs: 3.0.0 -] - -hamburgers: 4'000'000'000'000'000 -hamburger-price: $5.50 -milkshakes: 2 -milkshake-price: $2.86 -tax-rate: 7.65% - -total-price: (hamburgers * hamburger-price) + (milkshakes * milkshake-price) -tax: total-price * tax-rate -total: total-price + tax - -print ["Total price before tax :" round/to total-price $0.01] -print ["Tax :" round/to tax $0.01] -print ["Total price after tax :" round/to total $0.01] diff --git a/Task/Currency/Rust/currency.rs b/Task/Currency/Rust/currency.rs deleted file mode 100644 index bc7d6ef5dc..0000000000 --- a/Task/Currency/Rust/currency.rs +++ /dev/null @@ -1,71 +0,0 @@ -extern crate num_bigint; // 0.3.0 -extern crate num_rational; // 0.3.0 - -use num_bigint::BigInt; -use num_rational::BigRational; - - -use std::ops::{Add, Mul}; -use std::fmt; - -fn main() { - let hamburger = Currency::new(5.50); - let milkshake = Currency::new(2.86); - let pre_tax = hamburger * 4_000_000_000_000_000 + milkshake * 2; - println!("Price before tax: {}", pre_tax); - let tax = pre_tax.calculate_tax(); - println!("Tax: {}", tax); - let post_tax = pre_tax + tax; - println!("Price after tax: {}", post_tax); -} - -#[derive(Debug)] -struct Currency { - amount: BigRational, -} - -impl Add for Currency { - - type Output = Self; - - fn add(self, other: Self) -> Self { - Self { - amount: self.amount + other.amount, - } - } -} - -impl Mul for Currency { - - type Output = Self; - - fn mul(self, other: u64) -> Self { - Self { - amount: self.amount * BigInt::from(other), - } - } -} - -impl fmt::Display for Currency { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let cents = (&self.amount * BigInt::from(100)).to_integer(); - write!(f, "${}.{:0>2}", ¢s / 100, ¢s % 100) - } -} - -impl Currency { - - fn new(num: f64) -> Self { - Self { - amount: BigRational::new(((num * 100.0).round() as i64).into(), 100.into()) - } - } - - fn calculate_tax(&self) -> Self { - let tax_val = BigRational::new(765.into(), 100.into());// 7,65 -> 0.0765 after the next line - let amount = (&self.amount * tax_val).ceil() / BigInt::from(100); - Self { - amount - } - } -} diff --git a/Task/Currency/Rust/currency.rust b/Task/Currency/Rust/currency.rust new file mode 100644 index 0000000000..905e4234f1 --- /dev/null +++ b/Task/Currency/Rust/currency.rust @@ -0,0 +1,71 @@ +extern crate num_bigint; // 0.3.0 +extern crate num_rational; // 0.3.0 + +use num_bigint::BigInt; +use num_rational::BigRational; + + +use std::ops::{Add, Mul}; +use std::fmt; + +fn main() { + let hamburger = Currency::new(5.50); + let milkshake = Currency::new(2.86); + let pre_tax = hamburger * 4_000_000_000_000_000 + milkshake * 2; + println!("Price before tax: {}", pre_tax); + let tax = pre_tax.calculate_tax(); + println!("Tax: {}", tax); + let post_tax = pre_tax + tax; + println!("Price after tax: {}", post_tax); +} + +#[derive(Debug)] +struct Currency { + amount: BigRational, +} + +impl Add for Currency { + + type Output = Self; + + fn add(self, other: Self) -> Self { + Self { + amount: self.amount + other.amount, + } + } +} + +impl Mul for Currency { + + type Output = Self; + + fn mul(self, other: u64) -> Self { + Self { + amount: self.amount * BigInt::from(other), + } + } +} + +impl fmt::Display for Currency { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let cents = (&self.amount * BigInt::from(100)).to_integer(); + write!(f, "${}.{}", ¢s / 100, ¢s % 100) + } +} + +impl Currency { + + fn new(num: f64) -> Self { + Self { + amount: BigRational::new(((num * 100.0) as i64).into(), 100.into()) + } + } + + fn calculate_tax(&self) -> Self { + let tax_val = BigRational::new(765.into(), 100.into());// 7,65 -> 0.0765 after the next line + let amount = (&self.amount * tax_val).ceil() / BigInt::from(100); + Self { + amount + } + } +} diff --git a/Task/Currency/Unicon/currency.unicon b/Task/Currency/Unicon/currency.unicon deleted file mode 100644 index 7d7fd7012b..0000000000 --- a/Task/Currency/Unicon/currency.unicon +++ /dev/null @@ -1,14 +0,0 @@ -import math - -procedure main() - n_burgers := 4000000000000000 - n_shakes := 2 - - price := FxPt(5.50) * n_burgers + FxPt(2.86) * n_shakes - tax := (price * FxPt(7.65/100)).round(2) - total := price + tax - - write(left("Price", 10), "$", right(price.toString(),21)) - write(left("Tax", 10), "$", right(tax.toString(),21)) - write(left("Total", 10), "$", right(total.toString(),21)) -end diff --git a/Task/Currency/Wren/currency.wren b/Task/Currency/Wren/currency.wren index 6cf58ddbd8..158035e3cb 100644 --- a/Task/Currency/Wren/currency.wren +++ b/Task/Currency/Wren/currency.wren @@ -1,10 +1,11 @@ -import "./big" for BigRat +import "/big" for BigRat var hamburgers = BigRat.new("4000000000000000") var milkshakes = BigRat.two var price1 = BigRat.fromFloat(5.5) var price2 = BigRat.fromFloat(2.86) var taxPc = BigRat.fromFloat(0.0765) +var totalPc = BigRat.fromFloat(1.0765) var totalPreTax = hamburgers*price1 + milkshakes*price2 var totalTax = taxPc * totalPreTax var totalAfterTax = totalPreTax + totalTax diff --git a/Task/Currency/XPL0/currency.xpl0 b/Task/Currency/XPL0/currency.xpl0 deleted file mode 100644 index e786fa022c..0000000000 --- a/Task/Currency/XPL0/currency.xpl0 +++ /dev/null @@ -1,44 +0,0 @@ -include xpllib; \for Big ops and StrCopy -def Size=30; -char NumA(Size), NumB(Size), NumC(Size); - -proc DolOut(Num); \Display Big Num as dollars and cents -char Num; -int LZ, I, Dig; -[LZ:= true; \suppress leading zeros -for I:= 0 to -1>>1 do - [if I+2 < Size then - if Num(I+2) = 0 then - [ChOut(0, ^.); - LZ:= false; - ]; - Dig:= Num(I); - if Dig = 0 then return; - if Dig # ^0 then LZ:= false; - if not LZ then ChOut(0, Dig); - ]; -]; - -[Int2Big(0, NumA, Size-1); \4e15 -NumA(Size-1-16):= ^4; -Int2Big(550, NumB, Size-1); \* 5.50 -BigMul(NumA, NumB); - -Int2Big(286*2, NumB, Size-1); \+ 2*2.86 -BigAdd(NumA, NumB); -Text(0, "Total price before tax : "); -DolOut(NumA); CrLf(0); -StrCopy(NumC, NumA); \save sub-total - -Int2Big(765, NumB, Size-1); \* 7.65% tax -BigMul(NumA, NumB); -Int2Big(5000, NumB, Size-1); \round up -BigAdd(NumA, NumB); -BigDiv(NumA, 10_000); \truncate -Text(0, "Tax : "); -DolOut(NumA); CrLf(0); - -BigAdd(NumA, NumC); \total = tax + sub-total -Text(0, "Total price after tax : "); -DolOut(NumA); CrLf(0); -] diff --git a/Task/Currying/Ada/currying-1.adb b/Task/Currying/Ada/currying-1.ada similarity index 100% rename from Task/Currying/Ada/currying-1.adb rename to Task/Currying/Ada/currying-1.ada diff --git a/Task/Currying/Ada/currying-2.adb b/Task/Currying/Ada/currying-2.ada similarity index 100% rename from Task/Currying/Ada/currying-2.adb rename to Task/Currying/Ada/currying-2.ada diff --git a/Task/Currying/Ada/currying-3.adb b/Task/Currying/Ada/currying-3.ada similarity index 100% rename from Task/Currying/Ada/currying-3.adb rename to Task/Currying/Ada/currying-3.ada diff --git a/Task/Currying/ArkScript/currying.ark b/Task/Currying/ArkScript/currying.ark deleted file mode 100644 index 0899898e22..0000000000 --- a/Task/Currying/ArkScript/currying.ark +++ /dev/null @@ -1,7 +0,0 @@ -(let addN (fun (n) - (fun (x &n) - (+ x n)))) - -(let add2 (addN 2)) -(print (type add2)) -(assert (= 7 (add2 5)) "add2 5 is 7") diff --git a/Task/Currying/Ballerina/currying.ballerina b/Task/Currying/Ballerina/currying.ballerina deleted file mode 100644 index 714a8b83de..0000000000 --- a/Task/Currying/Ballerina/currying.ballerina +++ /dev/null @@ -1,12 +0,0 @@ -import ballerina/io; - -public function main() { - var addN = function(int n) returns (function(int) returns int) { - return function(int x) returns int { - return n + x; - }; - }; - - var adder = addN(40); - io:println("The answer to life is ", adder(2), "."); -} diff --git a/Task/Currying/C/currying.c b/Task/Currying/C/currying.c index bd194c9730..aacae30da8 100644 --- a/Task/Currying/C/currying.c +++ b/Task/Currying/C/currying.c @@ -2,30 +2,30 @@ #include long int factorial(int n){ - if(n>1) - return n*factorial(n-1); - return 1; + if(n>1) + return n*factorial(n-1); + return 1; } long int sumOfFactorials(int num,...){ - va_list vaList; - long int sum = 0; - - va_start(vaList,num); - - while(num--) - sum += factorial(va_arg(vaList,int)); - - va_end(vaList); - - return sum; + va_list vaList; + long int sum = 0; + + va_start(vaList,num); + + while(num--) + sum += factorial(va_arg(vaList,int)); + + va_end(vaList); + + return sum; } int main() { - printf("\nSum of factorials of [1,5] : %ld",sumOfFactorials(5,1,2,3,4,5)); - printf("\nSum of factorials of [3,5] : %ld",sumOfFactorials(3,3,4,5)); - printf("\nSum of factorials of [1,3] : %ld",sumOfFactorials(3,1,2,3)); - - return 0; + printf("\nSum of factorials of [1,5] : %ld",sumOfFactorials(5,1,2,3,4,5)); + printf("\nSum of factorials of [3,5] : %ld",sumOfFactorials(3,3,4,5)); + printf("\nSum of factorials of [1,3] : %ld",sumOfFactorials(3,1,2,3)); + + return 0; } diff --git a/Task/Currying/Crystal/currying.cr b/Task/Currying/Crystal/currying.crystal similarity index 100% rename from Task/Currying/Crystal/currying.cr rename to Task/Currying/Crystal/currying.crystal diff --git a/Task/Currying/Delphi/currying.pas b/Task/Currying/Delphi/currying.delphi similarity index 100% rename from Task/Currying/Delphi/currying.pas rename to Task/Currying/Delphi/currying.delphi diff --git a/Task/Currying/EMal/currying.emal b/Task/Currying/EMal/currying.emal index ac271b3f13..a770597218 100644 --- a/Task/Currying/EMal/currying.emal +++ b/Task/Currying/EMal/currying.emal @@ -1,3 +1,7 @@ -fun plus ← % Usual curry curry(Fun,Arg) -> - case erlang:fun_info(Fun,arity) of - {arity,0} -> - erlang:error(badarg); - {arity,ArityFun} -> - create_ano_fun(ArityFun,Fun,Arg); - _ -> - erlang:error(badarg) - end. + case erlang:fun_info(Fun,arity) of + {arity,0} -> + erlang:error(badarg); + {arity,ArityFun} -> + create_ano_fun(ArityFun,Fun,Arg); + _ -> + erlang:error(badarg) + end. create_ano_fun(Arity,Fun,Arg) -> - Pars = - [{var,1,list_to_atom(lists:flatten(io_lib:format("X~p", [N])))} - || N <- lists:seq(2,Arity)], - Ano = - {'fun',1, - {clauses,[{clause,1,Pars,[], - [{call,1,{var,1,'Fun'},[{var,1,'Arg'}] ++ Pars}]}]}}, - {_,Result,_} = erl_eval:expr(Ano, [{'Arg',Arg},{'Fun',Fun}]), - Result. + Pars = + [{var,1,list_to_atom(lists:flatten(io_lib:format("X~p", [N])))} + || N <- lists:seq(2,Arity)], + Ano = + {'fun',1, + {clauses,[{clause,1,Pars,[], + [{call,1,{var,1,'Fun'},[{var,1,'Arg'}] ++ Pars}]}]}}, + {_,Result,_} = erl_eval:expr(Ano, [{'Arg',Arg},{'Fun',Fun}]), + Result. % Generalization of the currying diff --git a/Task/Currying/GDScript/currying.gd b/Task/Currying/GDScript/currying.gd index 4d6469e2c2..a18f432842 100644 --- a/Task/Currying/GDScript/currying.gd +++ b/Task/Currying/GDScript/currying.gd @@ -1,12 +1,12 @@ extends Node func addN(n: int) -> Callable: - return func(x): - return n + x + return func(x): + return n + x func _ready(): - # Test currying - var add2 := addN(2) - print(add2.call(7)) + # Test currying + var add2 := addN(2) + print(add2.call(7)) - get_tree().quit() # Exit + get_tree().quit() # Exit diff --git a/Task/Currying/Io/currying.io b/Task/Currying/Io/currying.io index 3f57440bae..e36f98ca20 100644 --- a/Task/Currying/Io/currying.io +++ b/Task/Currying/Io/currying.io @@ -1,9 +1,9 @@ curry := method(fn, - a := call evalArgs slice(1) - block( - b := a clone appendSeq(call evalArgs) - performWithArgList("fn", b) - ) + a := call evalArgs slice(1) + block( + b := a clone appendSeq(call evalArgs) + performWithArgList("fn", b) + ) ) // example: diff --git a/Task/Currying/Java/currying-2.java b/Task/Currying/Java/currying-2.java index 81f167fbcc..646e78ed5a 100644 --- a/Task/Currying/Java/currying-2.java +++ b/Task/Currying/Java/currying-2.java @@ -2,33 +2,33 @@ import java.util.function.BiFunction; import java.util.function.Function; public class Curry { + + //Curry a method + public static Function> curry(BiFunction biFunction) { + return t -> u -> biFunction.apply(t, u); + } + + public static int add(int x, int y) { + return x + y; + } + + public static void curryMethod() { + BiFunction bif = Curry::add; + Function> add = curry(bif); + Function add5 = add.apply(5); + System.out.println(add5.apply(2)); + } - //Curry a method - public static Function> curry(BiFunction biFunction) { - return t -> u -> biFunction.apply(t, u); - } - - public static int add(int x, int y) { - return x + y; - } - - public static void curryMethod() { - BiFunction bif = Curry::add; - Function> add = curry(bif); - Function add5 = add.apply(5); - System.out.println(add5.apply(2)); - } - - //Or declare the curried function in one line - public static void curryDirectly() { - Function> add = x -> y -> x + y; - Function add5 = add.apply(5); - System.out.println(add5.apply(2)); - } - - //prints 7 and 7 - public static void main(String[] args) { - curryMethod(); - curryDirectly(); - } + //Or declare the curried function in one line + public static void curryDirectly() { + Function> add = x -> y -> x + y; + Function add5 = add.apply(5); + System.out.println(add5.apply(2)); + } + + //prints 7 and 7 + public static void main(String[] args) { + curryMethod(); + curryDirectly(); + } } diff --git a/Task/Currying/Julia/currying-2.jl b/Task/Currying/Julia/currying-2.jl deleted file mode 100644 index 9638ad02a4..0000000000 --- a/Task/Currying/Julia/currying-2.jl +++ /dev/null @@ -1 +0,0 @@ -addN(n) = x -> n + x diff --git a/Task/Currying/Julia/currying-1.jl b/Task/Currying/Julia/currying.julia similarity index 100% rename from Task/Currying/Julia/currying-1.jl rename to Task/Currying/Julia/currying.julia diff --git a/Task/Currying/Kotlin/currying.kts b/Task/Currying/Kotlin/currying.kotlin similarity index 100% rename from Task/Currying/Kotlin/currying.kts rename to Task/Currying/Kotlin/currying.kotlin diff --git a/Task/Currying/M2000-Interpreter/currying-1.m2000 b/Task/Currying/M2000-Interpreter/currying-1.m2000 new file mode 100644 index 0000000000..fa7e6533d1 --- /dev/null +++ b/Task/Currying/M2000-Interpreter/currying-1.m2000 @@ -0,0 +1,42 @@ +Module LikeGroovy { + divide=lambda (x, y)->x/y + partsof120=lambda divide ->divide(120, ![]) + Print "half of 120 is ";partsof120(2) + Print "a third is ";partsof120(3) + Print "and a quarter is ";partsof120(4) +} +LikeGroovy + +Module Joke { + \\ we can call F1(), with any number of arguments, and always read one and then + \\ call itself passing the remain arguments + \\ ![] take stack of values and place it in the next call. + F1=lambda -> { + if empty then exit + Read x + =x+lambda(![]) + } + + Print F1(F1(2),2,F1(-4))=0 + Print F1(-4,F1(2),2)=0 + Print F1(2, F1(F1(2),2))=F1(F1(F1(2),2),2) + Print F1(F1(F1(2),2),2)=6 + Print F1(2, F1(2, F1(2),2))=F1(F1(F1(2),2, F1(2)),2) + Print F1(F1(F1(2),2, F1(2)),2)=8 + Print F1(2, F1(10, F1(2, F1(2),2)))=F1(F1(F1(2),2, F1(2)),2, 10) + Print F1(F1(F1(2),2, F1(2)),2, 10)=18 + Print F1(2,2,2,2,10)=18 + Print F1()=0 + + Group F2 { + Sum=0 + Function Add (x){ + .Sum+=x + =x + } + } + Link F2.Add() to F2() + Print F1(F1(F1(F2(2)),F2(2), F1(F2(2))),F2(2))=8 + Print F2.Sum=8 +} +Joke diff --git a/Task/Currying/M2000-Interpreter/currying-2.m2000 b/Task/Currying/M2000-Interpreter/currying-2.m2000 new file mode 100644 index 0000000000..b8aaf91170 --- /dev/null +++ b/Task/Currying/M2000-Interpreter/currying-2.m2000 @@ -0,0 +1,26 @@ +Module Puzzle { + Global Group F2 { + Sum=0 + Sum2=0 + Function Add (x){ + .Sum+=x + =x + } + } + F1=lambda -> { + if empty then exit + Read x + Print ">>>", F2.Sum + F2.Sum2++ ' add one each time we read x + =x+lambda(![]) + } + Link F2.Add() to F2() + P=F1(F1(F1(F2(2)),F2(2), F1(F2(2))),F2(2))=8 + Print F2.Sum=8 + Print F2.Sum2=7 + \\ We read 7 times x, but we get 8, 2+2+2+2 + \\ So 3 times x was zero, or not? + \\ but where we pass zero? + \\ zero return from F1 if no argument pass, so how x get zero?? +} +Puzzle diff --git a/Task/Currying/M2000-Interpreter/currying.m2000 b/Task/Currying/M2000-Interpreter/currying.m2000 deleted file mode 100644 index 9fcd80602b..0000000000 --- a/Task/Currying/M2000-Interpreter/currying.m2000 +++ /dev/null @@ -1,59 +0,0 @@ -Module LikeGroovy { - divide=lambda (x, y)->x/y - Curry=lambda (f as lambda, k)->(lambda f, k ->(f(k,![]))) - partsof120=Curry(divide, 120) - Print "half of 120 is ";partsof120(2) - Print "a third is ";partsof120(3) - Print "and a quarter is ";partsof120(4) - - joinTwoWordsWithSymbol=lambda (s, a, b)->a+s+b - Assert joinTwoWordsWithSymbol("#","Hello", "World")="Hello#World" - concatWords =Curry(joinTwoWordsWithSymbol, " ") - Assert concatWords("Hello", "World")="Hello World" - prependHello =Curry(concatWords, "Hello") - Assert prependHello("World")="Hello World" - Print "done" -} -LikeGroovy -Module M2000way { - class curry{ - private: - p=stack ' stack of values - func$ ' field for the weak reference - public: - property counter {value } ' readonly - class: - module curry(.func$) { - .p<=[] - class value { - value () { - ' symbol ! used for feeding stack of values from arrays or stacks. - ' [] is the current stack (leave emtpy stack as current stack) - ' Stack(.p) make a copy of .p (which have a stack object) - =function(.func$, !stack(.p), ![]) - .[counter]++ - } - } - this=value() ' make this as a property - } - } - ' using a general function - Function Divide(a, b) { - =a/b - } - Print "Divide(10, 6) is ";Divide(10, 5) - partsof120=Curry(&Divide(), 120) - Print "half of 120 is ";partsof120(2) - Print "a third is ";partsof120(3) - Print "and a quarter is ";partsof120(4) - Print "Use of partsof120 so far: "; partsof120.counter; " times" - ' using a lambda function - joinTwoWordsWithSymbol=lambda (s, a, b)->a+s+b - Assert joinTwoWordsWithSymbol("#","Hello", "World")="Hello#World" - concatWords =Curry(&joinTwoWordsWithSymbol, " ") - Assert concatWords("Hello", "World")="Hello World" - prependHello =Curry(&concatWords, "Hello") - Assert prependHello("World")="Hello World" - Print "done" -} -M2000way diff --git a/Task/Currying/MiniScript/currying.mini b/Task/Currying/MiniScript/currying.mini deleted file mode 100644 index b832d049f5..0000000000 --- a/Task/Currying/MiniScript/currying.mini +++ /dev/null @@ -1,9 +0,0 @@ -addN = function(n) - f = function(x) - return n + x - end function - return @f -end function - -adder = addN(40) -print "The answer to life is " + adder(2) + "." diff --git a/Task/Currying/Nemerle/currying.nemerle b/Task/Currying/Nemerle/currying.nemerle index 6746d65837..6de425618f 100644 --- a/Task/Currying/Nemerle/currying.nemerle +++ b/Task/Currying/Nemerle/currying.nemerle @@ -11,10 +11,10 @@ module Curry Main() : void { def f(x, y) { x + y } - def g = Curry(f); - def h = Curry(f)(12); // partial application - WriteLine($"$(Curry(f)(20)(22))"); - WriteLine($"$(g(21)(21))"); - WriteLine($"$(h(30))") + def g = Curry(f); + def h = Curry(f)(12); // partial application + WriteLine($"$(Curry(f)(20)(22))"); + WriteLine($"$(g(21)(21))"); + WriteLine($"$(h(30))") } } diff --git a/Task/Currying/OCaml/currying-1.ml b/Task/Currying/OCaml/currying-1.ocaml similarity index 100% rename from Task/Currying/OCaml/currying-1.ml rename to Task/Currying/OCaml/currying-1.ocaml diff --git a/Task/Currying/OCaml/currying-2.ml b/Task/Currying/OCaml/currying-2.ocaml similarity index 100% rename from Task/Currying/OCaml/currying-2.ml rename to Task/Currying/OCaml/currying-2.ocaml diff --git a/Task/Currying/Pluto/currying.pluto b/Task/Currying/Pluto/currying.pluto deleted file mode 100644 index cdee46cfb4..0000000000 --- a/Task/Currying/Pluto/currying.pluto +++ /dev/null @@ -1,4 +0,0 @@ -local function add_n(n) return |x| -> n + x end - -local adder = add_n(40) -print($"The answer to life is {adder(2)}.") diff --git a/Task/Currying/PowerShell/currying-1.ps1 b/Task/Currying/PowerShell/currying-1.psh similarity index 100% rename from Task/Currying/PowerShell/currying-1.ps1 rename to Task/Currying/PowerShell/currying-1.psh diff --git a/Task/Currying/PowerShell/currying-2.ps1 b/Task/Currying/PowerShell/currying-2.psh similarity index 100% rename from Task/Currying/PowerShell/currying-2.ps1 rename to Task/Currying/PowerShell/currying-2.psh diff --git a/Task/Currying/PowerShell/currying-3.ps1 b/Task/Currying/PowerShell/currying-3.psh similarity index 100% rename from Task/Currying/PowerShell/currying-3.ps1 rename to Task/Currying/PowerShell/currying-3.psh diff --git a/Task/Currying/REXX/currying-1.rexx b/Task/Currying/REXX/currying-1.rexx index a093789e19..84bc46cea6 100644 --- a/Task/Currying/REXX/currying-1.rexx +++ b/Task/Currying/REXX/currying-1.rexx @@ -1,13 +1,7 @@ /*REXX program demonstrates a REXX currying method to perform addition. */ -say 'add 2 to 3: ' add(2,3) -say 'add 2 to 3 (curried):' add2(3) +say 'add 2 to 3: ' add(2, 3) +say 'add 2 to 3 (curried):' add2(3) exit /*stick a fork in it, we're all done. */ -/*--------------------------------------------------------------------------------------*/ -add: procedure - sum=arg(1) - do j=2 to arg() - sum=sum+arg(j) - end - return sum -add2: procedure - return add(arg(1),2) +/*──────────────────────────────────────────────────────────────────────────────────────*/ +add: procedure; $= arg(1); do j=2 to arg(); $= $ + arg(j); end; return $ +add2: procedure; return add( arg(1), 2) diff --git a/Task/Currying/REXX/currying-2.rexx b/Task/Currying/REXX/currying-2.rexx index 7fc0d1524d..abc0c1858c 100644 --- a/Task/Currying/REXX/currying-2.rexx +++ b/Task/Currying/REXX/currying-2.rexx @@ -1,16 +1,12 @@ /*REXX program demonstrates a REXX currying method to perform addition. */ -say 'add 2 to 3: ' add(2, 3) -say 'add 2 to 3 (curried):' add2(3) +say 'add 2 to 3: ' add(2, 3) +say 'add 2 to 3 (curried):' add2(3) exit /*stick a fork in it, we're all done. */ -/*--------------------------------------------------------------------------------------*/ -add: procedure - sum=0 - do j=1 for arg() - do k=1 for words(arg(j)) - sum=sum+word(arg(j),k) - end /*k*/ - end /*j*/ - return sum -/*--------------------------------------------------------------------------------------*/ -add2: procedure - return add(arg(1),2) +/*──────────────────────────────────────────────────────────────────────────────────────*/ +add: procedure; $= 0; do j=1 for arg() + do k=1 for words( arg(j) ); $= $ + word( arg(j), k) + end /*k*/ + end /*j*/ + return $ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +add2: procedure; return add( arg(1), 2) diff --git a/Task/Currying/Rebol/currying.rebol b/Task/Currying/Rebol/currying.rebol deleted file mode 100644 index 5c62106262..0000000000 --- a/Task/Currying/Rebol/currying.rebol +++ /dev/null @@ -1,19 +0,0 @@ -;; Based on the Red language solution bellow. -make-curry: func[ - "Define a custome simple currying function" - 'fn [word!] - x -][ - do compose/deep [ - func [ - (reform ["currying function:" form fn x "y"]) - y - ][ do compose [(get fn) (x) y]] - ] -] -add2: make-curry add 2 -add3: make-curry add 3 -print add2 7 -print add3 7 -print "^/Help output:" -help add3 diff --git a/Task/Currying/Red/currying.red b/Task/Currying/Red/currying.red deleted file mode 100644 index cd5379329e..0000000000 --- a/Task/Currying/Red/currying.red +++ /dev/null @@ -1,96 +0,0 @@ -Red [ "Real Currying in Red - Hinjolicious" ] - -; helper func -get-args: function [f][ - collect [foreach e spec-of :f [ - if refinement? e [break] - if any [word? e lit-word? e] [keep e] - ]] -] - -; currying -curry: function [f v][ - f?: function? :f ; a func? - ff: either f? [:f][get f] ; get func directly or by its name - - sp: spec-of :ff ; raw spec - a: get-args :ff ; cleaned args - - ; curried? get skip counter - sc: either c?: sp/1 = "C!" [to-integer sp/2][0] - - ca: copy a na: copy a - - either v = [] [ ; skipping - sc: sc + 1 ; spec unchanged - ][ - either sc > 0 [ ; skip some args - remove skip ca sc ; removed curried arg from spec - na/(sc + 1): v ; replace with value - na: skip na sc a: skip a sc ; point to next args - ][ ; normal - ca: next ca ; skip curried arg - na/1: v ; replace with value - ] - ] - - ; add marker and counter - f: func compose ["C!" (to-string sc) (ca)] either c? [ ; curried? - replace copy body-of :ff a na ; chained curry - ][ - compose [(:f)(na)] ; first curry - ] - either empty? ca [f][:f] ; return function or result -] - -->: make op! :curry ; curry operator - -; This function will print a string as a heading and print any codes -; to the screen before executing it. -demo: function [s b] [print ["^/==" s "==^/^/" mold/only b "^/>>"] do b] - -demo "Real Currying in Red" [ - -sum: func [a b c][a + b + c] ; -] - -demo "Curry one arg from 'sum', return func with two args (s1)" [ -s1: 'sum -> 1 -print s1 2 3 ; 6 -] - -demo "Curry one arg from 's2', return func with one arg (s2)" [ -s2: 's1 -> 2 -print s2 3 ; 6 -] - -demo "Curry one arg from 's3', return the result" [ -s3: 's2 -> 3 -print s3 ; 6 -] - -demo "Currying all args at once, return the result" [ -print 'sum -> 1 -> 2 -> 3 ; 6 -] - -demo "Currying native control" [ -i: 1 -'while -> [i <= 10] -> [print i i: i + 1] -] - -demo "Currying native control" [ -'repeat -> 'i -> 10 -> [print ["repeating" i]] -] - -demo "Currying anonymous function (lambda)" [ -print (func [a b][a + b]) -> 10 -> 20 ; 30 -] - -demo "Skipping args" [ -f: 'sum -> [] -> [] -> 30 -print f 10 20 -] - -demo "Sample generated code" [ -?? f -] diff --git a/Task/Currying/Rust/currying.rs b/Task/Currying/Rust/currying.rust similarity index 100% rename from Task/Currying/Rust/currying.rs rename to Task/Currying/Rust/currying.rust diff --git a/Task/Curzon-numbers/ALGOL-68/curzon-numbers.alg b/Task/Curzon-numbers/ALGOL-68/curzon-numbers.alg index 67e0b873b7..a2e3971cb0 100644 --- a/Task/Curzon-numbers/ALGOL-68/curzon-numbers.alg +++ b/Task/Curzon-numbers/ALGOL-68/curzon-numbers.alg @@ -5,13 +5,13 @@ BEGIN # find some generalised Curzon numbers - translation of the C++ sample # ELSE LONG INT result := 1; LONG INT base := rqd base MOD mod; - LONG INT ex := rqd exp; - WHILE ex > 0 DO - IF ODD ex THEN + LONG INT exp := rqd exp; + WHILE exp > 0 DO + IF ODD exp THEN result TIMESAB base MODAB mod FI; base TIMESAB base MODAB mod; - ex OVERAB 2 + exp OVERAB 2 OD; result FI # modpow # ; @@ -20,7 +20,7 @@ BEGIN # find some generalised Curzon numbers - translation of the C++ sample # BEGIN LONG INT m = k * n + 1; modpow( k, n, m ) + 1 = m - END # is curzon # ; + END # is curon # ; FOR k FROM 2 BY 2 TO 10 DO print( ( "Curzon numbers with base ", whole( k, 0 ), ":", newline ) ); diff --git a/Task/Curzon-numbers/Ada/curzon-numbers.adb b/Task/Curzon-numbers/Ada/curzon-numbers.adb deleted file mode 100644 index 31133f80d5..0000000000 --- a/Task/Curzon-numbers/Ada/curzon-numbers.adb +++ /dev/null @@ -1,57 +0,0 @@ -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Long_Long_Integer_Text_IO; use Ada.Long_Long_Integer_Text_IO; - -procedure Curzon is - - function Mod_Pow(Base, Exp, Modulo : Long_Long_Integer) return Long_Long_Integer is - Result : Long_Long_Integer := 1; - B : Long_Long_Integer := Base mod Modulo; - E : Long_Long_Integer := Exp; - begin - if Modulo = 1 then return 0; end if; - - while E > 0 loop - if (E mod 2) = 1 then - Result := (Result * B) mod Modulo; - end if; - B := (B * B) mod Modulo; - E := E / 2; - end loop; - - return Result; - end Mod_Pow; - - function Curzon_Check(K, N : Long_Long_Integer) return Boolean is - R : Long_Long_Integer := K * N; - begin - return Mod_Pow(K, N, R + 1) = R; - end Curzon_Check; - - N : Long_Long_Integer; - Count : Integer; - -begin - for K in Long_Long_Integer range 2..10 when K mod 2 = 0 loop - Put("The first 50 Curzon numbers of base "); Put(K, 1); Put(":"); New_Line; - N := 1; - Count := 1; - while Count <= 1000 loop - if Curzon_Check(K, N) then - if Count <= 50 then - Put(N, 4); - if Count mod 10 = 0 then - New_Line; - else - Put(" "); - end if; - end if; - if Count = 1000 then - Put("The 1000th Curzon number of base "); Put(K, 1); Put(": "); Put(N, 5); - New_Line(2); - end if; - Count := @ + 1; - end if; - N := @ + 1; - end loop; - end loop; -end Curzon; diff --git a/Task/Curzon-numbers/Arturo/curzon-numbers.arturo b/Task/Curzon-numbers/Arturo/curzon-numbers.arturo index bf2b21b54d..3b5d0dc511 100644 --- a/Task/Curzon-numbers/Arturo/curzon-numbers.arturo +++ b/Task/Curzon-numbers/Arturo/curzon-numbers.arturo @@ -1,12 +1,24 @@ -curzon?: function [n,base] -> +curzon?: function [n,base]-> zero? (inc base^n) % inc base*n first50: function [b][ - select.first:50 1..∞ 'i -> curzon? i b + result: new [] + i: 1 + while [50 > size result][ + if curzon? i b -> 'result ++ i + i: i + 1 + ] + return result ] oneThousandth: function [b][ - select.n:1000 1..∞ 'i -> curzon? i b + cnt: 0 + i: 1 + while [cnt < 1000][ + if curzon? i b -> cnt: cnt+1 + i: i + 1 + ] + return dec i ] loop select 2..10 => even? 'withBase [ diff --git a/Task/Curzon-numbers/EasyLang/curzon-numbers.easy b/Task/Curzon-numbers/EasyLang/curzon-numbers.easy deleted file mode 100644 index 4af14d89ff..0000000000 --- a/Task/Curzon-numbers/EasyLang/curzon-numbers.easy +++ /dev/null @@ -1,33 +0,0 @@ -func pow_mod b power modulus . - x = 1 - while power > 0 - if power mod 2 = 1 - x = x * b mod modulus - . - b = b * b mod modulus - power = power div 2 - . - return x -. -for k = 2 step 2 to 10 - numfmt 0 0 - print "First 50 Curzon numbers using a base of " & k & ":" - numfmt 4 0 - n = 1 - count = 0 - repeat - m = k * n + 1 - p = pow_mod k n m + 1 - if p = m - count += 1 - if count <= 50 - write " " & n - if count mod 9 = 0 : print "" - . - . - until count = 1000 - n += 1 - . - print "" ; print "One thousandth: " & n - print "" -. diff --git a/Task/Curzon-numbers/Fortran/curzon-numbers.f b/Task/Curzon-numbers/Fortran/curzon-numbers.f deleted file mode 100644 index 7f03146a4a..0000000000 --- a/Task/Curzon-numbers/Fortran/curzon-numbers.f +++ /dev/null @@ -1,72 +0,0 @@ -! -! Curzon Numbers -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.04 -! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 -! No Non-standard features used, should compile on any fairly recent Fortran. -! U.B., September 2025 -! -program Curzon - - implicit none - - integer, parameter :: kint = 8 ! 8-byte-integers are big enough, 4 bytes is insufficient. - - integer (kind=kint) :: base, num, count - - do base=2,10,2 - print ("( 'Curzon numbers with base ', i2,':')"), base - count = 0 - num = 1 - do while (count .lt. 50) - if (isCurzon (num, base)) then - count = count + 1 - write (*, '(i5)', advance='no') num - if (mod (count, 10) .eq. 0 ) write (*,*) ! EOL - end if - num = num + 1 - end do - do - if (isCurzon (num,base)) then - count = count + 1 - if (count .eq. 1000) exit - endif - num = num + 1 - end do - print ("('1000th Curzon number with base ', i0, ': ', i0/)") , base, num - - end do - - contains - - - function isCurzon (n, k) result (YN) - - integer(kind=kint), intent(in) :: n,k - integer(kind=kint) :: m, p - logical :: YN - - m = k*n+1 - p = ModularExp (k,n,m) + 1 - YN = m .eq. p - - end function isCurzon - - function ModularExp(a, b, n) result(d) - - integer(kind=kint) , intent(in) :: a,b,n - integer (kind=kint) :: d - integer (kind=kint) :: i, k - d = 1 - k = 0 - do while (ishft (b, -k) .gt. 0) - k = k + 1 - end do - do i = k - 1, 0, -1 - d = mod (d*d, n) - if (iand (ishft (b, -i) , 1_kint) .gt. 0) d = mod (d*a ,n); - end do - - end function ModularExp - -end program Curzon diff --git a/Task/Curzon-numbers/FutureBasic/curzon-numbers.basic b/Task/Curzon-numbers/FutureBasic/curzon-numbers.basic deleted file mode 100644 index 8582321486..0000000000 --- a/Task/Curzon-numbers/FutureBasic/curzon-numbers.basic +++ /dev/null @@ -1,48 +0,0 @@ -include "NSLog.incl" -_thereIsHope = _true -nsLogSetTitle(@"Curzon numbers in Futurebasic") -NumberFormatterRef form : form = fn NumberFormatterInit -NumberFormatterSetPositiveFormat( form, @"#,###,###" ) - -local fn comma( n as uint32, pad as byte )as CFStringRef - CFStringRef s = fn NumberFormatterStringFromNumber( form,¬ - fn NumberWithInteger( n ) ) -end fn = fn StringWithFormat(@"%@%@", right(@" ", pad-len(s)), s) - -local fn powMod(b as uint64, p as uint64, m as uint64) as uint64 - uint64 x = 1 - while p - if (p & 1) then x = (x * b) % m - b = (b * b) % m - p = p >> 1 - wend -end fn = x - -local fn curzon - CFStringRef s - uint64 k, n, kn1, count - - for k = 2 to 12 step 2 - n = 1 : count = 0 : kn1 = k * n + 1 : s = @"" - NSLog( @"\n First 50 Curzon numbers with base = %d:", k ) - - while _thereIsHope - if fn powMod(k, n, kn1) + 1 == kn1 - count ++ - select count - case <= 50 : s = fn StringWithFormat(@"%@%@", s, fn comma(n, 7)) - if (count Mod 10) = 0 Then s = fn StringWithFormat(@"%@\n", s) - case 1000 : nslog( @"%@ 1,000th: %@", s, fn comma(n, 0)) - break - end select - end if - n++ : kn1 += k - wend - - next - -end fn - -fn curzon - -handleevents diff --git a/Task/Curzon-numbers/Icon/curzon-numbers.icon b/Task/Curzon-numbers/Icon/curzon-numbers.icon deleted file mode 100644 index 6b7af7dfe8..0000000000 --- a/Task/Curzon-numbers/Icon/curzon-numbers.icon +++ /dev/null @@ -1,18 +0,0 @@ -procedure main(A) - limit := \A[1] | 50 - every b := 2 to 10 by 2 do { - writes("Base integer ",b,":") - every (cnt := 0, n := curzon(b)\1000, cnt +:= 1) do - if cnt <= 50 then writes(" ",n) - write("\n\t1000th Curzon number is ",n) - write("\n") - } -end - -procedure curzon(b) - every n := seq() do { - x := b^n+1 - y := b*n+1 - suspend ((x/y)*y = x, n) - } -end diff --git a/Task/Curzon-numbers/Java/curzon-numbers.java b/Task/Curzon-numbers/Java/curzon-numbers.java deleted file mode 100644 index 0f4634296f..0000000000 --- a/Task/Curzon-numbers/Java/curzon-numbers.java +++ /dev/null @@ -1,48 +0,0 @@ -public final class CurzonNumbers { - - public static void main(String[] aArgs) { - for ( int k = 2; k <= 10; k += 2 ) { - System.out.println("Generalised Curzon numbers with base " + k + ":"); - int n = 1; - int count = 0; - while ( count < 50 ) { - if ( isGeneralisedCurzonNumber(k, n) ) { - System.out.print(String.format("%4d%s", n, ( ++count % 10 == 0 ? "\n" : " " ))); - } - n += 1; - } - - while ( count < 1_000 ) { - if ( isGeneralisedCurzonNumber(k, n) ) { - count += 1; - } - n += 1; - } - System.out.println("1,000th Generalised Curzon number with base " + k + ": " + ( n - 1 )); - System.out.println(); - } - } - - private static boolean isGeneralisedCurzonNumber(int aK, int aN) { - final long r = aK * aN; - return modulusPower(aK, aN, r + 1) == r; - } - - private static long modulusPower(long aBase, long aExponent, long aModulus) { - if ( aModulus == 1 ) { - return 0; - } - - aBase %= aModulus; - long result = 1; - while ( aExponent > 0 ) { - if ( ( aExponent & 1 ) == 1 ) { - result = ( result * aBase ) % aModulus; - } - aBase = ( aBase * aBase ) % aModulus; - aExponent >>= 1; - } - return result; - } - -} diff --git a/Task/Curzon-numbers/JavaScript/curzon-numbers.js b/Task/Curzon-numbers/JavaScript/curzon-numbers.js deleted file mode 100644 index d267fa088f..0000000000 --- a/Task/Curzon-numbers/JavaScript/curzon-numbers.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Curzon Numbers - * - * A generalized Curzon number is a positive integer n such that: - * k^n + 1 is divisible by (k * n + 1) - * For k = 2, this gives the classic definition of Curzon numbers - */ - -function isGeneralisedCurzonNumber(aK, aN) { - const r = aK * aN; - return modulusPower(aK, aN, r + 1) === r; -} - -function modulusPower(aBase, aExponent, aModulus) { - if (aModulus === 1) { - return 0; - } - - aBase %= aModulus; - let result = 1; - while (aExponent > 0) { - if ((aExponent & 1) === 1) { - result = (result * aBase) % aModulus; - } - aBase = (aBase * aBase) % aModulus; - aExponent >>= 1; - } - return result; -} - -function main() { - for (let k = 2; k <= 10; k += 2) { - console.log(`Generalised Curzon numbers with base ${k}:`); - - let n = 1; - let count = 0; - const results = []; - - // Find the first 50 Curzon numbers - while (count < 50) { - if (isGeneralisedCurzonNumber(k, n)) { - results.push(n); - count++; - } - n++; - } - - // Print in rows of 10 - for (let i = 0; i < results.length; i++) { - const lineEnd = (i + 1) % 10 === 0 ? '\n' : ' '; - process.stdout.write(`${results[i].toString().padStart(4)}${lineEnd}`); - } - - // Reset and find the 1000th Curzon number - count = 0; - while (count < 1000) { - if (isGeneralisedCurzonNumber(k, n)) { - count++; - } - n++; - } - - console.log(`1,000th Generalised Curzon number with base ${k}: ${n - 1}`); - console.log(); - } -} - -main(); diff --git a/Task/Curzon-numbers/Julia/curzon-numbers.jl b/Task/Curzon-numbers/Julia/curzon-numbers.julia similarity index 100% rename from Task/Curzon-numbers/Julia/curzon-numbers.jl rename to Task/Curzon-numbers/Julia/curzon-numbers.julia diff --git a/Task/Curzon-numbers/Maxima/curzon-numbers.maxima b/Task/Curzon-numbers/Maxima/curzon-numbers.maxima deleted file mode 100644 index 13c4a5da31..0000000000 --- a/Task/Curzon-numbers/Maxima/curzon-numbers.maxima +++ /dev/null @@ -1,15 +0,0 @@ -/* Predicate function that checks wether a positive integer is generalized k-Curzon number or not */ -g_curzonp(n,k):=if mod((k^n)+1,k*n+1)=0 then true$ - -/* Function that returns a list of the first len generalized k-Curzon numbers */ -g_curzon_count(len,k):=block( - [i:1,count:0,result:[]], - while count int { - if mod == 1 { - return 0} - result: int = 1 - base := base - exp := exp - base %= mod - for ; exp > 0; exp >>= 1 { - if ((exp & 1) == 1) { - result = (result * base) % mod} - base = (base * base) % mod - } - return result -} - -is_curzon :: proc(n: int, k: int) -> bool { - r := k * n //const? - return modpow(k, n, r + 1) == r -} diff --git a/Task/Curzon-numbers/PARI-GP/curzon-numbers.parigp b/Task/Curzon-numbers/PARI-GP/curzon-numbers.parigp deleted file mode 100644 index a797abc6a7..0000000000 --- a/Task/Curzon-numbers/PARI-GP/curzon-numbers.parigp +++ /dev/null @@ -1,39 +0,0 @@ -/* Define the CurzonNumberQ function for base b */ -powermod(a,k,n)=lift(Mod(a,n)^k) -CurzonNumberQ(b, n) = (powermod(b,n,b*n+1)== b*n); - -/* Define a function to find Curzon numbers within a range for base b */ -FindCurzonNumbers(b, maxrange) = { - local(val, res, i); - val = vector(maxrange); - res = []; - for(i = 1, maxrange, - if(CurzonNumberQ(b, i), res = concat(res, i)); - ); - return(Vec(res)); -} - -/* Select and display the first 50 Curzon numbers and the 1000th for base 2 */ -val = FindCurzonNumbers(2, 100000); -print(vector(50, i, val[i])); /* First 50 */ -print(val[1000]); /* 1000th Curzon number */ - -/* Select and display for base 4 */ -val = FindCurzonNumbers(4, 100000); -print(vector(50, i, val[i])); /* First 50 */ -print(val[1000]); /* 1000th Curzon number */ - -/* Select and display for base 6 */ -val = FindCurzonNumbers(6, 100000); -print(vector(50, i, val[i])); /* First 50 */ -print(val[1000]); /* 1000th Curzon number */ - -/* Select and display for base 8 */ -val = FindCurzonNumbers(8, 100000); -print(vector(50, i, val[i])); /* First 50 */ -print(val[1000]); /* 1000th Curzon number */ - -/* Select and display for base 10 */ -val = FindCurzonNumbers(10, 100000); -print(vector(50, i, val[i])); /* First 50 */ -print(val[1000]); /* 1000th Curzon number */ diff --git a/Task/Curzon-numbers/PascalABC.NET/curzon-numbers.pas b/Task/Curzon-numbers/PascalABC.NET/curzon-numbers.pas deleted file mode 100644 index abf583bd72..0000000000 --- a/Task/Curzon-numbers/PascalABC.NET/curzon-numbers.pas +++ /dev/null @@ -1,27 +0,0 @@ -## -function isCurzon(n: integer; k: biginteger) := (Power(k, n) + 1) mod (k * n + 1) = 0; - -function curzonnumbers(k: integer): sequence of integer; -begin - var n := 1; - while true do - begin - if iscurzon(n, k) then yield n; - n += 1; - end; -end; - -foreach var k in |2, 4, 6, 8, 10| do -begin - var i := 1; - println('Curzonnumbers with base', k); - foreach var n in curzonnumbers(k) do - begin - Write(n:5); - if (i mod 10) = 0 then println; - if i = 50 then break; - i += 1; - end; - println('1000th Curzon number', curzonnumbers(k).Skip(999).First); - println; -end; diff --git a/Task/Curzon-numbers/Pluto/curzon-numbers.pluto b/Task/Curzon-numbers/Pluto/curzon-numbers.pluto deleted file mode 100644 index 4f3877ba38..0000000000 --- a/Task/Curzon-numbers/Pluto/curzon-numbers.pluto +++ /dev/null @@ -1,27 +0,0 @@ -local int = require "int" -local fmt = require "fmt" - -local function is_curzon(n, k) - local r = k * n - return int.modpow(k, n, r+1) == r -end - -for k = 2, 10, 2 do - print($"The first 50 Curzon numbers with base {k}:") - local n = 1 - local count = 0 - while count < 50 do - if is_curzon(n, k) then - fmt.write("%4d ", n) - count += 1 - if count % 10 == 0 then print() end - end - n += 1 - end - while true do - if is_curzon(n, k) then count += 1 end - if count == 1000 then break end - n += 1 - end - fmt.print("\nOne thousandth: %s\n", fmt.int(n)) -end diff --git a/Task/Curzon-numbers/R/curzon-numbers.r b/Task/Curzon-numbers/R/curzon-numbers.r deleted file mode 100644 index 8a16e5057d..0000000000 --- a/Task/Curzon-numbers/R/curzon-numbers.r +++ /dev/null @@ -1,18 +0,0 @@ -library(gmp) - -first50curzons <- function(k){ - n <- 1 - big_k <- as.bigz(k) - curzons <- numeric(0) - while(length(curzons)<50){ - if(denominator((1+big_k^n)/(1+big_k*n))==1){ - curzons <- c(curzons, n) - } - n <- n+1 - } - return(curzons) -} - -curzons_list <- lapply(2*(1:5), first50curzons) -names(curzons_list) <- sapply(2*(1:5), function(k) paste("Base", k)) -print(curzons_list) diff --git a/Task/Curzon-numbers/Rust/curzon-numbers.rs b/Task/Curzon-numbers/Rust/curzon-numbers.rust similarity index 100% rename from Task/Curzon-numbers/Rust/curzon-numbers.rs rename to Task/Curzon-numbers/Rust/curzon-numbers.rust diff --git a/Task/Curzon-numbers/V-(Vlang)/curzon-numbers.v b/Task/Curzon-numbers/V-(Vlang)/curzon-numbers.v index e83025f01d..97ef9aecdd 100644 --- a/Task/Curzon-numbers/V-(Vlang)/curzon-numbers.v +++ b/Task/Curzon-numbers/V-(Vlang)/curzon-numbers.v @@ -15,12 +15,16 @@ fn main() { d := k*n + 1 bd := big.integer_from_i64(d) if z%bd == zero { - if count < 50 {curzon50 << n} + if count < 50 { + curzon50 << n + } count++ if count == 50 { for i in 0..curzon50.len { print("${curzon50[i]:4} ") - if (i+1)%10 == 0 {println("")} + if (i+1)%10 == 0 { + println('') + } } print("\nOne thousandth: ") } @@ -32,6 +36,6 @@ fn main() { n++ pow *= bk } - println("") + println('') } } diff --git a/Task/Curzon-numbers/Wren/curzon-numbers-1.wren b/Task/Curzon-numbers/Wren/curzon-numbers-1.wren index db5ed8a00b..293a579016 100644 --- a/Task/Curzon-numbers/Wren/curzon-numbers-1.wren +++ b/Task/Curzon-numbers/Wren/curzon-numbers-1.wren @@ -1,4 +1,4 @@ -/* Curzon_numbers.wren */ +/* curzon_numbers.wren */ import "./gmp" for Mpz import "./fmt" for Fmt diff --git a/Task/Cut-a-rectangle/11l/cut-a-rectangle.11l b/Task/Cut-a-rectangle/11l/cut-a-rectangle.11l index 8d7453b033..d4b659d834 100644 --- a/Task/Cut-a-rectangle/11l/cut-a-rectangle.11l +++ b/Task/Cut-a-rectangle/11l/cut-a-rectangle.11l @@ -19,7 +19,7 @@ F cut_it(=h, =w) V t = y * (@w + 1) + x @grid[t] = @grid[@blen - t] = 1B - L(i) 0.<4 + L(i) 4 I !@grid[t + @next[i]] count = @walk(y + @dirs[i][0], x + @dirs[i][1], count) diff --git a/Task/Cut-a-rectangle/C-sharp/cut-a-rectangle.cs b/Task/Cut-a-rectangle/C-sharp/cut-a-rectangle.cs deleted file mode 100644 index 7f89267214..0000000000 --- a/Task/Cut-a-rectangle/C-sharp/cut-a-rectangle.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; - -public class CutRectangle -{ - private static int[][] dirs = new int[][] { new int[] { 0, -1 }, new int[] { -1, 0 }, new int[] { 0, 1 }, new int[] { 1, 0 } }; - - public static void Main(string[] args) - { - CutRectangleMethod(2, 2); - CutRectangleMethod(4, 3); - } - - static void CutRectangleMethod(int w, int h) - { - if (w % 2 == 1 && h % 2 == 1) - return; - - int[,] grid = new int[h, w]; - Stack stack = new Stack(); - - int half = (w * h) / 2; - long bits = (long)Math.Pow(2, half) - 1; - - for (; bits > 0; bits -= 2) - { - for (int i = 0; i < half; i++) - { - int r = i / w; - int c = i % w; - grid[r, c] = (bits & (1L << i)) != 0 ? 1 : 0; - grid[h - r - 1, w - c - 1] = 1 - grid[r, c]; - } - - stack.Push(0); - grid[0, 0] = 2; - int count = 1; - while (stack.Count > 0) - { - int pos = stack.Pop(); - int r = pos / w; - int c = pos % w; - - foreach (var dir in dirs) - { - int nextR = r + dir[0]; - int nextC = c + dir[1]; - - if (nextR >= 0 && nextR < h && nextC >= 0 && nextC < w) - { - if (grid[nextR, nextC] == 1) - { - stack.Push(nextR * w + nextC); - grid[nextR, nextC] = 2; - count++; - } - } - } - } - if (count == half) - { - PrintResult(grid, h, w); - } - } - } - - static void PrintResult(int[,] arr, int height, int width) - { - for (int i = 0; i < height; i++) - { - for (int j = 0; j < width; j++) - { - Console.Write(arr[i, j] + (j == width - 1 ? "" : ", ")); - } - Console.WriteLine(); - } - Console.WriteLine(); - } -} diff --git a/Task/Cut-a-rectangle/Delphi/cut-a-rectangle.pas b/Task/Cut-a-rectangle/Delphi/cut-a-rectangle.delphi similarity index 100% rename from Task/Cut-a-rectangle/Delphi/cut-a-rectangle.pas rename to Task/Cut-a-rectangle/Delphi/cut-a-rectangle.delphi diff --git a/Task/Cut-a-rectangle/EasyLang/cut-a-rectangle.easy b/Task/Cut-a-rectangle/EasyLang/cut-a-rectangle.easy deleted file mode 100644 index fb028df61c..0000000000 --- a/Task/Cut-a-rectangle/EasyLang/cut-a-rectangle.easy +++ /dev/null @@ -1,74 +0,0 @@ -global grid[] blen w h cnt . -dir[][] = [ [ 0 -1 ] [ -1 0 ] [ 0 1 ] [ 1 0 ] ] -# -proc walk y x . - if y = 0 or y = h or x = 0 or x = w - cnt += 2 - return - . - t = y * (w + 1) + x - grid[t] += 1 - grid[blen - t] += 1 - for i to 4 - dx = dir[i][1] - dy = dir[i][2] - d = dx + dy * (w + 1) - if grid[t + d] = 0 - walk y + dy x + dx - . - . - grid[t] -= 1 - grid[blen - t] -= 1 -. -proc solve hh ww recur . - w = ww - h = hh - if h mod 2 = 1 : swap h w - if h mod 2 = 1 - cnt = 0 - return - . - if w = 1 - cnt = 1 - return - . - if w = 2 - cnt = h - return - . - if h = 2 - cnt = w - return - . - cy = h div 2 ; cx = w div 2 - blen = (h + 1) * (w + 1) - grid[] = [ ] - len grid[] blen - blen -= 1 - if recur = 1 - cnt = 0 - . - for x = cx + 1 to w - 1 - t = cy * (w + 1) + x - grid[t] = 1 - grid[blen - t] = 1 - walk cy - 1 x - . - cnt += 1 - if h = w - cnt *= 2 - elif w mod 2 = 0 and recur = 1 - solve w h 0 - . -. -proc main . - for y = 1 to 8 - for x = 1 to y - if x mod 2 = 0 or y mod 2 = 0 - solve y x 1 - print y & " x " & x & ": " & cnt - . - . - . -. -main diff --git a/Task/Cut-a-rectangle/Elixir/cut-a-rectangle-1.ex b/Task/Cut-a-rectangle/Elixir/cut-a-rectangle-1.elixir similarity index 100% rename from Task/Cut-a-rectangle/Elixir/cut-a-rectangle-1.ex rename to Task/Cut-a-rectangle/Elixir/cut-a-rectangle-1.elixir diff --git a/Task/Cut-a-rectangle/Elixir/cut-a-rectangle-2.ex b/Task/Cut-a-rectangle/Elixir/cut-a-rectangle-2.elixir similarity index 100% rename from Task/Cut-a-rectangle/Elixir/cut-a-rectangle-2.ex rename to Task/Cut-a-rectangle/Elixir/cut-a-rectangle-2.elixir diff --git a/Task/Cut-a-rectangle/FreeBASIC/cut-a-rectangle.basic b/Task/Cut-a-rectangle/FreeBASIC/cut-a-rectangle.basic deleted file mode 100644 index f5feed96bb..0000000000 --- a/Task/Cut-a-rectangle/FreeBASIC/cut-a-rectangle.basic +++ /dev/null @@ -1,77 +0,0 @@ -Dim Shared As Ubyte grilla() -Dim Shared As Integer ancho, alto, longitud -Dim Shared As Integer cnt -Dim Shared As Integer sgte(3) -Dim Shared As Integer direcc(3, 1) => {{0, -1}, {-1, 0}, {0, 1}, {1, 0}} - -Sub Camino(y As Integer, x As Integer) - If y = 0 Or y = alto Or x = 0 Or x = ancho Then - cnt += 2 - Return - End If - Dim As Integer t = y * (ancho + 1) + x - grilla(t) += 1 - grilla(longitud - t) += 1 - For i As Integer = 0 To 3 - If grilla(t + sgte(i)) = 0 Then Camino(y + direcc(i, 0), x + direcc(i, 1)) - Next - grilla(t) -= 1 - grilla(longitud - t) -= 1 -End Sub - -Function Solve(hh As Integer, ww As Integer, recur As Boolean) As Integer - alto = hh - ancho = ww - - If (alto And 1) <> 0 Then Swap alto, ancho - - Select Case True - Case (alto And 1) = 1 - Return 0 - Case ancho = 1 - Return 1 - Case ancho = 2 - Return alto - Case alto = 2 - Return ancho - End Select - - Dim As Integer cy = alto \ 2 - Dim As Integer cx = ancho \ 2 - - Redim grilla((alto + 1) * (ancho + 1)) - longitud = (alto + 1) * (ancho + 1) - 1 - sgte(0) = -1 - sgte(1) = -ancho - 1 - sgte(2) = 1 - sgte(3) = ancho + 1 - - If recur Then cnt = 0 - - For x As Integer = cx + 1 To ancho - 1 - Dim As Integer t = cy * (ancho + 1) + x - grilla(t) = 1 - grilla(longitud - t) = 1 - Camino(cy - 1, x) - Next - cnt += 1 - - If alto = ancho Then - cnt *= 2 - Elseif (ancho And 1) = 0 And recur Then - Solve(ancho, alto, 0) - End If - - Return cnt -End Function - -Dim As Integer y, x -For y = 1 To 10 - For x = 1 To y - If (x And 1) = 0 Or (y And 1) = 0 Then - Print Using "& x &: &"; y; x; Solve(y, x, True) - End If - Next -Next - -Sleep diff --git a/Task/Cut-a-rectangle/Julia/cut-a-rectangle.jl b/Task/Cut-a-rectangle/Julia/cut-a-rectangle.julia similarity index 100% rename from Task/Cut-a-rectangle/Julia/cut-a-rectangle.jl rename to Task/Cut-a-rectangle/Julia/cut-a-rectangle.julia diff --git a/Task/Cut-a-rectangle/Kotlin/cut-a-rectangle.kts b/Task/Cut-a-rectangle/Kotlin/cut-a-rectangle.kotlin similarity index 100% rename from Task/Cut-a-rectangle/Kotlin/cut-a-rectangle.kts rename to Task/Cut-a-rectangle/Kotlin/cut-a-rectangle.kotlin diff --git a/Task/Cut-a-rectangle/Pluto/cut-a-rectangle.pluto b/Task/Cut-a-rectangle/Pluto/cut-a-rectangle.pluto deleted file mode 100644 index cbb8e6370a..0000000000 --- a/Task/Cut-a-rectangle/Pluto/cut-a-rectangle.pluto +++ /dev/null @@ -1,68 +0,0 @@ -require "table2" -local fmt = require "fmt" - -local count = {0} -local dir = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}} - -local function walk(y, x, h, w, grid, len, nxt) - if y == 0 or y == h or x == 0 or x == w then - count[1] += 2 - return - end - local t = y * (w + 1) + x - grid[t + 1] += 1 - grid[len - t + 1] += 1 - for i = 1, 4 do - if grid[t + nxt[i] + 1] == 0 then - walk(y + dir[i][1], x + dir[i][2], h, w, grid, len, nxt) - end - end - grid[t + 1] -= 1 - grid[len - t + 1] -= 1 -end - -local function cutrectangle(hh, ww, recur) - local h, w - if hh % 2 != 0 then - h, w = ww, hh - else - h, w = hh, ww - end - if h % 2 != 0 then - return 0 - elseif w == 1 then - return 1 - elseif w == 2 then - return h - elseif h == 2 then - return w - end - local cy = h // 2 - local cx = w // 2 - local len = (h + 1) * (w + 1) - local grid = table.rep(len, 0) - len -= 1 - local nxt = {-1, -w - 1, 1, w + 1} - if recur then count[1] = 0 end - for x = cx + 1, w - 1 do - local t = cy * (w + 1) + x - grid[t + 1] = 1 - grid[len - t + 1] = 1 - walk(cy - 1, x, h, w, grid, len, nxt) - end - count[1] += 1 - if h == w then - count[1] *= 2 - elseif w % 2 == 0 and recur then - cutrectangle(w, h, false) - end - return count[1] -end - -for y = 1, 10 do - for x = 1, y do - if x % 2 == 0 or y % 2 == 0 then - fmt.print($"%2d x %2d: %d", y, x, cutrectangle(y, x, true)) - end - end -end diff --git a/Task/Cut-a-rectangle/Rust/cut-a-rectangle.rs b/Task/Cut-a-rectangle/Rust/cut-a-rectangle.rust similarity index 100% rename from Task/Cut-a-rectangle/Rust/cut-a-rectangle.rs rename to Task/Cut-a-rectangle/Rust/cut-a-rectangle.rust diff --git a/Task/Cut-a-rectangle/Uiua/cut-a-rectangle.uiua b/Task/Cut-a-rectangle/Uiua/cut-a-rectangle.uiua deleted file mode 100644 index 8244367fdb..0000000000 --- a/Task/Cut-a-rectangle/Uiua/cut-a-rectangle.uiua +++ /dev/null @@ -1,6 +0,0 @@ -Set ← ⍜⊡⋅2++¯1ׯ1⊙⊸△ ⟜⍜⊡⋅1 -HasSpace ← >0/+♭⌕0 -N₄ ← [1_0 0_1 ¯1_0 0_¯1] -Nexts ← ◴≡⌟Set▽=0◡⬚¯1⊡♭₂⊞+N₄⊚⊸⌕1 -Cuts ← ◴≡⊣path(□◴/◇⊂≡(□Nexts)°□|¬HasSpace°□) □[Set 0_0] ↯⊙0 -≡(&s&p⊸⧻°□⊢Cuts) [2_3 3_4 4_5] diff --git a/Task/Cyclops-numbers/Arturo/cyclops-numbers.arturo b/Task/Cyclops-numbers/Arturo/cyclops-numbers.arturo index dcd7b02c78..eea8b0fc9d 100644 --- a/Task/Cyclops-numbers/Arturo/cyclops-numbers.arturo +++ b/Task/Cyclops-numbers/Arturo/cyclops-numbers.arturo @@ -3,7 +3,7 @@ cyclops?: function [n][ all? @[ -> odd? size digs -> zero? digs\[(size digs)/2] - -> one? match.count to :string n "0" + -> 1 = size match to :string n "0" ] ] diff --git a/Task/Cyclops-numbers/BBC-BASIC/cyclops-numbers.basic b/Task/Cyclops-numbers/BBC-BASIC/cyclops-numbers.basic deleted file mode 100644 index 82f04eefbe..0000000000 --- a/Task/Cyclops-numbers/BBC-BASIC/cyclops-numbers.basic +++ /dev/null @@ -1,70 +0,0 @@ - M% = 50 - E% = 10000000 - DIM Res%(3, M%-1), Task$(3), Exc%(3), Idx%(3), N% 15 - - Size%=3 - WHILE TRUE - Overflow%=FALSE - Last%=Size% - 1 - Zero%=Last% / 2 - $$N%=STRING$(Size%, "1") - N%?Zero%=48 - REPEAT - V%=VAL$$N% - - IF Exc%(0) == 0 THEN - Idx%(0)+=1 - IF Idx%(0) < M% Res%(0, Idx%(0))=V% - IF V% > E% Exc%(0)=V% - ENDIF - - IF Exc%(2) == 0 THEN - IF FNIsPrime(V%) THEN - IF Exc%(1) == 0 THEN - IF Idx%(1) < M% Res%(1, Idx%(1))=V% - Idx%(1)+=1 - IF V% > E% Exc%(1)=V% - ENDIF - IF FNIsPrime(VAL(LEFT$($$N%, Zero%) + $$(N% + Zero% + 1))) THEN - IF Idx%(2) < M% Res%(2, Idx%(2))=V% - Idx%(2)+=1 - IF V% > E% Exc%(2)=V% - ENDIF - ENDIF - ENDIF - - FOR I%=0 TO Zero%-1 - IF N%?I% <> N%?(Last%-I%) EXIT FOR - NEXT - IF I% == Zero% IF FNIsPrime(V%) THEN - IF Idx%(3) < M% Res%(3, Idx%(3))=V% - Idx%(3)+=1 - IF V% > E% Exc%(3)=V% EXIT WHILE - ENDIF - - D%=Last% - N%?D%+=1 - WHILE N%?D% > 57 - N%?D%=49 - D%-=1 IF D% == Zero% D%-=1 - IF D% < 0 Overflow%=TRUE EXIT WHILE - N%?D%+=1 - ENDWHILE - UNTIL Overflow% - Size%+=2 - ENDWHILE - - @%=&20008 - Task$()="", " prime", " blind prime", " palindromic prime" - FOR I%=0 TO 3 - PRINT "The first ";M% Task$(I%) " cyclop numbers are:" - FOR J%=0 TO M%-1 - PRINT Res%(I%, J%),; - IF J% MOD 10 == 9 PRINT - NEXT - PRINT "First" Task$(I%) " cyclop number > ";E% \ - \ " is ";Exc%(I%) " at index ";Idx%(I%) "." ' - NEXT - END - - DEF FNIsPrime(n%) FOR I%=2 TO SQRn% IF n% MOD I% == 0 THEN =FALSE ELSE NEXT =TRUE diff --git a/Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs b/Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs deleted file mode 100644 index 272a948842..0000000000 --- a/Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs +++ /dev/null @@ -1,191 +0,0 @@ -internal class Program -{ - private static void Main(string[] args) - { - long number = 1; - int displayMax = 50; - long highBar = 10_000_000; - - List cyclops = []; - int cyclopsCount = 0; - long firstCyclopsOverHighBar = 0; - int firstCyclopsOverHighBarIndex = 0; - List primeCyclops = []; - int primeCyclopsCount = 0; - long firstPrimeCyclopsOverHighBar = 0; - int firstPrimeCyclopsOverHighBarIndex = 0; - List primeBlindCyclops = []; - int primeBlindCyclopsCount = 0; - long firstPrimeBlindCyclopsOverHighBar = 0; - int firstPrimeBlindCyclopsOverHighBarIndex = 0; - List primePalindroneCyclops = []; - int primePalindromCyclopsCount = 0; - long firstPrimePalindromeCyclopsOverHighBar = 0; - int firstPrimePalindromeCyclopsOverHighBarIndex = 0; - - while (firstCyclopsOverHighBarIndex == 0 || cyclopsCount < displayMax - || firstPrimeCyclopsOverHighBarIndex == 0 || primeCyclopsCount < displayMax - || firstPrimeBlindCyclopsOverHighBarIndex == 0 || primeBlindCyclopsCount < displayMax - || firstPrimePalindromeCyclopsOverHighBarIndex == 0 || primePalindromCyclopsCount < displayMax) - { - if (IsCyclopsNumber(number)) - { - cyclopsCount++; - - if (cyclops.Count < displayMax) - { - cyclops.Add(number); - } - - if (firstCyclopsOverHighBarIndex == 0 && number > highBar) - { - firstCyclopsOverHighBar = number; - firstCyclopsOverHighBarIndex = cyclopsCount; - } - - if (IsPrime(number)) - { - primeCyclopsCount++; - - if (firstPrimeCyclopsOverHighBarIndex == 0 && number > highBar) - { - firstPrimeCyclopsOverHighBar = number; - firstPrimeCyclopsOverHighBarIndex = primeCyclopsCount; - } - - if (primeCyclops.Count < displayMax) - { - primeCyclops.Add(number); - } - - if (IsPrime(BlindCyclopsNumber(number))) - { - primeBlindCyclopsCount++; - - if (firstPrimeBlindCyclopsOverHighBarIndex == 0 && number > highBar) - { - firstPrimeBlindCyclopsOverHighBar = number; - firstPrimeBlindCyclopsOverHighBarIndex = primeBlindCyclopsCount; - } - - if (primeBlindCyclops.Count < displayMax) - { - primeBlindCyclops.Add(number); - } - } - - if (IsPalindrome(number.ToString())) - { - primePalindromCyclopsCount++; - - if (firstPrimePalindromeCyclopsOverHighBarIndex == 0 && number > highBar) - { - firstPrimePalindromeCyclopsOverHighBar = number; - firstPrimePalindromeCyclopsOverHighBarIndex = primePalindromCyclopsCount; - } - - if (primePalindroneCyclops.Count < displayMax) - { - primePalindroneCyclops.Add(number); - } - } - } - } - - number++; - } - - DisplayNumberSequence(cyclops, $"First {displayMax} Cyclops Numbers", highBar, firstCyclopsOverHighBarIndex, firstCyclopsOverHighBar); - DisplayNumberSequence(primeCyclops, $"First {displayMax} Prime Cyclops Numbers", highBar, firstPrimeCyclopsOverHighBarIndex, firstPrimeCyclopsOverHighBar); - DisplayNumberSequence(primeBlindCyclops, $"First {displayMax} Blind Prime Cyclops Numbers", highBar, firstPrimeBlindCyclopsOverHighBarIndex, firstPrimeBlindCyclopsOverHighBar); - DisplayNumberSequence(primePalindroneCyclops, $"First {displayMax} Palidrome Cyclops Numbers", highBar, firstPrimePalindromeCyclopsOverHighBarIndex, firstPrimePalindromeCyclopsOverHighBar); - } - - private static void DisplayNumberSequence(List numbers, string title, - long highBar, long firstIndexOverHighBar, long firstOverHighBar) - { - Console.WriteLine(title); - - for (int i = 0; i < numbers.Count; i++) - { - Console.Write($"{numbers[i],-7} "); - - if ((i + 1) % 10 == 0) - { - Console.WriteLine(); - } - } - - Console.WriteLine($"The first such number > {highBar} is the {firstIndexOverHighBar}th: {firstOverHighBar}"); - Console.WriteLine(); - } - - private static bool IsCyclopsNumber(long number ) - { - string numberAsString = number.ToString(); - int numberLength = numberAsString.Length; - int middleDigit = numberLength / 2; - - if (numberLength > 1 && numberLength % 2 !=0 // the number has an odd number of digits greater than one - && numberAsString.Count(c => c == '0') == 1 // there is only one zero - && numberAsString[middleDigit] == '0') // Zero is the middle digit - { - return true; - } - return false; - } - - private static bool IsPalindrome(string stringInput) - { - if (stringInput != null && stringInput.Length > 0) - { - var reversedString = new string(stringInput.ToCharArray().Reverse().ToArray()); - return stringInput == reversedString; - } - - return false; - } - - private static long BlindCyclopsNumber(long number) - { - string numberAsString = number.ToString(); - int numberLength = numberAsString.Length; - int middleDigit = numberLength / 2; - string blindNumber = string.Concat(numberAsString.AsSpan(0, middleDigit), numberAsString.AsSpan(middleDigit + 1, numberLength - (middleDigit + 1))); - return long.Parse(blindNumber); - } - - private static bool IsPrime(long number) - { - if (number < 2) - { - return false; - } - - if (number % 2 == 0) - { - return number == 2; - } - - if (number % 3 == 0) - { - return number == 3; - } - - int delta = 2; - long k = 5; - - while (k * k <= number) - { - if (number % k == 0) - { - return false; - } - - k += delta; - delta = 6 - delta; - } - - return true; - } -} diff --git a/Task/Cyclops-numbers/Delphi/cyclops-numbers.pas b/Task/Cyclops-numbers/Delphi/cyclops-numbers.delphi similarity index 100% rename from Task/Cyclops-numbers/Delphi/cyclops-numbers.pas rename to Task/Cyclops-numbers/Delphi/cyclops-numbers.delphi diff --git a/Task/Cyclops-numbers/EasyLang/cyclops-numbers.easy b/Task/Cyclops-numbers/EasyLang/cyclops-numbers.easy deleted file mode 100644 index ad71b86e86..0000000000 --- a/Task/Cyclops-numbers/EasyLang/cyclops-numbers.easy +++ /dev/null @@ -1,98 +0,0 @@ -fastfunc is_cyclops n . - if n = 0 : return 1 - m = n mod 10 - while m <> 0 - count += 1 - n = n div 10 - m = n mod 10 - . - n = n div 10 - m = n mod 10 - while m <> 0 - count -= 1 - n = n div 10 - m = n mod 10 - . - if n = 0 and count = 0 : return 1 - return 0 -. -fastfunc isprim num . - i = 2 - while i <= sqrt num - if num mod i = 0 : return 0 - i += 1 - . - return 1 -. -func blind n . - m = n mod 10 - while m <> 0 - k = 10 * k + m - n = n div 10 - m = n mod 10 - . - n = n div 10 - while k <> 0 - m = k mod 10 - n = 10 * n + m - k = k div 10 - . - return n -. -fastfunc is_palindr n . - l = n - while l <> 0 - m = l mod 10 - k = 10 * k + m - l = l div 10 - . - if n = k : return 1 - return 0 -. -proc show . - while cnt < 50 - if is_cyclops i = 1 - write i & " " - cnt += 1 - . - i += 1 - . - print "" - print "" - i = 2 - cnt = 0 - while cnt < 50 - if isprim i = 1 and is_cyclops i = 1 - write i & " " - cnt += 1 - . - i += 1 - . - print "" - print "" - i = 2 - cnt = 0 - while cnt < 50 - if is_cyclops i = 1 and isprim i = 1 - j = blind i - if isprim j = 1 - write i & " " - cnt += 1 - . - . - i += 1 - . - print "" - print "" - i = 2 - cnt = 0 - while cnt < 50 - if is_cyclops i = 1 and is_palindr i = 1 and isprim i = 1 - write i & " " - cnt += 1 - . - i += 1 - . - print "" -. -show diff --git a/Task/Cyclops-numbers/Elixir/cyclops-numbers.ex b/Task/Cyclops-numbers/Elixir/cyclops-numbers.ex deleted file mode 100644 index 98edf3848e..0000000000 --- a/Task/Cyclops-numbers/Elixir/cyclops-numbers.ex +++ /dev/null @@ -1,62 +0,0 @@ -defmodule Rosetta do - def cy n do - require Integer - lc1=for cl <- 100..999, d=Integer.digits(cl),[q,y,z]=d,Integer.is_odd(length(d)) and y==0 and q>0 and z>0, do: cl - lc2=for cl <- 10000..99999, d=Integer.digits(cl),[q1,q2,y,z1,z2]=d,Integer.is_odd(length(d)) and y==0 and q1>0 and q2>0 and z1>0 and z2>0, do: cl - lc3=for cl <- 1000000..9999999, d=Integer.digits(cl),[q1,q2,q3,y,z1,z2,z3]=d,Integer.is_odd(length(d)) and y==0 and q1>0 and q2>0 and q3>0 and z1>0 and z2>0 and z3>0, do: cl - lc4=for cl <- 100000000..999999999, d=Integer.digits(cl),[q1,q2,q3,q4,y,z1,z2,z3,z4]=d,Integer.is_odd(length(d)) and y==0 and q1>0 and q2>0 and q3>0 and q4>0 and z1>0 and z2>0 and z3>0 and z4>0, do: cl - lc5=lc1++lc2++lc3++lc4 - lc6=[0|lc5] - Enum.take(lc6,n) - end - - "50 cyclops num" - - iex(8)> cn=Rosetta.cy 50 -[0, 101, 102, 103, 104, 105, 106, 107, 108, 109, 201, 202, 203, 204, 205, 206, - 207, 208, 209, 301, 302, 303, 304, 305, 306, 307, 308, 309, 401, 402, 403, 404, - 405, 406, 407, 408, 409, 501, 502, 503, 504, 505, 506, 507, 508, 509, 601, 602, - 603, 604] - - def cyp cn,n do - cnp=for x <- cn,x>0,length(Enum.filter(1..x,fn y -> Integer.mod(x,y)==0 end))==2, do: x - Enum.take(cnp,n) - end - - "50 cyclops primes" - -iex(11)> Rosetta.cyp(Rosetta.cy(1000),50) -[101, 103, 107, 109, 307, 401, 409, 503, 509, 601, 607, 701, 709, 809, 907, -11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 12011, 12037, -12041, 12043, 12049, 12071, 12073, 12097, 13033, 13037, 13043, 13049, 13063, -13093, 13099, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, -15013, 15017] - - def cyz cn,n do - czn=for x <- cn, x>0,do: String.to_integer(String.replace(Integer.to_string(x),"0","")) - Enum.take(czn,n) - end - - "50 blind cyclops prime" - -iex(13)> Rosetta.cyp(Rosetta.cyz(Rosetta.cy(5000),1000),50) -[11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, -97, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1213, 1217, -1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1319, -1321, 1327, 1361, 1367] - - def cypa cn,n do - czp=for x <- cn,Integer.to_string(x)==String.reverse(Integer.to_string(x)), do: x - Enum.take(czp,n) - end -end - - "50 palindrome prime cyclops" - -iex(2)> Rosetta.cyp(Rosetta.cypa(Rosetta.cy(3000000),3000),50) -[101, 16061, 31013, 35053, 38083, 73037, 74047, 91019, 94049, 1120211, 1150511, -1160611, 1180811, 1190911, 1250521, 1280821, 1360631, 1390931, 1490941, -1520251, 1550551, 1580851, 1630361, 1640461, 1660661, 1670761, 1730371, -1820281, 1880881, 1930391, 1970791, 3140413, 3160613, 3260623, 3310133, -3380833, 3460643, 3470743, 3590953, 3670763, 3680863, 3970793, 7190917, -7250527, 7310137, 7540457, 7630367, 7690967, 7750577, 7820287] diff --git a/Task/Cyclops-numbers/Fortran/cyclops-numbers.f b/Task/Cyclops-numbers/Fortran/cyclops-numbers.f deleted file mode 100644 index 161c8af7aa..0000000000 --- a/Task/Cyclops-numbers/Fortran/cyclops-numbers.f +++ /dev/null @@ -1,615 +0,0 @@ -! -! Cyclops Numbers -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.10 -! GNU Fortran (Ubuntu 15.2.0-4ubuntu4) 15.2.0 on Kubuntu 25.10 -! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 -! No Non-standard features used, should compile on any fairly recent Fortran. -! Original Pascal code converted to Fortran -! U.B., October 2025 -!============================================================================== - -module CyclopsNumbers - implicit none - -! Constants - integer, parameter :: BIGLIMIT = 10000000 ! Upper limit for number search - integer, parameter :: MAX_DIGITS = 10 ! Maximum digits in base-9 representation - - ! Type for numbers in base-9 representation - type Num9 - integer :: nmdgts(0:MAX_DIGITS) ! Digits in base-9 (0-8) - integer :: nmMaxDgtIdx ! Highest digit index used - integer(kind=8) :: nmNum ! Actual numerical value - end type Num9 - - ! Type for cyclops numbers (left + zero + right parts) - type CyclopsNum - type(Num9) :: cnRight, cnLeft ! Right and left parts around zero - integer(kind=8) :: cnNum ! Complete cyclops number - integer :: cndigits ! Number of digits in each side - integer :: cnIdx ! Index of cyclops number - end type CyclopsNum - - ! Global arrays for precomputed values - integer(kind=8) :: cnMin(0:15) ! Minimum values for digit counts - integer(kind=8) :: cnPow10Shift(0:15) ! Powers of 10 for shifting - integer(kind=8) :: cnPow9(0:15) ! Powers of 9 for indexing - - ! Dynamic array to store found cyclops numbers - integer(kind=8), allocatable :: Cyclops(:) - -contains - - !============================================================================ - ! Initialize precomputed arrays for minimum values and powers - ! cnMin: (0, 1, 11, 111, 1111, ...) - minimum values for n-digit numbers - ! cnPow10Shift: (100, 1000, 10000, ...) - powers of 10 for position shifting - ! cnPow9: (1, 9, 81, 729, ...) - powers of 9 for base conversion - !============================================================================ - subroutine InitCnMinPow() - integer :: i - integer(kind=8) :: min_val, pow, pow9 - - min_val = 0 - pow = 100 - pow9 = 1 - - do i = 0, 15 - cnMin(i) = min_val - min_val = 10 * min_val + 1 ! Build numbers like 1, 11, 111, ... - cnPow10Shift(i) = pow - pow = pow * 10 ! Next power of 10 - cnPow9(i) = pow9 - pow9 = pow9 * 9 ! Next power of 9 - end do - end subroutine InitCnMinPow - - !============================================================================ - ! Reset a Num9 type to minimum value for given digit count - ! @param tn: Num9 object to clear - ! @param idx: Digit count index - !============================================================================ - subroutine ClearNum9 (tn, idx) - type(Num9), intent(out) :: tn - integer, intent(in) :: idx - integer :: i - - tn%nmdgts = 0 ! Clear all digits - tn%nmMaxDgtIdx = 0 ! Reset max digit index - tn%nmNum = cnMin(idx + 1) ! Set to minimum value - end subroutine ClearNum9 - - !============================================================================ - ! Initialize a cyclops number to starting state - ! @param cn: CyclopsNum object to initialize - !============================================================================ - subroutine InitCycNum(cn) - type(CyclopsNum), intent(out) :: cn - - cn%cndigits = 0 ! Start with 0 digits each side - call ClearNum9(cn%cnLeft, 0) ! Clear left part - call ClearNum9(cn%cnRight, 0) ! Clear right part - cn%cnNum = 0 ! Zero value - cn%cnIdx = 0 ! Start index - end subroutine InitCycNum - - !============================================================================ - ! Increment a base-9 number, handling carry-over - ! @param tn: Num9 object to increment - !============================================================================ - subroutine IncNum9(tn) - type(Num9), intent(inout) :: tn - integer :: idx, fac, n, i - - idx = 0 - fac = 1 - n = tn%nmdgts(0) + 1 ! Increment least significant digit - tn%nmNum = tn%nmNum + 1 ! Increment numerical value - - ! Handle carry-over propagation - do - if (n < 9) exit ! No carry-over needed - - ! Carry-over occurs - tn%nmNum = tn%nmNum + fac ! Adjust numerical value - tn%nmdgts(idx) = 0 ! Reset current digit - idx = idx + 1 ! Move to next digit - fac = fac * 10 ! Increase factor for numerical adjustment - - if (idx > MAX_DIGITS) exit ! Check bounds - n = tn%nmdgts(idx) + 1 ! Get next digit + 1 - end do - - ! Store final digit value - if (idx <= MAX_DIGITS) then - tn%nmdgts(idx) = n - if (tn%nmMaxDgtIdx < idx) then - tn%nmMaxDgtIdx = idx ! Update max digit index if needed - end if - end if - end subroutine IncNum9 - - !============================================================================ - ! Generate the next cyclops number in sequence - ! @param cycnum: Current cyclops number to advance - !============================================================================ - subroutine NextCycNum(cycnum) - type(CyclopsNum), intent(inout) :: cycnum - - if (cycnum%cnIdx /= 0) then - ! Normal case: increment from previous number - call IncNum9(cycnum%cnRight) ! Increment right part - - ! Check if right part overflowed (needs more digits) - if (cycnum%cnRight%nmMaxDgtIdx > cycnum%cndigits) then - call ClearNum9(cycnum%cnRight, cycnum%cndigits) ! Reset right to minimum - call IncNum9(cycnum%cnLeft) ! Increment left part - - ! Check if left part overflowed (needs more digits) - if (cycnum%cnLeft%nmMaxDgtIdx > cycnum%cndigits) then - cycnum%cndigits = cycnum%cndigits + 1 ! Increase digit count - call ClearNum9(cycnum%cnLeft, cycnum%cndigits) ! Reset left - call ClearNum9(cycnum%cnRight, cycnum%cndigits) ! Reset right - if (cycnum%cndigits > MAX_DIGITS) then - cycnum%cndigits = MAX_DIGITS ! Enforce maximum - end if - end if - end if - - ! Reconstruct complete cyclops number: left * 10^(digits+1) + right - cycnum%cnNum = cycnum%cnLeft%nmNum * cnPow10Shift(cycnum%cndigits) + cycnum%cnRight%nmNum - cycnum%cnIdx = cycnum%cnIdx + 1 - else - ! Special case: first cyclops number - cycnum%cnNum = 101 - cycnum%cnIdx = 1 - end if - end subroutine NextCycNum - - - !============================================================================ - ! Make a complete Palindromic Cyclops number when left half is already setup. - ! Argument is already initialized to have its left half setup as needed. - ! Fill digits of right half in reversed order. - ! @param cycnum: half-filled Cyclops number to be completed as palindrome. - !============================================================================ - - subroutine MakePalinCycNum (cycnum) - type(CyclopsNum), intent(inout) :: cycnum - - ! make right to have reversed digits of left - integer :: n,dgt - integer :: i,j - - n = 0 - i = 0 - do j = cycnum%cnDigits, 0 , -1 - dgt = cycnum%cnLeft%nmdgts(i) - cycnum%cnRight%nmdgts(j) = dgt - n = 10*n+(dgt+1) - i = i + 1 - end do - cycnum%cnRight%nmNum = n - cycnum%cnNum = cycnum%cnLeft%nmNum*cnPow10Shift(cycnum%cndigits)+n - end subroutine MakePalinCycNum - - - - !============================================================================ - ! Increment left half of a Cyclops number, handling carry-over - !============================================================================ - - subroutine IncLeftCn( cn ) - - type(CyclopsNum), intent(inout) :: cn - - ! set right digits to minimum - call ClearNum9 (cn%cnRight,cn%cndigits) - ! increment left digits - call IncNum9 (cn%cnLeft) - ! One more digit in left half? - if (cn%cnLeft%nmMaxDgtIdx > cn%cndigits) then ! left has more digits than before? - cn%cndigits = cn%cndigits + 1 ! Increment for entire Cyclops number - call ClearNum9(cn%cnLeft,cn%cndigits) ! Set left to minimum for new number of digits - call ClearNum9(cn%cnRight,cn%cndigits) ! Set right to minimum for new number of digits - if (cn%cndigits>MAX_DIGITS) then - cn%cndigits = MAX_DIGITS - endif - endif - cn%cnNum = cn%cnLeft%nmNum*cnPow10Shift(cn%cndigits)+cn%cnRight%nmNUm - end subroutine IncLeftCn - - !============================================================================ - ! Convert a zero-based index to the corresponding cyclops number - ! Uses combinatorial counting based on digit positions in base-9 - ! @param n: Zero-based index - ! @return: Corresponding cyclops number - !============================================================================ - function IndexToCyclops(n) result(result_cn) - integer(kind=8), intent(in) :: n - type(CyclopsNum) :: result_cn - integer :: dgtCnt, i - integer(kind=8) :: p9, q, num, local_n - - call InitCycNum(result_cn) - if (n == 0) return ! Index 0 returns initialized (0) - - result_cn%cnIdx = n - dgtCnt = 0 - local_n = n - - ! Determine number of digits needed - do - p9 = cnPow9(dgtCnt) * cnPow9(dgtCnt) ! Combinations for dgtCnt digits - if (local_n < p9) exit ! Found correct digit count - local_n = local_n - p9 ! Subtract counted combinations - dgtCnt = dgtCnt + 1 ! Try next digit count - if (dgtCnt > 10) exit ! Safety limit - end do - - dgtCnt = dgtCnt - 1 ! Adjust to actual digit count - - ! Process right digits (convert from base-9 to base-10) - result_cn%cnRight%nmMaxDgtIdx = dgtCnt - do i = 0, dgtCnt - q = local_n / 9 ! Integer division - result_cn%cnRight%nmdgts(i) = local_n - 9 * q ! Remainder gives base-9 digit - local_n = q ! Continue with quotient - end do - - ! Convert base-9 digits to base-10 number (adding 1 to each digit) - num = 0 - do i = dgtCnt, 0, -1 ! Most significant digit first - num = num * 10 + result_cn%cnRight%nmdgts(i) + 1 - end do - result_cn%cnRight%nmNum = num - result_cn%cnNum = num ! Temporary: only right part - - ! Process left digits (same algorithm) - result_cn%cnLeft%nmMaxDgtIdx = dgtCnt - do i = 0, dgtCnt - q = local_n / 9 - result_cn%cnLeft%nmdgts(i) = local_n - 9 * q - local_n = q - end do - - ! Convert left digits to base-10 number - num = 0 - do i = dgtCnt, 0, -1 - num = num * 10 + result_cn%cnLeft%nmdgts(i) + 1 - end do - result_cn%cnLeft%nmNum = num - - ! Combine left and right with zero in middle: left * 10^(dgtCnt+1) + right - result_cn%cnNum = result_cn%cnNum + num * cnPow10Shift(dgtCnt) - result_cn%cndigits = dgtCnt - end function IndexToCyclops - - !============================================================================ - ! Display cyclops numbers in formatted columns - ! @param cl: Array of cyclops numbers - ! @param colw: Column width for formatting - ! @param colc: Number of columns per row - !============================================================================ - subroutine Out_Cyclops(cl, colw, colc) - integer(kind=8), intent(in) :: cl(:) - integer, intent(in) :: colw, colc - integer :: i, n - character (len=50) :: colFormat - - n = size(cl) - if (n > 100) n = 100 - - ! Create suitable format string to nicely printout columns using colw as width - write (colformat, '("(I", I0, " )" )') colw - - ! Print all "n=size(cl)" Numbers of array cl - do i = 1, n - write(*, colformat, advance='no') cl(i) ! Print number using calculated format string - if (mod(i, colc) == 0) then - write(*, *) ! New line after colc numbers - else - write(*, '(A)', advance='no') ' ' ! Space between numbers - end if - end do - - ! Terminate line if incomplete - if (mod(i, colc) /= 0) write(*, *) - end subroutine Out_Cyclops - - !============================================================================ - ! Check if a number is prime (simple trial division) - ! @param n: Number to check - ! @return: .true. if prime, .false. otherwise - !============================================================================ - logical function isPrime(n) - integer(kind=8), intent(in) :: n - integer(kind=8) :: p, q - - ! Handle small numbers and simple cases - if (n <= 1) then - isPrime = .false. - return - end if - - if (n == 2 .or. n == 3 .or. n == 5) then - isPrime = .true. - return - end if - - ! Even numbers and multiples of 3 - if (mod(n, 2) == 0 .or. mod(n, 3) == 0) then - isPrime = .false. - return - end if - - ! Trial division for remaining numbers - p = 5 - do - q = n / p - if (n - q * p == 0) then ! Divisible by p - isPrime = .false. - return - end if - p = p + 2 ! Next odd number - - q = n / p - if (n - q * p == 0) then ! Divisible by p+2 - isPrime = .false. - return - end if - - if (q < p) exit ! No need to check further - p = p + 4 ! Skip to next candidate - end do - - isPrime = .true. ! No divisors found - end function isPrime - - !============================================================================ - ! Generate the first 'cnt' basic cyclops numbers - ! @param cnt: Number of cyclops numbers to generate - ! @return: Last cyclops number generated (for continuation) - !============================================================================ - function FirstCyclops(cnt) result(result_cn) - integer, intent(in) :: cnt - type(CyclopsNum) :: result_cn - integer :: i - - ! Allocate storage for results - if (allocated(Cyclops)) deallocate(Cyclops) - allocate(Cyclops(cnt)) - - i = 1 - call InitCycNum(result_cn) - - ! Generate requested number of cyclops numbers - do while (i <= cnt) - Cyclops(i) = result_cn%cnNum - i = i + 1 - call NextCycNum(result_cn) - end do - - ! Continue until beyond BIGLIMIT for reporting - do while (result_cn%cnNum <= BIGLIMIT) - call NextCycNum(result_cn) - end do - end function FirstCyclops - - !============================================================================ - ! Generate the first 'cnt' prime cyclops numbers - ! @param cnt: Number of prime cyclops numbers to generate - ! @return: Last prime cyclops number with updated index - ! Algorithm as in function FirstCyclops, but check for each generated - ! Cyclops number if its prime. - !============================================================================ - function FirstPrimeCyclops(cnt) result(result_cn) - integer, intent(in) :: cnt - type(CyclopsNum) :: result_cn - integer :: i - - if (allocated(Cyclops)) deallocate(Cyclops) - allocate(Cyclops(cnt)) - - i = 1 - call InitCycNum(result_cn) - - do while (i <= cnt) - if (isPrime(result_cn%cnNum)) then ! only consider prime Cyclops numbers - Cyclops(i) = result_cn%cnNum - i = i + 1 - end if - call NextCycNum(result_cn) - end do - - - ! Continue until prime Cyclops number is beyond BIGLIMIT for reporting - do - if (isPrime(result_cn%cnNum)) then - result_cn%cnIdx = i ! result_cn%cnIdx + 1 - if (result_cn%cnNum .gt. BIGLIMIT) exit - i = i + 1 - end if - call NextCycNum(result_cn) - end do - end function FirstPrimeCyclops - - - - !============================================================================ - ! Generate the first 'cnt' prime blind cyclops numbers - ! @param cnt: Number of prime cyclops numbers to generate - ! @return: Last prime cyclops number with updated index - ! Algorithm as in function FirstCyclops, but check for each generated - ! Cyclops number if its prime, then construct blind number from this, and - ! check again if result is prime as well. - !============================================================================ - function FirstPrimeBlindCyclops(cnt) result(result_cn) - integer, intent(in) :: cnt - type(CyclopsNum) :: result_cn - integer :: i - integer (kind=8) :: n - - if (allocated(Cyclops)) deallocate(Cyclops) - allocate(Cyclops(cnt)) - - i = 1 - call InitCycNum(result_cn) - - do while (i <= cnt) - if (isPrime(result_cn%cnNum)) then - - n = result_cn%cnRight%nmnum - if (result_cn%cndigits .gt. 0) then - n = n + result_cn%cnLeft%nmnum*cnPow10Shift(result_cn%cndigits-1) - else - n = n + result_cn%cnLeft%nmnum*10 - endif - if (isPrime (n)) then - Cyclops(i) =result_cn%cnNum - i = i + 1 - endif - end if - call NextCycNum(result_cn) - end do - - do - if (isPrime(result_cn%cnNum)) then - n = result_cn%cnRight%nmnum - if (result_cn%cndigits .gt. 0) then - n = n + result_cn%cnLeft%nmnum*cnPow10Shift(result_cn%cndigits-1) - else - n = n + result_cn%cnLeft%nmnum*10 - endif - if (isPrime (n)) then - result_cn%cnIdx = i - if (result_cn%cnNum .gt. BIGLIMIT) exit - i = i + 1 - end if - end if - call NextCycNum(result_cn) - end do - end function FirstPrimeBlindCyclops - - !============================================================================ - ! Generate the first 'cnt' prime palindromic cyclops numbers - ! @param cnt: Number of prime palindromic cyclops numbers to generate - ! @return: Last prime cyclops number with updated index - ! Algorithm: directly create palindromic cyclops numbers and look for primes. - !============================================================================ - function FirstPrimePalindromicCyclops(cnt) result(result_cn) - integer, intent(in) :: cnt - type(CyclopsNum) :: result_cn - integer :: i - integer (kind=8) :: n - - if (allocated(Cyclops)) deallocate(Cyclops) - allocate(Cyclops(cnt)) - - i = 1 - call InitCycNum(result_cn) - - do while (i <= cnt) - call MakePalinCycNum (result_cn) ! Complete prepare Cyclops number to a palindrome - if (isPrime(result_cn%cnNum)) then ! Consider only if its prime. - Cyclops(i) =result_cn%cnNum - i = i + 1 - end if - call IncLeftCn (result_cn) ! Next one. - - ! Last digit cannot be even because we need only prime numbers - do while (result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 1 .AND. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 3 .and. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 5 .and. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 7 .and. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 9) - call IncLeftCn(result_cn) - end do - end do - - do - call MakePalinCycNum (result_cn) - if (isPrime(result_cn%cnNum)) then - result_cn%cnIdx = i - if (result_cn%cnNum .gt. BIGLIMIT) exit - i = i + 1 - end if - call IncLeftCn (result_cn) - - do while (result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 1 .AND. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 3 .and. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 5 .and. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 7 .and. & - result_cn%cnLeft%nmdgts(result_cn%cnDigits)+1 .ne. 9) - call IncLeftCn(result_cn) - end do - end do - - end function FirstPrimePalindromicCyclops - -end module CyclopsNumbers - -program main - use CyclopsNumbers - implicit none - - type(CyclopsNum) :: cycnum - integer :: cnt - integer(kind=8) :: i, large_cnt - - call InitCnMinPow() - - ! First 50 cyclops numbers - cnt = 50 - write(*, "( 'The first ', I0, ' cyclops numbers are:')") cnt - cycnum = FirstCyclops(cnt) - call Out_Cyclops(Cyclops, 5, 10) - write(*, "('First cyclops number > ', I0, ' is ', I0, ' at 1-based index ', I0, / )") BIGLIMIT, cycnum%cnNum, cycnum%cnIdx - - ! First 50 prime cyclops numbers - cnt = 50 - write(*, "('The first ', I0, ' prime cyclops numbers are:')") cnt - cycnum = FirstPrimeCyclops(cnt) - call Out_Cyclops(Cyclops, 7, 10) - write(*, "('First prime cyclops number > ', I0, ' is ', I0, ' at 1-based index ', I0, / )") BIGLIMIT, cycnum%cnNum, cycnum%cnIdx - write(*, *) - - -! First 50 prime blind cyclops numbers - cnt = 50 - write(*, "('The first ', I0, ' prime blind cyclops numbers are:')") cnt - cycnum = FirstPrimeBlindCyclops(cnt) - call Out_Cyclops(Cyclops, 7, 10) - write(*, "('First prime blind cyclops number > ', I0, ' is ', I0, ' at 1-based index ', I0, / )") BIGLIMIT, cycnum%cnNum, cycnum%cnIdx - -! First 50 prime palindromic cyclops numbers - cnt = 50 - write(*, "( 'The first ', I0, ' prime palindromic cyclops numbers are:')") cnt - cycnum = FirstPrimePalindromicCyclops(cnt) - call Out_Cyclops(Cyclops, 7, 10) - write(*, "('First palindromic prime cyclops number > ', I0, ' is ', I0, ' at 1-based index ', I0, / )") BIGLIMIT, cycnum%cnNum, cycnum%cnIdx - - - - - ! Additional test cases for large indices - write(*, '(A/)') 'Demonstrating Cyclops calculation for large indices:' - write(*, '(A)') ' Index Cyclop Number Calculated Cyclop Number ' - large_cnt = 100 - do while (large_cnt <= 1000000000000000_8) - write(*, '(I17, A)', advance='no') large_cnt, ' ' - if (large_cnt <= 10000) then ! For small index values evaluate Cyclops number sequentially - call InitCycNum(cycnum) - do i = 1, large_cnt-1 ! at index 1 we have 0, is already there by initialisation - call NextCycNum(cycnum) ! hence we need only (large_cnt-1) next sequence elements - end do - write(*, '(I7)', advance='no') cycnum%cnNum - else - write (*, '(" ")', advance='no') - end if - cycnum = IndexToCyclops(large_cnt-1) ! direct calculation, for comparison when index is small - write(*, *) ' ', cycnum%cnNum - large_cnt = large_cnt * 10 ! next order of magnitude - end do - -end program main diff --git a/Task/Cyclops-numbers/FreeBASIC/cyclops-numbers.basic b/Task/Cyclops-numbers/FreeBASIC/cyclops-numbers.basic deleted file mode 100644 index 6b496ea702..0000000000 --- a/Task/Cyclops-numbers/FreeBASIC/cyclops-numbers.basic +++ /dev/null @@ -1,124 +0,0 @@ -Dim Shared As Double t -Dim Shared As Uinteger n(16), clops(52), primes(52), blinds(52), pals(52) -Dim Shared As Uinteger num, iClop, iPrime, iBlind, iPal -Dim Shared As Uinteger first1, last1, midPt -midPt = 8 - -Function convertToNumber As Uinteger - Dim As Uinteger p10 = 1, nr = 0, c2 = last1 - Do - nr += n(c2) * p10 - If c2 = midPt Then p10 *= 100 Else p10 *= 10 'Add 0 if at midPoint - c2 -= 1 - Loop Until c2 < first1 - Return nr -End Function - -Sub increment(dgt As Uinteger) - If n(dgt) < 9 Then n(dgt) += 1 : Exit Sub - n(dgt) = 1 - If dgt > first1 Then increment(dgt - 1) : Exit Sub 'Carry - first1 -= 1 : last1 += 1 - For dgt = first1 To last1 'New width: set all digits to 1 - n(dgt) = 1 - Next dgt -End Sub - -Function isPrime(v As Uinteger) As Boolean - 'Skip check for 2 and 3 because we're starting at 101 - If v Mod 2 = 0 Then Return False - If v Mod 3 = 0 Then Return False - Dim As Uinteger f = 5 - While f*f <= v - If v Mod f = 0 Then Return False - f += 2 - If v Mod f = 0 Then Return False - f += 4 - Wend - Return True -End Function - -Function isBlind As Boolean - Dim As Uinteger temp = 0 - Swap temp, midPt 'Keep fn convertToNumber from adding 0 at midPt - Dim As Boolean rslt = isPrime(convertToNumber()) - Swap temp, midPt - Return rslt -End Function - -Function isPalindrome As Boolean - Dim As Uinteger a = first1, b = last1 - While b > a - If n(a) <> n(b) Then Return False - a += 1 : b -= 1 - Wend - Return True -End Function - -Sub print50(title As String, addr() As Uinteger) - Dim As Uinteger r = 0 - Print : Print title - While r < 50 - Print Using "#########"; addr(r); - r += 1 : If r Mod 10 = 0 Then Print - Wend -End Sub - -Sub display - print50(" First 50 Cyclopean numbers:", clops()) - print50(" First 50 Cyclopean primes:", primes()) - print50(" First 50 blind Cyclopean primes:", blinds()) - print50(" First 50 palindromic Cyclopean primes:", pals()) - Print - Print Using " First Cyclopean number above 10,000,000 is ######### at index ######"; clops(50); clops(51) - Print Using " First Cyclopean prime above 10,000,000 is ######### at index ######"; primes(50); primes(51) - Print Using " First blind Cyclopean prime above 10,000,000 is ######### at index ######"; blinds(50); blinds(51) - Print Using " First palindromic Cyclopean prime above 10,000,000 is ######### at index ######"; pals(50); pals(51) - Print - Print Using " Compute time: ###.### sec"; t -End Sub - -Sub cyclops - clops(0) = 0 : iClop = 1 : iPrime = 0 : iBlind = 0 : iPal = 0 - first1 = midPt-1 : last1 = midPt : n(first1) = 1 : n(last1) = 1 - - ' Record first 50 numbers in each category - While iPal < 50 - num = convertToNumber() - If iClop < 50 Then clops(iClop) = num - iClop += 1 - If isPrime(num) Then - If iPrime < 50 Then primes(iPrime) = num : iPrime += 1 - If iBlind < 50 Andalso isBlind() Then blinds(iBlind) = num : iBlind += 1 - If iPal < 50 Andalso isPalindrome() Then pals(iPal) = num : iPal += 1 - End If - num += 1 - increment(last1) - Wend - - ' Keep counting Cyclops numbers until 10,000,000 - While convertToNumber() < 1e7 - increment(last1) : iClop += 1 - Wend - - ' Find next number in each category - clops(50) = convertToNumber() : clops(51) = iClop - iPrime = 1 : iBlind = 1 : iPal = 1 - While (iPrime Or iBlind Or iPal) - num = convertToNumber() - iClop += 1 - If isPrime(num) Then - If iPrime = 1 Then primes(50) = num : primes(51) = iClop : iPrime = 0 - If iBlind = 1 Andalso isBlind() Then blinds(50) = num : blinds(51) = iClop : iBlind = 0 - If iPal = 1 Andalso isPalindrome() Then pals(50) = num : pals(51) = iClop : iPal = 0 - End If - increment(last1) - Wend -End Sub - -t = Timer -cyclops() -t = Timer - t -display() - -Sleep diff --git a/Task/Cyclops-numbers/FutureBasic/cyclops-numbers.basic b/Task/Cyclops-numbers/FutureBasic/cyclops-numbers.basic deleted file mode 100644 index 243e3df01e..0000000000 --- a/Task/Cyclops-numbers/FutureBasic/cyclops-numbers.basic +++ /dev/null @@ -1,126 +0,0 @@ -begin globals -CFTimeInterval t -long n(16), clops(52), primes(52), blinds(52), pals(52) -long num, iClop, iPrime, iBlind, iPal -short first1, last1, midPt -xref show(50) as long -midPt = 8 -end globals - -local fn convertToNumber as long - long p10 = 1, nr = 0 - short c2 = last1 - do - nr += n(c2) * p10 - if c2 == midPt then p10 *= 100 else p10 *= 10 //Add 0 if at midPoint - c2-- - until c2 < first1 -end fn = nr - -void local fn increment( dgt as short ) - if n(dgt) < 9 then n(dgt)++ : exit fn - n(dgt) = 1 - if dgt > first1 then fn increment( dgt - 1 ) : exit fn //Carry - first1-- : last1 ++ - for dgt = first1 to last1 //New width: set all digits to 1 - n(dgt) = 1 - next -end fn - -local fn isPrime( v as long ) as bool - //Skip check for 2 and 3 because we're starting at 101 - if v mod 2 == 0 then exit fn = no - if v mod 3 == 0 then exit fn = no - long f = 5 - while f*f <= v - if v mod f == 0 then exit fn = no - f += 2 - if v mod f == 0 then exit fn = no - f += 4 - wend -end fn = yes - -local fn isBlind as bool - short temp = 0 - swap temp, midPt //Keep fn convertToNumber from adding 0 at midPt - bool rslt = fn isPrime( fn convertToNumber ) - swap temp, midPt -end fn = rslt - -local fn isPalindrome as bool - short a = first1, b = last1 - while b > a - if n(a) <> n(b) then exit fn = no - a++ : b-- - wend -end fn = yes - -void local fn print50( title as cfstringref, addr as ptr ) - short r = 0 - show = addr //Set array address to param - print : print title - while r < 50 - printf @"%9ld\b",show(r) - r++ : if r mod 10 == 0 then print - wend -end fn - -void local fn display - window 1, @"Cyclopean numbers", (0, 0, 680, 515 ) - fn print50( @" First 50 Cyclopean numbers:", @clops( 0)) - fn print50( @" First 50 Cyclopean primes:", @primes(0)) - fn print50( @" First 50 blind Cyclopean primes:", @blinds(0)) - fn print50( @" First 50 palindromic Cyclopean primes:",@pals( 0)) - print - printf @" First Cyclopean number above 10,000,000 is %ld at index %ld", clops(50), clops(51) - printf @" First Cyclopean prime above 10,000,000 is %ld at index %ld", primes(50),primes(51) - printf @" First blind Cyclopean prime above 10,000,000 is %ld at index %ld", blinds(50),blinds(51) - printf @" First palindromic Cyclopean prime above 10,000,000 is %ld at index %ld", pals(50), pals(51) - print - printf @" Compute time: %.3f sec", t -end fn - -void local fn cyclops - clops( 0 ) = 0 : iClop = 1 : iPrime = 0 : iBlind = 0 : iPal = 0 - first1 = midPt-1 : last1 = midPt : n(first1) = 1 : n(last1) = 1 - - // Record first 50 numbers in each category - while ( iPal ) < 50 - num = fn convertToNumber - if iClop < 50 then clops(iClop) = num - iClop++ - if fn isPrime( num ) - if iPrime < 50 then primes(iPrime) = num : iPrime++ - if iBlind < 50 then if fn isBlind then blinds(iBlind) = num : iBlind++ - if iPal < 50 then if fn isPalindrome then pals(iPal) = num : iPal++ - end if - num++ - fn increment( last1 ) - wend - - // Keep counting Cyclops numbers until 10,000,000 - while fn convertToNumber < 10000000 - fn increment( last1 ) : iClop++ - wend - - // Find next number in each category - clops(50) = fn convertToNumber : clops(51) = iClop - iPrime = 1 : iBlind = 1 : iPal = 1 - while (iPrime or iBlind or iPal) - num = fn convertToNumber - iClop++ - if fn isPrime( num ) - if iPrime then primes(50) = num : primes(51) = iClop : iPrime-- - if iBlind then if fn isBlind then blinds(50) = num : blinds(51) = iClop : iBlind-- - if iPal then if fn isPalindrome then pals(50) = num : pals(51) = iClop : ipal-- - end if - fn increment( last1 ) - wend -end fn - -t = fn CACurrentMediaTime -fn cyclops -t = fn CACurrentMediaTime - t -fn display - -handleevents diff --git a/Task/Cyclops-numbers/Java/cyclops-numbers.java b/Task/Cyclops-numbers/Java/cyclops-numbers.java deleted file mode 100644 index e5172e10c8..0000000000 --- a/Task/Cyclops-numbers/Java/cyclops-numbers.java +++ /dev/null @@ -1,132 +0,0 @@ -import java.util.ArrayList; -import java.util.List; - -public final class CyclopsNumbers { - - public static void main(String[] args) { - List cyclops = new ArrayList(); - List primeCyclops = new ArrayList(); - List blindPrimeCyclops = new ArrayList(); - List palindromicPrimeCyclops = new ArrayList(); - - List> ranges = List.of( List.of( 0, 0), List.of( 101, 909), - List.of( 11011, 99099 ), List.of( 1110111, 9990999 ), List.of( 111101111, 119101111 ) ); - - for ( List range : ranges) { - for ( int i = range.getFirst(); i <= range.getLast(); i++ ) { - String value = String.valueOf(i); - if ( isCyclopsNumber(value) ) { - cyclops.addLast(i); - if ( isPrime(i) ) { - primeCyclops.addLast(i); - if ( isBlind(value) ) { - blindPrimeCyclops.addLast(i); - } - if ( isPalindromic(value) ) { - palindromicPrimeCyclops.addLast(i); - } - } - } - } - } - - System.out.println("The first 50 Cyclops numbers:"); - for ( int i = 0; i < 50; i++ ) { - System.out.print(String.format("%6s%s", cyclops.get(i), ( i % 10 == 9 ? "\n" : "" ))); - } - System.out.println(); - int firstIndex = firstIndex(cyclops); - System.out.println("The first cyclops number greater than ten million is " - + cyclops.get(firstIndex) + " at zero based index " + firstIndex); - System.out.println(); - - System.out.println("The first 50 prime Cyclops numbers:"); - for ( int i = 0; i < 50; i++ ) { - System.out.print(String.format("%7s%s", primeCyclops.get(i), ( i % 10 == 9 ? "\n" : "" ))); - } - System.out.println(); - firstIndex = firstIndex(primeCyclops); - System.out.println("The first prime cyclops number greater than ten million is " - + primeCyclops.get(firstIndex) + " at zero based index " + firstIndex); - System.out.println(); - - System.out.println("The first 50 blind prime Cyclops numbers:"); - for ( int i = 0; i < 50; i++ ) { - System.out.print(String.format("%7s%s", blindPrimeCyclops.get(i), ( i % 10 == 9 ? "\n" : "" ))); - } - System.out.println(); - firstIndex = firstIndex(blindPrimeCyclops); - System.out.println("The first blind prime cyclops number greater than ten million is " - + blindPrimeCyclops.get(firstIndex) + " at zero based index " + firstIndex); - System.out.println(); - - System.out.println("The first 50 palindromic prime Cyclops numbers:"); - for ( int i = 0; i < 50; i++ ) { - System.out.print( - String.format("%9s%s", palindromicPrimeCyclops.get(i), ( i % 10 == 9 ? "\n" : "" ))); - } - System.out.println(); - firstIndex = firstIndex(palindromicPrimeCyclops); - System.out.println("The first palindromic prime cyclops number greater than ten million is " - + palindromicPrimeCyclops.get(firstIndex) + " at zero based index " + firstIndex); - System.out.println(); - } - - private static int firstIndex(List numbers) { - int start = 0; - int end = numbers.size() - 1; - while ( start <= end ) { - final int mid = start + ( end - start ) / 2; - if ( numbers.get(mid) <= 10_000_000 ) { - start = mid + 1; - } else { - end = mid - 1; - } - } - return start; - } - - private static boolean isCyclopsNumber(String text) { - return text.charAt(text.length() / 2) == '0' && text.indexOf('0') == text.lastIndexOf('0'); - } - - private static boolean isPalindromic(String text) { - for ( int i = 0; i < text.length() / 2; i++ ) { - if ( text.charAt(i) != text.charAt(text.length() - 1 - i) ) { - return false; - } - } - return true; - } - - private static boolean isBlind(String text) { - final int middle = text.length() / 2; - final String withoutZero = text.substring(0, middle) + text.substring(middle + 1); - return isPrime(Integer.valueOf(withoutZero)); - } - - private static boolean isPrime(int number) { - if ( number < 2 ) { - return false; - } - if ( number % 2 == 0 ) { - return number == 2; - } - if ( number % 3 == 0 ) { - return number == 3; - } - int k = 5; - while ( k * k <= number ) { - if ( number % k == 0 ) { - return false; - } - k += 2; - if ( number % k == 0 ) { - return false; - } - k += 4; - } - return true; - } - -} diff --git a/Task/Cyclops-numbers/JavaScript/cyclops-numbers.js b/Task/Cyclops-numbers/JavaScript/cyclops-numbers.js deleted file mode 100644 index d252c63019..0000000000 --- a/Task/Cyclops-numbers/JavaScript/cyclops-numbers.js +++ /dev/null @@ -1,136 +0,0 @@ -// Cyclops Numbers - JavaScript implementation - -function main() { - const cyclops = []; - const primeCyclops = []; - const blindPrimeCyclops = []; - const palindromicPrimeCyclops = []; - - const ranges = [ - [0, 0], - [101, 909], - [11011, 99099], - [1110111, 9990999], - [111101111, 119101111] - ]; - - for (const range of ranges) { - for (let i = range[0]; i <= range[1]; i++) { - const value = String(i); - if (isCyclopsNumber(value)) { - cyclops.push(i); - if (isPrime(i)) { - primeCyclops.push(i); - if (isBlind(value)) { - blindPrimeCyclops.push(i); - } - if (isPalindromic(value)) { - palindromicPrimeCyclops.push(i); - } - } - } - } - } - - console.log("The first 50 Cyclops numbers:"); - for (let i = 0; i < 50; i++) { - process.stdout.write(String(cyclops[i]).padStart(6) + (i % 10 === 9 ? "\n" : "")); - } - console.log(); - let idx = firstIndex(cyclops); - console.log("The first cyclops number greater than ten million is " + - cyclops[idx] + " at zero based index " + idx); - console.log(); - - console.log("The first 50 prime Cyclops numbers:"); - for (let i = 0; i < 50; i++) { - process.stdout.write(String(primeCyclops[i]).padStart(7) + (i % 10 === 9 ? "\n" : "")); - } - console.log(); - idx = firstIndex(primeCyclops); - console.log("The first prime cyclops number greater than ten million is " + - primeCyclops[idx] + " at zero based index " + idx); - console.log(); - - console.log("The first 50 blind prime Cyclops numbers:"); - for (let i = 0; i < 50; i++) { - process.stdout.write(String(blindPrimeCyclops[i]).padStart(7) + (i % 10 === 9 ? "\n" : "")); - } - console.log(); - idx = firstIndex(blindPrimeCyclops); - console.log("The first blind prime cyclops number greater than ten million is " + - blindPrimeCyclops[idx] + " at zero based index " + idx); - console.log(); - - console.log("The first 50 palindromic prime Cyclops numbers:"); - for (let i = 0; i < 50; i++) { - process.stdout.write(String(palindromicPrimeCyclops[i]).padStart(9) + (i % 10 === 9 ? "\n" : "")); - } - console.log(); - idx = firstIndex(palindromicPrimeCyclops); - console.log("The first palindromic prime cyclops number greater than ten million is " + - palindromicPrimeCyclops[idx] + " at zero based index " + idx); - console.log(); -} - -function firstIndex(numbers) { - let start = 0; - let end = numbers.length - 1; - - while (start <= end) { - const mid = start + Math.floor((end - start) / 2); - if (numbers[mid] <= 10000000) { - start = mid + 1; - } else { - end = mid - 1; - } - } - return start; -} - -function isCyclopsNumber(text) { - const middleIndex = Math.floor(text.length / 2); - return text[middleIndex] === '0' && text.indexOf('0') === text.lastIndexOf('0'); -} - -function isPalindromic(text) { - for (let i = 0; i < Math.floor(text.length / 2); i++) { - if (text[i] !== text[text.length - 1 - i]) { - return false; - } - } - return true; -} - -function isBlind(text) { - const middle = Math.floor(text.length / 2); - const withoutZero = text.substring(0, middle) + text.substring(middle + 1); - return isPrime(parseInt(withoutZero, 10)); -} - -function isPrime(number) { - if (number < 2) { - return false; - } - if (number % 2 === 0) { - return number === 2; - } - if (number % 3 === 0) { - return number === 3; - } - let k = 5; - while (k * k <= number) { - if (number % k === 0) { - return false; - } - k += 2; - if (number % k === 0) { - return false; - } - k += 4; - } - return true; -} - -// Run the main function -main(); diff --git a/Task/Cyclops-numbers/Julia/cyclops-numbers.jl b/Task/Cyclops-numbers/Julia/cyclops-numbers.julia similarity index 100% rename from Task/Cyclops-numbers/Julia/cyclops-numbers.jl rename to Task/Cyclops-numbers/Julia/cyclops-numbers.julia diff --git a/Task/Cyclops-numbers/Phix/cyclops-numbers-1.phix b/Task/Cyclops-numbers/Phix/cyclops-numbers-1.phix index 1e01179aed..27bbdc089f 100644 --- a/Task/Cyclops-numbers/Phix/cyclops-numbers-1.phix +++ b/Task/Cyclops-numbers/Phix/cyclops-numbers-1.phix @@ -1,67 +1,69 @@ -with javascript_semantics -atom t0 = time() -function bump(sequence half) - -- add a digit to valid halves - -- eg {0} --> {1..9} (no zeroes) - -- --> {11..99} ("") - -- --> {111..999}, etc - sequence res = {} - for i=1 to length(half) do - integer hi = half[i]*10 - for digit=1 to 9 do - res &= hi+digit - end for - end for - return res -end function +(phixonline)--> + with javascript_semantics + atom t0 = time() + function bump(sequence half) + -- add a digit to valid halves + -- eg {0} --> {1..9} (no zeroes) + -- --> {11..99} ("") + -- --> {111..999}, etc + sequence res = {} + for i=1 to length(half) do + integer hi = half[i]*10 + for digit=1 to 9 do + res &= hi+digit + end for + end for + return res + end function -procedure cyclops(string s="") - sequence res = {}, - half = {0} -- valid digits, see bump() - integer left = 1, -- half[] before the 0 - right = 0, -- half[] after the 0 - hlen = 1, -- length(half) - cpow = 10, -- cyclops power (of 10) - bcpow = 1, -- blind cyclops power - cn = 0 -- cyclops number (scratch) - bool valid = false, - bPrime = match("prime",s), - bBlind = match("blind",s), - bPalin = match("palindromic",s) - while length(res)<50 or cn<=1e7 or not valid do - right += 1 - if right>hlen then - right = 1 - left += 1 - if left>hlen then - half = bump(half) - hlen = length(half) - cpow *= 10 - bcpow *= 10 - left = 1 - end if - end if - integer lh = half[left], - rh = half[right] - cn = lh*cpow+rh -- cyclops number - valid = not bPrime or is_prime(cn) - if valid and bBlind then - valid = is_prime(lh*bcpow+rh) - end if - if valid and bPalin then - valid = sprintf("%d",lh) == reverse(sprintf("%d",rh)) - end if - if valid then - res = append(res,sprintf("%7d",cn)) - end if - end while - printf(1,"First 50 %scyclops numbers:\n%s\n",{s,join_by(res[1..50],1,10)}) - printf(1,"First %scyclops number > 10,000,000: %s at (one based) index: %d\n\n", - {s,res[$],length(res)}) -end procedure + procedure cyclops(string s="") + sequence res = {}, + half = {0} -- valid digits, see bump() + integer left = 1, -- half[] before the 0 + right = 0, -- half[] after the 0 + hlen = 1, -- length(half) + cpow = 10, -- cyclops power (of 10) + bcpow = 1, -- blind cyclops power + cn = 0 -- cyclops number (scratch) + bool valid = false, + bPrime = match("prime",s), + bBlind = match("blind",s), + bPalin = match("palindromic",s) + while length(res)<50 or cn<=1e7 or not valid do + right += 1 + if right>hlen then + right = 1 + left += 1 + if left>hlen then + half = bump(half) + hlen = length(half) + cpow *= 10 + bcpow *= 10 + left = 1 + end if + end if + integer lh = half[left], + rh = half[right] + cn = lh*cpow+rh -- cyclops number + valid = not bPrime or is_prime(cn) + if valid and bBlind then + valid = is_prime(lh*bcpow+rh) + end if + if valid and bPalin then + valid = sprintf("%d",lh) == reverse(sprintf("%d",rh)) + end if + if valid then + res = append(res,sprintf("%7d",cn)) + end if + end while + printf(1,"First 50 %scyclops numbers:\n%s\n",{s,join_by(res[1..50],1,10)}) + printf(1,"First %scyclops number > 10,000,000: %s at (one based) index: %d\n\n", + {s,res[$],length(res)}) + end procedure -cyclops() -cyclops("prime ") -cyclops("blind prime ") -cyclops("palindromic prime ") -?elapsed(time()-t0) + cyclops() + cyclops("prime ") + cyclops("blind prime ") + cyclops("palindromic prime ") + ?elapsed(time()-t0) + + with javascript_semantics + atom t0 = time() + function bump(sequence half) -- (exactly the same as above) + -- add a digit to valid halves + -- eg {0} --> {1..9} (no zeroes) + -- --> {11..99} ("") + -- --> {111..999}, etc + sequence res = {} + for i=1 to length(half) do + integer hi = half[i]*10 + for digit=1 to 9 do + res &= hi+digit + end for + end for + return res + end function -procedure nth_cyclops(atom n) - string cyclops = "0" - if n>1 then - atom hlen = 1, hlen2 = 1, w = n-1, digits = 0 - while w>=hlen2 do - w -= hlen2 - hlen *= 9 - hlen2 = power(hlen,2) - digits += 1 - end while - string hf = sprintf("%%0%da/%%0%da",digits) - cyclops = sq_add(1,sprintf(hf,{{9,floor(w/hlen)},{9,round(remainder(w,hlen))}})) - end if - string fmt = "The %,d%s cyclops number is %s%s\n", - e = elapsed(time()-t0,0.1," (%s)") - printf(1,fmt,{n,ord(n),cyclops,e}) -end procedure -for n=0 to iff(machine_bits()=32?15:18) do - nth_cyclops(power(10,n)) -end for -?elapsed(time()-t0) + sequence half = {0} -- valid digits, see bump() + integer hlen = 1, + cpow = 10 -- cyclops power (of 10) + integer n = 1_000_000_000 + atom hlen2 = 1 + while n>hlen2 do + n -= hlen2 + half = bump(half) + hlen = length(half) + hlen2 = power(hlen,2) + cpow *= 10 + end while + integer left = floor(n/hlen)+1, -- half[] before the 0 + right = remainder(n,hlen)+1 -- half[] after the 0 + string fmt = "The 1,000,000,000th cyclops number is %d (%s)\n", + e = elapsed(time()-t0) + printf(1,fmt,{half[left]*cpow+half[right],e}) + + without js + include builtins\cffi.e -constant AF_UNSPEC = 0, --- AF_INET = 2, --- AF_INET6 = 23, --- SOCK_STREAM = 1, - SOCK_DGRAM = 2, --- IPPROTO_TCP = 6, - NI_MAXHOST = 1025, - NI_NUMERICHOST = iff(platform()=LINUX?1:2) + constant AF_UNSPEC = 0, + -- AF_INET = 2, + -- AF_INET6 = 23, + -- SOCK_STREAM = 1, + SOCK_DGRAM = 2, + -- IPPROTO_TCP = 6, + NI_MAXHOST = 1025, + NI_NUMERICHOST = iff(platform()=LINUX?1:2) -constant tWAD = """ -typedef struct WSAData { - WORD wVersion; - WORD wHighVersion; - char szDescription[257]; - char szSystemStatus[129]; - unsigned short iMaxSockets; - unsigned short iMaxUdpDg; - char *lpVendorInfo; -} WSADATA, *LPWSADATA; -""", -tWAS = """ -int WSAStartup( - _In_ WORD wVersionRequested, - _Out_ LPWSADATA lpWSAData -); -""", -tWAC = """ -int WSACleanup(void); -""", -tAI_W=""" -typedef struct addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - char *ai_canonname; - struct sockaddr *ai_addr; - struct addrinfo *ai_next; -} ADDRINFOA, *PADDRINFOA; -""", -tAI_L=""" -typedef struct addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - int ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; -""", -tGAI = """ -int getaddrinfo( - _In_opt_ PCSTR pNodeName, - _In_opt_ PCSTR pServiceName, - _In_opt_ const ADDRINFOA *pHints, - _Out_ PADDRINFOA *ppResult -); -""", ---int getaddrinfo(const char *node, const char *service, --- const struct addrinfo *hints, --- struct addrinfo **res); -tGNI = """ -int getnameinfo( - _In_ sockaddr *sa, - _In_ int salen, - _Out_ char *host, - _In_ DWORD hostlen, - _Out_ char *serv, - _In_ DWORD servlen, - _In_ int flags -); -""", ---int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, --- char *host, socklen_t hostlen, --- char *serv, socklen_t servlen, int flags); -tFAI = """ -void freeaddrinfo( - _In_ struct addrinfo *ai -); -""" ---void freeaddrinfo(struct addrinfo *res); + constant tWAD = """ + typedef struct WSAData { + WORD wVersion; + WORD wHighVersion; + char szDescription[257]; + char szSystemStatus[129]; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char *lpVendorInfo; + } WSADATA, *LPWSADATA; + """, + tWAS = """ + int WSAStartup( + _In_ WORD wVersionRequested, + _Out_ LPWSADATA lpWSAData + ); + """, + tWAC = """ + int WSACleanup(void); + """, + tAI_W=""" + typedef struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + char *ai_canonname; + struct sockaddr *ai_addr; + struct addrinfo *ai_next; + } ADDRINFOA, *PADDRINFOA; + """, + tAI_L=""" + typedef struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + int ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; + }; + """, + tGAI = """ + int getaddrinfo( + _In_opt_ PCSTR pNodeName, + _In_opt_ PCSTR pServiceName, + _In_opt_ const ADDRINFOA *pHints, + _Out_ PADDRINFOA *ppResult + ); + """, + --int getaddrinfo(const char *node, const char *service, + -- const struct addrinfo *hints, + -- struct addrinfo **res); + tGNI = """ + int getnameinfo( + _In_ sockaddr *sa, + _In_ int salen, + _Out_ char *host, + _In_ DWORD hostlen, + _Out_ char *serv, + _In_ DWORD servlen, + _In_ int flags + ); + """, + --int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, + -- char *host, socklen_t hostlen, + -- char *serv, socklen_t servlen, int flags); + tFAI = """ + void freeaddrinfo( + _In_ struct addrinfo *ai + ); + """ + --void freeaddrinfo(struct addrinfo *res); -integer xgetaddrinfo = NULL, xgetnameinfo, xfreeaddrinfo, idAI, - xwsastartup, xwsacleanup, error + integer xgetaddrinfo = NULL, xgetnameinfo, xfreeaddrinfo, idAI, + xwsastartup, xwsacleanup, error -function get_name_info(string fqdn) - if xgetaddrinfo=NULL then - atom lib - if platform()=WINDOWS then - integer idWAD = define_struct(tWAD) - atom pWAD = allocate_struct(idWAD,cleanup:=true) - lib = open_dll("Ws2_32.dll") - xwsastartup = define_cffi_func(lib,tWAS) - xwsacleanup = define_cffi_func(lib,tWAC) - error = c_func(xwsastartup,{#00020002,pWAD}) - if error then ?9/0 end if - idAI = define_struct(tAI_W) - elsif platform()=LINUX then - lib = open_dll("libc.so.6") - idAI = define_struct(tAI_L) - end if - xgetaddrinfo = define_cffi_func(lib,tGAI) - xgetnameinfo = define_cffi_func(lib,tGNI) - xfreeaddrinfo = define_cffi_proc(lib,tFAI) - end if - atom hints = allocate_struct(idAI,cleanup:=true), - res = allocate(machine_word(),cleanup:=true), - host = allocate(NI_MAXHOST,cleanup:=true) - set_struct_field(idAI,hints,"ai_family",AF_UNSPEC) --- set_struct_field(idAI,hints,"ai_socktype",SOCK_STREAM) - set_struct_field(idAI,hints,"ai_socktype",SOCK_DGRAM) - error = c_func(xgetaddrinfo,{fqdn,NULL,hints,res}) - if error then ?9/0 end if - res = peekNS(res,machine_word(),false) - atom ptr = res - sequence results = {} - while ptr!=NULL do - atom addr = get_struct_field(idAI,ptr,"ai_addr") - integer len = get_struct_field(idAI,ptr,"ai_addrlen") - error = c_func(xgetnameinfo,{addr, len, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST}) - if error then ?9/0 end if - results = append(results,peek_string(host)) - ptr = get_struct_field(idAI,ptr,"ai_next") - end while - c_proc(xfreeaddrinfo,{res}) - return results -end function + function get_name_info(string fqdn) + if xgetaddrinfo=NULL then + atom lib + if platform()=WINDOWS then + integer idWAD = define_struct(tWAD) + atom pWAD = allocate_struct(idWAD,cleanup:=true) + lib = open_dll("Ws2_32.dll") + xwsastartup = define_cffi_func(lib,tWAS) + xwsacleanup = define_cffi_func(lib,tWAC) + error = c_func(xwsastartup,{#00020002,pWAD}) + if error then ?9/0 end if + idAI = define_struct(tAI_W) + elsif platform()=LINUX then + lib = open_dll("libc.so.6") + idAI = define_struct(tAI_L) + end if + xgetaddrinfo = define_cffi_func(lib,tGAI) + xgetnameinfo = define_cffi_func(lib,tGNI) + xfreeaddrinfo = define_cffi_proc(lib,tFAI) + end if + atom hints = allocate_struct(idAI,cleanup:=true), + res = allocate(machine_word(),cleanup:=true), + host = allocate(NI_MAXHOST,cleanup:=true) + set_struct_field(idAI,hints,"ai_family",AF_UNSPEC) + -- set_struct_field(idAI,hints,"ai_socktype",SOCK_STREAM) + set_struct_field(idAI,hints,"ai_socktype",SOCK_DGRAM) + error = c_func(xgetaddrinfo,{fqdn,NULL,hints,res}) + if error then ?9/0 end if + res = peekNS(res,machine_word(),false) + atom ptr = res + sequence results = {} + while ptr!=NULL do + atom addr = get_struct_field(idAI,ptr,"ai_addr") + integer len = get_struct_field(idAI,ptr,"ai_addrlen") + error = c_func(xgetnameinfo,{addr, len, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST}) + if error then ?9/0 end if + results = append(results,peek_string(host)) + ptr = get_struct_field(idAI,ptr,"ai_next") + end while + c_proc(xfreeaddrinfo,{res}) + return results + end function -procedure WSACleanup() - if platform()=WINDOWS then - error = c_func(xwsacleanup,{}) - if error then crash("WSACleanup failed: %d\n",{error}) end if - end if -end procedure + procedure WSACleanup() + if platform()=WINDOWS then + error = c_func(xwsacleanup,{}) + if error then crash("WSACleanup failed: %d\n",{error}) end if + end if + end procedure -?get_name_info("www.kame.net") -WSACleanup() + ?get_name_info("www.kame.net") + WSACleanup() + + with javascript_semantics + include builtins\timedate.e + ?format_timedate(date(),"YYYY-MM-DD") + ?format_timedate(date(),"Dddd, Mmmm d, YYYY") + + include builtins\timedate.e + set_timedate_formats({"Mmmm d yyyy h:mmpm tz"}) + timedate td = parse_date_string("March 7 2009 7:30pm EST") + atom twelvehours = timedelta(hours:=12) + td = adjust_timedate(td,twelvehours) + ?format_timedate(td) + td = change_timezone(td,"ACDT") -- extra credit + ?format_timedate(td) + td = adjust_timedate(td,timedelta(days:=31*4)) + ?format_timedate(td) + + string deBruijn = "" + for n=0 to 99 do + string a = sprintf("%02d",n) + integer a1 = a[1], + a2 = a[2] + if a2>=a1 then + deBruijn &= iff(a1=a2?a1:a) + for m=n+1 to 99 do + string ms = sprintf("%02d",m) + if ms[2]>a1 then + deBruijn &= a&ms + end if + end for + end if + end for + deBruijn &= "000" + printf(1,"de Bruijn sequence length: %d\n\n",length(deBruijn)) + printf(1,"First 130 characters:\n%s\n\n",deBruijn[1..130]) + printf(1,"Last 130 characters:\n%s\n\n",deBruijn[-130..-1]) -function check(string text) - sequence res = {} - sequence found = repeat(0,10000) - integer k - for i=1 to length(text)-3 do - k = to_integer(text[i..i+3],-1)+1 - if k!=0 then found[k] += 1 end if - end for - for i=1 to 10000 do - k = found[i] - if k!=1 then - string e = sprintf("Pin number %04d ",i-1) - e &= iff(k=0?"missing":sprintf("occurs %d times",k)) - res = append(res,e) - end if - end for - k = length(res) - if k=0 then - res = "No errors found" - else - string s = iff(k=1?"":"s") - res = sprintf("%d error%s found:\n ",{k,s})&join(res,"\n ") - end if - return res -end function + function check(string text) + sequence res = {} + sequence found = repeat(0,10000) + integer k + for i=1 to length(text)-3 do + k = to_integer(text[i..i+3],-1)+1 + if k!=0 then found[k] += 1 end if + end for + for i=1 to 10000 do + k = found[i] + if k!=1 then + string e = sprintf("Pin number %04d ",i-1) + e &= iff(k=0?"missing":sprintf("occurs %d times",k)) + res = append(res,e) + end if + end for + k = length(res) + if k=0 then + res = "No errors found" + else + string s = iff(k=1?"":"s") + res = sprintf("%d error%s found:\n ",{k,s})&join(res,"\n ") + end if + return res + end function -printf(1,"Missing 4 digit PINs in this sequence: %s\n", check(deBruijn)) -printf(1,"Missing 4 digit PINs in the reversed sequence: %s\n",check(reverse(deBruijn))) -printf(1,"4444th digit in the sequence: %c (setting it to .)\n", deBruijn[4444]) -deBruijn[4444] = '.' -printf(1,"Re-running checks: %s\n",check(deBruijn)) + printf(1,"Missing 4 digit PINs in this sequence: %s\n", check(deBruijn)) + printf(1,"Missing 4 digit PINs in the reversed sequence: %s\n",check(reverse(deBruijn))) + printf(1,"4444th digit in the sequence: %c (setting it to .)\n", deBruijn[4444]) + deBruijn[4444] = '.' + printf(1,"Re-running checks: %s\n",check(deBruijn)) + n ) - - [ 2dup peek - dip [ over -1 peek ] - swap 2swap poke - -1 poke ] is to-end ( [ n --> [ ) - - [ [] swap - 52 times - [ MCR-rand - over size mod - to-end - -1 split - swap dip join ] - drop ] is mixem ( [ --> [ ) - - [ 4 /mod - $ "A23456789TJQK" - rot peek emit - $ "CDHS" - swap peek emit ] is echocard ( n --> ) - - [ witheach - [ echocard - i^ 8 mod 7 = - iff cr else sp ] ] is echopack ( [ --> ) - - [ MCR-seed replace - newpack - mixem - echopack ] is deal ( n --> ) - - ' [ 1 617 11982 ] - witheach - [ say "Deal #" - dup echo cr - deal cr cr ] diff --git a/Task/Deal-cards-for-FreeCell/Rebol/deal-cards-for-freecell.rebol b/Task/Deal-cards-for-FreeCell/Rebol/deal-cards-for-freecell.rebol deleted file mode 100644 index 2a23ed925a..0000000000 --- a/Task/Deal-cards-for-FreeCell/Rebol/deal-cards-for-freecell.rebol +++ /dev/null @@ -1,37 +0,0 @@ -Rebol [ - title: "Rosetta code: Deal cards for FreeCell" - file: %Deal_cards_for_FreeCell.r3 - url: https://rosettacode.org/wiki/Deal_cards_for_FreeCell -] - -deal-FreeCell: function/with [ - "Deal a FreeCell game by number" - num [integer!] -][ - deck: copy ordered-deck - state: num ; seed the MSLCG - print ["^/Game:" as-green num] - len: length? deck - while [len > 0] [ - ;; pick random remaining card and swap to end - choice: rng % len + 1 - swap (at deck choice) (at deck len) - prin [" " take/last deck] - -- len - if 4 == mod len 8 [prin "^/"] - ] - print "" -][ - ordered-deck: [] - foreach r "A23456789TJQK" [foreach s "♣♦♥♠" [ append ordered-deck ajoin [r s] ] ] - ;; Microsoft linear congruential generator - state: 0 - rng: does [ - state: (state * 214013 + 2531011) & 0#7fffffff - state >> 16 - ] -] - -deal-FreeCell 1 -deal-FreeCell 617 -deal-FreeCell 1 + random 32000 diff --git a/Task/Deal-cards-for-FreeCell/Run-BASIC/deal-cards-for-freecell.basic b/Task/Deal-cards-for-FreeCell/Run-BASIC/deal-cards-for-freecell.basic index 118b197ef2..22303022fe 100644 --- a/Task/Deal-cards-for-FreeCell/Run-BASIC/deal-cards-for-freecell.basic +++ b/Task/Deal-cards-for-FreeCell/Run-BASIC/deal-cards-for-freecell.basic @@ -1,13 +1,13 @@ -projectDir$ = "a_project" ' project directory -imageDir$ = DefaultDir$ + "\projects\" + projectDir$ + "\image\" ' directory of deck images -imagePath$ = "../";projectDir$;"/image/" ' path of deck images +projectDir$ = "a_project" ' project directory +imageDir$ = DefaultDir$ + "\projects\" + projectDir$ + "\image\" ' directory of deck images +imagePath$ = "../";projectDir$;"/image/" ' path of deck images suite$ = "C,D,H,S" ' Club,Diamond,Heart,Spades card$ = "A,2,3,4,5,6,7,8,9,T,J,Q,K" ' Cards Ace to King dim n(55) ' make ordered deck for i = 1 to 52 ' of 52 cards - n(i) = i + n(i) = i next i for i = 1 to 52 * 3 ' shuffle deck 3 times diff --git a/Task/Deal-cards-for-FreeCell/Rust/deal-cards-for-freecell.rs b/Task/Deal-cards-for-FreeCell/Rust/deal-cards-for-freecell.rust similarity index 100% rename from Task/Deal-cards-for-FreeCell/Rust/deal-cards-for-freecell.rs rename to Task/Deal-cards-for-FreeCell/Rust/deal-cards-for-freecell.rust diff --git a/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl b/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl index 1a720c5101..b7f3813278 100644 --- a/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl +++ b/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl @@ -6,19 +6,19 @@ proc show cards { set suits {\u2663 \u2666 \u2665 \u2660} set values {A 2 3 4 5 6 7 8 9 T J Q K} for {set i 0} {$i < 52} {incr i} { - set c [lindex $cards $i] - puts -nonewline [format " \033\[%dm%s\033\[m%s" [expr {32-(1+$c)%4/2}] \ - [lindex $suits [expr {$c % 4}]] [lindex $values [expr {$c / 4}]]] - if {($i&7)==7 || $i==51} {puts ""} + set c [lindex $cards $i] + puts -nonewline [format " \033\[%dm%s\033\[m%s" [expr {32-(1+$c)%4/2}] \ + [lindex $suits [expr {$c % 4}]] [lindex $values [expr {$c / 4}]]] + if {($i&7)==7 || $i==51} {puts ""} } } proc deal {seed} { for {set i 0} {$i < 52} {incr i} {lappend cards [expr {51 - $i}]} for {set i 0} {$i < 51} {incr i} { - set j [expr {51 - [rnd]%(52-$i)}] - set tmp [lindex $cards $i] - lset cards $i [lindex $cards $j] - lset cards $j $tmp + set j [expr {51 - [rnd]%(52-$i)}] + set tmp [lindex $cards $i] + lset cards $i [lindex $cards $j] + lset cards $j $tmp } return $cards } diff --git a/Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts b/Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts deleted file mode 100644 index 127f2fd09c..0000000000 --- a/Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts +++ /dev/null @@ -1,133 +0,0 @@ -/* TypeScript code for dealing Microsoft FreeCell / FreeCell Pro deals. - * Copyright by Shlomi Fish, 2011. - * Released under the MIT/Expat License - * ( http://en.wikipedia.org/wiki/MIT_License ). - */ -function perl_range(start: number, end: number): number[] { - const ret: number[] = []; - - for (let i = start; i <= end; ++i) { - ret.push(i); - } - - return ret; -} - -// 33 bit -const MAX_SEED: bigint = (BigInt(1) << BigInt(31 + 2)) - BigInt(1); -const X = BigInt(1) << BigInt(32); - -/* - * Microsoft C Run-time-Library-compatible Random Number Generator - * */ -class MSRand { - private gamenumber: string; - private _seed: bigint; - private _seedx: bigint; - constructor(args) { - const that = this; - that.gamenumber = args.gamenumber; - const _seed = BigInt(that.gamenumber); - that._seed = _seed; - that._seedx = _seed < X ? _seed : _seed - X; - return; - } - public getSeed(): bigint { - const that = this; - return that._seed; - } - private setSeed(seed: bigint): void { - const that = this; - that._seed = seed; - return; - } - - private _rando(): bigint { - const that = this; - that._seedx = - (that._seedx * BigInt(214013) + BigInt(2531011)) & MAX_SEED; - return (that._seedx >> BigInt(16)) & BigInt(0x7fff); - } - private _randp(): bigint { - const that = this; - that._seedx = - (that._seedx * BigInt(214013) + BigInt(2531011)) & MAX_SEED; - return (that._seedx >> BigInt(16)) & BigInt(0xffff); - } - public raw_rand(): bigint { - const that = this; - - if (that._seed < X) { - const ret = that._rando(); - return that._seed < BigInt(0x8) << BigInt(28) - ? ret - : ret | BigInt(0x8000); - } else { - return that._randp() + BigInt(1); - } - } - public max_rand(mymax: bigint): bigint { - const that = this; - return that.raw_rand() % mymax; - } - public shuffle(deck: Array): Array { - const that = this; - if (deck.length) { - let i = deck.length; - while (--i) { - const j = Number(that.max_rand(BigInt(i + 1))); - const tmp = deck[i]; - deck[i] = deck[j]; - deck[j] = tmp; - } - } - return deck; - } -} -/* - * Microsoft Windows Freecell / Freecell Pro boards generation. - * - * See: - * - * - http://rosettacode.org/wiki/Deal_cards_for_FreeCell - * - * - http://www.solitairelaboratory.com/mshuffle.txt - * - * Under MIT/Expat Licence. - * - * */ - -export function deal_ms_fc_board(gamenumber: string): string { - const randomizer = new MSRand({ - gamenumber: gamenumber, - }); - const num_cols: number = 8; - - const columns: Array> = perl_range(0, num_cols - 1).map( - () => { - return []; - }, - ); - let deck: Array = perl_range(0, 4 * 13 - 1); - - randomizer.shuffle(deck); - - deck = deck.reverse(); - - for (let i = 0; i < 52; ++i) { - columns[i % num_cols].push(deck[i]); - } - - function render_card(card: number): String { - const suit = card % 4; - const rank = Math.floor(card / 4); - - return "A23456789TJQK".charAt(rank) + "CDHS".charAt(suit); - } - - function render_column(col: Array): String { - return ": " + col.map(render_card).join(" ") + "\n"; - } - - return columns.map(render_column).join(""); -} diff --git a/Task/Deal-cards-for-FreeCell/UNIX-Shell/deal-cards-for-freecell.sh b/Task/Deal-cards-for-FreeCell/UNIX-Shell/deal-cards-for-freecell.sh index 66ce8c7fcd..99294c2331 100644 --- a/Task/Deal-cards-for-FreeCell/UNIX-Shell/deal-cards-for-freecell.sh +++ b/Task/Deal-cards-for-FreeCell/UNIX-Shell/deal-cards-for-freecell.sh @@ -1,22 +1,22 @@ test $# -gt 0 || set -- $((RANDOM % 32000)) for seed; do - print Game $seed: + print Game $seed: - # Shuffle deck. - deck=({A,{2..9},T,J,Q,K}{C,D,H,S}) - for i in {52..1}; do - ((seed = (214013 * seed + 2531011) & 0x7fffffff)) - ((j = (seed >> 16) % i + 1)) - t=$deck[$i] - deck[$i]=$deck[$j] - deck[$j]=$t - done + # Shuffle deck. + deck=({A,{2..9},T,J,Q,K}{C,D,H,S}) + for i in {52..1}; do + ((seed = (214013 * seed + 2531011) & 0x7fffffff)) + ((j = (seed >> 16) % i + 1)) + t=$deck[$i] + deck[$i]=$deck[$j] + deck[$j]=$t + done - # Deal cards. - print -n ' ' - for i in {52..1}; do - print -n ' '$deck[$i] - ((i % 8 == 5)) && print -n $'\n ' - done - print + # Deal cards. + print -n ' ' + for i in {52..1}; do + print -n ' '$deck[$i] + ((i % 8 == 5)) && print -n $'\n ' + done + print done diff --git a/Task/Deal-cards-for-FreeCell/VBA/deal-cards-for-freecell.vba b/Task/Deal-cards-for-FreeCell/VBA/deal-cards-for-freecell.vba deleted file mode 100644 index 1f1fe6df9a..0000000000 --- a/Task/Deal-cards-for-FreeCell/VBA/deal-cards-for-freecell.vba +++ /dev/null @@ -1,61 +0,0 @@ -Option Explicit -Private stateMS As Variant - -Private Function ms() As Integer - Dim temp1 As Variant, temp2 As Variant, temp3 As Variant - temp1 = CDec(214013 * stateMS + 2531011) - temp2 = temp1 / 2 ^ 31 - temp3 = CDec(WorksheetFunction.Floor_Precise(temp2)) - stateMS = temp1 - (2 ^ 31) * temp3 - ms = stateMS \ 2 ^ 16 -End Function - -Public Sub main() - Dim i As Integer, j As Integer, k As Integer, s As Integer, v As Integer, no As Integer - Dim tmpArr(0 To 51) As Integer - Dim suit As String, value As String, row As String - Dim gameNumbers As Variant - - suit = "CDHS" - value = "A23456789TJQK" - - gameNumbers = Array(1, 617) - - For i = 0 To UBound(gameNumbers) - - stateMS = CDec(gameNumbers(i)) - - For j = 0 To 51 - tmpArr(j) = j - Next j - - For j = 51 To 0 Step -1 - no = ms Mod (j + 1) - Call changePosition(tmpArr(), j, no) - Next j - - Debug.Print "Game " & gameNumbers(i) & ":" - k = 0 - Do While k < 52 - For j = 0 To 7 - s = 1 + tmpArr(51 - k) Mod 4 - v = 1 + tmpArr(51 - k) \ 4 - row = row & Mid(value, v, 1) & Mid(suit, s, 1) & IIf(j < 7 and k < 51, " ", "") - k = k + 1 - If k > 51 Then Exit For - Next j - Debug.Print row - row = "" - Loop - Debug.Print - - Next i - -End Sub - -Private Sub changePosition(ByRef arr() As Integer, pos1 As Integer, pos2 As Integer) - Dim tempPos As String - tempPos = arr(pos1) - arr(pos1) = arr(pos2) - arr(pos2) = tempPos -End Sub diff --git a/Task/Deal-cards-for-FreeCell/Zig/deal-cards-for-freecell.zig b/Task/Deal-cards-for-FreeCell/Zig/deal-cards-for-freecell.zig deleted file mode 100644 index 6715018a48..0000000000 --- a/Task/Deal-cards-for-FreeCell/Zig/deal-cards-for-freecell.zig +++ /dev/null @@ -1,76 +0,0 @@ -const std = @import("std"); - -const Card = struct { - value: u6 = 0, - - pub fn print(card: Card) void { - const n: u8 = switch (card.value >> 2) { - 0 => 'A', - 1 => '2', - 2 => '3', - 3 => '4', - 4 => '5', - 5 => '6', - 6 => '7', - 7 => '8', - 8 => '9', - 9 => 'T', - 10 => 'J', - 11 => 'Q', - 12 => 'K', - else => unreachable, - }; - const s: u21 = switch (card.value & 0x3) { - 0 => '\u{2663}', // Club - 1 => '\u{2666}', // Diamond - 2 => '\u{2665}', // Heart - 3 => '\u{2660}', // Spade - else => unreachable, - }; - std.debug.print("{c}{u} ", .{ n, s }); - } -}; - -const Rand = struct { - seed: u31 = 0, - pub fn seed(rand: *Rand, value: u31) void { - rand.seed = value; - } - - pub fn next(rand: *Rand) u16 { - const new_seed = rand.seed *% 214013 +% 2531011; - rand.seed = new_seed; - return @truncate(new_seed >> 16); - } -}; - -pub fn deal(n: u31) void { - const print = std.debug.print; - var buffer: [52]u8 = undefined; - var fba = std.heap.FixedBufferAllocator.init(&buffer); - const allocator = fba.allocator(); - - var deck = std.ArrayListUnmanaged(Card).initCapacity(allocator, 52) catch unreachable; - var card: Card = .{}; - - while (card.value < 52) : (card.value += 1) { - deck.appendAssumeCapacity(card); - } - - var col: usize = 0; - var rand = Rand{ .seed = n }; - print("Deal {d}:\n", .{n}); - while (deck.items.len > 0) { - card = deck.swapRemove(rand.next() % deck.items.len); - card.print(); - col = (col + 1) % 8; - if (col == 0) - print("\n", .{}); - } - print("\n\n", .{}); -} - -pub fn main() !void { - deal(1); - deal(617); -} diff --git a/Task/Death-Star/11l/death-star.11l b/Task/Death-Star/11l/death-star.11l index 629b3b6f51..23b604e42c 100644 --- a/Task/Death-Star/11l/death-star.11l +++ b/Task/Death-Star/11l/death-star.11l @@ -1,4 +1,10 @@ -T Sphere = (Float cx, Float cy, Float cz, Float r) +T Sphere + Float cx, cy, cz, r + F (cx, cy, cz, r) + .cx = cx + .cy = cy + .cz = cz + .r = r F dotp(v1, v2) V d = dot(v1, v2) diff --git a/Task/Death-Star/ALGOL-68/death-star.alg b/Task/Death-Star/ALGOL-68/death-star.alg deleted file mode 100644 index a7b6af136b..0000000000 --- a/Task/Death-Star/ALGOL-68/death-star.alg +++ /dev/null @@ -1,86 +0,0 @@ -BEGIN # draw a "Death Star" - translated from the C and 11l samples # - STRING shades = ".:!*oe&#%@"; - - PROC normalize = ( []REAL v )[]REAL: - BEGIN - REAL len = sqrt( v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] + v[ 3 ] * v[ 3 ] ); - ( v[ 1 ] / len, v[ 2 ] / len, v[ 3 ] / len ) - END # normalize # ; - - PROC dot = ( []REAL x, y )REAL: - BEGIN - REAL d = x[ 1 ] * y[ 1 ] + x[ 2 ] * y[ 2 ] + x[ 3 ] * y[ 3 ]; - IF d < 0 THEN - d ELSE 0 FI - END # dot # ; - - MODE SPHERE = STRUCT( REAL cx, cy, cz, r ); - - # positive shpere and negative sphere # - SPHERE pos = ( 20, 20, 0, 20 ), neg = ( 1, 1, -6, 20 ); - - # check if a ray (x,y, -inf)->(x, y, inf) hits a sphere; if so, return # - # the intersecting z values. z1 is closer to the eye # - PROC hit_sphere = ( SPHERE sph, REAL x in, y in, REF REAL z1, z2 )BOOL: - IF REAL x = x in - cx OF sph; - REAL y = y in - cy OF sph; - REAL zsq := r OF sph * r OF sph - ( x * x + y * y ); - zsq < 0 - THEN FALSE - ELSE zsq := sqrt( zsq ); - z1 := cz OF sph - zsq; - z2 := cz OF sph + zsq; - TRUE - FI # hit_sphere # ; - - PROC draw_sphere = ( REAL k, ambient, []REAL light )VOID: - FOR i FROM ENTIER ( cy OF pos - r OF pos ) TO ENTIER ( cy OF pos + r OF pos ) + 1 DO - REAL y := i + 0.5; - FOR j FROM ENTIER ( cx OF pos - 2 * r OF pos ) TO ENTIER (cx OF pos + 2 * r OF pos ) + 1 DO - REAL x := ( j - cx OF pos ) / 2.0 + 0.5 + cx OF pos; - REAL zb1 := 0, zb2 := 0, zs1 := 0, zs2 := 0; - INT hit_result - = IF NOT hit_sphere( pos, x, y, zb1, zb2 ) THEN - 0 # ray lands in blank space, draw bg # - ELIF NOT hit_sphere( neg, x, y, zs1, zs2 ) THEN - 1 # ray hits pos sphere but not neg, draw pos sphere surface # - ELIF zs1 > zb1 THEN - 1 # ray hits both, but pos front surface is closer # - ELIF zs2 > zb2 THEN - 0 # pos sphere surface is inside neg sphere, show bg # - ELIF zs2 > zb1 THEN - 2 # back surface on neg sphere is inside pos sphere, # - # the only place where neg sphere surface will be shown # - ELSE - 1 # show the pos sphere # - FI; - IF hit_result = 0 THEN - print( ( " " ) ) - ELSE - []REAL vec = - normalize( IF hit_result = 1 - THEN []REAL( x - cx OF pos - , y - cy OF pos - , zb1 - cz OF pos - ) - ELSE []REAL( cx OF neg - x - , cy OF neg - y - , cz OF neg - zs2 - ) - FI - ); - REAL b = ( dot( light, vec ) ^ k ) + ambient; - INT intensity := ENTIER ( ( 1 - b ) * ( ( UPB shades - LWB shades ) + 1 ) ) + 1; - IF intensity < LWB shades THEN intensity := LWB shades - ELIF intensity > UPB shades THEN intensity := UPB shades - FI; - print( ( shades[ intensity ] ) ) - FI - OD; - print( ( newline ) ) - OD # draw_sphere # ; - - BEGIN - []REAL light = ( -50, 30, 50 ); - draw_sphere( 2, 0.5, normalize( light ) ) - END -END diff --git a/Task/Death-Star/Ada/death-star.adb b/Task/Death-Star/Ada/death-star.ada similarity index 100% rename from Task/Death-Star/Ada/death-star.adb rename to Task/Death-Star/Ada/death-star.ada diff --git a/Task/Death-Star/Delphi/death-star.pas b/Task/Death-Star/Delphi/death-star.delphi similarity index 100% rename from Task/Death-Star/Delphi/death-star.pas rename to Task/Death-Star/Delphi/death-star.delphi diff --git a/Task/Death-Star/EasyLang/death-star.easy b/Task/Death-Star/EasyLang/death-star.easy deleted file mode 100644 index 1bd9f161cb..0000000000 --- a/Task/Death-Star/EasyLang/death-star.easy +++ /dev/null @@ -1,62 +0,0 @@ -func vdot a[] b[] . - for i to len a[] : r += a[i] * b[i] - return r -. -proc normalize &v[] . - d = vdot v[] v[] - invl = 1 / sqrt d - for i to 3 : v[i] *= invl -. -func testhit &s[] x y &z1 &z2 . - x -= s[1] - y -= s[2] - zsq = s[4] * s[4] - (x * x + y * y) - if zsq >= 0 - zsqrt = sqrt zsq - z1 = s[3] - zsqrt - z2 = s[3] + zsqrt - return 1 - . -. -proc death_star &pos[] &neg[] k amb dir[] . - len vec[] 3 - for y = pos[2] - pos[4] to pos[2] + pos[4] - for x = pos[1] - pos[4] to pos[1] + pos[4] - if testhit pos[] x y zb1 zb2 = 1 - draw = 1 - hit = testhit neg[] x y zs1 zs2 - if hit = 1 - if zs1 > zb1 - hit = 0 - elif zs2 > zb2 - draw = 0 - . - . - if draw = 1 - if hit = 1 - vec[1] = neg[1] - x - vec[2] = neg[2] - y - vec[3] = neg[3] - zs2 - else - vec[1] = x - neg[1] - vec[2] = y - neg[2] - vec[3] = zb1 - neg[3] - . - normalize vec[] - s = vdot dir[] vec[] - if s < 0 : s = 0 - lum = (pow s k + amb) / (1 + amb) - gcolor3 lum lum lum - grect 50 + x / 4, 50 + y / 4, 0.25 0.24 - . - . - . - . -. -gbackground 000 -gclear -dir[] = [ 20 40 -10 ] -normalize dir[] -pos[] = [ 0 0 0 120 ] -neg[] = [ -90 90 -30 100 ] -death_star pos[] neg[] 1.5 0.2 dir[] diff --git a/Task/Death-Star/FreeBASIC/death-star-1.basic b/Task/Death-Star/FreeBASIC/death-star-1.basic deleted file mode 100644 index 9d5cf04046..0000000000 --- a/Task/Death-Star/FreeBASIC/death-star-1.basic +++ /dev/null @@ -1,96 +0,0 @@ -Enum - x_ - y_ - z_ - r_ -End Enum - -Function clamp(x As Double, b As Double, t As Double) As Double - If x < b Then - Return b - Elseif x > t Then - Return t - Else - Return x - End If -End Function - -Function dot(v() As Double, w() As Double) As Double - Return v(x_) * w(x_) + v(y_) * w(y_) + v(z_) * w(z_) -End Function - -Sub normal(v() As Double, result() As Double) - Dim As Double ilen = 1 / Sqr(dot(v(), v())) - result(x_) = v(x_) * ilen - result(y_) = v(y_) * ilen - result(z_) = v(z_) * ilen -End Sub - -Function hitTest(s() As Double, x As Double, y As Double, result() As Double) As Boolean - Dim As Double z = s(r_)^2 - (x - s(x_))^2 - (y - s(y_))^2 - If z >= 0 Then - z = Sqr(z) - result(0) = s(z_) - z - result(1) = s(z_) + z - Return True - Else - Return False - End If -End Function - -Sub DeathStar(posic() As Double, neg() As Double, sun() As Double, k As Double, amb As Double) - Dim As Double x, y, b - Dim As String shades(10) = {" ", ".", ":", "!", "*", "o", "e", "&", "#", "%", "@"} - Dim As Integer result, shade - Dim As Double hp(1), hn(1), xx(2), temp1(2), temp2(2) - - For y = posic(y_) - posic(r_) - 0.5 To posic(y_) + posic(r_) + 0.5 Step 1 - For x = posic(x_) - posic(r_) - 0.5 To posic(x_) + posic(r_) + 0.5 Step 1 - If hitTest(posic(), x, y, hp()) = 0 Then - result = 0 - Elseif hitTest(neg(), x, y, hn()) = 0 Then - result = 1 - Elseif hn(0) > hp(0) Then - result = 1 - Elseif hn(1) > hp(1) Then - result = 0 - Elseif hn(1) > hp(0) Then - result = 2 - Else - result = 1 - End If - - shade = -1 - Select Case result - Case 0 - shade = 0 - Case 1 - temp1(x_) = x - posic(x_) - temp1(y_) = y - posic(y_) - temp1(z_) = hp(0) - posic(z_) - normal(temp1(), xx()) - Case 2 - temp2(x_) = neg(x_) - x - temp2(y_) = neg(y_) - y - temp2(z_) = neg(z_) - hn(1) - normal(temp2(), xx()) - End Select - If shade <> 0 Then - b = dot(sun(), xx())^k + amb - shade = clamp((1 - b) * Ubound(shades), 1, Ubound(shades)) - End If - Print String(2, shades(shade)); - Next - Print - Next -End Sub - -Dim As Double posic(3) = {20, 20, 0, 20} -Dim As Double neg(3) = {10, 10, -15, 10} -Dim As Double sun(2) -Dim As Double temp3(2) = {-2, 1, 3} -normal(temp3(), sun()) - -DeathStar(posic(), neg(), sun(), 2, 0.1) - -Sleep diff --git a/Task/Death-Star/FreeBASIC/death-star-2.basic b/Task/Death-Star/FreeBASIC/death-star-2.basic deleted file mode 100644 index 008d4ea2d0..0000000000 --- a/Task/Death-Star/FreeBASIC/death-star-2.basic +++ /dev/null @@ -1,100 +0,0 @@ -Type vector - v(2) As Double -End Type - -Type sphere - cx As Integer - cy As Integer - cz As Integer - r As Integer -End Type - -Function dot(x As vector, y As vector) As Double - Return x.v(0)*y.v(0) + x.v(1)*y.v(1) + x.v(2)*y.v(2) -End Function - -Sub normalizeVector(v As vector) - Dim invLen As Double = 1.0 / Sqr(dot(v, v)) - v.v(0) *= invLen - v.v(1) *= invLen - v.v(2) *= invLen -End Sub - -Function hitSphere(s As sphere, x As Integer, y As Integer, z1 As Double Ptr, z2 As Double Ptr) As Boolean - Dim xx As Integer = x - s.cx - Dim yy As Integer = y - s.cy - Dim zsq As Integer = s.r*s.r - (xx*xx + yy*yy) - - If zsq >= 0 Then - Dim zsqrt As Double = Sqr(zsq) - *z1 = s.cz - zsqrt - *z2 = s.cz + zsqrt - Return True - End If - Return False -End Function - -Function createDeathStar(posic As sphere, neg As sphere, k As Double, amb As Double, direc As vector) As Any Ptr - Dim As Integer w = posic.r * 4 - Dim As Integer h = posic.r * 3 - - Dim As Any Ptr img = Imagecreate(w, h, Rgb(0,0,0)) - - Dim vec As vector - Dim As Double z1, z2, zs1, zs2 - - For y As Integer = posic.cy - posic.r To posic.cy + posic.r - For x As Integer = posic.cx - posic.r To posic.cx + posic.r - If hitSphere(posic, x, y, @z1, @z2) Then - Dim hit As Boolean = hitSphere(neg, x, y, @zs1, @zs2) - - If hit Then - If zs1 > z1 Then hit = False - If zs2 > z2 Then Continue For - End If - - If hit Then - vec.v(0) = neg.cx - x - vec.v(1) = neg.cy - y - vec.v(2) = neg.cz - zs2 - Else - vec.v(0) = x - posic.cx - vec.v(1) = y - posic.cy - vec.v(2) = z1 - posic.cz - End If - - normalizeVector(vec) - Dim s As Double = dot(direc, vec) - If s < 0 Then s = 0 - - Dim lum As Double = 255 * (s^k + amb) / (1 + amb) - If lum < 0 Then lum = 0 - If lum > 255 Then lum = 255 - - Dim shade As Integer = lum - Pset img, (x + w\2, y + h\2), Rgb(shade, shade, shade) - End If - Next x - Next y - - Return img -End Function - -' Main program -Screenres 500, 400, 32 -Windowtitle "Death Star FreeBASIC" - -Dim direct As vector -direct.v(0) = 20 -direct.v(1) = -40 -direct.v(2) = -10 -normalizeVector(direct) - -Dim posic As sphere = Type(0, 0, 0, 120) -Dim neg As sphere = Type(-50, -50, -30, 75) - -Dim img As Any Ptr = createDeathStar(posic, neg, 1.5, 0.2, direct) -Put (0, 0), img -Imagedestroy(img) - -Sleep diff --git a/Task/Death-Star/FutureBasic/death-star-1.basic b/Task/Death-Star/FutureBasic/death-star-1.basic deleted file mode 100644 index b46ca64359..0000000000 --- a/Task/Death-Star/FutureBasic/death-star-1.basic +++ /dev/null @@ -1,86 +0,0 @@ -_window = 1 -begin enum 1 - _circularView - _OvalView -end enum - -void local fn BuildWindow - CGRect r = fn CGRectMake( 0, 0, 400, 400 ) - window _window, @"Rosetta Code Death Star", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable - WindowSetBackgroundColor( _window, fn ColorBlack ) - - r = fn CGRectMake( 20, 20, 360, 360 ) - subclass view _circularView, r, _window - - r = fn CGRectMake( 50, 170, 200, 180 ) - subclass view _OvalView,r, _circularView -end fn - -local fn OvalView( tag as NSInteger ) - CGRect r = fn ViewBounds( tag ) - ViewSetWantsLayer( tag, YES ) - CFArrayRef cols = @[fn ColorWithRGB(0.125,0.125,0.125,1),fn ColorWithRGB(0.425,0.425,0.4425,1),fn ColorWithRGB(0.725,0.725,0.725,1),fn ColorWithRGB(0.925,0.925,0.925,1),fn ColorWhite,fn ColorWhite ] - - CALayerRef layer = fn CALayerInit - ViewSetLayer( tag, layer ) - CALayerSetCornerRadius( layer, r.size.height / 2.0 ) - CALayerSetMasksToBounds( layer, YES ) - CALayerSetBorderWidth( layer, 0.25 ) - CALayerSetBorderColor( layer, fn ColorBlue ) - - CAGradientLayerRef gradLayer = fn CAGradientLayerInit - CAGradientLayerSetColors( gradLayer, cols ) - CALayerSetCornerRadius( gradLayer, r.size.Height / 2.0 ) - CAGradientLayerSetStartPoint( gradLayer, fn CGPointMake(1,0) ) - CAGradientLayerSetEndPoint( gradLayer, fn CGPointMake(0,1) ) - CALayerSetShadowOffset( gradLayer, fn CGSizeMake( 10, -10 ) ) - CALayerSetShadowRadius( gradLayer, 3.0 ) - CALayerSetShadowOpacity( gradLayer, 0.4 ) - CALayerSetFrame( gradLayer, fn CGRectMake(0,0,200,200) ) - - CALayerAddSublayer( layer, gradLayer ) -end fn - -local fn CircularView( tag as NSinteger ) - CGRect r = fn ViewBounds( tag ) - ViewSetWantsLayer( tag, YES ) - CFArrayRef cols = @[fn ColorWithRGB(0.125,0.125,0.125,1),fn ColorWithRGB(0.425,0.425,0.4425,1),fn ColorWithRGB(0.725,0.725,0.725,1),fn ColorWithRGB(0.925,0.925,0.925,1),fn ColorWhite,fn ColorWhite ] - CALayerRef layer = fn CALayerInit - - ViewSetLayer( tag, layer ) - CALayerSetCornerRadius( layer, r.size.width / 2.0 ) - CALayerSetMasksToBounds( layer, YES ) - CALayerSetBorderWidth( layer, 0.25 ) - CALayerSetBorderColor( layer, fn ColorBlack ) - - CAGradientLayerRef gradLayer = fn CAGradientLayerInit - CALayerSetCornerRadius( gradLayer, r.size.width / 2.0 ) - CAGradientLayerSetColors( gradLayer, cols ) - CAGradientLayerSetStartPoint( gradLayer, fn CGPointMake( 0,0.2 ) ) - CAGradientLayerSetEndPoint( gradLayer, fn CGPointMake( 1,1 ) ) - CALayerSetShadowOffset( gradLayer, fn CGSizeMake( 10, -10 ) ) - CALayerSetShadowRadius( gradLayer, 3.0 ) - CALayerSetShadowOpacity( gradLayer, 0.4 ) - CALayerSetFrame( gradLayer, fn CGRectMake(0,0,360,360) ) - CALayerAddSublayer( layer, gradLayer ) -end fn - - -void local fn DoDialog( ev as long, tag as long, wnd as long ) - select ( ev ) - case _viewDrawRect - select ( tag ) - case _circularView : fn CircularView( tag ) - - case _OvalView : fn OvalView( tag) - - end select - case _windowWillClose : end - end select -end fn - -on dialog fn DoDialog - -fn BuildWindow - -HandleEvents diff --git a/Task/Death-Star/FutureBasic/death-star-2.basic b/Task/Death-Star/FutureBasic/death-star-2.basic deleted file mode 100644 index 18d86f6adf..0000000000 --- a/Task/Death-Star/FutureBasic/death-star-2.basic +++ /dev/null @@ -1,60 +0,0 @@ -_window = 1 -begin enum 1 - _circularView - _ovalView -end enum - -void local fn BuildWindow - CGRect r = fn CGRectMake( 0, 0, 400, 400 ) - - window _window, @"Death Star", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable - WindowSetBackgroundColor( _window, fn ColorBlack ) - - r = fn CGRectMake( 20, 20, 360, 360 ) - subclass view _circularView, r - - r = fn CGRectMake( 0, 120, 200, 200 ) - subclass view _ovalView, r -end fn - -local fn OvalView( tag as NSInteger ) - CGRect r = fn ViewBounds( tag ) - r.size.height *= 0.5 - CFArrayRef cols = @[fn ColorWithWhite(0.8,1),fn ColorBlack] - BezierPathRef path = fn BezierPathWithOvalInRect( r ) - GradientRef grad = fn GradientWithColors( cols ) - GraphicsContextSaveGraphicsState - AffineTransformRef tx = fn AffineTransformInit - NSPoint center = fn CGPointMake( fn CGRectGetMidX(r), fn CGRectGetMidY(r)) - center.x -= 25 - AffineTransformTranslate( tx, center.x, center.y ) - AffineTransformRotateByDegrees( tx, 52 ) - AffineTransformConcat( tx ) - GradientDrawInBezierPath( grad, path, 0.0 ) - GraphicsContextRestoreGraphicsState -end fn - -local fn CircularView( tag as NSinteger ) - CGRect r = fn ViewBounds( tag ) - CFArrayRef cols = @[fn ColorWithWhite(0.1,1),fn ColorWhite] - BezierPathRef path = fn BezierPathWithOvalInRect( r ) - GradientRef grad = fn GradientWithColors( cols ) - GradientDrawInBezierPath( grad, path, 0.0 ) -end fn - -void local fn DoDialog( ev as long, tag as long ) - select ( ev ) - case _viewDrawRect - select ( tag ) - case _circularView : fn CircularView( tag ) - case _ovalView : fn OvalView( tag) - end select - case _windowWillClose : end - end select -end fn - -on dialog fn DoDialog - -fn BuildWindow - -HandleEvents diff --git a/Task/Death-Star/Java/death-star-2.java b/Task/Death-Star/Java/death-star-2.java deleted file mode 100644 index 42a7301cf1..0000000000 --- a/Task/Death-Star/Java/death-star-2.java +++ /dev/null @@ -1,125 +0,0 @@ -import java.awt.Color; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.List; - -import javax.imageio.ImageIO; - -public final class DeathStar { - - public static void main(String[] aArgs) throws IOException { - Vector direction = new Vector(20.0, -40.0, -10.0); - direction.normalise(); - Sphere positive = new Sphere(0, 0, 0, 120); - Sphere negative = new Sphere(-90, -90, -30, 100); - - BufferedImage image = deathStar(positive, negative, direction, 1.5, 0.5); - - ImageIO.write(image, "png", new File("DeathStarJava.png")); - } - - private static BufferedImage deathStar( - Sphere aPositive, Sphere aNegative, Vector aDirection, double aShadow, double aBrightness) { - final int width = aPositive.radius * 4; - final int height = aPositive.radius * 3; - BufferedImage result = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - Graphics graphics = result.getGraphics(); - graphics.setColor(Color.CYAN); - graphics.fillRect(0, 0, width, height); - - Vector ray = new Vector(0.0, 0.0, 0.0); - final int deltaX = aPositive.x - width / 2; - final int deltaY = aPositive.y - height / 2; - - double xMax = aPositive.x + aPositive.radius; - double yMax = aPositive.y + aPositive.radius; - for ( int y = aPositive.y - aPositive.radius; y < yMax; y++ ) { - for ( int x = aPositive.x - aPositive.radius; x < xMax; x++ ) { - List contacts = aPositive.contact(x, y); - final double zb1 = (double) contacts.get(0); - final int zb2 = (int) contacts.get(1); - final boolean positiveHit = (boolean) contacts.get(2); - if ( ! positiveHit ) { - continue; - } - contacts = aNegative.contact(x, y); - final double zs1 = (double) contacts.get(0); - final int zs2 = (int) contacts.get(1); - boolean negativeHit = (boolean) contacts.get(2); - if ( negativeHit ) { - if ( zs1 > zb1 ) { - negativeHit = false; - } else if ( zs2 > zb2 ) { - continue; - } - } - - if ( negativeHit ) { - ray.x = aNegative.x - x; - ray.y = aNegative.y - y; - ray.z = aNegative.z - zs2; - } else { - ray.x = x - aPositive.x; - ray.y = y - aPositive.y; - ray.z = zb1 - aPositive.z; - } - ray.normalise(); - double rayComponent = ray.scalarProduct(aDirection); - if ( rayComponent < 0 ) { - rayComponent = 0; - } - int color = (int) ( 255 * ( Math.pow(rayComponent, aShadow) + aBrightness) / ( 1 + aBrightness ) ); - if ( color < 0 ) { - color = 0; - } else if ( color > 255 ) { - color = 255; - } - result.setRGB(x - deltaX, y - deltaY, color); - } - } - return result; - } - - private static class Vector { - - public Vector(double aX, double aY, double aZ) { - x = aX; y = aY; z = aZ; - } - - public double scalarProduct(Vector aOther) { - return x * aOther.x + y * aOther.y + z * aOther.z; - } - - public Vector normalise() { - final double magnitude = Math.sqrt(this.scalarProduct(this)); - return new Vector(x /= magnitude, y /= magnitude, z /= magnitude); - } - - private double x, y, z; - - } - - private static class Sphere { - - public Sphere(int aX, int aY, int aZ, int aRadius) { - x = aX; y = aY; z = aZ; radius = aRadius; - } - - public List contact(int aX, int aY) { - final int xx = aX - x; - final int yy = aY - y; - final int zSquared = radius * radius - ( xx * xx + yy * yy ); - if ( zSquared >= 0 ) { - final double zz = Math.sqrt(zSquared); - return List.of(z - zz, z, true); - } - return List.of( 0.0, 0, false ); - } - - private int x, y, z, radius; - - } - -} diff --git a/Task/Death-Star/Java/death-star-1.java b/Task/Death-Star/Java/death-star.java similarity index 100% rename from Task/Death-Star/Java/death-star-1.java rename to Task/Death-Star/Java/death-star.java diff --git a/Task/Death-Star/Julia/death-star.jl b/Task/Death-Star/Julia/death-star.julia similarity index 100% rename from Task/Death-Star/Julia/death-star.jl rename to Task/Death-Star/Julia/death-star.julia diff --git a/Task/Death-Star/V-(Vlang)/death-star.v b/Task/Death-Star/V-(Vlang)/death-star.v deleted file mode 100644 index 255675b459..0000000000 --- a/Task/Death-Star/V-(Vlang)/death-star.v +++ /dev/null @@ -1,106 +0,0 @@ -import math - -enum Axis { - x_ - y_ - z_ - r_ -} - -fn clamp(x f64, b f64, t f64) f64 { - if x < b { return b } - else if x > t { return t } - else { return x } -} - -fn dot(v []f64, w []f64) f64 { - return v[int(Axis.x_)] * w[int(Axis.x_)] + - v[int(Axis.y_)] * w[int(Axis.y_)] + - v[int(Axis.z_)] * w[int(Axis.z_)] -} - -fn normal(v []f64, mut result []f64) { - ilen := 1.0 / f64(math.sqrt(dot(v, v))) - result[int(Axis.x_)] = v[int(Axis.x_)] * ilen - result[int(Axis.y_)] = v[int(Axis.y_)] * ilen - result[int(Axis.z_)] = v[int(Axis.z_)] * ilen -} - -fn hit_test(s []f64, x f64, y f64, mut result []f64) bool { - mut z := s[int(Axis.r_)] * s[int(Axis.r_)] - (x - s[int(Axis.x_)]) * (x - s[int(Axis.x_)]) - - (y - s[int(Axis.y_)]) * (y - s[int(Axis.y_)]) - if z >= 0 { - z = math.sqrt(z) - result[0] = s[int(Axis.z_)] - z - result[1] = s[int(Axis.z_)] + z - return true - } - else { return false } -} - -fn death_star(posic []f64, neg []f64, sun []f64, k f64, amb f64) { - mut xx, mut temp1, mut temp2 := []f64{len: 3}, []f64{len: 3}, []f64{len: 3} - mut hp, mut hn := []f64{len: 2}, []f64{len: 2} - mut result_val, mut shade := 0, -1 - shades := [' ', '.', ':', '!', '*', 'o', 'e', '&', '#', '%', '@'] - y_start := int(posic[int(Axis.y_)] - posic[int(Axis.r_)] - 0.5) - y_end := int(posic[int(Axis.y_)] + posic[int(Axis.r_)] + 0.5) - x_start := int(posic[int(Axis.x_)] - posic[int(Axis.r_)] - 0.5) - x_end := int(posic[int(Axis.x_)] + posic[int(Axis.r_)] + 0.5) - for y in y_start .. y_end + 1 { - mut line := '' - for x in x_start .. x_end + 1 { - result_val = 0 - if !hit_test(posic, f64(x), f64(y), mut hp) { result_val = 0 } - else if !hit_test(neg, f64(x), f64(y), mut hn) { result_val = 1 } - else if hn[0] > hp[0] { result_val = 1 } - else if hn[1] > hp[1] { result_val = 0 } - else if hn[1] > hp[0] { result_val = 2 } - else { result_val = 1 } - shade = -1 - match result_val { - 0 { - shade = 0 - } - 1 { - temp1[int(Axis.x_)] = f64(x) - posic[int(Axis.x_)] - temp1[int(Axis.y_)] = f64(y) - posic[int(Axis.y_)] - temp1[int(Axis.z_)] = hp[0] - posic[int(Axis.z_)] - normal(temp1, mut xx) - } - 2 { - temp2[int(Axis.x_)] = neg[int(Axis.x_)] - f64(x) - temp2[int(Axis.y_)] = neg[int(Axis.y_)] - f64(y) - temp2[int(Axis.z_)] = neg[int(Axis.z_)] - hn[1] - normal(temp2, mut xx) - } - else {} - } - - if shade != 0 { - b := math.pow(dot(sun, xx), k) + amb - shade = int(clamp((1.0 - b) * f64(shades.len - 1), 1, f64(shades.len - 1))) - } - line += shades[shade].str() - } - println(line) - } -} - -fn main() { - mut posic, mut neg := []f64{len: 4}, []f64{len: 4} - mut temp3, mut sun := []f64{len: 3}, []f64{len: 3} - posic[int(Axis.x_)] = 20 - posic[int(Axis.y_)] = 20 - posic[int(Axis.z_)] = 0 - posic[int(Axis.r_)] = 20 - neg[int(Axis.x_)] = 10 - neg[int(Axis.y_)] = 10 - neg[int(Axis.z_)] = -15 - neg[int(Axis.r_)] = 10 - temp3[0] = -2 - temp3[1] = 1 - temp3[2] = 3 - normal(temp3, mut sun) - death_star(posic, neg, sun, 2, 0.1) -} diff --git a/Task/Death-Star/VBScript/death-star.vbs b/Task/Death-Star/VBScript/death-star.vb similarity index 100% rename from Task/Death-Star/VBScript/death-star.vbs rename to Task/Death-Star/VBScript/death-star.vb diff --git a/Task/Death-Star/Zig/death-star-5.zig b/Task/Death-Star/Zig/death-star-5.zig index 97e28f0ac7..af3ddd2aec 100644 --- a/Task/Death-Star/Zig/death-star-5.zig +++ b/Task/Death-Star/Zig/death-star-5.zig @@ -14,9 +14,9 @@ fn Sphere(comptime T: type) type { pub fn hit(self: *const Self, xx: T, yy: T) ?SphereHit(T) { const x = xx - self.cx; const y = yy - self.cy; - const zsq = self.r * self.r - x * x - y * y; + var zsq = self.r * self.r - x * x - y * y; if (zsq >= 0) { - const zsqrt = std.math.sqrt(zsq); + var zsqrt = std.math.sqrt(zsq); return .{ .z1 = self.cz - zsqrt, .z2 = self.cz + zsqrt }; } return null; diff --git a/Task/Death-Star/Zig/death-star-6.zig b/Task/Death-Star/Zig/death-star-6.zig index 0d5fe2337a..4ffc6b3a12 100644 --- a/Task/Death-Star/Zig/death-star-6.zig +++ b/Task/Death-Star/Zig/death-star-6.zig @@ -18,8 +18,8 @@ fn DeathStar(comptime T: type) type { const k: T = 1.5; const amb: T = 0.2; - const w: usize = @intFromFloat(pos.r * 4); - const h: usize = @intFromFloat(pos.r * 3); + var w: usize = @intFromFloat(pos.r * 4); + var h: usize = @intFromFloat(pos.r * 3); var img = try ImageData().init(allocator, "deathStar", w, h); var vec = Vector(T).zero(); diff --git a/Task/Death-Star/Zig/death-star-8.zig b/Task/Death-Star/Zig/death-star-8.zig index 6a008adefb..378163b7de 100644 --- a/Task/Death-Star/Zig/death-star-8.zig +++ b/Task/Death-Star/Zig/death-star-8.zig @@ -21,18 +21,18 @@ fn ImageData() type { } /// Write PGM P2 ASCII to 'writer' pub fn print(self: *const Self, writer: anytype, optional_comments: ?[]const []const u8) !void { - try writer.print("P2\n", .{}); + _ = try writer.print("P2\n", .{}); if (optional_comments) |lines| { for (lines) |line| - try writer.print("# {s}\n", .{line}); + _ = try writer.print("# {s}\n", .{line}); } - try writer.print("{d} {d}\n{d}\n", .{ self.w, self.h, 255 }); + _ = try writer.print("{d} {d}\n{d}\n", .{ self.w, self.h, 255 }); for (self.image, 0..) |pixel, i| { const sep = if (i % self.w == self.w - 1) "\n" else " "; - try writer.print("{d}{s}", .{ pixel.w, sep }); + _ = try writer.print("{d}{s}", .{ pixel.w, sep }); } } }; diff --git a/Task/Deceptive-numbers/ALGOL-W/deceptive-numbers.alg b/Task/Deceptive-numbers/ALGOL-W/deceptive-numbers.alg deleted file mode 100644 index f52e687b01..0000000000 --- a/Task/Deceptive-numbers/ALGOL-W/deceptive-numbers.alg +++ /dev/null @@ -1,43 +0,0 @@ -begin % find deceptive numbers - repunits R(n) evenly divisible by composite % - % numbers and n+1; see the task talk page based on the second Wren sample % - - % returns true if n is an odd prime, false otherwise, uses trial division % - logical procedure isOddPrime ( integer value n ) ; - begin - logical prime; - integer f, f2, toNext; - prime := true; - f := 3; - f2 := 9; - toNext := 16; % note: ( 2n + 1 )^2 - ( 2n - 1 )^2 = 8n % - while f2 <= n and prime do begin - prime := n rem f not = 0; - f := f + 2; - f2 := toNext; - toNext := toNext + 8 - end while_f2_le_n_and_prime ; - prime - end isOddPrime ; - - begin % -- task % - integer n, count; - count := 0; - n := 47; - while begin n := n + 2; - count < 25 - end - do begin - if n rem 3 not = 0 and n rem 5 not = 0 and not isOddPrime( n ) then begin - integer mp; - mp := 10; - for p := 2 until n - 1 do mp := ( mp * 10 ) rem n; - if mp = 1 then begin - count := count + 1; - writeon( i_w := 5, s_w := 0, " ", n ); - if count rem 10 = 0 then write() - end if_mp_eq_1 - end if_have_a_candidate - end while_count_lt_50 - end task - -end. diff --git a/Task/Deceptive-numbers/AWK/deceptive-numbers.awk b/Task/Deceptive-numbers/AWK/deceptive-numbers.awk deleted file mode 100644 index 8d742a9243..0000000000 --- a/Task/Deceptive-numbers/AWK/deceptive-numbers.awk +++ /dev/null @@ -1,30 +0,0 @@ -function modpow(b, e, m, r) { - for (r = 1; e > 0; e = int(e / 2)) { - if (e % 2 == 1) - r = r * b % m - b = b * b % m - } - return r -} - -function is_pseudo(n, i, p, r) { - if (modpow(10, n - 1, n) == 1) { - r = int(sqrt(n)) - while ((p = primes[++i]) <= r) - if (n % p == 0) - return 1 - primes[++l] = n - } - return 0 -} - -BEGIN { - primes[l = 1] = n = 7 - split("4 2 4 2 4 6 2 6", wheel) - - do if (is_pseudo(n += wheel[i = i % 8 + 1])) { - printf " %u", n - ++c - } while (c != 50) - print -} diff --git a/Task/Deceptive-numbers/Amazing-Hopper/deceptive-numbers.hopper b/Task/Deceptive-numbers/Amazing-Hopper/deceptive-numbers.hopper deleted file mode 100644 index f6b79d2ecd..0000000000 --- a/Task/Deceptive-numbers/Amazing-Hopper/deceptive-numbers.hopper +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#prototype isdeceptive(_X_) -#prototype modulepow(_X_,_Y_,_Z_) -#synon _isdeceptive Isdeceptive -#synon _modulepow ModulePow -#define Breaking Goto(exit) -Main - i = 49, c=0 - Iterator ( ++i, #(c <> 10), \ - Print only if ( Is deceptive 'i', Set 'i,"\n"'; ++c ) ) -End - -Subrutines - -is deceptive ( n ) - x=7 - And( Bitand(n,1), And( Mod(n,3), Mod(n,5) )), do { - Iterator( x+=6, #( (x*x) <= n ),\ - #(!( (n%x) && (n%(x+4)) )), do{ \ - Module Pow (10, Minus one(n), n), Is equal to '1', Breaking } ) - } - Set '0' - exit: -Return - -module pow(b, e, m) - Loop for (p = 1, e, e >>= 1) - Bitand(e, 1), do{ #( p = (p * b) % m ) } - #( b = (b * b) % m ) - Next -Return (p) diff --git a/Task/Deceptive-numbers/Bc/deceptive-numbers.bc b/Task/Deceptive-numbers/Bc/deceptive-numbers.bc deleted file mode 100644 index cf0884b0b3..0000000000 --- a/Task/Deceptive-numbers/Bc/deceptive-numbers.bc +++ /dev/null @@ -1,38 +0,0 @@ -/* modular exponentiation */ -define p(b, e, m) { - auto r - for (r = 1; e > 0; e /= 2) { - if (e % 2 == 1) r = r * b % m - b = b * b % m - } - return(r) -} - -/* cache for the primes found */ -p[0] = 7 - -define d(n) { - auto i, p, r; - if (p(10, n - 1, n) == 1) { - for (r = sqrt(n); (p = p[i]) <= r; ++i) if (n % p == 0) return(1) - p[++l] = n - } - return(0) -} - -/* wheel to skip multiples of 2, 3, and 5 */ -w[0] = 4 -w[1] = 2 -w[2] = 4 -w[3] = 2 -w[4] = 4 -w[5] = 6 -w[6] = 2 -w[7] = 6 - -for (n = p[0]; c != 10; i = (i + 1) % 8) { - if (d(n += w[i]) == 1) { - n - c += 1 - } -} diff --git a/Task/Deceptive-numbers/C++/deceptive-numbers-2.cpp b/Task/Deceptive-numbers/C++/deceptive-numbers-2.cpp deleted file mode 100644 index 7b6923514e..0000000000 --- a/Task/Deceptive-numbers/C++/deceptive-numbers-2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include - -uint64_t power_modulus(uint64_t base, uint64_t exponent, const uint64_t& modulus) { - if ( modulus == 1 ) { - return 0; - } - - base %= modulus; - uint64_t result = 1; - while ( exponent > 0 ) { - if ( ( exponent & 1 ) == 1 ) { - result = ( result * base ) % modulus; - } - base = ( base * base ) % modulus; - exponent >>= 1; - } - return result; -} - -bool is_deceptive(const uint32_t& n) { - if ( n % 2 != 0 && n % 3 != 0 && n % 5 != 0 && power_modulus(10, n - 1, n) == 1 ) { - for ( uint32_t divisor = 7; divisor < sqrt(n); divisor += 6 ) { - if ( n % divisor == 0 || n % ( divisor + 4 ) == 0 ) { - return true; - } - } - } - return false; -} - -int main() { - uint32_t n = 7; - uint32_t count = 0; - while ( count < 100 ) { - if ( is_deceptive(n) ) { - std::cout << std::setw(6) << n << ( ++count % 10 == 0 ? "\n" : " " ); - } - n += 1; - } -} diff --git a/Task/Deceptive-numbers/C++/deceptive-numbers-1.cpp b/Task/Deceptive-numbers/C++/deceptive-numbers.cpp similarity index 100% rename from Task/Deceptive-numbers/C++/deceptive-numbers-1.cpp rename to Task/Deceptive-numbers/C++/deceptive-numbers.cpp diff --git a/Task/Deceptive-numbers/C/deceptive-numbers.c b/Task/Deceptive-numbers/C/deceptive-numbers.c index 885a07dfac..b74c6c6326 100644 --- a/Task/Deceptive-numbers/C/deceptive-numbers.c +++ b/Task/Deceptive-numbers/C/deceptive-numbers.c @@ -1,24 +1,23 @@ -#include #include -uint32_t modpow(uint32_t b, uint32_t e, uint32_t m) +unsigned modpow(unsigned b, unsigned e, unsigned m) { - uint32_t p; + unsigned p; for (p = 1; e; e >>= 1) { if (e & 1) - p = (uint64_t)p * b % m; - b = (uint64_t)b * b % m; + p = p * b % m; + b = b * b % m; } return p; } -int is_deceptive(uint32_t n) +int is_deceptive(unsigned n) { - uint32_t x; - if (n & 1 && n % 3 && n % 5 && modpow(10, n - 1, n) == 1) { + unsigned x; + if (n & 1 && n % 3 && n % 5) { for (x = 7; x * x <= n; x += 6) { if (!(n % x && n % (x + 4))) - return 1; + return modpow(10, n - 1, n) == 1; } } return 0; @@ -26,11 +25,10 @@ int is_deceptive(uint32_t n) int main(void) { - uint32_t n = 49; - unsigned int c; - for (c = 0; c != 500; ++n) { - if (is_deceptive(n)) { - printf(" %" PRIu32, n); + unsigned c, i = 49; + for (c = 0; c != 50; ++i) { + if (is_deceptive(i)) { + printf(" %u", i); ++c; } } diff --git a/Task/Deceptive-numbers/EasyLang/deceptive-numbers.easy b/Task/Deceptive-numbers/EasyLang/deceptive-numbers.easy deleted file mode 100644 index 6cbd386682..0000000000 --- a/Task/Deceptive-numbers/EasyLang/deceptive-numbers.easy +++ /dev/null @@ -1,31 +0,0 @@ -func modpow b e m . - r = 1 - while e > 0 - if e mod 2 = 1 - r = r * b mod m - . - b = b * b mod m - e = e div 2 - . - return r -. -func is_deceptive n . - if n mod 2 = 1 and n mod 3 <> 0 and n mod 5 <> 0 - if modpow 10 (n - 1) n = 1 - x = 7 - while x * x <= n - if n mod x = 0 or n mod (x + 4) = 0 - return 1 - . - x += 6 - . - . - . -. -while cnt < 10 - n += 1 - if is_deceptive n = 1 - write n & " " - cnt += 1 - . -. diff --git a/Task/Deceptive-numbers/Forth/deceptive-numbers.fth b/Task/Deceptive-numbers/Forth/deceptive-numbers.fth deleted file mode 100644 index a3289a799e..0000000000 --- a/Task/Deceptive-numbers/Forth/deceptive-numbers.fth +++ /dev/null @@ -1,44 +0,0 @@ -: modpow { c b a -- a^b mod c } - c 1 = if 0 exit then - 1 - a c mod to a - begin - b 0> - while - b 1 and 1 = if - a * c mod - then - a a * c mod to a - b 2/ to b - repeat ; - -: deceptive? ( n -- ? ) - dup 2 mod 0= if drop false exit then - dup 3 mod 0= if drop false exit then - dup 5 mod 0= if drop false exit then - dup dup 1- 10 modpow 1 <> if drop false exit then - 7 begin - 2dup dup * > - while - 2dup mod 0= if 2drop true exit then - 4 + - 2dup mod 0= if 2drop true exit then - 2 + - repeat - 2drop false ; - -: main ( -- ) - 0 7 begin - over 100 < - while - dup deceptive? if - dup 6 .r - swap 1+ swap - over 10 mod 0= if cr else space then - then - 1+ - repeat - 2drop ; - -main -bye diff --git a/Task/Deceptive-numbers/Free-Pascal-Lazarus/deceptive-numbers-2.pas b/Task/Deceptive-numbers/Free-Pascal-Lazarus/deceptive-numbers-2.pas deleted file mode 100644 index 2a598322af..0000000000 --- a/Task/Deceptive-numbers/Free-Pascal-Lazarus/deceptive-numbers-2.pas +++ /dev/null @@ -1,67 +0,0 @@ -program DeceptiveNumbers; -{$IfDef FPC} {$MODE DELPHI}{$Optimization ON,ALL} {$ENDIF} -{$IfDef Windows} {$APPTYPE CONSOLE} {$ENDIF} -uses - sysutils; -const - LIMIT = 1000; - -function OutN(n,count:Uint64):Uint64; -begin - result := count; - If result mod 8 = 0 then - write(#13#10,count:6); - write(n:10); - inc(result); -end; - -function isPrime(n: UInt64):boolean; -var - p: Uint64; -begin - if n <32 then - if n in [2,3,5,7,11,13,17,19,23,29,31] then - EXIT(true); - - if Not ODD(n) OR ( n MOD 3 = 0) then - EXIT(false); - p := 5; - repeat - if (n mod p=0)or(n mod(p+2)=0) then - EXIT(false); - p +=6; - until p*p>n; - Exit(true); -end; - -function powMod(n,pow,rest: Uint64): Uint64; -begin - result := 1; - while pow > 0 do - begin - if pow mod 2 <> 0 then - result := (result * n) mod rest; - pow := pow div 2; - n := sqr(n) mod rest; - end; -end; - -const - NextNotMulOf235 : array[0..7] of Uint32 = (6,4,2,4,2,4,6,2); -var - n,count,idx235:Uint64; -begin - idx235 := 0; - n := 1; - count := 0; - writeln(' count +1 2 3 4 5 6 7 8'); - repeat - //simple isprime takes mostly more time than powMod - if (powMod(10, n-1, n) = 1) AND Not(isPrime(n)) then - count := OutN(n,count); - inc(n,NextNotMulOf235[idx235]); - idx235 :=(idx235+1) AND 7; - until count >=LIMIT; - - writeln; -END. diff --git a/Task/Deceptive-numbers/Free-Pascal-Lazarus/deceptive-numbers-1.pas b/Task/Deceptive-numbers/Free-Pascal/deceptive-numbers.pas similarity index 100% rename from Task/Deceptive-numbers/Free-Pascal-Lazarus/deceptive-numbers-1.pas rename to Task/Deceptive-numbers/Free-Pascal/deceptive-numbers.pas diff --git a/Task/Deceptive-numbers/FreeBASIC/deceptive-numbers.basic b/Task/Deceptive-numbers/FreeBASIC/deceptive-numbers.basic deleted file mode 100644 index c94a8eb4bc..0000000000 --- a/Task/Deceptive-numbers/FreeBASIC/deceptive-numbers.basic +++ /dev/null @@ -1,33 +0,0 @@ -Function ModPow(b As Uinteger, e As Uinteger, m As Uinteger) As Uinteger - Dim As Uinteger p = 1 - While e <> 0 - If (e And 1) Then p = (p*b) Mod m - b = (b*b) Mod m - e Shr= 1 - Wend - Return p -End Function - -Function isDeceptive(n As Uinteger) As Uinteger - Dim As Uinteger x - If (n And 1) <> 0 Andalso (n Mod 3) <> 0 Andalso (n Mod 5) <> 0 Then - x = 7 - While x*x <= n - If (n Mod x) = 0 Orelse (n Mod (x+4)) = 0 Then Return (ModPow(10, n-1, n) = 1) - x += 6 - Wend - End If - Return 0 -End Function - -Dim As Uinteger c = 0, i = 49 -While c <> 41 ' limit for signed 32-bit integers - If isDeceptive(i) Then - Print Using "#######"; Csng(i); - c += 1 - If (c Mod 10) = 0 Then Print - End If - i += 1 -Wend - -Sleep diff --git a/Task/Deceptive-numbers/FutureBasic/deceptive-numbers.basic b/Task/Deceptive-numbers/FutureBasic/deceptive-numbers.basic deleted file mode 100644 index 7bcd7c556c..0000000000 --- a/Task/Deceptive-numbers/FutureBasic/deceptive-numbers.basic +++ /dev/null @@ -1,84 +0,0 @@ -// ------------------------------------------------------------ -// Deceptive numbers -// Using FutureBasic 7.0.36 -// November 2025, R.W. -// -// A composite n such that n | R_{n-1}, where -// R_k = (10^k - 1) / 9 is the k-digit repunit. -// ------------------------------------------------------------ - -include "gmp.incl" - -_kPrimeReps = 25 // Miller–Rabin rounds for mpz_probab_prime_p -_kDeceptiveLimit = 152 //should fit in the window -CFTimeInterval t - -// ------------------------------------------------------------ -// Probable prime test using GMP -// Returns _true if n is (probably) prime, _false otherwise. -// ------------------------------------------------------------ -local fn IsProbablePrime( n as UInt32 ) as Boolean - mpz_t z - int r - if n < 2 then RETURN _false - mpz_init( z ) - fn mpz_set_ui( z, n ) - r = fn mpz_probab_prime_p( z, _kPrimeReps ) - mpz_clear( z ) - if r > 0 then RETURN _true -end fn = _false - -// ------------------------------------------------------------ -// Find and print the first `limit` deceptive numbers -// ------------------------------------------------------------ -local fn PrintDeceptiveNumbers( limit as Int ) - mpz_t repunit - long n - int count - mpz_init( repunit ) - fn mpz_set_ui( repunit, 0 ) - n = 1 - count = 0 - print @"\nThe first "; limit; @" deceptive numbers are:\n" - t = fn CACurrentMediaTime - - while (count < limit) - // Only odd n; repunit holds R_{n-1} - n = n + 2 - // repunit = repunit * 100 + 11 - // This appends two '1' digits each step: - // 0 → 11 → 1111 → 111111 → ... - fn mpz_mul_ui( repunit, repunit, 100 ) - fn mpz_add_ui( repunit, repunit, 11 ) - - // Skip all multiples of 3 or 5. - - if ( (n MOD 3) != 0 ) && ( (n MOD 5) != 0 ) - // We want composite n, so reject primes. - if fn IsProbablePrime( n ) == _false - // Check if repunit is divisible by n - if fn mpz_divisible_ui_p( repunit, n ) != 0 - count = count + 1 - CFStringRef s = fn CFStringCreateWithFormat¬ - ( _kCFAllocatorDefault, 0, @"%8ld ", n ) - print s; - CFRelease( s ) - if (count MOD 8) == 0 then print - end if - end if - end if - wend - // Tidy final newline if the last row wasn't complete - if (count MOD 8) != 0 then print - printf @"\nElapsed time: %.3f secs", (fn CACurrentMediaTime-t) - mpz_clear( repunit ) -end fn - -// ------------------------------------------------------------ -// Main -// ------------------------------------------------------------ -Window 1,@"Deceptive Numbers" - -fn PrintDeceptiveNumbers( _kDeceptiveLimit ) - -HandleEvents diff --git a/Task/Deceptive-numbers/Haskell/deceptive-numbers.hs b/Task/Deceptive-numbers/Haskell/deceptive-numbers.hs deleted file mode 100644 index 9f48b64a53..0000000000 --- a/Task/Deceptive-numbers/Haskell/deceptive-numbers.hs +++ /dev/null @@ -1,24 +0,0 @@ -import Data.Numbers.Primes -import Data.List - --- Translation of Wren ver1 -deceptives1 :: [Int] -deceptives1 = - [ n - | (n, r) <- zip [17, 19 ..] (iterate ((11 +) . (100 *)) 1111111111111111) - , not $ isPrime n, mod n 3 /= 0, mod n 5 /= 0, mod r (fromIntegral n) == 0 - ] - --- Translation of Wren ver2 -deceptives2 :: [Int] -deceptives2 = - [ n - | n <- [49, 51 ..], mod n 3 /= 0, mod n 5 /= 0 - , not $ isPrime n, modPower (9 * n) 10 (pred n) == 1] - -modPower :: Int -> Int -> Int -> Int -modPower base a b = foldl' mul 1 [p | (True, p) <- zip bs ps] - where - mul x y = mod (x * y) base - bs = map odd $ takeWhile (0 <) $ iterate (flip div 2) b - ps = iterate (\x -> mul x x) a diff --git a/Task/Deceptive-numbers/J/deceptive-numbers-1.j b/Task/Deceptive-numbers/J/deceptive-numbers-1.j new file mode 100644 index 0000000000..5c27fdfc1b --- /dev/null +++ b/Task/Deceptive-numbers/J/deceptive-numbers-1.j @@ -0,0 +1,5 @@ +R=: (10x #. #&1)"0 +deceptive=: 1&p: < 0 = ] | R@<: + + 2+I.deceptive 2+i.10000 +91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 7471 7777 8149 8401 8911 10001 diff --git a/Task/Deceptive-numbers/J/deceptive-numbers-2.j b/Task/Deceptive-numbers/J/deceptive-numbers-2.j new file mode 100644 index 0000000000..19405b3336 --- /dev/null +++ b/Task/Deceptive-numbers/J/deceptive-numbers-2.j @@ -0,0 +1,17 @@ +deceptives=: {{ + r=.$k=.10x #.}.1#~j=.9 + while. y>#r do. + if. 0<2|j do. + if. 0<5|j do. + if. 0=1 p:j do. + if. 0=0]j|k do. + r=. r, j + end. + end. + end. + end. + k=. 1 10x p.k + j=. j+1 + end. + r +}} diff --git a/Task/Deceptive-numbers/J/deceptive-numbers-3.j b/Task/Deceptive-numbers/J/deceptive-numbers-3.j new file mode 100644 index 0000000000..4c4afa0533 --- /dev/null +++ b/Task/Deceptive-numbers/J/deceptive-numbers-3.j @@ -0,0 +1,2 @@ + deceptives 21 +91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 7471 7777 8149 8401 8911 10001 diff --git a/Task/Deceptive-numbers/J/deceptive-numbers.j b/Task/Deceptive-numbers/J/deceptive-numbers.j deleted file mode 100644 index 8d91f7d19b..0000000000 --- a/Task/Deceptive-numbers/J/deceptive-numbers.j +++ /dev/null @@ -1,4 +0,0 @@ -wheel=. 4 6 2 6 4 2 4 2 -fermat=. {{1 = 10 (y&|@^) <: y}}"0 - -_10 ]\ (#~ fermat) (#~ 0&p:) +/\ 49 , 15e4 $ wheel diff --git a/Task/Deceptive-numbers/Java/deceptive-numbers.java b/Task/Deceptive-numbers/Java/deceptive-numbers.java deleted file mode 100644 index 011c08f949..0000000000 --- a/Task/Deceptive-numbers/Java/deceptive-numbers.java +++ /dev/null @@ -1,42 +0,0 @@ -public final class DeceptiveNumbers { - - public static void main(String[] aArgs) { - int n = 7; - int count = 0; - while ( count < 200 ) { - if ( isDeceptive(n) ) { - System.out.print(String.format("%6d%s", n, ( ++count % 10 == 0 ? "\n" : " " ))); - } - n += 1; - } - } - - private static boolean isDeceptive(int aN) { - if ( aN % 2 != 0 && aN % 3 != 0 && aN % 5 != 0 && modulusPower(10, aN - 1, aN) == 1 ) { - for ( int divisor = 7; divisor <= Math.sqrt(aN); divisor += 6 ) { - if ( aN % divisor == 0 || aN % ( divisor + 4 ) == 0 ) { - return true; - } - } - } - return false; - } - - private static long modulusPower(long aBase, long aExponent, long aModulus) { - if ( aModulus == 1 ) { - return 0; - } - - aBase %= aModulus; - long result = 1; - while ( aExponent > 0 ) { - if ( ( aExponent & 1 ) == 1 ) { - result = ( result * aBase ) % aModulus; - } - aBase = ( aBase * aBase ) % aModulus; - aExponent >>= 1; - } - return result; - } - -} diff --git a/Task/Deceptive-numbers/Julia/deceptive-numbers.jl b/Task/Deceptive-numbers/Julia/deceptive-numbers.julia similarity index 100% rename from Task/Deceptive-numbers/Julia/deceptive-numbers.jl rename to Task/Deceptive-numbers/Julia/deceptive-numbers.julia diff --git a/Task/Deceptive-numbers/Langur/deceptive-numbers.langur b/Task/Deceptive-numbers/Langur/deceptive-numbers.langur index 456016e51d..370672e433 100644 --- a/Task/Deceptive-numbers/Langur/deceptive-numbers.langur +++ b/Task/Deceptive-numbers/Langur/deceptive-numbers.langur @@ -1,16 +1,13 @@ -val isPrime = fn(i number) { - i == 2 or i > 2 and - not any(series(2 .. i ^/ 2, asconly=true), by=fn(x) { i div x }) -} +val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2 -var nums = [] -var repunit = 111_111 +var .nums = [] +var .repunit = 111_111 -for n = 9; len(nums) < 10; n += 2 { - repunit = repunit * 100 + 11 - if not isPrime(n) and repunit div n { - nums = more(nums, n) +for .n = 9; len(.nums) < 10; .n += 2 { + .repunit = .repunit x 100 + 11 + if not .isPrime(.n) and .repunit div .n { + .nums = more .nums, .n } } -writeln nums +writeln .nums diff --git a/Task/Deceptive-numbers/Lua/deceptive-numbers.lua b/Task/Deceptive-numbers/Lua/deceptive-numbers.lua deleted file mode 100644 index 271c26c487..0000000000 --- a/Task/Deceptive-numbers/Lua/deceptive-numbers.lua +++ /dev/null @@ -1,38 +0,0 @@ -do -- find deceptive numbers - repunits R(n) evenly divisible by composite numbers and n+1 - -- see tha task talk page based on the second Wren sample - - -- returns true if n is prime, false otherwise, uses trial division % - local function isPrime ( n ) - if n < 3 then return n == 2 - elseif n % 3 == 0 then return n == 3 - elseif n % 2 == 0 then return false - else - local prime = true - local f, f2, toNext = 5, 25, 24 - while f2 <= n and prime do - prime = n % f ~= 0 - f = f + 2 - f2 = toNext - toNext = toNext + 8 - end - return prime - end - end - - do -- task - local n, count = 47, 0 - while count < 25 do - n = n + 2 - if n % 3 ~= 0 and n % 5 ~= 0 and not isPrime( n ) then - local mp = 10 - for p = 2, n - 1 do mp = ( mp * 10 ) % n end - if mp == 1 then - count = count + 1 - io.write( string.format( " %5d", n ) ) - if count % 10 == 0 then io.write( "\n" ) end - end - end - end - end - -end diff --git a/Task/Deceptive-numbers/Maxima/deceptive-numbers.maxima b/Task/Deceptive-numbers/Maxima/deceptive-numbers.maxima deleted file mode 100644 index afeb61c4f5..0000000000 --- a/Task/Deceptive-numbers/Maxima/deceptive-numbers.maxima +++ /dev/null @@ -1,10 +0,0 @@ -/* Function for repunit numbers */ -repunit(n):=(10^n-1)/9; - -/* Function that checks if property is satisfied */ -repunit_property(n):=is(mod(repunit(n-1),n)=0); - -/* Function to list the first n deceptive numbers */ -deceptive_list(n):=block([deceptives:[],count:0,i:5], -while count 0 && n mod 3 <> 0 && n mod 5 <> 0 && - modpow n 10 (pred n) = 1 && loop 7 - -let () = - Seq.(ints 49 |> filter is_deceptive |> take 100 - |> iter (Printf.printf " %u%!")) |> print_newline diff --git a/Task/Deceptive-numbers/OCaml/deceptive-numbers.ocaml b/Task/Deceptive-numbers/OCaml/deceptive-numbers.ocaml new file mode 100644 index 0000000000..51eb61199b --- /dev/null +++ b/Task/Deceptive-numbers/OCaml/deceptive-numbers.ocaml @@ -0,0 +1,17 @@ +let modpow m = + let rec loop p b e = + if e land 1 = 0 + then if e = 0 then p else loop p (b * b mod m) (e lsr 1) + else loop (p * b mod m) (b * b mod m) (e lsr 1) + in loop 1 + +let is_deceptive n = + let rec loop x = + x * x <= n && (n mod x = 0 || n mod (x + 4) = 0 || loop (x + 6)) + in + n land 1 <> 0 && n mod 3 <> 0 && n mod 5 <> 0 && loop 7 && + modpow n 10 (pred n) = 1 + +let () = + Seq.(ints 49 |> filter is_deceptive |> take 500 + |> iter (Printf.printf " %u%!")) |> print_newline diff --git a/Task/Deceptive-numbers/PascalABC.NET/deceptive-numbers.pas b/Task/Deceptive-numbers/PascalABC.NET/deceptive-numbers.pas deleted file mode 100644 index 9dfc636ee7..0000000000 --- a/Task/Deceptive-numbers/PascalABC.NET/deceptive-numbers.pas +++ /dev/null @@ -1,19 +0,0 @@ -uses School; - -function Deceptives(num: integer): List; -begin - Result := new List; - var n := 2; - var r:BigInteger := 1; - while Result.Count < num do - begin - if not n.IsPrime and (r mod n = 0) then - Result.Add(n); - n += 1; - r := 10*r + 1; - end; -end; - -begin - Deceptives(25).Println; -end. diff --git a/Task/Deceptive-numbers/Phix/deceptive-numbers-2.phix b/Task/Deceptive-numbers/Phix/deceptive-numbers-2.phix deleted file mode 100644 index dde4813570..0000000000 --- a/Task/Deceptive-numbers/Phix/deceptive-numbers-2.phix +++ /dev/null @@ -1,22 +0,0 @@ -(phixonline)--> - with javascript_semantics - constant limit = iff(platform()=JS?100:1000), showlim=70 - atom t0 = time(), t1 = t0+1 - integer n = 1, count = 0 - printf(1,"The first %d deceptive numbers are:\n",showlim) - while count<limit do - n += 2 - if gcd(n,3*5)=1 - and not is_prime(n) - and powmod(10,n-1,n)=1 then - count += 1 - if count<=showlim then - printf(1," %7d%n",{n,remainder(count,10)=0}) - elsif count=limit or time()>t1 then - printf(1,"The %d%s is %d\r",{count,ord(count),n}) - t1 = time()+1 - end if - end if - end while - printf(1,"\n%s\n",elapsed(time()-t0)) - n ) - - [] 0 - [ 2 + dup 1+ isprime if again - dup rep over 1+ mod if again - tuck 1+ join - tuck size 20 = until ] - drop echo diff --git a/Task/Deceptive-numbers/R/deceptive-numbers.r b/Task/Deceptive-numbers/R/deceptive-numbers.r deleted file mode 100644 index ed5f0d4818..0000000000 --- a/Task/Deceptive-numbers/R/deceptive-numbers.r +++ /dev/null @@ -1,15 +0,0 @@ -library(gmp) - -repunit <- function(n) as.bigz(strrep("1", n)) - -n <- 9 -count <- 0 -while(count<50){ - if(repunit(n-1)%%n==0){ - if(isprime(n)==0){ - count <- count+1 - cat(n, "", rep("\n", count%%10==0)) - } - } - n <- n+2 -} diff --git a/Task/Deceptive-numbers/REXX/deceptive-numbers.rexx b/Task/Deceptive-numbers/REXX/deceptive-numbers.rexx deleted file mode 100644 index 6175bfe63b..0000000000 --- a/Task/Deceptive-numbers/REXX/deceptive-numbers.rexx +++ /dev/null @@ -1,60 +0,0 @@ -/* REXX */ -Numeric Digits 100 -count=0 -ol='' -Call Time 'R' -Do n=7 by 1 While count<200 - if isDeceptive(n) Then Do - count+=1 - Call o n - End - End -Say ol time('E') 'seconds' -exit - -isDeceptive: procedure expose count - Parse Arg n - If n//2>0 & n//3>0 & n//5>0 Then Do - If modulusPower(10,N-1,N)=1 Then Do - Do divisor=7 By 6 while divisor*divisor<=n - If n//divisor=0 | n//(divisor+4)=0 Then Do - Return 1 - End - End - End - Return 0 - End - Return 0 - -modulusPower: Procedure - Parse Arg Base,Exponent,Modulus - Call dbg 'ModP Base='Base 'Exponent='Exponent 'Modulus='Modulus - If Modulus=1 Then - Return 0 - Base=Base//Modulus - Call dbg 'Base='Base - res=1 - Do While Exponent>0 - If exponent//2>0 Then Do - res=res*base//modulus - Call dbg 'result='res - End - Call dbg 'base='base 'modulus='modulus - base=(base*base)//modulus - Call dbg 'base='base - exponent=exponent%2 - Call dbg 'exponent='exponent - End - Call dbg 'result='res - Return res - -o: -ol=ol right(arg(1),6) -If count//10=0 Then Do - Say substr(ol,2) - ol='' - End -Return - -dbg: -Return diff --git a/Task/Deceptive-numbers/Rust/deceptive-numbers.rs b/Task/Deceptive-numbers/Rust/deceptive-numbers.rust similarity index 100% rename from Task/Deceptive-numbers/Rust/deceptive-numbers.rs rename to Task/Deceptive-numbers/Rust/deceptive-numbers.rust diff --git a/Task/Deceptive-numbers/Scheme/deceptive-numbers.scm b/Task/Deceptive-numbers/Scheme/deceptive-numbers.ss similarity index 100% rename from Task/Deceptive-numbers/Scheme/deceptive-numbers.scm rename to Task/Deceptive-numbers/Scheme/deceptive-numbers.ss diff --git a/Task/Deceptive-numbers/UNIX-Shell/deceptive-numbers.sh b/Task/Deceptive-numbers/UNIX-Shell/deceptive-numbers.sh deleted file mode 100644 index a0effa0812..0000000000 --- a/Task/Deceptive-numbers/UNIX-Shell/deceptive-numbers.sh +++ /dev/null @@ -1,33 +0,0 @@ -is () { - return "$((!($1)))" -} - -fermat_test () { - set -- 1 "$1" "$(($2 - 1))" "$2" - while is "$3 > 0" - do - set -- "$(($1 * (-($3 & 1) & ($2 ^ 1) ^ 1) % $4))" "$(($2 * $2 % $4))" "$(($3 >> 1))" "$4" - done - return "$(($1 != 1))" -} - -set -- 7 -c=0 n=$1 -while : -do - for w in 4 2 4 2 4 6 2 6 - do - fermat_test 10 "$((n += w))" && for p - do - is 'p * p > n' && { - set -- "$@" "$n" - break - } - is 'n % p == 0' && { - echo "$n" - is '(c += 1) == 10' && exit - break - } - done - done -done diff --git a/Task/Deceptive-numbers/Unicon/deceptive-numbers.unicon b/Task/Deceptive-numbers/Unicon/deceptive-numbers.unicon deleted file mode 100644 index 4f089ccf9e..0000000000 --- a/Task/Deceptive-numbers/Unicon/deceptive-numbers.unicon +++ /dev/null @@ -1,21 +0,0 @@ -link fastprime - -procedure main(A) - limit := \A[1] | 10 - every writes(" ",deceptive()\limit) - write() -end - -procedure deceptive() - every n := seq(2) do { - if not is_prime(n) then { - r := repunit(10,n-1) - if (r/n*n) = r then suspend n - } - } -end - -procedure repunit(b,n) - every (r := 0) +:= b^(0 to n-1) - return r -end diff --git a/Task/Deceptive-numbers/V-(Vlang)/deceptive-numbers.v b/Task/Deceptive-numbers/V-(Vlang)/deceptive-numbers.v index 176c0c35e7..f4b00ce09a 100644 --- a/Task/Deceptive-numbers/V-(Vlang)/deceptive-numbers.v +++ b/Task/Deceptive-numbers/V-(Vlang)/deceptive-numbers.v @@ -1,15 +1,22 @@ import math.big fn is_prime(n int) bool { - if n < 2 {return false} - else if n % 2 == 0 {return n == 2} - else if n % 3 == 0 {return n == 3} - else { + if n < 2 { + return false + } else if n%2 == 0 { + return n == 2 + } else if n%3 == 0 { + return n == 3 + } else { mut d := 5 - for d * d <= n { - if n % d == 0 {return false} + for d*d <= n { + if n%d == 0 { + return false + } d += 2 - if n % d == 0 {return false} + if n%d == 0 { + return false + } d += 4 } return true @@ -27,7 +34,7 @@ fn main() { hundred := big.integer_from_int(100) mut deceptive := []i64{} for count < limit { - if !is_prime(int(n)) && n % 3 != 0 && n % 5 != 0 { + if !is_prime(int(n)) && n%3 != 0 && n%5 != 0 { bn := big.integer_from_i64(n) t = repunit % bn if t == zero { diff --git a/Task/Deceptive-numbers/Wren/deceptive-numbers-1.wren b/Task/Deceptive-numbers/Wren/deceptive-numbers-1.wren deleted file mode 100644 index b7d1f122ba..0000000000 --- a/Task/Deceptive-numbers/Wren/deceptive-numbers-1.wren +++ /dev/null @@ -1,22 +0,0 @@ -/* Deceptive_numbers.wren */ - -import "./gmp" for Mpz -import "./math" for Int - -var count = 0 -var limit = 25 -var n = 17 -var repunit = Mpz.from(1111111111111111) -var deceptive = [] -while (count < limit) { - if (!Int.isPrime(n) && n % 3 != 0 && n % 5 != 0) { - if (repunit.isDivisibleUi(n)) { - deceptive.add(n) - count = count + 1 - } - } - n = n + 2 - repunit.mul(100).add(11) -} -System.print("The first %(limit) deceptive numbers are:") -System.print(deceptive) diff --git a/Task/Deceptive-numbers/Wren/deceptive-numbers-2.wren b/Task/Deceptive-numbers/Wren/deceptive-numbers-2.wren deleted file mode 100644 index fca08dc00a..0000000000 --- a/Task/Deceptive-numbers/Wren/deceptive-numbers-2.wren +++ /dev/null @@ -1,15 +0,0 @@ -import "./math" for Int - -var count = 0 -var limit = 25 // or 62 -var n = 49 -var deceptive = [] -while (count < limit) { - if (!Int.isPrime(n) && n % 3 != 0 && n % 5 != 0 && Int.modPow(10, n-1, n) == 1) { - deceptive.add(n) - count = count + 1 - } - n = n + 2 -} -System.print("The first %(limit) deceptive numbers are:") -System.print(deceptive) diff --git a/Task/Deceptive-numbers/Wren/deceptive-numbers.wren b/Task/Deceptive-numbers/Wren/deceptive-numbers.wren new file mode 100644 index 0000000000..069e3a0962 --- /dev/null +++ b/Task/Deceptive-numbers/Wren/deceptive-numbers.wren @@ -0,0 +1,22 @@ +/* deceptive_numbers.wren */ + +import "./gmp" for Mpz +import "./math" for Int + +var count = 0 +var limit = 25 +var n = 17 +var repunit = Mpz.from(1111111111111111) +var deceptive = [] +while (count < limit) { + if (!Int.isPrime(n) && n % 3 != 0 && n % 5 != 0) { + if (repunit.isDivisibleUi(n)) { + deceptive.add(n) + count = count + 1 + } + } + n = n + 2 + repunit.mul(100).add(11) +} +System.print("The first %(limit) deceptive numbers are:") +System.print(deceptive) diff --git a/Task/Deconvolution-1D/Ada/deconvolution-1d.adb b/Task/Deconvolution-1D/Ada/deconvolution-1d.ada similarity index 100% rename from Task/Deconvolution-1D/Ada/deconvolution-1d.adb rename to Task/Deconvolution-1D/Ada/deconvolution-1d.ada diff --git a/Task/Deconvolution-1D/C++/deconvolution-1d.cpp b/Task/Deconvolution-1D/C++/deconvolution-1d.cpp deleted file mode 100644 index 8047f5b2d0..0000000000 --- a/Task/Deconvolution-1D/C++/deconvolution-1d.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include -#include - -void print_vector(const std::vector& list) { - std::cout << "["; - for ( uint64_t i = 0; i < list.size() - 1; ++i ) { - std::cout << list[i] << ", "; - } - std::cout << list.back() << "]" << std::endl; -} - -std::vector deconvolution(const std::vector& a, const std::vector& b) { - std::vector result(a.size() - b.size() + 1, 0); - for ( uint64_t n = 0; n < result.size(); n++ ) { - result[n] = a[n]; - uint64_t start = std::max((int) (n - b.size() + 1), 0); - for ( uint64_t i = start; i < n; i++ ) { - result[n] -= result[i] * b[n - i]; - } - result[n] /= b[0]; - } - return result; -} - -int main() { - const std::vector h = { -8, -9, -3, -1, -6, 7 }; - const std::vector f = { -3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1 }; - const std::vector g = { 24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, - 25, -67, -96, 96, 31, 55, 36, 29, -43, -7 }; - - std::cout << "h = "; print_vector(h); - std::cout << "deconvolution(g, f) = "; print_vector(deconvolution(g, f)); - std::cout << "f = "; print_vector(f); - std::cout << "deconvolution(g, h) = "; print_vector(deconvolution(g, h)); -} diff --git a/Task/Deconvolution-1D/EasyLang/deconvolution-1d.easy b/Task/Deconvolution-1D/EasyLang/deconvolution-1d.easy deleted file mode 100644 index c2ce226851..0000000000 --- a/Task/Deconvolution-1D/EasyLang/deconvolution-1d.easy +++ /dev/null @@ -1,19 +0,0 @@ -func[] deconv g[] f[] . - len h[] len g[] - len f[] + 1 - for n = 1 to len h[] - h[n] = g[n] - low = higher 1 (n - len f[] + 1) - for i = low to n - 1 - h[n] -= h[i] * f[n - i + 1] - . - h[n] /= f[1] - . - return h[] -. -h[] = [ -8 -9 -3 -1 -6 7 ] -f[] = [ -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1 ] -g[] = [ 24 75 71 -34 3 22 -45 23 245 25 52 25 -67 -96 96 31 55 36 29 -43 -7 ] -print h[] -print deconv g[] f[] -print f[] -print deconv g[] h[] diff --git a/Task/Deconvolution-1D/FreeBASIC/deconvolution-1d.basic b/Task/Deconvolution-1D/FreeBASIC/deconvolution-1d.basic deleted file mode 100644 index d393dadbe7..0000000000 --- a/Task/Deconvolution-1D/FreeBASIC/deconvolution-1d.basic +++ /dev/null @@ -1,50 +0,0 @@ -Sub Deconv(g() As Double, f() As Double, h() As Double) - Dim As Integer n, i, lower - Dim As Integer hCount = Ubound(g) - Ubound(f) + 2 - Redim h(hCount - 1) - - For n = 0 To hCount - 1 - h(n) = g(n) - lower = Iif(n >= Ubound(f) + 1, n - Ubound(f), 0) - i = lower - While i < n - h(n) -= h(i) * f(n - i) - i += 1 - Wend - h(n) /= f(0) - Next n -End Sub - -Dim As Integer i -Dim As Double h(5) = {-8, -9, -3, -1, -6, 7} -Dim As Double f(15) = {-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1} -Dim As Double g(20) = {24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7} -Dim As Double result() - -Print !"h:\n["; -For i = Lbound(h) To Ubound(h) - Print h(i); ","; -Next i -Print Chr(8) & !"]\n"; - -Deconv(g(), f(), result()) -Print !"\deconv(g, f):\n["; -For i = Lbound(result) To Ubound(result)-1 - Print result(i); ","; -Next i -Print Chr(8) & !"]\n"; - -Print -Print !"f:\n["; -For i = Lbound(f) To Ubound(f) - Print f(i); ","; -Next i -Print Chr(8) & !"]\n"; - -Deconv(g(), h(), result()) -Print !"\deconv(g, h):\n["; -For i = Lbound(result) To Ubound(result)-1 - Print Using "##_,"; result(i); -Next i -Print Chr(8) & !"]\n"; -Sleep diff --git a/Task/Deconvolution-1D/JavaScript/deconvolution-1d.js b/Task/Deconvolution-1D/JavaScript/deconvolution-1d.js deleted file mode 100644 index 686a7d80c4..0000000000 --- a/Task/Deconvolution-1D/JavaScript/deconvolution-1d.js +++ /dev/null @@ -1,27 +0,0 @@ -function deconv(g, f) { - const h = new Array(g.length - f.length + 1); - for (let n = 0; n < h.length; n++) { - h[n] = g[n]; - const lower = Math.max(n - f.length + 1, 0); - for (let i = lower; i < n; i++) - h[n] -= h[i] * f[n - i]; - h[n] /= f[0]; - } - return h; -} - -function main() { - const h = [-8, -9, -3, -1, -6, 7]; - const f = [-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]; - const g = [24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, - 96, 31, 55, 36, 29, -43, -7]; - - let output = ''; - output += `h = ${JSON.stringify(h)}\n`; - output += `deconv(g, f) = ${JSON.stringify(deconv(g, f))}\n`; - output += `f = ${JSON.stringify(f)}\n`; - output += `deconv(g, h) = ${JSON.stringify(deconv(g, h))}\n`; - console.log(output); -} - -main(); diff --git a/Task/Deconvolution-1D/Jq/deconvolution-1d.jq b/Task/Deconvolution-1D/Jq/deconvolution-1d.jq deleted file mode 100644 index 49402b22d4..0000000000 --- a/Task/Deconvolution-1D/Jq/deconvolution-1d.jq +++ /dev/null @@ -1,22 +0,0 @@ -def deconv($g; $f): - { h: [range(0; ($g|length) - ($f|length) + 1) | 0] } - | reduce range ( 0;.h|length) as $n (.; - .h[$n] = $g[$n] - | (if $n >= ($f|length) then $n - ($f|length) + 1 else 0 end) as $lower - | .i = $lower - | until(.i >= $n; - .h[$n] -= .h[.i] * $f[$n - .i] - | .i += 1 ) - | .h[$n] /= $f[0] ) - | .h ; - -### The tasks - -def h: [-8, -9, -3, -1, -6, 7]; -def f: [-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]; -def g: [24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7]; - -h, -deconv(g; f), -f, -deconv(g; h) diff --git a/Task/Deconvolution-1D/Julia/deconvolution-1d.jl b/Task/Deconvolution-1D/Julia/deconvolution-1d.julia similarity index 100% rename from Task/Deconvolution-1D/Julia/deconvolution-1d.jl rename to Task/Deconvolution-1D/Julia/deconvolution-1d.julia diff --git a/Task/Deconvolution-1D/Kotlin/deconvolution-1d.kts b/Task/Deconvolution-1D/Kotlin/deconvolution-1d.kotlin similarity index 100% rename from Task/Deconvolution-1D/Kotlin/deconvolution-1d.kts rename to Task/Deconvolution-1D/Kotlin/deconvolution-1d.kotlin diff --git a/Task/Deconvolution-1D/PascalABC.NET/deconvolution-1d.pas b/Task/Deconvolution-1D/PascalABC.NET/deconvolution-1d.pas deleted file mode 100644 index d53aa8498f..0000000000 --- a/Task/Deconvolution-1D/PascalABC.NET/deconvolution-1d.pas +++ /dev/null @@ -1,26 +0,0 @@ -## -function deconv(g, f: array of real): array of real; -begin - var h: array of real; - setlength(h, g.length - f.length + 1); - for var n := 0 to h.length - 1 do - begin - h[n] := g[n]; - var lower: integer; - if n >= f.length then - lower := n - f.length + 1; - for var i := lower to n - 1 do - h[n] -= h[i] * f[n - i]; - h[n] /= f[0]; - end; - result := h; -end; - -var h := |-8.0, -9, -3, -1, -6, 7|; -var f := |-3.0, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1|; -var g := |24.0, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, - 96, 31, 55, 36, 29, -43, -7|; -h.Println; -deconv(g, f).Println; -f.Println; -deconv(g, h).Println; diff --git a/Task/Deconvolution-1D/Rust/deconvolution-1d.rs b/Task/Deconvolution-1D/Rust/deconvolution-1d.rs deleted file mode 100644 index dedb7ff775..0000000000 --- a/Task/Deconvolution-1D/Rust/deconvolution-1d.rs +++ /dev/null @@ -1,39 +0,0 @@ -fn print_vector(list: &Vec) { - print!("["); - for i in 0..list.len() - 1 { - print!("{}, ", list[i]); - } - println!("{}]", list.last().unwrap()); -} - -fn deconvolution(a: &Vec, b: &Vec) -> Vec { - let mut result = vec![0; a.len() - b.len() + 1]; - for n in 0..result.len() { - result[n] = a[n]; - let start = std::cmp::max(n as i64 - b.len() as i64 + 1, 0) as usize; - for i in start..n { - result[n] -= result[i] * b[n - i]; - } - result[n] /= b[0]; - } - result -} - -fn main() { - let h: Vec = vec![-8, -9, -3, -1, -6, 7]; - let f: Vec = vec![-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]; - let g: Vec = vec![24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, - 25, -67, -96, 96, 31, 55, 36, 29, -43, -7]; - - print!("h = "); - print_vector(&h); - - print!("deconvolution(g, f) = "); - print_vector(&deconvolution(&g, &f)); - - print!("f = "); - print_vector(&f); - - print!("deconvolution(g, h) = "); - print_vector(&deconvolution(&g, &h)); -} diff --git a/Task/Deconvolution-1D/Zig/deconvolution-1d.zig b/Task/Deconvolution-1D/Zig/deconvolution-1d.zig deleted file mode 100644 index b7b6aa7f08..0000000000 --- a/Task/Deconvolution-1D/Zig/deconvolution-1d.zig +++ /dev/null @@ -1,54 +0,0 @@ -const std = @import("std"); - -fn printVector(list: []const i32) void { - const stdout = std.io.getStdOut().writer(); - stdout.print("[", .{}) catch unreachable; - for (0..list.len - 1) |i| { - stdout.print("{}, ", .{list[i]}) catch unreachable; - } - stdout.print("{}]\n", .{list[list.len - 1]}) catch unreachable; -} - -fn deconvolution(allocator: std.mem.Allocator, a: []const i32, b: []const i32) ![]i32 { - const result_len = a.len - b.len + 1; - var result = try allocator.alloc(i32, result_len); - @memset(result, 0); - - for (0..result_len) |n| { - result[n] = a[n]; - const start = @max(@as(i64, @intCast(n)) - @as(i64, @intCast(b.len)) + 1, 0); - var i: usize = @intCast(start); - while (i < n) : (i += 1) { - result[n] -= result[i] * b[n - i]; - } - result[n] = @divTrunc(result[n], b[0]); - } - return result; -} - -pub fn main() !void { - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - const allocator = gpa.allocator(); - defer _ = gpa.deinit(); - - const h = [_]i32{ -8, -9, -3, -1, -6, 7 }; - const f = [_]i32{ -3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1 }; - const g = [_]i32{ 24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7 }; - - const stdout = std.io.getStdOut().writer(); - try stdout.print("h = ", .{}); - printVector(&h); - - const deconv_gf = try deconvolution(allocator, &g, &f); - defer allocator.free(deconv_gf); - try stdout.print("deconvolution(g, f) = ", .{}); - printVector(deconv_gf); - - try stdout.print("f = ", .{}); - printVector(&f); - - const deconv_gh = try deconvolution(allocator, &g, &h); - defer allocator.free(deconv_gh); - try stdout.print("deconvolution(g, h) = ", .{}); - printVector(deconv_gh); -} diff --git a/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp b/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp deleted file mode 100644 index 04e6133754..0000000000 --- a/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp +++ /dev/null @@ -1,282 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -struct Return_Value { - int32_t power_of_two; - std::vector> list; -}; - -template -void print_vector(const std::vector& list) { - std::cout << "["; - for ( uint32_t i = 0; i < list.size() - 1; ++i ) { - std::cout << list[i] << ", "; - } - std::cout << list.back() << "]"; -} - -template -void print_2D_vector(const std::vector>& lists) { - std::cout << "["; - for ( uint32_t i = 0; i < lists.size() - 1; ++i ) { - print_vector(lists[i]); std::cout << ", "; - } - print_vector(lists.back()); std::cout << "]"; -} - -template -void print_3D_vector(const std::vector>>& lists) { - std::cout << "["; - for ( uint32_t i = 0; i < lists.size() - 1; ++i ) { - print_2D_vector(lists[i]); std::cout << ", "; - } - print_2D_vector(lists.back()); std::cout << "]" << std::endl; -} - -Return_Value pad_and_complexify(const std::vector& list, const int32_t& power_of_two) { - const int32_t padded_vector_size = ( power_of_two == 0 ) ? - 1 << static_cast(std::ceil(std::log(list.size()) / std::log(2))) : power_of_two; - std::vector> padded_vector(padded_vector_size, std::complex(0.0, 0.0)); - for ( int32_t i = 0; i < padded_vector_size; ++i ) { - padded_vector[i] = ( i < static_cast(list.size()) ) ? - std::complex(static_cast(list[i]), 0.0) : std::complex(0.0, 0.0); - } - return Return_Value(padded_vector_size, padded_vector); -} - -std::vector> pack_2D(const std::vector& to_pack, const uint64_t& to_pack_X, - const uint64_t& to_pack_Y, const int32_t& convolved_Y) { - std::vector> packed = { to_pack_X, std::vector(to_pack_Y, 0) }; - for ( uint64_t i = 0; i < to_pack_X; ++i ) { - for ( uint64_t j = 0; j < to_pack_Y; ++j ) { - packed[i][j] = to_pack[i * convolved_Y + j] / 4; - } - } - return packed; -} - -std::vector>> pack_3D(const std::vector& to_pack, - const uint64_t& to_pack_X, const uint64_t& to_pack_Y, const uint64_t to_pack_Z, - const int32_t& convolved_Y, const int32_t& convolved_Z) { - - std::vector>> packed = - { to_pack_X, std::vector>(to_pack_Y, std::vector(to_pack_Z, 0)) }; - for ( uint64_t i = 0; i < to_pack_X; ++i ) { - for ( uint64_t j = 0; j < to_pack_Y; ++j ) { - for ( uint64_t k = 0; k < to_pack_Z; ++k ) { - packed[i][j][k] = to_pack[( i * convolved_Y + j ) * convolved_Z + k] / 4; - } - } - } - return packed; -} - -std::vector unpack_2D(const std::vector>& to_unpack, - const int32_t& convolved_Y) { - - std::vector unpacked(to_unpack.size() * convolved_Y, 0); - for ( uint32_t i = 0; i < to_unpack.size(); ++i ) { - for ( uint32_t j = 0; j < to_unpack[0].size(); ++j ) { - unpacked[i * convolved_Y + j] = to_unpack[i][j]; - } - } - return unpacked; -} - -std::vector unpack_3D(const std::vector>>& to_unpack, - const int32_t& convolved_Y, const int32_t& convolved_Z) { - - std::vector unpacked(to_unpack.size() * convolved_Y * convolved_Z, 0); - for ( uint64_t i = 0; i < to_unpack.size(); ++i ) { - for ( uint64_t j = 0; j < to_unpack[0].size(); ++j ) { - for ( uint64_t k = 0; k < to_unpack[0][0].size(); ++k ) { - unpacked[( i * convolved_Y + j ) * convolved_Z + k] = to_unpack[i][j][k]; - } - } - } - return unpacked; - } - -void fft(std::vector>& deconvolution1D, std::vector>& result, - const int32_t& power_of_two, const int32_t& step, const int32_t& start) { - - if ( step < power_of_two ) { - fft(result, deconvolution1D, power_of_two, 2 * step, start); - fft(result, deconvolution1D, power_of_two, 2 * step, start + step); - for ( int32_t j = 0; j < power_of_two; j += 2 * step ) { - const double theta = -std::numbers::pi * j / power_of_two; - std::complex t = std::complex(std::cos(theta), std::sin(theta)) * result[j + step + start]; - deconvolution1D[( j / 2 ) + start] = result[j + start] + t; - deconvolution1D[( ( j + power_of_two ) / 2 ) + start] = result[j + start] - t; - } - } -} - -std::vector> fft(std::vector>& deconvolution1D, - const int32_t& powerOfTwo) { - - std::vector> result(deconvolution1D); - fft(deconvolution1D, result, powerOfTwo, 1, 0); - return result; -} - -std::vector deconvolution(const std::vector& convolved, const int32_t& convolved_size, - const std::vector& remove, const int32_t& remove_size, - const int32_t& convolved_row_size, const int32_t& remain_size) { - - int32_t power_of_two = 0; - Return_Value convoluted_result = pad_and_complexify(convolved, power_of_two); - std::vector> convoluted_padded = convoluted_result.list; - Return_Value remove_result = pad_and_complexify(remove, convoluted_result.power_of_two); - std::vector> remove_padded = remove_result.list; - power_of_two = remove_result.power_of_two; - - fft(convoluted_padded, power_of_two); - fft(remove_padded, power_of_two); - std::vector> quotient(power_of_two, std::complex(0.0, 0.0)); - for ( int32_t i = 0; i < power_of_two; ++i ) { - quotient[i] = convoluted_padded[i] / remove_padded[i]; - } - - fft(quotient, power_of_two); - for ( int32_t i = 0; i < power_of_two; ++i ) { - if ( std::abs(quotient[i].real()) < 0.000'000'000'1 ) { - quotient[i] = std::complex(0.0, 0.0); - } - } - - std::vector remain_vector(remain_size, 0); - int32_t i = 0; - while ( i > remove_size - convolved_size - convolved_row_size ) { - remain_vector[-i] = std::lround(( - quotient[( i + power_of_two ) % power_of_two] / std::complex(32.0, 0.0)).real()); - i -= 1; - } - return remain_vector; -} - -std::vector deconvolution_1D(const std::vector& convolved, - const std::vector& remove) { - - return deconvolution(convolved, convolved.size(), remove, remove.size(), - 1 , convolved.size() - remove.size() + 1); -} - -std::vector> deconvolution_2D(const std::vector>& convolved, - const std::vector>& toRemove) { - - std::vector convolved_1D = unpack_2D(convolved, convolved[0].size()); - std::vector toRemove_1D = unpack_2D(toRemove, convolved[0].size()); - std::vector toRemain_1D = deconvolution(convolved_1D, convolved.size() * convolved[0].size(), - toRemove_1D, toRemove.size() * convolved[0].size(), - convolved[0].size(), ( convolved[0].size() - toRemove[0].size() + 1 ) * convolved[0].size()); - - return pack_2D(toRemain_1D, convolved.size() - toRemove.size() + 1, - convolved[0].size() - toRemove[0].size() + 1, convolved[0].size()); -} - -std::vector>> deconvolution_3D( - const std::vector>>& convolved, - const std::vector>>& toRemove) { - - const int32_t cX = convolved.size(); - const int32_t cY = convolved[0].size(); - const int32_t cZ = convolved[0][0].size(); - - const int32_t rX = toRemove.size(); - const int32_t rY = toRemove[0].size(); - const int32_t rZ = toRemove[0][0].size(); - - const std::vector convolved_1D = unpack_3D(convolved, cY, cZ); - const std::vector toRemove_1D = unpack_3D(toRemove, cY, cZ); - const std::vector toRemain_1D = deconvolution(convolved_1D, cX * cY * cZ, - toRemove_1D, rX * cY * cZ, cY * cZ, ( cX - rX + 1 ) * cY * cZ); - - return pack_3D(toRemain_1D, cX - rX + 1, cY - rY + 1, cZ - rZ + 1, cY, cZ); -} - -int main() { - const std::vector f1 = { -3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1 }; - - const std::vector g1 = - { 24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7 }; - - const std::vector h1 = { -8, -9, -3, -1, -6, 7 }; - - const std::vector> f2 = { { -5, 2, -2, -6, -7 }, - { 9, 7, -6, 5, -7 }, - { 1, -1, 9, 2, -7 }, - { 5, 9, -9, 2, -5 }, - { -8, 5, -2, 8, 5 } }; - - const std::vector> g2 = - { { 40, -21, 53, 42, 105, 1, 87, 60, 39, -28 }, - { -92, -64, 19, -167, -71, -47, 128, -109, 40, -21 }, - { 58, 85, -93, 37, 101, -14, 5, 37, -76, -56 }, - { -90, -135, 60, -125, 68, 53, 223, 4, -36, -48 }, - { 78, 16, 7, -199, 156, -162, 29, 28, -103, -10 }, - { -62, -89, 69, -61, 66, 193, -61, 71, -8, -30 }, - { 48, -6, 21, -9, -150, -22, -56, 32, 85, 25 } }; - - const std::vector> h2 = { { -8, 1, -7, -2, -9, 4 }, - { 4, 5, -5, 2, 7, -1 }, - { -6, -3, -3, -6, 9, 5 } }; - - const std::vector>> f3 = { { { -9, 5, -8 }, { 3, 5, 1 } }, - { { -1, -7, 2 }, { -5, -6, 6 } }, - { { 8, 5, 8 }, { -2, -6, -4 } } }; - - const std::vector>> g3 = - { { { 54, 42, 53, -42, 85, -72 }, - { 45, -170, 94, -36, 48, 73 }, - { -39, 65, -112, -16, -78, -72 }, - { 6, -11, -6, 62, 49, 8 } }, - { { -57, 49, -23, 52, -135, 66 }, - { -23, 127, -58, -5, -118, 64 }, - { 87, -16, 121, 23, -41, -12 }, - { -19, 29, 35, -148, -11, 45 } }, - { { -55, -147, -146, -31, 55, 60 }, - { -88, -45, -28, 46, -26, -144 }, - { -12, -107, -34, 150, 249, 66 }, - { 11, -15, -34, 27, -78, -50 } }, - { { 56, 67, 108, 4, 2, -48 }, - { 58, 67, 89, 32, 32, -8 }, - { -42, -31, -103, -30, -23, -8 }, - { 6, 4, -26, -10, 26, 12 } } }; - - const std::vector>> h3 = { { { -6, -8, -5, 9 }, - { -7, 9, -6, -8 }, - { 2, -7, 9, 8 } }, - { { 7, 4, 4, -6 }, - { 9, 9, 4, -4 }, - { -3, 7, -2, -3 } } }; - - const std::vector H1 = deconvolution_1D(g1, f1); - std::cout << "deconvolution1D(g1, f1) = "; print_vector(H1); std::cout << std::endl; - std::cout << "H1 = h1 ? " << std::boolalpha << ( H1 == h1 ) << std::endl << std::endl; - - const std::vector F1 = deconvolution_1D(g1, h1); - std::cout << "deconvolution1D(g1, h1) = "; print_vector(F1); std::cout << std::endl; - std::cout << "F1 = f1 ? " << ( F1 == f1 ) << std::endl << std::endl; - - const std::vector> H2 = deconvolution_2D(g2, f2); - std::cout << "deconvolution2D(g2, f2) = "; print_2D_vector(H2); std::cout << std::endl; - std::cout << "H2 = h2 ? " << ( H2 == h2 ) << std::endl << std::endl; - - const std::vector> F2 = deconvolution_2D(g2, h2); - std::cout << "deconvolution2D(g2, h2) = "; print_2D_vector(F2); std::cout << std::endl; - std::cout << "F2 = f2 ? " << ( F2 == f2 ) << std::endl << std::endl; - - const std::vector>> H3 = deconvolution_3D(g3, f3); - std::cout << "deconvolution3D(g3, f3) = "; print_3D_vector(H3); - std::cout << "H3 = h3 ? " << ( H3 == h3 ) << std::endl << std::endl; - - const std::vector>> F3 = deconvolution_3D(g3, h3); - std::cout << "deconvolution3D(g3, h3) = "; print_3D_vector(F3); - std::cout << "F3 = f3 ? " << ( F3 == f3 ) << std::endl; -} diff --git a/Task/Deconvolution-2D+/FreeBASIC/deconvolution-2d+.basic b/Task/Deconvolution-2D+/FreeBASIC/deconvolution-2d+.basic deleted file mode 100644 index 14fda1196b..0000000000 --- a/Task/Deconvolution-2D+/FreeBASIC/deconvolution-2d+.basic +++ /dev/null @@ -1,183 +0,0 @@ -' Function to calculate direct convolution -Sub convolve3D(f() As Double, Byval fx As Integer, Byval fy As Integer, _ - Byval fz As Integer, h() As Double, Byval hx As Integer, _ - Byval hy As Integer, Byval hz As Integer, result() As Double) - - Dim gx As Integer = fx + hx - 1 - Dim gy As Integer = fy + hy - 1 - Dim gz As Integer = fz + hz - 1 - - For i As Integer = 0 To gx-1 - For j As Integer = 0 To gy-1 - For k As Integer = 0 To gz-1 - result(i, j, k) = 0 - Next - Next - Next - - For i As Integer = 0 To fx-1 - For j As Integer = 0 To fy-1 - For k As Integer = 0 To fz-1 - For a As Integer = 0 To hx-1 - For b As Integer = 0 To hy-1 - For c As Integer = 0 To hz-1 - result(i+a, j+b, k+c) += f(i, j, k) * h(a, b, c) - Next - Next - Next - Next - Next - Next -End Sub - -' Function to solve deconvolution by optimization -Sub deconv3D_direct(g() As Double, Byval gx As Integer, Byval gy As Integer, _ - Byval gz As Integer, f() As Double, Byval fx As Integer, _ - Byval fy As Integer, Byval fz As Integer, result() As Double) - - Dim hx As Integer = gx - fx + 1 - Dim hy As Integer = gy - fy + 1 - Dim hz As Integer = gz - fz + 1 - - Dim expected_h(0 To 1, 0 To 2, 0 To 3) As Double - - expected_h(0, 0, 0) = -6 : expected_h(0, 0, 1) = -8 : expected_h(0, 0, 2) = -5 : expected_h(0, 0, 3) = 9 - expected_h(0, 1, 0) = -7 : expected_h(0, 1, 1) = 9 : expected_h(0, 1, 2) = -6 : expected_h(0, 1, 3) = -8 - expected_h(0, 2, 0) = 2 : expected_h(0, 2, 1) = -7 : expected_h(0, 2, 2) = 9 : expected_h(0, 2, 3) = 8 - - expected_h(1, 0, 0) = 7 : expected_h(1, 0, 1) = 4 : expected_h(1, 0, 2) = 4 : expected_h(1, 0, 3) = -6 - expected_h(1, 1, 0) = 9 : expected_h(1, 1, 1) = 9 : expected_h(1, 1, 2) = 4 : expected_h(1, 1, 3) = -4 - expected_h(1, 2, 0) = -3 : expected_h(1, 2, 1) = 7 : expected_h(1, 2, 2) = -2 : expected_h(1, 2, 3) = -3 - - For i As Integer = 0 To hx-1 - For j As Integer = 0 To hy-1 - For k As Integer = 0 To hz-1 - result(i, j, k) = expected_h(i, j, k) - Next - Next - Next -End Sub - -' Function to solve the second deconvolution -Sub deconv_g_h_direct(g() As Double, Byval gx As Integer, Byval gy As Integer, _ - Byval gz As Integer, h() As Double, Byval hx As Integer, _ - Byval hy As Integer, Byval hz As Integer, result() As Double) - - Dim fx As Integer = gx - hx + 1 - Dim fy As Integer = gy - hy + 1 - Dim fz As Integer = gz - hz + 1 - - Dim expected_f(0 To 2, 0 To 1, 0 To 2) As Double - - expected_f(0, 0, 0) = -9 : expected_f(0, 0, 1) = 5 : expected_f(0, 0, 2) = -8 - expected_f(0, 1, 0) = 3 : expected_f(0, 1, 1) = 5 : expected_f(0, 1, 2) = 1 - expected_f(1, 0, 0) = -1 : expected_f(1, 0, 1) = -7 : expected_f(1, 0, 2) = 2 - expected_f(1, 1, 0) = -5 : expected_f(1, 1, 1) = -6 : expected_f(1, 1, 2) = 6 - expected_f(2, 0, 0) = 8 : expected_f(2, 0, 1) = 5 : expected_f(2, 0, 2) = 8 - expected_f(2, 1, 0) = -2 : expected_f(2, 1, 1) = -6 : expected_f(2, 1, 2) = -4 - - For i As Integer = 0 To fx-1 - For j As Integer = 0 To fy-1 - For k As Integer = 0 To fz-1 - result(i, j, k) = expected_f(i, j, k) - Next - Next - Next -End Sub - -Sub main() - ' Define 3D arrays - Dim f(0 To 2, 0 To 1, 0 To 2) As Double - f(0, 0, 0) = -9 : f(0, 0, 1) = 5 : f(0, 0, 2) = -8 - f(0, 1, 0) = 3 : f(0, 1, 1) = 5 : f(0, 1, 2) = 1 - f(1, 0, 0) = -1 : f(1, 0, 1) = -7 : f(1, 0, 2) = 2 - f(1, 1, 0) = -5 : f(1, 1, 1) = -6 : f(1, 1, 2) = 6 - f(2, 0, 0) = 8 : f(2, 0, 1) = 5 : f(2, 0, 2) = 8 - f(2, 1, 0) = -2 : f(2, 1, 1) = -6 : f(2, 1, 2) = -4 - - Dim As Integer fx = 3, fy = 2, fz = 3 - - Dim g(0 To 3, 0 To 3, 0 To 5) As Double - g(0, 0, 0) = 54 : g(0, 0, 1) = 42 : g(0, 0, 2) = 53 : g(0, 0, 3) = -42 : g(0, 0, 4) = 85 : g(0, 0, 5) = -72 - g(0, 1, 0) = 45 : g(0, 1, 1) = -170 : g(0, 1, 2) = 94 : g(0, 1, 3) = -36 : g(0, 1, 4) = 48 : g(0, 1, 5) = 73 - g(0, 2, 0) = -39 : g(0, 2, 1) = 65 : g(0, 2, 2) = -112 : g(0, 2, 3) = -16 : g(0, 2, 4) = -78 : g(0, 2, 5) = -72 - g(0, 3, 0) = 6 : g(0, 3, 1) = -11 : g(0, 3, 2) = -6 : g(0, 3, 3) = 62 : g(0, 3, 4) = 49 : g(0, 3, 5) = 8 - - g(1, 0, 0) = 23 : g(1, 0, 1) = 45 : g(1, 0, 2) = 23 : g(1, 0, 3) = 12 : g(1, 0, 4) = -45 : g(1, 0, 5) = 67 - g(1, 1, 0) = -23 : g(1, 1, 1) = 127 : g(1, 1, 2) = -58 : g(1, 1, 3) = -5 : g(1, 1, 4) = -118 : g(1, 1, 5) = 64 - g(1, 2, 0) = 87 : g(1, 2, 1) = -16 : g(1, 2, 2) = 121 : g(1, 2, 3) = 23 : g(1, 2, 4) = -41 : g(1, 2, 5) = -12 - g(1, 3, 0) = -19 : g(1, 3, 1) = 29 : g(1, 3, 2) = 35 : g(1, 3, 3) = -148 : g(1, 3, 4) = -11 : g(1, 3, 5) = 45 - - g(2, 0, 0) = -55 : g(2, 0, 1) = -147 : g(2, 0, 2) = -146 : g(2, 0, 3) = -31 : g(2, 0, 4) = 55 : g(2, 0, 5) = 60 - g(2, 1, 0) = -88 : g(2, 1, 1) = -45 : g(2, 1, 2) = -28 : g(2, 1, 3) = 46 : g(2, 1, 4) = -26 : g(2, 1, 5) = -144 - g(2, 2, 0) = -12 : g(2, 2, 1) = -107 : g(2, 2, 2) = -34 : g(2, 2, 3) = 150 : g(2, 2, 4) = 249 : g(2, 2, 5) = 66 - g(2, 3, 0) = 11 : g(2, 3, 1) = -15 : g(2, 3, 2) = -34 : g(2, 3, 3) = 27 : g(2, 3, 4) = -78 : g(2, 3, 5) = -50 - - g(3, 0, 0) = 56 : g(3, 0, 1) = 67 : g(3, 0, 2) = 108 : g(3, 0, 3) = 4 : g(3, 0, 4) = 2 : g(3, 0, 5) = -48 - g(3, 1, 0) = 58 : g(3, 1, 1) = 67 : g(3, 1, 2) = 89 : g(3, 1, 3) = 32 : g(3, 1, 4) = 32 : g(3, 1, 5) = -8 - g(3, 2, 0) = -42 : g(3, 2, 1) = -31 : g(3, 2, 2) = -103: g(3, 2, 3) = -30 : g(3, 2, 4) = -23 : g(3, 2, 5) = -8 - g(3, 3, 0) = 6 : g(3, 3, 1) = 4 : g(3, 3, 2) = -26 : g(3, 3, 3) = -10 : g(3, 3, 4) = 26 : g(3, 3, 5) = 12 - - Dim As Integer gx = 4, gy = 4, gz = 6 - - Dim h(0 To 1, 0 To 2, 0 To 3) As Double - h(0, 0, 0) = -6 : h(0, 0, 1) = -8 : h(0, 0, 2) = -5 : h(0, 0, 3) = 9 - h(0, 1, 0) = -7 : h(0, 1, 1) = 9 : h(0, 1, 2) = -6 : h(0, 1, 3) = -8 - h(0, 2, 0) = 2 : h(0, 2, 1) = -7 : h(0, 2, 2) = 9 : h(0, 2, 3) = 8 - - h(1, 0, 0) = 7 : h(1, 0, 1) = 4 : h(1, 0, 2) = 4 : h(1, 0, 3) = -6 - h(1, 1, 0) = 9 : h(1, 1, 1) = 9 : h(1, 1, 2) = 4 : h(1, 1, 3) = -4 - h(1, 2, 0) = -3 : h(1, 2, 1) = 7 : h(1, 2, 2) = -2 : h(1, 2, 3) = -3 - - Dim As Integer hx = 2, hy = 3, hz = 4 - - ' Calculate output dimensions - Dim h2x As Integer = gx - fx + 1 - Dim h2y As Integer = gy - fy + 1 - Dim h2z As Integer = gz - fz + 1 - - ' Create output array h2 - Dim h2(0 To h2x-1, 0 To h2y-1, 0 To h2z-1) As Double - - ' Perform deconvolution directly - deconv3D_direct(g(), gx, gy, gz, f(), fx, fy, fz, h2()) - - Print "deconv3(g, f):" & Chr(10) - - For i As Integer = 0 To h2x-1 - For j As Integer = 0 To h2y-1 - For k As Integer = 0 To h2z-1 - Print Using "####"; h2(i, j, k); - Next - Print - Next - If i < h2x-1 Then Print - Next - - ' Calculate dimensions for second deconvolution - Dim kx As Integer = gx - hx + 1 - Dim ky As Integer = gy - hy + 1 - Dim kz As Integer = gz - hz + 1 - - ' Create output array f2 - Dim f2(0 To kx-1, 0 To ky-1, 0 To kz-1) As Double - - ' Perform second deconvolution directly - deconv_g_h_direct(g(), gx, gy, gz, h(), hx, hy, hz, f2()) - - Print Chr(10) & "deconv(g, h):" & Chr(10) - - For i As Integer = 0 To kx-1 - For j As Integer = 0 To ky-1 - For k As Integer = 0 To kz-1 - Print Using "####"; f2(i, j, k); - Next - Print - Next - If i < kx-1 Then Print - Next -End Sub - -main() - -Sleep diff --git a/Task/Deconvolution-2D+/Java/deconvolution-2d+.java b/Task/Deconvolution-2D+/Java/deconvolution-2d+.java deleted file mode 100644 index 9d2d6ec147..0000000000 --- a/Task/Deconvolution-2D+/Java/deconvolution-2d+.java +++ /dev/null @@ -1,279 +0,0 @@ -import java.util.Arrays; - -public final class Deconvolution { - - public static void main(String[] args) { - final int[] f1 = { -3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1 }; - - final int[] g1 = - { 24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7 }; - - final int[] h1 = { -8, -9, -3, -1, -6, 7 }; - - final int[][] f2 = { { -5, 2, -2, -6, -7 }, - { 9, 7, -6, 5, -7 }, - { 1, -1, 9, 2, -7 }, - { 5, 9, -9, 2, -5 }, - { -8, 5, -2, 8, 5 } }; - - final int[][] g2 = { { 40, -21, 53, 42, 105, 1, 87, 60, 39, -28 }, - { -92, -64, 19, -167, -71, -47, 128, -109, 40, -21 }, - { 58, 85, -93, 37, 101, -14, 5, 37, -76, -56 }, - { -90, -135, 60, -125, 68, 53, 223, 4, -36, -48 }, - { 78, 16, 7, -199, 156, -162, 29, 28, -103, -10 }, - { -62, -89, 69, -61, 66, 193, -61, 71, -8, -30 }, - { 48, -6, 21, -9, -150, -22, -56, 32, 85, 25 } }; - - final int[][] h2 = { { -8, 1, -7, -2, -9, 4 }, - { 4, 5, -5, 2, 7, -1 }, - { -6, -3, -3, -6, 9, 5 } }; - - final int[][][] f3 = { { { -9, 5, -8 }, { 3, 5, 1 } }, - { { -1, -7, 2 }, { -5, -6, 6 } }, - { { 8, 5, 8 }, { -2, -6, -4 } } }; - - final int[][][] g3 = { { { 54, 42, 53, -42, 85, -72 }, - { 45, -170, 94, -36, 48, 73 }, - { -39, 65, -112, -16, -78, -72 }, - { 6, -11, -6, 62, 49, 8 } }, - { { -57, 49, -23, 52, -135, 66 }, - { -23, 127, -58, -5, -118, 64 }, - { 87, -16, 121, 23, -41, -12 }, - { -19, 29, 35, -148, -11, 45 } }, - { { -55, -147, -146, -31, 55, 60 }, - { -88, -45, -28, 46, -26, -144 }, - { -12, -107, -34, 150, 249, 66 }, - { 11, -15, -34, 27, -78, -50 } }, - { { 56, 67, 108, 4, 2, -48 }, - { 58, 67, 89, 32, 32, -8 }, - { -42, -31, -103, -30, -23, -8 }, - { 6, 4, -26, -10, 26, 12 } } }; - - final int[][][] h3 = { { { -6, -8, -5, 9 }, - { -7, 9, -6, -8 }, - { 2, -7, 9, 8 } }, - { { 7, 4, 4, -6 }, - { 9, 9, 4, -4 }, - { -3, 7, -2, -3 } } }; - - int[] H1 = deconvolution1D(g1, f1); - System.out.println("deconvolution1D(g1, f1) = " + Arrays.toString(H1)); - System.out.println("H1 = h1 ? " + Arrays.equals(H1, h1)); - System.out.println(); - - int[] F1 = deconvolution1D(g1, h1); - System.out.println("deconvolution1D(g1, h1) = " + Arrays.toString(F1)); - System.out.println("F1 = f1 ? " + Arrays.equals(F1, f1)); - System.out.println(); - - int[][] H2 = deconvolution2D(g2, f2); - System.out.println("deconvolution2D(g2, f2) = " + Arrays.deepToString(H2)); - System.out.println("H2 = h2 ? " + Arrays.deepEquals(H2, h2)); - System.out.println(); - - int[][] F2 = deconvolution2D(g2, h2); - System.out.println("deconvolution2D(g2, h2) = " + Arrays.deepToString(F2)); - System.out.println("F2 = f2 ? " + Arrays.deepEquals(F2, f2)); - System.out.println(); - - int[][][] H3 = deconvolution3D(g3, f3); - System.out.println("deconvolution3D(g3, f3) = " + Arrays.deepToString(H3)); - System.out.println("H3 = h3 ? " + Arrays.deepEquals(H3, h3)); - System.out.println(); - - int[][][] F3 = deconvolution3D(g3, h3); - System.out.println("deconvolution3D(g3, h3) = " + Arrays.deepToString(F3)); - System.out.println("F3 = f3 ? " + Arrays.deepEquals(F3, f3)); - } - - private static int[] deconvolution1D(int[] convolved, int[] toRemove) { - return deconvolution(convolved, convolved.length, toRemove, toRemove.length, - 1 , convolved.length - toRemove.length + 1); - } - - private static int[][] deconvolution2D(int[][] convolved, int[][] toRemove) { - int[] convolvedArray = unpack2D(convolved, convolved[0].length); - int[] toRemoveArray = unpack2D(toRemove, convolved[0].length); - int[] toRemainArray = deconvolution(convolvedArray, convolved.length * convolved[0].length, - toRemoveArray, toRemove.length * convolved[0].length, - convolved[0].length, ( convolved[0].length - toRemove[0].length + 1 ) * convolved[0].length); - - return pack2D(toRemainArray, convolved.length - toRemove.length + 1, - convolved[0].length - toRemove[0].length + 1, convolved[0].length); - } - - private static int[][][] deconvolution3D(int[][][] convolved, int[][][] toRemove) { - final int cX = convolved.length; - final int cY = convolved[0].length; - final int cZ = convolved[0][0].length; - - final int rX = toRemove.length; - final int rY = toRemove[0].length; - final int rZ = toRemove[0][0].length; - - int[] convolvedArray = unpack3D(convolved, cY, cZ); - int[] toRemoveArray = unpack3D(toRemove, cY, cZ); - int[] toRemainArray = deconvolution(convolvedArray, cX * cY * cZ, - toRemoveArray, rX * cY * cZ, cY * cZ, ( cX - rX + 1 ) * cY * cZ); - - return pack3D(toRemainArray, cX - rX + 1, cY - rY + 1, cZ - rZ + 1, cY, cZ); - } - - private static int[] deconvolution(int[] convolvedArray, int convolvedLength, - int[] toRemoveArray, int toRemoveLength, - int convolvedRowLength, int toRemainLength) { - - int powerOfTwo = 0; - ReturnValue convolvedResult = padAndComplexify(convolvedArray, powerOfTwo); - Complex[] convolvedPadded = convolvedResult.array; - ReturnValue toRemoveResult = padAndComplexify(toRemoveArray, convolvedResult.powerOfTwo); - Complex[] toRemovePadded = toRemoveResult.array; - powerOfTwo = toRemoveResult.powerOfTwo; - - fft(convolvedPadded, powerOfTwo); - fft(toRemovePadded, powerOfTwo); - Complex[] quotient = new Complex[powerOfTwo]; - for ( int i = 0; i < powerOfTwo; i++ ) { - quotient[i] = convolvedPadded[i].divide(toRemovePadded[i]); - } - - fft(quotient, powerOfTwo); - for ( int i = 0; i < powerOfTwo; i++ ) { - if ( Math.abs(quotient[i].real()) < 0.000_000_000_1 ) { - quotient[i] = Complex.ZERO; - } - } - - int[] toRemainArray = new int[toRemainLength]; - int i = 0; - while ( i > toRemoveLength - convolvedLength - convolvedRowLength ) { - toRemainArray[-i] = Math.toIntExact(Math.round( - quotient[( i + powerOfTwo ) % powerOfTwo].divide(32).real())); - i -= 1; - } - return toRemainArray; - } - - private static Complex[] fft(Complex[] deconvolution1D, int powerOfTwo) { - Complex[] result = Arrays.copyOf(deconvolution1D, deconvolution1D.length); - fft(deconvolution1D, result, powerOfTwo, 1, 0); - return result; - } - - private static void fft(Complex[] deconvolution1D, Complex[] result, - int powerOfTwo, int step, int start) { - - if ( step < powerOfTwo ) { - fft(result, deconvolution1D, powerOfTwo, 2 * step, start); - fft(result, deconvolution1D, powerOfTwo, 2 * step, start + step); - - for ( int j = 0; j < powerOfTwo; j += 2 * step ) { - final double theta = -Math.PI * j / powerOfTwo; - Complex t = new Complex(Math.cos(theta), Math.sin(theta)).multiply(result[j + step + start]); - deconvolution1D[( j / 2 ) + start] = result[j + start].add(t); - deconvolution1D[( ( j + powerOfTwo ) / 2 ) + start] = result[j + start].subtract(t); - } - } - } - - private static int[] unpack2D(int[][] toUnpack, int convolvedY) { - int[] unpacked = new int[toUnpack.length * convolvedY]; - for ( int i = 0; i < toUnpack.length; i++ ) { - for ( int j = 0; j < toUnpack[0].length; j++ ) { - unpacked[i * convolvedY + j] = toUnpack[i][j]; - } - } - return unpacked; - } - - private static int[] unpack3D(int[][][] toUnpack, int convolvedY, int convolvedZ) { - int[] unpacked = new int[toUnpack.length * convolvedY * convolvedZ]; - for ( int i = 0; i < toUnpack.length; i++ ) { - for ( int j = 0; j < toUnpack[0].length; j++ ) { - for ( int k = 0; k < toUnpack[0][0].length; k++ ) { - unpacked[( i * convolvedY + j ) * convolvedZ + k] = toUnpack[i][j][k]; - } - } - } - return unpacked; - } - - private static int[][] pack2D(int[] toPack, int toPackX, int toPackY, int convolvedY) { - int[][] packed = new int[toPackX][toPackY]; - for ( int i = 0; i < toPackX; i++ ) { - for ( int j = 0; j < toPackY; j++ ) { - packed[i][j] = toPack[i * convolvedY + j] / 4; - } - } - return packed; - } - - private static int[][][] pack3D(int[] toPack, int toPackX, int toPackY, int toPackZ, - int convolvedY, int convolvedZ) { - - int[][][] packed = new int[toPackX][toPackY][toPackZ]; - for ( int i = 0; i < toPackX; i++ ) { - for ( int j = 0; j < toPackY; j++ ) { - for ( int k = 0; k < toPackZ; k++ ) { - packed[i][j][k] = toPack[( i * convolvedY + j ) * convolvedZ + k] / 4; - } - } - } - return packed; - } - - private static ReturnValue padAndComplexify(int[] array, int powerOfTwo) { - final int paddedArrayLength = ( powerOfTwo == 0 ) ? - Integer.highestOneBit(array.length - 1) << 1 : powerOfTwo; - - Complex[] paddedArray = new Complex[paddedArrayLength]; - for ( int i = 0; i < paddedArrayLength; i++ ) { - paddedArray[i] = ( i < array.length ) ? new Complex(array[i], 0.0) : Complex.ZERO; - } - return new ReturnValue(paddedArrayLength, paddedArray); - } - - private static record ReturnValue(int powerOfTwo, Complex[] array) {} - -} - -final class Complex { - - public Complex(double aReal, double aImag) { - real = aReal; - imag = aImag; - } - - public Complex add(Complex other) { - return new Complex(real + other.real, imag + other.imag); - } - - public Complex subtract(Complex other) { - return new Complex(real - other.real, imag - other.imag); - } - - public Complex multiply(Complex other) { - return new Complex(real * other.real - imag * other.imag, imag * other.real + real * other.imag); - } - - public Complex divide(int n) { - return new Complex(real / n, imag / n); - } - - public Complex divide(Complex other) { - final double rr = real * other.real + imag * other.imag; - final double ii = imag * other.real - real * other.imag; - final double norm = other.real * other.real + other.imag * other.imag; - return new Complex(rr / norm, ii / norm); - } - - public double real() { - return real; - } - - public static final Complex ZERO = new Complex(0.0, 0.0); - - private final double real; - private final double imag; - -} diff --git a/Task/Deconvolution-2D+/JavaScript/deconvolution-2d+.js b/Task/Deconvolution-2D+/JavaScript/deconvolution-2d+.js deleted file mode 100644 index d50b0baec9..0000000000 --- a/Task/Deconvolution-2D+/JavaScript/deconvolution-2d+.js +++ /dev/null @@ -1,329 +0,0 @@ -class Complex { - constructor(aReal, aImag) { - this.real = aReal; - this.imag = aImag; - } - - add(other) { - return new Complex(this.real + other.real, this.imag + other.imag); - } - - subtract(other) { - return new Complex(this.real - other.real, this.imag - other.imag); - } - - multiply(other) { - return new Complex( - this.real * other.real - this.imag * other.imag, - this.imag * other.real + this.real * other.imag - ); - } - - divide(n) { - if (typeof n === 'number') { - return new Complex(this.real / n, this.imag / n); - } else { - // Assume n is another Complex - const rr = this.real * n.real + this.imag * n.imag; - const ii = this.imag * n.real - this.real * n.imag; - const norm = n.real * n.real + n.imag * n.imag; - return new Complex(rr / norm, ii / norm); - } - } - - real() { - return this.real; - } -} - -// Static property for Complex -Complex.ZERO = new Complex(0.0, 0.0); - -class ReturnValue { - constructor(powerOfTwo, array) { - this.powerOfTwo = powerOfTwo; - this.array = array; - } -} - -function deconvolution1D(convolved, toRemove) { - return deconvolution( - convolved, convolved.length, - toRemove, toRemove.length, - 1, convolved.length - toRemove.length + 1 - ); -} - -function deconvolution2D(convolved, toRemove) { - const convolvedArray = unpack2D(convolved, convolved[0].length); - const toRemoveArray = unpack2D(toRemove, convolved[0].length); - const toRemainArray = deconvolution( - convolvedArray, convolved.length * convolved[0].length, - toRemoveArray, toRemove.length * convolved[0].length, - convolved[0].length, (convolved[0].length - toRemove[0].length + 1) * convolved[0].length - ); - - return pack2D( - toRemainArray, - convolved.length - toRemove.length + 1, - convolved[0].length - toRemove[0].length + 1, - convolved[0].length - ); -} - -function deconvolution3D(convolved, toRemove) { - const cX = convolved.length; - const cY = convolved[0].length; - const cZ = convolved[0][0].length; - - const rX = toRemove.length; - const rY = toRemove[0].length; - const rZ = toRemove[0][0].length; - - const convolvedArray = unpack3D(convolved, cY, cZ); - const toRemoveArray = unpack3D(toRemove, cY, cZ); - const toRemainArray = deconvolution( - convolvedArray, cX * cY * cZ, - toRemoveArray, rX * cY * cZ, - cY * cZ, (cX - rX + 1) * cY * cZ - ); - - return pack3D(toRemainArray, cX - rX + 1, cY - rY + 1, cZ - rZ + 1, cY, cZ); -} - -function deconvolution(convolvedArray, convolvedLength, toRemoveArray, toRemoveLength, convolvedRowLength, toRemainLength) { - let powerOfTwo = 0; - let convolvedResult = padAndComplexify(convolvedArray, powerOfTwo); - let convolvedPadded = convolvedResult.array; - let toRemoveResult = padAndComplexify(toRemoveArray, convolvedResult.powerOfTwo); - let toRemovePadded = toRemoveResult.array; - powerOfTwo = toRemoveResult.powerOfTwo; - - fft(convolvedPadded, powerOfTwo); - fft(toRemovePadded, powerOfTwo); - let quotient = new Array(powerOfTwo); - for (let i = 0; i < powerOfTwo; i++) { - quotient[i] = convolvedPadded[i].divide(toRemovePadded[i]); - } - - fft(quotient, powerOfTwo); - for (let i = 0; i < powerOfTwo; i++) { - if (Math.abs(quotient[i].real) < 0.0000000001) { - quotient[i] = Complex.ZERO; - } - } - - let toRemainArray = new Array(toRemainLength); - let i = 0; - while (i > toRemoveLength - convolvedLength - convolvedRowLength) { - toRemainArray[-i] = Math.round( - quotient[(i + powerOfTwo) % powerOfTwo].divide(32).real - ); - i -= 1; - } - return toRemainArray; -} - -function fft(deconvolution1D, powerOfTwo) { - const result = [...deconvolution1D]; - fftRecursive(deconvolution1D, result, powerOfTwo, 1, 0); - return result; -} - -function fftRecursive(deconvolution1D, result, powerOfTwo, step, start) { - if (step < powerOfTwo) { - fftRecursive(result, deconvolution1D, powerOfTwo, 2 * step, start); - fftRecursive(result, deconvolution1D, powerOfTwo, 2 * step, start + step); - - for (let j = 0; j < powerOfTwo; j += 2 * step) { - const theta = -Math.PI * j / powerOfTwo; - const t = new Complex(Math.cos(theta), Math.sin(theta)).multiply(result[j + step + start]); - deconvolution1D[(j / 2) + start] = result[j + start].add(t); - deconvolution1D[((j + powerOfTwo) / 2) + start] = result[j + start].subtract(t); - } - } -} - -function unpack2D(toUnpack, convolvedY) { - let unpacked = new Array(toUnpack.length * convolvedY); - for (let i = 0; i < toUnpack.length; i++) { - for (let j = 0; j < toUnpack[0].length; j++) { - unpacked[i * convolvedY + j] = toUnpack[i][j]; - } - } - return unpacked; -} - -function unpack3D(toUnpack, convolvedY, convolvedZ) { - let unpacked = new Array(toUnpack.length * convolvedY * convolvedZ); - for (let i = 0; i < toUnpack.length; i++) { - for (let j = 0; j < toUnpack[0].length; j++) { - for (let k = 0; k < toUnpack[0][0].length; k++) { - unpacked[(i * convolvedY + j) * convolvedZ + k] = toUnpack[i][j][k]; - } - } - } - return unpacked; -} - -function pack2D(toPack, toPackX, toPackY, convolvedY) { - let packed = Array(toPackX).fill().map(() => Array(toPackY)); - for (let i = 0; i < toPackX; i++) { - for (let j = 0; j < toPackY; j++) { - packed[i][j] = Math.floor(toPack[i * convolvedY + j] / 4); - } - } - return packed; -} - -function pack3D(toPack, toPackX, toPackY, toPackZ, convolvedY, convolvedZ) { - let packed = Array(toPackX).fill().map(() => - Array(toPackY).fill().map(() => - Array(toPackZ) - ) - ); - - for (let i = 0; i < toPackX; i++) { - for (let j = 0; j < toPackY; j++) { - for (let k = 0; k < toPackZ; k++) { - packed[i][j][k] = Math.floor(toPack[(i * convolvedY + j) * convolvedZ + k] / 4); - } - } - } - return packed; -} - -function padAndComplexify(array, powerOfTwo) { - const paddedArrayLength = (powerOfTwo === 0) ? - 1 << (32 - Math.clz32(array.length - 1)) : powerOfTwo; - - let paddedArray = new Array(paddedArrayLength); - for (let i = 0; i < paddedArrayLength; i++) { - paddedArray[i] = (i < array.length) ? new Complex(array[i], 0.0) : Complex.ZERO; - } - return new ReturnValue(paddedArrayLength, paddedArray); -} - -// Main function -function main() { - const f1 = [-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]; - - const g1 = [24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7]; - - const h1 = [-8, -9, -3, -1, -6, 7]; - - const f2 = [ - [-5, 2, -2, -6, -7], - [9, 7, -6, 5, -7], - [1, -1, 9, 2, -7], - [5, 9, -9, 2, -5], - [-8, 5, -2, 8, 5] - ]; - - const g2 = [ - [40, -21, 53, 42, 105, 1, 87, 60, 39, -28], - [-92, -64, 19, -167, -71, -47, 128, -109, 40, -21], - [58, 85, -93, 37, 101, -14, 5, 37, -76, -56], - [-90, -135, 60, -125, 68, 53, 223, 4, -36, -48], - [78, 16, 7, -199, 156, -162, 29, 28, -103, -10], - [-62, -89, 69, -61, 66, 193, -61, 71, -8, -30], - [48, -6, 21, -9, -150, -22, -56, 32, 85, 25] - ]; - - const h2 = [ - [-8, 1, -7, -2, -9, 4], - [4, 5, -5, 2, 7, -1], - [-6, -3, -3, -6, 9, 5] - ]; - - // const f3 = [ - // [[- 9, 5, -8], [3, 5, 1]], - // [[-1, -7, 2], [-5, -6, 6]], - // [[8, 5, 8], [-2, -6, -4]] - // ]; - - // const g3 = [ - // [ - // [54, 42, 53, -42, 85, -72], - // [45, -170, 94, -36, 48, 73], - // [-39, 65, -112, -16, -78, -72], - // [6, -11, -6, 62, 49, 8] - // ], - // [ - // [-57, 49, -23, 52, -135, 66], - // [-23, 127, -58, -5, -118, 64], - // [87, -16, 121, 23, -41, -12], - // [-19, 29, 35, -148, -11, 45] - // ], - // [ - // [-55, -147, -146, -31, 55, 60], - // [-88, -45, -28, 46, -26, -144], - // [-12, -107, -34, 150, 249, 66], - // [11, -15, -34, 27, -78, -50] - // ], - // [ - // [56, 67, 108, 4, 2, -48], - // [58, 67, 89, 32, 32, -8], - // [-42, -31, -103, -30, -23, -8], - // [6, 4, -26, -10, 26, 12] - // ] - // ]; - - // const h3 = [ - // [ - // [-6, -8, -5, 9], - // [-7, 9, -6, -8], - // [2, -7, 9, 8] - // ], - // [ - // [7, 4, 4, -6], - // [9, 9, 4, -4], - // [-3, 7, -2, -3] - // ] - // ]; - - const H1 = deconvolution1D(g1, f1); - console.log("deconvolution1D(g1, f1) = " + JSON.stringify(H1)); - console.log("H1 = h1 ? " + arraysEqual(H1, h1)); - console.log(); - - const F1 = deconvolution1D(g1, h1); - console.log("deconvolution1D(g1, h1) = " + JSON.stringify(F1)); - console.log("F1 = f1 ? " + arraysEqual(F1, f1)); - console.log(); - - // const H2 = deconvolution2D(g2, f2); - // console.log("deconvolution2D(g2, f2) = " + JSON.stringify(H2)); - // console.log("H2 = h2 ? " + arraysDeepEqual(H2, h2)); - // console.log(); - - // const F2 = deconvolution2D(g2, h2); - // console.log("deconvolution2D(g2, h2) = " + JSON.stringify(F2)); - // console.log("F2 = f2 ? " + arraysDeepEqual(F2, f2)); - // console.log(); - - // const H3 = deconvolution3D(g3, f3); - // console.log("deconvolution3D(g3, f3) = " + JSON.stringify(H3)); - // console.log("H3 = h3 ? " + arraysDeepEqual(H3, h3)); - // console.log(); - - // const F3 = deconvolution3D(g3, h3); - // console.log("deconvolution3D(g3, h3) = " + JSON.stringify(F3)); - // console.log("F3 = f3 ? " + arraysDeepEqual(F3, f3)); -} - -// Helper functions for array comparison -function arraysEqual(a, b) { - if (a.length !== b.length) return false; - for (let i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - return true; -} - -function arraysDeepEqual(a, b) { - return JSON.stringify(a) === JSON.stringify(b); -} - -// Run the main function -main(); diff --git a/Task/Deconvolution-2D+/Julia/deconvolution-2d+.jl b/Task/Deconvolution-2D+/Julia/deconvolution-2d+.julia similarity index 100% rename from Task/Deconvolution-2D+/Julia/deconvolution-2d+.jl rename to Task/Deconvolution-2D+/Julia/deconvolution-2d+.julia diff --git a/Task/Deconvolution-2D+/Rust/deconvolution-2d+.rs b/Task/Deconvolution-2D+/Rust/deconvolution-2d+.rs deleted file mode 100644 index dd8d669ebc..0000000000 --- a/Task/Deconvolution-2D+/Rust/deconvolution-2d+.rs +++ /dev/null @@ -1,359 +0,0 @@ -extern crate num_complex; // 0.4.6 - -use std::f64::consts::PI; -use num_complex::Complex; -use std::fmt; - -struct ReturnValue { - power_of_two: i32, - list: Vec>, -} - -// Custom Display implementation for Complex -// impl fmt::Display for Complex { -// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -// if self.im >= 0.0 { -// write!(f, "{}+{}i", self.re, self.im) -// } else { -// write!(f, "{}{}i", self.re, self.im) -// } -// } -// } - -fn print_vector(list: &[T]) { - print!("["); - for (i, item) in list.iter().enumerate() { - if i < list.len() - 1 { - print!("{}, ", item); - } else { - print!("{}", item); - } - } - print!("]"); -} - -fn print_2d_vector(lists: &[Vec]) { - print!("["); - for (i, list) in lists.iter().enumerate() { - print_vector(list); - if i < lists.len() - 1 { - print!(", "); - } - } - print!("]"); -} - -fn print_3d_vector(lists: &[Vec>]) { - print!("["); - for (i, list) in lists.iter().enumerate() { - print_2d_vector(list); - if i < lists.len() - 1 { - print!(", "); - } - } - println!("]"); -} - -fn pad_and_complexify(list: &[i32], power_of_two: i32) -> ReturnValue { - let padded_vector_size = if power_of_two == 0 { - 1 << (f64::ceil(f64::log2(list.len() as f64)) as i32) - } else { - power_of_two - }; - - let mut padded_vector = vec![Complex::new(0.0, 0.0); padded_vector_size as usize]; - for i in 0..padded_vector_size { - padded_vector[i as usize] = if i < list.len() as i32 { - Complex::new(list[i as usize] as f64, 0.0) - } else { - Complex::new(0.0, 0.0) - }; - } - - ReturnValue { - power_of_two: padded_vector_size, - list: padded_vector, - } -} - -fn pack_2d(to_pack: &[i32], to_pack_x: usize, to_pack_y: usize, convolved_y: i32) -> Vec> { - let mut packed = vec![vec![0; to_pack_y]; to_pack_x]; - for i in 0..to_pack_x { - for j in 0..to_pack_y { - packed[i][j] = to_pack[i * convolved_y as usize + j] / 4; - } - } - packed -} - -fn pack_3d(to_pack: &[i32], to_pack_x: usize, to_pack_y: usize, to_pack_z: usize, - convolved_y: i32, convolved_z: i32) -> Vec>> { - let mut packed = vec![vec![vec![0; to_pack_z]; to_pack_y]; to_pack_x]; - for i in 0..to_pack_x { - for j in 0..to_pack_y { - for k in 0..to_pack_z { - packed[i][j][k] = to_pack[(i * convolved_y as usize + j) * convolved_z as usize + k] / 4; - } - } - } - packed -} - -fn unpack_2d(to_unpack: &[Vec], convolved_y: i32) -> Vec { - let mut unpacked = vec![0; to_unpack.len() * convolved_y as usize]; - for i in 0..to_unpack.len() { - for j in 0..to_unpack[0].len() { - unpacked[i * convolved_y as usize + j] = to_unpack[i][j]; - } - } - unpacked -} - -fn unpack_3d(to_unpack: &[Vec>], convolved_y: i32, convolved_z: i32) -> Vec { - let mut unpacked = vec![0; to_unpack.len() * convolved_y as usize * convolved_z as usize]; - for i in 0..to_unpack.len() { - for j in 0..to_unpack[0].len() { - for k in 0..to_unpack[0][0].len() { - unpacked[(i * convolved_y as usize + j) * convolved_z as usize + k] = to_unpack[i][j][k]; - } - } - } - unpacked -} - -fn fft_recursive(deconvolution1d: &mut [Complex], result: &mut [Complex], - power_of_two: i32, step: i32, start: i32) { - if step < power_of_two { - fft_recursive(result, deconvolution1d, power_of_two, 2 * step, start); - fft_recursive(result, deconvolution1d, power_of_two, 2 * step, start + step); - - for j in (0..power_of_two).step_by(2 * step as usize) { - let theta = -PI * j as f64 / power_of_two as f64; - let t = Complex::new(f64::cos(theta), f64::sin(theta)) * result[(j + step + start) as usize]; - deconvolution1d[(j / 2 + start) as usize] = result[(j + start) as usize] + t; - deconvolution1d[((j + power_of_two) / 2 + start) as usize] = result[(j + start) as usize] - t; - } - } -} - -fn fft(deconvolution1d: &mut [Complex], power_of_two: i32) -> Vec> { - let mut result = deconvolution1d.to_vec(); - fft_recursive(deconvolution1d, &mut result, power_of_two, 1, 0); - result -} - -fn deconvolution(convolved: &[i32], convolved_size: i32, remove: &[i32], remove_size: i32, - convolved_row_size: i32, remain_size: i32) -> Vec { - let mut power_of_two = 0; - let convoluted_result = pad_and_complexify(convolved, power_of_two); - let mut convoluted_padded = convoluted_result.list; - let remove_result = pad_and_complexify(remove, convoluted_result.power_of_two); - let mut remove_padded = remove_result.list; - power_of_two = remove_result.power_of_two; - - fft(&mut convoluted_padded, power_of_two); - fft(&mut remove_padded, power_of_two); - - let mut quotient = vec![Complex::new(0.0, 0.0); power_of_two as usize]; - for i in 0..power_of_two { - quotient[i as usize] = convoluted_padded[i as usize] / remove_padded[i as usize]; - } - - fft(&mut quotient, power_of_two); - for i in 0..power_of_two { - if quotient[i as usize].re.abs() < 0.000_000_000_1 { - quotient[i as usize] = Complex::new(0.0, 0.0); - } - } - - let mut remain_vector = vec![0; remain_size as usize]; - let mut i = 0; - while i > remove_size - convolved_size - convolved_row_size { - remain_vector[(-i) as usize] = (quotient[((i + power_of_two) % power_of_two) as usize] / Complex::new(32.0, 0.0)).re.round() as i32; - i -= 1; - } - - remain_vector -} - -fn deconvolution_1d(convolved: &[i32], remove: &[i32]) -> Vec { - deconvolution( - convolved, - convolved.len() as i32, - remove, - remove.len() as i32, - 1, - convolved.len() as i32 - remove.len() as i32 + 1 - ) -} - -fn deconvolution_2d(convolved: &[Vec], to_remove: &[Vec]) -> Vec> { - let convolved_1d = unpack_2d(convolved, convolved[0].len() as i32); - let to_remove_1d = unpack_2d(to_remove, convolved[0].len() as i32); - - let to_remain_1d = deconvolution( - &convolved_1d, - (convolved.len() * convolved[0].len()) as i32, - &to_remove_1d, - (to_remove.len() * convolved[0].len()) as i32, - convolved[0].len() as i32, - ((convolved[0].len() - to_remove[0].len() + 1) * convolved[0].len()) as i32 - ); - - pack_2d( - &to_remain_1d, - convolved.len() - to_remove.len() + 1, - convolved[0].len() - to_remove[0].len() + 1, - convolved[0].len() as i32 - ) -} - -fn deconvolution_3d(convolved: &[Vec>], to_remove: &[Vec>]) -> Vec>> { - let cx = convolved.len(); - let cy = convolved[0].len(); - let cz = convolved[0][0].len(); - - let rx = to_remove.len(); - let ry = to_remove[0].len(); - let rz = to_remove[0][0].len(); - - let convolved_1d = unpack_3d(convolved, cy as i32, cz as i32); - let to_remove_1d = unpack_3d(to_remove, cy as i32, cz as i32); - - let to_remain_1d = deconvolution( - &convolved_1d, - (cx * cy * cz) as i32, - &to_remove_1d, - (rx * cy * cz) as i32, - (cy * cz) as i32, - ((cx - rx + 1) * cy * cz) as i32 - ); - - pack_3d( - &to_remain_1d, - cx - rx + 1, - cy - ry + 1, - cz - rz + 1, - cy as i32, - cz as i32 - ) -} - -fn main() { - let f1 = vec![-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]; - - let g1 = vec![ - 24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7 - ]; - - let h1 = vec![-8, -9, -3, -1, -6, 7]; - - let f2 = vec![ - vec![-5, 2, -2, -6, -7], - vec![9, 7, -6, 5, -7], - vec![1, -1, 9, 2, -7], - vec![5, 9, -9, 2, -5], - vec![-8, 5, -2, 8, 5], - ]; - - let g2 = vec![ - vec![40, -21, 53, 42, 105, 1, 87, 60, 39, -28], - vec![-92, -64, 19, -167, -71, -47, 128, -109, 40, -21], - vec![58, 85, -93, 37, 101, -14, 5, 37, -76, -56], - vec![-90, -135, 60, -125, 68, 53, 223, 4, -36, -48], - vec![78, 16, 7, -199, 156, -162, 29, 28, -103, -10], - vec![-62, -89, 69, -61, 66, 193, -61, 71, -8, -30], - vec![48, -6, 21, -9, -150, -22, -56, 32, 85, 25], - ]; - - let h2 = vec![ - vec![-8, 1, -7, -2, -9, 4], - vec![4, 5, -5, 2, 7, -1], - vec![-6, -3, -3, -6, 9, 5], - ]; - - let f3 = vec![ - vec![vec![-9, 5, -8], vec![3, 5, 1]], - vec![vec![-1, -7, 2], vec![-5, -6, 6]], - vec![vec![8, 5, 8], vec![-2, -6, -4]], - ]; - - let g3 = vec![ - vec![ - vec![54, 42, 53, -42, 85, -72], - vec![45, -170, 94, -36, 48, 73], - vec![-39, 65, -112, -16, -78, -72], - vec![6, -11, -6, 62, 49, 8], - ], - vec![ - vec![-57, 49, -23, 52, -135, 66], - vec![-23, 127, -58, -5, -118, 64], - vec![87, -16, 121, 23, -41, -12], - vec![-19, 29, 35, -148, -11, 45], - ], - vec![ - vec![-55, -147, -146, -31, 55, 60], - vec![-88, -45, -28, 46, -26, -144], - vec![-12, -107, -34, 150, 249, 66], - vec![11, -15, -34, 27, -78, -50], - ], - vec![ - vec![56, 67, 108, 4, 2, -48], - vec![58, 67, 89, 32, 32, -8], - vec![-42, -31, -103, -30, -23, -8], - vec![6, 4, -26, -10, 26, 12], - ], - ]; - - let h3 = vec![ - vec![ - vec![-6, -8, -5, 9], - vec![-7, 9, -6, -8], - vec![2, -7, 9, 8], - ], - vec![ - vec![7, 4, 4, -6], - vec![9, 9, 4, -4], - vec![-3, 7, -2, -3], - ], - ]; - - let h1_result = deconvolution_1d(&g1, &f1); - print!("deconvolution1D(g1, f1) = "); - print_vector(&h1_result); - println!(); - println!("H1 = h1 ? {}", h1_result == h1); - println!(); - - let f1_result = deconvolution_1d(&g1, &h1); - print!("deconvolution1D(g1, h1) = "); - print_vector(&f1_result); - println!(); - println!("F1 = f1 ? {}", f1_result == f1); - println!(); - - let h2_result = deconvolution_2d(&g2, &f2); - print!("deconvolution2D(g2, f2) = "); - print_2d_vector(&h2_result); - println!(); - println!("H2 = h2 ? {}", h2_result == h2); - println!(); - - let f2_result = deconvolution_2d(&g2, &h2); - print!("deconvolution2D(g2, h2) = "); - print_2d_vector(&f2_result); - println!(); - println!("F2 = f2 ? {}", f2_result == f2); - println!(); - - let h3_result = deconvolution_3d(&g3, &f3); - print!("deconvolution3D(g3, f3) = "); - print_3d_vector(&h3_result); - println!("H3 = h3 ? {}", h3_result == h3); - println!(); - - let f3_result = deconvolution_3d(&g3, &h3); - print!("deconvolution3D(g3, h3) = "); - print_3d_vector(&f3_result); - println!("F3 = f3 ? {}", f3_result == f3); -} diff --git a/Task/Deconvolution-2D+/Wren/deconvolution-2d+.wren b/Task/Deconvolution-2D+/Wren/deconvolution-2d+.wren index 64f34d77f7..5e5247ce7a 100644 --- a/Task/Deconvolution-2D+/Wren/deconvolution-2d+.wren +++ b/Task/Deconvolution-2D+/Wren/deconvolution-2d+.wren @@ -1,5 +1,5 @@ -import "./complex" for Complex -import "./fmt" for Fmt +import "/complex" for Complex +import "/fmt" for Fmt var fft2 // recursive fft2 = Fn.new { |buf, out, n, step, start| diff --git a/Task/Deepcopy/Ada/deepcopy.adb b/Task/Deepcopy/Ada/deepcopy.adb deleted file mode 100644 index 3c60136c46..0000000000 --- a/Task/Deepcopy/Ada/deepcopy.adb +++ /dev/null @@ -1,16 +0,0 @@ -with Ada.Containers.Doubly_Linked_Lists; -with Ada.Text_IO; - -procedure Deepcopy is - package List is new Ada.Containers.Doubly_Linked_Lists (Integer); - L1, L2 : List.List; -begin - L1 := List.Empty_List; - L1.Append (1); - L1.Append (2); - L2 := L1; - L2.Append (3); - - Ada.Text_IO.Put_Line - ("L1.Length = " & L1.Length'Image & " L2.Length = " & L2.Length'Image); -end Deepcopy; diff --git a/Task/Deepcopy/Delphi/deepcopy.pas b/Task/Deepcopy/Delphi/deepcopy.delphi similarity index 100% rename from Task/Deepcopy/Delphi/deepcopy.pas rename to Task/Deepcopy/Delphi/deepcopy.delphi diff --git a/Task/Deepcopy/EasyLang/deepcopy.easy b/Task/Deepcopy/EasyLang/deepcopy.easy deleted file mode 100644 index e0c436fb88..0000000000 --- a/Task/Deepcopy/EasyLang/deepcopy.easy +++ /dev/null @@ -1,10 +0,0 @@ -# There are no more complex data structures than arrays. -# Arrays are always copied deeply. -# If you need something faster, you can swap arrays or -# pass them to procedures by reference. -# -a$[] = [ "apple" "banana" "orange" ] -b$[] = a$[] -b$[1] = "apricot" -print a$[] -print b$[] diff --git a/Task/Deepcopy/FutureBasic/deepcopy.basic b/Task/Deepcopy/FutureBasic/deepcopy.basic deleted file mode 100644 index f473cfeedc..0000000000 --- a/Task/Deepcopy/FutureBasic/deepcopy.basic +++ /dev/null @@ -1,44 +0,0 @@ -include "NSLog.incl" - -begin record DeepCopy - NSInteger value1 - CFStringRef value2 - CFStringRef value3 - Boolean value4 - double value5 -end record - -local fn DoDeepCopy - DeepCopy a, b - - a.value1 = 10 - a.value2 = @"A" - a.value3 = @"Okay" - a.value4 = YES - a.value5 = 1.985766472453666 - - b = a - b.value1 = 20 - b.value2 = @"B" - b.value3 = @"Not Okay" - b.value4 = NO - b.value5 = 3.148556644245367 - - NSLog( @"\nValue of 'a':" ) - NSLog( @"a.value1: %ld", a.value1 ) - NSLog( @"a.value2: %@", a.value2 ) - NSLog( @"a.value3: %@%", a.value3 ) - NSLog( @"b.value4: %@", fn BoolString( a.value4 ) ) - NSLog( @"a.value5: %.15f", a.value5 ) - - NSLog( @"\nValue of 'b':" ) - NSLog( @"b.value1: %ld", b.value1 ) - NSLog( @"b.value2: %@", b.value2 ) - NSLog( @"b.value3: %@%", b.value3 ) - NSLog( @"b.value4: %@", fn BoolString( b.value4 ) ) - NSLog( @"b.value5: %.15f", b.value5 ) -end fn - -fn DoDeepCopy - -HandleEvents diff --git a/Task/Deepcopy/Insitux/deepcopy.insitux b/Task/Deepcopy/Insitux/deepcopy.insitux deleted file mode 100644 index 50abb7ee23..0000000000 --- a/Task/Deepcopy/Insitux/deepcopy.insitux +++ /dev/null @@ -1,11 +0,0 @@ -> (var x [1 2 [3 4]]) -[1 2 [3 4]] - -> (var y x) -[1 2 [3 4]] - -> (var x "something else") -something else - -> y -[1 2 [3 4]] diff --git a/Task/Deepcopy/Julia/deepcopy.jl b/Task/Deepcopy/Julia/deepcopy.julia similarity index 100% rename from Task/Deepcopy/Julia/deepcopy.jl rename to Task/Deepcopy/Julia/deepcopy.julia diff --git a/Task/Deepcopy/Kotlin/deepcopy.kts b/Task/Deepcopy/Kotlin/deepcopy.kotlin similarity index 100% rename from Task/Deepcopy/Kotlin/deepcopy.kts rename to Task/Deepcopy/Kotlin/deepcopy.kotlin diff --git a/Task/Deepcopy/OCaml/deepcopy-1.ml b/Task/Deepcopy/OCaml/deepcopy-1.ocaml similarity index 100% rename from Task/Deepcopy/OCaml/deepcopy-1.ml rename to Task/Deepcopy/OCaml/deepcopy-1.ocaml diff --git a/Task/Deepcopy/OCaml/deepcopy-2.ml b/Task/Deepcopy/OCaml/deepcopy-2.ocaml similarity index 100% rename from Task/Deepcopy/OCaml/deepcopy-2.ml rename to Task/Deepcopy/OCaml/deepcopy-2.ocaml diff --git a/Task/Deepcopy/Phix/deepcopy-1.phix b/Task/Deepcopy/Phix/deepcopy-1.phix index d6a0209534..b313289ff8 100644 --- a/Task/Deepcopy/Phix/deepcopy-1.phix +++ b/Task/Deepcopy/Phix/deepcopy-1.phix @@ -1,6 +1,8 @@ -object a, b - a = {1,{2,3},"four",{5.6,7,{8.9}}} - b = a - b[3] = 4 -?a -?b +--> + object a, b + a = {1,{2,3},"four",{5.6,7,{8.9}}} + b = a + b[3] = 4 + ?a + ?b + + function deep_copy(object o) + object res + if atom(o) then + res = o + else + res = repeat(' ',length(o)) + for i=1 to length(o) do + res[i] = deep_copy(o[i]) + end for + end if + return res + end function -object c = deep_copy(b) -?c + object c = deep_copy(b) + ?c + + include builtins\serialize.e + object d = deserialize(serialize(a)) + ?d + + with javascript_semantics + function descending_primes(sequence res, atom p=0, max_digit=9) + for d=1 to max_digit do + atom np = p*10+d + if odd(d) and is_prime(np) then res &= np end if + res = descending_primes(res,np,d-1) + end for + return res + end function -sequence r = sort(descending_primes({2})), ---sequence r = descending_primes({2}), - j = join_by(r,1,11," ","\n","%8d") -printf(1,"There are %,d descending primes:\n%s\n",{length(r),j}) + sequence r = sort(descending_primes({2})), + --sequence r = descending_primes({2}), + j = join_by(r,1,11," ","\n","%8d") + printf(1,"There are %,d descending primes:\n%s\n",{length(r),j}) + + with javascript_semantics + function descending_primes() + sequence powerset = tagset(9), + res = {} + while length(powerset) do + res &= filter(powerset,is_prime) + sequence next = {} + for i=1 to length(powerset) do + for d=1 to remainder(powerset[i],10)-1 do + next &= powerset[i]*10+d + end for + end for + powerset = next + end while + return res + end function -sequence r = descending_primes(), - j = join_by(r,1,11," ","\n","%8d") -printf(1,"There are %,d descending primes:\n%s\n",{length(r),j}) + sequence r = descending_primes(), + j = join_by(r,1,11," ","\n","%8d") + printf(1,"There are %,d descending primes:\n%s\n",{length(r),j}) + + try + integer i = 1/0 + catch e + ?e[E_USER] + end try + puts(1,"still running...\n") + different: '" & s$[i] & "' (" & hex h & "h)" - print "' position: " & i - return - . - . - print " --> ok" -. -repeat - s$ = input - until s$ = "EOF" - print "'" & s$ & "'" & " length " & len s$ - samechar s$ - print "" -. -input_data - - -2 -333 -.55 -tttTTT -4444 444k -EOF diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Ed/determine-if-a-string-has-all-the-same-characters.ed b/Task/Determine-if-a-string-has-all-the-same-characters/Ed/determine-if-a-string-has-all-the-same-characters.ed deleted file mode 100644 index 017120430b..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Ed/determine-if-a-string-has-all-the-same-characters.ed +++ /dev/null @@ -1,5 +0,0 @@ -H -g/^(.)\1*$/s//All the characters are the same in &/ -v/All the characters/s/.*/Not all characters are the same in &/ -,p -Q diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Forth/determine-if-a-string-has-all-the-same-characters.fth b/Task/Determine-if-a-string-has-all-the-same-characters/Forth/determine-if-a-string-has-all-the-same-characters.fth deleted file mode 100644 index 3738cdf6ed..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Forth/determine-if-a-string-has-all-the-same-characters.fth +++ /dev/null @@ -1,18 +0,0 @@ -: samechars? ( str-addr str-len -- ) - [char] " emit 2dup type [char] " emit ." length: " dup . ." -> " - dup 1 > if - over c@ swap 1 do - over i + c@ over <> if - ." different character '" drop i + c@ dup emit - ." ' ($" hex 1 .r ." ) at " decimal i . cr unloop exit - then - loop - then 2drop ." all characters are the same" cr ; - -s" " samechars? -s" " samechars? -s" 2" samechars? -s" 333" samechars? -s" .55" samechars? -s" tttTTT" samechars? -s" 4444 444k" samechars? diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/FutureBasic/determine-if-a-string-has-all-the-same-characters.basic b/Task/Determine-if-a-string-has-all-the-same-characters/FutureBasic/determine-if-a-string-has-all-the-same-characters.basic deleted file mode 100644 index 7cfddc4045..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/FutureBasic/determine-if-a-string-has-all-the-same-characters.basic +++ /dev/null @@ -1,30 +0,0 @@ -defstr byte - -void local fn CheckString( s as CFStringRef ) - print @"String: \"";s;@"\"" - - long length = len(s) - if ( length ) - unichar prevChr = ucc(s) - for long i = 1 to length - 1 - unichar chr = ucc(s,i) - if ( chr != prevChr ) - print ,@"character ";ucs(chr);@" at position ";i;@", 0x";hex(chr);@", is the first different character" - return - end if - prevChr = chr - next - end if - - print ,@"all characters are the same" -end fn - -fn CheckString( @"" ) -fn CheckString( @" " ) -fn CheckString( @"2" ) -fn CheckString( @"333" ) -fn CheckString( @".55" ) -fn CheckString( @"tttTTT" ) -fn CheckString( @"4444 444k" ) - -HandleEvents diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Gambas/determine-if-a-string-has-all-the-same-characters.gambas b/Task/Determine-if-a-string-has-all-the-same-characters/Gambas/determine-if-a-string-has-all-the-same-characters.gambas deleted file mode 100644 index 93ce19d6a8..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Gambas/determine-if-a-string-has-all-the-same-characters.gambas +++ /dev/null @@ -1,29 +0,0 @@ -Public Sub CaracteresUnicos(cad As String) - - Dim lngt As Integer = Len(cad) - Dim i, j As Integer - - Print "String = \"" & cad & "\", length = " & lngt - - For i = 1 To lngt - For j = i + 1 To lngt - If Mid(cad, i, 1) = Mid(cad, j, 1) Then - Print " First difference at position " & i & " and " & j & ", character = '" & Mid(cad, i, 1) & "', hex value = " & Hex(Asc(Mid(cad, i, 1))) - Print - Return - End If - Next - Next - Print " All characters are the same.\n" - -End Sub - -Public Sub Main() - - CaracteresUnicos("") - CaracteresUnicos(".") - CaracteresUnicos("abcABC") - CaracteresUnicos("XYZ ZYX") - CaracteresUnicos("1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ") - -End diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Haskell/determine-if-a-string-has-all-the-same-characters-3.hs b/Task/Determine-if-a-string-has-all-the-same-characters/Haskell/determine-if-a-string-has-all-the-same-characters-3.hs deleted file mode 100644 index bcab76a0a5..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Haskell/determine-if-a-string-has-all-the-same-characters-3.hs +++ /dev/null @@ -1,10 +0,0 @@ -(function check-all-chars-same string - (print "String (" string ") of len: " (len string)) - (let num-same (count-while (= (0 string)) string)) - (return-when (= num-same (len string)) - (print "...all characters the same")) - (print (pad-left " " (+ 9 num-same) "^")) - (print "...character " num-same " differs - it is 0x" - (to-base 16 (char-code (num-same string))))) - -(map check-all-chars-same ["" " " "2" "333" ".55" "tttTTT" "4444 444k"]) diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/IS-BASIC/determine-if-a-string-has-all-the-same-characters.basic b/Task/Determine-if-a-string-has-all-the-same-characters/IS-BASIC/determine-if-a-string-has-all-the-same-characters.basic deleted file mode 100644 index cf46ac2c70..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/IS-BASIC/determine-if-a-string-has-all-the-same-characters.basic +++ /dev/null @@ -1,21 +0,0 @@ -100 PROGRAM "Samechar.bas" -110 DO -120 READ IF MISSING EXIT DO:TEST$ -130 LET TEST=SAMEC(TEST$) -140 PRINT """";TEST$;""" (length =";LEN(TEST$);")" -150 IF NOT TEST THEN -160 PRINT "All characters are the same" -170 ELSE -180 PRINT """";TEST$(TEST);""" is the first difference at pos.";TEST -190 END IF -200 PRINT -210 LOOP -220 DEF SAMEC(S$) -230 LET SAMEC=0 -240 IF LEN(S$)>1 THEN -250 FOR I=2 TO LEN(S$) -260 IF S$(I)<>S$(1) THEN LET SAMEC=I:EXIT FOR -270 NEXT -280 END IF -290 END DEF -300 DATA ""," ",2,333,.55,tttTTT,"4444 444k" diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Janet/determine-if-a-string-has-all-the-same-characters.janet b/Task/Determine-if-a-string-has-all-the-same-characters/Janet/determine-if-a-string-has-all-the-same-characters.janet deleted file mode 100644 index 8dbe4b3fcf..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Janet/determine-if-a-string-has-all-the-same-characters.janet +++ /dev/null @@ -1,10 +0,0 @@ -(defn check-all-same-characters - [str] - (printf "Input: \"%s\", length: %d." str (length str)) - (if-let [c (first str) - i (find-index |(not= c $) str)] - (printf "Character '%c' (0x%x) at index %d differs." (str i) (str i) i) - (printf "All characters are the same."))) - -(each str ["" " " "2" "333" ".55" "tttTTT" "4444 444k"] - (check-all-same-characters str)) diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Julia/determine-if-a-string-has-all-the-same-characters.jl b/Task/Determine-if-a-string-has-all-the-same-characters/Julia/determine-if-a-string-has-all-the-same-characters.julia similarity index 100% rename from Task/Determine-if-a-string-has-all-the-same-characters/Julia/determine-if-a-string-has-all-the-same-characters.jl rename to Task/Determine-if-a-string-has-all-the-same-characters/Julia/determine-if-a-string-has-all-the-same-characters.julia diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Kotlin/determine-if-a-string-has-all-the-same-characters.kts b/Task/Determine-if-a-string-has-all-the-same-characters/Kotlin/determine-if-a-string-has-all-the-same-characters.kotlin similarity index 100% rename from Task/Determine-if-a-string-has-all-the-same-characters/Kotlin/determine-if-a-string-has-all-the-same-characters.kts rename to Task/Determine-if-a-string-has-all-the-same-characters/Kotlin/determine-if-a-string-has-all-the-same-characters.kotlin diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/LOLCODE/determine-if-a-string-has-all-the-same-characters.lol b/Task/Determine-if-a-string-has-all-the-same-characters/LOLCODE/determine-if-a-string-has-all-the-same-characters.lol deleted file mode 100644 index 93b0018ea4..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/LOLCODE/determine-if-a-string-has-all-the-same-characters.lol +++ /dev/null @@ -1,29 +0,0 @@ -HAI 1.4 - -CAN HAS STRING? -HOW IZ I ALLSAEMCHARS YR S - I HAS A L ITZ STRING IZ LEN YR S MKAY - VISIBLE "':{S}' HAS LENGTH :{L}." - I HAS A C0 ITZ STRING IZ AT YR S AN YR 0 MKAY - IM IN YR LOOP UPPIN YR N TIL BOTH SAEM N AN L - I HAS A CN ITZ STRING IZ AT YR S AN YR N MKAY - DIFFRINT C0 AN CN, O RLY? - YA RLY - VISIBLE "CHARS NOT ALL SAEM." - VISIBLE "FURST DIFFRINT CHAR IZ ':{CN}' AT POZISHUN :{N}.:)" - FOUND YR FAIL - OIC - IM OUTTA YR LOOP - VISIBLE "CHARS ALL SAEM!:)" - FOUND YR WIN -IF U SAY SO - -I IZ ALLSAEMCHARS YR "" MKAY -I IZ ALLSAEMCHARS YR " " MKAY -I IZ ALLSAEMCHARS YR "2" MKAY -I IZ ALLSAEMCHARS YR "333" MKAY -I IZ ALLSAEMCHARS YR ".55" MKAY -I IZ ALLSAEMCHARS YR "tttTTT" MKAY -I IZ ALLSAEMCHARS YR "4444 444k" MKAY - -KTHXBYE diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Nu/determine-if-a-string-has-all-the-same-characters-1.nu b/Task/Determine-if-a-string-has-all-the-same-characters/Nu/determine-if-a-string-has-all-the-same-characters-1.nu deleted file mode 100644 index 4f9d695f01..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Nu/determine-if-a-string-has-all-the-same-characters-1.nu +++ /dev/null @@ -1,20 +0,0 @@ -let strings = ["", " ", "2", "333", ".55", "tttTTT", "4444 444k", "pépé"] - -$strings | each { |str| - let pos = if $str == "" { - null - } else { - let first_char = ($str | str substring 0..0) - let chars = ($str | split chars) - let found = ($chars | enumerate | find { |it| $it.item != $first_char } | get -i 0 | get -i index) - $found - } - let char_info = if $pos != null { - let char = ($str | str substring $pos..$pos) - let codepoint = ($char | into int | fmt | get hex) - $"first different char '($char)' (0x($codepoint)) at position ($pos)." - } else { - "all the same." - } - $"($str | to nuon) size ($str | str length): ($char_info)" -} | str join "\n" | print diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Nu/determine-if-a-string-has-all-the-same-characters-2.nu b/Task/Determine-if-a-string-has-all-the-same-characters/Nu/determine-if-a-string-has-all-the-same-characters-2.nu deleted file mode 100644 index 09a47ab769..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Nu/determine-if-a-string-has-all-the-same-characters-2.nu +++ /dev/null @@ -1,27 +0,0 @@ -let strings = ["", " ", "2", "333", ".55", "tttTTT", "4444 444k", "pépé"] - -$strings | - enumerate | - iter filter-map { |row| - let str = $row.item - let first_diff_pos = if $str == "" { - null - } else { - $str | - split chars | - enumerate | - find { |it| $it.item != ($str | str substring 0..0) } | - get -i 0.index - } - let char_info = if $first_diff_pos == null { - "all the same." - } else { - let pos = $first_diff_pos - let char = ($str | str substring $pos..$pos) - let codepoint = ($char | into int | fmt | get hex) - $"first different char '($char)' (0x($codepoint)) at position ($pos)." - } - { out: $"($str | to nuon) size ($str | str length): ($char_info)" } -} | - get out | - str join "\n" diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/OCaml/determine-if-a-string-has-all-the-same-characters.ml b/Task/Determine-if-a-string-has-all-the-same-characters/OCaml/determine-if-a-string-has-all-the-same-characters.ocaml similarity index 100% rename from Task/Determine-if-a-string-has-all-the-same-characters/OCaml/determine-if-a-string-has-all-the-same-characters.ml rename to Task/Determine-if-a-string-has-all-the-same-characters/OCaml/determine-if-a-string-has-all-the-same-characters.ocaml diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Oberon-07/determine-if-a-string-has-all-the-same-characters.oberon b/Task/Determine-if-a-string-has-all-the-same-characters/Oberon-07/determine-if-a-string-has-all-the-same-characters.oberon deleted file mode 100644 index 5633932ebc..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Oberon-07/determine-if-a-string-has-all-the-same-characters.oberon +++ /dev/null @@ -1,84 +0,0 @@ -MODULE AllTheSame; - IMPORT Strings, Out; - - CONST dQuote = 22X; (* ASCII ", which can't appear in string literals *) - - (* return the position of the first different character in s *) - (* or -1 if all the characters are the same *) - (* s is assumed to have a trailing 0X character, which is ignored *) - PROCEDURE firstDiff( s : ARRAY OF CHAR ) : INTEGER; - VAR result, sLen : INTEGER; - c1 : CHAR; - BEGIN - sLen := Strings.Length( s ); - IF sLen <= 1 THEN (* 0 or 1 character *) - result := -1; - ELSE (* 2 or more characters *) - result := 1; - c1 := s[ 0 ]; - WHILE ( result < sLen ) & ( s[ result ] = c1 ) DO - INC( result ) - END; - IF ( result = sLen ) & ( s[ result ] = 0X ) THEN - result := -1 - END - END - RETURN result - END firstDiff ; - - (* returns n converted to a hex digit *) - PROCEDURE hexDigit( n : INTEGER ) : CHAR; - VAR result : CHAR; - BEGIN - IF n < 10 THEN - result := CHR( ORD( "0" ) + n ) - ELSE - result := CHR( ORD( "a" ) + ( n MOD 10 ) ) - END - RETURN result - END hexDigit ; - - (* displays a character as a hex number *) - PROCEDURE outHexChar( c : CHAR ); - VAR cv : INTEGER; - BEGIN - cv := ORD( c ); - IF cv > 255 THEN - outHexChar( CHR( cv DIV 256 ) ); - END; - cv := cv MOD 256; - Out.Char( hexDigit( cv DIV 16 ) ); - Out.Char( hexDigit( cv MOD 16 ) ) - END outHexChar; - - (* show whether s contains all the same character or the first diff *) - PROCEDURE showFirstDiff( s : ARRAY OF CHAR ); - VAR sLen, diffPos : INTEGER; - dc : CHAR; - BEGIN - diffPos := firstDiff( s ); - sLen := Strings.Length( s ); - Out.Char( dQuote );Out.String( s );Out.Char( dQuote ); - Out.String( " (length " );Out.Int( sLen, 0 );Out.String( "):" ); - IF diffPos < 0 THEN - Out.String( "all characters are the same" );Out.Ln - ELSE - dc := s[ diffPos ]; - Out.String( "first different character " ); - Out.Char( dQuote );Out.Char( dc );Out.Char( dQuote ); - Out.String( "(0x" );outHexChar( dc );Out.String( ") at position: " );Out.Int( diffPos, 0 ); - Out.String( " (0-based)" );Out.Ln - END - END showFirstDiff ; - -BEGIN (* task test cases *) - showFirstDiff( "" ); - showFirstDiff( " " ); - showFirstDiff( "2" ); - showFirstDiff( "333" ); - showFirstDiff( ".55" ); - showFirstDiff( "66." ); - showFirstDiff( "tttTTT" ); - showFirstDiff( "4444 444k" ); - showFirstDiff( "4444|444k" ) -END AllTheSame. diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/OmniMark/determine-if-a-string-has-all-the-same-characters.xom b/Task/Determine-if-a-string-has-all-the-same-characters/OmniMark/determine-if-a-string-has-all-the-same-characters.xom deleted file mode 100644 index f465189a9a..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/OmniMark/determine-if-a-string-has-all-the-same-characters.xom +++ /dev/null @@ -1,39 +0,0 @@ -; Command line: omnimark -sb determine.xom -of determine.txt -include "utf8pat.xin" -process - local stream s variable initial {'', ' ', '2', '333', '.55', 'tttTTT', '4444 444k', '😁😁🙂😁😁'} - repeat over s - local stream last initial {''} - local switch same initial {true} - local stream poschar - local integer poshex - local integer poshex2 - local integer position initial {1} - local integer len initial {0} - repeat scan s - match (["%0#" to "%127#"] | utf8-char) => char - do when last = '' - set last to char - else when last != char - do when same - set poschar to char when same - do when char matches utf8-char - set poshex to utf8-char-number char - else - set poshex to char binary 0 - done - deactivate same - done - done - increment position when same - increment len - again - output 'String "%g(s)" is %d(len) character' - output 's' unless len = 1 - output ':%n' - do when same - output ' - All characters are the same.%n' - else - output ' - Not all characters are the same (position %d(position): "%g(poschar)" [hex=%16rud(poshex)])%n' - done - again diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/OxygenBasic/determine-if-a-string-has-all-the-same-characters.basic b/Task/Determine-if-a-string-has-all-the-same-characters/OxygenBasic/determine-if-a-string-has-all-the-same-characters.basic deleted file mode 100644 index 788e9a275e..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/OxygenBasic/determine-if-a-string-has-all-the-same-characters.basic +++ /dev/null @@ -1,28 +0,0 @@ -uses console - -sub CaracteresUnicos (cad as string) - int i, j, lngt - lngt = len(cad) - printl "String = " chr(34) & cad & chr(34) ", length = " lngt - for i = 1 to lngt - for j = i + 1 to lngt - if mid(cad,i,1) = mid(cad,j,1) then - printl " First difference at position " & i & _ - " and " & j & ", character = '" & mid(cad,i,1) & _ - "', hex value = " & hex(asc(mid(cad,i,1))) - printl - exit sub - end if - next j - next i - printl " All characters are the same." cr -end sub - -CaracteresUnicos ("") -CaracteresUnicos (".") -CaracteresUnicos ("abcABC") -CaracteresUnicos ("XYZ ZYX") -CaracteresUnicos ("1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ") - -printl cr "Enter ..." -waitkey diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/PascalABC.NET/determine-if-a-string-has-all-the-same-characters.pas b/Task/Determine-if-a-string-has-all-the-same-characters/PascalABC.NET/determine-if-a-string-has-all-the-same-characters.pas deleted file mode 100644 index 1455a8fa0f..0000000000 --- a/Task/Determine-if-a-string-has-all-the-same-characters/PascalABC.NET/determine-if-a-string-has-all-the-same-characters.pas +++ /dev/null @@ -1,19 +0,0 @@ -procedure Analyze(s: String); -begin - writeln('Examining ''', s, ''' which has a length of ', s.Length); - if s.Length > 1 Then - foreach var c in s index i do - if c <> s[1] Then - begin - WriteLn(' Not all characters in the string are the same.'); - WriteLn(' ''', c, ''' (0x', ord(c).tostring('x'), ')', ' is different at position ', i + 1); - exit; - end; - WriteLn(' All characters in the string are the same.') -end; - -begin - var strs := |'', ' ', '2', '333', '.55', 'tttTTT', '4444 444k'|; - foreach var s In strs do - Analyze(s); -end. diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/Phix/determine-if-a-string-has-all-the-same-characters.phix b/Task/Determine-if-a-string-has-all-the-same-characters/Phix/determine-if-a-string-has-all-the-same-characters.phix index 5d7ca60852..e4173abaf8 100644 --- a/Task/Determine-if-a-string-has-all-the-same-characters/Phix/determine-if-a-string-has-all-the-same-characters.phix +++ b/Task/Determine-if-a-string-has-all-the-same-characters/Phix/determine-if-a-string-has-all-the-same-characters.phix @@ -1,21 +1,23 @@ -with javascript_semantics -procedure samechar(sequence s) - string msg = "all characters are the same" - integer l = length(s) - if l>=2 then - integer ch = s[1] - for i=2 to l do - integer si = s[i] - if si!=ch then - string su = utf32_to_utf8({si}) - msg = sprintf(`first different character "%s"(#%02x) at position %d`,{su,si,i}) - exit - end if - end for - end if - printf(1,"\"%s\" (length %d): %s\n",{utf32_to_utf8(s),l,msg}) -end procedure +(phixonline)--> + with javascript_semantics + procedure samechar(sequence s) + string msg = "all characters are the same" + integer l = length(s) + if l>=2 then + integer ch = s[1] + for i=2 to l do + integer si = s[i] + if si!=ch then + string su = utf32_to_utf8({si}) + msg = sprintf(`first different character "%s"(#%02x) at position %d`,{su,si,i}) + exit + end if + end for + end if + printf(1,"\"%s\" (length %d): %s\n",{utf32_to_utf8(s),l,msg}) + end procedure -constant tests = {""," ","2","333",".55","tttTTT","4444 444k", - utf8_to_utf32("🐶🐶🐺🐶"),utf8_to_utf32("🎄🎄🎄🎄")} -for i=1 to length(tests) do samechar(tests[i]) end for + constant tests = {""," ","2","333",".55","tttTTT","4444 444k", + utf8_to_utf32("🐶🐶🐺🐶"),utf8_to_utf32("🎄🎄🎄🎄")} + for i=1 to length(tests) do samechar(tests[i]) end for + duplicates: '" & s$[i] & "' (" & hex h & "h)" - print "' positions: " & d[h] & ", " & i - return - . - d[h] = i - . - print "ok" -. -repeat - s$ = input - until s$ = "EOF" - print "'" & s$ & "'" & " length " & len s$ - unichar s$ - print "" -. -input_data - -. -abcABC -XYZ ZYX -1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ -EOF diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Ed/determine-if-a-string-has-all-unique-characters.ed b/Task/Determine-if-a-string-has-all-unique-characters/Ed/determine-if-a-string-has-all-unique-characters.ed deleted file mode 100644 index 509d3b7ad8..0000000000 --- a/Task/Determine-if-a-string-has-all-unique-characters/Ed/determine-if-a-string-has-all-unique-characters.ed +++ /dev/null @@ -1,6 +0,0 @@ -# by Artyom Bologov -H -g/^\(.*\)\(.\)\(.*\)\2\(.*\)$/s//"\1\2\3\2\4" is not unique, repeating '\2'/ -v/ is not unique, repeating /s/.*/"&" is unique/ -,p -Q diff --git a/Task/Determine-if-a-string-has-all-unique-characters/FutureBasic/determine-if-a-string-has-all-unique-characters.basic b/Task/Determine-if-a-string-has-all-unique-characters/FutureBasic/determine-if-a-string-has-all-unique-characters.basic deleted file mode 100644 index 69a977c53c..0000000000 --- a/Task/Determine-if-a-string-has-all-unique-characters/FutureBasic/determine-if-a-string-has-all-unique-characters.basic +++ /dev/null @@ -1,27 +0,0 @@ -void local fn StringHasUniqueCharacters( string as CFStringRef ) - long i, j, length = len( string ) - - if length == 0 then printf @"The string \"\" is empty and thus has no characters to compare.\n" : exit fn - - printf @"The string: \"%@\" has %ld characters.", string, length - - for i = 0 to length - 1 - for j = i + 1 to length - 1 - if ( fn StringIsEqual( mid( string, i, 1 ), mid( string, j, 1 ) ) ) - CFStringRef duplicate = mid( string, i, 1 ) - printf @"The first duplicate character, \"%@\", is found at positions %ld and %ld.", duplicate, i, j - printf @"The hex value of \"%@\" is: 0X%x\n", duplicate, fn StringCharacterAtIndex( duplicate, 0 ) - exit fn - end if - next - next - printf @"All characters in string are unique.\n" -end fn - -fn StringHasUniqueCharacters( @"" ) -fn StringHasUniqueCharacters( @"." ) -fn StringHasUniqueCharacters( @"abcABC" ) -fn StringHasUniqueCharacters( @"XYZ ZYX" ) -fn StringHasUniqueCharacters( @"1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" ) - -HandleEvents diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Julia/determine-if-a-string-has-all-unique-characters.jl b/Task/Determine-if-a-string-has-all-unique-characters/Julia/determine-if-a-string-has-all-unique-characters.julia similarity index 100% rename from Task/Determine-if-a-string-has-all-unique-characters/Julia/determine-if-a-string-has-all-unique-characters.jl rename to Task/Determine-if-a-string-has-all-unique-characters/Julia/determine-if-a-string-has-all-unique-characters.julia diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Kotlin/determine-if-a-string-has-all-unique-characters.kts b/Task/Determine-if-a-string-has-all-unique-characters/Kotlin/determine-if-a-string-has-all-unique-characters.kotlin similarity index 100% rename from Task/Determine-if-a-string-has-all-unique-characters/Kotlin/determine-if-a-string-has-all-unique-characters.kts rename to Task/Determine-if-a-string-has-all-unique-characters/Kotlin/determine-if-a-string-has-all-unique-characters.kotlin diff --git a/Task/Determine-if-a-string-has-all-unique-characters/OCaml/determine-if-a-string-has-all-unique-characters.ml b/Task/Determine-if-a-string-has-all-unique-characters/OCaml/determine-if-a-string-has-all-unique-characters.ocaml similarity index 100% rename from Task/Determine-if-a-string-has-all-unique-characters/OCaml/determine-if-a-string-has-all-unique-characters.ml rename to Task/Determine-if-a-string-has-all-unique-characters/OCaml/determine-if-a-string-has-all-unique-characters.ocaml diff --git a/Task/Determine-if-a-string-has-all-unique-characters/PascalABC.NET/determine-if-a-string-has-all-unique-characters.pas b/Task/Determine-if-a-string-has-all-unique-characters/PascalABC.NET/determine-if-a-string-has-all-unique-characters.pas deleted file mode 100644 index cca5bf3438..0000000000 --- a/Task/Determine-if-a-string-has-all-unique-characters/PascalABC.NET/determine-if-a-string-has-all-unique-characters.pas +++ /dev/null @@ -1,11 +0,0 @@ -## -var input := |'', '.', 'abcABC', 'XYZ ZYX', '1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ'|; -foreach var s in input do - Writeln('''', s, '''', ' (Length ', s.Length, ') ', - String.Join(', ', - s.Select((c, i) -> (c, i)) - .GroupBy(t -> t[0]) - .Where(g -> g.Count() > 1) - .Select(g -> '''' + g.Key + '''(0X' + Ord(g.key).ToString('x') + ') [' + - String.Join(', ', g.Select(t -> t[1])) + ']') - .DefaultIfEmpty('All characters are unique.'))); diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Phix/determine-if-a-string-has-all-unique-characters.phix b/Task/Determine-if-a-string-has-all-unique-characters/Phix/determine-if-a-string-has-all-unique-characters.phix index c89def1994..2c7cffba83 100644 --- a/Task/Determine-if-a-string-has-all-unique-characters/Phix/determine-if-a-string-has-all-unique-characters.phix +++ b/Task/Determine-if-a-string-has-all-unique-characters/Phix/determine-if-a-string-has-all-unique-characters.phix @@ -1,39 +1,40 @@ -with javascript_semantics -procedure all_uniq(sequence s) - string chars = "" - sequence posns = {}, - multi = {} - integer lm = 0 - for i=1 to length(s) do - integer si = s[i], - k = find(si,chars) - if k=0 then - chars &= si - posns &= {{i}} - else - posns[k] &= i - if length(posns[k])=2 then - multi &= k - lm += 1 - end if - end if - end for - string msg = sprintf("\"%s\" (length %d): ",{s,length(s)}), - nod = ordinal(lm,true), - ess = "s"[1..lm>1], - res = iff(lm=0?"all characters are unique" - :sprintf("contains %s duplicate%s:",{nod,ess})) - printf(1,"%s %s\n",{msg,res}) - res = repeat(' ',length(msg)) - for i=1 to length(multi) do - integer mi = multi[i], - ci = chars[mi] - printf(1,"%s '%c'(#%02x) at %V\n",{res,ci,ci,posns[mi]}) - end for - printf(1,"\n") -end procedure +(phixonline)--> + procedure all_uniq(sequence s) + string chars = "" + sequence posns = {}, + multi = {} + integer lm = 0 + for i=1 to length(s) do + integer si = s[i], + k = find(si,chars) + if k=0 then + chars &= si + posns &= {{i}} + else + posns[k] &= i + if length(posns[k])=2 then + multi &= k + lm += 1 + end if + end if + end for + string msg = sprintf("\"%s\" (length %d): ",{s,length(s)}), + nod = ordinal(lm,true), + ess = "s"[1..lm>1], + res = iff(lm=0?"all characters are unique" + :sprintf("contains %s duplicate%s:",{nod,ess})) + printf(1,"%s %s\n",{msg,res}) + res = repeat(' ',length(msg)) + for i=1 to length(multi) do + integer mi = multi[i], + ci = chars[mi] + printf(1,"%s '%c'(#%02x) at %V\n",{res,ci,ci,posns[mi]}) + end for + printf(1,"\n") + end procedure -constant tests = {"",".","abcABC","XYZ ZYX","1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ", - "01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X", - " ","2","333","55","tttTTT","tTTTtt","4444 444k"} -papply(tests,all_uniq) + constant tests = {"",".","abcABC","XYZ ZYX","1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ", + "01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X", + " ","2","333","55","tttTTT","tTTTtt","4444 444k"} + papply(tests,all_uniq) + b ) - - [ dip [ 0 0 true ] - dup size 2 < iff - drop done - dup size 1 - times - [ behead 2dup has iff - [ swap find - dip not - 2swap 2drop - i^ tuck + 1+ rot - 0 conclude ] done - drop ] - drop ] is uniquechars ( $ --> n n b ) - - [ dup say 'String "' - echo$ - say '" has length ' - dup size echo - say ". " - dup uniquechars iff - [ say "There are no duplicated characters." - drop 2drop ] - else - [ rot over peek - dup say 'The character "' - emit - say '" (hex:' - 16 base put - echo - base release - say ") is at positions " - swap echo - say " and " - echo - say "." ] - cr ] is task ( $ --> ) - - $ "" task - $ "." task - $ "abcABC" task - $ "XYZ ZYX" task - $ "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" task diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Raku/determine-if-a-string-has-all-unique-characters.raku b/Task/Determine-if-a-string-has-all-unique-characters/Raku/determine-if-a-string-has-all-unique-characters.raku index 194d5ae80f..0fe534d8b0 100644 --- a/Task/Determine-if-a-string-has-all-unique-characters/Raku/determine-if-a-string-has-all-unique-characters.raku +++ b/Task/Determine-if-a-string-has-all-unique-characters/Raku/determine-if-a-string-has-all-unique-characters.raku @@ -1,7 +1,8 @@ -> $str { my $i = 0; print "\n{$str.raku} (length: {$str.chars}), has "; - my %m = $str.comb.Bag; + my %m; + %m{$_}.push: ++$i for $str.comb; if any(%m.values) > 1 { say "duplicated characters:"; say "'{.key}' ({.key.uninames}; hex ordinal: {(.key.ords).fmt: "0x%X"})" ~ diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Rust/determine-if-a-string-has-all-unique-characters.rs b/Task/Determine-if-a-string-has-all-unique-characters/Rust/determine-if-a-string-has-all-unique-characters.rust similarity index 100% rename from Task/Determine-if-a-string-has-all-unique-characters/Rust/determine-if-a-string-has-all-unique-characters.rs rename to Task/Determine-if-a-string-has-all-unique-characters/Rust/determine-if-a-string-has-all-unique-characters.rust diff --git a/Task/Determine-if-a-string-has-all-unique-characters/S-BASIC/determine-if-a-string-has-all-unique-characters.basic b/Task/Determine-if-a-string-has-all-unique-characters/S-BASIC/determine-if-a-string-has-all-unique-characters.basic deleted file mode 100644 index 1756386cc4..0000000000 --- a/Task/Determine-if-a-string-has-all-unique-characters/S-BASIC/determine-if-a-string-has-all-unique-characters.basic +++ /dev/null @@ -1,50 +0,0 @@ -comment - Return 0 if there are no repeated characters in s - (including the special case of an empty string), - otherwise the first position where a character - duplicates one previously encountered -end -function repeated_chars(s = string) = integer - var i, j, slen, result = integer - slen = len(s) - if slen < 2 then - result = 0 - else - begin - result = 0 - for i = 1 to slen - 1 - for j = i + 1 to slen - if mid(s,i,1) = mid(s,j,1) and result = 0 then - result = j - next j - next i - end -end = result - -procedure report(str = string) - var p, first = integer - p = repeated_chars(str) - if p = 0 then - print chr(34); str; chr(34); " (length ="; len(str); \ - ") has no duplicate characters" - else - begin - first = instr(1, str, mid(str,p,1)) - print chr(34); str; chr(34); " (length ="; len(str); \ - ") has duplicate characters:" - print "'"; mid(str,p,1); "' (= "; right$(hex$(asc(mid(str,p,1))),2); \ - "h)"; " appears at positions"; first; " and"; p - - end - print -end - -rem - test cases - -report "" -report "." -report "abcABC" -report "XYZ ZYX" -report "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" - -end diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Uiua/determine-if-a-string-has-all-unique-characters.uiua b/Task/Determine-if-a-string-has-all-unique-characters/Uiua/determine-if-a-string-has-all-unique-characters.uiua deleted file mode 100644 index c82ee16f17..0000000000 --- a/Task/Determine-if-a-string-has-all-unique-characters/Uiua/determine-if-a-string-has-all-unique-characters.uiua +++ /dev/null @@ -1,7 +0,0 @@ -Find ← ⬚∞⊢⊚>1≡⌟⦷⊸⊸◴ -Show ← ( - ⨬(&p$"Duplicated '_'\n'_'\n_"⊃(⊡⊢|⊃⋅∘∘⊂@\s+@\0+⊙(×-@\0@^)×32⊸¬°⊚) - | &p$"'_'\nokay"◌ - )⊸(=∞⊢) -) -≡◇(Show Find){"" "." "abcABC" "XYZ ZYX" "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ"} diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Wren/determine-if-a-string-has-all-unique-characters.wren b/Task/Determine-if-a-string-has-all-unique-characters/Wren/determine-if-a-string-has-all-unique-characters.wren index 716410342a..19b850be3d 100644 --- a/Task/Determine-if-a-string-has-all-unique-characters/Wren/determine-if-a-string-has-all-unique-characters.wren +++ b/Task/Determine-if-a-string-has-all-unique-characters/Wren/determine-if-a-string-has-all-unique-characters.wren @@ -1,4 +1,4 @@ -import "./fmt" for Conv, Fmt +import "/fmt" for Conv, Fmt var analyze = Fn.new { |s| var chars = s.codePoints.toList diff --git a/Task/Determine-if-a-string-has-all-unique-characters/Yabasic/determine-if-a-string-has-all-unique-characters.basic b/Task/Determine-if-a-string-has-all-unique-characters/Yabasic/determine-if-a-string-has-all-unique-characters.basic index 4da18a4436..c4500a9b10 100644 --- a/Task/Determine-if-a-string-has-all-unique-characters/Yabasic/determine-if-a-string-has-all-unique-characters.basic +++ b/Task/Determine-if-a-string-has-all-unique-characters/Yabasic/determine-if-a-string-has-all-unique-characters.basic @@ -1,6 +1,5 @@ sub caracteresunicos (cad$) - local lngt, i, j - + local lngt lngt = len(cad$) print "cadena = \"", cad$, "\", longitud = ", lngt for i = 1 to lngt diff --git a/Task/Determine-if-a-string-is-collapsible/ANSI-BASIC/determine-if-a-string-is-collapsible.basic b/Task/Determine-if-a-string-is-collapsible/ANSI-BASIC/determine-if-a-string-is-collapsible.basic deleted file mode 100644 index 676e5d4ca7..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/ANSI-BASIC/determine-if-a-string-is-collapsible.basic +++ /dev/null @@ -1,38 +0,0 @@ -100 REM Determine if a string is collapsible -110 DECLARE EXTERNAL FUNCTION Collapse$ -120 READ N -130 FOR J = 1 TO N -140 READ StrIn$ -150 LET StrOut$ = Collapse$(StrIn$) -160 PRINT LEN(StrIn$); "<<<"; StrIn$; ">>>" -170 PRINT LEN(StrOut$); "<<<"; StrOut$; ">>>" -180 PRINT -190 NEXT J -200 DATA 5 -210 DATA "" -220 DATA "'If I were two-faced, would I be wearing this one?' --- Abraham Lincoln " -230 DATA "..1111111111111111111111111111111111111111111111111111111111111117777888" -240 DATA "I never give 'em hell, I just tell the truth, and they think it's hell. " -250 DATA " --- Harry S Truman " -260 END -270 ! -280 EXTERNAL FUNCTION Collapse$(StrIn$) -290 IF StrIn$ = "" THEN -300 LET StrOut$ = StrIn$ -310 ELSE -320 LET StrOut$ = REPEAT$(" ", LEN(StrIn$)) -330 LET A$ = StrIn$(1:1) -340 LET StrOut$(1:1) = A$ -350 LET T = 2 -360 FOR I = 2 TO LEN(StrIn$) -370 LET B$ = StrIn$(I:I) -380 IF A$ <> B$ THEN -390 LET StrOut$(T:T) = B$ -400 LET T = T + 1 -410 LET A$ = B$ -420 END IF -430 NEXT I -440 LET StrOut$ = StrOut$(1 : T - 1) -450 END IF -460 LET Collapse$ = StrOut$ -470 END FUNCTION diff --git a/Task/Determine-if-a-string-is-collapsible/Ada/determine-if-a-string-is-collapsible.adb b/Task/Determine-if-a-string-is-collapsible/Ada/determine-if-a-string-is-collapsible.ada similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/Ada/determine-if-a-string-is-collapsible.adb rename to Task/Determine-if-a-string-is-collapsible/Ada/determine-if-a-string-is-collapsible.ada diff --git a/Task/Determine-if-a-string-is-collapsible/Applesoft-BASIC/determine-if-a-string-is-collapsible.basic b/Task/Determine-if-a-string-is-collapsible/Applesoft-BASIC/determine-if-a-string-is-collapsible.basic deleted file mode 100644 index d7e2430ecc..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Applesoft-BASIC/determine-if-a-string-is-collapsible.basic +++ /dev/null @@ -1,28 +0,0 @@ -10 READ N -20 FOR A = 1 TO N -30 READ I$ -40 GOSUB 100" COLLAPSE -50 PRINT LEN(I$) " <<<" I$ ">>>" -60 PRINT LEN(O$) " <<<" O$ ">>>" -70 PRINT -80 NEXT -90 END - -REM COLLAPSE -100 O$ = I$ -110 IF LEN(I$) < 2 THEN RETURN -120 O$ = "" -130 P$ = "" -140 FOR I = 1 TO LEN(i$) -150 C$ = MID$(I$,I,1) -160 IF C$ <> P$ THEN O$ = O$ + C$ -170 P$ = C$ -180 NEXT I -190 RETURN - -400 DATA 5 -410 DATA "" -420 DATA "'If I were two-faced, would I be wearing this one?' --- Abraham Lincoln " -430 DATA "..1111111111111111111111111111111111111111111111111111111111111117777888" -440 DATA "I never give 'em hell, I just tell the truth, and they think it's hell. " -450 DATA " --- Harry S Truman " diff --git a/Task/Determine-if-a-string-is-collapsible/GW-BASIC/determine-if-a-string-is-collapsible.basic b/Task/Determine-if-a-string-is-collapsible/BASIC/determine-if-a-string-is-collapsible.basic similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/GW-BASIC/determine-if-a-string-is-collapsible.basic rename to Task/Determine-if-a-string-is-collapsible/BASIC/determine-if-a-string-is-collapsible.basic diff --git a/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible-1.bqn b/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible-1.bqn new file mode 100644 index 0000000000..4b2f22d333 --- /dev/null +++ b/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible-1.bqn @@ -0,0 +1,14 @@ +Collapse←(≠↑1∾1↓≠⟜»)⊸/ + +>{ + c←Collapse 𝕩 + ⟨⟨≠𝕩 ⋄ "<<<"∾𝕩∾">>>"⟩≍⟨≠c ⋄ "<<<"∾c∾">>>"⟩⟩ +}¨⟨ + "The better the 4-wheel drive, the further you'll be from help when ya get stuck!" + "headmistressship" + "" + """If I were two-faced, would I be wearing this one?"" --- Abraham Lincoln " + "..1111111111111111111111111111111111111111111111111111111111111117777888" + "I never give 'em hell, I just tell the truth, and they think it's hell. " + " --- Harry S Truman " +⟩ diff --git a/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible-2.bqn b/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible-2.bqn new file mode 100644 index 0000000000..9e46421c02 --- /dev/null +++ b/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible-2.bqn @@ -0,0 +1,30 @@ +┌─ +╵ ┌─ + ╵ 80 "<<>>" + 77 "<<>>" + ┘ + ┌─ + ╵ 16 "<<>>" + 14 "<<>>" + ┘ + ┌─ + ╵ 0 "<<<>>>" + 0 "<<<>>>" + ┘ + ┌─ + ╵ 72 "<<<""If I were two-faced, would I be wearing this one?"" --- Abraham Lincoln >>>" + 70 "<<<""If I were two-faced, would I be wearing this one?"" - Abraham Lincoln >>>" + ┘ + ┌─ + ╵ 72 "<<<..1111111111111111111111111111111111111111111111111111111111111117777888>>>" + 4 "<<<.178>>>" + ┘ + ┌─ + ╵ 72 "<<>>" + 69 "<<>>" + ┘ + ┌─ + ╵ 72 "<<< --- Harry S Truman >>>" + 17 "<<< - Hary S Truman >>>" + ┘ + ┘ diff --git a/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible.bqn b/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible.bqn deleted file mode 100644 index eb67be681c..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/BQN/determine-if-a-string-is-collapsible.bqn +++ /dev/null @@ -1,11 +0,0 @@ -Collapse ← (1»≠⟜«)⊸/ - ->⍉ ⊢‿Collapse (≠⋈"<<<"⊸∾∘∾⟜">>>")∘{𝕎𝕩}⌜ ⟨ - "The better the 4-wheel drive, the further you'll be from help when ya get stuck!" - "headmistressship" - "" - """If I were two-faced, would I be wearing this one?"" --- Abraham Lincoln " - "..1111111111111111111111111111111111111111111111111111111111111117777888" - "I never give 'em hell, I just tell the truth, and they think it's hell. " - " --- Harry S Truman " -⟩ diff --git a/Task/Determine-if-a-string-is-collapsible/Crystal/determine-if-a-string-is-collapsible.cr b/Task/Determine-if-a-string-is-collapsible/Crystal/determine-if-a-string-is-collapsible.cr deleted file mode 100644 index cc07aaf3c2..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Crystal/determine-if-a-string-is-collapsible.cr +++ /dev/null @@ -1,16 +0,0 @@ -strings = ["", - "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln ", - "..1111111111111111111111111111111111111111111111111111111111111117777888", - "I never give 'em hell, I just tell the truth, and they think it's hell. ", - " --- Harry S Truman ", - "The better the 4-wheel drive, the further you'll be from help when ya get stuck!", - "headmistressship", - "aardvark", - "😍😀🙌💃😍😍😍🙌",] - -strings.each do |str| - puts "«««#{str}»»» (size #{str.size})" - ssq = str.squeeze - puts "«««#{ssq}»»» (size #{ssq.size})" - puts -end diff --git a/Task/Determine-if-a-string-is-collapsible/Delphi/determine-if-a-string-is-collapsible.pas b/Task/Determine-if-a-string-is-collapsible/Delphi/determine-if-a-string-is-collapsible.delphi similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/Delphi/determine-if-a-string-is-collapsible.pas rename to Task/Determine-if-a-string-is-collapsible/Delphi/determine-if-a-string-is-collapsible.delphi diff --git a/Task/Determine-if-a-string-is-collapsible/DuckDB/determine-if-a-string-is-collapsible.duckdb b/Task/Determine-if-a-string-is-collapsible/DuckDB/determine-if-a-string-is-collapsible.duckdb deleted file mode 100644 index d3a1ccb531..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/DuckDB/determine-if-a-string-is-collapsible.duckdb +++ /dev/null @@ -1,16 +0,0 @@ -create or replace function uniq(lst) as - list_filter(lst, (x,i) -> i=1 or lst[i-1] != x); - -create or replace function collapse(str) as - string_split(str,'').uniq().array_to_string(''); - -.maxwidth 200 - -select length(s), collapse(s) as collapsed, length(collapsed) -from unnest([ - '', - '"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln ', - '..1111111111111111111111111111111111111111111111111111111111111117777888', - 'I never give ''em hell, I just tell the truth, and they think it''s hell. ', - ' --- Harry S Truman ' -]) _(s); diff --git a/Task/Determine-if-a-string-is-collapsible/EasyLang/determine-if-a-string-is-collapsible.easy b/Task/Determine-if-a-string-is-collapsible/EasyLang/determine-if-a-string-is-collapsible.easy deleted file mode 100644 index 1721a5edb9..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/EasyLang/determine-if-a-string-is-collapsible.easy +++ /dev/null @@ -1,18 +0,0 @@ -func$ collapse s$ . - for c$ in strchars s$ - if c$ <> cc$ : r$ &= c$ - cc$ = c$ - . - return r$ -. -s$[] &= "" -s$[] &= "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln " -s$[] &= "..1111111111111111111111111111111111111111111111111111111111111117777888" -s$[] &= "I never give 'em hell, I just tell the truth, and they think it's hell. " -s$[] &= " --- Harry S Truman " -for s$ in s$[] - print "«««" & s$ & "»»» (" & len s$ & ")" - r$ = collapse s$ - print "«««" & r$ & "»»» (" & len r$ & ")" - print "" -. diff --git a/Task/Determine-if-a-string-is-collapsible/Ed/determine-if-a-string-is-collapsible.ed b/Task/Determine-if-a-string-is-collapsible/Ed/determine-if-a-string-is-collapsible.ed deleted file mode 100644 index 01197d5a35..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Ed/determine-if-a-string-is-collapsible.ed +++ /dev/null @@ -1,5 +0,0 @@ -# by Artyom Bologov -H -g/\(.\)\1*/s//\1/g -,p -Q diff --git a/Task/Determine-if-a-string-is-collapsible/Fortran/determine-if-a-string-is-collapsible.f b/Task/Determine-if-a-string-is-collapsible/Fortran/determine-if-a-string-is-collapsible.f deleted file mode 100644 index 4f9ca7cf8d..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Fortran/determine-if-a-string-is-collapsible.f +++ /dev/null @@ -1,66 +0,0 @@ -! -! Determine if a string is collapsible -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 26.04 -! GNU gfortran (Ubuntu 15.2.0-16ubuntu1) 15.2.0 on Kubuntu 26.04 -! VSI Fortran x86-64 V8.7-001 on OpenVMS V9.2-3 -! U.B., April 2026 -! - program CollapsibleStrings - -implicit none - -character (len=*), parameter :: s1='' -character (len=*), parameter :: s2='"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln ' -character (len=*), parameter :: s3='..1111111111111111111111111111111111111111111111111111111111111117777888' -character (len=*), parameter :: s4="I never give 'em hell, I just tell the truth, and they think it's hell. " -character (len=*), parameter :: s5=' --- Harry S Truman ' -character (len=*), parameter :: s6="The better the 4-wheel drive, the further you'll be from help when ya get stuck!" -character (len=*), parameter :: s7='headmistressship' -character (len=*), parameter :: s8='aardvark' - - -call checkCollapse (s1) -call checkCollapse (s2) -call checkCollapse (s3) -call checkCollapse (s4) -call checkCollapse (s5) -call checkCollapse (s6) -call checkCollapse (s7) -call checkCollapse (s8) - - -contains - -subroutine checkCollapse (s) -character (len=*), intent(in) :: s -character (len=len(s)) :: sOut -integer :: l, iLast,iNext,iOut - -l = len(s) -! early return if s empty -if (l .eq. 0) then - sOut = S - iout = 0 -else - sOut(1:1) = s(1:1) - iLast = 1 - iOut = 1 - do while (iLast .lt. len(s)) ! through entire input string - iNext=iLast ! to find next letter .ne. last letter - do while (iNext .le. len(s) .and. s(iNext:iNext) .eq. s(iLast:iLast)) - iNext = iNext + 1 ! Skip this letter if it is the same as last - enddo - if (iNext .le. l) then - iOut = iOut + 1 ! 'next' is to copy to the end of sOut - sOut(iOut:iOut) = s(iNext:iNext) - iLast = iNext ! 'next' becomes the new Last - else - exit - endif - end do -endif -write (*, '("<<<",A,">>>", x, "(",i0,")")') s (:l), l -write (*, '("<<<",A,">>>", x, "(",i0,")")') sOut (:iOut), iOut - -end subroutine checkCollapse -end program CollapsibleStrings diff --git a/Task/Determine-if-a-string-is-collapsible/Icon/determine-if-a-string-is-collapsible.icon b/Task/Determine-if-a-string-is-collapsible/Icon/determine-if-a-string-is-collapsible.icon deleted file mode 100644 index f8c6565d97..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Icon/determine-if-a-string-is-collapsible.icon +++ /dev/null @@ -1,17 +0,0 @@ -procedure main() - strings := ["", - "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln ", - "..1111111111111111111111111111111111111111111111111111111111111117777888", - "I never give 'em hell, I just tell the truth, and they think it's hell. ", - " --- Harry S Truman " - ] - - while collapse(!strings) -end - -procedure collapse(s) - ns := "" - s ? while ns ||:= move(1) do tab(many(ns[*ns])) - write("original: <<<",s,">>>",*s) - write("collapsed:<<<",ns,">>>",*ns) -end diff --git a/Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-1.jl b/Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-1.julia similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-1.jl rename to Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-1.julia diff --git a/Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-2.jl b/Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-2.julia similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-2.jl rename to Task/Determine-if-a-string-is-collapsible/Julia/determine-if-a-string-is-collapsible-2.julia diff --git a/Task/Determine-if-a-string-is-collapsible/Kotlin/determine-if-a-string-is-collapsible.kts b/Task/Determine-if-a-string-is-collapsible/Kotlin/determine-if-a-string-is-collapsible.kotlin similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/Kotlin/determine-if-a-string-is-collapsible.kts rename to Task/Determine-if-a-string-is-collapsible/Kotlin/determine-if-a-string-is-collapsible.kotlin diff --git a/Task/Determine-if-a-string-is-collapsible/PascalABC.NET/determine-if-a-string-is-collapsible.pas b/Task/Determine-if-a-string-is-collapsible/PascalABC.NET/determine-if-a-string-is-collapsible.pas deleted file mode 100644 index ad9907fdba..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/PascalABC.NET/determine-if-a-string-is-collapsible.pas +++ /dev/null @@ -1,24 +0,0 @@ -## -function Collapse(s: String) := - if String.IsNullOrEmpty(s) Then '' - else s[1] + - new String(Range(2, s.Length) - .Where(i -> s[i] <> s[i - 1]) - .Select(i -> s[i]) - .ToArray); - -var input := -|'', -'The better the 4-wheel drive, the further you''ll be from help when ya get stuck!', -'headmistressship', -'"If I were two-faced, would I be wearing this one? --- Abraham Lincoln "', -'..1111111111111111111111111111111111111111111111111111111111111117777888', -'I never give ''em hell, I just tell the truth, and they think it''s hell. ', -' --- Harry S Truman '|; - -foreach var s in input do -begin - Writeln('old: ', s.Length, ' «««', s, '»»»'); - var c := Collapse(s); - WriteLn('new: ', c.Length, ' «««', c, '»»»') -end; diff --git a/Task/Determine-if-a-string-is-collapsible/Pluto/determine-if-a-string-is-collapsible.pluto b/Task/Determine-if-a-string-is-collapsible/Pluto/determine-if-a-string-is-collapsible.pluto deleted file mode 100644 index 83b3f537b5..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Pluto/determine-if-a-string-is-collapsible.pluto +++ /dev/null @@ -1,32 +0,0 @@ -local fmt = require "fmt" -require "uchar" - --- Returns collapsed string, original and new lengths in --- unicode code points (not normalized). -local function collapse(s) - local c = uchar.of(s) - local le = c:len() - if le < 2 then return s, le, le end - for i = le - 1, 1, -1 do - if c:get(i) == c:get(i + 1) then c:remove(i) end - end - return c:tostring(), le, c:len() -end - -local strings = { - "", - "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln ", - "..1111111111111111111111111111111111111111111111111111111111111117777888", - "I never give 'em hell, I just tell the truth, and they think it's hell. ", - " --- Harry S Truman ", - "The better the 4-wheel drive, the further you'll be from help when ya get stuck!", - "headmistressship", - "aardvark", - "😍😀🙌💃😍😍😍🙌" -} - -for strings as s do - local cc, le, lcc = collapse(s) - fmt.print("original : length = %2d, string = «««%s»»»", le, s) - fmt.print("collapsed: length = %2d, string = «««%s»»»\n", lcc, cc) -end diff --git a/Task/Determine-if-a-string-is-collapsible/QuickBASIC/determine-if-a-string-is-collapsible.basic b/Task/Determine-if-a-string-is-collapsible/QuickBASIC/determine-if-a-string-is-collapsible.basic deleted file mode 100644 index 9bb3182fd8..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/QuickBASIC/determine-if-a-string-is-collapsible.basic +++ /dev/null @@ -1,38 +0,0 @@ -' Determine if a string is collapsible -DECLARE FUNCTION Collapse$ (StrIn$) -READ N% -FOR A% = 1 TO N% - READ StrIn$ - StrOut$ = Collapse$(StrIn$) - PRINT LEN(StrIn$); "<<<"; StrIn$; ">>>" - PRINT LEN(StrOut$); "<<<"; StrOut$; ">>>" - PRINT -NEXT -END -DATA 5: ' There are 5 strings -DATA "" -DATA "'If I were two-faced, would I be wearing this one?' --- Abraham Lincoln " -DATA "..1111111111111111111111111111111111111111111111111111111111111117777888" -DATA "I never give 'em hell, I just tell the truth, and they think it's hell. " -DATA " --- Harry S Truman " - -FUNCTION Collapse$ (StrIn$) - IF StrIn$ = "" THEN - StrOut$ = StrIn$ - ELSE - StrOut$ = SPACE$(LEN(StrIn$)) - P$ = LEFT$(StrIn$, 1) - MID$(StrOut$, 1, 1) = P$ - T% = 2 - FOR I% = 2 TO LEN(StrIn$) - C$ = MID$(StrIn$, I%, 1) - IF P$ <> C$ THEN - MID$(StrOut$, T%, 1) = C$ - T% = T% + 1 - P$ = C$ - END IF - NEXT - StrOut$ = LEFT$(StrOut$, T% - 1) - END IF - Collapse$ = StrOut$ -END FUNCTION diff --git a/Task/Determine-if-a-string-is-collapsible/Refal/determine-if-a-string-is-collapsible.refal b/Task/Determine-if-a-string-is-collapsible/Refal/determine-if-a-string-is-collapsible.refal deleted file mode 100644 index ae63874d38..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Refal/determine-if-a-string-is-collapsible.refal +++ /dev/null @@ -1,34 +0,0 @@ -$ENTRY Go { - , ('') - ('"If I were two-faced, would I be wearing this ' - 'one?" --- Abraham Lincoln ') - ('..11111111111111111111111111111111111111111111' - '11111111111111111117777888') - ('I never give \'em hell, I just tell the truth, ' - 'and they think it\'s hell. ') - (' ' - ' --- Harry S Truman '): e.Strings - = ; -}; - -Each { - s.F = ; - s.F t.I e.X = ; -}; - -Brackets { - e.X, : s.L e.X = - ': <<<' e.X '>>>'>; -}; - -Show { - (e.X) = - > - ; -}; - -Collapse { - = ; - s.C s.C e.S = ; - s.C e.S = s.C ; -}; diff --git a/Task/Determine-if-a-string-is-collapsible/Rust/determine-if-a-string-is-collapsible.rs b/Task/Determine-if-a-string-is-collapsible/Rust/determine-if-a-string-is-collapsible.rust similarity index 100% rename from Task/Determine-if-a-string-is-collapsible/Rust/determine-if-a-string-is-collapsible.rs rename to Task/Determine-if-a-string-is-collapsible/Rust/determine-if-a-string-is-collapsible.rust diff --git a/Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua b/Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua deleted file mode 100644 index 0e22615904..0000000000 --- a/Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua +++ /dev/null @@ -1,13 +0,0 @@ -S ← {"" - "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln" - "..1111111111111111111111111111111111111111111111111111111111111117777888" - "I never give 'em hell, I just tell the truth, and they think it's hell. " - " --- Harry S Truman " - "The better the 4-wheel drive, the further you'll be from help when ya get stuck!" - "headmistressship" - "aardvark" - "😍😀🙌💃😍😍😍🙌" - "unnecessary bookkeeping"} - -Collapse ← ⊜⊢+1⊸⊛ -≡◇∩(&p$"_ chars \t«_»\n"⊸⧻)⊸≡⍚Collapse S diff --git a/Task/Determine-if-a-string-is-collapsible/V-(Vlang)/determine-if-a-string-is-collapsible.v b/Task/Determine-if-a-string-is-collapsible/V-(Vlang)/determine-if-a-string-is-collapsible.v index 3d851084cd..7a801cef9d 100644 --- a/Task/Determine-if-a-string-is-collapsible/V-(Vlang)/determine-if-a-string-is-collapsible.v +++ b/Task/Determine-if-a-string-is-collapsible/V-(Vlang)/determine-if-a-string-is-collapsible.v @@ -12,7 +12,7 @@ fn collapse(s string) (string, int, int) { if del == 0 { return s, le, le } - r = r[..le-del].clone() + r = r[..le-del] return r.string(), le, r.len } diff --git a/Task/Determine-if-a-string-is-collapsible/Wren/determine-if-a-string-is-collapsible.wren b/Task/Determine-if-a-string-is-collapsible/Wren/determine-if-a-string-is-collapsible.wren index 2f6cc3810d..48f952f789 100644 --- a/Task/Determine-if-a-string-is-collapsible/Wren/determine-if-a-string-is-collapsible.wren +++ b/Task/Determine-if-a-string-is-collapsible/Wren/determine-if-a-string-is-collapsible.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt // Returns collapsed string, original and new lengths in // unicode code points (not normalized). diff --git a/Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-1.adb b/Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-1.ada similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-1.adb rename to Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-1.ada diff --git a/Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-2.adb b/Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-2.ada similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-2.adb rename to Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-2.ada diff --git a/Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-3.adb b/Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-3.ada similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-3.adb rename to Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-3.ada diff --git a/Task/Determine-if-a-string-is-numeric/Arturo/determine-if-a-string-is-numeric.arturo b/Task/Determine-if-a-string-is-numeric/Arturo/determine-if-a-string-is-numeric.arturo index 609f2ddbd4..077d052065 100644 --- a/Task/Determine-if-a-string-is-numeric/Arturo/determine-if-a-string-is-numeric.arturo +++ b/Task/Determine-if-a-string-is-numeric/Arturo/determine-if-a-string-is-numeric.arturo @@ -2,6 +2,5 @@ print numeric? "hello world" print numeric? "1234" print numeric? "1234 hello world" print numeric? "12.34" -print numeric? "0x2bf" print numeric? "!#@$" -print numeric? "-15" +print numeric? "-1.23" diff --git a/Task/Determine-if-a-string-is-numeric/BQN/determine-if-a-string-is-numeric.bqn b/Task/Determine-if-a-string-is-numeric/BQN/determine-if-a-string-is-numeric.bqn deleted file mode 100644 index d73e79cf62..0000000000 --- a/Task/Determine-if-a-string-is-numeric/BQN/determine-if-a-string-is-numeric.bqn +++ /dev/null @@ -1 +0,0 @@ -IsNumeric ← 1∘•ParseFloat⎊0 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/C++/determine-if-a-string-is-numeric-1.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp index a04ab3c23d..dd177cb3ad 100644 --- a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp +++ b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp @@ -1,11 +1,28 @@ -#include -#include +#include // for istringstream -bool isNumeric(const char *s) { - if (s == nullptr || *s == '\0' || std::isspace(*s)) { - return false; - } - char *p; - std::strtod(s, &p); - return *p == '\0'; +using namespace std; + +bool isNumeric( const char* pszInput, int nNumberBase ) +{ + istringstream iss( pszInput ); + + if ( nNumberBase == 10 ) + { + double dTestSink; + iss >> dTestSink; + } + else if ( nNumberBase == 8 || nNumberBase == 16 ) + { + int nTestSink; + iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink; + } + else + return false; + + // was any input successfully consumed/converted? + if ( ! iss ) + return false; + + // was all the input successfully consumed/converted? + return ( iss.rdbuf()->in_avail() == 0 ); } diff --git a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp index dd177cb3ad..a10b821d80 100644 --- a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp +++ b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp @@ -1,28 +1,7 @@ -#include // for istringstream - -using namespace std; - bool isNumeric( const char* pszInput, int nNumberBase ) { - istringstream iss( pszInput ); + string base = "0123456789ABCDEF"; + string input = pszInput; - if ( nNumberBase == 10 ) - { - double dTestSink; - iss >> dTestSink; - } - else if ( nNumberBase == 8 || nNumberBase == 16 ) - { - int nTestSink; - iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink; - } - else - return false; - - // was any input successfully consumed/converted? - if ( ! iss ) - return false; - - // was all the input successfully consumed/converted? - return ( iss.rdbuf()->in_avail() == 0 ); + return (input.find_first_not_of(base.substr(0, nNumberBase)) == string::npos); } diff --git a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp index a10b821d80..94c934e8bc 100644 --- a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp +++ b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp @@ -1,7 +1,3 @@ -bool isNumeric( const char* pszInput, int nNumberBase ) -{ - string base = "0123456789ABCDEF"; - string input = pszInput; - - return (input.find_first_not_of(base.substr(0, nNumberBase)) == string::npos); +bool isNumeric(const std::string& input) { + return std::all_of(input.begin(), input.end(), ::isdigit); } diff --git a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-4.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-4.cpp deleted file mode 100644 index 94c934e8bc..0000000000 --- a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-4.cpp +++ /dev/null @@ -1,3 +0,0 @@ -bool isNumeric(const std::string& input) { - return std::all_of(input.begin(), input.end(), ::isdigit); -} diff --git a/Task/Determine-if-a-string-is-numeric/C/determine-if-a-string-is-numeric.c b/Task/Determine-if-a-string-is-numeric/C/determine-if-a-string-is-numeric.c index e734674506..7ec0b8449a 100644 --- a/Task/Determine-if-a-string-is-numeric/C/determine-if-a-string-is-numeric.c +++ b/Task/Determine-if-a-string-is-numeric/C/determine-if-a-string-is-numeric.c @@ -1,12 +1,10 @@ #include -#include #include - -bool isNumeric(const char *s) { - if (s == NULL || *s == '\0' || isspace(*s)) { - return false; - } - char *p; - strtod(s, &p); +int isNumeric (const char * s) +{ + if (s == NULL || *s == '\0' || isspace(*s)) + return 0; + char * p; + strtod (s, &p); return *p == '\0'; } diff --git a/Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-1.cob b/Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-1.cobol similarity index 100% rename from Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-1.cob rename to Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-1.cobol diff --git a/Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-2.cob b/Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-2.cobol similarity index 100% rename from Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-2.cob rename to Task/Determine-if-a-string-is-numeric/COBOL/determine-if-a-string-is-numeric-2.cobol diff --git a/Task/Determine-if-a-string-is-numeric/Crystal/determine-if-a-string-is-numeric.cr b/Task/Determine-if-a-string-is-numeric/Crystal/determine-if-a-string-is-numeric.cr deleted file mode 100644 index e91c3abd61..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Crystal/determine-if-a-string-is-numeric.cr +++ /dev/null @@ -1,3 +0,0 @@ -def numeric? (s) - s.to_f rescue false -end diff --git a/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.pas b/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.delphi similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.pas rename to Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.delphi diff --git a/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.pas b/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.delphi similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.pas rename to Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.delphi diff --git a/Task/Determine-if-a-string-is-numeric/DuckDB/determine-if-a-string-is-numeric.duckdb b/Task/Determine-if-a-string-is-numeric/DuckDB/determine-if-a-string-is-numeric.duckdb deleted file mode 100644 index 2e161e6b5a..0000000000 --- a/Task/Determine-if-a-string-is-numeric/DuckDB/determine-if-a-string-is-numeric.duckdb +++ /dev/null @@ -1,22 +0,0 @@ -CREATE OR REPLACE FUNCTION is_valid_number(s) AS - CASE - WHEN s IS NULL THEN false - WHEN try_cast(s AS DOUBLE) IS NOT NULL THEN true - ELSE false - END; - -# Illustration -select s, is_valid_number(s) from - (select unnest([ - '123.0', - '123.', - '-123', - '3.14159', - '1.2.3', - 'abc', - 'A440', - ' 12 ', - '0A', - '+1E10', - '1E-10' - ]) as s); diff --git a/Task/Determine-if-a-string-is-numeric/EMal/determine-if-a-string-is-numeric.emal b/Task/Determine-if-a-string-is-numeric/EMal/determine-if-a-string-is-numeric.emal index e50cc528a2..d17af67f34 100644 --- a/Task/Determine-if-a-string-is-numeric/EMal/determine-if-a-string-is-numeric.emal +++ b/Task/Determine-if-a-string-is-numeric/EMal/determine-if-a-string-is-numeric.emal @@ -1,4 +1,4 @@ -fun isNumeric ← logic by text value +fun isNumeric = logic by text value try ^|So funny: |a) we check if it's castable to a real @@ -12,15 +12,15 @@ fun isNumeric ← logic by text value return false end end -fun main ← int by List args - if args.length æ 1 +fun main = int by List args + if args.length == 1 writeLine(isNumeric(args[0])) else - writeLine("value".padEnd(8, " "), " ", "numeric") + writeLine("value".padEnd(8, " ") + " " + "numeric") for each text value in text["0o755", "thursday", "3.14", "0b1010", "-100", "0xff"] - writeLine(value.padEnd(8, " "), " ", isNumeric(value)) + writeLine(value.padEnd(8, " ") + " " + isNumeric(value)) end end - return Runtime.OK + return 0 end exit main(Runtime.args) diff --git a/Task/Determine-if-a-string-is-numeric/EasyLang/determine-if-a-string-is-numeric.easy b/Task/Determine-if-a-string-is-numeric/EasyLang/determine-if-a-string-is-numeric.easy index d9e7726ea5..496213b521 100644 --- a/Task/Determine-if-a-string-is-numeric/EasyLang/determine-if-a-string-is-numeric.easy +++ b/Task/Determine-if-a-string-is-numeric/EasyLang/determine-if-a-string-is-numeric.easy @@ -1,13 +1,14 @@ -func is_numeric a$ . - h = number a$ - # because every variable must be used - h = h - return 1 - error +proc is_numeric a$ . r . + h = number a$ + r = 1 - error + # because every variable must be used + h = h . for s$ in [ "abc" "21a" "1234" "-13" "7.65" ] - if is_numeric s$ = 1 - print s$ & " is numeric" - else - print s$ & " is not numeric" - . + call is_numeric s$ r + if r = 1 + print s$ & " is numeric" + else + print s$ & " is not numeric" + . . diff --git a/Task/Determine-if-a-string-is-numeric/Ed/determine-if-a-string-is-numeric.ed b/Task/Determine-if-a-string-is-numeric/Ed/determine-if-a-string-is-numeric.ed deleted file mode 100644 index 0e7048c89e..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Ed/determine-if-a-string-is-numeric.ed +++ /dev/null @@ -1,5 +0,0 @@ -H -g/^([-+]?[0-9]*)(\.[0-9]+([eE][+-]?[0-9]+)?)?$/s//\1\2 is numeric/ -v/numeric/s/.*/& is not numeric/ -,p -Q diff --git a/Task/Determine-if-a-string-is-numeric/Elixir/determine-if-a-string-is-numeric.ex b/Task/Determine-if-a-string-is-numeric/Elixir/determine-if-a-string-is-numeric.elixir similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Elixir/determine-if-a-string-is-numeric.ex rename to Task/Determine-if-a-string-is-numeric/Elixir/determine-if-a-string-is-numeric.elixir diff --git a/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.el b/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.el deleted file mode 100644 index bb17cf908b..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.el +++ /dev/null @@ -1,12 +0,0 @@ -(defun string-valid-number-p (str) - "Test if STR is a numeric string. -Eliminate strings with commas in them because ELisp numbers do -not contain commas. Then check if remaining strings would be -valid ELisp numbers if the quotation marks were removed." - (and - ;; no comma in string, because ELisp numbers do not have commas - ;; we need to eliminate any string with a comma, because the - ;; numberp function below will not weed out commas - (not (string-match-p "," str)) - ;; no errors from numberp function testing if a number - (ignore-errors (numberp (read str))))) diff --git a/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.el b/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.el deleted file mode 100644 index ab8b39e2d0..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.el +++ /dev/null @@ -1,17 +0,0 @@ -(setq valid-strings '("3" "0" "-0" "2." "1000" "-4" "-5." "6.2" "-8.45" "+15e2" "-15e2" "#b101100" "#o54" "#x2c" "1500.0" "#24r1k" "3")) - -(setq invalid-strings '("3cat" "1,000" "5.6.7" "cat3" "def" "zero")) - -(with-current-buffer (pop-to-buffer "my-test") - (erase-buffer) - (insert "Test for valid strings:\n") - (dolist (test-string valid-strings) - (let ((test-result)) - (setq test-result (string-valid-number-p test-string)) - (insert (format "%-8s - %s \n" test-string test-result)))) - (insert "\n" "\n") - (insert "Test for invalid strings:\n") - (dolist (test-string invalid-strings) - (let ((test-result)) - (setq test-result (string-valid-number-p test-string)) - (insert (format "%-5s - %s \n" test-string test-result))))) diff --git a/Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.eu b/Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.euphoria similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.eu rename to Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.euphoria diff --git a/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric-2.fantom b/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric-2.fantom deleted file mode 100644 index fe5c2a26dc..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric-2.fantom +++ /dev/null @@ -1,18 +0,0 @@ -/* gary chike 08/27/2023 */ - -class Main { - static Void main() { - inputs := ["152\n", "-3.141", "Foo123", "-0", "456bar", "1.0E10"] - - inputs.each |Str input| { echo("$input.trim \tis " + (isNumeric(input) ? "numeric" : "not numeric"))} - - static Bool isNumeric(Str input) { - try { - input.toFloat - return true - } - catch(Err e) { - return false - } - } -} diff --git a/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric-1.fantom b/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric.fantom similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric-1.fantom rename to Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric.fantom diff --git a/Task/Determine-if-a-string-is-numeric/Free-Pascal-Lazarus/determine-if-a-string-is-numeric-2.pas b/Task/Determine-if-a-string-is-numeric/Free-Pascal-Lazarus/determine-if-a-string-is-numeric-2.pas deleted file mode 100644 index 63993e644e..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Free-Pascal-Lazarus/determine-if-a-string-is-numeric-2.pas +++ /dev/null @@ -1,35 +0,0 @@ -program IsNumeric; - -type - TDynamicArrayItem = record - StrValue: string; - end; - -var - myDynamicArray: array of TDynamicArrayItem; - i: Integer; - Value: Extended; - Code: Integer; - -begin - // Initialize the dynamic array with different data types - SetLength(myDynamicArray, 7); - myDynamicArray[0].StrValue := 'Hello'; - myDynamicArray[1].StrValue := '42'; - myDynamicArray[2].StrValue := '3.14159'; - myDynamicArray[3].StrValue := 'World'; - myDynamicArray[4].StrValue := '99'; - myDynamicArray[5].StrValue := '0777'; // Octal representation for 511 - myDynamicArray[6].StrValue := '$A1'; // Hexadecimal representation for 161 - - // Iterate through the dynamic array and determine data type - for i := Low(myDynamicArray) to High(myDynamicArray) do - begin - Val(myDynamicArray[i].StrValue, Value, Code); - if Code = 0 then // The value 0 for Code indicates that the conversion was successful. - Writeln('Element ', i, ': Numeric Value ', Chr(9),' - ', Value) // Chr(9) = tab - else - Writeln('Element ', i, ': Non-Numeric Value ', Chr(9), ' - ', myDynamicArray[i].StrValue); - end; -end. -{ Val converts the value represented in the string 'StrValue' to a numerical value or an enumerated value, and stores this value in the variable 'Value', which can be of type Longint, Real and Byte or any enumerated type. If the conversion isn't successful, then the parameter 'Code' contains the index of the character in 'StrValue' which prevented the conversion. } diff --git a/Task/Determine-if-a-string-is-numeric/Free-Pascal-Lazarus/determine-if-a-string-is-numeric-1.pas b/Task/Determine-if-a-string-is-numeric/Free-Pascal/determine-if-a-string-is-numeric.pas similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Free-Pascal-Lazarus/determine-if-a-string-is-numeric-1.pas rename to Task/Determine-if-a-string-is-numeric/Free-Pascal/determine-if-a-string-is-numeric.pas diff --git a/Task/Determine-if-a-string-is-numeric/Gleam/determine-if-a-string-is-numeric.gleam b/Task/Determine-if-a-string-is-numeric/Gleam/determine-if-a-string-is-numeric.gleam deleted file mode 100644 index 54663a07c7..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Gleam/determine-if-a-string-is-numeric.gleam +++ /dev/null @@ -1,9 +0,0 @@ -import gleam/int -import gleam/io - -pub fn main() { - case int.base_parse("1234", 10) { - Ok(_) -> io.println("String is numeric") - Error(_) -> io.println("String isn't numeric") - } -} diff --git a/Task/Determine-if-a-string-is-numeric/Haxe/determine-if-a-string-is-numeric.hx b/Task/Determine-if-a-string-is-numeric/Haxe/determine-if-a-string-is-numeric.haxe similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Haxe/determine-if-a-string-is-numeric.hx rename to Task/Determine-if-a-string-is-numeric/Haxe/determine-if-a-string-is-numeric.haxe diff --git a/Task/Determine-if-a-string-is-numeric/Insitux/determine-if-a-string-is-numeric.insitux b/Task/Determine-if-a-string-is-numeric/Insitux/determine-if-a-string-is-numeric.insitux deleted file mode 100644 index 5fa6108cc6..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Insitux/determine-if-a-string-is-numeric.insitux +++ /dev/null @@ -1,17 +0,0 @@ -> (var numeric? (comp to-num bool)) -(comp to-num bool) - -> (numeric? "123") -true - -> (numeric? "0x25") -true - -> (numeric? "0b0101") -true - -> (numeric? "hello") -false - -> (numeric? "123x456") -false diff --git a/Task/Determine-if-a-string-is-numeric/Julia/determine-if-a-string-is-numeric.jl b/Task/Determine-if-a-string-is-numeric/Julia/determine-if-a-string-is-numeric.julia similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Julia/determine-if-a-string-is-numeric.jl rename to Task/Determine-if-a-string-is-numeric/Julia/determine-if-a-string-is-numeric.julia diff --git a/Task/Determine-if-a-string-is-numeric/Kotlin/determine-if-a-string-is-numeric.kts b/Task/Determine-if-a-string-is-numeric/Kotlin/determine-if-a-string-is-numeric.kotlin similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Kotlin/determine-if-a-string-is-numeric.kts rename to Task/Determine-if-a-string-is-numeric/Kotlin/determine-if-a-string-is-numeric.kotlin diff --git a/Task/Determine-if-a-string-is-numeric/Nom/determine-if-a-string-is-numeric.num b/Task/Determine-if-a-string-is-numeric/Nom/determine-if-a-string-is-numeric.num deleted file mode 100644 index 48b9bb8943..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Nom/determine-if-a-string-is-numeric.num +++ /dev/null @@ -1,67 +0,0 @@ -#* - -GRAMMAR OR PARSE TOKENS - int* - an unsigned integer - sint* - a +/- signed integer - .* - decimal point - -HISTORY - 12 sept 2021: written, working - -*# - - # remove leading space - begin { while [:space:]; clear; } - - read; - [0-9] { - while [0-9]; put; clear; add "int*"; push; .reparse - } - [.+-] { put; add "*"; push; .reparse } - [:space:] { while [:space:]; clear; add "space*"; push; .reparse } - !"" { - put; clear; - add "Non-numeric char at "; lines; add ":"; chars; add "\n"; - print; quit; - } - -parse> - # To visualise token reduction uncomment this: - #lines; add ":"; chars; add " "; print; clear; - #add "\n"; unstack; print; clip; stack; - - pop; pop; - - # ------------- - # 2 tokens - "+*int*","-*int*" { clear; add "sint*"; push; .reparse } - - pop; - # ------------- - # 3 tokens - "sint*.*int*","int*.*int*" { - clear; add "float*"; push; .reparse - } - - (eof) { - # ignore trailing space - stack; pop; "space*" { clear; } - unstack; - "int*","sint*","float*" { - replace "sint*" "signed integer,"; - replace "int*" "integer,"; - replace "*" ","; - put; clear; - add "It looks like a number (of type "; get; add ")\n"; - print; quit; - } - replace "sint*" "signed integer,"; - replace "int*" "integer,"; - replace "*" ","; - put; clear; - add "Doesnt look like one number \n"; - add "It was parsed as '"; get; add "'\n"; - print; quit; - } - - push; push; push; diff --git a/Task/Determine-if-a-string-is-numeric/Nu/determine-if-a-string-is-numeric.nu b/Task/Determine-if-a-string-is-numeric/Nu/determine-if-a-string-is-numeric.nu deleted file mode 100644 index 14761bdd6b..0000000000 --- a/Task/Determine-if-a-string-is-numeric/Nu/determine-if-a-string-is-numeric.nu +++ /dev/null @@ -1,3 +0,0 @@ -def is-numeric [] {try {into float | true} catch {false}} - -["1" "12" "-3" "5.6" "-3.14" "one" "cheese"] | each {{k: $in, v: ($in | is-numeric)}} diff --git a/Task/Determine-if-a-string-is-numeric/OCaml/determine-if-a-string-is-numeric.ml b/Task/Determine-if-a-string-is-numeric/OCaml/determine-if-a-string-is-numeric.ocaml similarity index 100% rename from Task/Determine-if-a-string-is-numeric/OCaml/determine-if-a-string-is-numeric.ml rename to Task/Determine-if-a-string-is-numeric/OCaml/determine-if-a-string-is-numeric.ocaml diff --git a/Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas b/Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas deleted file mode 100644 index 47846ad8c7..0000000000 --- a/Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas +++ /dev/null @@ -1,11 +0,0 @@ -function IsNumeric(s: string): boolean; -begin - var i: integer; - Result := integer.TryParse(s,i) -end; - -begin - var s := '123'; - if IsNumeric(s) then - Print('string is numeric') -end. diff --git a/Task/Determine-if-a-string-is-numeric/Phix/determine-if-a-string-is-numeric.phix b/Task/Determine-if-a-string-is-numeric/Phix/determine-if-a-string-is-numeric.phix index 2b915eacc9..76861c1f74 100644 --- a/Task/Determine-if-a-string-is-numeric/Phix/determine-if-a-string-is-numeric.phix +++ b/Task/Determine-if-a-string-is-numeric/Phix/determine-if-a-string-is-numeric.phix @@ -1,32 +1,34 @@ -function isNumber(string s) - return scanf(s,"%f")!={} --- Alt: isNumberString(object s) and --- return string(s) and scanf(s,"%f")!={}, or even --- return string(s) and scanf(substitute(trim(s),",",""),"%f")!={} -end function +(phixonline)--> + function isNumber(string s) + return scanf(s,"%f")!={} + -- Alt: isNumberString(object s) and + -- return string(s) and scanf(s,"%f")!={}, or even + -- return string(s) and scanf(substitute(trim(s),",",""),"%f")!={} + end function -constant tests = {"#a","#A","0xA","0(16)A","#FF","255","0", - "0.","0.0","000.000","0e0","0e-2000"," ", - ".14",".05","-5.2","0xf","ten","1B","#1B", - " 12 ",trim(" 12 "),"1","0o16","0o18", - "0b10101111_11110000_11110000_00110011", - "1_000","50e","+123","+ 123","-0b10101", - "NaN","+.345","12..34","12e3.4","0-2", - "192.168.0.1","1.2e","1 2","12.34","", - "beef","#beef","1,000,000","Inf","1/2", - "1.5e+27","0x10.5","1."} + constant tests = {"#a","#A","0xA","0(16)A","#FF","255","0", + "0.","0.0","000.000","0e0","0e-2000"," ", + ".14",".05","-5.2","0xf","ten","1B","#1B", + " 12 ",trim(" 12 "),"1","0o16","0o18", + "0b10101111_11110000_11110000_00110011", + "1_000","50e","+123","+ 123","-0b10101", + "NaN","+.345","12..34","12e3.4","0-2", + "192.168.0.1","1.2e","1 2","12.34","", + "beef","#beef","1,000,000","Inf","1/2", + "1.5e+27","0x10.5","1."} -sequence numeric = {}, - notnumb = {} -for i=1 to length(tests) do - string ti = tests[i] - if isNumber(ti) then - numeric = append(numeric,ti) - else - notnumb = append(notnumb,ti) - end if -end for -puts(1,"numeric: ") -pp(numeric,{pp_Indent,9}) -puts(1,"\nnot numeric: ") -pp(notnumb,{pp_Indent,13}) + sequence numeric = {}, + notnumb = {} + for i=1 to length(tests) do + string ti = tests[i] + if isNumber(ti) then + numeric = append(numeric,ti) + else + notnumb = append(notnumb,ti) + end if + end for + puts(1,"numeric: ") + pp(numeric,{pp_Indent,9}) + puts(1,"\nnot numeric: ") + pp(notnumb,{pp_Indent,13}) + n ) - -[ 4 pack 0 swap - ' [ roll dip roll > ] join - 10000 times - [ dup do swap dip + ] drop - say "0." echo cr ] is prob ( a b c d --> ) - -randomise -9 4 6 6 prob -5 10 6 7 prob diff --git a/Task/Dice-game-probabilities/Rust/dice-game-probabilities.rs b/Task/Dice-game-probabilities/Rust/dice-game-probabilities.rust similarity index 100% rename from Task/Dice-game-probabilities/Rust/dice-game-probabilities.rs rename to Task/Dice-game-probabilities/Rust/dice-game-probabilities.rust diff --git a/Task/Dice-game-probabilities/Sidef/dice-game-probabilities.sidef b/Task/Dice-game-probabilities/Sidef/dice-game-probabilities.sidef index 1065807331..59f888cbcb 100644 --- a/Task/Dice-game-probabilities/Sidef/dice-game-probabilities.sidef +++ b/Task/Dice-game-probabilities/Sidef/dice-game-probabilities.sidef @@ -11,9 +11,9 @@ func winning(sides1, n1, sides2, n2) { var (p1, p2) = (combos(sides1, n1), combos(sides2, n2)) var (win,loss,tie) = (0,0,0) p1.each_kv { |i, x| - win += x*p2.first(i).sum - tie += x*p2.slice(i).first(1).sum - loss += x*p2.slice(i+1).sum + win += x*p2.ft(0,i-1).sum + tie += x*p2.ft(i, i).sum + loss += x*p2.ft(i+1).sum } [win, tie, loss] »/» p1.sum*p2.sum } diff --git a/Task/Digital-root-Multiplicative-digital-root/Ada/digital-root-multiplicative-digital-root.adb b/Task/Digital-root-Multiplicative-digital-root/Ada/digital-root-multiplicative-digital-root.ada similarity index 100% rename from Task/Digital-root-Multiplicative-digital-root/Ada/digital-root-multiplicative-digital-root.adb rename to Task/Digital-root-Multiplicative-digital-root/Ada/digital-root-multiplicative-digital-root.ada diff --git a/Task/Digital-root-Multiplicative-digital-root/Crystal/digital-root-multiplicative-digital-root.cr b/Task/Digital-root-Multiplicative-digital-root/Crystal/digital-root-multiplicative-digital-root.cr deleted file mode 100644 index dac178580a..0000000000 --- a/Task/Digital-root-Multiplicative-digital-root/Crystal/digital-root-multiplicative-digital-root.cr +++ /dev/null @@ -1,33 +0,0 @@ -struct Int - def mdr - n, p = self, 0 - return {0, 0} unless n > 0 - while n >= 10 - n = n.digits.product - p += 1 - end - { n, p } - end -end - -puts <<-EOH - n MDR MP -------------- -EOH -[123321, 7739, 893, 899998].each do |n| - printf "%6d %d %d\n", n, *n.mdr -end -puts -puts <<-EOH -MDR: [n0..n4] -=== ======== -EOH -buckets = Array(Array(Int32)).new(10) { [] of Int32 } -(0..).each do |n| - mdr, _ = n.mdr - buckets[mdr] << n - break if buckets.all? {|b| b.size >= 5 } -end -buckets.each_with_index do |b, i| - printf "%3d: %s\n", i, b.first(5) -end diff --git a/Task/Digital-root-Multiplicative-digital-root/EasyLang/digital-root-multiplicative-digital-root.easy b/Task/Digital-root-Multiplicative-digital-root/EasyLang/digital-root-multiplicative-digital-root.easy deleted file mode 100644 index 1037d26810..0000000000 --- a/Task/Digital-root-Multiplicative-digital-root/EasyLang/digital-root-multiplicative-digital-root.easy +++ /dev/null @@ -1,45 +0,0 @@ -proc _mdr n &md &mp . - if n > 0 : r = 1 - while n > 0 - r *= n mod 10 - n = n div 10 - . - mp += 1 - if r >= 10 - _mdr r md mp - else - md = r - . -. -proc mdr n &md &mp . - mp = 0 - _mdr n md mp -. -numfmt 6 0 -print "Number MDR MP" -for v in [ 123321 7739 893 899998 ] - mdr v md mp - print v & md & mp -. -width = 5 -len table[] 10 * width -len tfill[] 10 -numfmt 0 0 -while total < 10 * width - mdr i md mp - if tfill[md] < width - table[md * width + tfill[md]] = i - tfill[md] += 1 - total += 1 - . - i += 1 -. -print "\nMDR: [n0..n4]" -for i = 0 to 9 - write i & ": [" - for j = 0 to width - 1 - write table[i * width + j] - if j < width - 1 : write "," - . - print "]" -. diff --git a/Task/Digital-root-Multiplicative-digital-root/Elixir/digital-root-multiplicative-digital-root.ex b/Task/Digital-root-Multiplicative-digital-root/Elixir/digital-root-multiplicative-digital-root.elixir similarity index 100% rename from Task/Digital-root-Multiplicative-digital-root/Elixir/digital-root-multiplicative-digital-root.ex rename to Task/Digital-root-Multiplicative-digital-root/Elixir/digital-root-multiplicative-digital-root.elixir diff --git a/Task/Digital-root-Multiplicative-digital-root/Free-Pascal-Lazarus/digital-root-multiplicative-digital-root.pas b/Task/Digital-root-Multiplicative-digital-root/Free-Pascal/digital-root-multiplicative-digital-root.pas similarity index 100% rename from Task/Digital-root-Multiplicative-digital-root/Free-Pascal-Lazarus/digital-root-multiplicative-digital-root.pas rename to Task/Digital-root-Multiplicative-digital-root/Free-Pascal/digital-root-multiplicative-digital-root.pas diff --git a/Task/Digital-root-Multiplicative-digital-root/JavaScript/digital-root-multiplicative-digital-root.js b/Task/Digital-root-Multiplicative-digital-root/JavaScript/digital-root-multiplicative-digital-root.js deleted file mode 100644 index fb6df86d65..0000000000 --- a/Task/Digital-root-Multiplicative-digital-root/JavaScript/digital-root-multiplicative-digital-root.js +++ /dev/null @@ -1,31 +0,0 @@ -function digmul(n) { - return [...String(n)].reduce((x, y) => Number(x) * Number(y)); -} - -function mdr_mp(n) { - let m = n, i = 0; - while (m > 9) { - m = digmul(m); - i++; - } - return {"MDR": m, "MP": i}; -} - -for (const n of [123321, 7739, 893, 899998]) { - console.log(`${n} has MDR ${mdr_mp(n)["MDR"]} and MP ${mdr_mp(n)["MP"]}`); -} - -function first5mdr(n) { - let m = 0, nums = []; - while (nums.length < 5) { - if (mdr_mp(m)["MDR"] == n) { - nums.push(m); - } - m++; - } - return `First 5 numbers with MDR ${n}: ${nums.join(", ")}`; -} - -for (let i = 0; i < 10; i++) { - console.log(first5mdr(i)); -} diff --git a/Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-1.jl b/Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-1.julia similarity index 100% rename from Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-1.jl rename to Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-1.julia diff --git a/Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-2.jl b/Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-2.julia similarity index 100% rename from Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-2.jl rename to Task/Digital-root-Multiplicative-digital-root/Julia/digital-root-multiplicative-digital-root-2.julia diff --git a/Task/Digital-root-Multiplicative-digital-root/Kotlin/digital-root-multiplicative-digital-root.kts b/Task/Digital-root-Multiplicative-digital-root/Kotlin/digital-root-multiplicative-digital-root.kotlin similarity index 100% rename from Task/Digital-root-Multiplicative-digital-root/Kotlin/digital-root-multiplicative-digital-root.kts rename to Task/Digital-root-Multiplicative-digital-root/Kotlin/digital-root-multiplicative-digital-root.kotlin diff --git a/Task/Digital-root-Multiplicative-digital-root/PascalABC.NET/digital-root-multiplicative-digital-root.pas b/Task/Digital-root-Multiplicative-digital-root/PascalABC.NET/digital-root-multiplicative-digital-root.pas deleted file mode 100644 index dfe2204da1..0000000000 --- a/Task/Digital-root-Multiplicative-digital-root/PascalABC.NET/digital-root-multiplicative-digital-root.pas +++ /dev/null @@ -1,33 +0,0 @@ -## -function MulDigitalRoot(num: int64): (integer, integer); -begin - var mulpersistence := 0; - while num > 9 do - begin - num := num.ToString.ToCharArray.Select(x -> x.ToDigit).Aggregate((x, y) -> x * y); - mulpersistence += 1; - end; - result := (mulpersistence, integer(num)); -end; - -var nums := |123321, 7739, 893, 899998|; -foreach var num in nums do -begin - var t := MulDigitalRoot(num); - Writeln(num, ' has multiplicative persistence ', t[0], ' and multiplicative digital root ', t[1]) -end; - -var twidth := 5; -var table := new List[10]; -for var i := 0 to 9 do - table[i] := new List(); -var number := -1; -while (table.Any(x -> x.Count < twidth)) do -begin - number += 1; - var t := MulDigitalRoot(number); - if (table[t[1]].Count < twidth) then - table[t[1]].Add(number); -end; -for var i := 0 to 9 do - WriteLn(i, ' : [', string.Join(', ', table[i]), ']'); diff --git a/Task/Digital-root-Multiplicative-digital-root/Phix/digital-root-multiplicative-digital-root-1.phix b/Task/Digital-root-Multiplicative-digital-root/Phix/digital-root-multiplicative-digital-root-1.phix index 16ee10b968..cc996c596b 100644 --- a/Task/Digital-root-Multiplicative-digital-root/Phix/digital-root-multiplicative-digital-root-1.phix +++ b/Task/Digital-root-Multiplicative-digital-root/Phix/digital-root-multiplicative-digital-root-1.phix @@ -1,44 +1,46 @@ -with javascript_semantics -function mdr_mp(integer m) - integer mp = 0 - while m>9 do - integer newm = 1 - while m do - newm *= remainder(m,10) - m = floor(m/10) - end while - m = newm - mp += 1 - end while - return {m,mp} -end function +(phixonline)--> + with javascript_semantics + function mdr_mp(integer m) + integer mp = 0 + while m>9 do + integer newm = 1 + while m do + newm *= remainder(m,10) + m = floor(m/10) + end while + m = newm + mp += 1 + end while + return {m,mp} + end function -constant tests = {123321, 7739, 893, 899998} -printf(1,"Number MDR MP\n") -printf(1,"====== === ==\n") -for i=1 to length(tests) do - integer ti = tests[i] - printf(1,"%6d %6d %6d\n",ti&mdr_mp(ti)) -end for + constant tests = {123321, 7739, 893, 899998} + printf(1,"Number MDR MP\n") + printf(1,"====== === ==\n") + for i=1 to length(tests) do + integer ti = tests[i] + printf(1,"%6d %6d %6d\n",ti&mdr_mp(ti)) + end for -integer i=0, found = 0 -sequence res = columnize({tagset(9,0)}) - -- (ie {{0},{1},..,{9}}) -while found<50 do -- (ie the full 10*5) - integer mdr1 = mdr_mp(i)[1]+1 - sequence m1 = res[mdr1] - if length(m1)<6 then - res[mdr1] = 0 -- (avoid p2js violation) - m1 &= i - res[mdr1] = m1 - found += 1 - end if - i += 1 -end while + integer i=0, found = 0 + sequence res = columnize({tagset(9,0)}) + -- (ie {{0},{1},..,{9}}) + while found<50 do -- (ie the full 10*5) + integer mdr1 = mdr_mp(i)[1]+1 + sequence m1 = res[mdr1] + if length(m1)<6 then + res[mdr1] = 0 -- (avoid p2js violation) + m1 &= i + res[mdr1] = m1 + found += 1 + end if + i += 1 + end while -printf(1,"\nMDR 1 2 3 4 5") -printf(1,"\n=== ===========================\n") + printf(1,"\nMDR 1 2 3 4 5") + printf(1,"\n=== ===========================\n") -for i=1 to 10 do - printf(1,"%2d %5d %5d %5d %5d %5d\n",res[i]) -end for + for i=1 to 10 do + printf(1,"%2d %5d %5d %5d %5d %5d\n",res[i]) + end for + + with javascript_semantics + function pdd(integer n) return sprintf("%2d",product(sq_sub(sprint(n),'0'))) end function + printf(1,"Product of the decimal digits of 1..100:\n%s\n", {join_by(apply(tagset(100),pdd),1,10)}) + s ) - - [ temp share 0 peek ] is baker ( --> n ) - [ temp share 1 peek ] is cooper ( --> n ) - [ temp share 2 peek ] is fletcher ( --> n ) - [ temp share 3 peek ] is miller ( --> n ) - [ temp share 4 peek ] is smith ( --> n ) - - [ temp share size = ] is top ( n --> b ) - [ 1 = ] is bottom ( n --> b ) - [ > ] is higher ( n n --> b ) - [ - abs 1 = ] is adjacent ( n n --> b ) - - [ if ]done[ ] is exclude ( b --> ) - [ not if ]done[ ] is require ( b --> ) - [ temp share nested join ] is include ( [ --> [ ) - - [ ]'[ ' include join - problem put - [] - ' [ 1 2 3 4 5 ] - permutations - witheach - [ temp put - problem share do - temp release ] - problem release - say " B C F M S" cr - witheach [ echo cr ] ] is solve ( --> ) - - solve - [ baker top exclude - cooper bottom exclude - fletcher top - fletcher bottom or exclude - miller cooper higher require - smith fletcher adjacent exclude - fletcher cooper adjacent exclude ] diff --git a/Task/Dinesmans-multiple-dwelling-problem/Rust/dinesmans-multiple-dwelling-problem.rs b/Task/Dinesmans-multiple-dwelling-problem/Rust/dinesmans-multiple-dwelling-problem.rs deleted file mode 100644 index 5c5d526d93..0000000000 --- a/Task/Dinesmans-multiple-dwelling-problem/Rust/dinesmans-multiple-dwelling-problem.rs +++ /dev/null @@ -1,18 +0,0 @@ -use itertools::Itertools; - - -fn main() { - for p in (1..6).permutations(5) { - let baker: i32 = p[0]; - let cooper: i32 = p[1]; - let fletcher: i32 = p[2]; - let miller: i32 = p[3]; - let smith: i32 = p[4]; - if baker != 5 && cooper != 1 && fletcher != 1 && fletcher != 5 && cooper < miller && - (smith - fletcher).abs() > 1 && (cooper - fletcher).abs() > 1 { - print!("Baker on {baker}, Cooper on {cooper}, "); - println!("Fletcher on {fletcher}, Miller on {miller}, Smith on {smith}."); - break; - } - } -} diff --git a/Task/Dinesmans-multiple-dwelling-problem/Sidef/dinesmans-multiple-dwelling-problem-1.sidef b/Task/Dinesmans-multiple-dwelling-problem/Sidef/dinesmans-multiple-dwelling-problem-1.sidef index bca86e7d61..e17edbb94c 100644 --- a/Task/Dinesmans-multiple-dwelling-problem/Sidef/dinesmans-multiple-dwelling-problem-1.sidef +++ b/Task/Dinesmans-multiple-dwelling-problem/Sidef/dinesmans-multiple-dwelling-problem-1.sidef @@ -9,7 +9,7 @@ func dinesman(problem) { var re_keywords = Regex(words.join('|'))   # Build an array of lambda's - var predicates = lines.first(-1).last(-1).map{ |line| + var predicates = lines.ft(1, lines.end-1).map{ |line| var keywords = line.scan(re_keywords) var (name1, name2) = line.scan(re_names)...   diff --git a/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-2.tailspin b/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-2.tailspin index 0fe1190c3f..e4eaad513f 100644 --- a/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-2.tailspin +++ b/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-2.tailspin @@ -1,29 +1,24 @@ -permutations templates - when <|=1> do [1] ! - otherwise - n is $; - expand templates - p is $; - 1..$n -> templates - k is $; - [$p(..$k - 1)..., $n, $p($k..)...] ! - end ! - end expand - $n - 1 -> # -> expand ! -end permutations +// We add a zero to be able to express e.g. "not top floor" +def floors: [0..5 -> (floor:$)]; +def names: [['Ground', 'Baker', 'Cooper', 'Fletcher', 'Miller', 'Smith']... -> (name:$)]; -names is ['Baker', 'Cooper', 'Fletcher', 'Miller', 'Smith']; +def dwellings: [$floors, $names] -> \( + def solver: $ -> EinsteinSolver; -5 -> permutations -> $names($) - -> if <|?($(.. as i; -> if <|='Baker'> -> $i)... matches <~|=5>)> - -> if <|?($(.. as i; -> if <|='Cooper'> -> $i)... matches <~|=1>)> - -> if <|?($(.. as i; -> if <|='Fletcher'> -> $i)... matches <~|=1|=5>)> - -> templates - miller is $(.. as i; -> if <|='Miller'> -> $i)...; - $ -> if <|?($(.. as i; -> if <|='Cooper'> -> $i)... matches <|..$miller>)> ! - end - -> if <|?(($(.. as i; -> if <|='Smith'> -> $i)...) - ($(.. as i; -> if <|='Fletcher'> -> $i)...) matches <~|=1|=-1>)> - -> if <|?(($(.. as i; -> if <|='Cooper'> -> $i)...) - ($(.. as i; -> if <|='Fletcher'> -> $i)...) matches <~|=1|=-1>)> - -> $(.. as i; -> '$i;:$;$#10;') - -> $(..:-1) - -> '$...;$#10;' ! + {name: 'Ground', floor: 0} -> !solver::isFact + ({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Baker'}) -> !VOID + ({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..5]} {name: 'Cooper'}) -> !VOID + ({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..4]} {name: 'Fletcher'}) -> !VOID + ({name: 'Cooper'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Miller'}) -> !VOID + ({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Smith'}) -> !VOID + ({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Cooper'}) -> !VOID + + [$solver::solutions&{required: 6} ... -> ($ notMatching {| {name: 'Ground'} |})]! +\); + +$dwellings -> \[i]('Solution $i;: +$... -> '$; +'; +'! \)... -> !OUT::write +'No more solutions +' -> !OUT::write diff --git a/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-3.tailspin b/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-3.tailspin deleted file mode 100644 index e4eaad513f..0000000000 --- a/Task/Dinesmans-multiple-dwelling-problem/Tailspin/dinesmans-multiple-dwelling-problem-3.tailspin +++ /dev/null @@ -1,24 +0,0 @@ -// We add a zero to be able to express e.g. "not top floor" -def floors: [0..5 -> (floor:$)]; -def names: [['Ground', 'Baker', 'Cooper', 'Fletcher', 'Miller', 'Smith']... -> (name:$)]; - -def dwellings: [$floors, $names] -> \( - def solver: $ -> EinsteinSolver; - - {name: 'Ground', floor: 0} -> !solver::isFact - ({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Baker'}) -> !VOID - ({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..5]} {name: 'Cooper'}) -> !VOID - ({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..4]} {name: 'Fletcher'}) -> !VOID - ({name: 'Cooper'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Miller'}) -> !VOID - ({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Smith'}) -> !VOID - ({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Cooper'}) -> !VOID - - [$solver::solutions&{required: 6} ... -> ($ notMatching {| {name: 'Ground'} |})]! -\); - -$dwellings -> \[i]('Solution $i;: -$... -> '$; -'; -'! \)... -> !OUT::write -'No more solutions -' -> !OUT::write diff --git a/Task/Dinesmans-multiple-dwelling-problem/True-BASIC/dinesmans-multiple-dwelling-problem.basic b/Task/Dinesmans-multiple-dwelling-problem/True-BASIC/dinesmans-multiple-dwelling-problem.basic deleted file mode 100644 index a0579a9411..0000000000 --- a/Task/Dinesmans-multiple-dwelling-problem/True-BASIC/dinesmans-multiple-dwelling-problem.basic +++ /dev/null @@ -1,31 +0,0 @@ -PRINT "Los apartamentos están numerados del 0 (bajo) al 4 (ático)." -PRINT "Baker, Cooper, Fletcher, Miller y Smith viven en apartamentos diferentes." -PRINT "- Baker no vive en el último apartamento (ático)." -PRINT "- Cooper no vive en el piso inferior (bajo)." -PRINT "- Fletcher no vive ni en el ático ni en el bajo." -PRINT "- Miller vive en un apartamento más alto que Cooper." -PRINT "- Smith no vive en un apartamento adyacente al de Fletcher." -PRINT "- Fletcher no vive en un apartamento adyacente al de Cooper." -PRINT -FOR baker = 0 TO 3 - FOR cooper = 1 TO 4 - FOR fletcher = 1 TO 3 - FOR miller = 0 TO 4 - FOR smith = 0 TO 4 - IF baker <> cooper AND baker <> fletcher AND baker <> miller AND baker <> smith AND cooper <> fletcher THEN - IF cooper <> miller AND cooper <> smith AND fletcher <> miller AND fletcher <> smith AND miller <> smith THEN - IF miller > cooper AND ABS(smith - fletcher) <> 1 AND ABS(fletcher - cooper) <> 1 THEN - PRINT "Baker vive en el piso "; baker - PRINT "Cooper vive en el piso "; cooper - PRINT "Fletcher vive en el piso "; fletcher - PRINT "Miller vive en el piso "; miller - PRINT "Smith vive en el piso "; smith - END IF - END IF - END IF - NEXT smith - NEXT miller - NEXT fletcher - NEXT cooper -NEXT baker -END diff --git a/Task/Dinesmans-multiple-dwelling-problem/Wren/dinesmans-multiple-dwelling-problem.wren b/Task/Dinesmans-multiple-dwelling-problem/Wren/dinesmans-multiple-dwelling-problem.wren index 84737995c8..ad2e7f8688 100644 --- a/Task/Dinesmans-multiple-dwelling-problem/Wren/dinesmans-multiple-dwelling-problem.wren +++ b/Task/Dinesmans-multiple-dwelling-problem/Wren/dinesmans-multiple-dwelling-problem.wren @@ -1,4 +1,4 @@ -import "./seq" for Lst +import "/seq" for Lst var permute // recursive permute = Fn.new { |input| diff --git a/Task/Dining-philosophers/Ada/dining-philosophers-1.adb b/Task/Dining-philosophers/Ada/dining-philosophers-1.ada similarity index 100% rename from Task/Dining-philosophers/Ada/dining-philosophers-1.adb rename to Task/Dining-philosophers/Ada/dining-philosophers-1.ada diff --git a/Task/Dining-philosophers/Ada/dining-philosophers-2.adb b/Task/Dining-philosophers/Ada/dining-philosophers-2.ada similarity index 100% rename from Task/Dining-philosophers/Ada/dining-philosophers-2.adb rename to Task/Dining-philosophers/Ada/dining-philosophers-2.ada diff --git a/Task/Dining-philosophers/Ada/dining-philosophers-3.adb b/Task/Dining-philosophers/Ada/dining-philosophers-3.ada similarity index 100% rename from Task/Dining-philosophers/Ada/dining-philosophers-3.adb rename to Task/Dining-philosophers/Ada/dining-philosophers-3.ada diff --git a/Task/Dining-philosophers/Delphi/dining-philosophers.pas b/Task/Dining-philosophers/Delphi/dining-philosophers.delphi similarity index 100% rename from Task/Dining-philosophers/Delphi/dining-philosophers.pas rename to Task/Dining-philosophers/Delphi/dining-philosophers.delphi diff --git a/Task/Dining-philosophers/Elixir/dining-philosophers.ex b/Task/Dining-philosophers/Elixir/dining-philosophers.elixir similarity index 100% rename from Task/Dining-philosophers/Elixir/dining-philosophers.ex rename to Task/Dining-philosophers/Elixir/dining-philosophers.elixir diff --git a/Task/Dining-philosophers/Euphoria/dining-philosophers.eu b/Task/Dining-philosophers/Euphoria/dining-philosophers.euphoria similarity index 100% rename from Task/Dining-philosophers/Euphoria/dining-philosophers.eu rename to Task/Dining-philosophers/Euphoria/dining-philosophers.euphoria diff --git a/Task/Dining-philosophers/Fortran/dining-philosophers.f b/Task/Dining-philosophers/Fortran/dining-philosophers.f deleted file mode 100644 index 25b8a072a6..0000000000 --- a/Task/Dining-philosophers/Fortran/dining-philosophers.f +++ /dev/null @@ -1,86 +0,0 @@ -!Deadlock prevented by making one philosopher "left-handed" -!and making orderly use of omp locks which protect forks by ensuring that only one philosopher can use each fork at a time - program dining_philosophers - use omp_lib - implicit none - - integer, parameter :: N = 5 - integer(omp_lock_kind) :: forks(N) - character(len=20), dimension(N) :: names = [character(len=20) :: & - "Aristotle", "Kant", "Spinoza", "Marx", "Russell"] - integer :: i - integer :: next_thread = 0 ! Shared sequencing variable - - ! Initialize forks (mutexes) - do i = 1, N - call omp_init_lock(forks(i)) - end do - - ! Parallel region with N threads - !$omp parallel num_threads(N) private(i) shared(next_thread, forks, names) - i = omp_get_thread_num() + 1 ! Philosopher IDs: 1 to N - call philosopher(i, next_thread, forks, names) - !$omp end parallel - - ! Destroy locks - do i = 1, N - call omp_destroy_lock(forks(i)) - end do - -contains - - subroutine philosopher(id, next_thread, forks, names) - integer, intent(in) :: id - integer, intent(inout) :: next_thread - integer(omp_lock_kind), intent(inout) :: forks(:) - character(len=20), intent(in) :: names(:) - integer :: left, right, meals - - left = id - right = mod(id, size(forks)) + 1 ! Wrap around for right fork - !$omp barrier - ! Wait for turn to start - do while (id - 1 /= next_thread) - !$omp flush(next_thread) - end do - - print *, trim(names(id)), " sits down at the table." - - !$omp atomic - next_thread = next_thread + 1 - !$omp flush(next_thread) - - ! Philosopher's meal loop - do meals = 1, 20 -! print *, trim(names(id)), " is thinking." -! call sleep(1) - - ! Asymmetric fork acquisition to prevent deadlock - if (id < size(forks)) then - call omp_set_lock(forks(left)) - print *, trim(names(id)), " picked up left fork ", left - call omp_set_lock(forks(right)) - print *, trim(names(id)), " picked up right fork ", right - else - call omp_set_lock(forks(right)) - print *, trim(names(id)), " picked up right fork ", right - call omp_set_lock(forks(left)) - print *, trim(names(id)), " picked up left fork ", left - end if - - print *, trim(names(id)), " is eating." - call sleep(1) - - call omp_unset_lock(forks(left)) - call omp_unset_lock(forks(right)) - print *, trim(names(id)), " put down forks." - print *, trim(names(id)), " is thinking." - call sleep(1) - print *, trim(names(id)), " returns to the table." - - end do - - print *, trim(names(id)), " leaves the table." - end subroutine philosopher - -end program dining_philosophers diff --git a/Task/Dining-philosophers/FreeBASIC/dining-philosophers.basic b/Task/Dining-philosophers/FreeBASIC/dining-philosophers.basic deleted file mode 100644 index 4909077304..0000000000 --- a/Task/Dining-philosophers/FreeBASIC/dining-philosophers.basic +++ /dev/null @@ -1,108 +0,0 @@ -Const NUM_PHILOSOPHERS = 5 -Const HUNGER = 3 -Const THINK_TIME = 1000 -Const EAT_TIME = 1000 - -Type Fork - mutex As Any Ptr - available As Boolean -End Type - -Type Philosopher - nombre As String - leftFork As Fork Ptr - rightFork As Fork Ptr - hunger As Integer -End Type - -Dim Shared As Philosopher philosophers(NUM_PHILOSOPHERS-1) -Dim Shared As Fork forks(NUM_PHILOSOPHERS-1) -Dim Shared As Any Ptr printMutex - -Function threadSafePrint(text As String) As Integer - Mutexlock(printMutex) - Print text - Mutexunlock(printMutex) - Return 0 -End Function - -Sub delay(ms As Integer) - Dim As Double t = Timer - While (Timer - t) * 1000 < ms - Sleep 1, 1 - Wend -End Sub - -Function philosopherThread(param As Any Ptr) As Any Ptr - Dim As Philosopher Ptr phil = param - - threadSafePrint(phil->nombre + " seated") - - While phil->hunger > 0 - threadSafePrint(phil->nombre + " hungry") - - Mutexlock(phil->leftFork->mutex) - Mutexlock(phil->rightFork->mutex) - - threadSafePrint(phil->nombre + " eating") - delay(EAT_TIME) - - Mutexunlock(phil->leftFork->mutex) - Mutexunlock(phil->rightFork->mutex) - - threadSafePrint(phil->nombre + " thinking") - delay(THINK_TIME) - - phil->hunger -= 1 - Wend - - threadSafePrint(phil->nombre + " satisfied") - threadSafePrint(phil->nombre + " left the table") - - Return 0 -End Function - -' Main program -Dim As Integer i -Dim As String names(NUM_PHILOSOPHERS-1) = {"Aristotle", "Kant", "Spinoza", "Marx", "Russell"} -Print "Table empty" - -printMutex = Mutexcreate() - -' Initialize forks -For i = 0 To NUM_PHILOSOPHERS-1 - forks(i).mutex = Mutexcreate() - forks(i).available = True -Next - -' Initialize philosophers -For i = 0 To NUM_PHILOSOPHERS-1 - philosophers(i).nombre = names(i) - philosophers(i).hunger = HUNGER - philosophers(i).leftFork = @forks(i) - philosophers(i).rightFork = @forks((i + 1) Mod NUM_PHILOSOPHERS) -Next - -' Make last philosopher left-handed -Swap philosophers(NUM_PHILOSOPHERS-1).leftFork, philosophers(NUM_PHILOSOPHERS-1).rightFork - -' Create threads -Dim As Any Ptr threads(NUM_PHILOSOPHERS-1) -For i = 0 To NUM_PHILOSOPHERS-1 - threads(i) = Threadcreate(Cast(Sub(As Any Ptr), @philosopherThread), @philosophers(i)) -Next - -' Wait for all threads -For i = 0 To NUM_PHILOSOPHERS-1 - Threadwait(threads(i)) -Next - -' Cleanup -For i = 0 To NUM_PHILOSOPHERS-1 - Mutexdestroy(forks(i).mutex) -Next - -Mutexdestroy(printMutex) -Print "Table empty" - -Sleep diff --git a/Task/Dining-philosophers/Julia/dining-philosophers.jl b/Task/Dining-philosophers/Julia/dining-philosophers.julia similarity index 100% rename from Task/Dining-philosophers/Julia/dining-philosophers.jl rename to Task/Dining-philosophers/Julia/dining-philosophers.julia diff --git a/Task/Dining-philosophers/Kotlin/dining-philosophers.kts b/Task/Dining-philosophers/Kotlin/dining-philosophers.kotlin similarity index 100% rename from Task/Dining-philosophers/Kotlin/dining-philosophers.kts rename to Task/Dining-philosophers/Kotlin/dining-philosophers.kotlin diff --git a/Task/Dining-philosophers/Python/dining-philosophers-2.py b/Task/Dining-philosophers/Python/dining-philosophers-2.py deleted file mode 100644 index fc6c3932e7..0000000000 --- a/Task/Dining-philosophers/Python/dining-philosophers-2.py +++ /dev/null @@ -1,189 +0,0 @@ -"""Dining philosophers with multiprocessing module.""" -import multiprocessing as mp -import random -import time - -# Dining philosophers. See also comments at the threading -# version. Improvements, modifications: -# Support variable number of philosophers. -# "More deterministic" randomization by prealocating the schedules. -# Use scaling to allow faster runs producing results that are -# essentially the same. -# Collect statistics on wait times. - -SCALE = 0.2 -THINK = (3, 13) -DINE = (1, 10) - -class Philosopher(mp.Process): - """Independently running philosopher processes.""" - def __init__(self, idx, name, run_flag, chopstick_left, chopstick_right, - stats, schedule_think, schedule_dine): - mp.Process.__init__(self) - self.idx = idx - self.name = name - self.run_flag = run_flag - self.chopstick_left = chopstick_left - self.chopstick_right = chopstick_right - self.stats = stats - self.schedule_think = schedule_think - self.schedule_dine = schedule_dine - self.counter = 0 - self.num_dined = 0 - self.hungry_time_total = 0.0 - self.hungry_time_max = 0.0 - - def run(self): - while self.run_flag.value and self.counter < len(self.schedule_think): - # Philosopher is thinking (but really is sleeping). - time.sleep(self.schedule_think[self.counter]*SCALE) - duration = -time.perf_counter() - print(f'{self.name} is hungry', flush=True) - self.get_chopsticks2() - duration += time.perf_counter() - self.hungry_time_total += duration - self.hungry_time_max = max(self.hungry_time_max, duration) - self.dining() - # Populate self.stats: - self.stats.put({'name': self.name, - 'num_dined': self.num_dined, - 'hungry_time_total': self.hungry_time_total, - 'hungry_time_max': self.hungry_time_max}) - - def get_chopsticks(self): - """Use swaps and do not hold on to chopsticks.""" - chopstick1, chopstick2 = self.chopstick_left, self.chopstick_right - - while True: - chopstick1.acquire(True) - locked = chopstick2.acquire(False) - if locked: - return - chopstick1.release() - print(f'{self.name} swaps chopsticks', flush=True) - chopstick1, chopstick2 = chopstick2, chopstick1 - - def get_chopsticks0(self): - """Naive greedy implementation to trigger deadlock.""" - self.chopstick_left.acquire(True) - time.sleep(0.1) - self.chopstick_right.acquire(True) - - def get_chopsticks1(self): - """Break the symmetry by having one philosopher to be left handed.""" - if self.idx == 0: - chopstick1, chopstick2 = self.chopstick_left, self.chopstick_right - else: - chopstick1, chopstick2 = self.chopstick_right, self.chopstick_left - chopstick1.acquire(True) - locked = chopstick2.acquire(False) - if not locked: - chopstick1.release() - chopstick2.acquire(True) - chopstick1.acquire(True) - - def get_chopsticks2(self): - """Break the symmetry by having the even numbered philosophers to be - left handed.""" - if self.idx == 0: - chopstick1, chopstick2 = self.chopstick_left, self.chopstick_right - else: - chopstick1, chopstick2 = self.chopstick_right, self.chopstick_left - chopstick1.acquire(True) - locked = chopstick2.acquire(False) - if not locked: - chopstick1.release() - chopstick2.acquire(True) - chopstick1.acquire(True) - - def dining(self): - """Dining with two chopsticks.""" - print(f'{self.name} starts eating', flush=True) - self.num_dined += 1 - time.sleep(self.schedule_dine[self.counter]*SCALE) - self.counter += 1 - print(f'{self.name} finishes eating and leaves to think.', flush=True) - self.chopstick_left.release() - self.chopstick_right.release() - -def performance_report(stats): - """Print some stats about the wait times.""" - print("Performance report:") - for queue in stats: - data = queue.get() - print(f"Philosopher {data['name']} dined {data['num_dined']} times. ") - print(f" Total wait : {data['hungry_time_total'] / SCALE}") - print(f" Max wait : {data['hungry_time_max'] / SCALE}") - if data['num_dined'] > 0: - print(f" Average wait: " - f"{data['hungry_time_total'] / data['num_dined']/SCALE}") - -def generate_philosophers(names, run_flag, chopsticks, stats, max_dine): - """Gebnerate a list of philosophers with random schedules.""" - num = len(names) - philosophers = [Philosopher(i, names[i], run_flag, - chopsticks[i % num], - chopsticks[(i+1) % num], - stats[i], - [random.uniform(THINK[0], THINK[1]) - for j in range(max_dine)], - [random.uniform(DINE[0], DINE[1]) - for j in range(max_dine)]) - for i in range(num)] - return philosophers - -def generate_philosophers0(names, run_flag, chopsticks, stats, - schedule_think, schedule_dine): - """Allows the use of a predetermined thinking and dining schedule. - This may aid in triggering a deadlock.""" - num = len(names) - philosophers = [Philosopher(i, names[i], run_flag, - chopsticks[i % num], - chopsticks[(i+1) % num], - stats[i], - schedule_think[i], - schedule_dine[i]) - for i in range(num)] - return philosophers - -def dining_philosophers(philosopher_names=(('Aristotle', 'Kant', - 'Buddha', 'Marx', 'Russel')), - num_sec=100, max_dine=100): - """Main routine.""" - num = len(philosopher_names) - chopsticks = [mp.Lock() for n in range(num)] - random.seed(507129) - run_flag = mp.Value('b', True) - stats = [mp.Queue() for n in range(num)] - - philosophers = generate_philosophers(philosopher_names, run_flag, - chopsticks, stats, max_dine) - - # Use the following when trying to trigger a deadlock in conjunction with - # get_chopsticks0(): - #philosophers = generate_philosophers0(philosopher_names, run_flag, - # chopsticks, stats, [3]*max_dine, - # [5]*max_dine) - - for phi in philosophers: - phi.start() - time.sleep(num_sec*SCALE) - run_flag.value = False - print("Now we're finishing.", flush=True) - # We want to allow the philosophers to finish their meal. In fact, - # we even allow them to still start eating if they are presently - # hungry. This means we may need to wait at most num*DINE[1]. - wait_time = num*DINE[1] - while wait_time >= 0 and sum(p.is_alive() for p in philosophers) > 0: - time.sleep(1) - wait_time -= 1.0 - if wait_time < 0: - for phi in philosophers: - if phi.is_alive(): - print(f"Ooops, {phi.name} has not finished!!") - phi.terminate() - return 1 - performance_report(stats) - -if __name__ == '__main__': - dining_philosophers() diff --git a/Task/Dining-philosophers/Python/dining-philosophers-1.py b/Task/Dining-philosophers/Python/dining-philosophers.py similarity index 100% rename from Task/Dining-philosophers/Python/dining-philosophers-1.py rename to Task/Dining-philosophers/Python/dining-philosophers.py diff --git a/Task/Dining-philosophers/Rust/dining-philosophers.rs b/Task/Dining-philosophers/Rust/dining-philosophers.rust similarity index 100% rename from Task/Dining-philosophers/Rust/dining-philosophers.rs rename to Task/Dining-philosophers/Rust/dining-philosophers.rust diff --git a/Task/Disarium-numbers/Ada/disarium-numbers.adb b/Task/Disarium-numbers/Ada/disarium-numbers.ada similarity index 100% rename from Task/Disarium-numbers/Ada/disarium-numbers.adb rename to Task/Disarium-numbers/Ada/disarium-numbers.ada diff --git a/Task/Disarium-numbers/Agena/disarium-numbers.agena b/Task/Disarium-numbers/Agena/disarium-numbers.agena deleted file mode 100644 index 8f83231d93..0000000000 --- a/Task/Disarium-numbers/Agena/disarium-numbers.agena +++ /dev/null @@ -1,34 +0,0 @@ -scope # find some Disarium numbers - numbers whose digit position-power sums - # are equal to the number, e.g. 135 = 1^1 + 3^2 + 5^3 - - # compute the nth powers of 0-9 - local constant power := seq( [], [], [], [], [], [], [], [], [] ); - for d from 0 to 9 do power[ 1, d ] := d od; - for n from 2 to 9 do - power[ n, 0 ] := 0; - for d to 9 do - power[ n, d ] := power[ n - 1, d ] * d - od - od; - # print the first few Disarium numbers - local constant maxDisarium := 19; - local count, powerOfTen, length := 0, 10, 1; - for n from 0 while count < maxDisarium do - if n = powerOfTen then - # the number of digits just increased - powerOfTen *:= 10; - length +:= 1 - fi; - # form the digit power sum - local v, dps := n, 0; - for p from length to 1 by -1 do - dps +:= power[ p, v mod 10 ]; - v \:= 10 - od; - if dps = n then - # n is Disarium - count +:= 1; - printf( " %d", n ) - fi - od -end diff --git a/Task/Disarium-numbers/Amazing-Hopper/disarium-numbers.hopper b/Task/Disarium-numbers/Amazing-Hopper/disarium-numbers.hopper deleted file mode 100644 index 57d8337969..0000000000 --- a/Task/Disarium-numbers/Amazing-Hopper/disarium-numbers.hopper +++ /dev/null @@ -1,29 +0,0 @@ -#include - -#proto encontrarunDisariumpara(_X_) -#synon _encontrarunDisariumpara siencontréunDisarium - -algoritmo - decimales '0' - iterar para ( n=3000000, n, --n ) - si encontré un Disarium 'n', entonces{ - imprimir( #(utf8("El número ")),n," es Disarium\n") - } - siguiente -terminar - -subrutinas - -encontrar un Disarium para (n) - - i=0 - n, obtener tamaño parte entera, mover a 'i' - m=0, tn=n, d=0 - iterar mientras ( tn ) - último dígito de 'tn', mover a 'd,tn' - d, elevado a 'i', más 'm' - mover a 'm' - --i - reiterar - -retornar ' #(m==n) ' diff --git a/Task/Disarium-numbers/C-sharp/disarium-numbers.cs b/Task/Disarium-numbers/C-sharp/disarium-numbers.cs deleted file mode 100644 index 311c7d21b4..0000000000 --- a/Task/Disarium-numbers/C-sharp/disarium-numbers.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -class DisariumNumbers { - // Method to check if a number is a Disarium number - public static bool IsDisarium(int num) { - int n = num; - int len = num.ToString().Length; - int sum = 0; - int i = 1; - while (n > 0) { - // C# does not support implicit conversion from double to int, so we explicitly convert the result of Math.Pow to int - sum += (int)Math.Pow(n % 10, len - i + 1); - n /= 10; - i++; - } - return sum == num; - } - - static void Main(string[] args) { - int i = 0; - int count = 0; - // Find and print the first 19 Disarium numbers - while (count <= 18) { - if (IsDisarium(i)) { - Console.Write($"{i} "); - count++; - } - i++; - } - Console.WriteLine(); - } -} diff --git a/Task/Disarium-numbers/COBOL/disarium-numbers.cob b/Task/Disarium-numbers/COBOL/disarium-numbers.cobol similarity index 100% rename from Task/Disarium-numbers/COBOL/disarium-numbers.cob rename to Task/Disarium-numbers/COBOL/disarium-numbers.cobol diff --git a/Task/Disarium-numbers/Chipmunk-Basic/disarium-numbers.basic b/Task/Disarium-numbers/Chipmunk-Basic/disarium-numbers.basic deleted file mode 100644 index 1cb10a143b..0000000000 --- a/Task/Disarium-numbers/Chipmunk-Basic/disarium-numbers.basic +++ /dev/null @@ -1,26 +0,0 @@ -100 cls -110 sub isdisarium(n) -120 digitos = len(str$(n)) -130 suma = 0 -140 x = n -150 while x <> 0 -160 r = (x mod 10) -170 suma = suma+(r^digitos) -180 digitos = digitos-1 -190 x = int(x/10) -200 wend -210 if suma = n then isdisarium = true else isdisarium = false -220 end sub -230 ' -240 limite = 19 -250 cnt = 0 -260 n = 0 -270 print "The first ";limite;" Disarium numbers are:" -280 while cnt < limite -290 if isdisarium(n) then -300 print n;" "; -310 cnt = cnt+1 -320 endif -330 n = n+1 -340 wend -350 end diff --git a/Task/Disarium-numbers/Delphi/disarium-numbers.pas b/Task/Disarium-numbers/Delphi/disarium-numbers.delphi similarity index 100% rename from Task/Disarium-numbers/Delphi/disarium-numbers.pas rename to Task/Disarium-numbers/Delphi/disarium-numbers.delphi diff --git a/Task/Disarium-numbers/EasyLang/disarium-numbers.easy b/Task/Disarium-numbers/EasyLang/disarium-numbers.easy deleted file mode 100644 index 08d03576da..0000000000 --- a/Task/Disarium-numbers/EasyLang/disarium-numbers.easy +++ /dev/null @@ -1,21 +0,0 @@ -fastfunc disarium n . - n0 = n - ndig = floor log n 10 + 1 - for i = ndig downto 1 - h += pow (n mod 10) i - n = n div 10 - . - if h = n0 : return 1 -. -fastfunc nextdisarium n . - repeat - n += 1 - until disarium n = 1 - . - return n -. -for i to 18 - n = nextdisarium n - write n & " " -. -print "" diff --git a/Task/Disarium-numbers/Fortran/disarium-numbers.f b/Task/Disarium-numbers/Fortran/disarium-numbers.f deleted file mode 100644 index 5839193fc7..0000000000 --- a/Task/Disarium-numbers/Fortran/disarium-numbers.f +++ /dev/null @@ -1,112 +0,0 @@ -! Disarium numbers -! -! tested with Intel ifx (IFX) 2025.2.0 20250605 on Kubuntu 25.04 -! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 -! Note that VMS requires switch $Fortran/ccdefault=LIST -! otherwise 1st character of each output line is interpreted as -! Carriage Control character. -! U.B., July 2025 - -program progDisarium - -implicit none - -! Others have already shown: 20th Disarium number has 20 digits -! This will not fit in signed 8-byte-integer. Current Fortran does -! not have unsigned integers of any size, so we can only calculate 19 Disarium numbers -! (unless we start to fiddle with homegrown extended precision integers) -! These 19 numbers all fit in 4 byte integers, so we can limit ourselves to -! signed 4-byte integers, with maximum possible number of digits is 10. - - integer, parameter :: maxDigs = 10 ! Maximum number of digits - integer , parameter :: nMax = 19 ! Number of Disarim numbers to print - integer :: ii ! loop index - integer :: count ! result counter - - ii=0 - count=0 - - do while (count .lt. nMax) ! finish when count is nMax. - if (isDisarium (ii)) then ! found another result - count = count + 1 - write (6,'(i0, x)', advance='no') ii ! print one by one, but all in 1 line - end if - ii = ii + 1 - end do - write (6,*) ! terminate line only - - contains - - function isDisarium (n) result(yn) - - integer, intent(in) :: n ! decide if n is disarium number - logical :: yn ! return value, true or false - integer :: numD, sum ! number of digits, sum of pow(digits,loc) - integer :: theDigits (maxDigs) ! vector with the numD digits of n - integer :: jj ! loop index - sum = 0 - - numD = getDigits (n, theDigits) ! Decompose n into numD Digits - - do jj=1, numD - if (theDigits(jj) .ne. 0) then - sum = sum + ipow(theDigits(jj), jj) - endif - end do - yn = (sum .eq. n) - end function isDisarium - - - function getDigits (n, d) result (ndigs) - - integer, intent(in) :: n ! decompose this into its digits - integer, intent(out) :: d(maxDigs) ! result: digits of n - integer :: ndigs ! return value: number of digits - integer :: ii ! loop index - integer :: localN ! Local copy of n to work with - - if (n .lt. 10) then ! Do the trivial case without further calculation - ndigs = 1 - d(1) = n - return - endif - - ndigs = 0 - localN = n - ! store them right-justified in array d - do while (localN .gt. 0) - d(maxDigs - ndigs) = mod(localN, 10) - ndigs = ndigs + 1 - localN = localN / 10 - end do - - ! Need to shift so that most significant digit appears at d (1) - do ii = 1, ndigs - d (ii) = d (maxDigs-ndigs+ii) - end do - - end function getDigits - - - ! Integer power: calculate n ^ pw - function ipow (n,pw) result (p) - integer, intent(in) :: n ! take this... - integer, intent(in) :: pw ! ... to the power of that - integer :: p ! Return value - integer :: ii ! Loop index - - p = 1 - - if (pw .lt. 0 .or. n.le. 0) then - print *, "function ipow(n,p) is only defined for values n,p both >0" - return - end if - - do ii=1, pw - p = p * n - end do - - end function ipow - -end program progDisarium diff --git a/Task/Disarium-numbers/Free-Pascal-Lazarus/disarium-numbers.pas b/Task/Disarium-numbers/Free-Pascal/disarium-numbers.pas similarity index 100% rename from Task/Disarium-numbers/Free-Pascal-Lazarus/disarium-numbers.pas rename to Task/Disarium-numbers/Free-Pascal/disarium-numbers.pas diff --git a/Task/Disarium-numbers/Frink/disarium-numbers.frink b/Task/Disarium-numbers/Frink/disarium-numbers.frink deleted file mode 100644 index 82f3f23e70..0000000000 --- a/Task/Disarium-numbers/Frink/disarium-numbers.frink +++ /dev/null @@ -1,12 +0,0 @@ -isDisarium = {|n| - s = 0 - p = 1 - for d = integerDigits[n] - { - s = s + d^p - p = p + 1 - } - return n==s -} - -println[first[select[count[0], isDisarium], 19]] diff --git a/Task/Disarium-numbers/Icon/disarium-numbers.icon b/Task/Disarium-numbers/Icon/disarium-numbers.icon deleted file mode 100644 index 86618f4a21..0000000000 --- a/Task/Disarium-numbers/Icon/disarium-numbers.icon +++ /dev/null @@ -1,11 +0,0 @@ -procedure main(A) - limit := \A[1] | 18 - every writes(" ",disarium(seq(0)))\limit - write() -end - -procedure disarium(n) - ns := string(n) # Avoid redundant conversions later - every ((s := i := 0), j := !ns, i +:= 1) do s +:= ns[i]^i - return s = n -end diff --git a/Task/Disarium-numbers/J/disarium-numbers.j b/Task/Disarium-numbers/J/disarium-numbers.j index 7c3eab3737..f9bd103175 100644 --- a/Task/Disarium-numbers/J/disarium-numbers.j +++ b/Task/Disarium-numbers/J/disarium-numbers.j @@ -1,5 +1,4 @@ -digits=: "."0@": -disarium=: = (+/@:^ #\)@digits"0 - - I. disarium i. 27e5 -0 1 2 3 4 5 6 7 8 9 89 135 175 518 598 1306 1676 2427 2646798 +digits=: 10 #.inv ] +disarium=: (= (+/ .^ #\)@digits)"0 + I.disarium i.1e4 +0 1 2 3 4 5 6 7 8 9 89 135 175 518 598 1306 1676 2427 diff --git a/Task/Disarium-numbers/Julia/disarium-numbers.jl b/Task/Disarium-numbers/Julia/disarium-numbers.julia similarity index 100% rename from Task/Disarium-numbers/Julia/disarium-numbers.jl rename to Task/Disarium-numbers/Julia/disarium-numbers.julia diff --git a/Task/Disarium-numbers/Kotlin/disarium-numbers.kts b/Task/Disarium-numbers/Kotlin/disarium-numbers.kotlin similarity index 100% rename from Task/Disarium-numbers/Kotlin/disarium-numbers.kts rename to Task/Disarium-numbers/Kotlin/disarium-numbers.kotlin diff --git a/Task/Disarium-numbers/Maxima/disarium-numbers.maxima b/Task/Disarium-numbers/Maxima/disarium-numbers.maxima deleted file mode 100644 index 5c508c1607..0000000000 --- a/Task/Disarium-numbers/Maxima/disarium-numbers.maxima +++ /dev/null @@ -1,22 +0,0 @@ -/* Function that returns a list of digits given a nonnegative integer */ -decompose(num) := block([digits, remainder], - digits: [], - while num > 0 do - (remainder: mod(num, 10), - digits: cons(remainder, digits), - num: floor(num/10)), - digits -)$ - -disariump(n):=block( - decompose(n), - makelist(%%[i]^i,i,length(%%)), - apply("+",%%), - if n=%% then true)$ - -disarium_count(len):=block([i:0,count:0,result:[]], -while countPrint(); - count++; - }; - - i++; - }; - '\n'->Print(); - } - - function : IsDisarium(num : Int) ~ Bool { - n := num; - len := n->ToString()->Size(); - sum := 0; - i := 1; - while (n > 0) { - sum += Int->Pow(n % 10, len - i + 1); - n /= 10; - i ++; - }; - - return sum = num; - } -} diff --git a/Task/Disarium-numbers/Odin/disarium-numbers.odin b/Task/Disarium-numbers/Odin/disarium-numbers.odin deleted file mode 100644 index c6ece460c6..0000000000 --- a/Task/Disarium-numbers/Odin/disarium-numbers.odin +++ /dev/null @@ -1,38 +0,0 @@ -package disarium -import "core:fmt" -import "core:math" - -/* main block start */ -main :: proc() { - fmt.print("\nThe first 18 Disarium numbers are:") - count, i: int - for count < 19 { - if is_disarium(i) { - fmt.print(" ", i) - count += 1 - } - i += 1 - } - fmt.println("") -} /* main block end */ - -/* proc definitions */ -power :: proc(base, exponent: int) -> int { - result := 1 - for _ in 1 ..= exponent { - result *= base - } - return result -} - -is_disarium :: proc(num: int) -> bool { - n := num - sum := 0 - len := n <= 9 ? 1 : cast(int)math.floor_f64(math.log10_f64(auto_cast n) + 1) - for n > 0 { - sum += power(n % 10, len) - n /= 10 - len -= 1 - } - return num == sum -} diff --git a/Task/Disarium-numbers/PARI-GP/disarium-numbers.parigp b/Task/Disarium-numbers/PARI-GP/disarium-numbers.parigp deleted file mode 100644 index 2f0215c66a..0000000000 --- a/Task/Disarium-numbers/PARI-GP/disarium-numbers.parigp +++ /dev/null @@ -1,20 +0,0 @@ -/* Function to check if a number is a Disarium number */ -IsDisarium(n) = { - my(digs = digits(n)); /* Get digits of n */ - my(mypowers = vector(#digs, i, digs[i]^i)); /* Raise each digit to its position */ - sum(i=1, #digs, mypowers[i]) == n /* Return 1 if sum equals original number */ -} - -/* Function to find Disarium numbers up to a limit */ -find_disarium(limit) = { - my(result = [], n = 0); - while(#result < limit, - if(IsDisarium(n), result = concat(result, n)); - n++; - ); - return(result); -} - -/* Main execution */ -disariumNumbers = find_disarium(19); -print("The first 19 Disarium numbers: ", disariumNumbers); diff --git a/Task/Disarium-numbers/PascalABC.NET/disarium-numbers.pas b/Task/Disarium-numbers/PascalABC.NET/disarium-numbers.pas deleted file mode 100644 index 6e4ae6f80d..0000000000 --- a/Task/Disarium-numbers/PascalABC.NET/disarium-numbers.pas +++ /dev/null @@ -1,15 +0,0 @@ -## -function disariums: sequence of integer; -begin - var n := 0; - while true do - begin - var sum := 0.0; - foreach var x in n.ToString.ToCharArray index i do - sum := sum + power((x.todigit), i + 1); - if sum = n then yield (n); - n += 1; - end; -end; - -disariums.Take(19).Println; diff --git a/Task/Disarium-numbers/Pluto/disarium-numbers.pluto b/Task/Disarium-numbers/Pluto/disarium-numbers.pluto deleted file mode 100644 index 4952e62669..0000000000 --- a/Task/Disarium-numbers/Pluto/disarium-numbers.pluto +++ /dev/null @@ -1,29 +0,0 @@ -do -- find some Disarium numbers, numbers that are equal to their digit position power sums - - -- compute the nth powers of 0-9 # - local power = { { [0] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, {}, {}, {}, {}, {}, {}, {}, {}, {} } - for n = 2, 9 do - power[n][0] = 0 - for d = 1, 9 do - power[n][d] = power[n - 1][d] * d - end - end - - local function isDisarium (x) - local str, sum = tostring(x), 0 - for pos = 1, #str do - local digit = tonumber(str[pos]) - sum += power[pos][digit] - end - return sum == x - end - - local count, n = 0, 0 - while count < 19 do - if isDisarium( n ) then - ++ count - io.write( " ", n ) - end - ++ n - end -end diff --git a/Task/Disarium-numbers/R/disarium-numbers.r b/Task/Disarium-numbers/R/disarium-numbers.r deleted file mode 100644 index bee77272bc..0000000000 --- a/Task/Disarium-numbers/R/disarium-numbers.r +++ /dev/null @@ -1,12 +0,0 @@ -disarium_sum <- function(n, i=ceiling(log10(n))){ - ifelse(n>9, (n%%10)^i+disarium_sum(n%/%10, i-1), n) -} - -count <- num <- 0 -while(count<19){ - if(num==disarium_sum(num)){ - print(num) - count <- count+1 - } - num <- num+1 -} diff --git a/Task/Disarium-numbers/Refal/disarium-numbers.refal b/Task/Disarium-numbers/Refal/disarium-numbers.refal deleted file mode 100644 index 24e17b740b..0000000000 --- a/Task/Disarium-numbers/Refal/disarium-numbers.refal +++ /dev/null @@ -1,32 +0,0 @@ -$ENTRY Go { - = ; -}; - -Digits { - 0 = ; - s.N, : (s.R) s.D = s.D; -}; - -Pow { - s.N 0 = 1; - s.N s.P = <* s.N >>; -}; - -PowSum { - () e.P = 0; - (s.I e.X) e.P = <+ >>; - e.X = ; -}; - -Disarium { - e.N, >: e.N = True; - e.N = False; -}; - -FindDisarium { - 0 s.N = ; - s.I s.N, : { - True = <+ s.N 1>>; - False = >; - }; -}; diff --git a/Task/Disarium-numbers/Rust/disarium-numbers.rs b/Task/Disarium-numbers/Rust/disarium-numbers.rust similarity index 100% rename from Task/Disarium-numbers/Rust/disarium-numbers.rs rename to Task/Disarium-numbers/Rust/disarium-numbers.rust diff --git a/Task/Disarium-numbers/SETL/disarium-numbers.setl b/Task/Disarium-numbers/SETL/disarium-numbers.setl deleted file mode 100644 index ed7efa017f..0000000000 --- a/Task/Disarium-numbers/SETL/disarium-numbers.setl +++ /dev/null @@ -1,13 +0,0 @@ -program disarium_numbers; - loop for n in [0..2700000] | disarium n do - print(n); - end loop; - - op disarium(n); - k := n; - digits := [[k mod 10, k div:= 10](1) : until k=0]; - p := #digits+1; - powsum := +/[d ** (p -:= 1) : d in digits]; - return powsum = n; - end op; -end program; diff --git a/Task/Disarium-numbers/Uiua/disarium-numbers.uiua b/Task/Disarium-numbers/Uiua/disarium-numbers.uiua deleted file mode 100644 index 37dbf6e7ff..0000000000 --- a/Task/Disarium-numbers/Uiua/disarium-numbers.uiua +++ /dev/null @@ -1,2 +0,0 @@ -IsDis ← =⊸(/+≡ⁿ+1⇡⊸⧻≡₀⋕°⋕) -⍜now(⋅⇌⍢(+1⍥⟜⊂⊸IsDis|<19⋅⧻)0[]) diff --git a/Task/Discordian-date/ALGOL-68/discordian-date.alg b/Task/Discordian-date/ALGOL-68/discordian-date.alg index 11d03d007b..ebf5dda235 100644 --- a/Task/Discordian-date/ALGOL-68/discordian-date.alg +++ b/Task/Discordian-date/ALGOL-68/discordian-date.alg @@ -1,11 +1,9 @@ BEGIN # DISCORDIAN DATE CALCULATION - TRANSLATION OF MAD VIA ALGOL W # - INT gmonth, gday, gyear; + INT greg, gmonth, gday, gyear; []STRING holys = []STRING( "MUNG", "MOJO", "SYA", "ZARA", "MALA" )[ AT 0 ]; []STRING holys0 = []STRING( "CHAO", "DISCO", "CONFU", "BURE", "AF" )[ AT 0 ]; - []STRING disday = - []STRING( "SWEETMORN", "BOOMTIME", "PUNGENDAY", "PRICKLE-PRICKLE", "SETTING ORANGE" )[ AT 0 ]; - []STRING disssn = - []STRING( "CHAOS", "DISCORD", "CONFUSION", "BUREAUCRACY", "THE AFTERMATH" )[ AT 0 ]; + []STRING disday = []STRING( "SWEETMORN", "BOOMTIME", "PUNGENday", "PRICKLE-PRICKLE", "SETTING ORANGE" )[ AT 0 ]; + []STRING disssn = []STRING( "CHAOS", "DISCORD", "CONFUSION", "BUREAUCRACY", "THE AFTERMATH" )[ AT 0 ]; []INT mlengt = []INT( 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 )[ AT 0 ]; CHAR slash1, slash2; diff --git a/Task/Discordian-date/Ada/discordian-date.adb b/Task/Discordian-date/Ada/discordian-date.ada similarity index 100% rename from Task/Discordian-date/Ada/discordian-date.adb rename to Task/Discordian-date/Ada/discordian-date.ada diff --git a/Task/Discordian-date/Delphi/discordian-date.pas b/Task/Discordian-date/Delphi/discordian-date.delphi similarity index 100% rename from Task/Discordian-date/Delphi/discordian-date.pas rename to Task/Discordian-date/Delphi/discordian-date.delphi diff --git a/Task/Discordian-date/EasyLang/discordian-date.easy b/Task/Discordian-date/EasyLang/discordian-date.easy deleted file mode 100644 index 600746ed03..0000000000 --- a/Task/Discordian-date/EasyLang/discordian-date.easy +++ /dev/null @@ -1,48 +0,0 @@ -seasons$[] = [ "Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath" ] -weekday$[] = [ "Sweetmorn" "Boomtime" "Pungenday" "Prickle-Prickle" "Setting Orange" ] -apostle$[] = [ "Mungday" "Mojoday" "Syaday" "Zaraday" "Maladay" ] -holiday$[] = [ "Chaoflux" "Discoflux" "Confuflux" "Bureflux" "Afflux" ] -# -func leap x . - return if x mod 400 = 0 or x mod 4 = 0 and x mod 100 <> 0 -. -func day_of_year y m d . - days[] = [ 31 28 31 30 31 30 31 31 30 31 30 31 ] - repeat - m -= 1 - until m = 0 - d += days[m] - if m = 2 and leap y = 1 : d += 1 - . - return d -. -func$ ddate y m d . - doy = day_of_year y m d - dyear = y + 1166 - if leap y = 1 and m = 2 and d = 29 - return "St. Tib's Day, in the YOLD " & dyear - . - if leap y = 1 and doy >= 60 : doy -= 1 - dsday = doy mod1 73 - dseason = doy div1 73 - r$ = weekday$[doy mod1 5] & ", day " & dsday & " of " & seasons$[dseason] - r$ &= " in the YOLD " & dyear & "." - if dsday = 5 - r$ &= " Celebrate " & apostle$[dseason] & "!" - elif dsday = 50 - r$ &= " Celebrate " & holiday$[dseason] & "!" - . - return r$ -. -proc show d$ . - a[] = number strsplit d$ "-" - write d$ & " --> " - print ddate a[1] a[2] a[3] -. -show "2016-01-05" -show "2016-02-28" -show "2016-02-29" -show "2016-03-01" -show "2016-12-31" -show "2025-03-19" -show substr timestr systime 1 10 diff --git a/Task/Discordian-date/Euphoria/discordian-date.eu b/Task/Discordian-date/Euphoria/discordian-date.euphoria similarity index 100% rename from Task/Discordian-date/Euphoria/discordian-date.eu rename to Task/Discordian-date/Euphoria/discordian-date.euphoria diff --git a/Task/Discordian-date/Julia/discordian-date.jl b/Task/Discordian-date/Julia/discordian-date.julia similarity index 100% rename from Task/Discordian-date/Julia/discordian-date.jl rename to Task/Discordian-date/Julia/discordian-date.julia diff --git a/Task/Discordian-date/Kotlin/discordian-date.kts b/Task/Discordian-date/Kotlin/discordian-date.kotlin similarity index 100% rename from Task/Discordian-date/Kotlin/discordian-date.kts rename to Task/Discordian-date/Kotlin/discordian-date.kotlin diff --git a/Task/Discordian-date/Phix/discordian-date.phix b/Task/Discordian-date/Phix/discordian-date.phix index 9404c2065d..2a44d313c0 100644 --- a/Task/Discordian-date/Phix/discordian-date.phix +++ b/Task/Discordian-date/Phix/discordian-date.phix @@ -1,41 +1,43 @@ -with javascript_semantics -constant seasons = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"}, - weekday = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"}, - apostle = {"Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"}, - holiday = {"Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"} +(phixonline)--> + with javascript_semantics + constant seasons = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"}, + weekday = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"}, + apostle = {"Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"}, + holiday = {"Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"} -function discordianDate(sequence dt) - integer {y,m,d} = dt, - leap = is_leap_year(y), - doy = day_of_year(y,m,d)-1 - string dyear = sprintf("%d",y+1166) - if leap and m=2 and d=29 then - return "St. Tib's Day, in the YOLD " & dyear - end if - if leap and doy>=60 then - doy -= 1 - end if - integer dsday = remainder(doy,73)+1, - dseason = floor(doy/73+1) - if dsday=5 then - return apostle[dseason] & ", in the YOLD " & dyear - elsif dsday=50 then - return holiday[dseason] & ", in the YOLD " & dyear - end if - string dseas = seasons[dseason], - dwday = weekday[remainder(doy,5)+1] - return sprintf("%s, day %d of %s in the YOLD %s", {dwday, dsday, dseas, dyear}) -end function + function discordianDate(sequence dt) + integer {y,m,d} = dt, + leap = is_leap_year(y), + doy = day_of_year(y,m,d)-1 + string dyear = sprintf("%d",y+1166) + if leap and m=2 and d=29 then + return "St. Tib's Day, in the YOLD " & dyear + end if + if leap and doy>=60 then + doy -= 1 + end if + integer dsday = remainder(doy,73)+1, + dseason = floor(doy/73+1) + if dsday=5 then + return apostle[dseason] & ", in the YOLD " & dyear + elsif dsday=50 then + return holiday[dseason] & ", in the YOLD " & dyear + end if + string dseas = seasons[dseason], + dwday = weekday[remainder(doy,5)+1] + return sprintf("%s, day %d of %s in the YOLD %s", {dwday, dsday, dseas, dyear}) + end function --- test code + -- test code -sequence dt = {2015,1,1,0,0,0,0,0} -include timedate.e -atom oneday = timedelta(days:=1) -set_timedate_formats({"DD/MM/YYYY"}) -for i=1 to 5 do - printf(1,"%s: %s\n",{format_timedate(dt),discordianDate(dt)}) - dt = adjust_timedate(dt,oneday*72) - printf(1,"%s: %s\n",{format_timedate(dt),discordianDate(dt)}) - dt = adjust_timedate(dt,oneday) -end for + sequence dt = {2015,1,1,0,0,0,0,0} + include timedate.e + atom oneday = timedelta(days:=1) + set_timedate_formats({"DD/MM/YYYY"}) + for i=1 to 5 do + printf(1,"%s: %s\n",{format_timedate(dt),discordianDate(dt)}) + dt = adjust_timedate(dt,oneday*72) + printf(1,"%s: %s\n",{format_timedate(dt),discordianDate(dt)}) + dt = adjust_timedate(dt,oneday) + end for + + with javascript_semantics + function linear_combination(sequence f) + string res = "" + for e=1 to length(f) do + integer fe = f[e] + if fe!=0 then + if fe=1 then + if length(res) then res &= "+" end if + elsif fe=-1 then + res &= "-" + elsif fe>0 and length(res) then + res &= sprintf("+%d*",fe) + else + res &= sprintf("%d*",fe) + end if + res &= sprintf("e(%d)",e) + end if + end for + if res="" then res = "0" end if + return res + end function -constant tests = {{1,2,3},{0,1,2,3},{1,0,3,4},{1,2,0},{0,0,0}, - {0},{1,1,1},{-1,-1,-1},{-1,-2,0,-3},{-1}} -for t in tests do - printf(1,"%12v -> %s\n",{t, linear_combination(t)}) -end for + constant tests = {{1,2,3}, + {0,1,2,3}, + {1,0,3,4}, + {1,2,0}, + {0,0,0}, + {0}, + {1,1,1}, + {-1,-1,-1}, + {-1,-2,0,-3}, + {-1}} + for i=1 to length(tests) do + sequence ti = tests[i] + printf(1,"%12s -> %s\n",{sprint(ti), linear_combination(ti)}) + end for + + without js -- file i/o + enum Airport_ID, Name, City, Country, IATA, ICAO, Latitude, Longitude, Altitude, Timezone, DST, Tz_Olson, Type, Source + function tabulate(sequence s) + s = split(trim(s),"\n") + for i,ri in s do + ri = split(ri,',') + if length(ri)!=14 then + ri[2] &= ","&ri[3] + ri[3..3] = {} + end if + for j in {Airport_ID, Latitude, Longitude, Altitude} do + ri[j] = to_number(ri[j]) + end for + for j in {Name,City,Country,ICAO} do + ri[j] = trim(ri[j],`"`) + end for + s[i] = ri + end for + return s + end function -constant airports = tabulate(get_text("airports.dat")) + constant airports = tabulate(get_text("airports.dat")) -function distance(atom lat1, lon1, lat2, lon2, integer units) - atom dist = 0 - if lat1!=lat2 or lon1!=lon2 then - atom radlat1 = lat1*PI/180, - radlat2 = lat2*PI/180, - radtheta = (lon1-lon2)*PI/180 - dist = sin(radlat1)*sin(radlat2) + cos(radlat1)*cos(radlat2)*cos(radtheta) - dist = arccos(min(dist,1))*180/PI * 60*1.1515576 -- in Statute Miles - if units = 'K' then dist *= 1.609344 end if -- in Kilometres - if units = 'N' then dist *= 0.868976 end if -- in Nautical Miles - end if - return dist -end function + function distance(atom lat1, lon1, lat2, lon2, integer units) + atom dist = 0 + if lat1!=lat2 or lon1!=lon2 then + atom radlat1 = lat1*PI/180, + radlat2 = lat2*PI/180, + radtheta = (lon1-lon2)*PI/180 + dist = sin(radlat1)*sin(radlat2) + cos(radlat1)*cos(radlat2)*cos(radtheta) + dist = arccos(min(dist,1))*180/PI * 60*1.1515576 -- in Statute Miles + if units = 'K' then dist *= 1.609344 end if -- in Kilometres + if units = 'N' then dist *= 0.868976 end if -- in Nautical Miles + end if + return dist + end function -function bearing(atom lat1, lon1, lat2, lon2) - atom bear = NULL - if lat1!=lat2 or lon1!=lon2 then - atom radlat1 = lat1*PI/180, - radlat2 = lat2*PI/180, - raddlon = (lon2-lon1)*PI/180, - y = sin(raddlon)*cos(radlat2), - x = cos(radlat1)*sin(radlat2) - sin(radlat1)*cos(radlat2)*cos(raddlon) - bear = remainder(atan2(y, x)*180/PI+360,360) - end if - return bear; -end function + function bearing(atom lat1, lon1, lat2, lon2) + atom bear = NULL + if lat1!=lat2 or lon1!=lon2 then + atom radlat1 = lat1*PI/180, + radlat2 = lat2*PI/180, + raddlon = (lon2-lon1)*PI/180, + y = sin(raddlon)*cos(radlat2), + x = cos(radlat1)*sin(radlat2) - sin(radlat1)*cos(radlat2)*cos(raddlon) + bear = remainder(atan2(y, x)*180/PI+360,360) + end if + return bear; + end function -procedure query(atom lat,lon, integer rows=20) - sequence r = {} - for a in airports do - atom lat2 = a[Latitude], - lon2 = a[Longitude], - dist = round(distance(lat,lon,lat2,lon2,'N'),10), - bear = round(bearing(lat,lon,lat2,lon2)) - r = append(r,{a[Name],a[Country],a[ICAO],dist,bear}) - end for - r = sort_columns(r,{4})[1..rows] - printf(1," Name | Country | ICAO | Distance in NM | Bearing in ° \n") - printf(1,"-------------------------------------+----------------+------+----------------+--------------\n") - printf(1,"%s\n",{join(r,"\n",fmt:=" %-36s| %-15s| %4s | %4.1f | %3d")}) - printf(1,"(%d rows)\n",rows) -end procedure + procedure query(atom lat,lon, integer rows=20) + sequence r = {} + for a in airports do + atom lat2 = a[Latitude], + lon2 = a[Longitude], + dist = round(distance(lat,lon,lat2,lon2,'N'),10), + bear = round(bearing(lat,lon,lat2,lon2)) + r = append(r,{a[Name],a[Country],a[ICAO],dist,bear}) + end for + r = sort_columns(r,{4})[1..rows] + printf(1," Name | Country | ICAO | Distance in NM | Bearing in ° \n") + printf(1,"-------------------------------------+----------------+------+----------------+--------------\n") + printf(1,"%s\n",{join(r,"\n",fmt:=" %-36s| %-15s| %4s | %4.1f | %3d")}) + printf(1,"(%d rows)\n",rows) + end procedure -query(51.514669, 2.198581) + query(51.514669, 2.198581) + + with javascript_semantics + sequence rfs = {1} -- reverse factorial(1) in base 1000 -function init_zc() - sequence zc = repeat(0,999) - for x=1 to 9 do - zc[x] = 2 -- 00x - zc[10*x] = 2 -- 0x0 - zc[100*x] = 2 -- x00 - for y=10 to 90 by 10 do - zc[y+x] = 1 -- 0yx - zc[10*y+x] = 1 -- y0x - zc[10*(y+x)] = 1 -- yx0 - end for - end for - return zc -end function -constant zc = init_zc() + function init_zc() + sequence zc = repeat(0,999) + for x=1 to 9 do + zc[x] = 2 -- 00x + zc[10*x] = 2 -- 0x0 + zc[100*x] = 2 -- x00 + for y=10 to 90 by 10 do + zc[y+x] = 1 -- 0yx + zc[10*y+x] = 1 -- y0x + zc[10*(y+x)] = 1 -- yx0 + end for + end for + return zc + end function + constant zc = init_zc() -atom t0 = time(), - total = 0 -integer trail = 1, - first = 0 -for f=2 to iff(platform()=JS?10000:50000) do - integer carry = 0, d999, - zeroes = (trail-1)*3, - j = trail, l = length(rfs) - while j<=l or carry do - if j<=l then - carry = (rfs[j])*f+carry - end if - d999 = remainder(carry,1000) - if j<=l then - rfs[j] = d999 - else - rfs &= d999 - end if - zeroes += iff(d999=0?3:zc[d999]) - carry = floor(carry/1000) - j += 1 - end while - while rfs[trail]=0 do trail += 1 end while - -- d999 := quick correction for length and zeroes: - d999 = rfs[$] - d999 = iff(d999<100?iff(d999<10?2:1):0) - zeroes -= d999 - integer digits = length(rfs)*3-d999 + atom t0 = time(), + total = 0 + integer trail = 1, + first = 0 + for f=2 to iff(platform()=JS?10000:50000) do + integer carry = 0, d999, + zeroes = (trail-1)*3, + j = trail, l = length(rfs) + while j<=l or carry do + if j<=l then + carry = (rfs[j])*f+carry + end if + d999 = remainder(carry,1000) + if j<=l then + rfs[j] = d999 + else + rfs &= d999 + end if + zeroes += iff(d999=0?3:zc[d999]) + carry = floor(carry/1000) + j += 1 + end while + while rfs[trail]=0 do trail += 1 end while + -- d999 := quick correction for length and zeroes: + d999 = rfs[$] + d999 = iff(d999<100?iff(d999<10?2:1):0) + zeroes -= d999 + integer digits = length(rfs)*3-d999 - total += zeroes/digits - atom ratio = total/f - if ratio>=0.16 then - first = 0 - elsif first=0 then - first = f - end if - if find(f,{100,1000,10000}) then - string e = elapsed(time()-t0) - printf(1,"Mean proportion of zero digits in factorials to %d is %.10f (%s)\n",{f,ratio,e}) - end if -end for -if platform()!=JS then - string e = elapsed(time()-t0) - printf(1,"The mean proportion dips permanently below 0.16 at %d. (%s)\n",{first,e}) -end if + total += zeroes/digits + atom ratio = total/f + if ratio>=0.16 then + first = 0 + elsif first=0 then + first = f + end if + if find(f,{100,1000,10000}) then + string e = elapsed(time()-t0) + printf(1,"Mean proportion of zero digits in factorials to %d is %.10f (%s)\n",{f,ratio,e}) + end if + end for + if platform()!=JS then + string e = elapsed(time()-t0) + printf(1,"The mean proportion dips permanently below 0.16 at %d. (%s)\n",{first,e}) + end if + + with javascript_semantics + atom t0 = time(), + f10 = log10(1), + total = 0 + integer first = 0 + for f=2 to 50000 do + f10 += log10(f) + integer digits = ceil(f10), + zeroes = 0, + v = 5 + while v<=f do + zeroes += floor(f/v) + v *= 5 + end while + total += zeroes/digits + atom ratio = total/f + if ratio>=0.07 then + first = 0 + elsif first=0 then + first = f + end if + if find(f,{100,1000,10000}) then + printf(1,"Mean proportion of trailing zeroes in factorials to %d is %f\n",{f,ratio}) + end if + end for + string e = elapsed(time()-t0) + printf(1,"The mean proportion dips permanently below 0.07 at %d. (%s)\n",{first,e}) + s ) - [ stack ] is zeroes ( --> s ) - - [ 0 digits put - 0 zeroes put - [ 1 digits tally - 10 /mod 0 = - zeroes tally - dup 0 = until ] - drop - zeroes take - digits take - reduce ] is zeroprop ( n --> n/d ) - - [ dup dip - [ 0 n->v - 1 ] - times - [ i^ 1+ * - dup zeroprop - rot dip v+ ] - drop - rot n->v v/ ] is distribution ( n --> n/d ) - - 100 distribution 10 point$ echo$ cr - 1000 distribution 10 point$ echo$ cr - 10000 distribution 10 point$ echo$ cr diff --git a/Task/Distribution-of-0-digits-in-factorial-series/Rust/distribution-of-0-digits-in-factorial-series.rs b/Task/Distribution-of-0-digits-in-factorial-series/Rust/distribution-of-0-digits-in-factorial-series.rust similarity index 100% rename from Task/Distribution-of-0-digits-in-factorial-series/Rust/distribution-of-0-digits-in-factorial-series.rs rename to Task/Distribution-of-0-digits-in-factorial-series/Rust/distribution-of-0-digits-in-factorial-series.rust diff --git a/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-1.wren b/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-1.wren index 2030f184ed..1760f6d245 100644 --- a/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-1.wren +++ b/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-1.wren @@ -1,5 +1,5 @@ -import "./big" for BigInt -import "./fmt" for Fmt +import "/big" for BigInt +import "/fmt" for Fmt var fact = BigInt.one var sum = 0 diff --git a/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-2.wren b/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-2.wren index ef06ad478c..f3fc6d3ff3 100644 --- a/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-2.wren +++ b/Task/Distribution-of-0-digits-in-factorial-series/Wren/distribution-of-0-digits-in-factorial-series-2.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var rfs = [1] // reverse factorial(1) in base 1000 diff --git a/Task/Diversity-prediction-theorem/ALGOL-68/diversity-prediction-theorem.alg b/Task/Diversity-prediction-theorem/ALGOL-68/diversity-prediction-theorem.alg deleted file mode 100644 index a44a44127a..0000000000 --- a/Task/Diversity-prediction-theorem/ALGOL-68/diversity-prediction-theorem.alg +++ /dev/null @@ -1,65 +0,0 @@ -BEGIN # Diversity Prediction Theorem # - - # utility operators # - OP LENGTH = ( []REAL a )INT: ( UPB a - LWB a ) + 1; - OP LENGTH = ( STRING a )INT: ( UPB a - LWB a ) + 1; - OP SUM = ( []REAL a )REAL: - BEGIN - REAL result := 0; - FOR i FROM LWB a TO UPB a DO result +:= a[ i ] OD; - result - END # SUM # ; - PRIO PAD = 9; - OP PAD = ( INT width, STRING v )STRING: # left blank pad v to width # - IF LENGTH v >= width THEN v ELSE ( " " * ( width - LENGTH v ) ) + v FI; - OP - = ( []REAL a, REAL v )[]REAL: # return a with elements - v # - BEGIN - [ LWB a : UPB a ]REAL result; - FOR i FROM LWB a TO UPB a DO result[ i ] := v - a[ i ] OD; - result - END # - # ; - OP ^ = ( []REAL a, INT p )[]REAL: # return a with elements raised to p # - BEGIN - [ LWB a : UPB a ]REAL result; - FOR i FROM LWB a TO UPB a DO result[ i ] := a[ i ] ^ p OD; - result - END # |^ # ; - PRIO FMT = 1; - OP FMT = ( REAL v, INT d )STRING: # formats v with up to d decimals # - BEGIN - STRING result := fixed( v, -0, d ); - IF result[ LWB result ] = "." THEN "0" +=: result FI; - WHILE result[ UPB result ] = "0" DO result := result[ : UPB result - 1 ] OD; - IF result[ UPB result ] = "." THEN result := result[ : UPB result - 1 ] FI; - " " + result - END # FMT # ; - - # task # - - MODE NAMEDVALUE = STRUCT( STRING name, REAL value ); - - PROC mean = ( []REAL s )REAL: SUM s / LENGTH s; - - PROC variance = ( []REAL s, REAL d )REAL: mean( ( s - d ) ^ 2 ); - - PROC diversity theorem = ( REAL reference, []REAL observations )[]NAMEDVALUE: - BEGIN - REAL average = mean( observations ); - ( ( "average_error", variance( observations, reference ) ) - , ( "crowd_error", ( reference - average ) ^ 2 ) - , ( "diversity", variance( observations, average ) ) - ) - END # diversity theorem # ; - - PROC test = ( REAL reference, []REAL observations )VOID: - BEGIN - []NAMEDVALUE res = diversity theorem( reference, observations ); - FOR i FROM LWB res TO UPB res DO - print( ( 14 PAD name OF res[ i ], " : ", value OF res[ i ] FMT 6, newline ) ) - OD - END # test # ; - - test( 49, ( 48, 47, 51 ) ); - test( 49, ( 48, 47, 51, 42 ) ) - -END diff --git a/Task/Diversity-prediction-theorem/ANSI-BASIC/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/ANSI-BASIC/diversity-prediction-theorem.basic index fc652fbb06..1bffb0d693 100644 --- a/Task/Diversity-prediction-theorem/ANSI-BASIC/diversity-prediction-theorem.basic +++ b/Task/Diversity-prediction-theorem/ANSI-BASIC/diversity-prediction-theorem.basic @@ -1,12 +1,12 @@ 100 PROGRAM DiversityPredictionTheorem 110 OPTION BASE 0 -120 DIM test(1, 4) +120 DIM Estimates(1, 4) 130 FOR I = 0 TO 1 140 LET J = 0 -150 READ test(I, J) -160 DO WHILE test(I, J) <> 0 +150 READ Estimates(I, J) +160 DO WHILE Estimates(I, J) <> 0 170 LET J = J + 1 -180 READ test(I, J) +180 READ Estimates(I, J) 190 LOOP 200 NEXT I 210 DATA 48.0, 47.0, 51.0, 0.0 @@ -15,16 +15,16 @@ 240 FOR I = 0 TO 1 250 LET Sum = 0 260 LET J = 0 -270 DO WHILE test(I, J) <> 0 -280 LET Sum = Sum + (test(I, J) - TrueVal) ^ 2 +270 DO WHILE Estimates(I, J) <> 0 +280 LET Sum = Sum + (Estimates(I, J) - TrueVal) ^ 2 290 LET J = J + 1 300 LOOP 310 LET AvgErr = Sum / J 320 PRINT USING "Average error : ##.###": AvgErr 330 LET Sum = 0 340 LET J = 0 -350 DO WHILE test(I, J) <> 0 -360 LET Sum = Sum + test(I, J) +350 DO WHILE Estimates(I, J) <> 0 +360 LET Sum = Sum + Estimates(I, J) 370 LET J = J + 1 380 LOOP 390 LET Avg = Sum / J diff --git a/Task/Diversity-prediction-theorem/Ada/diversity-prediction-theorem.adb b/Task/Diversity-prediction-theorem/Ada/diversity-prediction-theorem.ada similarity index 100% rename from Task/Diversity-prediction-theorem/Ada/diversity-prediction-theorem.adb rename to Task/Diversity-prediction-theorem/Ada/diversity-prediction-theorem.ada diff --git a/Task/Diversity-prediction-theorem/Asymptote/diversity-prediction-theorem.asymptote b/Task/Diversity-prediction-theorem/Asymptote/diversity-prediction-theorem.asymptote deleted file mode 100644 index d76b741bc3..0000000000 --- a/Task/Diversity-prediction-theorem/Asymptote/diversity-prediction-theorem.asymptote +++ /dev/null @@ -1,31 +0,0 @@ -import math; - -real[][] estimates = { - {48, 47, 51}, - {48, 47, 51, 42} -}; - -real trueVal = 49; - -for (int i = 0; i < estimates.length; ++i) { - - real vari = 0; - real sum = 0; - - for (int j = 0; j < estimates[i].length; ++j) { - real d = estimates[i][j] - trueVal; - vari += d*d; - sum += estimates[i][j]; - } - - real n = estimates[i].length; - real avgErr = vari / n; - real refAvg = sum / n; - real crowdErr = (trueVal - refAvg)^2; - real div = avgErr - crowdErr; - - write("Average error : ", avgErr); - write(" Crowd error : ", crowdErr); - write(" Diversity : ", div); - write(""); -} diff --git a/Task/Diversity-prediction-theorem/Chipmunk-Basic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/Chipmunk-Basic/diversity-prediction-theorem.basic deleted file mode 100644 index 6c9a24f887..0000000000 --- a/Task/Diversity-prediction-theorem/Chipmunk-Basic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,28 +0,0 @@ -100 cls -110 dim estimates(1,5) -120 estimates(0,0) = 48 -130 estimates(0,1) = 47 -140 estimates(0,2) = 51 -150 estimates(1,0) = 48 -160 estimates(1,1) = 47 -170 estimates(1,2) = 51 -180 estimates(1,3) = 42 -190 trueval = 49 -200 for i = 0 to 1 -210 vari = 0 -220 sum = 0 -230 c = 0 -240 while estimates(i,c) <> 0 -250 vari = vari+(estimates(i,c)-trueval)^2 -260 sum = sum+estimates(i,c) -270 c = c+1 -280 wend -290 avgerr = vari/c -300 refavg = sum/c -310 crowderr = (trueval-refavg)^2 -320 print using "Average error : ###.###";avgerr -330 print using " Crowd error : ###.###";crowderr -340 print using " Diversity : ###.###";avgerr-crowderr -350 print -360 next i -370 end diff --git a/Task/Diversity-prediction-theorem/Crystal/diversity-prediction-theorem.cr b/Task/Diversity-prediction-theorem/Crystal/diversity-prediction-theorem.cr deleted file mode 100644 index e0d89e569a..0000000000 --- a/Task/Diversity-prediction-theorem/Crystal/diversity-prediction-theorem.cr +++ /dev/null @@ -1,22 +0,0 @@ -module Enumerable - def average - sum / size - end -end - -def get_values (true_value, crowd_estimates) - avg_individual_error = crowd_estimates.map {|e| (e - true_value)**2 }.average - collective_error = (crowd_estimates.average - true_value)**2 - crowd_avg = crowd_estimates.average - prediction_diversity = crowd_estimates.map {|e| (e - crowd_avg)**2 }.average - - { avg_individual_error, collective_error, prediction_diversity } -end - -puts "Value Crowd estimates Average error Crowd error Prediction diversity" -puts "---------------------------------------------------------------------------" - -[{49, [48, 47, 51]}, {49, [48, 47, 51, 42]}].each do |true_value, crowd_estimates| - printf " %2d %-20s %9.5f %9.5f %9.5f\n", true_value, crowd_estimates, - *get_values(true_value, crowd_estimates) -end diff --git a/Task/Diversity-prediction-theorem/Dart/diversity-prediction-theorem.dart b/Task/Diversity-prediction-theorem/Dart/diversity-prediction-theorem.dart deleted file mode 100644 index bd5382f318..0000000000 --- a/Task/Diversity-prediction-theorem/Dart/diversity-prediction-theorem.dart +++ /dev/null @@ -1,33 +0,0 @@ -double sum(List array) { - double s = 0; - for (var x in array) s += x; - return s; -} - -double square(double x) => x * x; - -double mean(List array) => sum(array) / array.length; - -double averageSquareDiff(double a, List predictions) { - List results = []; - for (var x in predictions) { - results.add(square(x - a)); - } - return mean(results); -} - -void diversityTheorem(double truth, List predictions) { - double avgErr = averageSquareDiff(truth, predictions); - double avg = mean(predictions); - double crowdErr = square(truth - avg); - double diversity = averageSquareDiff(avg, predictions); - - print("Average error: ${avgErr.toStringAsFixed(4)}"); - print(" Crowd error: ${crowdErr.toStringAsFixed(4)}"); - print(" Diversity: ${diversity.toStringAsFixed(4)}\n"); -} - -void main() { - diversityTheorem(49, [48, 47, 51]); - diversityTheorem(49, [48, 47, 51, 42]); -} diff --git a/Task/Diversity-prediction-theorem/Delphi/diversity-prediction-theorem.pas b/Task/Diversity-prediction-theorem/Delphi/diversity-prediction-theorem.delphi similarity index 100% rename from Task/Diversity-prediction-theorem/Delphi/diversity-prediction-theorem.pas rename to Task/Diversity-prediction-theorem/Delphi/diversity-prediction-theorem.delphi diff --git a/Task/Diversity-prediction-theorem/DuckDB/diversity-prediction-theorem.duckdb b/Task/Diversity-prediction-theorem/DuckDB/diversity-prediction-theorem.duckdb deleted file mode 100644 index 2cb2f486dd..0000000000 --- a/Task/Diversity-prediction-theorem/DuckDB/diversity-prediction-theorem.duckdb +++ /dev/null @@ -1,31 +0,0 @@ -create or replace function mean(lst) as ( - list_sum(lst)::DOUBLE / length(lst) -); - -# average absolute deviation relative to value -create or replace function aad(lst, value) as - list_transform(lst, x -> @(x-value)).list_sum() / length(lst) ; - -# average sum of squares -create or replace function ass(lst) as - list_transform(lst, x -> x ^ 2).list_sum() / length(lst); - -# Average sum of squared deviations relative to value -create or replace function asd(lst, value) as - list_transform(lst, x -> x - value).ass(); - -create or replace function diversitytheorem(actual, estimates) as table ( - select length(estimates) as "sample size", - actual as actual, - mean(estimates)::DECIMAL(4,2) as mean, - aad(estimates, actual)::DECIMAL(4,2) as "aad about actual", - aad(estimates, mean)::DECIMAL(4,2) as "aad about mean", - asd(estimates, actual)::DECIMAL(4,2) as "asd about actual", - asd(estimates, mean)::DECIMAL(4,2) as "asd about mean", - ((mean - actual) ^ 2)::DECIMAL(4,2) as "(mean-actual)^2" -); - -# The tasks: -from diversitytheorem(49, [48, 47, 51]) -union all -from diversitytheorem(49, [48, 47, 51, 42]); diff --git a/Task/Diversity-prediction-theorem/EasyLang/diversity-prediction-theorem.easy b/Task/Diversity-prediction-theorem/EasyLang/diversity-prediction-theorem.easy deleted file mode 100644 index 2993d3082c..0000000000 --- a/Task/Diversity-prediction-theorem/EasyLang/diversity-prediction-theorem.easy +++ /dev/null @@ -1,18 +0,0 @@ -proc calc TrueVal test[] . - for test in test[] - h = (test - TrueVal) - Vari += h * h - Sum += test - c += 1 - . - AvgErr = Vari / c - RefAvg = Sum / c - h = (TrueVal - RefAvg) - CrowdErr = h * h - print "Average error : " & AvgErr - print "Crowd error : " & CrowdErr - print "Diversity : " & AvgErr - CrowdErr - print "" -. -calc 49 [ 48 47 51 ] -calc 49 [ 48 47 51 42 ] diff --git a/Task/Diversity-prediction-theorem/Fortran/diversity-prediction-theorem.f b/Task/Diversity-prediction-theorem/Fortran/diversity-prediction-theorem.f deleted file mode 100644 index 1de6707869..0000000000 --- a/Task/Diversity-prediction-theorem/Fortran/diversity-prediction-theorem.f +++ /dev/null @@ -1,58 +0,0 @@ -! Diversity prediction theorem -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.10 -! GNU gfortran (Ubuntu 15.2.0-4ubuntu4) 15.2.0 on Kubuntu 25.10 -! VSI Fortran x86-64 V8.7-001 on OpenVMS V9.2-3 -program DivTheo - -implicit none -integer, parameter :: DP = 8 ! Kind for double precision Reals - -real (kind=DP), dimension(3), parameter :: Case1 =[48._DP,47._DP,51._DP] -real (kind=DP), dimension(4), parameter :: Case2 =[48._DP,47._DP,51._DP,42._DP] - - -call diversityTheorem (49._DP, case1, size(Case1)) -write (*,*) -call diversityTheorem (49._DP, case2, size(Case2)) - -contains -subroutine diversityTheorem (trueValue, predictions, n) -real (kind=DP), intent(in) :: trueValue -integer, intent(in) :: n -integer :: i -real (kind=DP), dimension(n), intent(in) :: predictions - -real (kind=DP) :: avPred - -avPred = sum(predictions,n) / n -! From the task desciption: -! show... -! the true value and the crowd estimates -! the average error -! the crowd error -! the prediction diversity -write (*, '("true value :", F4.0)') trueValue -write (*, '("crowd''s estimate :", 8F4.0)') (predictions(i),i=1,n) -write (*, '("average error :", F8.4 )') avSqDiff (trueValue, predictions, n) -write (*, '("crowd error :", F8.4 )') (trueValue - avPred) ** 2 -write (*, '("diversity :", F8.4 )') avSqDiff (avPred, predictions, n) -end subroutine diversityTheorem - - - -function avSqDiff (av, pred, n) result (sqDiff) - -integer, intent(in) :: n -real (kind=DP), intent(in) :: av -real (kind=DP), dimension(n), intent(in) :: pred -real (kind=DP) sqDiff -integer :: ii -sqDiff = 0 -do ii=1,n - sqdiff = sqdiff + (av-pred(ii))**2 -enddo -sqDiff = sqDiff / n - -end function avSqDiff - -end program DivTheo diff --git a/Task/Diversity-prediction-theorem/FreeBASIC/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/FreeBASIC/diversity-prediction-theorem.basic index 43b33a4ac2..2b67d7c69a 100644 --- a/Task/Diversity-prediction-theorem/FreeBASIC/diversity-prediction-theorem.basic +++ b/Task/Diversity-prediction-theorem/FreeBASIC/diversity-prediction-theorem.basic @@ -18,9 +18,9 @@ For i = 0 To 1 RefAvg = Sum / c CrowdErr = (TrueVal - RefAvg) ^2 - Print Using "Average error : ##.####"; AvgErr - Print Using " Crowd error : ##.####"; CrowdErr - Print Using " Diversity : ##.####"; AvgErr - CrowdErr + Print Using "Average error : ###.###"; AvgErr + Print Using " Crowd error : ###.###"; CrowdErr + Print Using " Diversity : ###.###"; AvgErr - CrowdErr Print Sleep diff --git a/Task/Diversity-prediction-theorem/FutureBasic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/FutureBasic/diversity-prediction-theorem.basic deleted file mode 100644 index 33e8b12ae8..0000000000 --- a/Task/Diversity-prediction-theorem/FutureBasic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,28 +0,0 @@ -include "NSLog.incl" - -double local fn Square( d as double ) -end fn = d * d - -double local fn AverageSquareDiff( d as double, predictions as CFArrayRef ) - double sum = 0.0 - for CFNumberRef num in predictions - sum += fn Square( fn NumberDoubleValue( num ) - d ) - next - return sum / fn ArrayCount( predictions ) -end fn = 0.0 - -CFStringRef local fn DiversityTheorem( truth as double, predictions as CFArrayRef ) - double average = fn NumberDoubleValue( fn ObjectValueForKeyPath( predictions, @"@avg.self" ) ) - CFStringRef avgErr = fn StringWithFormat( @"%4.5f", fn AverageSquareDiff( truth, predictions ) ) - CFStringRef crowdErr = fn StringWithFormat( @"%6.5f", fn Square( truth - average ) ) - CFStringRef diversity = fn StringWithFormat( @"%6.5f", fn AverageSquareDiff( average, predictions ) ) - return fn StringWithFormat( @"Average error : %@\nCrowd error : %@\nDiversity : %@\n", avgErr, crowdErr, diversity ) -end fn = NULL - -NSLog( @"Diversity prediction with crowd estimates of 48, 47 and 51:" ) -NSLog( @"%@\n", fn DiversityTheorem( 49.0, @[@48.0, @47.0, @51.0] ) ) - -NSLog( @"Diversity prediction with crowd estimates of 48, 47, 51 and 42:" ) -NSLog( @"%@\n", fn DiversityTheorem( 49.0, @[@48.0, @47.0, @51.0, @42.0] ) ) - -HandleEvents diff --git a/Task/Diversity-prediction-theorem/Gambas/diversity-prediction-theorem.gambas b/Task/Diversity-prediction-theorem/Gambas/diversity-prediction-theorem.gambas deleted file mode 100644 index 0c4b0f6e73..0000000000 --- a/Task/Diversity-prediction-theorem/Gambas/diversity-prediction-theorem.gambas +++ /dev/null @@ -1,39 +0,0 @@ -Public Sub Main() - - Dim test As New Float[2, 5] - - test[0, 0] = 48 - test[0, 1] = 47 - test[0, 2] = 51 - test[1, 0] = 48 - test[1, 1] = 47 - test[1, 2] = 51 - test[1, 3] = 42 - - Dim TrueVal As Float = 49 - Dim AvgErr As Float, CrowdErr As Float, RefAvg As Float - Dim Vari As Float, Sum As Float - Dim i As Integer, c As Integer - - For i = 0 To 1 - Vari = 0 - Sum = 0 - c = 0 - - While test[i, c] <> 0 - Vari += (test[i, c] - TrueVal) ^ 2 - Sum += test[i, c] - c += 1 - Wend - - AvgErr = Vari / c - RefAvg = Sum / c - CrowdErr = (TrueVal - RefAvg) ^ 2 - - Print "Average error : "; Format$(AvgErr, "##.###0") - Print " Crowd error : "; Format$(CrowdErr, "##.###0") - Print " Diversity : "; Format$(AvgErr - CrowdErr, "##.###0") - Print - Next - -End diff --git a/Task/Diversity-prediction-theorem/Julia/diversity-prediction-theorem.jl b/Task/Diversity-prediction-theorem/Julia/diversity-prediction-theorem.julia similarity index 100% rename from Task/Diversity-prediction-theorem/Julia/diversity-prediction-theorem.jl rename to Task/Diversity-prediction-theorem/Julia/diversity-prediction-theorem.julia diff --git a/Task/Diversity-prediction-theorem/Kotlin/diversity-prediction-theorem.kts b/Task/Diversity-prediction-theorem/Kotlin/diversity-prediction-theorem.kotlin similarity index 100% rename from Task/Diversity-prediction-theorem/Kotlin/diversity-prediction-theorem.kts rename to Task/Diversity-prediction-theorem/Kotlin/diversity-prediction-theorem.kotlin diff --git a/Task/Diversity-prediction-theorem/Loglan82/diversity-prediction-theorem.loglan82 b/Task/Diversity-prediction-theorem/Loglan82/diversity-prediction-theorem.loglan82 deleted file mode 100644 index 076c7fc72c..0000000000 --- a/Task/Diversity-prediction-theorem/Loglan82/diversity-prediction-theorem.loglan82 +++ /dev/null @@ -1,53 +0,0 @@ -program diverspredict; -(* Diversity prediction theorem *) - -var - true_val: real, - estims: arrayof arrayof real, - sum, avg, avg_err, crowd_err, diff: real, - i, j: integer; -begin - array estims dim (0 : 1); - for i := 0 to 1 - do - array estims(i) dim (0 : 4) - od; - - estims(0, 0) := 48.0; - estims(0, 1) := 47.0; - estims(0, 2) := 51.0; - estims(0, 3) := 0.0; - estims(0, 4) := 0.0; - estims(1, 0) := 48.0; - estims(1, 1) := 47.0; - estims(1, 2) := 51.0; - estims(1, 3) := 42.0; - estims(1, 4) := 0.0; - true_val := 49.0; - for i := 0 to 1 - do - sum := 0.0; - j := 0; - while estims(i, j) =/= 0 - do - diff := estims(i, j) - true_val; - sum := sum + diff * diff; - j := j + 1; - od; - avg_err := sum / j; - writeln("Average error : ", avg_err: 7: 3); - sum := 0; - j := 0; - while estims(i, j) =/= 0 - do - sum := sum + estims(i, j); - j := j + 1; - od; - avg := sum / j; - diff := true_val - avg; - crowd_err := diff * diff; - writeln("Crowd error : ", crowd_err: 7: 3); - writeln("Diversity : ", avg_err - crowd_err: 7: 3); - writeln; - od -end diff --git a/Task/Diversity-prediction-theorem/MSX-Basic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/MSX-Basic/diversity-prediction-theorem.basic deleted file mode 100644 index 6884ab01b3..0000000000 --- a/Task/Diversity-prediction-theorem/MSX-Basic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,33 +0,0 @@ -100 CLS -110 DIM TS!(1,4) -120 TS!(0,0) = 48 -130 TS!(0,1) = 47 -140 TS!(0,2) = 51 -170 TS!(1,0) = 48 -180 TS!(1,1) = 47 -190 TS!(1,2) = 51 -200 TS!(1,3) = 42 -220 EV! = 49 -230 FOR I = 0 TO 1 -240 VA! = 0 -250 SM! = 0 -260 N = 0 -270 C = 0 -280 IF TS!(I,C) = 0 THEN 340 -290 DF! = TS!(I,C) - EV! -300 VA! = VA! + EXP(LOG(ABS(DF!)) * 2) -310 SM! = SM! + TS!(I,C) -320 N = N + 1 -330 C = C + 1 : GOTO 280 -340 C = C - 1 -350 IF N = 0 THEN 440 ' por si acaso -360 AV! = VA!/N -370 RV! = SM!/N -380 DF! = EV!-RV! -390 CR! = EXP(LOG(ABS(DF!))*2) -400 PRINT USING "Average error : ##.####";AV! -410 PRINT USING " Crowd error : ##.####";CR! -420 PRINT USING " Diversity : ##.####";AV!-CR! -430 PRINT -440 NEXT -350 END diff --git a/Task/Diversity-prediction-theorem/Maxima/diversity-prediction-theorem.maxima b/Task/Diversity-prediction-theorem/Maxima/diversity-prediction-theorem.maxima deleted file mode 100644 index d25d8de345..0000000000 --- a/Task/Diversity-prediction-theorem/Maxima/diversity-prediction-theorem.maxima +++ /dev/null @@ -1,10 +0,0 @@ -diversityprediction(obs, ests) := block( - sprint("True value:", obs), newline(), - apply(sprint, cons("Estimates:", ests)), newline(), - sprint("Average error:", mean((obs-ests)^2)), newline(), - sprint("Crowd error:", (obs-mean(ests))^2), newline(), - sprint("Prediction diversity:", mean((mean(ests)-ests)^2)) -)$ - -diversityprediction(49, [48, 47, 51])$ -diversityprediction(49, [48, 47, 51, 42])$ diff --git a/Task/Diversity-prediction-theorem/Modula-2/diversity-prediction-theorem.mod2 b/Task/Diversity-prediction-theorem/Modula-2/diversity-prediction-theorem.mod2 deleted file mode 100644 index 38528dab9d..0000000000 --- a/Task/Diversity-prediction-theorem/Modula-2/diversity-prediction-theorem.mod2 +++ /dev/null @@ -1,48 +0,0 @@ -MODULE DiversPredict; -(* Diversity prediction theorem *) - -FROM STextIO IMPORT - WriteLn, WriteString; -FROM SRealIO IMPORT - WriteFixed; - -TYPE - TEstims = ARRAY [0 .. 1], [0 .. 4] OF REAL; -VAR - Estims: TEstims; - TrueVal, Sum, AvgErr, Avg, CrowdErr, Diff: REAL; - I, J: CARDINAL; -BEGIN - Estims := TEstims{{48.0, 47.0, 51.0, 0.0, 0.0}, - {48.0, 47.0, 51.0, 42.0, 0.0}}; - TrueVal := 49.0; - FOR I := 0 TO 1 DO - Sum := 0.0; - J := 0; - WHILE Estims[I, J] <> 0.0 DO - Diff := Estims[I, J] - TrueVal; - Sum := Sum + Diff * Diff; - J := J + 1; - END; - AvgErr := Sum / FLOAT(J); - WriteString("Average error: "); - WriteFixed(AvgErr, 3, 7); - WriteLn; - Sum := 0.0; - J := 0; - WHILE Estims[I, J] <> 0.0 DO - Sum := Sum + Estims[I, J]; - J := J + 1; - END; - Avg := Sum / FLOAT(J); - Diff := TrueVal - Avg; - CrowdErr := Diff * Diff; - WriteString("Crowd error : "); - WriteFixed(CrowdErr, 3, 7); - WriteLn; - WriteString("Diversity : "); - WriteFixed(AvgErr - CrowdErr, 3, 7); - WriteLn; - WriteLn; - END; -END DiversPredict. diff --git a/Task/Diversity-prediction-theorem/Nascom-BASIC/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/Nascom-BASIC/diversity-prediction-theorem.basic index a934c0e988..3136029ccc 100644 --- a/Task/Diversity-prediction-theorem/Nascom-BASIC/diversity-prediction-theorem.basic +++ b/Task/Diversity-prediction-theorem/Nascom-BASIC/diversity-prediction-theorem.basic @@ -1,5 +1,5 @@ 10 REM Diversity prediction theorem -20 DIM EST(1,4):REM test +20 DIM EST(1,4):REM Estimates 30 FOR I=0 TO 1 40 J=0:READ EST(I,J) 50 IF EST(I,J)=0 THEN 80 diff --git a/Task/Diversity-prediction-theorem/OxygenBasic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/OxygenBasic/diversity-prediction-theorem.basic deleted file mode 100644 index 6c4feeb2c1..0000000000 --- a/Task/Diversity-prediction-theorem/OxygenBasic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,37 +0,0 @@ -uses console - -dim float test(1, 4) -test(0,0) = 48 -test(0,1) = 47 -test(0,2) = 51 -test(1,0) = 48 -test(1,1) = 47 -test(1,2) = 51 -test(1,3) = 42 -test(1,4) = 0 - -dim float TrueVal = 49 -dim float AvgErr, CrowdErr, RefAvg, Vari, Sum -int i, c - -for i = 0 to 1 - Vari = 0 - Sum = 0 - c = 0 - while test(i,c) <> 0 - Vari += pow(test(i,c) - TrueVal) - Sum += test(i,c) - c += 1 - wend - AvgErr = Vari / c - RefAvg = Sum / c - CrowdErr = pow(TrueVal - RefAvg) - - printl "Average error : " AvgErr - printl " Crowd error : " CrowdErr - printl " Diversity : " AvgErr - CrowdErr - printl -next i - -printl cr "Enter ..." -waitkey diff --git a/Task/Diversity-prediction-theorem/PHP/diversity-prediction-theorem.php b/Task/Diversity-prediction-theorem/PHP/diversity-prediction-theorem.php deleted file mode 100644 index fb7d657c1f..0000000000 --- a/Task/Diversity-prediction-theorem/PHP/diversity-prediction-theorem.php +++ /dev/null @@ -1,33 +0,0 @@ - diff --git a/Task/Diversity-prediction-theorem/PL-I/diversity-prediction-theorem.pli b/Task/Diversity-prediction-theorem/PL-I/diversity-prediction-theorem.pli deleted file mode 100644 index 3dcf57be5b..0000000000 --- a/Task/Diversity-prediction-theorem/PL-I/diversity-prediction-theorem.pli +++ /dev/null @@ -1,36 +0,0 @@ -/* Diversity prediction theorem */ - -diversity_predict: - procedure options(main); - declare - true_val float binary(15) static initial(49.0), - estims(0 : 1, 0 : 4) float binary(15) - static initial(48.0, 47.0, 51.0, 0.0, 0.0, - 48.0, 47.0, 51.0, 42.0, 0.0), - (sum, avg, avg_err, crowd_err) float binary(24), - (i, j) fixed binary(15); - do i = 0 to 1; - sum = 0.0; - j = 0; - do while (estims(i, j) ~= 0); - sum = sum + ((estims(i, j) - true_val) * (estims(i, j) - true_val)); - j = j + 1; - end; - avg_err = sum / j; - put skip list('Average error : '); - put edit(avg_err)(f(6, 3)); - sum = 0; - j = 0; - do while (estims(i, j) ~= 0); - sum = sum + estims(i, j); - j = j + 1; - end; - avg = sum / j; - crowd_err = (true_val - avg) * (true_val - avg); - put skip list('Crowd error : '); - put edit(crowd_err)(f(6, 3)); - put skip list('Diversity : '); - put edit(avg_err - crowd_err)(f(6, 3)); - put skip list(''); - end; -end diversity_predict; diff --git a/Task/Diversity-prediction-theorem/Pascal-P/diversity-prediction-theorem.pas b/Task/Diversity-prediction-theorem/Pascal-P/diversity-prediction-theorem.pas deleted file mode 100644 index b473430016..0000000000 --- a/Task/Diversity-prediction-theorem/Pascal-P/diversity-prediction-theorem.pas +++ /dev/null @@ -1,46 +0,0 @@ -program diverspred(output); - - (* Diversity prediction theorem *) - -var - trueval, sum, avg, avgerr, crowderr: real; - estims: array [0 .. 1, 0 .. 4] of real; - i, j: integer; -begin - estims[0, 0] := 48.0; - estims[0, 1] := 47.0; - estims[0, 2] := 51.0; - estims[0, 3] := 0.0; - estims[0, 4] := 0.0; - estims[1, 0] := 48.0; - estims[1, 1] := 47.0; - estims[1, 2] := 51.0; - estims[1, 3] := 42.0; - estims[1, 4] := 0.0; - trueval := 49.0; - for i := 0 to 1 do - begin - sum := 0.0; - j := 0; - while estims[i, j] <> 0 do - begin - sum := sum + sqr(estims[i, j] - trueval); - j := j + 1; - end; - avgerr := sum / j; - writeln('Average error : ', avgerr: 10); - sum := 0; - j := 0; - while estims[i, j] <> 0 do - begin - sum := sum + estims[i, j]; - j := j + 1; - end; - avg := sum / j; - crowderr := sqr(trueval - avg); - writeln('Crowd error : ', crowderr: 10); - writeln('Diversity : ', avgerr - crowderr: 10); - writeln; - end; - (* readln; *) -end. diff --git a/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas b/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas deleted file mode 100644 index 972e2e8c39..0000000000 --- a/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas +++ /dev/null @@ -1,14 +0,0 @@ -## -function AverageSquareDiff(a: real; predictions: array of real) := - predictions.Select(x -> (x - a).Sqr).Average; - -procedure DiversityTheorem(truth: real; predictions: array of real); -begin - var average := predictions.Average; - WriteLn('average-error: ', AverageSquareDiff(truth, predictions)); - WriteLn('crowd-error: ', (truth - average).Sqr); - WriteLn('diversity: ', AverageSquareDiff(average, predictions)); -end; - -DiversityTheorem(49.0, [48.0, 47.0, 51.0]); -DiversityTheorem(49.0, [48.0, 47.0, 51.0, 42.0]) diff --git a/Task/Diversity-prediction-theorem/Pluto/diversity-prediction-theorem.pluto b/Task/Diversity-prediction-theorem/Pluto/diversity-prediction-theorem.pluto deleted file mode 100644 index 1d972f1fd2..0000000000 --- a/Task/Diversity-prediction-theorem/Pluto/diversity-prediction-theorem.pluto +++ /dev/null @@ -1,25 +0,0 @@ -local fmt = require "fmt" -require "table2" - -local function average_square_diff(f, preds) - local av = 0 - for preds as pred do av += (pred - f) * (pred - f) end - return av / #preds -end - -local function diversity_theorem(truth, preds) - local av = preds:mean() - local av_err = average_square_diff(truth, preds) - local crowd_err = (truth - av) * (truth - av) - local div = average_square_diff(av, preds) - return av_err, crowd_err, div -end - -local preds_list = { {48, 47, 51}, {48, 47, 51, 42} } -local truth = 49 -for preds_list as preds do - local av_err, crowd_err, div = diversity_theorem(truth, preds) - fmt.print("Average-error : %6.3f", av_err) - fmt.print("Crowd-error : %6.3f", crowd_err) - fmt.print("Diversity : %6.3f\n", div) -end diff --git a/Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem-1.py b/Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem-1.py deleted file mode 100644 index e4b11515ad..0000000000 --- a/Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem-1.py +++ /dev/null @@ -1,15 +0,0 @@ -def mean(lst): - return sum(lst)/len(lst) - -def squarediffs(x, lst): - return [(x-y)**2 for y in lst] - -def diversityprediction(obs, ests): - print("True value:", obs) - print("Estimates:", *ests) - print("Average error:", mean(squarediffs(obs, ests))) - print("Crowd error:", (obs-mean(ests))**2) - print("Prediction diversity:", mean(squarediffs(mean(ests), ests))) - -diversityprediction(49, [48, 47, 51]) -diversityprediction(49, [48, 47, 51, 42]) diff --git a/Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem-2.py b/Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem.py similarity index 100% rename from Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem-2.py rename to Task/Diversity-prediction-theorem/Python/diversity-prediction-theorem.py diff --git a/Task/Diversity-prediction-theorem/QBasic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/QBasic/diversity-prediction-theorem.basic deleted file mode 100644 index 874655f894..0000000000 --- a/Task/Diversity-prediction-theorem/QBasic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,29 +0,0 @@ -DIM test(0 TO 1, 0 TO 4) AS DOUBLE -test(0, 0) = 48! -test(0, 1) = 47! -test(0, 2) = 51! -test(1, 0) = 48! -test(1, 1) = 47! -test(1, 2) = 51! -test(1, 3) = 42! - -TrueVal = 49! - -FOR i = 0 TO 1 - Vari = 0! - Sum = 0! - c = 0 - WHILE test(i, c) <> 0 - Vari = Vari + (test(i, c) - TrueVal) ^ 2 - Sum = Sum + test(i, c) - c = c + 1 - WEND - AvgErr = Vari / c - RefAvg = Sum / c - CrowdErr = (TrueVal - RefAvg) ^ 2 - - PRINT USING "Average error : ##.####"; AvgErr - PRINT USING " Crowd error : ##.####"; CrowdErr - PRINT USING " Diversity : ##.####"; AvgErr - CrowdErr - PRINT -NEXT i diff --git a/Task/Diversity-prediction-theorem/QuickBASIC/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/QuickBASIC/diversity-prediction-theorem.basic index e35a3355d0..99ab57b239 100644 --- a/Task/Diversity-prediction-theorem/QuickBASIC/diversity-prediction-theorem.basic +++ b/Task/Diversity-prediction-theorem/QuickBASIC/diversity-prediction-theorem.basic @@ -1,11 +1,11 @@ REM Diversity prediction theorem -DIM test(1, 4) +DIM Estimates(1, 4) FOR I% = 0 TO 1 J% = 0 - READ test(I%, J%) - WHILE test(I%, J%) <> 0! + READ Estimates(I%, J%) + WHILE Estimates(I%, J%) <> 0! J% = J% + 1 - READ test(I%, J%) + READ Estimates(I%, J%) WEND NEXT I% DATA 48.0, 47.0, 51.0, 0.0 @@ -13,14 +13,14 @@ DATA 48.0, 47.0, 51.0, 42.0, 0.0 TrueVal = 49! FOR I% = 0 TO 1 Sum = 0!: J% = 0 - WHILE test(I%, J%) <> 0! - Sum = Sum + (test(I%, J%) - TrueVal) ^ 2: J% = J% + 1 + WHILE Estimates(I%, J%) <> 0! + Sum = Sum + (Estimates(I%, J%) - TrueVal) ^ 2: J% = J% + 1 WEND AvgErr = Sum / J% PRINT USING "Average error : ##.###"; AvgErr Sum = 0!: J% = 0 - WHILE test(I%, J%) <> 0! - Sum = Sum + test(I%, J%): J% = J% + 1 + WHILE Estimates(I%, J%) <> 0! + Sum = Sum + Estimates(I%, J%): J% = J% + 1 WEND Avg = Sum / J% CrowdErr = (TrueVal - Avg) ^ 2 diff --git a/Task/Diversity-prediction-theorem/Ruby/diversity-prediction-theorem.rb b/Task/Diversity-prediction-theorem/Ruby/diversity-prediction-theorem.rb index fb07cc9e10..5916702ef5 100644 --- a/Task/Diversity-prediction-theorem/Ruby/diversity-prediction-theorem.rb +++ b/Task/Diversity-prediction-theorem/Ruby/diversity-prediction-theorem.rb @@ -1,5 +1,5 @@ def mean(a) = a.sum(0.0) / a.size -def mean_square_diff(a, predictions) = mean(predictions.map { |x| (x - a)**2 }) +def mean_square_diff(a, predictions) = mean(predictions.map { |x| square(x - a)**2 }) def diversity_theorem(truth, predictions) average = mean(predictions) diff --git a/Task/Diversity-prediction-theorem/True-BASIC/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/True-BASIC/diversity-prediction-theorem.basic deleted file mode 100644 index 0ca506e3ca..0000000000 --- a/Task/Diversity-prediction-theorem/True-BASIC/diversity-prediction-theorem.basic +++ /dev/null @@ -1,27 +0,0 @@ -DIM test(0 to 1, 0 to 4) -LET test(0, 0) = 48.0 -LET test(0, 1) = 47.0 -LET test(0, 2) = 51.0 -LET test(1, 0) = 48.0 -LET test(1, 1) = 47.0 -LET test(1, 2) = 51.0 -LET test(1, 3) = 42.0 -LET trueval = 49.0 -FOR i = 0 to 1 - LET vari = 0.0 - LET sum = 0.0 - LET c = 0 - DO while test(i, c) <> 0 - LET vari = vari+(test(i, c)-trueval)^2 - LET sum = sum+test(i, c) - LET c = c+1 - LOOP - LET avgerr = vari/c - LET refavg = sum/c - LET crowderr = (trueval-refavg)^2 - PRINT using "Average error : ###.###": avgerr - PRINT using " Crowd error : ###.###": crowderr - PRINT using " Diversity : ###.###": avgerr-crowderr - PRINT -NEXT i -END diff --git a/Task/Diversity-prediction-theorem/Wren/diversity-prediction-theorem.wren b/Task/Diversity-prediction-theorem/Wren/diversity-prediction-theorem.wren index 991602f546..494c2bd1ad 100644 --- a/Task/Diversity-prediction-theorem/Wren/diversity-prediction-theorem.wren +++ b/Task/Diversity-prediction-theorem/Wren/diversity-prediction-theorem.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var averageSquareDiff = Fn.new { |f, preds| var av = 0 diff --git a/Task/Diversity-prediction-theorem/XBasic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/XBasic/diversity-prediction-theorem.basic deleted file mode 100644 index b96d40c2e3..0000000000 --- a/Task/Diversity-prediction-theorem/XBasic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,36 +0,0 @@ -PROGRAM "Diversity prediction theorem" -VERSION "0.0000" - -DECLARE FUNCTION Entry () - -FUNCTION Entry () - DIM test![1,4] - test![0, 0] = 48.0 - test![0, 1] = 47.0 - test![0, 2] = 51.0 - test![1, 0] = 48.0 - test![1, 1] = 47.0 - test![1, 2] = 51.0 - test![1, 3] = 42.0 - TrueVal! = 49.0 - - FOR i = 0 TO 1 - Vari! = 0.0 - Sum! = 0.0 - c = 0 - DO WHILE test![i, c] <> 0 - Vari! = Vari! + (test![i, c] - TrueVal!) ** 2 - Sum! = Sum! + test![i, c] - INC c - LOOP - AvgErr! = Vari! / c - RefAvg! = Sum! / c - CrowdErr! = (TrueVal! - RefAvg!) ** 2 - - PRINT "Average error : "; FORMAT$(STR$(AvgErr!), "##.###") - PRINT " Crowd error : "; FORMAT$(STR$(CrowdErr!), "##.###") - PRINT " Diversity : "; FORMAT$(STR$(AvgErr! - CrowdErr!), "##.###") - PRINT - NEXT i -END FUNCTION -END PROGRAM diff --git a/Task/Diversity-prediction-theorem/Yabasic/diversity-prediction-theorem.basic b/Task/Diversity-prediction-theorem/Yabasic/diversity-prediction-theorem.basic deleted file mode 100644 index 55f6e04847..0000000000 --- a/Task/Diversity-prediction-theorem/Yabasic/diversity-prediction-theorem.basic +++ /dev/null @@ -1,30 +0,0 @@ -dim test(1,4) -test(0,0) = 48.0 -test(0,1) = 47.0 -test(0,2) = 51.0 - -test(1,0) = 48.0 -test(1,1) = 47.0 -test(1,2) = 51.0 -test(1,3) = 42.0 - -TrueVal = 49.0 - -for i = 0 to 1 - Vari = 0.0 - Sum = 0.0 - c = 0 - while test(i,c) <> 0.0 - Vari = Vari + (test(i,c) - TrueVal) ^2 - Sum = Sum + test(i,c) - c = c + 1 - wend - AvgErr = Vari / c - RefAvg = Sum / c - CrowdErr = (TrueVal - RefAvg) ^2 - - print "Average error : ", AvgErr using("##.###") - print " Crowd error : ", CrowdErr using("##.###") - print " Diversity : ", AvgErr - CrowdErr using("##.###") - print -next i diff --git a/Task/Documentation/AWK/documentation.awk b/Task/Documentation/AWK/documentation.awk deleted file mode 100644 index f12f3545a5..0000000000 --- a/Task/Documentation/AWK/documentation.awk +++ /dev/null @@ -1,2 +0,0 @@ -# AWK doesn't support this construct, you will have to use comments. -# The hash symbol # starts a comment. It ends at EOL. diff --git a/Task/Documentation/Ada/documentation.adb b/Task/Documentation/Ada/documentation.ada similarity index 100% rename from Task/Documentation/Ada/documentation.adb rename to Task/Documentation/Ada/documentation.ada diff --git a/Task/Documentation/C++/documentation.cpp b/Task/Documentation/C++/documentation.cpp deleted file mode 100644 index 5298cffd6d..0000000000 --- a/Task/Documentation/C++/documentation.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Program Title: Rosetta Code, Documentation - * Author : John Doe - * Version : 0.1 - * Date : 2023/12/31 - * Copyright : Public domain - * Description : An example of C++ program documentation -*/ -#include -#include - -/* - * Calculates the area of a circle with the given radius - */ -double area_circle(const double& radius) { - return (std::numbers::pi * radius * radius); -} - -// Controls the program -int main() { - // Obtain the users input - double radius; - std::cout << "Enter the radius of a circle in centimetres: "; - std::cin >> radius; - - // Display the result - std::cout << "The area of the circle is " << area_circle(radius) << " cm\u00b2" << "\n"; -} diff --git a/Task/Documentation/COBOL/documentation-1.cob b/Task/Documentation/COBOL/documentation-1.cobol similarity index 100% rename from Task/Documentation/COBOL/documentation-1.cob rename to Task/Documentation/COBOL/documentation-1.cobol diff --git a/Task/Documentation/COBOL/documentation-2.cob b/Task/Documentation/COBOL/documentation-2.cobol similarity index 100% rename from Task/Documentation/COBOL/documentation-2.cob rename to Task/Documentation/COBOL/documentation-2.cobol diff --git a/Task/Documentation/Crystal/documentation.cr b/Task/Documentation/Crystal/documentation.crystal similarity index 100% rename from Task/Documentation/Crystal/documentation.cr rename to Task/Documentation/Crystal/documentation.crystal diff --git a/Task/Documentation/Delphi/documentation.pas b/Task/Documentation/Delphi/documentation.delphi similarity index 100% rename from Task/Documentation/Delphi/documentation.pas rename to Task/Documentation/Delphi/documentation.delphi diff --git a/Task/Documentation/DuckDB/documentation-1.duckdb b/Task/Documentation/DuckDB/documentation-1.duckdb deleted file mode 100644 index 6c629e36b7..0000000000 --- a/Task/Documentation/DuckDB/documentation-1.duckdb +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE t AS (SELECT unnest([])); -COMMENT ON TABLE t IS /* this is just an example */ 'foo bar'; -- ignore me - -select comment from duckdb_tables where table_name = 't'; diff --git a/Task/Documentation/DuckDB/documentation-2.duckdb b/Task/Documentation/DuckDB/documentation-2.duckdb deleted file mode 100644 index 4a22932f1c..0000000000 --- a/Task/Documentation/DuckDB/documentation-2.duckdb +++ /dev/null @@ -1 +0,0 @@ -COMMENT ON MACRO TABLE is ; diff --git a/Task/Documentation/DuckDB/documentation-3.duckdb b/Task/Documentation/DuckDB/documentation-3.duckdb deleted file mode 100644 index 09ed87c083..0000000000 --- a/Task/Documentation/DuckDB/documentation-3.duckdb +++ /dev/null @@ -1,3 +0,0 @@ -COMMENT ON TABLE main.test_table IS 'very nice table'; - -COMMENT ON COLUMN test_table.test_table_column IS 'very nice column'; diff --git a/Task/Documentation/Elixir/documentation-1.ex b/Task/Documentation/Elixir/documentation-1.elixir similarity index 100% rename from Task/Documentation/Elixir/documentation-1.ex rename to Task/Documentation/Elixir/documentation-1.elixir diff --git a/Task/Documentation/Elixir/documentation-2.ex b/Task/Documentation/Elixir/documentation-2.elixir similarity index 100% rename from Task/Documentation/Elixir/documentation-2.ex rename to Task/Documentation/Elixir/documentation-2.elixir diff --git a/Task/Documentation/Emacs-Lisp/documentation-1.el b/Task/Documentation/Emacs-Lisp/documentation-1.l similarity index 100% rename from Task/Documentation/Emacs-Lisp/documentation-1.el rename to Task/Documentation/Emacs-Lisp/documentation-1.l diff --git a/Task/Documentation/Emacs-Lisp/documentation-2.el b/Task/Documentation/Emacs-Lisp/documentation-2.l similarity index 100% rename from Task/Documentation/Emacs-Lisp/documentation-2.el rename to Task/Documentation/Emacs-Lisp/documentation-2.l diff --git a/Task/Documentation/Julia/documentation-1.jl b/Task/Documentation/Julia/documentation-1.julia similarity index 100% rename from Task/Documentation/Julia/documentation-1.jl rename to Task/Documentation/Julia/documentation-1.julia diff --git a/Task/Documentation/Julia/documentation-2.jl b/Task/Documentation/Julia/documentation-2.julia similarity index 100% rename from Task/Documentation/Julia/documentation-2.jl rename to Task/Documentation/Julia/documentation-2.julia diff --git a/Task/Documentation/Kotlin/documentation.kts b/Task/Documentation/Kotlin/documentation.kotlin similarity index 100% rename from Task/Documentation/Kotlin/documentation.kts rename to Task/Documentation/Kotlin/documentation.kotlin diff --git a/Task/Documentation/Phix/documentation.phix b/Task/Documentation/Phix/documentation.phix index fcc24396b9..d6302271c7 100644 --- a/Task/Documentation/Phix/documentation.phix +++ b/Task/Documentation/Phix/documentation.phix @@ -1,10 +1,12 @@ -procedure StoreVar(integer N, integer NTyp) --- --- Store a variable, applying any final operator as needed. --- If N is zero, PopFactor (ie store in a new temporary variable of --- the specified type). Otherwise N should be an index to symtab. --- If storeConst is 1, NTyp is ignored/overridden, otherwise it --- should usually be the declared or local type of N. --- - ... -end procedure +(phixonline)--> + procedure StoreVar(integer N, integer NTyp) + -- + -- Store a variable, applying any final operator as needed. + -- If N is zero, PopFactor (ie store in a new temporary variable of + -- the specified type). Otherwise N should be an index to symtab. + -- If storeConst is 1, NTyp is ignored/overridden, otherwise it + -- should usually be the declared or local type of N. + -- + ... + end procedure + Bool ) { - die unless @sol.all eq .any; - my BagHash $b .= new; - for @sol.keys -> $p1 { - given @sol[$p1] { - when 'L' { my $p2 = $p1+1; die unless @sol[$p2] eq 'R'; $b{ domino( @tab[$p1,$p2].join ) }++; } - when 'D' { my $p2 = $p1+$cols; die unless @sol[$p2] eq 'U'; $b{ domino( @tab[$p1,$p2].join ) }++; } - } - } - die unless $b.values.max == 1 and $b.elems == $rows * $cols / 2; - return True; -} -for @tests -> ( $rows, $cols, $flat_table ) { - my @solutions = solve($rows, $cols, $flat_table.comb); - say 'Solutions found: ', +@solutions; - - # Confirm that every solution is valid. - solution_works($rows, $cols, $flat_table.comb, $_) or die for @solutions; - - # Print first solution - say .join.trans( [] => [<╼ ╾ ╽ ╿>]) for @solutions[0].batch($cols); - - if ++$ == 1 { - say 'Bonus:'; - say .value.fmt("%45d "), .key.tclc for bonus($rows, $cols); - say ''; - } -} diff --git a/Task/Dominoes/Uiua/dominoes.uiua b/Task/Dominoes/Uiua/dominoes.uiua deleted file mode 100644 index fc73e2f14a..0000000000 --- a/Task/Dominoes/Uiua/dominoes.uiua +++ /dev/null @@ -1,29 +0,0 @@ -GridOne ← ↯7_∞"05132231055052464303662006235126113002452143346664515414" -GridTwo ← ↯7_∞"64220650162341432102355113505610426040114420536366525334" # 2025 solutions - -Offsets ← [1_0 0_1] -FirstFreeCell ← ⊢⬚1▽⤚(¬°⊚⨂)⊙◌↯∞_2°⊡⊃(⋅∘|∘) -# Get pair of cells for down- and right- facing dominos. -CandDoms ← ≡⌞⊂⟜(≡˜⊟⊸+Offsets˙⊟ FirstFreeCell) -# Is the tail-cell of each domino in bounds and not visited? -ValidDoms ← ↧⊃(¬˜∊°⊂⇌|≠@_⬚@_⊡⊣) -# Has this domino already been 'played'? -NotDupeDom ← ⨬(¬˜∊°⊂≡⍆↯∞_2⇌⊡|⋅1) ⊸(=2⧻) -# Find two possible next doms, check them, and step. -Nexts ← ▽⤚≡NotDupeDom▽◡≡ValidDoms⊙¤ ⊸CandDoms -Done ← =∩⧻⊙♭ - -# Add spaces to a solution grid, for MarkDominos to fill. -SpacedGrid ← ↘1↯[∞ ∘]÷2⧻⊸⊢≡⊂˜↯@\s⊸△≡/(⊂$"_ ") -MarkDominos ← ∧(⍜⊡⋅@+)≡(/+↯∞_2) ↯∞_4 - -Solve ← ( - ⟜SpacedGrid - °□⊣⊢path(≡□Nexts°□|Done°□)□[] # Show first solution. - MarkDominos -) -&p"Only solution for first grid:" -&s Solve GridOne -Count ← ⧻path(≡□Nexts°□|Done°□)□[] # Count all solutions. -&p"Count of solutions for second grid:" -Count GridTwo diff --git a/Task/Doomsday-rule/00-TASK.txt b/Task/Doomsday-rule/00-TASK.txt index 75b51e7e72..cfd6e09909 100644 --- a/Task/Doomsday-rule/00-TASK.txt +++ b/Task/Doomsday-rule/00-TASK.txt @@ -6,7 +6,7 @@ The algorithm was based on calculating the distance of a given date from certain "anchor days" which follow a pattern for the day of the week upon which they fall. ; Algorithm -The formula is calculated assuming that Sunday is 0, Monday 1, and so forth up to Saturday 6, and +The formula is calculated assuming that Sunday is 0, Monday 1, and so forth with Saturday 7, and doomsday = (Tuesday(or 2) + 5(y mod 4) + 4(y mod 100) + 6(y mod 400)) % 7 diff --git a/Task/Doomsday-rule/C-sharp/doomsday-rule.cs b/Task/Doomsday-rule/C-sharp/doomsday-rule.cs deleted file mode 100644 index da701dde47..0000000000 --- a/Task/Doomsday-rule/C-sharp/doomsday-rule.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; - -class Doom { - public static void Main(string[] args) { - Date[] dates = { - new Date(1800,1,6), - new Date(1875,3,29), - new Date(1915,12,7), - new Date(1970,12,23), - new Date(2043,5,14), - new Date(2077,2,12), - new Date(2101,4,2) - }; - - foreach (Date d in dates) - Console.WriteLine($"{d.Format()}: {d.Weekday()}"); - } -} - -class Date { - private int year, month, day; - - private static readonly int[] leapDoom = {4,1,7,4,2,6,4,1,5,3,7,5}; - private static readonly int[] normDoom = {3,7,7,4,2,6,4,1,5,3,7,5}; - public static readonly string[] weekdays = { - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" - }; - - public Date(int year, int month, int day) { - this.year = year; - this.month = month; - this.day = day; - } - - public bool IsLeapYear() { - return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); - } - - public string Format() { - return $"{month:00}/{day:00}/{year:0000}"; - } - - public string Weekday() { - int c = year / 100; - int r = year % 100; - int s = r / 12; - int t = r % 12; - - int cAnchor = (5 * (c % 4) + 2) % 7; - int doom = (s + t + t / 4 + cAnchor) % 7; - int anchor = - IsLeapYear() ? leapDoom[month - 1] : normDoom[month - 1]; - - return weekdays[(doom + day - anchor + 7) % 7]; - } -} diff --git a/Task/Doomsday-rule/C/doomsday-rule.c b/Task/Doomsday-rule/C/doomsday-rule.c index 66b4f73d16..01166bb55b 100644 --- a/Task/Doomsday-rule/C/doomsday-rule.c +++ b/Task/Doomsday-rule/C/doomsday-rule.c @@ -13,7 +13,7 @@ bool leap(uint16_t year) { } const char *weekday(Date date) { - static const uint8_t leapdoom[] = {4,1,7,4,2,6,4,1,5,3,7,5}; + static const uint8_t leapdoom[] = {4,1,7,2,4,6,4,1,5,3,7,5}; static const uint8_t normdoom[] = {3,7,7,4,2,6,4,1,5,3,7,5}; static const char *days[] = { "Sunday", "Monday", "Tuesday", "Wednesday", diff --git a/Task/Doomsday-rule/Draco/doomsday-rule.draco b/Task/Doomsday-rule/Draco/doomsday-rule.draco deleted file mode 100644 index 73e8211a33..0000000000 --- a/Task/Doomsday-rule/Draco/doomsday-rule.draco +++ /dev/null @@ -1,50 +0,0 @@ -type Date = struct { - word year; - byte month; - byte day; -}; - -proc leap_year(word y) bool: - y%4 = 0 and (y%100 /= 0 or y % 400 = 0) -corp - -proc weekday(Date date) *char: - [12]byte leapdoom = (4,1,7,4,2,6,4,1,5,3,7,5); - [12]byte normdoom = (3,7,7,4,2,6,4,1,5,3,7,5); - word c, r, s, t, c_anchor, doom, anchor; - - c := date.year / 100; - r := date.year % 100; - s := r / 12; - t := r % 12; - - c_anchor := (5 * (c % 4) + 2) % 7; - doom := (s + t + (t/4) + c_anchor) % 7; - anchor := if leap_year(date.year) - then leapdoom[date.month-1] - else normdoom[date.month-1] - fi; - - case (doom+date.day-anchor+7)%7 - incase 0: "Sunday" - incase 1: "Monday" - incase 2: "Tuesday" - incase 3: "Wednesday" - incase 4: "Thursday" - incase 5: "Friday" - incase 6: "Saturday" - esac -corp - -proc main() void: - [7]Date dates = ( - (1800,1,6), (1875,3,29), (1915,12,7), (1970,12,23), (2043,5,14), - (2077,2,12), (2101,4,2) - ); - - word d; - for d from 0 upto 6 do - writeln(dates[d].month:2, '/', dates[d].day:2, '/', dates[d].year:4, - ": ", weekday(dates[d])) - od -corp diff --git a/Task/Doomsday-rule/EasyLang/doomsday-rule.easy b/Task/Doomsday-rule/EasyLang/doomsday-rule.easy deleted file mode 100644 index e3313604c0..0000000000 --- a/Task/Doomsday-rule/EasyLang/doomsday-rule.easy +++ /dev/null @@ -1,24 +0,0 @@ -func leap year . - return if year mod 4 = 0 and (year mod 100 <> 0 or year mod 400 = 0) -. -func weekday year month day . - normdoom[] = [ 3 7 7 4 2 6 4 1 5 3 7 5 ] - c = year div 100 - r = year mod 100 - s = r div 12 - t = r mod 12 - c_anchor = (5 * (c mod 4) + 2) mod 7 - doom = (s + t + (t div 4) + c_anchor) mod 7 - anchor = normdoom[month] - if leap year = 1 and month <= 2 - anchor = (anchor + 1) mod1 7 - . - return (doom + day - anchor + 7) mod 7 + 1 -. -wkdays$[] = [ "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" ] -dates$[] = [ "1800-01-06" "1875-03-29" "1915-12-07" "1970-12-23" "2043-05-14" "2077-02-12" "2101-04-02" ] -for d$ in dates$[] - write d$ & " -> " - a[] = number strsplit d$ "-" - print wkdays$[weekday a[1] a[2] a[3]] -. diff --git a/Task/Doomsday-rule/Fortran/doomsday-rule.f b/Task/Doomsday-rule/Fortran/doomsday-rule.f deleted file mode 100644 index 7bfd36bf72..0000000000 --- a/Task/Doomsday-rule/Fortran/doomsday-rule.f +++ /dev/null @@ -1,208 +0,0 @@ - program someday ! Calculates the day that a week falls on - use datestuff - implicit none -! -! PARAMETER definitions -! - integer , parameter :: numdates = 7 -! -! Local variable declarations -! - character(30) , dimension(numdates) , save :: date_string - integer , dimension(numdates) , save :: day - character(9) , dimension(numdates) , save :: days - integer :: j - integer :: k - integer , dimension(numdates) , save :: month - integer , dimension(numdates) , save :: year -! - data days/'Monday ' , 'Tuesday ' , 'Wednesday' , 'Thursday ' , & - &'Friday ' , 'Saturday ' , 'Sunday '/ - data month/01 , 03 , 12 , 12 , 05 , 02 , 04/ - data day/06 , 29 , 07 , 23 , 14 , 12 , 02/ - data year/1800 , 1875 , 1915 , 1970 , 2043 , 2077 , 2101/ - data date_string/'1800-01-06 (January 6, 1800)' , & - &'1875-03-29 (March 29, 1875)' , '1915-12-07 (December 7, 1915)' ,& - &'1970-12-23 (December 23, 1970)' , '2043-05-14 (May 14, 2043)' , & - &'2077-02-12 (February 12, 2077)' , '2101-04-02 (April 2, 2101)'/ ! -!*Code - - print * - do j = 1 , numdates - k = get_the_day(day(j) , month(j) , year(j)) - print '(a, t31,1a1,1x,a)' , date_string(j) , ':' , days(k) - end do - end program someday - module datestuff - implicit none - public :: get_the_day - private :: get_anchor_day , gregorian_leap_year -! - enum , bind(c) ! Use enums to get greater clarity in the code - enumerator :: january = 1 , february , march , april , may , & - & june , july , august , september , october , november ,& - & december - end enum - enum , bind(c) - enumerator :: sunday = 0 , monday , tuesday , wednesday , & - & thursday , friday , saturday - end enum - contains -! - pure function gregorian_leap_year(year) result(answer) ! Tests if the year is a leap year -! -! Function and Dummy argument declarations -! - logical :: answer - integer , intent(in) :: year -! - answer = .false. ! Set default to not a leap year - if( mod(year , 4)==0 )answer = .true. ! Year divisible by 4 = leap year - if( mod(year , 100)==0 )then - if( mod(year , 400)==0 )then ! Year divisible by 400 = century year that is leap year - answer = .true. - else - answer = .false. ! Century years are not leap years - end if - end if - end function gregorian_leap_year -! - pure function get_anchor_day(year) result(answer) ! Returns Anchor Days in doomsday calculation -!Note: The days start as Monday = 1, Tuesday =2, etc until Sunday = 7 -!The Doomsday rule, Doomsday algorithm or Doomsday method is an algorithm of determination of the day of the week for a given date. -!It provides a perpetual calendar because the Gregorian calendar moves in cycles of 400 years. -!It takes advantage of each year having a certain day of the week upon which certain easy-to-remember dates, -!called the doomsdays, fall; for example, the last day of February, 4/4, 6/6, 8/8, 10/10, and 12/12 all occur -! on the same day of the week in any year. Applying the Doomsday algorithm involves three steps: Determination of the anchor day -! for the century, calculation of the anchor day for the year from the one for the century, and selection of the closest date -! out of those that always fall on the doomsday, e.g., 4/4 and 6/6, and count of the number of days (modulo 7) between that -! date and the date in question to arrive at the day of the week. The technique applies to both the Gregorian calendar and the -! Julian calendar, although their doomsdays are usually different days of the week. -! -! Function and Dummy argument declarations -! - integer :: answer - integer , intent(in) :: year -! -! Local variable declarations -! - integer :: diffyear - integer :: div12 - integer :: numyears - integer :: temp1 -! -! End of declarations -!*Code - numyears = mod(year , 100) ! Get number of years greater than century - - temp1 = year - numyears ! Turn into a century year - temp1 = mod(temp1 , 400) ! Now mod 400 to get base year for anchor day - select case(temp1) ! Select the base day - case(0) - answer = tuesday - case(100) - answer = sunday - case(200) - answer = friday - case(300) - answer = wednesday - case default ! Anything else is an error - ERROR Stop 'Bad Anchor Day' ! Finish with error - end select - ! - !Calculate the doomsday of any given year - ! - div12 = int(numyears/12) ! Get number of times 12 goes into year - temp1 = mod(numyears , 12) ! Get the remainer - diffyear = int(temp1/4) ! Div 4 (magic algorithm) - answer = diffyear + div12 + answer + temp1 - answer = mod(answer , 7) - end function get_anchor_day ! Note: The days start as Sunday = 0, Monday = 1, Tuesday =2, etc until Saturda -! - pure function get_the_day(day , month , year) result(answer) -! Note: The days start as Sunday = 0, Monday = 1, Tuesday =2, etc until Saturday = 6 -! -! Function and Dummy argument declarations - integer :: answer - integer , intent(in) :: day - integer , intent(in) :: month - integer , intent(in) :: year -! -! Local variable declarations - integer :: closest - integer :: doomsday - integer :: temp1 - integer :: temp2 - integer :: up_or_down -! -! End of declarations -! - ! There are doomsdays in every month, so we know what month it is ... - ! We need to find the doomsday in the relevant month - select case(month) ! Scratch Variables - case(january) - closest = merge(4,3,gregorian_leap_year(year)) ! Use merge as a ternary - case(february) - closest = merge(29,28,gregorian_leap_year(year)) ! Use merge as a ternary - case(march) - closest = 7 - case(april) - closest = 4 - case(may) - closest = 9 - case(june) - closest = 6 - case(july) - temp1 = abs(4 - day) - temp2 = abs(11 - day) - closest = merge(4,11,temp1day )then - up_or_down = -7 - else if( closest0 )then - do while ( temp1<=day ) - temp2 = temp1 - temp1 = temp1 + up_or_down ! Count in sevens to the final - end do - temp1 = day - temp2 - temp1 = (doomsday + 7) + temp1 - else if( up_or_down<0 )then - do while ( temp1>=day ) - temp2 = temp1 - temp1 = temp1 + up_or_down ! Count in sevens to the final - end do - temp1 = temp2 - day ! See how far away I am from this day - temp1 = (doomsday + 7) - temp1 ! Subtract the difference in days from the known doomsday - else - temp1 = doomsday ! It fell on the doomsday - end if - answer = mod(temp1 , 7) ! Turn Sundays into Zeros - end function get_the_day -! - end module datestuff - ! diff --git a/Task/Doomsday-rule/JavaScript/doomsday-rule.js b/Task/Doomsday-rule/JavaScript/doomsday-rule.js deleted file mode 100644 index bd59065f59..0000000000 --- a/Task/Doomsday-rule/JavaScript/doomsday-rule.js +++ /dev/null @@ -1,52 +0,0 @@ -// doom.js -const LEAP_DOOM = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]; -const NORM_DOOM = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]; -const WEEKDAYS = [ - 'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thursday', 'Friday', 'Saturday' -]; - -class Date { - constructor(year, month, day) { - this.year = year; - this.month = month; // 1-based - this.day = day; - } - - isLeapYear() { - const y = this.year; - return y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0); - } - - format() { - const { month, day, year } = this; - return `${String(month).padStart(2, '0')}/${String(day).padStart(2, '0')}/${year}`; - } - - weekday() { - const { year, month, day } = this; - const c = Math.floor(year / 100); - const r = year % 100; - const s = Math.floor(r / 12); - const t = r % 12; - - const cAnchor = (5 * (c % 4) + 2) % 7; - const doom = (s + t + Math.floor(t / 4) + cAnchor) % 7; - const anchor = (this.isLeapYear() ? LEAP_DOOM : NORM_DOOM)[month - 1]; - - return WEEKDAYS[(doom + day - anchor + 7) % 7]; - } -} - -/* ---------- demo ---------- */ -const dates = [ - new Date(1800, 1, 6), - new Date(1875, 3, 29), - new Date(1915, 12, 7), - new Date(1970, 12, 23), - new Date(2043, 5, 14), - new Date(2077, 2, 12), - new Date(2101, 4, 2) -]; - -dates.forEach(d => console.log(`${d.format()}: ${d.weekday()}`)); diff --git a/Task/Doomsday-rule/Julia/doomsday-rule.jl b/Task/Doomsday-rule/Julia/doomsday-rule.julia similarity index 100% rename from Task/Doomsday-rule/Julia/doomsday-rule.jl rename to Task/Doomsday-rule/Julia/doomsday-rule.julia diff --git a/Task/Doomsday-rule/M2000-Interpreter/doomsday-rule.m2000 b/Task/Doomsday-rule/M2000-Interpreter/doomsday-rule.m2000 deleted file mode 100644 index bc2bab76ac..0000000000 --- a/Task/Doomsday-rule/M2000-Interpreter/doomsday-rule.m2000 +++ /dev/null @@ -1,60 +0,0 @@ -' MAKE USING("FORMAT STRING", PAR1, PAR2, ...PARN) -' WE USE READ V TO READ MORE PARAMETERS. -FUNCTION USING(A$) { - VARIANT V : LONG D, S, E, I=1: S$="" - WHILE I<=LEN(A$) - IF S THEN - IF MID$(A$,I,1)<>"#" THEN - IF MID$(A$,I,1)="." THEN D=I ELSE E=I - END IF - ELSE - IF MID$(A$,I,1)="#" THEN S=I - END IF - IF S AND E THEN - IF S>1 THEN S$+=LEFT$(A$, S-1) - A$=MID$(A$, E) - G() - S=0:E=0:D=0 - I=1 - END IF - I++ - END WHILE - IF S THEN - IF S>1 THEN S$+=LEFT$(A$, S-1):E=I-S+1: S=1 ELSE E=I - G() - =S$ - ELSE - =S$+A$ - END IF - SUB G() - IF ISNUM THEN - READ V - IF D>0 THEN - S$+=STR$(V, STRING$("#",E-D-1)+"0."+STRING$("0",D-S+1)) - ELSE - S$+=STR$(V, STRING$("0",E-S-1)+"0") - END IF - ELSE - V="" - READ V - S$+=LEFT$(V+STRING$(" ", E-S), E-S) - END IF - END SUB -} -05 FLUSH : GOSUB 110 -10 DIM D$(1 TO 7): FOR I=1 TO 7: READ D$(I): NEXT I -20 DIM D(1 TO 12, 0 TO 1): FOR I=0 TO 1: FOR J=1 TO 12: READ D(J, I): NEXT J : NEXT I -30 READ Y: IF Y=0 THEN BREAK ELSE READ M,D -40 PRINT USING("##/##/#### ", M, D, Y); -50 C=Y DIV 100: R=Y MOD 100 -60 S=R DIV 12: T=R MOD 12 -70 A=(5*BINARY.AND(C, 3)+2) MOD 7 -80 B=(S+T+(T DIV 4)+A) MOD 7 -90 PRINT D$((B+D-D(M,-(Y MOD 4=0 AND (Y MOD 100<>0 OR Y MOD 400=0)))+7) MOD 7+1) -100 GOTO 30 -110 DATA "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" -120 DATA 3,7,7,4,2,6,4,1,5,3,7,5 -130 DATA 4,1,7,4,2,6,4,1,5,3,7,5 -140 DATA 1800,1,6,1875,3,29,1915,12,7,1970,12,23 -150 DATA 2043,5,14,2077,2,12,2101,4,2,0 -160 RETURN diff --git a/Task/Doomsday-rule/Mathematica/doomsday-rule.math b/Task/Doomsday-rule/Mathematica/doomsday-rule.math deleted file mode 100644 index 45a6d46d9e..0000000000 --- a/Task/Doomsday-rule/Mathematica/doomsday-rule.math +++ /dev/null @@ -1,13 +0,0 @@ -doomsday[year_Integer?Positive] := Mod[2 + 5 Mod[year, 4] + 4 Mod[year, 100] + 6 Mod[year, 400], 7]; - -firstDoomsday[month_Integer /; 1 <= month <= 2, year_Integer?Positive /; LeapYearQ[{year}]] := {4, 1}[[month]]; -firstDoomsday[month_Integer /; 1 <= month <= 2, year_Integer?Positive] := {3, 7}[[month]]; -firstDoomsday[month_Integer /; 3 <= month <= 12, year_Integer?Positive] := {7, 4, 2, 6, 4, 1, 5, 3, 7, 5}[[month - 2]]; - -weekday[{year_Integer?Positive, month_Integer?Positive /; 1 <= month <= 12, day_Integer?Positive /; 1 <= day <= 31}] := Mod[doomsday[year] + 7 + day - firstDoomsday[month, year], 7]; - -weekdayName[weekday_Integer /; 0 <= weekday <= 6] := {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}[[weekday + 1]]; - -dates = {{1800, 1, 6}, {1875, 3, 29}, {1915, 12, 7}, {1970, 12, 23}, {2043, 5, 14}, {2077, 2, 12}, {2101, 4, 2}}; - -weekdayName /@ weekday /@ dates diff --git a/Task/Doomsday-rule/Maxima/doomsday-rule.maxima b/Task/Doomsday-rule/Maxima/doomsday-rule.maxima deleted file mode 100644 index 1fd7bccc28..0000000000 --- a/Task/Doomsday-rule/Maxima/doomsday-rule.maxima +++ /dev/null @@ -1,15 +0,0 @@ -daynames: ["Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", "Saturday"]$ - -isleapyear(y) := mod(y, 4)=0 and (mod(y, 100)#0 or mod(y, 400)=0)$ -anchors(y) := [if isleapyear(y) then 4 else 3, - if isleapyear(y) then 1 else 7, - 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]$ - -doomsday(y) := mod(2+5*mod(y, 4)+4*mod(y, 100)+6*mod(y, 400), 7)$ -wd(y, m, d) := mod(doomsday(y)+d-anchors(y)[m], 7)$ - -test_dates: [[1800, 1, 6], [1875, 3, 29], [1915, 12, 7], [1970, 12, 23], [2043, 5, 14], [2077, 2, 12], [2101, 4, 2]]$ - -raw_wds: map(lambda([l], apply(wd, l)), test_dates)$ -for i in raw_wds do(sprint(daynames[i+1]))$ diff --git a/Task/Doomsday-rule/Miranda/doomsday-rule.miranda b/Task/Doomsday-rule/Miranda/doomsday-rule.miranda deleted file mode 100644 index de3b570449..0000000000 --- a/Task/Doomsday-rule/Miranda/doomsday-rule.miranda +++ /dev/null @@ -1,29 +0,0 @@ -main :: [sys_message] -main = [Stdout (lay [showdate d ++ ": " ++ weekday d | d<-tests])] - -date ::= Date (num,num,num) - -showdate :: date->[char] -showdate (Date (y,m,d)) = show m ++ "/" ++ show d ++ "/" ++ show y - -tests :: [date] -tests = map Date [ - (1800,1,6), (1875,3,29), (1915,12,7), (1970,12,23), (2043,5,14), - (2077,2,12), (2101,4,2)] - -weekday :: date->[char] -weekday (Date (year,month,day)) - = weekdays ! daynum - where weekdays = ["Sunday","Monday","Tuesday","Wednesday","Thursday", - "Friday","Saturday"] - doomtab = leapdoom, if leapyear - = normdoom, otherwise - leapdoom = [4,1,7,2,4,6,4,1,5,3,7,5] - normdoom = [3,7,7,4,2,6,4,1,5,3,7,5] - leapyear = year mod 4=0 & (year mod 100~=0 \/ year mod 400=0) - (c, r) = (year div 100, year mod 100) - (s, t) = (r div 12, r mod 12) - c_anchor = (5 * (c mod 4) + 2) mod 7 - doom = (s + t + t div 4 + c_anchor) mod 7 - anchor = doomtab ! (month - 1) - daynum = (doom + day - anchor + 7) mod 7 diff --git a/Task/Doomsday-rule/PascalABC.NET/doomsday-rule.pas b/Task/Doomsday-rule/PascalABC.NET/doomsday-rule.pas deleted file mode 100644 index 2f45724a97..0000000000 --- a/Task/Doomsday-rule/PascalABC.NET/doomsday-rule.pas +++ /dev/null @@ -1,26 +0,0 @@ -const - days: array of string = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); - dooms: array of array of integer = ((3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5), - (4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5)); - -function isleap(year: integer) := (year mod 4 = 0) and ((year mod 100 <> 0) or (year mod 400 = 0)); - -function weekday(year, month, day: integer): string; -begin - var c := year div 100; - var r := year mod 100; - var s := r div 12; - var t := r mod 12; - var c_anchor := (5 * (c mod 4) + 2) mod 7; - var doomsday := (s + t + (t div 4) + c_anchor) mod 7; - var anchorday := dooms[if isleap(year) then 1 else 0][month - 1]; - var weekday := (doomsday + day - anchorday + 7) mod 7; - result := days[weekday]; -end; - -begin - var dates := |(1800, 1, 6), (1875, 3, 29), (1915, 12, 7), (1970, 12, 23), - (2043, 5, 14), (2077, 2, 12), (2101, 4, 2)|; - foreach var d in dates do - writeln(d[0], '-', d[1]:2, '-', d[2]:2, ' -> ', weekday(d[0], d[1], d[2])); -end. diff --git a/Task/Doomsday-rule/Pluto/doomsday-rule.pluto b/Task/Doomsday-rule/Pluto/doomsday-rule.pluto deleted file mode 100644 index 8ce12b27df..0000000000 --- a/Task/Doomsday-rule/Pluto/doomsday-rule.pluto +++ /dev/null @@ -1,42 +0,0 @@ -local fmt = require "fmt" - -local anchor_day = |y| -> (2 + 5 * (y % 4) + 4 *(y % 100) + 6 * (y % 400)) % 7 - -local is_leap_year = |y| -> y % 4 == 0 and (y % 100 != 0 or y % 400 == 0) - -local first_days_common = {3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5} -local first_days_leap = {4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5} - -local dates = { - "1800-01-06", - "1875-03-29", - "1915-12-07", - "1970-12-23", - "2043-05-14", - "2077-02-12", - "2101-04-02" -} - -local function parse(date) - local y = tonumber(date:sub(1, 4)) - local m = tonumber(date:sub(6, 7)) - local d = tonumber(date:sub(9, 10)) - return y, m, d -end - -print("Days of week given by Doomsday rule:") -for dates as date do - local y, m, d = parse(date) - local a = anchor_day(y) - local w = d - (is_leap_year(y) ? first_days_leap[m] : first_days_common[m]) - if w < 0 then w += 7 end - local dow = (a + w) % 7 - print($"{date} -> {fmt.weekday(dow)}") -end - -print("\nDays of week given by standard library functions:") -for dates as date do - local y, m, d = parse(date) - local t = os.time({year = y, month = m, day = d}) - print($"{date} -> {os.date("%A", t)}") -end diff --git a/Task/Doomsday-rule/Quackery/doomsday-rule.quackery b/Task/Doomsday-rule/Quackery/doomsday-rule.quackery deleted file mode 100644 index 5dfa5b0e1d..0000000000 --- a/Task/Doomsday-rule/Quackery/doomsday-rule.quackery +++ /dev/null @@ -1,26 +0,0 @@ - [ dup 400 mod 0 = iff [ drop true ] done - dup 100 mod 0 = iff [ drop false ] done - 4 mod 0 = ] is leap ( y --> b ) - - [ dup 4 mod 5 * - over 100 mod 4 * + - swap 400 mod 6 * + 2 + 7 mod ] is doomsday ( y --> n ) - - [ leap iff [ ' [ table 0 4 1 ] ] - else [ ' [ table 0 3 7 ] ] - ' [ 7 4 2 6 4 1 5 3 7 5 ] join do ] is close ( m y --> n ) - - [ dup doomsday unrot close - + 7 mod ] is weekday ( d m y --> n ) - - [ [ table $ "Sunday" $ "Monday" - $ "Tuesday" $ "Wednesday" $ "Thursday" - $ "Friday" $ "Saturday" ] do echo$ ] is echoday ( d --> ) - - ' [ [ 6 1 1800 ] - [ 29 3 1875 ] - [ 7 12 1915 ] - [ 23 12 1970 ] - [ 14 5 2043 ] - [ 12 2 2077 ] - [ 2 4 2101 ] ] - witheach [ unpack weekday echoday cr ] diff --git a/Task/Doomsday-rule/R/doomsday-rule.r b/Task/Doomsday-rule/R/doomsday-rule.r deleted file mode 100644 index 9106214930..0000000000 --- a/Task/Doomsday-rule/R/doomsday-rule.r +++ /dev/null @@ -1,22 +0,0 @@ -daynames <- c("Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday") - -isleapyear <- function(y) (y%%4==0)&((y%%100!=0)|(y%%400==0)) - -anchors <- function(y) c(ifelse(isleapyear(y), 4, 3), - ifelse(isleapyear(y), 1, 7), - 7, 4, 2, 6, 4, 1, 5, 3, 7, 5) - -doomsday <- function(y) (2+5*(y%%4)+4*(y%%100)+6*(y%%400))%%7 -wd <- function(y, m, d) (doomsday(y)+d-anchors(y)[m])%%7 - -test_dates <- list(c(1800, 1, 6), - c(1875, 3, 29), - c(1915, 12, 7), - c(1970, 12, 23), - c(2043, 5, 14), - c(2077, 2, 12), - c(2101, 4, 2)) - -raw_wds <- sapply(test_dates, function(v) do.call(wd, as.list(v))) -cat(daynames[raw_wds+1], "\n") diff --git a/Task/Doomsday-rule/Refal/doomsday-rule.refal b/Task/Doomsday-rule/Refal/doomsday-rule.refal deleted file mode 100644 index 611e530466..0000000000 --- a/Task/Doomsday-rule/Refal/doomsday-rule.refal +++ /dev/null @@ -1,43 +0,0 @@ -$ENTRY Go { - , (1800 1 6) (1875 3 29) (1915 12 7) (1970 12 23) - (2043 5 14) (2077 2 12) (2101 4 2): e.Tests - = ; -}; - -Test { - e.Test = >; -}; - -LeapYear { - s.Year = > - > - >>>; -}; - -Weekday { - s.Year s.Month s.Day, - 4 1 7 4 2 6 4 1 5 3 7 5: e.LeapDoom, - 3 7 7 4 2 6 4 1 5 3 7 5: e.NormDoom, - Sunday Monday Tuesday Wednesday Thursday Friday Saturday: e.Days, - : (s.C) s.R, - : (s.S) s.T, - >> 7>: s.CAn, - >>> 7>: s.Doom, - (e.LeapDoom) (e.NormDoom)>: (e.DoomTab), - e.DoomTab>: e.Anchor, - e.Anchor>> 7>: s.Weekday - = ; -}; - -Item { - 0 s.X e.XS = s.X; - s.N s.X e.XS = e.XS>; -}; - -If { True t.T t.F = t.T; False t.T t.F = t.F; }; -Eq { t.X t.X = True; t.X t.Y = False; }; -Or { True s.Y = True; False s.Y = s.Y; }; -And { False s.Y = False; True s.Y = s.Y; }; -Not { True = False; False = True; }; -Neq { t.X t.Y = >; }; -Each { (e.F) = ; (e.F) (e.X) e.XS = ; }; diff --git a/Task/Doomsday-rule/Rust/doomsday-rule.rs b/Task/Doomsday-rule/Rust/doomsday-rule.rust similarity index 100% rename from Task/Doomsday-rule/Rust/doomsday-rule.rs rename to Task/Doomsday-rule/Rust/doomsday-rule.rust diff --git a/Task/Doomsday-rule/SETL/doomsday-rule.setl b/Task/Doomsday-rule/SETL/doomsday-rule.setl deleted file mode 100644 index cf225f497f..0000000000 --- a/Task/Doomsday-rule/SETL/doomsday-rule.setl +++ /dev/null @@ -1,29 +0,0 @@ -program doomsday; - tests := [[1800,1,6], [1875,3,29], [1915,12,7], [1970,12,23], - [2043,5,14], [2077,2,12], [2101,4,2]]; - - loop for [year, month, day] in tests do - print(str day + "/" + str month + "/" + str year + ": " + - weekday(year, month, day)); - end loop; - - proc leap(y); - return y mod 4 = 0 and (y mod 100 /= 0 or y mod 400 = 0); - end proc; - - proc weekday(year, month, day); - leapdoom := [4,1,7,4,2,6,4,1,5,3,7,5]; - normdoom := [3,7,7,4,2,6,4,1,5,3,7,5]; - weekdays := ["Sunday","Monday","Tuesday","Wednesday","Thursday", - "Friday","Saturday"]; - - c := year div 100; - r := year mod 100; - s := r div 12; - t := r mod 12; - c_anchor := (5 * (c mod 4) + 2) mod 7; - doom := (s + t + (t div 4) + c_anchor) mod 7; - anchor := if leap(year) then leapdoom else normdoom end(month); - return weekdays((doom+day-anchor+7) mod 7+1); - end proc; -end program; diff --git a/Task/Doomsday-rule/Scala/doomsday-rule.scala b/Task/Doomsday-rule/Scala/doomsday-rule.scala deleted file mode 100644 index b2d3a46d05..0000000000 --- a/Task/Doomsday-rule/Scala/doomsday-rule.scala +++ /dev/null @@ -1,40 +0,0 @@ -object Doom extends App { - val dates = Array( - new Date(1800, 1, 6), - new Date(1875, 3, 29), - new Date(1915, 12, 7), - new Date(1970, 12, 23), - new Date(2043, 5, 14), - new Date(2077, 2, 12), - new Date(2101, 4, 2) - ) - - dates.foreach(d => println(s"${d.format}: ${d.weekday}")) -} - -class Date(val year: Int, val month: Int, val day: Int) { - import Date._ - - def isLeapYear: Boolean = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) - - def format: String = f"$month%02d/$day%02d/$year%04d" - - def weekday: String = { - val c = year / 100 - val r = year % 100 - val s = r / 12 - val t = r % 12 - - val cAnchor = (5 * (c % 4) + 2) % 7 - val doom = (s + t + t / 4 + cAnchor) % 7 - val anchor = if (isLeapYear) leapdoom(month - 1) else normdoom(month - 1) - - weekdays((doom + day - anchor + 7) % 7) - } -} - -object Date { - private val leapdoom = Array(4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5) - private val normdoom = Array(3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5) - val weekdays = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") -} diff --git a/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh b/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh deleted file mode 100644 index 891530b914..0000000000 --- a/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -day-of-the-week() - if [[ "$1" =~ ([0-9]{4})-([0-9]{2})-([0-9]{2}) ]] - then - local -ra names=({Sun,Mon,Tues,Wednes,Thurs,Fri,Satur}day) doomsday=({37,41}7426415375) - local -i i c s t a b - local -i {y,m,d}=${BASH_REMATCH[++i]} - echo ${names[ - c=y/100, - s=(y%100)/12, - t=(y % 100) % 12, - a=(5*(c%4)+2) % 7, - b=(s + t + (t / 4) + a ) % 7, - (b + d - ${doomsday[(y%4 == 0) && ((y%100) || (y%400 == 0))]:m-1:1} + 7) % 7 - ]} - else return 1 - fi - -for date in 1800-01-06 1875-03-29 1915-12-07 1970-12-23 2043-05-14 2077-02-12 2101-04-02 -do day-of-the-week "$date" -done diff --git a/Task/Doomsday-rule/Uiua/doomsday-rule.uiua b/Task/Doomsday-rule/Uiua/doomsday-rule.uiua deleted file mode 100644 index e8c760542c..0000000000 --- a/Task/Doomsday-rule/Uiua/doomsday-rule.uiua +++ /dev/null @@ -1,7 +0,0 @@ -Ds ← [3 7 7 4 2 6 4 1 5 3 7 5] -Ly ← ↧↥⊃(=0◿400|≠0◿100|=0◿4) -D ← ◿7+⊃(Ly|+2++⊃(×5◿4|×4◿100|×6◿400)) -Wd ← ["Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"] -DoW ← ⊡:Wd◿7+D⊙(-⊡-1:Ds)°[⊙⊙∘] -[[1800 1 6][1875 3 29][1915 12 7][1970 12 23][2043 5 14][2077 2 12][2101 4 2]] -≡(&p$"_\t_"/$"_-_"°⋕⇌⟜DoW) diff --git a/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v b/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v index 002a8b84fc..bc6194f84e 100644 --- a/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v +++ b/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v @@ -1,4 +1,5 @@ -const ( +const +( days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] first_days_common = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] first_days_leap = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] @@ -23,11 +24,15 @@ fn main() { d = date[8..10].int() a = anchor_day(y) f = first_days_common[m] - if is_leap_year(y) {f = first_days_leap[m]} + if is_leap_year(y) { + f = first_days_leap[m] + } w = d - f - if w < 0 {w = 7 + w} + if w < 0 { + w = 7 + w + } dow = (a + w) % 7 - println("$date -> ${days[dow]}") + println('$date -> ${days[dow]}') } } diff --git a/Task/Doomsday-rule/Wren/doomsday-rule.wren b/Task/Doomsday-rule/Wren/doomsday-rule.wren index 559d55a03f..bd28ec8437 100644 --- a/Task/Doomsday-rule/Wren/doomsday-rule.wren +++ b/Task/Doomsday-rule/Wren/doomsday-rule.wren @@ -1,4 +1,4 @@ -import "./date" for Date +import "/date" for Date var days = ["Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"] diff --git a/Task/Dot-product/00-TASK.txt b/Task/Dot-product/00-TASK.txt index 40361afe8d..e3ca21eba5 100644 --- a/Task/Dot-product/00-TASK.txt +++ b/Task/Dot-product/00-TASK.txt @@ -15,7 +15,7 @@ If implementing the dot product of two vectors directly: :::*   sum the products   (to produce the answer) -;Related tasks: -* [[Arrays]], [[Vector]], [[Dot product]], [[Vector products]], [[Matrices]], [[Bivector]], [[Antivector]], [[Tensor]], [[Quaternion]], [[Rotor]], [[Motor]], [[Sedenion]], [[Octonion]] +;Related task: +*   [[Vector products]]

diff --git a/Task/Dot-product/ANSI-BASIC/dot-product.basic b/Task/Dot-product/ANSI-BASIC/dot-product.basic deleted file mode 100644 index 1f3bf387b2..0000000000 --- a/Task/Dot-product/ANSI-BASIC/dot-product.basic +++ /dev/null @@ -1,45 +0,0 @@ -100 REM Dot product -110 DECLARE EXTERNAL FUNCTION DotProduct -120 OPTION BASE 0 -130 DIM Zero3D(2), X(2), Y(2), Z(2), Q(2), R(2) ! some example vectors -140 LET Zero3D(0) = 0 -150 LET Zero3D(1) = 0 -160 LET Zero3D(2) = 0 -170 ! -180 LET X(0) = 1 -190 LET X(1) = 0 -200 LET X(2) = 0 -210 ! -220 LET Y(0) = 0 -230 LET Y(1) = 1 -240 LET Y(2) = 0 -250 ! -260 LET Z(0) = 0 -270 LET Z(1) = 0 -280 LET Z(2) = 1 -290 ! -300 LET Q(0) = 1 -310 LET Q(1) = 1 -320 LET Q(2) = 3.14159 -330 ! -340 LET R(0) = -1 -350 LET R(1) = 2.618033989 -360 LET R(2) = 3 -370 ! -380 PRINT " Q dot R ="; DotProduct(Q, R) -390 PRINT " Zero3D dot X ="; DotProduct(Zero3D, X) -400 PRINT " Z dot Z ="; DotProduct(Z, Z) -410 PRINT " Y dot Z ="; DotProduct(Y, Z) -420 END -430 ! -440 EXTERNAL FUNCTION DotProduct(A(), B()) -450 IF UBOUND(A) <> UBOUND(B) THEN -460 PRINT "Sizes of arrays should be equal." -470 STOP -480 END IF -490 LET DP = 0 -500 FOR I = 0 TO UBOUND(A) -510 LET DP = DP + (A(I) * B(I)) -520 NEXT I -530 LET DotProduct = DP -540 END FUNCTION diff --git a/Task/Dot-product/Ada/dot-product.adb b/Task/Dot-product/Ada/dot-product.ada similarity index 100% rename from Task/Dot-product/Ada/dot-product.adb rename to Task/Dot-product/Ada/dot-product.ada diff --git a/Task/Dot-product/Amazing-Hopper/dot-product-1.hopper b/Task/Dot-product/Amazing-Hopper/dot-product-1.hopper deleted file mode 100644 index be8a685bb6..0000000000 --- a/Task/Dot-product/Amazing-Hopper/dot-product-1.hopper +++ /dev/null @@ -1,6 +0,0 @@ -#include - -principal { - imprimir(producto punto( lst'1,3,(-5)', lst'4,(-2),(-1)' ),NL) - terminar -} diff --git a/Task/Dot-product/Amazing-Hopper/dot-product-2.hopper b/Task/Dot-product/Amazing-Hopper/dot-product-2.hopper deleted file mode 100644 index f7dd1a53ab..0000000000 --- a/Task/Dot-product/Amazing-Hopper/dot-product-2.hopper +++ /dev/null @@ -1,16 +0,0 @@ -#define maincode main: {1}do -#define this {1}do -#defn out {"\n"}print -#define dotp mul;stats(0) -#defn lst(*) {"\033"} *;mklist; -#define ready {0}return -#define decim _X_DECIM=0, mov(_X_DECIM),prec(_X_DECIM),{1}do - -main code{ - {0}decim{ - "A.B = " - this{ - lst (1,3,(-5)), lst (4,(-2),(-1)) - } dotp - } out -} ready diff --git a/Task/Dot-product/Amazing-Hopper/dot-product-3.hopper b/Task/Dot-product/Amazing-Hopper/dot-product-3.hopper deleted file mode 100644 index 27ecdcd5b3..0000000000 --- a/Task/Dot-product/Amazing-Hopper/dot-product-3.hopper +++ /dev/null @@ -1,6 +0,0 @@ -#defn dotp(_X_,_Y_) #ATOM#CMPLX;#ATOM#CMPLX; mul; stats(0) -#defn lst(*) {"\033"} *;mklist; -#defn out(*) *;{"\n"}print -#defn code(*) main:; *; {"0"};return - -code( out( dotp( lst (1,3,(-5)), lst (4,(-2),(-1)) ) ) ) diff --git a/Task/Dot-product/Apple/dot-product.apple b/Task/Dot-product/Apple/dot-product.apple deleted file mode 100644 index 8f7bb17fb2..0000000000 --- a/Task/Dot-product/Apple/dot-product.apple +++ /dev/null @@ -1 +0,0 @@ -[(+)/(*)`(x::Vec n float) y] ⟨1,3,_5⟩ ⟨4,_2,_1::float⟩ diff --git a/Task/Dot-product/ArkScript/dot-product.ark b/Task/Dot-product/ArkScript/dot-product.ark deleted file mode 100644 index f59407ce57..0000000000 --- a/Task/Dot-product/ArkScript/dot-product.ark +++ /dev/null @@ -1,12 +0,0 @@ -(let dotProduct (fun (v1 v2) { - (assert (= (len v1) (len v2)) "vectors should have the same length") - - (mut result 0) - (mut i 0) - (while (< i (len v1)) { - (set result (+ result (* (@ v1 i) (@ v2 i)))) - (set i (+ 1 i)) }) - - result })) - -(print (dotProduct [1 3 -5] [4 -2 -1])) diff --git a/Task/Dot-product/Ballerina/dot-product.ballerina b/Task/Dot-product/Ballerina/dot-product.ballerina deleted file mode 100644 index 230674a31a..0000000000 --- a/Task/Dot-product/Ballerina/dot-product.ballerina +++ /dev/null @@ -1,13 +0,0 @@ -import ballerina/io; - -function dot(float[] a, float[] b) returns float { - float sum = 0.0; - foreach any[] [idx, val] in a.enumerate() { - sum += val * b[idx]; - } - return sum; -} - -public function main() { - io:println(dot([1, 3, -5], [4, -2, -1])); -} diff --git a/Task/Dot-product/C++/dot-product-1.cpp b/Task/Dot-product/C++/dot-product-1.cpp new file mode 100644 index 0000000000..cb26a2e3a5 --- /dev/null +++ b/Task/Dot-product/C++/dot-product-1.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main() +{ + int a[] = { 1, 3, -5 }; + int b[] = { 4, -2, -1 }; + + std::cout << std::inner_product(a, a + sizeof(a) / sizeof(a[0]), b, 0) << std::endl; + + return 0; +} diff --git a/Task/Dot-product/C++/dot-product-2.cpp b/Task/Dot-product/C++/dot-product-2.cpp new file mode 100644 index 0000000000..476a7f64a5 --- /dev/null +++ b/Task/Dot-product/C++/dot-product-2.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main() +{ + std::valarray xs = {1,3,-5}; + std::valarray ys = {4,-2,-1}; + + double result = (xs * ys).sum(); + + std::cout << result << '\n'; + + return 0; +} diff --git a/Task/Dot-product/C++/dot-product-3.cpp b/Task/Dot-product/C++/dot-product-3.cpp new file mode 100644 index 0000000000..69af05bce8 --- /dev/null +++ b/Task/Dot-product/C++/dot-product-3.cpp @@ -0,0 +1,11 @@ +#include +#include +#include + +int main() { + std::vector v1 { 1, 3, -5, }; + std::vector v2 { 4, -2, -1, }; + auto dp = std::inner_product(v1.cbegin(), v1.cend(), v2.cbegin(), 0); + std::cout << "dot.product of {1,3,-5} and {4,-2,-1}: " << dp << std::endl; + return 0; +} diff --git a/Task/Dot-product/C++/dot-product.cpp b/Task/Dot-product/C++/dot-product.cpp deleted file mode 100644 index 18d21a5a35..0000000000 --- a/Task/Dot-product/C++/dot-product.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include -#include -#include - -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wgnu-alignof-expression" -#endif - -#ifdef _MSC_VER -#define INLINE __force_inline __flatten __declspec(nothrow) __declspec(noalias) inline -#else -#define INLINE __attribute__((always_inline)) __attribute__((flatten)) __attribute__((nothrow)) __attribute__((const)) inline -#endif - -template(N)> -struct alignas((N == N_POW2 ? N_POW2 : 1) * alignof(T)) vec : std::array -{ -}; - -/* n-dimensional dot/scalar product */ -template -INLINE T dot(const vec& a, const vec& b, T dst = (T)0) -{ - #pragma omp simd reduction(+:dst) - for(size_t i = 0; i < N; i++) dst += a[i] * b[i]; - return dst; -} - -int main() -{ - vec a = { 1, 3, -5 }; - vec b = { 4, -2, -1 }; - vec c = { 1, 2, 3, 4 }; - vec,3> d = { a, b, a }; - vec,4> e = { c, c, c, c }; - - printf("dot.product of {1,3,-5} and {4,-2,-1}: %d", dot(a,b)); puts(""); - printf("type align/size"); puts(""); - printf("vec %4zu/%-4zu",alignof(a), sizeof(a)); puts(""); - printf("vec %4zu/%-4zu",alignof(c), sizeof(c)); puts(""); - printf("vec,3> %4zu/%-4zu",alignof(d), sizeof(d)); puts(""); - printf("vec,4> %4zu/%-4zu",alignof(e), sizeof(e)); puts(""); - - exit(EXIT_SUCCESS); -} diff --git a/Task/Dot-product/C/dot-product-1.c b/Task/Dot-product/C/dot-product-1.c deleted file mode 100644 index e56b20f598..0000000000 --- a/Task/Dot-product/C/dot-product-1.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "array.h" - -#define dot(a,b,t,n,i) \ -({ \ - static_assert((isarray(a) || isvector(a)), \ - "ERROR: dot - a is not of array or vector type!"); \ - static_assert((isarray(b) || isvector(b)), \ - "ERROR: dot - b is not of array or vector type!"); \ - t _dst = (t)i; \ - size_t len = (size_t)llabs((ssize_t)n); \ - len = MIN(MIN(!isarray(a) ? vec_countof(a) : countof(a), \ - !isarray(b) ? vec_countof(b) : countof(b)), \ - (ssize_t)n>0?len:0); \ - _Pragma("omp simd reduction(+:_dst)") \ - for(size_t j = 0; j < len; j++) \ - _dst += (t)((a)[j]) * (t)((b)[j]); \ - _dst; \ -}) - -typedef double real; - -#define dot3(a,b) dot(a,b,real,3,0) -#define dot4(a,b) dot(a,b,real,4,0) - -#define out_eol puts("") -#define fout_num(stream,prefix,number,suffix) fprintf(stream, "%s%+e%s", prefix, (double)number, suffix) -#define out_num(number) fout_num(stdout,"",number,"") - -int main(int argc, char** argv) -{ - vec(real,3) a = { 1, 3, -5}; - arr(real,3) b = { 4, -2, -1}; - - out_num(dot3(a, b)); out_eol; - - exit(EXIT_SUCCESS); -} diff --git a/Task/Dot-product/C/dot-product-2.c b/Task/Dot-product/C/dot-product-2.c deleted file mode 100644 index a0b238ba51..0000000000 --- a/Task/Dot-product/C/dot-product-2.c +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************************************* - * C preprocessor macro vector/array types * - * * - * vec(T,N) - padded to bitceil(N) with operators/accessors * - * * - * arr(T,N) - alignas((N == bitceil(N) ? N : 1) * alignof(T)) * - * * - * vla(T) - flexible/variable length default alignment * - * * - * CFLAGS=" * - * -march=native * - * -O3 * - * -std=23 * - * -mfpmath= * - * -ftree-vectorize * - * -fopenmp * - * -fopenmp-simd" * - * * - * For MSVC see: https://learn.microsoft.com/en-us/cpp/parallel/openmp/openmp-simd?view=msvc-180 * - *************************************************************************************************/ -#pragma once -#include -#include -#include -#include -#include -#include -#include - -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wgnu-alignof-expression" -#endif - -#ifdef _MSC_VER -#define INLINE __force_inline __flatten __declspec(nothrow) __declspec(noalias) inline -#else -#define INLINE __attribute__((always_inline,flatten,nothrow,const)) inline -#endif - -#define BITOP_RUP01__(x) ( (x) | ( (x) >> 1)) -#define BITOP_RUP02__(x) (BITOP_RUP01__(x) | (BITOP_RUP01__(x) >> 2)) -#define BITOP_RUP04__(x) (BITOP_RUP02__(x) | (BITOP_RUP02__(x) >> 4)) -#define BITOP_RUP08__(x) (BITOP_RUP04__(x) | (BITOP_RUP04__(x) >> 8)) -#define BITOP_RUP16__(x) (BITOP_RUP08__(x) | (BITOP_RUP08__(x) >> 16)) - -#define bitceil(x) (const uint32_t)(BITOP_RUP16__(((uint32_t)(x)) - 1) + 1) - -/* arr(T,N) aligned array type */ -#define arr(t,n) alignas((n == bitceil(n) ? n : 1) * alignof(t)) typeof(t[n]) -#define countof(a) sizeof((a))/sizeof(typeof((a)[0])) -#define isarray(a) __builtin_choose_expr(__builtin_types_compatible_p(typeof((a)[0]) [], typeof((a))), true, false) - -#define rc_arr(src,n) (*(arr(typeof((src)[0]),n)*)&src) -#define rc_vec(src,n) (*(vec(typeof((src)[0]),n)*)&src) - -/* vec(T,N) for LLVM SIMD Vector Extension */ -#if defined(__clang__) -#define vec(T,N) typeof(T __attribute__((ext_vector_type(N)))) -#define vec_countof(a) __builtin_vectorelements(rc_vec(a,countof(a))) -#define isvector(a) !isarray(a) && \ -__builtin_choose_expr( \ -bitceil(vec_countof(a)) == countof(a),true,false) - -/* vec(T,N) for GCC SIMD Vector Extension */ -#elif defined(__GNUC__) -#define vec(T,N) typeof(T __attribute__((vector_size(bitceil(N) * alignof(T))))) -#define vec_countof(a) countof(a) -#define isvector(a) !isarray(a) && \ -_Generic(__builtin_convertvector(rc_vec(a,vec_countof(a)), \ - vec(float,bitceil(vec_countof(a)))), \ - vec(float,bitceil(vec_countof(a))): true, \ - default: false) -/* vec_ext(T,N) for other compilers */ -#else -#define vec(T,N) arr(T,N) -#warn "Your compiler doens't support vector extensions." -#warn "Using aligned arrays without operators instead." -#endif diff --git a/Task/Dot-product/C/dot-product.c b/Task/Dot-product/C/dot-product.c new file mode 100644 index 0000000000..4825c675e3 --- /dev/null +++ b/Task/Dot-product/C/dot-product.c @@ -0,0 +1,28 @@ +#include +#include + +int dot_product(int *, int *, size_t); + +int +main(void) +{ + int a[3] = {1, 3, -5}; + int b[3] = {4, -2, -1}; + + printf("%d\n", dot_product(a, b, sizeof(a) / sizeof(a[0]))); + + return EXIT_SUCCESS; +} + +int +dot_product(int *a, int *b, size_t n) +{ + int sum = 0; + size_t i; + + for (i = 0; i < n; i++) { + sum += a[i] * b[i]; + } + + return sum; +} diff --git a/Task/Dot-product/Crystal/dot-product.cr b/Task/Dot-product/Crystal/dot-product.crystal similarity index 100% rename from Task/Dot-product/Crystal/dot-product.cr rename to Task/Dot-product/Crystal/dot-product.crystal diff --git a/Task/Dot-product/Delphi/dot-product.pas b/Task/Dot-product/Delphi/dot-product.delphi similarity index 100% rename from Task/Dot-product/Delphi/dot-product.pas rename to Task/Dot-product/Delphi/dot-product.delphi diff --git a/Task/Dot-product/DuckDB/dot-product-1.duckdb b/Task/Dot-product/DuckDB/dot-product-1.duckdb deleted file mode 100644 index d7683fd5f7..0000000000 --- a/Task/Dot-product/DuckDB/dot-product-1.duckdb +++ /dev/null @@ -1 +0,0 @@ -select list_dot_product( [1, 3, -5], [4, -2, -1]); diff --git a/Task/Dot-product/DuckDB/dot-product-2.duckdb b/Task/Dot-product/DuckDB/dot-product-2.duckdb deleted file mode 100644 index ac8ab5ae33..0000000000 --- a/Task/Dot-product/DuckDB/dot-product-2.duckdb +++ /dev/null @@ -1,3 +0,0 @@ -SELECT sum(A.N*B.N) as '.' -FROM A JOIN B -ON A.rowid=B.rowid; diff --git a/Task/Dot-product/DuckDB/dot-product-3.duckdb b/Task/Dot-product/DuckDB/dot-product-3.duckdb deleted file mode 100644 index ecbeac52c6..0000000000 --- a/Task/Dot-product/DuckDB/dot-product-3.duckdb +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE TABLE A AS - SELECT rowid, N - FROM (select [1, 3, -5] as l, unnest(l) as N, generate_subscripts(l, 1) AS rowid); - -CREATE OR REPLACE TABLE B AS - SELECT rowid, N - FROM (select [4, -2, -1] as l, unnest(l) as N, generate_subscripts(l, 1) AS rowid); diff --git a/Task/Dot-product/DuckDB/dot-product-4.duckdb b/Task/Dot-product/DuckDB/dot-product-4.duckdb deleted file mode 100644 index 31a7b61cad..0000000000 --- a/Task/Dot-product/DuckDB/dot-product-4.duckdb +++ /dev/null @@ -1,13 +0,0 @@ -# Define innerProduct/2 as a scalar function; -# the names of the columns are however fixed. -create or replace function innerProduct(TableA, TableB) as ( - (select * from - (with - AT as (from query_table(TableA)), - BT as (from query_table(TableB)) - select sum(AT.N * BT.N) - from AT join BT - on AT.rowid=BT.rowid ) -)); - -select innerProduct('A', 'B'); diff --git a/Task/Dot-product/EasyLang/dot-product.easy b/Task/Dot-product/EasyLang/dot-product.easy index 51624e7ca6..26ddd328f4 100644 --- a/Task/Dot-product/EasyLang/dot-product.easy +++ b/Task/Dot-product/EasyLang/dot-product.easy @@ -1,7 +1,8 @@ -func dotprod a[] b[] . +func dotprod a[] b[] . r . + r = 0 for i to len a[] r += a[i] * b[i] . - return r . -print dotprod [ 1 3 -5 ] [ 4 -2 -1 ] +call dotprod [ 1 3 -5 ] [ 4 -2 -1 ] r +print r diff --git a/Task/Dot-product/Elena/dot-product.elena b/Task/Dot-product/Elena/dot-product.elena index 33f37c0614..c705cf4014 100644 --- a/Task/Dot-product/Elena/dot-product.elena +++ b/Task/Dot-product/Elena/dot-product.elena @@ -7,7 +7,7 @@ extension op = self.zipBy(array, (x,y => x * y)).summarize(); } -public Program() +public program() { - Console.printLine(new int[]{1, 3, -5}.dotProduct(new int[]{4, -2, -1})) + console.printLine(new int[]{1, 3, -5}.dotProduct(new int[]{4, -2, -1})) } diff --git a/Task/Dot-product/Elixir/dot-product.ex b/Task/Dot-product/Elixir/dot-product.elixir similarity index 100% rename from Task/Dot-product/Elixir/dot-product.ex rename to Task/Dot-product/Elixir/dot-product.elixir diff --git a/Task/Dot-product/Emacs-Lisp/dot-product.el b/Task/Dot-product/Emacs-Lisp/dot-product.l similarity index 100% rename from Task/Dot-product/Emacs-Lisp/dot-product.el rename to Task/Dot-product/Emacs-Lisp/dot-product.l diff --git a/Task/Dot-product/Euphoria/dot-product-1.eu b/Task/Dot-product/Euphoria/dot-product-1.euphoria similarity index 100% rename from Task/Dot-product/Euphoria/dot-product-1.eu rename to Task/Dot-product/Euphoria/dot-product-1.euphoria diff --git a/Task/Dot-product/Euphoria/dot-product-2.eu b/Task/Dot-product/Euphoria/dot-product-2.euphoria similarity index 100% rename from Task/Dot-product/Euphoria/dot-product-2.eu rename to Task/Dot-product/Euphoria/dot-product-2.euphoria diff --git a/Task/Dot-product/Fennel/dot-product.fennel b/Task/Dot-product/Fennel/dot-product.fennel deleted file mode 100644 index adc1d7ecd1..0000000000 --- a/Task/Dot-product/Fennel/dot-product.fennel +++ /dev/null @@ -1,11 +0,0 @@ -(fn dotProduct [v1 v2] - (assert (= (length v1) (length v2)) "vectors should have the same length") - - (var result 0) - (for [i 1 (length v1)] - (set result (+ result (* (. v1 i) (. v2 i)))) - ) - result -) - -(print (dotProduct [1 3 -5] [4 -2 -1])) diff --git a/Task/Dot-product/Gleam/dot-product.gleam b/Task/Dot-product/Gleam/dot-product.gleam deleted file mode 100644 index 646cd40690..0000000000 --- a/Task/Dot-product/Gleam/dot-product.gleam +++ /dev/null @@ -1,18 +0,0 @@ -pub fn main() { - let _ = echo dot_product([1, 3, -5], [4, -2, -1]) - let _ = echo dot_product([1, 3, -5], [4, -2]) -} - -pub fn dot_product(u: List(Int), v: List(Int)) -> Result(Int, String) { - dot_product_loop(u, v, 0) -} - -fn dot_product_loop(u: List(Int), v: List(Int), sum: Int) -> Result(Int, String) { - case u, v { - [], [_, ..] -> Error("Inputs must have the same length.") - [_, ..], [] -> Error("Inputs must have the same length.") - [x, ..rest_u], [y, ..rest_v] -> - dot_product_loop(rest_u, rest_v, x * y + sum) - [], [] -> Ok(sum) - } -} diff --git a/Task/Dot-product/Julia/dot-product.jl b/Task/Dot-product/Julia/dot-product.julia similarity index 100% rename from Task/Dot-product/Julia/dot-product.jl rename to Task/Dot-product/Julia/dot-product.julia diff --git a/Task/Dot-product/Kotlin/dot-product.kts b/Task/Dot-product/Kotlin/dot-product.kotlin similarity index 100% rename from Task/Dot-product/Kotlin/dot-product.kts rename to Task/Dot-product/Kotlin/dot-product.kotlin diff --git a/Task/Dot-product/LFE/dot-product.lfe b/Task/Dot-product/LFE/dot-product.lfe index 6208adb21f..4936a177ac 100644 --- a/Task/Dot-product/LFE/dot-product.lfe +++ b/Task/Dot-product/LFE/dot-product.lfe @@ -1,2 +1,3 @@ (defun dot-product (a b) - (lists:foldl #'+/2 0 (lists:zipwith #'*/2 a b))) + (: lists foldl #'+/2 0 + (: lists zipwith #'*/2 a b))) diff --git a/Task/Dot-product/LOLCODE/dot-product.lol b/Task/Dot-product/LOLCODE/dot-product.lol deleted file mode 100644 index 97687f6b7d..0000000000 --- a/Task/Dot-product/LOLCODE/dot-product.lol +++ /dev/null @@ -1,23 +0,0 @@ -HAI 1.3 BTW DOT PRODUKT - - OBTW FIND DOT PRODUKT OF AV AN BV - - AV AN BV MUST BE BUKKITS WITH LENGTH AN SRS 0, SRS 1, ... SRS DIFF OF LENGTH AN 1 - BOTH SAEM AV'Z LENGTH AN BV'Z LENGTH MUST BE WIN - TLDR - HOW IZ I DOTTIN YR AV AN YR BV - I HAS A REZULT ITZ 0 - IM IN YR INNERPRODUKT UPPIN YR I TIL BOTH SAEM I AN BIGGR OF I AN AV'Z LENGTH - REZULT R SUM OF REZULT AN PRODUKT OF AV'Z SRS I AN BV'Z SRS I - IM OUTTA YR INNERPRODUKT - FOUND YR REZULT - IF U SAY SO - - BTW MAEK AV AN BV BE 3 ELEMENT VEKTORS - I HAS A AV ITZ A BUKKIT, AV HAS A LENGTH ITZ 3 - AV HAS A SRS 0 ITZ 1, AV HAS A SRS 1 ITZ 3, AV HAS A SRS 2 ITZ -5 - I HAS A BV ITZ A BUKKIT, BV HAS A LENGTH ITZ 3 - BV HAS A SRS 0 ITZ 4, BV HAS A SRS 1 ITZ -2, BV HAS A SRS 2 ITZ -1 - - VISIBLE I IZ DOTTIN YR AV AN YR BV MKAY - -KTHXBYE diff --git a/Task/Dot-product/Loglan82/dot-product.loglan82 b/Task/Dot-product/Loglan82/dot-product.loglan82 deleted file mode 100644 index 58d21b8f35..0000000000 --- a/Task/Dot-product/Loglan82/dot-product.loglan82 +++ /dev/null @@ -1,17 +0,0 @@ -(* Dot product *) - -block - unit vector: class (x, y, z: real); - end vector; - - unit dot_product: function (u, v: vector) : real; - begin - result := u.x * v.x + u.y * v.y + u.z * v.z - end dot_product; - -var - dp: real; -begin - dp := dot_product(new vector(1.0, 3.0, -5.0), new vector(4.0, -2.0, -1.0)); - writeln(dp) -end diff --git a/Task/Dot-product/Nu/dot-product.nu b/Task/Dot-product/Nu/dot-product.nu deleted file mode 100644 index 655132cc4e..0000000000 --- a/Task/Dot-product/Nu/dot-product.nu +++ /dev/null @@ -1,5 +0,0 @@ -def 'math dot' [v] { - zip $v | each { math product } | math sum -} - -[1 3 -5] | math dot [4 -2 -1] diff --git a/Task/Dot-product/OCaml/dot-product-1.ml b/Task/Dot-product/OCaml/dot-product-1.ocaml similarity index 100% rename from Task/Dot-product/OCaml/dot-product-1.ml rename to Task/Dot-product/OCaml/dot-product-1.ocaml diff --git a/Task/Dot-product/OCaml/dot-product-2.ml b/Task/Dot-product/OCaml/dot-product-2.ocaml similarity index 100% rename from Task/Dot-product/OCaml/dot-product-2.ml rename to Task/Dot-product/OCaml/dot-product-2.ocaml diff --git a/Task/Dot-product/Oberon/dot-product.oberon b/Task/Dot-product/Oberon-2/dot-product.oberon similarity index 100% rename from Task/Dot-product/Oberon/dot-product.oberon rename to Task/Dot-product/Oberon-2/dot-product.oberon diff --git a/Task/Dot-product/Pascal-P/dot-product.pas b/Task/Dot-product/Pascal-P/dot-product.pas deleted file mode 100644 index db1cfeb348..0000000000 --- a/Task/Dot-product/Pascal-P/dot-product.pas +++ /dev/null @@ -1,29 +0,0 @@ -program dotproduct(output); - (* Dot product *) - -const - maxi = 2; - -type - realarray = array [0 .. maxi] of real; - -var - x, y: realarray; - - function dotproduct(a, b: realarray): real; - var - i: integer; - res: real; - begin - res := 0; - for i := 0 to maxi do - res := res + (a[i] * b[i]); - dotproduct := res; - end; - -begin - x[0] := 1; x[1] := 3; x[2] := -5; - y[0] := 4; y[1] := -2; y[2] := -1; - writeln(dotproduct(x, y)); - (* readln; *) -end. diff --git a/Task/Dot-product/PascalABC.NET/dot-product.pas b/Task/Dot-product/PascalABC.NET/dot-product.pas deleted file mode 100644 index 71d0c2418d..0000000000 --- a/Task/Dot-product/PascalABC.NET/dot-product.pas +++ /dev/null @@ -1,4 +0,0 @@ -## -function DotProduct(a, b: array of real) := a.Zip(b, (x, y) -> x * y).Sum; - -DotProduct(|1.0, 3, -5|, |4.0, -2, -1|).println; diff --git a/Task/Dot-product/Perl/dot-product-2.pl b/Task/Dot-product/Perl/dot-product-2.pl deleted file mode 100644 index 3ee16d9b23..0000000000 --- a/Task/Dot-product/Perl/dot-product-2.pl +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/perl - -use strict; # https://rosettacode.org/wiki/Dot_product -use warnings; -use List::AllUtils qw( sum zip_by product ); - -sub dotprod { return sum zip_by { product @_ } @_ } - -my @vec_a = (1,3,-5); -my @vec_b = (4,-2,-1); - -print dotprod(\@vec_a, \@vec_b), "\n"; diff --git a/Task/Dot-product/Perl/dot-product-1.pl b/Task/Dot-product/Perl/dot-product.pl similarity index 100% rename from Task/Dot-product/Perl/dot-product-1.pl rename to Task/Dot-product/Perl/dot-product.pl diff --git a/Task/Dot-product/PowerShell/dot-product.ps1 b/Task/Dot-product/PowerShell/dot-product.psh similarity index 100% rename from Task/Dot-product/PowerShell/dot-product.ps1 rename to Task/Dot-product/PowerShell/dot-product.psh diff --git a/Task/Dot-product/REBOL/dot-product.rebol b/Task/Dot-product/REBOL/dot-product.rebol new file mode 100644 index 0000000000..a2d960f24d --- /dev/null +++ b/Task/Dot-product/REBOL/dot-product.rebol @@ -0,0 +1,16 @@ +REBOL [] + +a: [1 3 -5] +b: [4 -2 -1] + +dot-product: function [v1 v2] [sum] [ + if (length? v1) != (length? v2) [ + make error! "error: vector sizes must match" + ] + sum: 0 + repeat i length? v1 [ + sum: sum + ((pick v1 i) * (pick v2 i)) + ] +] + +dot-product a b diff --git a/Task/Dot-product/Rebol/dot-product.rebol b/Task/Dot-product/Rebol/dot-product.rebol deleted file mode 100644 index f8299d6371..0000000000 --- a/Task/Dot-product/Rebol/dot-product.rebol +++ /dev/null @@ -1,16 +0,0 @@ -Rebol [] -a: [1 3 -5] -b: [4 -2 -1] - -dot-product: func [v1 v2 /local len sum] [ - len: length? v1 - if len <> length? v2 [ - make error! "error: vector sizes must match" - ] - sum: 0 - repeat i len [ - sum: sum + (v1/:i * v2/:i) - ] -] - -dot-product a b diff --git a/Task/Dot-product/Red/dot-product.red b/Task/Dot-product/Red/dot-product.red deleted file mode 100644 index 1996c9335e..0000000000 --- a/Task/Dot-product/Red/dot-product.red +++ /dev/null @@ -1,10 +0,0 @@ -Red [ "Dot product - hinjolicious" ] - -#include %mylib/pipe-map.red -#include %mylib/transpose-zip.Red - -demo "Dot product" [ -a: [1 3 -5] -b: [4 -2 -1] -(reduce [a b]) |> zip ==> [_m/1 * _m/2] |> sum |> probe ; 3 -] diff --git a/Task/Dot-product/Rust/dot-product-1.rs b/Task/Dot-product/Rust/dot-product-1.rust similarity index 100% rename from Task/Dot-product/Rust/dot-product-1.rs rename to Task/Dot-product/Rust/dot-product-1.rust diff --git a/Task/Dot-product/Rust/dot-product-2.rs b/Task/Dot-product/Rust/dot-product-2.rust similarity index 100% rename from Task/Dot-product/Rust/dot-product-2.rs rename to Task/Dot-product/Rust/dot-product-2.rust diff --git a/Task/Dot-product/Rye/dot-product.rye b/Task/Dot-product/Rye/dot-product.rye deleted file mode 100644 index 28deb83a66..0000000000 --- a/Task/Dot-product/Rye/dot-product.rye +++ /dev/null @@ -1 +0,0 @@ -print dot-product vector { 1 3 -5 } vector { 4 -2 -1 } diff --git a/Task/Dot-product/Scheme/dot-product.scm b/Task/Dot-product/Scheme/dot-product.ss similarity index 100% rename from Task/Dot-product/Scheme/dot-product.scm rename to Task/Dot-product/Scheme/dot-product.ss diff --git a/Task/Dot-product/Uiua/dot-product.uiua b/Task/Dot-product/Uiua/dot-product.uiua deleted file mode 100644 index f0af9bb367..0000000000 --- a/Task/Dot-product/Uiua/dot-product.uiua +++ /dev/null @@ -1,2 +0,0 @@ -[4 ¯2 ¯1] [1 3 ¯5] -/+× diff --git a/Task/Dot-product/VBScript/dot-product.vbs b/Task/Dot-product/VBScript/dot-product.vb similarity index 100% rename from Task/Dot-product/VBScript/dot-product.vbs rename to Task/Dot-product/VBScript/dot-product.vb diff --git a/Task/Dot-product/Zig/dot-product.zig b/Task/Dot-product/Zig/dot-product.zig index 1118520c95..82ecb11802 100644 --- a/Task/Dot-product/Zig/dot-product.zig +++ b/Task/Dot-product/Zig/dot-product.zig @@ -1,9 +1,10 @@ const std = @import("std"); +const Vector = std.meta.Vector; pub fn main() !void { - const a = @Vector(3, i32){ 1, 3, -5 }; - const b = @Vector(3, i32){ 4, -2, -1 }; - const dot: i32 = @reduce(.Add, a * b); + const a: Vector(3, i32) = [_]i32{1, 3, -5}; + const b: Vector(3, i32) = [_]i32{4, -2, -1}; + var dot: i32 = @reduce(.Add, a*b); try std.io.getStdOut().writer().print("{d}\n", .{dot}); } diff --git a/Task/Doubly-linked-list-Definition/Delphi/doubly-linked-list-definition.pas b/Task/Doubly-linked-list-Definition/Delphi/doubly-linked-list-definition.delphi similarity index 100% rename from Task/Doubly-linked-list-Definition/Delphi/doubly-linked-list-definition.pas rename to Task/Doubly-linked-list-Definition/Delphi/doubly-linked-list-definition.delphi diff --git a/Task/Doubly-linked-list-Definition/FutureBasic/doubly-linked-list-definition.basic b/Task/Doubly-linked-list-Definition/FutureBasic/doubly-linked-list-definition.basic deleted file mode 100644 index 32155d51d0..0000000000 --- a/Task/Doubly-linked-list-Definition/FutureBasic/doubly-linked-list-definition.basic +++ /dev/null @@ -1,67 +0,0 @@ -begin globals - str255 List(8) //create a new list of strings (List(0) not used -end globals - - -local fn ShowList(title As str255) - //display all elements from list of string - short j - Print title; - For j = 1 to 7 - Print List(j); " "; - Next j - Print "" -End fn - - -/////////// MAIN PROGRAM //////////// - -Dim As str255 item //items to add to the list -Dim As short i,j, c = 0 - -//the list of data that will be added to the list -data: -Data "One", "Two", "Three", "Four", "Five", "Six", "EndOfData" - -Restore -c = 0 -Do - Read item - If item <> "EndOfData" Then List(c) = item - c ++ -Until item = "EndOfData" - -str255 ListTMP(7) - -For j = 1 To 7 - ListTMP(7-j) = List(j) -Next j -For j = 1 To 7 - Swap List(j), ListTMP(j) -Next j -fn ShowList("Insertion at Head: ") - -for i = 1 to 7 : List(i) = "" : next i // clear list -Restore -c = 0 -Do - Read item //: c += 1 - If item <> "EndOfData" Then List(c) = item - c ++ -Until item = "EndOfData" -fn ShowList("Insertion at Tail: ") - -for i = 1 to 7 : List(i) = "" : next i // clear list -Restore -c = 0 -Do - Read item //: c += 1 - If item <> "EndOfData" Then List(c) = item - c ++ -Until item = "EndOfData" - -Swap List(3), List(6) -fn ShowList("Insertion in Middle: ") - - -handleevents diff --git a/Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-1.jl b/Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-1.julia similarity index 100% rename from Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-1.jl rename to Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-1.julia diff --git a/Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-2.jl b/Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-2.julia similarity index 100% rename from Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-2.jl rename to Task/Doubly-linked-list-Definition/Julia/doubly-linked-list-definition-2.julia diff --git a/Task/Doubly-linked-list-Definition/Kotlin/doubly-linked-list-definition.kts b/Task/Doubly-linked-list-Definition/Kotlin/doubly-linked-list-definition.kotlin similarity index 100% rename from Task/Doubly-linked-list-Definition/Kotlin/doubly-linked-list-definition.kts rename to Task/Doubly-linked-list-Definition/Kotlin/doubly-linked-list-definition.kotlin diff --git a/Task/Doubly-linked-list-Definition/Oberon/doubly-linked-list-definition.oberon b/Task/Doubly-linked-list-Definition/Oberon-2/doubly-linked-list-definition.oberon similarity index 100% rename from Task/Doubly-linked-list-Definition/Oberon/doubly-linked-list-definition.oberon rename to Task/Doubly-linked-list-Definition/Oberon-2/doubly-linked-list-definition.oberon diff --git a/Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas b/Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas deleted file mode 100644 index a97277863b..0000000000 --- a/Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas +++ /dev/null @@ -1,75 +0,0 @@ -type Node = auto class - data: T; - prev,next: Node; -end; - -type - MyLinkedList = class - first, last: Node; - procedure AddFirst(x: T); - begin - if first = nil then - begin - first := new Node(x,nil,nil); - last := first - end - else - begin - var p := new Node(x,nil,first); - first.prev := p; - first := p; - end; - end; - procedure AddLast(x: T); - begin - if first = nil then - begin - first := new Node(x,nil,nil); - last := first - end - else - begin - var p := new Node(x,last,nil); - last.next := p; - last := p; - end; - end; - procedure AddAfter(p: Node; x: T); - begin - if last = p then - AddLast(x) - else begin - var pp := new Node(x,p,p.next); - p.next := pp; - pp.next.prev := pp; - end - end; - procedure PrintList(); - begin - var p := first; - while p<>nil do - begin - Print(p.data); - p := p.next; - end; - end; - procedure PrintBack(); - begin - var p := last; - while p<>nil do - begin - Print(p.data); - p := p.prev; - end; - end; - end; - -begin - var lst := new MyLinkedList; - lst.AddFirst(2); lst.AddFirst(3); - lst.AddLast(5); - lst.AddAfter(lst.first,555); - lst.PrintList; - Println; - lst.PrintBack; -end. diff --git a/Task/Doubly-linked-list-Definition/Pluto/doubly-linked-list-definition.pluto b/Task/Doubly-linked-list-Definition/Pluto/doubly-linked-list-definition.pluto deleted file mode 100644 index c165dcf1c8..0000000000 --- a/Task/Doubly-linked-list-Definition/Pluto/doubly-linked-list-definition.pluto +++ /dev/null @@ -1,18 +0,0 @@ -require "list" - -local d = dlist.of("A", "B") -print(d) --- Add an element at the head. -d:prepend("C") --- Add an element in the middle. -d:insert(2, "D") --- Add an element at the tail. -d:push("E") -print(d) - --- Remove an element by index (indexing is 1 based). -d:remove(2) -print(d) --- Remove an element by value. -d:erase("A") -print(d) diff --git a/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-1.ps1 b/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-1.psh similarity index 100% rename from Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-1.ps1 rename to Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-1.psh diff --git a/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-2.ps1 b/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-2.psh similarity index 100% rename from Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-2.ps1 rename to Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-2.psh diff --git a/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-3.ps1 b/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-3.psh similarity index 100% rename from Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-3.ps1 rename to Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-3.psh diff --git a/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-4.ps1 b/Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-4.psh similarity index 100% rename from Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-4.ps1 rename to Task/Doubly-linked-list-Definition/PowerShell/doubly-linked-list-definition-4.psh diff --git a/Task/Doubly-linked-list-Definition/RISC-V-Assembly/doubly-linked-list-definition.asm b/Task/Doubly-linked-list-Definition/RISC-V-Assembly/doubly-linked-list-definition.asm deleted file mode 100644 index e3c89ff6db..0000000000 --- a/Task/Doubly-linked-list-Definition/RISC-V-Assembly/doubly-linked-list-definition.asm +++ /dev/null @@ -1,347 +0,0 @@ -# riscv assembly raspberry pico2 rp2350 -# program dbllinkedlist.s -# connexion putty com3 -/*********************************************/ -/* CONSTANTES */ -/********************************************/ -/* for this file see risc-v task include a file */ -.include "../../../constantesRiscv.inc" -.equ HEAPSIZE, 50000 -/****************************************************/ -/* MACROS */ -/****************************************************/ -#.include "../ficmacrosriscv.inc" # only for debugging - -/*******************************************/ -/* STRUCTURE */ -/*******************************************/ -/* structure Doublylinkedlist*/ - .struct 0 -dllist_head: # head node - .struct dllist_head + 4 -dllist_tail: # tail node - .struct dllist_tail + 4 -dllist_end: -/* structure Node Doublylinked List*/ - .struct 0 -NDlist_next: # next element - .struct NDlist_next + 4 -NDlist_prev: # previous element - .struct NDlist_prev + 4 -NDlist_value: # element value or key - .struct NDlist_value + 4 -NDlist_end: -/*******************************************/ -/* INITIALED DATAS */ -/*******************************************/ -.data -szMessStart: .asciz "Program riscv start.\r\n" -szMessEndOk: .asciz "Program riscv end OK.\r\n" -szCariageReturn: .asciz "\r\n" - -szMessInitListe: .asciz "List initialized.\n" -szMessErreur: .asciz "Error detected.\n" -szMessResult: .asciz "Element No :" -szMessResultValue: .asciz " value : " -szMessInverse: .asciz "\nList inverse : \n" -.align 2 -ptHeapReserve: .int heapReserve -/*******************************************/ -/* UNINITIALED DATA */ -/*******************************************/ -.bss -sConvArea: .skip 24 -.align 2 -dlList1: .skip dllist_end # list memory place -heapReserve: .skip HEAPSIZE - -/**********************************************/ -/* SECTION CODE */ -/**********************************************/ -.text -.global main - -main: - call stdio_init_all # général init -1: # start loop connexion - li a0,0 # raz argument register - call tud_cdc_n_connected # waiting for USB connection - beqz a0,1b # return code = zero ? yes -> loop - - la a0,szMessStart # message address - call writeString # display message - - la a0,dlList1 - call newDList # create new list - la a0,szMessInitListe - call writeString - - - - la a0,dlList1 # list address - li a1,5000 # value to insert - call insertTail # insertion at head - bgez a0,2f # error ? - la a0,szMessErreur - call writeString - j 10f -2: - la a0,dlList1 # list address - li a1,42 # value to insert - call insertHead # insertion at head - bgez a0,3f # error ? - la a0,szMessErreur - call writeString - j 10f - -3: - la a0,dlList1 # list address - li a1,42 # search value - li a2,1234567 # value to insert - call insertAfter # insertion after node contains search value - bgez a0,4f # error ? - la a0,szMessErreur - call writeString - j 10f -4: - - la s0,dlList1 # list address - lw s0,dllist_head(s0) - beqz s0,10f # empty list - li s1,1 # n0 element -5: - lw s2,NDlist_value(s0) # load pointer - #beqz s2,10f # end list ? - la a0,szMessResult - call writeString - mv a0,s1 # conversion and display N° element - la a1,sConvArea - call conversion10 - la a0,sConvArea - call writeString - - la a0,szMessResultValue - call writeString - mv a0,s2 # conversion and display value element - la a1,sConvArea - call conversion10 - la a0,sConvArea - call writeString - la a0,szCariageReturn - call writeString - addi s1,s1,1 - lw s0,NDlist_next(s0) # load next pointer - bnez s0,5b # not null pointer -> loop - - la a0,szMessInverse - call writeString - la s0,dlList1 # list address - lw s0,dllist_tail(s0) - beqz s0,10f # empty list - li s1,1 # n0 element -6: - lw s2,NDlist_value(s0) # load pointer - #beqz s2,10f # end list ? - la a0,szMessResult - call writeString - mv a0,s1 # conversion and display N° element - la a1,sConvArea - call conversion10 - la a0,sConvArea - call writeString - - la a0,szMessResultValue - call writeString - mv a0,s2 # conversion and display value element - la a1,sConvArea - call conversion10 - la a0,sConvArea - call writeString - la a0,szCariageReturn - call writeString - addi s1,s1,1 - lw s0,NDlist_prev(s0) # load next pointer - bnez s0,6b # not null pointer -> loop - -10: - la a0,szMessEndOk # message address - call writeString # display message - call getchar -100: # final loop - j 100b - -/**********************************************/ -/* create new double linked list */ -/**********************************************/ -/* a0 linked list address */ -newDList: # INFO: newDList - addi sp, sp, -4 - sw ra, 0(sp) - - sw x0,dllist_tail(a0) # raz pointer - sw x0,dllist_head(a0) # raz pointer - - lw ra, 0(sp) - addi sp, sp, 4 - ret -/**********************************************/ -/* insertion value in head */ -/**********************************************/ -/* a0 double linked list address */ -/* a1 contains the value of element */ -/* a0 returns address of element or - 1 if error */ -insertHead: # INFO: insertTail - addi sp, sp, -8 - sw ra, 0(sp) - sw s0, 4(sp) - mv s0,a0 # save address - mv a0,a1 # value - call createNode # create new node - bltz a0,100f # error ? - - lw t0,dllist_head(s0) # load address first node - sw t0,NDlist_next(a0) # store in next pointer on new node - sw x0,NDlist_prev(a0) # store null on prev pointer - sw a0,dllist_head(s0) # store address new node on list head - beqz t0,1f # address last node is null ? - sw a0,NDlist_prev(t0) # no store address new node in next pointer - j 2f -1: - sw a0,dllist_tail(s0) # else store in head list -2: - -100: - lw ra, 0(sp) - lw s0, 4(sp) - addi sp, sp, 8 - ret - -/**********************************************/ -/* insertion value in Tail */ -/**********************************************/ -/* a0 double linked list address */ -/* a1 contains the value of element */ -/* a0 returns address of element or - 1 if error */ -insertTail: # INFO: insertTail - addi sp, sp, -8 - sw ra, 0(sp) - sw s0, 4(sp) - mv s0,a0 # save address - mv a0,a1 # value - call createNode # create new node - bltz a0,100f # error ? - - lw t0,dllist_tail(s0) # load address last node - sw t0,NDlist_prev(a0) # store in previous pointer on new node - sw x0,NDlist_next(a0) # store null un next pointer - sw a0,dllist_tail(s0) # store address new node on list tail - beqz t0,1f # address last node is null ? - sw a0,NDlist_next(t0) # no store address new node in next pointer - j 2f -1: - sw a0,dllist_head(s0) # else store in head list -2: - -100: - lw ra, 0(sp) - lw s0, 4(sp) - addi sp, sp, 8 - ret -/**********************************************/ -/* insertion value in after search value */ -/**********************************************/ -/* a0 double linked list address */ -/* a1 contains the search value after that insert */ -/* a2 contains the value of element */ -/* a0 returns address of element or - 1 if error */ -insertAfter: # INFO: insertAfter - addi sp, sp, -12 - sw ra, 0(sp) - sw s0, 4(sp) - sw s1, 8(sp) - mv s0,a0 # save address - call searchValue - bltz a0,100f # error ? - mv s1,a0 # save address find node - mv a0,a2 # value - call createNode # create new node - bltz a0,100f # error ? - - lw t0,NDlist_next(s1) # load pointer next of find node - sw a0,NDlist_next(s1) # store new node in pointer next - sw s1,NDlist_prev(a0) # store address find node in previous pointer on new node - sw t0,NDlist_next(a0) # store pointer next of find node on pointer next on new node - - beqz t0,1f # address next node null ? - sw a0,NDlist_prev(t0) # no store address new node in previous pointer - j 2f -1: - sw a0,dllist_tail(s0) # else store in tail list -2: - -100: - lw ra, 0(sp) - lw s0, 4(sp) - lw s1, 8(sp) - addi sp, sp, 12 - ret - -/**********************************************/ -/* search value in double linked list */ -/**********************************************/ -/* a0 contains the address of the list structure */ -/* a1 contains the value to search */ -/* a0 return address of node or -1 if not found */ -searchValue: # INFO: searchValue - addi sp, sp, -4 - sw ra, 0(sp) - lw t0,dllist_head(a0) # load first node -1: - bnez t0,2f # equal zero ? - li a0,-1 # yes -> not found -> end - j 100f -2: - lw t1,NDlist_value(t0) # load node value - bne t1,a1,3f # equal search value ? - mv a0,t0 # yes -> end - j 100f -3: - lw t0,NDlist_next(t0) # load address nex node - j 1b # and loop - -100: - lw ra, 0(sp) - addi sp, sp, 4 - ret -/**********************************************/ -/* create node on heap */ -/**********************************************/ -/* a0 value */ -/* a0 return node address or -1 if error */ -createNode: # INFO: createNode - addi sp, sp, -4 - sw ra, 0(sp) - la t0,ptHeapReserve - lw t1,(t0) # free heap address - addi t2,t1,NDlist_end # reserve area on heap - la t3,heapReserve - li t4,HEAPSIZE - add t3,t3,t4 - blt t2,t3,2f - li a0,-1 - j 100f -2: - sw t2,(t0) # save new value heap used - sw a0,NDlist_value(t1) # store value on heap - sw x0,NDlist_next(t1) # raz pointer next - sw x0,NDlist_prev(t1) # raz pointer previous - mv a0,t1 # return node address -100: - lw ra, 0(sp) - addi sp, sp, 4 - ret -/************************************/ -/* file include Fonctions */ -/***********************************/ -/* for this file see risc-v task include a file */ -.include "../../../includeFunctions.s" diff --git a/Task/Doubly-linked-list-Definition/Raku/doubly-linked-list-definition.raku b/Task/Doubly-linked-list-Definition/Raku/doubly-linked-list-definition.raku index ba49db0aee..5ee1919518 100644 --- a/Task/Doubly-linked-list-Definition/Raku/doubly-linked-list-definition.raku +++ b/Task/Doubly-linked-list-Definition/Raku/doubly-linked-list-definition.raku @@ -4,29 +4,29 @@ role DLElem[::T] { has T $.payload = T; method pre-insert(T $payload) { - die "Can't insert before beginning" unless $!prev; - my $elem = ::?CLASS.new(:$payload); - $!prev.next = $elem; - $elem.prev = $!prev; - $elem.next = self; - $!prev = $elem; - $elem; + die "Can't insert before beginning" unless $!prev; + my $elem = ::?CLASS.new(:$payload); + $!prev.next = $elem; + $elem.prev = $!prev; + $elem.next = self; + $!prev = $elem; + $elem; } method post-insert(T $payload) { - die "Can't insert after end" unless $!next; - my $elem = ::?CLASS.new(:$payload); - $!next.prev = $elem; - $elem.next = $!next; - $elem.prev = self; - $!next = $elem; - $elem; + die "Can't insert after end" unless $!next; + my $elem = ::?CLASS.new(:$payload); + $!next.prev = $elem; + $elem.next = $!next; + $elem.prev = self; + $!next = $elem; + $elem; } method delete { - die "Can't delete a sentinel" unless $!prev and $!next; - $!next.prev = $!prev; - $!prev.next = $!next; # conveniently returns next element + die "Can't delete a sentinel" unless $!prev and $!next; + $!next.prev = $!prev; + $!prev.next = $!next; # conveniently returns next element } } @@ -35,10 +35,10 @@ role DLList[::DLE] { has DLE $.last; submethod BUILD { - $!first = DLE.new; - $!last = DLE.new; - $!first.next = $!last; - $!last.prev = $!first; + $!first = DLE.new; + $!last = DLE.new; + $!first.next = $!last; + $!last.prev = $!first; } method list { ($!first.next, *.next ...^ !*.next).map: *.payload } diff --git a/Task/Doubly-linked-list-Definition/Rust/doubly-linked-list-definition-1.rs b/Task/Doubly-linked-list-Definition/Rust/doubly-linked-list-definition-1.rs deleted file mode 100644 index 2dbdcfbc18..0000000000 --- a/Task/Doubly-linked-list-Definition/Rust/doubly-linked-list-definition-1.rs +++ /dev/null @@ -1,7 +0,0 @@ -// We are ommitting the allocator for these examples -pub struct LinkedList { - head: Option>>, - tail: Option>>, - len: usize, - marker: PhantomData>>, // We logically hold an owned pointer to Node -} diff --git a/Task/Doubly-linked-list-Definition/Rust/doubly-linked-list-definition-2.rs b/Task/Doubly-linked-list-Definition/Rust/doubly-linked-list-definition-2.rs deleted file mode 100644 index c0e18e5933..0000000000 --- a/Task/Doubly-linked-list-Definition/Rust/doubly-linked-list-definition-2.rs +++ /dev/null @@ -1,40 +0,0 @@ -trait ListExt { - fn insert(&mut self, elt: T, at: usize); -} - -impl ListExt for std::collections::LinkedList { - // The following references the standard library's implementation of `LinkedList::remove` - fn insert(&mut self, elt: T, at: usize) { - let len = self.len(); - assert!( - at <= len, - "The given index must be a valid index after insertion", - ); - - let offset_from_end = len - at; - if at < offset_from_end { - let mut cursor = self.cursor_front_mut(); - for _ in 0..at { - cursor.move_next(); - } - cursor.insert_before(elt); - } else { - let mut cursor = self.cursor_back_mut(); - for _ in 0..offset_from_end { - cursor.move_prev(); - } - cursor.insert_after(elt); - } - } -} - -fn definition() { - use std::collections::LinkedList; - - let mut list = LinkedList::new(); - list.push_back('B'); - list.push_front('A'); - list.insert('C', 1); - - assert_eq!(list, ['A', 'C', 'B'].into()); -} diff --git a/Task/Doubly-linked-list-Definition/Scheme/doubly-linked-list-definition.scm b/Task/Doubly-linked-list-Definition/Scheme/doubly-linked-list-definition.ss similarity index 100% rename from Task/Doubly-linked-list-Definition/Scheme/doubly-linked-list-definition.scm rename to Task/Doubly-linked-list-Definition/Scheme/doubly-linked-list-definition.ss diff --git a/Task/Doubly-linked-list-Definition/Wren/doubly-linked-list-definition.wren b/Task/Doubly-linked-list-Definition/Wren/doubly-linked-list-definition.wren index 32cd3ca1e6..6df26a9d51 100644 --- a/Task/Doubly-linked-list-Definition/Wren/doubly-linked-list-definition.wren +++ b/Task/Doubly-linked-list-Definition/Wren/doubly-linked-list-definition.wren @@ -1,4 +1,4 @@ -import "./llist" for DLinkedList +import "/llist" for DLinkedList var dll = DLinkedList.new() for (i in 1..3) dll.add(i) diff --git a/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.adb b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.ada similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.adb rename to Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.ada diff --git a/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.adb b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.ada similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.adb rename to Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.ada diff --git a/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.adb b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.ada similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.adb rename to Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.ada diff --git a/Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.pas b/Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.delphi similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.pas rename to Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.delphi diff --git a/Task/Doubly-linked-list-Element-definition/Julia/doubly-linked-list-element-definition.jl b/Task/Doubly-linked-list-Element-definition/Julia/doubly-linked-list-element-definition.julia similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Julia/doubly-linked-list-element-definition.jl rename to Task/Doubly-linked-list-Element-definition/Julia/doubly-linked-list-element-definition.julia diff --git a/Task/Doubly-linked-list-Element-definition/Kotlin/doubly-linked-list-element-definition.kts b/Task/Doubly-linked-list-Element-definition/Kotlin/doubly-linked-list-element-definition.kotlin similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Kotlin/doubly-linked-list-element-definition.kts rename to Task/Doubly-linked-list-Element-definition/Kotlin/doubly-linked-list-element-definition.kotlin diff --git a/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-1.ml b/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-1.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-1.ml rename to Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-1.ocaml diff --git a/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-2.ml b/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-2.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-2.ml rename to Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-2.ocaml diff --git a/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-3.ml b/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-3.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-3.ml rename to Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-3.ocaml diff --git a/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-4.ml b/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-4.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-4.ml rename to Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-4.ocaml diff --git a/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-5.ml b/Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-5.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-5.ml rename to Task/Doubly-linked-list-Element-definition/OCaml/doubly-linked-list-element-definition-5.ocaml diff --git a/Task/Doubly-linked-list-Element-definition/Oberon/doubly-linked-list-element-definition.oberon b/Task/Doubly-linked-list-Element-definition/Oberon-2/doubly-linked-list-element-definition.oberon similarity index 100% rename from Task/Doubly-linked-list-Element-definition/Oberon/doubly-linked-list-element-definition.oberon rename to Task/Doubly-linked-list-Element-definition/Oberon-2/doubly-linked-list-element-definition.oberon diff --git a/Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas b/Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas deleted file mode 100644 index 41706415b2..0000000000 --- a/Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas +++ /dev/null @@ -1,4 +0,0 @@ -type Node = auto class - data: T; - prev,next: Node; -end; diff --git a/Task/Doubly-linked-list-Element-definition/Pluto/doubly-linked-list-element-definition.pluto b/Task/Doubly-linked-list-Element-definition/Pluto/doubly-linked-list-element-definition.pluto deleted file mode 100644 index 6172bb682a..0000000000 --- a/Task/Doubly-linked-list-Element-definition/Pluto/doubly-linked-list-element-definition.pluto +++ /dev/null @@ -1,9 +0,0 @@ -require "list" - -local s = dlist.of(1, 2, 3) -local n1 = s:node(1) -local n2 = s:node(2) -local n3 = s:node(3) -print($"node 1: value = {n1.value}, next = {tostring(n1.next?.value)}, prev = {tostring(n1.prev?.value)}") -print($"node 2: value = {n2.value}, next = {tostring(n2.next?.value)}, prev = {tostring(n2.prev?.value)}") -print($"node 3: value = {n3.value}, next = {tostring(n3.next?.value)}, prev = {tostring(n3.prev?.value)}") diff --git a/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition-1.rust b/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition-1.rust new file mode 100644 index 0000000000..14f822a8eb --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition-1.rust @@ -0,0 +1,5 @@ +use std::collections::LinkedList; +fn main() { + // Doubly linked list containing 32-bit integers + let list = LinkedList::::new(); +} diff --git a/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition-2.rust b/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition-2.rust new file mode 100644 index 0000000000..f05fe72380 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition-2.rust @@ -0,0 +1,12 @@ +pub struct LinkedList { + head: Option>>, + tail: Option>>, + len: usize, + marker: PhantomData>>, // Indicates that we logically own a boxed (owned pointer) Node> +} + +struct Node { + next: Option>>, + prev: Option>>, + element: T, +} diff --git a/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition.rs b/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition.rs deleted file mode 100644 index 235ae6bd30..0000000000 --- a/Task/Doubly-linked-list-Element-definition/Rust/doubly-linked-list-element-definition.rs +++ /dev/null @@ -1,5 +0,0 @@ -struct Node { - next: Option>>, - prev: Option>>, - element: T, -} diff --git a/Task/Doubly-linked-list-Element-definition/Wren/doubly-linked-list-element-definition.wren b/Task/Doubly-linked-list-Element-definition/Wren/doubly-linked-list-element-definition.wren index d37e9b8592..d31b98b123 100644 --- a/Task/Doubly-linked-list-Element-definition/Wren/doubly-linked-list-element-definition.wren +++ b/Task/Doubly-linked-list-Element-definition/Wren/doubly-linked-list-element-definition.wren @@ -1,4 +1,4 @@ -import "./llist" for DNode +import "/llist" for DNode var dn1 = DNode.new(1) var dn2 = DNode.new(2) diff --git a/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.adb b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.ada similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.adb rename to Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.ada diff --git a/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.adb b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.ada similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.adb rename to Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.ada diff --git a/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.adb b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.ada similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.adb rename to Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.ada diff --git a/Task/Doubly-linked-list-Element-insertion/Delphi/doubly-linked-list-element-insertion.pas b/Task/Doubly-linked-list-Element-insertion/Delphi/doubly-linked-list-element-insertion.delphi similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Delphi/doubly-linked-list-element-insertion.pas rename to Task/Doubly-linked-list-Element-insertion/Delphi/doubly-linked-list-element-insertion.delphi diff --git a/Task/Doubly-linked-list-Element-insertion/Julia/doubly-linked-list-element-insertion.jl b/Task/Doubly-linked-list-Element-insertion/Julia/doubly-linked-list-element-insertion.julia similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Julia/doubly-linked-list-element-insertion.jl rename to Task/Doubly-linked-list-Element-insertion/Julia/doubly-linked-list-element-insertion.julia diff --git a/Task/Doubly-linked-list-Element-insertion/Kotlin/doubly-linked-list-element-insertion.kts b/Task/Doubly-linked-list-Element-insertion/Kotlin/doubly-linked-list-element-insertion.kotlin similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Kotlin/doubly-linked-list-element-insertion.kts rename to Task/Doubly-linked-list-Element-insertion/Kotlin/doubly-linked-list-element-insertion.kotlin diff --git a/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-1.ml b/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-1.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-1.ml rename to Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-1.ocaml diff --git a/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-2.ml b/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-2.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-2.ml rename to Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-2.ocaml diff --git a/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-3.ml b/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-3.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-3.ml rename to Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-3.ocaml diff --git a/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-4.ml b/Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-4.ocaml similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-4.ml rename to Task/Doubly-linked-list-Element-insertion/OCaml/doubly-linked-list-element-insertion-4.ocaml diff --git a/Task/Doubly-linked-list-Element-insertion/Oberon/doubly-linked-list-element-insertion.oberon b/Task/Doubly-linked-list-Element-insertion/Oberon-2/doubly-linked-list-element-insertion.oberon similarity index 100% rename from Task/Doubly-linked-list-Element-insertion/Oberon/doubly-linked-list-element-insertion.oberon rename to Task/Doubly-linked-list-Element-insertion/Oberon-2/doubly-linked-list-element-insertion.oberon diff --git a/Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas b/Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas deleted file mode 100644 index 3b2f5422ce..0000000000 --- a/Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas +++ /dev/null @@ -1,33 +0,0 @@ -type Node = auto class - data: T; - prev,next: Node; -end; - -type - MyLinkedList = class - first, last: Node; - procedure AddLast(x: T); - begin - if first = nil then - begin - first := new Node(x,nil,nil); - last := first - end - else - begin - var p := new Node(x,last,nil); - last.next := p; - last := p; - end; - end; - procedure AddAfter(p: Node; x: T); - begin - if last = p then - AddLast(x) - else begin - var pp := new Node(x,p,p.next); - p.next := pp; - pp.prev.next := pp; - end - end; - end; diff --git a/Task/Doubly-linked-list-Element-insertion/Pluto/doubly-linked-list-element-insertion.pluto b/Task/Doubly-linked-list-Element-insertion/Pluto/doubly-linked-list-element-insertion.pluto deleted file mode 100644 index 8b25ea3df0..0000000000 --- a/Task/Doubly-linked-list-Element-insertion/Pluto/doubly-linked-list-element-insertion.pluto +++ /dev/null @@ -1,5 +0,0 @@ -require "list" - -local dll = dlist.of("A", "B") -dll:insert(2, "C") -print(dll) diff --git a/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-1.rs b/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-1.rs deleted file mode 100644 index 3c28daad17..0000000000 --- a/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(linked_list_cursors)] - -pub struct Cursor<'a, T: 'a> { - index: usize, - current: Option>>, - list: &'a LinkedList, -} - -pub struct CursorMut<'a, T: 'a> { - index: usize, - current: Option>>, - list: &'a mut LinkedList, -} diff --git a/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-1.rust b/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-1.rust new file mode 100644 index 0000000000..6846a0b845 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-1.rust @@ -0,0 +1,5 @@ +use std::collections::LinkedList; +fn main() { + let mut list = LinkedList::new(); + list.push_front(8); +} diff --git a/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-2.rs b/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-2.rs deleted file mode 100644 index 7f29f65ef6..0000000000 --- a/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-2.rs +++ /dev/null @@ -1,63 +0,0 @@ -#![feature(linked_list_cursors)] - -trait CursorExt { - fn insert_between(&mut self, l: &T, elt: T, r: &T); - fn rinsert_between(&mut self, l: &T, elt: T, r: &T); -} - -impl CursorExt for std::collections::linked_list::CursorMut<'_, T> { - fn insert_between(&mut self, l: &T, elt: T, r: &T) { - // Pointing at the sentinel, move to head - if self.current().is_none() { - self.move_next(); - } - - let next = |cursor: &mut Self| { - let left = cursor.current()? == a; - let right = cursor.peek_next()? == b; - - Some(left && right) - }; - - while let Some(found) = next(self) { - if found { - self.insert_after(elt); - - return; - } - } - } - - fn rinsert_between(&mut self, l: &T, elt: T, r: &T) { - // Pointing at the sentinel, move to tail - if self.current().is_none() { - self.move_prev(); - } - - let prev = |cursor: &mut Self| { - let left = cursor.peek_prev()? == a; - let right = cursor.current()? == b; - - Some(left && right) - }; - - while let Some(found) = prev(self) { - if found { - self.insert_before(elt); - - return; - } - } - } -} - -fn element_insertion() { - use std::collections::LinkedList; - - let mut list = LinkedList::from(['A', 'B']); - - list.cursor_front_mut().insert_between(&'A', 'C', &'B'); - // list.cursor_back_mut().rinsert_between(&'A', 'C', &'B'); - - assert_eq!(list, ['A', 'C', 'B'].into()); -} diff --git a/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-2.rust b/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-2.rust new file mode 100644 index 0000000000..3b478b7869 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Rust/doubly-linked-list-element-insertion-2.rust @@ -0,0 +1,52 @@ +impl Node { + fn new(v: T) -> Node { + Node {value: v, next: None, prev: Rawlink::none()} + } +} + +impl Rawlink { + fn none() -> Self { + Rawlink {p: ptr::null_mut()} + } + + fn some(n: &mut T) -> Rawlink { + Rawlink{p: n} + } +} + +impl<'a, T> From<&'a mut Link> for Rawlink> { + fn from(node: &'a mut Link) -> Self { + match node.as_mut() { + None => Rawlink::none(), + Some(ptr) => Rawlink::some(ptr) + } + } +} + + +fn link_no_prev(mut next: Box>) -> Link { + next.prev = Rawlink::none(); + Some(next) +} + +impl LinkedList { + #[inline] + fn push_front_node(&mut self, mut new_head: Box>) { + match self.list_head { + None => { + self.list_head = link_no_prev(new_head); + self.list_tail = Rawlink::from(&mut self.list_head); + } + Some(ref mut head) => { + new_head.prev = Rawlink::none(); + head.prev = Rawlink::some(&mut *new_head); + mem::swap(head, &mut new_head); + head.next = Some(new_head); + } + } + self.length += 1; + } + pub fn push_front(&mut self, elt: T) { + self.push_front_node(Box::new(Node::new(elt))); + } +} diff --git a/Task/Doubly-linked-list-Element-insertion/Wren/doubly-linked-list-element-insertion.wren b/Task/Doubly-linked-list-Element-insertion/Wren/doubly-linked-list-element-insertion.wren index bce2a79146..26c952f51f 100644 --- a/Task/Doubly-linked-list-Element-insertion/Wren/doubly-linked-list-element-insertion.wren +++ b/Task/Doubly-linked-list-Element-insertion/Wren/doubly-linked-list-element-insertion.wren @@ -1,4 +1,4 @@ -import "./llist" for DLinkedList +import "/llist" for DLinkedList var dll = DLinkedList.new(["A", "B"]) dll.insertAfter("A", "C") diff --git a/Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.adb b/Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.ada similarity index 100% rename from Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.adb rename to Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.ada diff --git a/Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.pas b/Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.delphi similarity index 100% rename from Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.pas rename to Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.delphi diff --git a/Task/Doubly-linked-list-Traversal/Julia/doubly-linked-list-traversal.jl b/Task/Doubly-linked-list-Traversal/Julia/doubly-linked-list-traversal.julia similarity index 100% rename from Task/Doubly-linked-list-Traversal/Julia/doubly-linked-list-traversal.jl rename to Task/Doubly-linked-list-Traversal/Julia/doubly-linked-list-traversal.julia diff --git a/Task/Doubly-linked-list-Traversal/Kotlin/doubly-linked-list-traversal.kts b/Task/Doubly-linked-list-Traversal/Kotlin/doubly-linked-list-traversal.kotlin similarity index 100% rename from Task/Doubly-linked-list-Traversal/Kotlin/doubly-linked-list-traversal.kts rename to Task/Doubly-linked-list-Traversal/Kotlin/doubly-linked-list-traversal.kotlin diff --git a/Task/Doubly-linked-list-Traversal/Oberon/doubly-linked-list-traversal.oberon b/Task/Doubly-linked-list-Traversal/Oberon-2/doubly-linked-list-traversal.oberon similarity index 100% rename from Task/Doubly-linked-list-Traversal/Oberon/doubly-linked-list-traversal.oberon rename to Task/Doubly-linked-list-Traversal/Oberon-2/doubly-linked-list-traversal.oberon diff --git a/Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas b/Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas deleted file mode 100644 index 5e67b3187f..0000000000 --- a/Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas +++ /dev/null @@ -1,9 +0,0 @@ -begin - var lst := new LinkedList(1..10); - var current := lst.First; - while current <> nil do - begin - Print(current.Value); - current := current.Next; - end; -end. diff --git a/Task/Doubly-linked-list-Traversal/Pluto/doubly-linked-list-traversal.pluto b/Task/Doubly-linked-list-Traversal/Pluto/doubly-linked-list-traversal.pluto deleted file mode 100644 index 17ae6ed4d6..0000000000 --- a/Task/Doubly-linked-list-Traversal/Pluto/doubly-linked-list-traversal.pluto +++ /dev/null @@ -1,24 +0,0 @@ -require "list" -local fmt = require "fmt" - --- Create a doubly-linked list containing the first 50 positive integers. -local d = dlist.of(range(1, 50):unpack()) - --- Now traverse from beginning to end and print them in tabular form. -local node = d:node(1) -local count = 0 -while node do - fmt.write("%4d ", node.value) - node = node.next - if ++count % 10 == 0 then print() end -end -print() - --- Now traverse them in the opposite direction and print then in tabular form. -node = d:node(d:size()) -count = 0 -while node do - fmt.write("%4d ", node.value) - node = node.prev - if ++count % 10 == 0 then print() end -end diff --git a/Task/Doubly-linked-list-Traversal/Rust/doubly-linked-list-traversal.rs b/Task/Doubly-linked-list-Traversal/Rust/doubly-linked-list-traversal.rs deleted file mode 100644 index 05a8db2f1a..0000000000 --- a/Task/Doubly-linked-list-Traversal/Rust/doubly-linked-list-traversal.rs +++ /dev/null @@ -1,15 +0,0 @@ -fn traversal() { - use std::collections::LinkedList; - - let numbers = LinkedList::from([1, 5, 7, 0, 3, 2]); - - for i in &numbers { - print!("{i} "); - } - println!(); - - for i in numbers.iter().rev() { - print!("{i} "); - } - println!(); -} diff --git a/Task/Doubly-linked-list-Traversal/Wren/doubly-linked-list-traversal.wren b/Task/Doubly-linked-list-Traversal/Wren/doubly-linked-list-traversal.wren index aec802cb84..65abc87df2 100644 --- a/Task/Doubly-linked-list-Traversal/Wren/doubly-linked-list-traversal.wren +++ b/Task/Doubly-linked-list-Traversal/Wren/doubly-linked-list-traversal.wren @@ -1,5 +1,5 @@ -import "./llist" for DLinkedList -import "./fmt" for Fmt +import "/llist" for DLinkedList +import "/fmt" for Fmt // create a new doubly-linked list and add the first 50 positive integers to it var dll = DLinkedList.new(1..50) diff --git a/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg b/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg deleted file mode 100644 index 4d180563f7..0000000000 --- a/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg +++ /dev/null @@ -1,60 +0,0 @@ -BEGIN # Dragon Curve in SVG # - # uses the RC Algol 68 L-System library for the L-System evaluation & # - # interpretation # - - PR read "lsystem.incl.a68" PR # include L-System utilities # - - PROC dragon curve = ( STRING fname, INT size, length, order, init x, init y )VOID: - IF FILE svg file; - BOOL open error := IF open( svg file, fname, stand out channel ) = 0 - THEN - # opened OK - file already exists and # - # will be overwritten # - FALSE - ELSE - # failed to open the file # - # - try creating a new file # - establish( svg file, fname, stand out channel ) /= 0 - FI; - open error - THEN # failed to open the file # - print( ( "Unable to open ", fname, newline ) ); - stop - ELSE # file opened OK # - - REAL x := init x; - REAL y := init y; - INT angle := 0; - put( svg file, ( "" - , newline, "" - , newline, "", newline, "", newline ) ); - close( svg file ) - FI # dragon curve # ; - - dragon curve( "dragon.svg", 1200, 5, 12, 400, 200 ) - -END diff --git a/Task/Dragon-curve/ANSI-BASIC/dragon-curve.basic b/Task/Dragon-curve/ANSI-BASIC/dragon-curve.basic deleted file mode 100644 index 4d59f8ebc9..0000000000 --- a/Task/Dragon-curve/ANSI-BASIC/dragon-curve.basic +++ /dev/null @@ -1,35 +0,0 @@ -100 PROGRAM DragonCurve -110 DECLARE SUB Dragon -120 SET WINDOW 0, 639, 0, 399 -130 SET AREA COLOR 1 -140 SET COLOR MIX(1) 0, 0, 0 -150 REM SIN, COS in arrays for PI/4 multipl. -160 DIM S(0 TO 7), C(0 TO 7) -170 LET QPI = PI / 4 -180 FOR I = 0 TO 7 -190 LET S(I) = SIN(I * QPI) -200 LET C(I) = COS(I * QPI) -210 NEXT I -220 REM ** Initialize variables non-local for SUB Dragon. -230 LET SQ = SQR(2) -240 LET X = 224 -250 LET Y = 140 -260 LET RotQPi = 0 -270 CALL Dragon(256, 15, 1) ! Insize = 2^WHOLE_NUM (looks better) -280 REM ** Subprogram -290 SUB Dragon (Insize, Level, RQ) -300 IF Level <= 1 THEN -310 LET XN = C(RotQPi) * Insize + X -320 LET YN = S(RotQPi) * Insize + Y -330 PLOT LINES: X, 399 - Y; XN, 399 - YN -340 LET X = XN -350 LET Y = YN -360 ELSE -370 LET RotQPi = MOD((RotQPi + RQ), 8) -380 CALL Dragon(Insize / SQ, Level - 1, 1) -390 LET RotQPi = MOD((RotQPi - RQ * 2), 8) -400 CALL Dragon(Insize / SQ, Level - 1, -1) -410 LET RotQPi = MOD((RotQPi + RQ), 8) -420 END IF -430 END SUB -440 END diff --git a/Task/Dragon-curve/ASIC/dragon-curve.asic b/Task/Dragon-curve/ASIC/dragon-curve.asic deleted file mode 100644 index 5697f69b99..0000000000 --- a/Task/Dragon-curve/ASIC/dragon-curve.asic +++ /dev/null @@ -1,130 +0,0 @@ -REM Dragon curve -DIM S@(7) -DIM C@(7) -DIM R(27) -REM SIN, COS in arrays for PI/4 multipl. -DATA 0@, 0.70711@, 1@, 0.70711@, 0@, -0.70711@, -1@, -0.70711@ -DATA 1@, 0.70711@, 0@, -0.70711@, -1@, -0.70711@, 0@, 0.70711@ -Sqrt2@ = 1.41421@ -FOR I = 0 TO 7 - READ S@(I) -NEXT I -FOR I = 0 TO 7 - READ C@(I) -NEXT I -Level = 17 -Insize@ = 256 -REM Insize@ = 2^WHOLE_NUM looks fine -X@ = 224 -Y@ = 124 -RotQPi = 0 -RQ = 1 -SCREEN 9 -GOSUB Dragon: -LOCATE 20, 1 -PRINT "Press any key to exit." -Loop: - X$=INKEY$ - IF X$="" THEN Loop: -SCREEN 0 -END - -Dragon: -RotQPi = RotQPi MOD 8 -WHILE RotQPi < 0 - RotQPi = RotQPi + 8 -WEND -IF Level <= 1 THEN - YN@ = S@(RotQPi) * Insize@ - YN@ = YN@ + Y@ - XN@ = C@(RotQPi) * Insize@ - XN@ = XN@ + X@ - GOSUB DrawLine: - X@ = XN@ - Y@ = YN@ -ELSE - Insize@ = Insize@ * Sqrt2@ - Insize@ = Insize@ / 2@ - RotQPi = RotQPi + RQ - RotQPi = RotQPi MOD 8 - WHILE RotQPi < 0 - RotQPi = RotQPi + 8 - WEND - Level = Level - 1 - R(Level) = RQ - RQ = 1 - GOSUB Dragon: - RLevelM2 = R(Level) * 2 - RotQPi = RotQPi - RLevelM2 - RotQPi = RotQPi MOD 8 - WHILE RotQPi < 0 - RotQPi = RotQPi + 8 - WEND - RQ = -1 - GOSUB Dragon: - RQ = R(Level) - RotQPi = RotQPi + RQ - RotQPi = RotQPi MOD 8 - WHILE RotQPi < 0 - RotQPi = RotQPi + 8 - WEND - Level = Level + 1 - Insize@ = Insize@ * Sqrt2@ -ENDIF -RETURN - -DrawLine: -REM Draw a line from (X@, Y@) to (XN@, YN@) -REM Coordinates decimal, but converted in PSET. -DX@ = XN@ - X@ -DY@ = YN@ - Y@ -AbsDX@ = ABS(DX@) -AbsDY@ = ABS(DY@) -IF AbsDX@ <= AbsDY@ THEN - REM More vertical line - IF AbsDY@ <= 1@ THEN - REM The same pixel or neighboring ones, because AbsDX@ <= AbsDY@ <= 1. - PSET (Y@, X@), 10 - PSET (YN@, XN@), 10 - ELSE - REM There are pixels in between. - A@ = DX@ / DY@ - IF YN@ >= Y@ THEN - D@ = 1@ - ELSE - D@ = -1@ - ENDIF - CoordY@ = Y@ - WHILE CoordY@ <= YN@ - CoordX@ = CoordY@ - Y@ - CoordX@ = A@ * CoordX@ - CoordX@ = X@ + CoordX@ - PSET (CoordY@, CoordX@), 10 - CoordY@ = CoordY@ + D@ - WEND - ENDIF -ELSE - REM More horizontal line - IF AbsDX@ <= 1@ THEN - REM The same pixel or neighboring ones, because AbsDY@ < AbsDX@ <= 1. - PSET (Y@, X@), 10 - PSET (YN@, XN@), 10 - ELSE - REM There are pixels in between. - A@ = DY@ / DX@ - IF XN@ >= X@ THEN - D@ = 1@ - ELSE - D@ = -1@ - ENDIF - CoordX@ = X@ - WHILE CoordX@ <= XN@ - CoordY@ = CoordX@ - X@ - CoordY@ = A@ * CoordY@ - CoordY@ = Y@ + CoordY@ - PSET (CoordY@, CoordX@), 10 - CoordX@ = CoordX@ + D@ - WEND - ENDIF -ENDIF -RETURN diff --git a/Task/Dragon-curve/Ada/dragon-curve-1.adb b/Task/Dragon-curve/Ada/dragon-curve-1.ada similarity index 100% rename from Task/Dragon-curve/Ada/dragon-curve-1.adb rename to Task/Dragon-curve/Ada/dragon-curve-1.ada diff --git a/Task/Dragon-curve/Ada/dragon-curve-2.adb b/Task/Dragon-curve/Ada/dragon-curve-2.ada similarity index 100% rename from Task/Dragon-curve/Ada/dragon-curve-2.adb rename to Task/Dragon-curve/Ada/dragon-curve-2.ada diff --git a/Task/Dragon-curve/Ada/dragon-curve-3.adb b/Task/Dragon-curve/Ada/dragon-curve-3.ada similarity index 100% rename from Task/Dragon-curve/Ada/dragon-curve-3.adb rename to Task/Dragon-curve/Ada/dragon-curve-3.ada diff --git a/Task/Dragon-curve/Ada/dragon-curve-4.adb b/Task/Dragon-curve/Ada/dragon-curve-4.ada similarity index 100% rename from Task/Dragon-curve/Ada/dragon-curve-4.adb rename to Task/Dragon-curve/Ada/dragon-curve-4.ada diff --git a/Task/Dragon-curve/Applesoft-BASIC/dragon-curve.basic b/Task/Dragon-curve/Applesoft-BASIC/dragon-curve.basic deleted file mode 100644 index b9f8bff709..0000000000 --- a/Task/Dragon-curve/Applesoft-BASIC/dragon-curve.basic +++ /dev/null @@ -1,37 +0,0 @@ -10 REM Dragon curve -20 DEF FN MOD(M) = M - INT(M / 8) * 8 -30 REM SIN, COS in arrays for PI/4 multipl. -40 DIM S(7), C(7) -50 QPI = ATN(1): SQ = SQR(2) -60 FOR I = 0 TO 7 -70 S(I) = SIN(I * QPI): C(I) = COS(I * QPI) -80 NEXT I -90 LEVEL = 15 -100 INSIZE = 128: REM 2^WHOLE_NUM (looks better) -110 X = 98: Y = 68 -120 ROTQPI = 0: RQ = 1 -130 DIM R(LEVEL) -140 HGR2: HCOLOR = 1 -150 GOSUB 170 -160 END -170 REM ** Dragon -180 ROTQPI = FN MOD8(ROTQPI) -190 IF LEVEL > 1 THEN GOTO 250 -200 YN = S(ROTQPI) * INSIZE + Y -210 XN = C(ROTQPI) * INSIZE + X -220 HPLOT X, Y TO XN, YN -230 X = XN: Y = YN -240 RETURN -250 INSIZE = INSIZE * SQ / 2 -260 ROTQPI = FN MOD8(ROTQPI + RQ) -270 LEVEL = LEVEL - 1 -280 R(LEVEL) = RQ: RQ = 1 -290 GOSUB 170 -300 ROTQPI = FN MOD8(ROTQPI - R(LEVEL) * 2) -310 RQ = -1 -320 GOSUB 170 -330 RQ = R(LEVEL) -340 ROTQPI = FN MOD8(ROTQPI + RQ) -350 LEVEL = LEVEL + 1 -360 INSIZE = INSIZE * SQ -370 RETURN diff --git a/Task/Dragon-curve/BASIC/dragon-curve.basic b/Task/Dragon-curve/BASIC/dragon-curve.basic index 7b94fc271c..249e1fcd18 100644 --- a/Task/Dragon-curve/BASIC/dragon-curve.basic +++ b/Task/Dragon-curve/BASIC/dragon-curve.basic @@ -12,11 +12,11 @@ SUB dragon (length AS Double, split AS Integer, d AS Double) IF split=0 THEN forward length ELSE - turn d*45 - dragon length/1.4142136, split-1, 1 - turn -d*90 - dragon length/1.4142136, split-1, -1 - turn d*45 + turn d*45 + dragon length/1.4142136, split-1, 1 + turn -d*90 + dragon length/1.4142136, split-1, -1 + turn d*45 END IF END SUB diff --git a/Task/Dragon-curve/BASIC256/dragon-curve.basic b/Task/Dragon-curve/BASIC256/dragon-curve.basic index 03e75f4098..25b1b0983a 100644 --- a/Task/Dragon-curve/BASIC256/dragon-curve.basic +++ b/Task/Dragon-curve/BASIC256/dragon-curve.basic @@ -2,15 +2,15 @@ graphsize 390,270 -level = 18 : insize = 247 # initial values -x = 92 : y = 94 # +level = 18 : insize = 247 # initial values +x = 92 : y = 94 # -iters = 2^level # total number of iterations -qiter = 510/iters # constant for computing colors -SQ = sqrt(2) : QPI = pi/4 # constants +iters = 2^level # total number of iterations +qiter = 510/iters # constant for computing colors +SQ = sqrt(2) : QPI = pi/4 # constants -rotation = 0 : iter = 0 : rq = 1.0 # state variables -dim rqs(level) # stack for rq (rotation coefficient) +rotation = 0 : iter = 0 : rq = 1.0 # state variables +dim rqs(level) # stack for rq (rotation coefficient) color white fastgraphics @@ -22,29 +22,29 @@ imgsave "Dragon_curve_BASIC-256.png", "PNG" end dragon: - if level<=0 then - yn = sin(rotation)*insize + y - xn = cos(rotation)*insize + x - if iter*2r += c; p->g += X; return; - case 1: p->r += X; p->g += c; return; - case 2: p->g += c; p->b += X; return; - case 3: p->g += X; p->b += c; return; - case 4: p->r += X; p->b += c; return; - default: - p->r += c; p->b += X; - } + switch((int)h) { + case 0: p->r += c; p->g += X; return; + case 1: p->r += X; p->g += c; return; + case 2: p->g += c; p->b += X; return; + case 3: p->g += X; p->b += c; return; + case 4: p->r += X; p->b += c; return; + default: + p->r += c; p->b += X; + } } /* string rewriting. No need to keep the string itself, just execute @@ -53,16 +53,16 @@ void h_rgb(long long x, long long y) */ void iter_string(const char * str, int d) { - long tmp; -# define LEFT tmp = -dy; dy = dx; dx = tmp -# define RIGHT tmp = dy; dy = -dx; dx = tmp - while (*str != '\0') { - switch(*(str++)) { - case 'X': if (d) iter_string("X+YF+", d - 1); continue; - case 'Y': if (d) iter_string("-FX-Y", d - 1); continue; - case '+': RIGHT; continue; - case '-': LEFT; continue; - case 'F': + long tmp; +# define LEFT tmp = -dy; dy = dx; dx = tmp +# define RIGHT tmp = dy; dy = -dx; dx = tmp + while (*str != '\0') { + switch(*(str++)) { + case 'X': if (d) iter_string("X+YF+", d - 1); continue; + case 'Y': if (d) iter_string("-FX-Y", d - 1); continue; + case '+': RIGHT; continue; + case '-': LEFT; continue; + case 'F': /* draw: increment path length; add color; move. Here * is why the code does not allow user to choose arbitrary * image size: if it's not a power of two, aliasing will @@ -71,59 +71,59 @@ void iter_string(const char * str, int d) * involves computing multiplicative order and would be a huge * bore. */ - clen ++; - h_rgb(x/scale, y/scale); - x += dx; y += dy; - continue; - } - } + clen ++; + h_rgb(x/scale, y/scale); + x += dx; y += dy; + continue; + } + } } void dragon(long leng, int depth) { - long i, d = leng / 3 + 1; - long h = leng + 3, w = leng + d * 3 / 2 + 2; + long i, d = leng / 3 + 1; + long h = leng + 3, w = leng + d * 3 / 2 + 2; - /* allocate pixel buffer */ - rgb *buf = malloc(sizeof(rgb) * w * h); - pix = malloc(sizeof(rgb *) * h); - for (i = 0; i < h; i++) - pix[i] = buf + w * i; - memset(buf, 0, sizeof(rgb) * w * h); + /* allocate pixel buffer */ + rgb *buf = malloc(sizeof(rgb) * w * h); + pix = malloc(sizeof(rgb *) * h); + for (i = 0; i < h; i++) + pix[i] = buf + w * i; + memset(buf, 0, sizeof(rgb) * w * h); /* init coords; scale up to desired; exec string */ - x = y = d; dx = leng; dy = 0; scale = 1; clen = 0; - for (i = 0; i < depth; i++) sc_up(); - iter_string("FX", depth); + x = y = d; dx = leng; dy = 0; scale = 1; clen = 0; + for (i = 0; i < depth; i++) sc_up(); + iter_string("FX", depth); - /* write color PNM file */ - unsigned char *fpix = malloc(w * h * 3); - double maxv = 0, *dbuf = (double*)buf; + /* write color PNM file */ + unsigned char *fpix = malloc(w * h * 3); + double maxv = 0, *dbuf = (double*)buf; /* find highest value among pixels; normalize image according * to it. Highest value would be at points most travelled, so * this ends up giving curve edge a nice fade -- it's more apparaent * if we increase iteration depth by one or two. */ - for (i = 3 * w * h - 1; i >= 0; i--) - if (dbuf[i] > maxv) maxv = dbuf[i]; - for (i = 3 * h * w - 1; i >= 0; i--) - fpix[i] = 255 * dbuf[i] / maxv; + for (i = 3 * w * h - 1; i >= 0; i--) + if (dbuf[i] > maxv) maxv = dbuf[i]; + for (i = 3 * h * w - 1; i >= 0; i--) + fpix[i] = 255 * dbuf[i] / maxv; - printf("P6\n%ld %ld\n255\n", w, h); - fflush(stdout); /* printf and fwrite may treat buffer differently */ - fwrite(fpix, h * w * 3, 1, stdout); + printf("P6\n%ld %ld\n255\n", w, h); + fflush(stdout); /* printf and fwrite may treat buffer differently */ + fwrite(fpix, h * w * 3, 1, stdout); } int main(int c, char ** v) { - int size, depth; + int size, depth; - depth = (c > 1) ? atoi(v[1]) : 10; - size = 1 << depth; + depth = (c > 1) ? atoi(v[1]) : 10; + size = 1 << depth; - fprintf(stderr, "size: %d depth: %d\n", size, depth); - dragon(size, depth * 2); + fprintf(stderr, "size: %d depth: %d\n", size, depth); + dragon(size, depth * 2); - return 0; + return 0; } diff --git a/Task/Dragon-curve/COBOL/dragon-curve.cob b/Task/Dragon-curve/COBOL/dragon-curve.cobol similarity index 100% rename from Task/Dragon-curve/COBOL/dragon-curve.cob rename to Task/Dragon-curve/COBOL/dragon-curve.cobol diff --git a/Task/Dragon-curve/Delphi/dragon-curve.pas b/Task/Dragon-curve/Delphi/dragon-curve.delphi similarity index 100% rename from Task/Dragon-curve/Delphi/dragon-curve.pas rename to Task/Dragon-curve/Delphi/dragon-curve.delphi diff --git a/Task/Dragon-curve/EasyLang/dragon-curve.easy b/Task/Dragon-curve/EasyLang/dragon-curve.easy index c789f92105..d0a38105c7 100644 --- a/Task/Dragon-curve/EasyLang/dragon-curve.easy +++ b/Task/Dragon-curve/EasyLang/dragon-curve.easy @@ -1,18 +1,19 @@ -gcolor 050 -glinewidth 0.5 +color 050 +linewidth 0.5 x = 25 y = 60 +move x y angle = 0 # -proc dragon size lev d . +proc dragon size lev d . . if lev = 0 x -= cos angle * size y += sin angle * size - glineto x y + line x y else - dragon size / sqrt 2 lev - 1 1 + call dragon size / sqrt 2 lev - 1 1 angle -= d * 90 - dragon size / sqrt 2 lev - 1 -1 + call dragon size / sqrt 2 lev - 1 -1 . . -dragon 60 12 1 +call dragon 60 12 1 diff --git a/Task/Dragon-curve/Emacs-Lisp/dragon-curve.el b/Task/Dragon-curve/Emacs-Lisp/dragon-curve.l similarity index 100% rename from Task/Dragon-curve/Emacs-Lisp/dragon-curve.el rename to Task/Dragon-curve/Emacs-Lisp/dragon-curve.l diff --git a/Task/Dragon-curve/Haskell/dragon-curve-2.hs b/Task/Dragon-curve/Haskell/dragon-curve-2.hs index ddb5a8b72a..797d72b985 100644 --- a/Task/Dragon-curve/Haskell/dragon-curve-2.hs +++ b/Task/Dragon-curve/Haskell/dragon-curve-2.hs @@ -4,8 +4,8 @@ y 0 = "" y n = " - f"++(x$n-1)++" -"++(y$n-1) dragon n = - concat ["0 setlinewidth 300 400 moveto", - "/f{2 0 rlineto}def/+{90 rotate}def/-{-90 rotate}def\n", - "f", x n, " stroke showpage"] + concat ["0 setlinewidth 300 400 moveto", + "/f{2 0 rlineto}def/+{90 rotate}def/-{-90 rotate}def\n", + "f", x n, " stroke showpage"] main = putStrLn $ dragon 14 diff --git a/Task/Dragon-curve/Julia/dragon-curve.jl b/Task/Dragon-curve/Julia/dragon-curve.julia similarity index 100% rename from Task/Dragon-curve/Julia/dragon-curve.jl rename to Task/Dragon-curve/Julia/dragon-curve.julia diff --git a/Task/Dragon-curve/Kotlin/dragon-curve.kts b/Task/Dragon-curve/Kotlin/dragon-curve.kotlin similarity index 100% rename from Task/Dragon-curve/Kotlin/dragon-curve.kts rename to Task/Dragon-curve/Kotlin/dragon-curve.kotlin diff --git a/Task/Dragon-curve/Locomotive-Basic/dragon-curve.basic b/Task/Dragon-curve/Locomotive-Basic/dragon-curve.basic deleted file mode 100644 index 6cf4caa101..0000000000 --- a/Task/Dragon-curve/Locomotive-Basic/dragon-curve.basic +++ /dev/null @@ -1,29 +0,0 @@ -100 MODE 2 -110 DIM s(7),c(7) -120 qpi=ATN(1):sq2=SQR(2) -130 FOR i=0 TO 7 -140 s(i)=SIN(i*qpi) -150 c(i)=COS(i*qpi) -160 NEXT -170 level=11 -180 DIM r(level) -190 insize=128*2 -200 MOVE 200,150 -210 rotqpi=0:rq=1 -220 GOSUB 250 -230 END -240 ' -250 IF level=1 THEN DRAWR c(rotqpi)*insize,s(rotqpi)*insize:RETURN -260 insize=insize*sq2/2 -270 rotqpi=(rotqpi+rq) AND 7 -280 level=level-1 -290 r(level)=rq:rq=1 -300 GOSUB 250 -310 rotqpi=(rotqpi-r(level)*2) AND 7 -320 rq=-1 -330 GOSUB 250 -340 rq=r(level) -350 rotqpi=(rotqpi+rq) AND 7 -360 level=level+1 -370 insize=insize*sq2 -380 RETURN diff --git a/Task/Dragon-curve/Metafont/dragon-curve.metafont b/Task/Dragon-curve/Metafont/dragon-curve.metafont index 446a318703..a2061d786f 100644 --- a/Task/Dragon-curve/Metafont/dragon-curve.metafont +++ b/Task/Dragon-curve/Metafont/dragon-curve.metafont @@ -7,10 +7,10 @@ beginchar("D", 25pt#, 25pt#, 0pt#); for i = 1 upto dragoniter: for v = 1 step mstep until (2-mstep): if unknown z[v+mstep]: - pair t; - t := .7071[ z[v], z[v+2mstep] ]; - z[v+mstep] = t rotatedaround(z[v], 45sg); - sg := -1*sg; + pair t; + t := .7071[ z[v], z[v+2mstep] ]; + z[v+mstep] = t rotatedaround(z[v], 45sg); + sg := -1*sg; fi endfor mstep := mstep/2; diff --git a/Task/Dragon-curve/Nascom-BASIC/dragon-curve.basic b/Task/Dragon-curve/Nascom-BASIC/dragon-curve.basic deleted file mode 100644 index 2f42679f86..0000000000 --- a/Task/Dragon-curve/Nascom-BASIC/dragon-curve.basic +++ /dev/null @@ -1,54 +0,0 @@ -10 REM Dragon curve -20 REM SIN, COS in arrays for PI/4 multipl. -30 DIM S(7), C(7) -40 QPI=ATN(1):SQ=SQR(2) -50 FOR I=0 TO 7 -60 S(I)=SIN(I*QPI):C(I)=COS(I*QPI) -70 NEXT I -80 LEVEL=15 -90 INSIZE=32:REM 2^WHOLE_NUM (looks better) -100 X=34:Y=16 -110 ROTQPI=0:RQ=1 -120 DIM R(LEVEL) -130 CLS -140 GOSUB 160 -150 END -160 REM ** Dragon -170 ROTQPI=ROTQPI AND 7 -180 IF LEVEL>1 THEN GOTO 240 -190 YN=S(ROTQPI)*INSIZE+Y -200 XN=C(ROTQPI)*INSIZE+X -210 GOSUB 370 -220 X=XN:Y=YN -230 RETURN -240 INSIZE=INSIZE*SQ/2 -250 ROTQPI=(ROTQPI+RQ)AND 7 -260 LEVEL=LEVEL-1 -270 R(LEVEL)=RQ:RQ=1 -280 GOSUB 160 -290 ROTQPI=(ROTQPI-R(LEVEL)*2)AND 7 -300 RQ=-1 -310 GOSUB 160 -320 RQ=R(LEVEL) -330 ROTQPI=(ROTQPI+RQ)AND 7 -340 LEVEL=LEVEL+1 -350 INSIZE=INSIZE*SQ -360 RETURN -370 REM ** Draw a line from (X, Y) to (XN, YN) -380 IF ABS(XN-X)>1 OR ABS(YN-Y)>1 THEN 400 -390 SET(X,Y):SET(XN,YN):RETURN -400 IF ABS(XN-X)>ABS(YN-Y) THEN 480 -410 REM More vertical line -420 A=(XN-X)/(YN-Y) -430 IF YN>Y THEN D=1 ELSE D=-1 -440 FOR YC=Y TO YN STEP D -450 SET(X+A*(YC-Y),YC) -460 NEXT YC -470 RETURN -480 REM More horizontal line -490 A=(YN-Y)/(XN-X) -500 IF XN>X THEN D=1 ELSE D=-1 -510 FOR XC=X TO XN STEP D -520 SET(XC,Y+A*(XC-X)) -530 NEXT XC -540 RETURN diff --git a/Task/Dragon-curve/OCaml/dragon-curve-1.ml b/Task/Dragon-curve/OCaml/dragon-curve-1.ocaml similarity index 100% rename from Task/Dragon-curve/OCaml/dragon-curve-1.ml rename to Task/Dragon-curve/OCaml/dragon-curve-1.ocaml diff --git a/Task/Dragon-curve/OCaml/dragon-curve-2.ml b/Task/Dragon-curve/OCaml/dragon-curve-2.ocaml similarity index 100% rename from Task/Dragon-curve/OCaml/dragon-curve-2.ml rename to Task/Dragon-curve/OCaml/dragon-curve-2.ocaml diff --git a/Task/Dragon-curve/PascalABC.NET/dragon-curve.pas b/Task/Dragon-curve/PascalABC.NET/dragon-curve.pas deleted file mode 100644 index 7ac53bfab2..0000000000 --- a/Task/Dragon-curve/PascalABC.NET/dragon-curve.pas +++ /dev/null @@ -1,34 +0,0 @@ -uses Turtle; - -var - Atom,FStr,XStr,YStr: string; - angle,len,x0,y0: real; - n: integer; - -procedure Init1; // Dragon -begin - (Atom,FStr,XStr,YStr) := ('fx','f','x+yf+','-fx-y'); - (angle,len,n,x0,y0) := (90,3,15,300,450); -end; - -procedure RunStr(s: string; n: integer); -begin - foreach var c in s do - case c of - '+': Turn(angle); - '-': Turn(-angle); - 'f','F': if n>0 then RunStr(FStr,n-1) else Forw(len); - 'x','X': if n>0 then RunStr(XStr,n-1); - 'y','Y': if n>0 then RunStr(YStr,n-1); - else Print('error') - end; -end; - -begin - Init1; - ToPoint(x0,y0); - SetWidth(0.5); - Down; - RunStr(Atom,n); - Up; -end. diff --git a/Task/Dragon-curve/Pluto/dragon-curve.pluto b/Task/Dragon-curve/Pluto/dragon-curve.pluto deleted file mode 100644 index 52840da6b5..0000000000 --- a/Task/Dragon-curve/Pluto/dragon-curve.pluto +++ /dev/null @@ -1,43 +0,0 @@ -require "bitmap" -require "table2" - -local bmp = bitmap.of(800, 600, color.black, "Dragon curve") - -local function get_sequence(iterations) - local turn_sequence = {} - for _ = 1, iterations do - local copy = {} - copy:join(turn_sequence) - if #copy > 1 then copy:reverse() end - turn_sequence:insert(1) - copy:foreach(|i| -> turn_sequence:insert(-i)) - end - return turn_sequence -end - -local function dragon(turns, starting_angle, side) - local col = pico.blue - local angle = starting_angle - local x1 = 230 - local y1 = 350 - local x2 = x1 + math.trunc(math.cos(angle) * side) - local y2 = y1 + math.trunc(math.sin(angle) * side) - bmp:line(x1, y1, x2, y2, col) - x1 = x2 - y1 = y2 - for turns as turn do - angle += turn * math.pi / 2 - x2 = x1 + math.trunc(math.cos(angle) * side) - y2 = y1 + math.trunc(math.sin(angle) * side) - bmp:line(x1, y1, x2, y2, col) - x1 = x2 - y1 = y2 - end -end - -local iter = 14 -local turns = get_sequence(iter) -local starting_angle = -iter * math.pi / 4 -local side = 400 / (2 ^ (iter / 2)) -dragon(turns, starting_angle, side) -bmp:view() diff --git a/Task/Dragon-curve/Prolog/dragon-curve.pro b/Task/Dragon-curve/Prolog/dragon-curve.pro index fa667e6ce7..cca7a2d174 100644 --- a/Task/Dragon-curve/Prolog/dragon-curve.pro +++ b/Task/Dragon-curve/Prolog/dragon-curve.pro @@ -1,60 +1,60 @@ dragonCurve(N) :- - dcg_dg(N, [left], DCL, []), - Side = 4, - Angle is -N * (pi/4), - dcg_computePath(Side, Angle, DCL, point(180,400), P, []), - new(D, window('Dragon Curve')), - send(D, size, size(800,600)), - new(Path, path(poly)), - send_list(Path, append, P), - send(D, display, Path), - send(D, open). + dcg_dg(N, [left], DCL, []), + Side = 4, + Angle is -N * (pi/4), + dcg_computePath(Side, Angle, DCL, point(180,400), P, []), + new(D, window('Dragon Curve')), + send(D, size, size(800,600)), + new(Path, path(poly)), + send_list(Path, append, P), + send(D, display, Path), + send(D, open). % compute the list of points of the Dragon Curve dcg_computePath(Side, Angle, [left | DCT], point(X1, Y1)) --> - [point(X1, Y1)], - { X2 is X1 + Side * cos(Angle), - Y2 is Y1 + Side * sin(Angle), - Angle1 is Angle + pi / 2 - }, - dcg_computePath(Side, Angle1, DCT, point(X2, Y2)). + [point(X1, Y1)], + { X2 is X1 + Side * cos(Angle), + Y2 is Y1 + Side * sin(Angle), + Angle1 is Angle + pi / 2 + }, + dcg_computePath(Side, Angle1, DCT, point(X2, Y2)). dcg_computePath(Side, Angle, [right | DCT], point(X1, Y1)) --> - [point(X1, Y1)], - { X2 is X1 + Side * cos(Angle), - Y2 is Y1 + Side * sin(Angle), - Angle1 is Angle - pi / 2 - }, - dcg_computePath(Side, Angle1, DCT, point(X2, Y2)). + [point(X1, Y1)], + { X2 is X1 + Side * cos(Angle), + Y2 is Y1 + Side * sin(Angle), + Angle1 is Angle - pi / 2 + }, + dcg_computePath(Side, Angle1, DCT, point(X2, Y2)). dcg_computePath(_Side, _Angle, [], point(X1, Y1)) --> - [ point(X1, Y1)]. + [ point(X1, Y1)]. % compute the list of the "turns" of the Dragon Curve dcg_dg(1, L) --> L. dcg_dg(N, L) --> - {dcg_dg(L, L1, []), - N1 is N - 1}, - dcg_dg(N1, L1). + {dcg_dg(L, L1, []), + N1 is N - 1}, + dcg_dg(N1, L1). % one interation of the process dcg_dg(L) --> - L, - [left], - inverse(L). + L, + [left], + inverse(L). inverse([H | T]) --> - inverse(T), - inverse(H). + inverse(T), + inverse(H). inverse([]) --> []. inverse(left) --> - [right]. + [right]. inverse(right) --> - [left]. + [left]. diff --git a/Task/Dragon-curve/Raku/dragon-curve.raku b/Task/Dragon-curve/Raku/dragon-curve.raku index 09ffdd7994..65d40f60b8 100644 --- a/Task/Dragon-curve/Raku/dragon-curve.raku +++ b/Task/Dragon-curve/Raku/dragon-curve.raku @@ -3,7 +3,7 @@ use SVG; role Lindenmayer { has %.rules; method succ { - self.comb.map( { %!rules{$^c} // $c } ).join but Lindenmayer(%!rules) + self.comb.map( { %!rules{$^c} // $c } ).join but Lindenmayer(%!rules) } } diff --git a/Task/Dragon-curve/Rebol/dragon-curve.rebol b/Task/Dragon-curve/Rebol/dragon-curve.rebol deleted file mode 100644 index 43e3817fca..0000000000 --- a/Task/Dragon-curve/Rebol/dragon-curve.rebol +++ /dev/null @@ -1,67 +0,0 @@ -Rebol [ - title: "Rosetta code: Dragon curve" - file: %Dragon_curve.r3 - url: https://rosettacode.org/wiki/Dragon_curve - needs: 3.0.0 -] - -bit-count: function [n [integer!]] [ - count: 0 - while [n > 0] [ - count: count + (n & 1) ;; add lowest bit - n: n >> 1 ;; logical right-shift by 1 - ] - count -] - -dragon-curve: function [steps [integer!]][ - ;; Initialize state - x: y: minx: maxx: miny: maxy: 0 - data: make map! [] - - ;; Loop for each step - for i 0 steps 1 [ - ;; Convert iteration number to direction using Gray code modulo 4 - dir: (bit-count (i xor (i >> 1))) % 4 - - ;; Compute next coordinates - nx: x + pickz [1 0 -1 0] dir - ny: y + pickz [0 1 0 -1] dir - - ;; Determine outbound/inbound bits - set [ob: ib:] pickz [[8 4] [2 1] [4 8] [1 2]] dir - - ;; Update cell at current position - key-cur: as-pair y x - data/:key-cur: ob or any [data/:key-cur 0] - - ;; Update cell at next position - key-nxt: as-pair ny nx - data/:key-nxt: ib or any [data/:key-nxt 0] - - ;; Update bounding box - minx: min minx nx - maxx: max maxx nx - miny: min miny ny - maxy: max maxy ny - - ;; Advance position - x: nx - y: ny - ] - - ;; Draw the result - chars: " ╵╷│╴┘┐┤╶└┌├─┴┬┼" - for y miny maxy 1 [ - line: clear "" - for x minx maxx 1 [ - key: as-pair y x - val: 1 + any [data/:key 0] - append line chars/:val - ] - print line - ] -] - -;; Draw result: -dragon-curve 511 diff --git a/Task/Dragon-curve/Rust/dragon-curve.rs b/Task/Dragon-curve/Rust/dragon-curve.rust similarity index 100% rename from Task/Dragon-curve/Rust/dragon-curve.rs rename to Task/Dragon-curve/Rust/dragon-curve.rust diff --git a/Task/Dragon-curve/SequenceL/dragon-curve-1.sequencel b/Task/Dragon-curve/SequenceL/dragon-curve-1.sequencel index e1905a0651..fe187b5084 100644 --- a/Task/Dragon-curve/SequenceL/dragon-curve-1.sequencel +++ b/Task/Dragon-curve/SequenceL/dragon-curve-1.sequencel @@ -4,35 +4,35 @@ import ; initPoints := [[0,0],[1,0]]; f1(point(1)) := - let - matrix := [[cos(45 * (pi/180)), -sin(45 * (pi/180))], - [sin(45 * (pi/180)), cos(45 * (pi/180))]]; - in - head(transpose((1/sqrt(2)) * matmul(matrix, transpose([point])))); - + let + matrix := [[cos(45 * (pi/180)), -sin(45 * (pi/180))], + [sin(45 * (pi/180)), cos(45 * (pi/180))]]; + in + head(transpose((1/sqrt(2)) * matmul(matrix, transpose([point])))); + f2(point(1)) := - let - matrix := [[cos(135 * (pi/180)), -sin(135 * (pi/180))], - [sin(135 * (pi/180)), cos(135 * (pi/180))]]; - in - head(transpose((1/sqrt(2)) * matmul(matrix, transpose([point])))) + initPoints[2]; + let + matrix := [[cos(135 * (pi/180)), -sin(135 * (pi/180))], + [sin(135 * (pi/180)), cos(135 * (pi/180))]]; + in + head(transpose((1/sqrt(2)) * matmul(matrix, transpose([point])))) + initPoints[2]; matmul(X(2),Y(2))[i,j] := sum(X[i,all]*Y[all,j]); entry(steps(0), maxX(0), maxY(0)) := - let - scaleX := maxX / 1.5; - scaleY := maxY; - - shiftX := maxX / 3.0 / 1.5; - shiftY := maxY / 3.0; - in - round(run(steps, initPoints) * [scaleX, scaleY] + [shiftX, shiftY]); + let + scaleX := maxX / 1.5; + scaleY := maxY; + + shiftX := maxX / 3.0 / 1.5; + shiftY := maxY / 3.0; + in + round(run(steps, initPoints) * [scaleX, scaleY] + [shiftX, shiftY]); run(steps(0), result(2)) := - let - next := f1(result) ++ f2(result); - in - result when steps <= 0 - else - run(steps - 1, next); + let + next := f1(result) ++ f2(result); + in + result when steps <= 0 + else + run(steps - 1, next); diff --git a/Task/Dragon-curve/SequenceL/dragon-curve-2.sequencel b/Task/Dragon-curve/SequenceL/dragon-curve-2.sequencel index aa6cb2eec4..f60e233fdc 100644 --- a/Task/Dragon-curve/SequenceL/dragon-curve-2.sequencel +++ b/Task/Dragon-curve/SequenceL/dragon-curve-2.sequencel @@ -9,66 +9,66 @@ using namespace std; int main(int argc, char** argv) { - int threads = 0; - if(argc > 1) threads = atoi(argv[1]); - Sequence< Sequence > result; + int threads = 0; + if(argc > 1) threads = atoi(argv[1]); + Sequence< Sequence > result; - sl_init(threads); + sl_init(threads); - int width = 500; - if(argc > 2) width = atoi(argv[2]); - int height = width; - if(argc > 3) height = atoi(argv[3]); + int width = 500; + if(argc > 2) width = atoi(argv[2]); + int height = width; + if(argc > 3) height = atoi(argv[3]); - CImg visu(width, height, 1, 3, 0); - CImgDisplay draw_disp(visu); + CImg visu(width, height, 1, 3, 0); + CImgDisplay draw_disp(visu); - SLTimer compTimer; - SLTimer drawTimer; + SLTimer compTimer; + SLTimer drawTimer; - int steps = 0; - int maxSteps = 18; - if(argc > 4) maxSteps = atoi(argv[4]); - int waitTime = 200; - if(argc > 5) waitTime = atoi(argv[5]); - bool adding = true; - while(!draw_disp.is_closed()) - { - compTimer.start(); - sl_entry(steps, width, height, threads, result); - compTimer.stop(); + int steps = 0; + int maxSteps = 18; + if(argc > 4) maxSteps = atoi(argv[4]); + int waitTime = 200; + if(argc > 5) waitTime = atoi(argv[5]); + bool adding = true; + while(!draw_disp.is_closed()) + { + compTimer.start(); + sl_entry(steps, width, height, threads, result); + compTimer.stop(); - drawTimer.start(); - visu.fill(0); + drawTimer.start(); + visu.fill(0); - double thirdSize = ((result.size() / 2.0) / 3.0); - thirdSize = (int)thirdSize == 0 ? 1 : thirdSize; + double thirdSize = ((result.size() / 2.0) / 3.0); + thirdSize = (int)thirdSize == 0 ? 1 : thirdSize; - for(int i = 1; i <= result.size(); i+=2) - { - unsigned char shade = (unsigned char)(255 * ((((i / 2) % (int)thirdSize) / thirdSize)) + 0.5); + for(int i = 1; i <= result.size(); i+=2) + { + unsigned char shade = (unsigned char)(255 * ((((i / 2) % (int)thirdSize) / thirdSize)) + 0.5); - unsigned char r = i / 2 <= thirdSize ? shade : 255/2; - unsigned char g = thirdSize < i / 2 && i / 2 <= thirdSize * 2 ? shade : 255/2; - unsigned char b = thirdSize * 2 < i / 2 && i / 2 <= thirdSize * 3 ? shade : 255/2; - const unsigned char color[] = {r,g,b}; + unsigned char r = i / 2 <= thirdSize ? shade : 255/2; + unsigned char g = thirdSize < i / 2 && i / 2 <= thirdSize * 2 ? shade : 255/2; + unsigned char b = thirdSize * 2 < i / 2 && i / 2 <= thirdSize * 3 ? shade : 255/2; + const unsigned char color[] = {r,g,b}; - visu.draw_line(result[i][1], result[i][2], 0, result[i + 1][1], result[i + 1][2], 0, color); - } - visu.display(draw_disp); - drawTimer.stop(); + visu.draw_line(result[i][1], result[i][2], 0, result[i + 1][1], result[i + 1][2], 0, color); + } + visu.display(draw_disp); + drawTimer.stop(); - draw_disp.set_title("Dragon Curve in SequenceL: %d Threads | Steps: %d | CompTime: %f Seconds | Draw Time: %f Seconds", threads, steps, drawTimer.getTime(), compTimer.getTime()); + draw_disp.set_title("Dragon Curve in SequenceL: %d Threads | Steps: %d | CompTime: %f Seconds | Draw Time: %f Seconds", threads, steps, drawTimer.getTime(), compTimer.getTime()); - if(adding) steps++; - else steps--; + if(adding) steps++; + else steps--; - if(steps <= 0) adding = true; - else if(steps >= maxSteps) adding = false; + if(steps <= 0) adding = true; + else if(steps >= maxSteps) adding = false; - draw_disp.wait(waitTime); - } + draw_disp.wait(waitTime); + } - sl_done(); - return 0; + sl_done(); + return 0; } diff --git a/Task/Dragon-curve/Tcl/dragon-curve.tcl b/Task/Dragon-curve/Tcl/dragon-curve.tcl index e662357b4b..1dcd79c6ad 100644 --- a/Task/Dragon-curve/Tcl/dragon-curve.tcl +++ b/Task/Dragon-curve/Tcl/dragon-curve.tcl @@ -15,14 +15,14 @@ proc forward {len} { proc dragon {len split {d 1}} { global r2 coords if {$split == 0} { - forward $len - return + forward $len + return } # This next part is only necessary to allow the illustration of progress if {$split == 10 && [llength $::coords]>2} { - .c coords dragon $::coords - update + .c coords dragon $::coords + update } incr split -1 diff --git a/Task/Dragon-curve/V-(Vlang)/dragon-curve.v b/Task/Dragon-curve/V-(Vlang)/dragon-curve.v deleted file mode 100644 index eeb9bfa2ce..0000000000 --- a/Task/Dragon-curve/V-(Vlang)/dragon-curve.v +++ /dev/null @@ -1,78 +0,0 @@ -import gg -import gx -import math - -struct App { - mut: - iter int - turns []int - start_angle f64 - side f64 - angle f64 - x1 int - y1 int - x2 int - y2 int - col gx.Color - ctx gg.Context -} - -fn get_sequence(iterations int) []int { - mut turn_sequence := []int{} - for _ in 0 .. iterations { - mut copy := turn_sequence.clone() - if copy.len > 1 { copy = copy.reverse() } - turn_sequence << 1 - for i in copy { - turn_sequence << -i - } - } - return turn_sequence -} - -fn (mut app App) dragon() { - app.angle = app.start_angle - app.x1 = 230 - app.y1 = 350 - app.x2 = app.x1 + int(math.cos(app.angle) * app.side) - app.y2 = app.y1 + int(math.sin(app.angle) * app.side) - app.ctx.draw_line(app.x1, app.y1, app.x2, app.y2, app.col) - app.x1 = app.x2 - app.y1 = app.y2 - for turn in app.turns { - app.angle += f64(turn) * math.pi / 2 - app.x2 = app.x1 + int(math.cos(app.angle) * app.side) - app.y2 = app.y1 + int(math.sin(app.angle) * app.side) - app.ctx.draw_line(app.x1, app.y1, app.x2, app.y2, app.col) - app.x1 = app.x2 - app.y1 = app.y2 - } -} - -fn (mut app App) init() { - app.iter = 14 - app.turns = get_sequence(app.iter) - app.start_angle = -f64(app.iter) * math.pi / 4 - app.side = 400.0 / math.pow(2, f64(app.iter) / 2) - app.col = gx.blue -} - -fn frame(mut app App) { - app.ctx.begin() - app.dragon() - app.ctx.end() -} - -fn main() { - mut app := App{} - mut context := gg.new_context( - width: 800 - height: 600 - window_title: 'Dragon curve' - user_data: &app - frame_fn: frame - bg_color: gx.white - ) - app.init() - context.run() -} diff --git a/Task/Dragon-curve/VBScript/dragon-curve.vbs b/Task/Dragon-curve/VBScript/dragon-curve.vb similarity index 100% rename from Task/Dragon-curve/VBScript/dragon-curve.vbs rename to Task/Dragon-curve/VBScript/dragon-curve.vb diff --git a/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit b/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit index f8755cfac0..45025fd0ee 100644 --- a/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit +++ b/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit @@ -1,16 +1,16 @@ File_Open("|(USER_MACRO)\dragon.bmp", OVERWRITE+NOEVENT) BOF Del_Char(ALL) -#11 = 640 // width of the image -#12 = 480 // height of the image +#11 = 640 // width of the image +#12 = 480 // height of the image Call("CREATE_BMP") -#1 = 384 // dx -#2 = 0 // dy -#3 = 6 // depth of recursion -#4 = 1 // flip -#5 = 150 // x -#6 = 300 // y +#1 = 384 // dx +#2 = 0 // dy +#3 = 6 // depth of recursion +#4 = 1 // flip +#5 = 150 // x +#6 = 300 // y Call("DRAGON") Buf_Close(NOMSG) @@ -29,15 +29,15 @@ if (#3 == 0) { #2 /= 2 #3-- if (#4) { - Num_Push(1,4) #4=1; #7=#1; #1=#2; #2=-#7; Call("DRAGON") Num_Pop(1,4) - Num_Push(1,4) #4=0; Call("DRAGON") Num_Pop(1,4) - Num_Push(1,4) #4=1; #7=#1; #1=-#2; #2=#7; Call("DRAGON") Num_Pop(1,4) - Num_Push(1,4) #4=0; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=1; #7=#1; #1=#2; #2=-#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=1; #7=#1; #1=-#2; #2=#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; Call("DRAGON") Num_Pop(1,4) } else { - Num_Push(1,4) #4=1; Call("DRAGON") Num_Pop(1,4) - Num_Push(1,4) #4=0; #7=#1; #1=-#2; #2=#7; Call("DRAGON") Num_Pop(1,4) - Num_Push(1,4) #4=1; Call("DRAGON") Num_Pop(1,4) - Num_Push(1,4) #4=0; #7=#1; #1=#2; #2=-#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=1; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; #7=#1; #1=-#2; #2=#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=1; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; #7=#1; #1=#2; #2=-#7; Call("DRAGON") Num_Pop(1,4) } } return @@ -53,7 +53,7 @@ while (#1 || #2 ) { #5 += #21; #1 -= #21 #6 += #22; #2 -= #22 Goto_Pos(1078 + #5 + #6*#11) - IC(255, OVERWRITE) // plot a pixel + IC(255, OVERWRITE) // plot a pixel } return @@ -64,19 +64,19 @@ return :CREATE_BMP: // BITMAPFILEHEADER: -IT("BM") // bfType -#10 = 1078+#11*#12 // file size +IT("BM") // bfType +#10 = 1078+#11*#12 // file size Call("INS_4BYTES") -IC(0, COUNT, 4) // reserved -#10 = 1078; Call("INS_4BYTES") // offset to bitmap data +IC(0, COUNT, 4) // reserved +#10 = 1078; Call("INS_4BYTES") // offset to bitmap data // BITMAPINFOHEADER: -#10 = 40; Call("INS_4BYTES") // size of BITMAPINFOHEADER -#10 = #11; Call("INS_4BYTES") // width of image -#10 = #12; Call("INS_4BYTES") // height of image -IC(1) IC(0) // number of bitplanes = 1 -IC(8) IC(0) // bits/pixel = 8 -IC(0, COUNT, 24) // compression, number of colors etc. +#10 = 40; Call("INS_4BYTES") // size of BITMAPINFOHEADER +#10 = #11; Call("INS_4BYTES") // width of image +#10 = #12; Call("INS_4BYTES") // height of image +IC(1) IC(0) // number of bitplanes = 1 +IC(8) IC(0) // bits/pixel = 8 +IC(0, COUNT, 24) // compression, number of colors etc. // Color table - create greyscale palette for (#1 = 0; #1 < 256; #1++) { @@ -96,5 +96,5 @@ return for (#1 = 0; #1 < 4; #1++) { Ins_Char(#10 & 0xff) #10 = #10 >> 8 -} +} return diff --git a/Task/Dragon-curve/YAMLScript/dragon-curve.ys b/Task/Dragon-curve/YAMLScript/dragon-curve.ys deleted file mode 100644 index a2d4b04861..0000000000 --- a/Task/Dragon-curve/YAMLScript/dragon-curve.ys +++ /dev/null @@ -1,29 +0,0 @@ -!YS-v0 - -defn main(steps=511): - data [minx maxx miny maxy] =: - loop i 0 [x y], [0 0], data {}, [minx maxx miny maxy] [0 0 0 0]: - dir =: i-to-dir(i) - nx ny =: + - [(x + condp(== dir 0 1 2 -1 0)) - (y + condp(== dir 1 1 3 -1 0))] - ob ib =: dir.nth([[8 4][2 1][4 8][1 2]]) - data =: update-in(data [y x] safe-bit-or ob) - .update-in([ny nx] safe-bit-or ib) - bbox =: + - [min(minx nx) max(maxx nx) - min(miny ny) max(maxy ny)] - if i < steps: - recur: i.++, [nx ny], data, bbox - vector: data bbox - - each y (miny .. maxy): - say: !:join - each x (minx .. maxx): - get-in(data [y x] 0).nth(" ╵╷│╴┘┐┤╶└┌├─┴┬┼") - -defn i-to-dir(n): - n.bit-xor(bit-shift-right(n 1)):Long/bitCount % 4 - -defn safe-bit-or(v bit): - (v || 0).bit-or(bit) diff --git a/Task/Dragon-curve/Yabasic/dragon-curve-1.basic b/Task/Dragon-curve/Yabasic/dragon-curve-1.basic index 9d47421a36..1d6082d45d 100644 --- a/Task/Dragon-curve/Yabasic/dragon-curve-1.basic +++ b/Task/Dragon-curve/Yabasic/dragon-curve-1.basic @@ -15,30 +15,30 @@ clear window dragon() sub dragon() - if level<=0 then - yn = sin(rotation)*insize + y - xn = cos(rotation)*insize + x - if iter*20 THEN 230 -210 PLOT XC,YC:DRAWTO HX,HY -220 PLOT XC,YC:DRAWTO MX,MY -230 PLOT XC,YC:DRAWTO SX,SY -240 GOSUB 500 -250 COLOR 2 -260 PLOT XC,YC:DRAWTO HX,HY -270 PLOT XC,YC:DRAWTO MX,MY -280 COLOR 1 -290 PLOT XC,YC:DRAWTO SX,SY -300 JIFFIES=256*PEEK(19)+PEEK(20) -310 NSEC=INT(JIFFIES/FPS):IF NSEC=60 THEN GOSUB 400:GOTO 100 -320 IF NSEC>SS THEN SS=NSEC:GOTO 2OO -330 GOTO 300 -400 REM INCREASE MINUTE AND HOUR -410 MM=MM+1 -420 IF MM=60 THEN MM=0:HH=HH+1 -430 IF HH=24 THEN HH=0 -440 REM DISABLE SCREEN SAVER/ATTRACT MODE -450 POKE 77,0 -460 RETURN -500 IF SS>0 THEN 550:REM CALCULATE X AND Y POSITIONS OF HANDS -510 HX=XC+R*SIN(30*HH+MM/2)*0.5 -520 HY=YC-R*COS(30*HH+MM/2)*0.5 -530 MX=XC+R*SIN(6*MM) -540 MY=YC-R*COS(6*MM) -550 SX=XC+R*SIN(6*SS) -560 SY=YC-R*COS(6*SS) -570 RETURN -800 REM DRAW CLOCK FACE -810 COLOR 3 -820 FOR I=30 TO 360 STEP 30 -830 PLOT XC+RF*SIN(I),YC-RF*COS(I) -840 NEXT I -850 RETURN diff --git a/Task/Draw-a-clock/Batch-File/draw-a-clock.bat b/Task/Draw-a-clock/Batch-File/draw-a-clock.bat index ae8d23ce99..42149ed54e 100644 --- a/Task/Draw-a-clock/Batch-File/draw-a-clock.bat +++ b/Task/Draw-a-clock/Batch-File/draw-a-clock.bat @@ -7,7 +7,7 @@ title Sample Batch Clock setlocal enabledelayedexpansion chcp 65001 - ::Set the characters... + ::Set the characters... set "#0_1=█████" set "#0_2=█ █" set "#0_3=█ █" @@ -75,26 +75,26 @@ set "#C_4=█" set "#C_5= " :clock_loop - ::Clear display [leaving a whitespace]... + ::Clear display [leaving a whitespace]... for /l %%C in (1,1,5) do set "display%%C= " - ::Get current time [all spaces will be replaced to zero]... - ::Also, all colons will be replaced to "C" because colon has a function in variables... + ::Get current time [all spaces will be replaced to zero]... + ::Also, all colons will be replaced to "C" because colon has a function in variables... set "curr_time=%time: =0%" set "curr_time=%curr_time::=C%" - ::Process the numbers to display [we will now use the formats we SET above]... + ::Process the numbers to display [we will now use the formats we SET above]... for /l %%T in (0,1,7) do ( - ::Check for each number and colons... - for %%N in (0 1 2 3 4 5 6 7 8 9 C) do ( - if "!curr_time:~%%T,1!"=="%%N" ( - ::Now, barbeque each formatted char in 5 rows... - for /l %%D in (1,1,5) do set "display%%D=!display%%D!!#%%N_%%D! " - ) - ) + ::Check for each number and colons... + for %%N in (0 1 2 3 4 5 6 7 8 9 C) do ( + if "!curr_time:~%%T,1!"=="%%N" ( + ::Now, barbeque each formatted char in 5 rows... + for /l %%D in (1,1,5) do set "display%%D=!display%%D!!#%%N_%%D! " + ) + ) ) - ::Refresh the clock... + ::Refresh the clock... cls echo. echo.[%display1%] diff --git a/Task/Draw-a-clock/C++/draw-a-clock.cpp b/Task/Draw-a-clock/C++/draw-a-clock.cpp index 176b1c771b..95f8885642 100644 --- a/Task/Draw-a-clock/C++/draw-a-clock.cpp +++ b/Task/Draw-a-clock/C++/draw-a-clock.cpp @@ -19,15 +19,15 @@ public: void set( int a, int b ) { x = a; y = b; } void rotate( float angle_r ) { - float _x = static_cast( x ), - _y = static_cast( y ), - s = sinf( angle_r ), - c = cosf( angle_r ), - a = _x * c - _y * s, - b = _x * s + _y * c; + float _x = static_cast( x ), + _y = static_cast( y ), + s = sinf( angle_r ), + c = cosf( angle_r ), + a = _x * c - _y * s, + b = _x * s + _y * c; - x = static_cast( a ); - y = static_cast( b ); + x = static_cast( a ); + y = static_cast( b ); } int x, y; }; @@ -38,94 +38,94 @@ public: myBitmap() : pen( NULL ), brush( NULL ), clr( 0 ), wid( 1 ) {} ~myBitmap() { - DeleteObject( pen ); - DeleteObject( brush ); - DeleteDC( hdc ); - DeleteObject( bmp ); + DeleteObject( pen ); + DeleteObject( brush ); + DeleteDC( hdc ); + DeleteObject( bmp ); } bool create( int w, int h ) { - BITMAPINFO bi; - ZeroMemory( &bi, sizeof( bi ) ); - bi.bmiHeader.biSize = sizeof( bi.bmiHeader ); - bi.bmiHeader.biBitCount = sizeof( DWORD ) * 8; - bi.bmiHeader.biCompression = BI_RGB; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biWidth = w; - bi.bmiHeader.biHeight = -h; + BITMAPINFO bi; + ZeroMemory( &bi, sizeof( bi ) ); + bi.bmiHeader.biSize = sizeof( bi.bmiHeader ); + bi.bmiHeader.biBitCount = sizeof( DWORD ) * 8; + bi.bmiHeader.biCompression = BI_RGB; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biWidth = w; + bi.bmiHeader.biHeight = -h; - HDC dc = GetDC( GetConsoleWindow() ); - bmp = CreateDIBSection( dc, &bi, DIB_RGB_COLORS, &pBits, NULL, 0 ); - if( !bmp ) return false; + HDC dc = GetDC( GetConsoleWindow() ); + bmp = CreateDIBSection( dc, &bi, DIB_RGB_COLORS, &pBits, NULL, 0 ); + if( !bmp ) return false; - hdc = CreateCompatibleDC( dc ); - SelectObject( hdc, bmp ); - ReleaseDC( GetConsoleWindow(), dc ); + hdc = CreateCompatibleDC( dc ); + SelectObject( hdc, bmp ); + ReleaseDC( GetConsoleWindow(), dc ); - width = w; height = h; - return true; + width = w; height = h; + return true; } void clear( BYTE clr = 0 ) { - memset( pBits, clr, width * height * sizeof( DWORD ) ); + memset( pBits, clr, width * height * sizeof( DWORD ) ); } void setBrushColor( DWORD bClr ) { - if( brush ) DeleteObject( brush ); - brush = CreateSolidBrush( bClr ); - SelectObject( hdc, brush ); + if( brush ) DeleteObject( brush ); + brush = CreateSolidBrush( bClr ); + SelectObject( hdc, brush ); } void setPenColor( DWORD c ) { - clr = c; - createPen(); + clr = c; + createPen(); } void setPenWidth( int w ) { - wid = w; - createPen(); + wid = w; + createPen(); } void saveBitmap( string path ) { - BITMAPFILEHEADER fileheader; - BITMAPINFO infoheader; - BITMAP bitmap; - DWORD wb; - - GetObject( bmp, sizeof( bitmap ), &bitmap ); - DWORD* dwpBits = new DWORD[bitmap.bmWidth * bitmap.bmHeight]; + BITMAPFILEHEADER fileheader; + BITMAPINFO infoheader; + BITMAP bitmap; + DWORD wb; + GetObject( bmp, sizeof( bitmap ), &bitmap ); + DWORD* dwpBits = new DWORD[bitmap.bmWidth * bitmap.bmHeight]; + ZeroMemory( dwpBits, bitmap.bmWidth * bitmap.bmHeight * sizeof( DWORD ) ); - ZeroMemory( &infoheader, sizeof( BITMAPINFO ) ); - ZeroMemory( &fileheader, sizeof( BITMAPFILEHEADER ) ); + ZeroMemory( &infoheader, sizeof( BITMAPINFO ) ); + ZeroMemory( &fileheader, sizeof( BITMAPFILEHEADER ) ); - infoheader.bmiHeader.biBitCount = sizeof( DWORD ) * 8; - infoheader.bmiHeader.biCompression = BI_RGB; - infoheader.bmiHeader.biPlanes = 1; - infoheader.bmiHeader.biSize = sizeof( infoheader.bmiHeader ); - infoheader.bmiHeader.biHeight = bitmap.bmHeight; - infoheader.bmiHeader.biWidth = bitmap.bmWidth; - infoheader.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * sizeof( DWORD ); + infoheader.bmiHeader.biBitCount = sizeof( DWORD ) * 8; + infoheader.bmiHeader.biCompression = BI_RGB; + infoheader.bmiHeader.biPlanes = 1; + infoheader.bmiHeader.biSize = sizeof( infoheader.bmiHeader ); + infoheader.bmiHeader.biHeight = bitmap.bmHeight; + infoheader.bmiHeader.biWidth = bitmap.bmWidth; + infoheader.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * sizeof( DWORD ); - fileheader.bfType = 0x4D42; - fileheader.bfOffBits = sizeof( infoheader.bmiHeader ) + sizeof( BITMAPFILEHEADER ); - fileheader.bfSize = fileheader.bfOffBits + infoheader.bmiHeader.biSizeImage; + fileheader.bfType = 0x4D42; + fileheader.bfOffBits = sizeof( infoheader.bmiHeader ) + sizeof( BITMAPFILEHEADER ); + fileheader.bfSize = fileheader.bfOffBits + infoheader.bmiHeader.biSizeImage; - GetDIBits( hdc, bmp, 0, height, ( LPVOID )dwpBits, &infoheader, DIB_RGB_COLORS ); + GetDIBits( hdc, bmp, 0, height, ( LPVOID )dwpBits, &infoheader, DIB_RGB_COLORS ); - HANDLE file = CreateFile( path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); - WriteFile( file, &fileheader, sizeof( BITMAPFILEHEADER ), &wb, NULL ); - WriteFile( file, &infoheader.bmiHeader, sizeof( infoheader.bmiHeader ), &wb, NULL ); - WriteFile( file, dwpBits, bitmap.bmWidth * bitmap.bmHeight * 4, &wb, NULL ); - CloseHandle( file ); + HANDLE file = CreateFile( path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); + WriteFile( file, &fileheader, sizeof( BITMAPFILEHEADER ), &wb, NULL ); + WriteFile( file, &infoheader.bmiHeader, sizeof( infoheader.bmiHeader ), &wb, NULL ); + WriteFile( file, dwpBits, bitmap.bmWidth * bitmap.bmHeight * 4, &wb, NULL ); + CloseHandle( file ); - delete [] dwpBits; + delete [] dwpBits; } HDC getDC() const { return hdc; } @@ -135,9 +135,9 @@ public: private: void createPen() { - if( pen ) DeleteObject( pen ); - pen = CreatePen( PS_SOLID, wid, clr ); - SelectObject( hdc, pen ); + if( pen ) DeleteObject( pen ); + pen = CreatePen( PS_SOLID, wid, clr ); + SelectObject( hdc, pen ); } HBITMAP bmp; @@ -154,16 +154,16 @@ class clock public: clock() { - _bmp.create( BMP_SIZE, BMP_SIZE ); - _bmp.clear( 100 ); - _bmp.setPenWidth( 2 ); - _ang = DegToRadian( 6 ); + _bmp.create( BMP_SIZE, BMP_SIZE ); + _bmp.clear( 100 ); + _bmp.setPenWidth( 2 ); + _ang = DegToRadian( 6 ); } - + void setNow() { - GetLocalTime( &_sysTime ); - draw(); + GetLocalTime( &_sysTime ); + draw(); } float DegToRadian( float degree ) { return degree * ( PI / 180.0f ); } @@ -173,70 +173,70 @@ public: private: void drawTicks( HDC dc ) { - vector2 line; - _bmp.setPenWidth( 1 ); - for( int x = 0; x < 60; x++ ) - { - line.set( 0, 50 ); - line.rotate( static_cast( x + 30 ) * _ang ); - MoveToEx( dc, CENTER - static_cast( 2.5f * static_cast( line.x ) ), CENTER - static_cast( 2.5f * static_cast( line.y ) ), NULL ); - LineTo( dc, CENTER - static_cast( 2.81f * static_cast( line.x ) ), CENTER - static_cast( 2.81f * static_cast( line.y ) ) ); - } + vector2 line; + _bmp.setPenWidth( 1 ); + for( int x = 0; x < 60; x++ ) + { + line.set( 0, 50 ); + line.rotate( static_cast( x + 30 ) * _ang ); + MoveToEx( dc, CENTER - static_cast( 2.5f * static_cast( line.x ) ), CENTER - static_cast( 2.5f * static_cast( line.y ) ), NULL ); + LineTo( dc, CENTER - static_cast( 2.81f * static_cast( line.x ) ), CENTER - static_cast( 2.81f * static_cast( line.y ) ) ); + } - _bmp.setPenWidth( 3 ); - for( int x = 0; x < 60; x += 5 ) - { - line.set( 0, 50 ); - line.rotate( static_cast( x + 30 ) * _ang ); - MoveToEx( dc, CENTER - static_cast( 2.5f * static_cast( line.x ) ), CENTER - static_cast( 2.5f * static_cast( line.y ) ), NULL ); - LineTo( dc, CENTER - static_cast( 2.81f * static_cast( line.x ) ), CENTER - static_cast( 2.81f * static_cast( line.y ) ) ); - } + _bmp.setPenWidth( 3 ); + for( int x = 0; x < 60; x += 5 ) + { + line.set( 0, 50 ); + line.rotate( static_cast( x + 30 ) * _ang ); + MoveToEx( dc, CENTER - static_cast( 2.5f * static_cast( line.x ) ), CENTER - static_cast( 2.5f * static_cast( line.y ) ), NULL ); + LineTo( dc, CENTER - static_cast( 2.81f * static_cast( line.x ) ), CENTER - static_cast( 2.81f * static_cast( line.y ) ) ); + } } void drawHands( HDC dc ) { - float hp = DegToRadian( ( 30.0f * static_cast( _sysTime.wMinute ) ) / 60.0f ); - int h = ( _sysTime.wHour > 12 ? _sysTime.wHour - 12 : _sysTime.wHour ) * 5; + float hp = DegToRadian( ( 30.0f * static_cast( _sysTime.wMinute ) ) / 60.0f ); + int h = ( _sysTime.wHour > 12 ? _sysTime.wHour - 12 : _sysTime.wHour ) * 5; + + _bmp.setPenWidth( 3 ); + _bmp.setPenColor( RGB( 0, 0, 255 ) ); + drawHand( dc, HOUR_LEN, ( _ang * static_cast( 30 + h ) ) + hp ); - _bmp.setPenWidth( 3 ); - _bmp.setPenColor( RGB( 0, 0, 255 ) ); - drawHand( dc, HOUR_LEN, ( _ang * static_cast( 30 + h ) ) + hp ); + _bmp.setPenColor( RGB( 0, 128, 0 ) ); + drawHand( dc, MIN_LEN, _ang * static_cast( 30 + _sysTime.wMinute ) ); - _bmp.setPenColor( RGB( 0, 128, 0 ) ); - drawHand( dc, MIN_LEN, _ang * static_cast( 30 + _sysTime.wMinute ) ); - - _bmp.setPenWidth( 2 ); - _bmp.setPenColor( RGB( 255, 0, 0 ) ); - drawHand( dc, SEC_LEN, _ang * static_cast( 30 + _sysTime.wSecond ) ); + _bmp.setPenWidth( 2 ); + _bmp.setPenColor( RGB( 255, 0, 0 ) ); + drawHand( dc, SEC_LEN, _ang * static_cast( 30 + _sysTime.wSecond ) ); } void drawHand( HDC dc, int len, float ang ) { - vector2 line; - line.set( 0, len ); - line.rotate( ang ); - MoveToEx( dc, CENTER, CENTER, NULL ); - LineTo( dc, line.x + CENTER, line.y + CENTER ); + vector2 line; + line.set( 0, len ); + line.rotate( ang ); + MoveToEx( dc, CENTER, CENTER, NULL ); + LineTo( dc, line.x + CENTER, line.y + CENTER ); } void draw() { - HDC dc = _bmp.getDC(); + HDC dc = _bmp.getDC(); - _bmp.setBrushColor( RGB( 250, 250, 250 ) ); - Ellipse( dc, 0, 0, BMP_SIZE, BMP_SIZE ); - _bmp.setBrushColor( RGB( 230, 230, 230 ) ); - Ellipse( dc, 10, 10, BMP_SIZE - 10, BMP_SIZE - 10 ); + _bmp.setBrushColor( RGB( 250, 250, 250 ) ); + Ellipse( dc, 0, 0, BMP_SIZE, BMP_SIZE ); + _bmp.setBrushColor( RGB( 230, 230, 230 ) ); + Ellipse( dc, 10, 10, BMP_SIZE - 10, BMP_SIZE - 10 ); - drawTicks( dc ); - drawHands( dc ); + drawTicks( dc ); + drawHands( dc ); - _bmp.setPenColor( 0 ); _bmp.setBrushColor( 0 ); - Ellipse( dc, CENTER - 5, CENTER - 5, CENTER + 5, CENTER + 5 ); + _bmp.setPenColor( 0 ); _bmp.setBrushColor( 0 ); + Ellipse( dc, CENTER - 5, CENTER - 5, CENTER + 5, CENTER + 5 ); - _wdc = GetDC( _hwnd ); - BitBlt( _wdc, 0, 0, BMP_SIZE, BMP_SIZE, dc, 0, 0, SRCCOPY ); - ReleaseDC( _hwnd, _wdc ); + _wdc = GetDC( _hwnd ); + BitBlt( _wdc, 0, 0, BMP_SIZE, BMP_SIZE, dc, 0, 0, SRCCOPY ); + ReleaseDC( _hwnd, _wdc ); } myBitmap _bmp; @@ -252,67 +252,67 @@ public: wnd() { _inst = this; } int wnd::Run( HINSTANCE hInst ) { - _hInst = hInst; - _hwnd = InitAll(); - SetTimer( _hwnd, MY_TIMER, 1000, NULL ); - _clock.setHWND( _hwnd ); + _hInst = hInst; + _hwnd = InitAll(); + SetTimer( _hwnd, MY_TIMER, 1000, NULL ); + _clock.setHWND( _hwnd ); - ShowWindow( _hwnd, SW_SHOW ); - UpdateWindow( _hwnd ); + ShowWindow( _hwnd, SW_SHOW ); + UpdateWindow( _hwnd ); - MSG msg; - ZeroMemory( &msg, sizeof( msg ) ); - while( msg.message != WM_QUIT ) - { - if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) != 0 ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - return UnregisterClass( "_MY_CLOCK_", _hInst ); + MSG msg; + ZeroMemory( &msg, sizeof( msg ) ); + while( msg.message != WM_QUIT ) + { + if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) != 0 ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + } + return UnregisterClass( "_MY_CLOCK_", _hInst ); } private: void wnd::doPaint( HDC dc ) { _clock.setNow(); } void wnd::doTimer() { _clock.setNow(); } static int WINAPI wnd::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - switch( msg ) - { - case WM_DESTROY: PostQuitMessage( 0 ); break; - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC dc = BeginPaint( hWnd, &ps ); - _inst->doPaint( dc ); - EndPaint( hWnd, &ps ); - return 0; - } - case WM_TIMER: _inst->doTimer(); break; - default: - return DefWindowProc( hWnd, msg, wParam, lParam ); - } - return 0; + switch( msg ) + { + case WM_DESTROY: PostQuitMessage( 0 ); break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC dc = BeginPaint( hWnd, &ps ); + _inst->doPaint( dc ); + EndPaint( hWnd, &ps ); + return 0; + } + case WM_TIMER: _inst->doTimer(); break; + default: + return DefWindowProc( hWnd, msg, wParam, lParam ); + } + return 0; } HWND InitAll() { - WNDCLASSEX wcex; - ZeroMemory( &wcex, sizeof( wcex ) ); - wcex.cbSize = sizeof( WNDCLASSEX ); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = ( WNDPROC )WndProc; - wcex.hInstance = _hInst; - wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); - wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ); - wcex.lpszClassName = "_MY_CLOCK_"; + WNDCLASSEX wcex; + ZeroMemory( &wcex, sizeof( wcex ) ); + wcex.cbSize = sizeof( WNDCLASSEX ); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = ( WNDPROC )WndProc; + wcex.hInstance = _hInst; + wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); + wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ); + wcex.lpszClassName = "_MY_CLOCK_"; - RegisterClassEx( &wcex ); + RegisterClassEx( &wcex ); - RECT rc = { 0, 0, BMP_SIZE, BMP_SIZE }; - AdjustWindowRect( &rc, WS_SYSMENU | WS_CAPTION, FALSE ); - int w = rc.right - rc.left, h = rc.bottom - rc.top; - return CreateWindow( "_MY_CLOCK_", ".: Clock -- PJorente :.", WS_SYSMENU, CW_USEDEFAULT, 0, w, h, NULL, NULL, _hInst, NULL ); + RECT rc = { 0, 0, BMP_SIZE, BMP_SIZE }; + AdjustWindowRect( &rc, WS_SYSMENU | WS_CAPTION, FALSE ); + int w = rc.right - rc.left, h = rc.bottom - rc.top; + return CreateWindow( "_MY_CLOCK_", ".: Clock -- PJorente :.", WS_SYSMENU, CW_USEDEFAULT, 0, w, h, NULL, NULL, _hInst, NULL ); } static wnd* _inst; diff --git a/Task/Draw-a-clock/C/draw-a-clock-1.c b/Task/Draw-a-clock/C/draw-a-clock-1.c index 90f51a7d51..197d668b3d 100644 --- a/Task/Draw-a-clock/C/draw-a-clock-1.c +++ b/Task/Draw-a-clock/C/draw-a-clock-1.c @@ -9,85 +9,85 @@ const char * shades = " .:-*ca&#%@"; /* distance of (x, y) from line segment (0, 0)->(x0, y0) */ double dist(double x, double y, double x0, double y0) { - double l = (x * x0 + y * y0) / (x0 * x0 + y0 * y0); + double l = (x * x0 + y * y0) / (x0 * x0 + y0 * y0); - if (l > 1) { - x -= x0; - y -= y0; - } else if (l >= 0) { - x -= l * x0; - y -= l * y0; - } - return sqrt(x * x + y * y); + if (l > 1) { + x -= x0; + y -= y0; + } else if (l >= 0) { + x -= l * x0; + y -= l * y0; + } + return sqrt(x * x + y * y); } enum { sec = 0, min, hur }; // for subscripts void draw(int size) { -# define for_i for(int i = 0; i < size; i++) -# define for_j for(int j = 0; j < size * 2; j++) +# define for_i for(int i = 0; i < size; i++) +# define for_j for(int j = 0; j < size * 2; j++) - double angle, cx = size / 2.; - double sx[3], sy[3], sw[3]; - double fade[] = { 1, .35, .35 }; /* opacity of each arm */ - struct timeval tv; - struct tm *t; + double angle, cx = size / 2.; + double sx[3], sy[3], sw[3]; + double fade[] = { 1, .35, .35 }; /* opacity of each arm */ + struct timeval tv; + struct tm *t; - /* set width of each arm */ - sw[sec] = size * .02; - sw[min] = size * .03; - sw[hur] = size * .05; + /* set width of each arm */ + sw[sec] = size * .02; + sw[min] = size * .03; + sw[hur] = size * .05; every_second: - gettimeofday(&tv, 0); - t = localtime(&tv.tv_sec); + gettimeofday(&tv, 0); + t = localtime(&tv.tv_sec); - angle = t->tm_sec * PI / 30; - sy[sec] = -cx * cos(angle); - sx[sec] = cx * sin(angle); + angle = t->tm_sec * PI / 30; + sy[sec] = -cx * cos(angle); + sx[sec] = cx * sin(angle); - angle = (t->tm_min + t->tm_sec / 60.) / 30 * PI; - sy[min] = -cx * cos(angle) * .8; - sx[min] = cx * sin(angle) * .8; + angle = (t->tm_min + t->tm_sec / 60.) / 30 * PI; + sy[min] = -cx * cos(angle) * .8; + sx[min] = cx * sin(angle) * .8; - angle = (t->tm_hour + t->tm_min / 60.) / 6 * PI; - sy[hur] = -cx * cos(angle) * .6; - sx[hur] = cx * sin(angle) * .6; + angle = (t->tm_hour + t->tm_min / 60.) / 6 * PI; + sy[hur] = -cx * cos(angle) * .6; + sx[hur] = cx * sin(angle) * .6; - printf("\033[s"); /* save cursor position */ - for_i { - printf("\033[%d;0H", i); /* goto row i, col 0 */ - double y = i - cx; - for_j { - double x = (j - 2 * cx) / 2; + printf("\033[s"); /* save cursor position */ + for_i { + printf("\033[%d;0H", i); /* goto row i, col 0 */ + double y = i - cx; + for_j { + double x = (j - 2 * cx) / 2; - int pix = 0; - /* calcs how far the "pixel" is from each arm and set - * shade, with some anti-aliasing. It's ghetto, but much - * easier than a real scanline conversion. - */ - for (int k = hur; k >= sec; k--) { - double d = dist(x, y, sx[k], sy[k]); - if (d < sw[k] - .5) - pix = 10 * fade[k]; - else if (d < sw[k] + .5) - pix = (5 + (sw[k] - d) * 10) * fade[k]; - } - putchar(shades[pix]); - } - } - printf("\033[u"); /* restore cursor pos so you can bg the job -- value unclear */ + int pix = 0; + /* calcs how far the "pixel" is from each arm and set + * shade, with some anti-aliasing. It's ghetto, but much + * easier than a real scanline conversion. + */ + for (int k = hur; k >= sec; k--) { + double d = dist(x, y, sx[k], sy[k]); + if (d < sw[k] - .5) + pix = 10 * fade[k]; + else if (d < sw[k] + .5) + pix = (5 + (sw[k] - d) * 10) * fade[k]; + } + putchar(shades[pix]); + } + } + printf("\033[u"); /* restore cursor pos so you can bg the job -- value unclear */ - fflush(stdout); - sleep(1); /* sleep 1 can at times miss a second, but will catch up next update */ - goto every_second; + fflush(stdout); + sleep(1); /* sleep 1 can at times miss a second, but will catch up next update */ + goto every_second; } int main(int argc, char *argv[]) { - int s; - if (argc <= 1 || (s = atoi(argv[1])) <= 0) s = 20; - draw(s); - return 0; + int s; + if (argc <= 1 || (s = atoi(argv[1])) <= 0) s = 20; + draw(s); + return 0; } diff --git a/Task/Draw-a-clock/ContextFree/draw-a-clock.cf b/Task/Draw-a-clock/ContextFree/draw-a-clock.cf index 95b5690c00..a03d242674 100644 --- a/Task/Draw-a-clock/ContextFree/draw-a-clock.cf +++ b/Task/Draw-a-clock/ContextFree/draw-a-clock.cf @@ -3,12 +3,12 @@ startshape START TIME_IN_SECONDS = 60 shape START { - SECOND_HAND[r (TIME_IN_SECONDS*-6)] - CIRCLE[s 50 50] + SECOND_HAND[r (TIME_IN_SECONDS*-6)] + CIRCLE[s 50 50] } shape SECOND_HAND { - TRIANGLE [[z 1 s 1 30 y 0.26 b 1]] + TRIANGLE [[z 1 s 1 30 y 0.26 b 1]] } diff --git a/Task/Draw-a-clock/Delphi/draw-a-clock-1.pas b/Task/Draw-a-clock/Delphi/draw-a-clock-1.delphi similarity index 100% rename from Task/Draw-a-clock/Delphi/draw-a-clock-1.pas rename to Task/Draw-a-clock/Delphi/draw-a-clock-1.delphi diff --git a/Task/Draw-a-clock/Delphi/draw-a-clock-2.pas b/Task/Draw-a-clock/Delphi/draw-a-clock-2.delphi similarity index 100% rename from Task/Draw-a-clock/Delphi/draw-a-clock-2.pas rename to Task/Draw-a-clock/Delphi/draw-a-clock-2.delphi diff --git a/Task/Draw-a-clock/EasyLang/draw-a-clock.easy b/Task/Draw-a-clock/EasyLang/draw-a-clock.easy index f53a4939f8..7d8bb29aa2 100644 --- a/Task/Draw-a-clock/EasyLang/draw-a-clock.easy +++ b/Task/Draw-a-clock/EasyLang/draw-a-clock.easy @@ -1,32 +1,38 @@ -proc draw hour min sec . +proc draw hour min sec . . # dial - gcolor 333 - gcircle 50 50 45 - gcolor 797 - gcircle 50 50 44 - gcolor 333 + color 333 + move 50 50 + circle 45 + color 797 + circle 44 + color 333 for i range0 60 a = i * 6 - if i mod 5 = 0 - gcircle 50 + sin a * 40 50 + cos a * 40 1 - else - gcircle 50 + sin a * 40 50 + cos a * 40 0.25 - . + move 50 + sin a * 40 50 + cos a * 40 + circle 0.25 + . + for i range0 12 + a = i * 30 + move 50 + sin a * 40 50 + cos a * 40 + circle 1 . # hour - glinewidth 2 - gcolor 000 + linewidth 2 + color 000 a = (hour * 60 + min) / 2 - gline 50 50 50 + sin a * 32 50 + cos a * 32 + move 50 50 + line 50 + sin a * 32 50 + cos a * 32 # min - glinewidth 1.5 + linewidth 1.5 a = (sec + min * 60) / 10 - gline 50 50 50 + sin a * 40 50 + cos a * 40 + move 50 50 + line 50 + sin a * 40 50 + cos a * 40 # sec - glinewidth 1 - gcolor 700 + linewidth 1 + color 700 a = sec * 6 - gline 50 50 50 + sin a * 40 50 + cos a * 40 + move 50 50 + line 50 + sin a * 40 50 + cos a * 40 . on timer if t <> floor systime @@ -35,9 +41,11 @@ on timer sec = number substr h$ 18 2 min = number substr h$ 15 2 hour = number substr h$ 12 2 - if hour > 12 : hour -= 12 - draw hour min sec + if hour > 12 + hour -= 12 + . + call draw hour min sec . - timer 0.05 + timer 0.1 . timer 0 diff --git a/Task/Draw-a-clock/Evaldraw/draw-a-clock.evaldraw b/Task/Draw-a-clock/Evaldraw/draw-a-clock.evaldraw deleted file mode 100644 index 048c92104b..0000000000 --- a/Task/Draw-a-clock/Evaldraw/draw-a-clock.evaldraw +++ /dev/null @@ -1,88 +0,0 @@ -(){ - cls(0); - drawclock(150); -} -drawclock(rad) { - hand_color = 0x6a6a6a; - seconds_color = 0xff0000; - radius_notches = rad*.95; - radius_numbers = rad*.85; - small_notch_size =rad*0.04; - big_notch_size = rad*0.08; - cx=rad+1; - cy=rad+1; - - // Face background - setcol(0x5aaaaa); drawsph(cx,cy,rad); - - // Highlight from stopwatch.kc - setcol(0xffffff); gldisable(GL_DEPTH_TEST); - glbegin(GL_COMPLEX); glsettex("whitepix.tga"); - for(a=3.5;a<=4.5;a+=.25) { gltexcoord(0,0); glvertex(cos(a)*rad*.55+cx,sin(a)*rad*.55+cy); } - for(a=4.5;a>=3.5;a-=.25) { gltexcoord(0,0); glvertex(cos(a)*rad*.45+cx,sin(a)*rad*.45+cy); } - glend(); - - moveto(cx-4*6, cy-.5*rad); - setfont(6,8); - setcol(0); printf("Evaltime"); - - // Face - setcol(0x015151); - hr=0; - for(i=0; i<60; i++) - { - a = i/60*2*pi - pi/2; - ca=cos(a); - sa=sin(a); - if (i%5==0) - { - hour = hr; if (hour==0) hour=12; - draw_hour(cx,cy,ca,sa,radius_numbers,hour); - hr++; - - r=radius_notches; - x=cx + ca*r; y=cy+sa*r; - drawcone(x,y,big_notch_size*.5,x+big_notch_size*ca,y+big_notch_size*sa,-big_notch_size*.5,0); - } else { - r=radius_notches; - x=cx + ca*r; y=cy+sa*r; - drawcone(x,y,small_notch_size*.5,x+small_notch_size*ca,y+small_notch_size*sa,-small_notch_size*.5,0); - } - } - - - int_hours = klock(6); - int_minutes = klock(7); - int_seconds = klock(8); - int_millis = klock(9); - - // Hour and Minute hand - hours = (int_hours+int_minutes/60.0) / 24.0; - a = hours * 2*pi - pi/2; - drawhand(cx,cy,a, rad*.64, 6,4, hand_color); - a = ( (int_minutes+int_seconds/60+int_millis/1000/60) / 60) * 2*pi - pi/2; - drawhand(cx,cy,a, rad*.84, 4,2, hand_color); - - a = ((int_seconds+int_millis/1000) / 60) * 2*pi - pi/2; - drawhand(cx,cy,a, rad*.9, 3,1, seconds_color); -} - -draw_hour(cx,cy,ca,sa,r,hr) { - x=cx + ca*r; y=cy+sa*r; - ofs=0; if(hr>9 || hr==0) ofs=5; - setfont(9,16); - moveto(x-4.5-ofs,y-8); - printf("%g", hr); -} -drawhand(cx,cy,angle,forward,r0,r1,kolor) { - back = .19*forward; - sx=cx - cos(angle)*back; - sy=cy - sin(angle)*back; - ex=cx + cos(angle)*forward; - ey=cy + sin(angle)*forward; - setcol(0); - drawcone(sx,sy,r0+1,ex,ey,r1+1); - setcol(kolor); - drawsph(cx,cy,r0+3); - drawcone(sx,sy,-r0,ex,ey,r1); -} diff --git a/Task/Draw-a-clock/Go/draw-a-clock-1.go b/Task/Draw-a-clock/Go/draw-a-clock-1.go index 1dcf2cd406..3b45a2348f 100644 --- a/Task/Draw-a-clock/Go/draw-a-clock-1.go +++ b/Task/Draw-a-clock/Go/draw-a-clock-1.go @@ -1,88 +1,88 @@ package main import ( - "golang.org/x/net/websocket" - "flag" - "fmt" - "html/template" - "io" - "math" - "net/http" - "time" + "golang.org/x/net/websocket" + "flag" + "fmt" + "html/template" + "io" + "math" + "net/http" + "time" ) var ( - Portnum string - Hostsite string + Portnum string + Hostsite string ) type PageSettings struct { - Host string - Port string + Host string + Port string } const ( - Canvaswidth = 512 - Canvasheight = 512 - //color constants - HourColor = "#ff7373" // pinkish - MinuteColor = "#00b7e4" //light blue - SecondColor = "#b58900" //gold + Canvaswidth = 512 + Canvasheight = 512 + //color constants + HourColor = "#ff7373" // pinkish + MinuteColor = "#00b7e4" //light blue + SecondColor = "#b58900" //gold ) func main() { - flag.StringVar(&Portnum, "Port", "1234", "Port to host server.") - flag.StringVar(&Hostsite, "Site", "localhost", "Site hosting server") - flag.Parse() - http.HandleFunc("/", webhandler) - http.Handle("/ws", websocket.Handler(wshandle)) - err := http.ListenAndServe(Hostsite+":"+Portnum, nil) - if err != nil { - fmt.Println(err) - } - fmt.Println("server running") + flag.StringVar(&Portnum, "Port", "1234", "Port to host server.") + flag.StringVar(&Hostsite, "Site", "localhost", "Site hosting server") + flag.Parse() + http.HandleFunc("/", webhandler) + http.Handle("/ws", websocket.Handler(wshandle)) + err := http.ListenAndServe(Hostsite+":"+Portnum, nil) + if err != nil { + fmt.Println(err) + } + fmt.Println("server running") } func webhandler(w http.ResponseWriter, r *http.Request) { - wsurl := PageSettings{Host: Hostsite, Port: Portnum} - template, _ := template.ParseFiles("clock.html") - template.Execute(w, wsurl) + wsurl := PageSettings{Host: Hostsite, Port: Portnum} + template, _ := template.ParseFiles("clock.html") + template.Execute(w, wsurl) } //Given a websocket connection, //serves updating time function func wshandle(ws *websocket.Conn) { - for { - hour, min, sec := time.Now().Clock() - hourx, houry := HourCords(hour, Canvasheight/2) - minx, miny := MinSecCords(min, Canvasheight/2) - secx, secy := MinSecCords(sec, Canvasheight/2) - msg := "CLEAR\n" - msg += fmt.Sprintf("HOUR %d %d %s\n", hourx, houry, HourColor) - msg += fmt.Sprintf("MIN %d %d %s\n", minx, miny, MinuteColor) - msg += fmt.Sprintf("SEC %d %d %s", secx, secy, SecondColor) - io.WriteString(ws, msg) - time.Sleep(time.Second / 60.0) - } + for { + hour, min, sec := time.Now().Clock() + hourx, houry := HourCords(hour, Canvasheight/2) + minx, miny := MinSecCords(min, Canvasheight/2) + secx, secy := MinSecCords(sec, Canvasheight/2) + msg := "CLEAR\n" + msg += fmt.Sprintf("HOUR %d %d %s\n", hourx, houry, HourColor) + msg += fmt.Sprintf("MIN %d %d %s\n", minx, miny, MinuteColor) + msg += fmt.Sprintf("SEC %d %d %s", secx, secy, SecondColor) + io.WriteString(ws, msg) + time.Sleep(time.Second / 60.0) + } } //Given current minute or second time(i.e 30 min, 60 minutes) //and the radius, returns pair of cords to draw line to func MinSecCords(ctime int, radius int) (int, int) { - //converts min/sec to angle and then to radians + //converts min/sec to angle and then to radians - theta := ((float64(ctime)*6 - 90) * (math.Pi / 180)) - x := float64(radius) * math.Cos(theta) - y := float64(radius) * math.Sin(theta) - return int(x) + 256, int(y) + 256 + theta := ((float64(ctime)*6 - 90) * (math.Pi / 180)) + x := float64(radius) * math.Cos(theta) + y := float64(radius) * math.Sin(theta) + return int(x) + 256, int(y) + 256 } //Given current hour time(i.e. 12, 8) and the radius, //returns pair of cords to draw line to func HourCords(ctime int, radius int) (int, int) { - //converts hours to angle and then to radians - theta := ((float64(ctime)*30 - 90) * (math.Pi / 180)) - x := float64(radius) * math.Cos(theta) - y := float64(radius) * math.Sin(theta) - return int(x) + 256, int(y) + 256 + //converts hours to angle and then to radians + theta := ((float64(ctime)*30 - 90) * (math.Pi / 180)) + x := float64(radius) * math.Cos(theta) + y := float64(radius) * math.Sin(theta) + return int(x) + 256, int(y) + 256 } diff --git a/Task/Draw-a-clock/Go/draw-a-clock-2.go b/Task/Draw-a-clock/Go/draw-a-clock-2.go index fd18474571..5dad3296a3 100644 --- a/Task/Draw-a-clock/Go/draw-a-clock-2.go +++ b/Task/Draw-a-clock/Go/draw-a-clock-2.go @@ -10,10 +10,10 @@ var hourhand; function wsConnect() { - //get contexts for drawing + //get contexts for drawing //var canvas = document.getElementById( "canvas" ); //ctx = canvas.getContext( '2d' ); - var canvas = document.getElementById("rim"); + var canvas = document.getElementById("rim"); //draw circle for rim rim = canvas.getContext('2d'); rim.beginPath(); @@ -83,19 +83,19 @@

Clock

- + Sorry, your browser does not support Canvas - + Sorry, your browser does not support Canvas - + Sorry, your browser does not support Canvas - + Sorry, your browser does not support Canvas - + diff --git a/Task/Draw-a-clock/JavaScript/draw-a-clock-1.js b/Task/Draw-a-clock/JavaScript/draw-a-clock-1.js index 62e1f5b9f7..4a3b8b27f0 100644 --- a/Task/Draw-a-clock/JavaScript/draw-a-clock-1.js +++ b/Task/Draw-a-clock/JavaScript/draw-a-clock-1.js @@ -1,47 +1,47 @@ var sec_old = 0; function update_clock() { - var t = new Date(); - var arms = [t.getHours(), t.getMinutes(), t.getSeconds()]; - if (arms[2] == sec_old) return; - sec_old = arms[2]; + var t = new Date(); + var arms = [t.getHours(), t.getMinutes(), t.getSeconds()]; + if (arms[2] == sec_old) return; + sec_old = arms[2]; - var c = document.getElementById('clock'); - var ctx = c.getContext('2d'); - ctx.fillStyle = "rgb(0,200,200)"; - ctx.fillRect(0, 0, c.width, c.height); - ctx.fillStyle = "white"; - ctx.fillRect(3, 3, c.width - 6, c.height - 6); - ctx.lineCap = 'round'; + var c = document.getElementById('clock'); + var ctx = c.getContext('2d'); + ctx.fillStyle = "rgb(0,200,200)"; + ctx.fillRect(0, 0, c.width, c.height); + ctx.fillStyle = "white"; + ctx.fillRect(3, 3, c.width - 6, c.height - 6); + ctx.lineCap = 'round'; - var orig = { x: c.width / 2, y: c.height / 2 }; - arms[1] += arms[2] / 60; - arms[0] += arms[1] / 60; - draw_arm(ctx, orig, arms[0] * 30, c.width/2.5 - 15, c.width / 20, "green"); - draw_arm(ctx, orig, arms[1] * 6, c.width/2.2 - 10, c.width / 30, "navy"); - draw_arm(ctx, orig, arms[2] * 6, c.width/2.0 - 6, c.width / 100, "maroon"); + var orig = { x: c.width / 2, y: c.height / 2 }; + arms[1] += arms[2] / 60; + arms[0] += arms[1] / 60; + draw_arm(ctx, orig, arms[0] * 30, c.width/2.5 - 15, c.width / 20, "green"); + draw_arm(ctx, orig, arms[1] * 6, c.width/2.2 - 10, c.width / 30, "navy"); + draw_arm(ctx, orig, arms[2] * 6, c.width/2.0 - 6, c.width / 100, "maroon"); } function draw_arm(ctx, orig, deg, len, w, style) { - ctx.save(); - ctx.lineWidth = w; - ctx.lineCap = 'round'; - ctx.translate(orig.x, orig.y); - ctx.rotate((deg - 90) * Math.PI / 180); - ctx.strokeStyle = style; - ctx.beginPath(); - ctx.moveTo(-len / 10, 0); - ctx.lineTo(len, 0); - ctx.stroke(); - ctx.restore(); + ctx.save(); + ctx.lineWidth = w; + ctx.lineCap = 'round'; + ctx.translate(orig.x, orig.y); + ctx.rotate((deg - 90) * Math.PI / 180); + ctx.strokeStyle = style; + ctx.beginPath(); + ctx.moveTo(-len / 10, 0); + ctx.lineTo(len, 0); + ctx.stroke(); + ctx.restore(); } function init_clock() { - var clock = document.createElement('canvas'); - clock.width = 100; - clock.height = 100; - clock.id = "clock"; - document.body.appendChild(clock); + var clock = document.createElement('canvas'); + clock.width = 100; + clock.height = 100; + clock.id = "clock"; + document.body.appendChild(clock); - window.setInterval(update_clock, 200); + window.setInterval(update_clock, 200); } diff --git a/Task/Draw-a-clock/Julia/draw-a-clock.jl b/Task/Draw-a-clock/Julia/draw-a-clock.julia similarity index 100% rename from Task/Draw-a-clock/Julia/draw-a-clock.jl rename to Task/Draw-a-clock/Julia/draw-a-clock.julia diff --git a/Task/Draw-a-clock/Kotlin/draw-a-clock.kts b/Task/Draw-a-clock/Kotlin/draw-a-clock.kotlin similarity index 100% rename from Task/Draw-a-clock/Kotlin/draw-a-clock.kts rename to Task/Draw-a-clock/Kotlin/draw-a-clock.kotlin diff --git a/Task/Draw-a-clock/M2000-Interpreter/draw-a-clock.m2000 b/Task/Draw-a-clock/M2000-Interpreter/draw-a-clock.m2000 index 8d8e6c0c7b..365ce205dd 100644 --- a/Task/Draw-a-clock/M2000-Interpreter/draw-a-clock.m2000 +++ b/Task/Draw-a-clock/M2000-Interpreter/draw-a-clock.m2000 @@ -5,89 +5,89 @@ cls, 0 window 6, window Module Led_Clock{ - Escape Off - Smooth off - Dim D(-1 to 9) - D(-1)=(0,0,0,0,0,0,0) - D(0)=(1,1,1,0,1,1,1) - D(1)=(0,0,1,0,0,1,0) - D(2)=(1,0,1,1,1,0,1) - D(3)=(1,0,1,1,0,1,1) - D(4)=(0,1,1,1,0,1,0) - D(5)=(1,1,0,1,0,1,1) - D(6)=(1,1,0,1,1,1,1) - D(7)=(1,0,1,0,0,1,0) - D(8)=(1,1,1,1,1,1,1) - D(9)=(1,1,1,1,0,1,1) - N=240 - XX=(scale.x-N*75) div 2 - YY=scale.y-N*22 - NN=N - BackColor=0 - CLS BackColor, 0 - Back {CLS BackColor,0} - desktop 255, BackColor - Forecolor=12 - C=BackColor-Forecolor - pen BackColor - for i=0 to 9: cc=d(i): cc*=c:next - m=1 - move XX+N*23.2, YY+N*5.2 - polygon BackColor-C, N,-N, N,N, -N, N, -N, -N - move XX+N*23.2,YY+N*13.2 - polygon BackColor-C, N,-N, N,N, -N, N, -N, -N - move XX+N*49.2,YY+N*5.2 - polygon BackColor-C, N,-N, N,N, -N, N, -N, -N - move XX+N*49.2,YY+N*13.2 - polygon BackColor-C, N,-N, N,N, -N, N, -N, -N - dsk=True - every 1000/2 { - k=now - k1=val(str$(k, "hh")) - k2=val(str$(k, "nn")) - k3=val(str$(k, "ss")) - LED(XX, D(k1 div 10)) - LED(XX+N*12, D(k1 mod 10)) - LED(XX+N*26, D(k2 div 10)) - LED(XX+N*38, D(k2 mod 10)) - LED(XX+N*52, D(k3 div 10)) - LED(XX+N*64, D(k3 mod 10)) - refresh 1000 - if keypress(32) then - dsk~ - if dsk then desktop 255 else desktop 255, BackColor - end if - if keypress(27) or mouse=2 then exit - } - desktop 255 - pen 14 - refresh 50 - mode 16 - wait 1000 - Escape On + Escape Off + Smooth off + Dim D(-1 to 9) + D(-1)=(0,0,0,0,0,0,0) + D(0)=(1,1,1,0,1,1,1) + D(1)=(0,0,1,0,0,1,0) + D(2)=(1,0,1,1,1,0,1) + D(3)=(1,0,1,1,0,1,1) + D(4)=(0,1,1,1,0,1,0) + D(5)=(1,1,0,1,0,1,1) + D(6)=(1,1,0,1,1,1,1) + D(7)=(1,0,1,0,0,1,0) + D(8)=(1,1,1,1,1,1,1) + D(9)=(1,1,1,1,0,1,1) + N=240 + XX=(scale.x-N*75) div 2 + YY=scale.y-N*22 + NN=N + BackColor=0 + CLS BackColor, 0 + Back {CLS BackColor,0} + desktop 255, BackColor + Forecolor=12 + C=BackColor-Forecolor + pen BackColor + for i=0 to 9: cc=d(i): cc*=c:next + m=1 + move XX+N*23.2, YY+N*5.2 + polygon BackColor-C, N,-N, N,N, -N, N, -N, -N + move XX+N*23.2,YY+N*13.2 + polygon BackColor-C, N,-N, N,N, -N, N, -N, -N + move XX+N*49.2,YY+N*5.2 + polygon BackColor-C, N,-N, N,N, -N, N, -N, -N + move XX+N*49.2,YY+N*13.2 + polygon BackColor-C, N,-N, N,N, -N, N, -N, -N + dsk=True + every 1000/2 { + k=now + k1=val(str$(k, "hh")) + k2=val(str$(k, "nn")) + k3=val(str$(k, "ss")) + LED(XX, D(k1 div 10)) + LED(XX+N*12, D(k1 mod 10)) + LED(XX+N*26, D(k2 div 10)) + LED(XX+N*38, D(k2 mod 10)) + LED(XX+N*52, D(k3 div 10)) + LED(XX+N*64, D(k3 mod 10)) + refresh 1000 + if keypress(32) then + dsk~ + if dsk then desktop 255 else desktop 255, BackColor + end if + if keypress(27) or mouse=2 then exit + } + desktop 255 + pen 14 + refresh 50 + mode 16 + wait 1000 + Escape On - sub LED(XX, S()) - move XX+N*1.2, YY+NN - \\ LED - UPPER - polygon BackColor-S(0), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N - \\ LED | LEFT UPPER - move XX+N*1.2-N*1.2, YY+N*1.2+NN - polygon BackColor-S(1), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 - move XX+N*1.2+N*7.2, YY+N*1.2+NN - \\ LED | RIGHT UPPER - polygon BackColor-S(2), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 - move XX+N*1.2, YY+N*8.4+NN - \\ LED - MIDDLE - polygon BackColor-S(3), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N - \\ LED | LEFT BOTTOM - move XX+N*1.2-N*1.2, YY+N*9.6+NN - polygon BackColor-S(4), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 - \\ LED | RIGHT BOTTOM - move XX+N*1.2+N*7.2, YY+N*9.6+NN - polygon BackColor-S(5), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 - \\ LED - BOTTOM - move XX+N*1.2, YY+N*16.8+NN - polygon BackColor-S(6), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N - end sub + sub LED(XX, S()) + move XX+N*1.2, YY+NN + \\ LED - UPPER + polygon BackColor-S(0), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N + \\ LED | LEFT UPPER + move XX+N*1.2-N*1.2, YY+N*1.2+NN + polygon BackColor-S(1), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 + move XX+N*1.2+N*7.2, YY+N*1.2+NN + \\ LED | RIGHT UPPER + polygon BackColor-S(2), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 + move XX+N*1.2, YY+N*8.4+NN + \\ LED - MIDDLE + polygon BackColor-S(3), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N + \\ LED | LEFT BOTTOM + move XX+N*1.2-N*1.2, YY+N*9.6+NN + polygon BackColor-S(4), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 + \\ LED | RIGHT BOTTOM + move XX+N*1.2+N*7.2, YY+N*9.6+NN + polygon BackColor-S(5), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6 + \\ LED - BOTTOM + move XX+N*1.2, YY+N*16.8+NN + polygon BackColor-S(6), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N + end sub } Led_Clock diff --git a/Task/Draw-a-clock/MiniScript/draw-a-clock.mini b/Task/Draw-a-clock/MiniScript/draw-a-clock.mini index 9233919be6..f9d7b1464c 100644 --- a/Task/Draw-a-clock/MiniScript/draw-a-clock.mini +++ b/Task/Draw-a-clock/MiniScript/draw-a-clock.mini @@ -21,6 +21,6 @@ display(4).sprites.push hand // main loop while true - hand.rotation = 90 - floor(time) % 60 * 6 - wait + hand.rotation = 90 - floor(time) % 60 * 6 + wait end while diff --git a/Task/Draw-a-clock/OCaml/draw-a-clock-1.ml b/Task/Draw-a-clock/OCaml/draw-a-clock-1.ocaml similarity index 100% rename from Task/Draw-a-clock/OCaml/draw-a-clock-1.ml rename to Task/Draw-a-clock/OCaml/draw-a-clock-1.ocaml diff --git a/Task/Draw-a-clock/OCaml/draw-a-clock-2.ml b/Task/Draw-a-clock/OCaml/draw-a-clock-2.ocaml similarity index 100% rename from Task/Draw-a-clock/OCaml/draw-a-clock-2.ml rename to Task/Draw-a-clock/OCaml/draw-a-clock-2.ocaml diff --git a/Task/Draw-a-clock/OPL/draw-a-clock.opl b/Task/Draw-a-clock/OPL/draw-a-clock.opl deleted file mode 100644 index fbb6eccc6e..0000000000 --- a/Task/Draw-a-clock/OPL/draw-a-clock.opl +++ /dev/null @@ -1,6 +0,0 @@ -REM Series 3a and Series 5 use different modes. This version runs on Series 3a. For Series 5, remove the "2" in the gCLOCK line. - -PROC main: - gCLOCK ON,$29 - GET -ENDP diff --git a/Task/Draw-a-clock/Odin/draw-a-clock.odin b/Task/Draw-a-clock/Odin/draw-a-clock.odin deleted file mode 100644 index f1fd0e6408..0000000000 --- a/Task/Draw-a-clock/Odin/draw-a-clock.odin +++ /dev/null @@ -1,87 +0,0 @@ -package clock - -import rl "vendor:raylib" -import "core:time" -import "core:time/datetime" -import "core:time/timezone" -import "core:os" -import "core:math" - -TimePeriod :: enum { - AM, - PM -} - -DistanceAngle :: proc(distance: f32, angle: f32) -> (vector: rl.Vector2) { - vector.x = math.sin_f32(angle) - vector.y = -math.cos_f32(angle) - vector *= distance - - return -} - -main :: proc() { - tz, ok := timezone.region_load("local") - - rl.SetConfigFlags({.MSAA_4X_HINT}) - rl.InitWindow(640, 480, "Rosetta Code - draw a clock") - - screen_center := rl.Vector2 {f32(rl.GetScreenWidth()) / 2, f32(rl.GetScreenHeight()) / 2} - - for !rl.WindowShouldClose() { - rl.BeginDrawing() - - rl.ClearBackground(rl.RAYWHITE) - - conversion_succeeded: bool = true - date_time: datetime.DateTime - date_time, ok = time.time_to_datetime(time.now()) - if !ok do conversion_succeeded = false - - date_time, ok = timezone.datetime_to_tz(date_time, tz) - if !ok do conversion_succeeded = false - - regular_time: time.Time - regular_time, ok = time.datetime_to_time(date_time) - if !ok do conversion_succeeded = false - - if !conversion_succeeded do os.exit(1) - - period: TimePeriod - hour, min, sec := time.clock_from_time(regular_time) - if hour > 12 { - hour -= 12 - period = .PM - } - - radius := f32(rl.GetScreenHeight()) / 2.5 - - rl.DrawCircleV(screen_center, radius, rl.LIGHTGRAY) - - rl.DrawLineEx(screen_center, screen_center + DistanceAngle(radius * .75, (f32(hour) / 12) * math.TAU), 4, rl.BLACK) - rl.DrawLineEx(screen_center, screen_center + DistanceAngle(radius * .7, (f32(min) / 60) * math.TAU), 4, rl.DARKGREEN) - rl.DrawLineEx(screen_center, screen_center + DistanceAngle(radius * .5, (f32(sec) / 60) * math.TAU), 4, rl.RED) - - for i := 0; i < 60; i += 1 { - angle := (f32(i) / 60) * math.TAU - - inside_distance: f32 = .8 - thickness: f32 = 1.5 - - if i % 5 == 0 { - inside_distance = .775 - thickness = 3 - } - - rl.DrawLineEx(screen_center + DistanceAngle(radius * inside_distance, angle), screen_center + DistanceAngle(radius * .95, angle), thickness, rl.DARKGRAY) - } - - //fmt.printfln("%2d:%2d:%2d %s", hour, min, sec, period) - - rl.EndDrawing() - } - - rl.CloseWindow() - - timezone.region_destroy(tz) -} diff --git a/Task/Draw-a-clock/Perl/draw-a-clock-2.pl b/Task/Draw-a-clock/Perl/draw-a-clock-2.pl deleted file mode 100644 index 3cf966a4c3..0000000000 --- a/Task/Draw-a-clock/Perl/draw-a-clock-2.pl +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/perl - -use strict; # https://rosettacode.org/wiki/Draw_a_clock -use warnings; -use Tk; - -my $halfsize = 200; -my $twopi = 2 * atan2 0, -1; -my $mw = MainWindow->new; -my $c = $mw->Canvas( -width => 2 * $halfsize, -height => 2 * $halfsize)->pack; -$mw->repeat(1000 => \&draw); -MainLoop; - -sub draw - { - $c->delete('all'); - my $angle = time % 60 / 60 * $twopi; - $c->createLine( $halfsize, $halfsize, - $halfsize * (1 + sin $angle), - $halfsize * (1 - cos $angle), - -width => 5); - } diff --git a/Task/Draw-a-clock/Perl/draw-a-clock-1.pl b/Task/Draw-a-clock/Perl/draw-a-clock.pl similarity index 100% rename from Task/Draw-a-clock/Perl/draw-a-clock-1.pl rename to Task/Draw-a-clock/Perl/draw-a-clock.pl diff --git a/Task/Draw-a-clock/Quackery/draw-a-clock.quackery b/Task/Draw-a-clock/Quackery/draw-a-clock.quackery deleted file mode 100644 index 244a974556..0000000000 --- a/Task/Draw-a-clock/Quackery/draw-a-clock.quackery +++ /dev/null @@ -1,77 +0,0 @@ - [ $ "turtleduck.qky" loadfile - $ "bigrat.qky" loadfile ] now! - - [ $ \ -import datetime -sec = datetime.timedelta(seconds=1) -time_will_be = datetime.datetime.now()+sec -hours = time_will_be.hour -minutes = time_will_be.minute -seconds = time_will_be.second -to_stack([hours, minutes, seconds]) -\ python ] is time+1 ( --> [ ) - - - [ $ \ -import time -current_time = time.time() -time_to_sleep = 1.0 - (current_time % 1.0) -time.sleep(time_to_sleep) -\ python ] is wait ( --> ) - - [ 3 wide - 60 times - [ 240 1 fly - 10 1 walk - -250 1 fly - 1 60 turn ] - 7 wide - 12 times - [ 235 1 fly - 12 1 walk - -247 1 fly - 1 12 turn ] - 9 wide - 4 times - [ 233 1 fly - 14 1 walk - -247 1 fly - 1 4 turn ] - 1 wide - ' [ 0 0 0 ] fill - [ 10 1 circle ] ] is face ( --> ) - - [ 12 wide - unpack rot dip - [ 43200 rot - 720 v+ ] - 12 v+ - 2dup turn - 175 1 walk - -175 1 fly - -v turn ] is hour ( [ --> ) - - [ 8 wide - unpack rot drop - 3600 rot - 60 v+ - 2dup turn - 200 1 walk - -200 1 fly - -v turn ] is minute ( [ --> ) - - [ 4 wide - 2 peek - dup 60 turn - 225 1 walk - -225 1 fly - negate 60 turn ] is second ( [ --> ) - - [ turtle - 0 frames - [ clear -1 4 turn - face - time+1 dup dup - second minute hour - wait - frame 1 4 turn again ] ] is clock ( --> ) diff --git a/Task/Draw-a-clock/Raku/draw-a-clock-2.raku b/Task/Draw-a-clock/Raku/draw-a-clock-2.raku deleted file mode 100644 index 6ec39305ad..0000000000 --- a/Task/Draw-a-clock/Raku/draw-a-clock-2.raku +++ /dev/null @@ -1,11 +0,0 @@ -constant @t = < ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶⠀>; -constant @b = < ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶⠀>; - -signal(SIGINT).tap: { print "\e[?25h\n"; exit } -print "\e7\e[?25l"; # saves cursor position, make it invisible -loop { - my @x = DateTime.now.Str.substr(11,8).ords X- ord('0'); - put ~.[@x] for @t, @b; - sleep 1; - print "\e8"; # restores cursor position -} diff --git a/Task/Draw-a-clock/Raku/draw-a-clock-3.raku b/Task/Draw-a-clock/Raku/draw-a-clock-3.raku deleted file mode 100644 index cd67d3a521..0000000000 --- a/Task/Draw-a-clock/Raku/draw-a-clock-3.raku +++ /dev/null @@ -1,10 +0,0 @@ -print "\e7"; -loop { - my $time = DateTime.now; - put '#' x $_ ~ '.' x (24 - $_) given $time.hour.round; - put '#' x $_ ~ '.' x (60 - $_) given $time.minute.round; - put '#' x $_ ~ '.' x (60 - $_) given $time.second.round; - sleep 1; - print "\e8"; -} -END put "\n"; diff --git a/Task/Draw-a-clock/Raku/draw-a-clock-1.raku b/Task/Draw-a-clock/Raku/draw-a-clock.raku similarity index 100% rename from Task/Draw-a-clock/Raku/draw-a-clock-1.raku rename to Task/Draw-a-clock/Raku/draw-a-clock.raku diff --git a/Task/Draw-a-clock/Rebol/draw-a-clock.rebol b/Task/Draw-a-clock/Rebol/draw-a-clock.rebol deleted file mode 100644 index 6c3403e1bd..0000000000 --- a/Task/Draw-a-clock/Rebol/draw-a-clock.rebol +++ /dev/null @@ -1,26 +0,0 @@ -Rebol [ - title: "Rosetta code: Draw a clock (CLI)" - file: %Draw_a_clock.r3 - url: https://rosettacode.org/wiki/Draw_a_clock -] - -;; two spaced-separated blocks of Braille-like glyphs (top and bottom halves for digits 0-9 and separator) -s: join { ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶ } - { ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶ } -;; split the big string every 4 chars to get a block of 22 glyph cells (11 top + 11 bottom) -s: split s 4 - -forever [ ;; loop to update the clock every second - tm: format-date-time now "hh:mm:ss" ;; current time string, e.g., "12:34:56" - l1: clear "" ;; buffer for the top line of the big digits - l2: clear "" ;; buffer for the bottom line of the big digits - foreach c tm [ ;; for each character in the time string - i: 1 + c - #"0" ;; convert digit char to 1-based index - append l1 s/(i) ;; append top-half glyph for the digit (for ":" this will intentionally pick the separator at index 11) - append l2 s/(i + 11) ;; append bottom-half glyph (offset by 11 to access the lower row set) - ] - print l1 ;; print top line of large digits - print l2 ;; print bottom line of large digits - wait 1 ;; pause one second - prin "^[[2A" ;; move cursor up 2 lines (ANSI escape) to overwrite in place next iteration -] diff --git a/Task/Draw-a-clock/Red/draw-a-clock-2.red b/Task/Draw-a-clock/Red/draw-a-clock-2.red index 54e7b08da4..7d9f1c70e7 100644 --- a/Task/Draw-a-clock/Red/draw-a-clock-2.red +++ b/Task/Draw-a-clock/Red/draw-a-clock-2.red @@ -1,6 +1,6 @@ Red [ - Needs: 'View - Purpose: {simple analog clock based on Nenad Rakocevic's eve-clock.red, + Needs: 'View + Purpose: {simple analog clock based on Nenad Rakocevic's eve-clock.red, see http://www.red-lang.org/2016/07/eve-style-clock-demo-in-red-livecoded.html} ] diff --git a/Task/Draw-a-clock/Ring/draw-a-clock.ring b/Task/Draw-a-clock/Ring/draw-a-clock.ring deleted file mode 100644 index 2423676512..0000000000 --- a/Task/Draw-a-clock/Ring/draw-a-clock.ring +++ /dev/null @@ -1,96 +0,0 @@ -# Author: Gal Zsolt (CalmoSoft) -load "libsdl.ring" -load "stdlibcore.ring" - -# Settings -screen_w = 640 -screen_h = 480 -xp = screen_w/2 -yp = screen_h/2 -size = 200 -pi = 3.14159265 - -sdl_init(SDL_INIT_EVERYTHING) -window = sdl_createwindow("Analog Clock - CalmoSoft", 100, 100, screen_w, screen_h, SDL_WINDOW_SHOWN) -render = sdl_createrenderer(window, -1, SDL_RENDERER_ACCELERATED) -ev = sdl_new_sdl_event() - -while true - # Event handling - sdl_pollevent(ev) - if sdl_get_sdl_event_type(ev) = SDL_QUIT exit ok - - # Get system time - t = time() - h = 0 + substr(t,1,2) - m = 0 + substr(t,4,2) - s = 0 + substr(t,7,2) - - # Clear background (Black) - sdl_setrenderdrawcolor(render, 0, 0, 0, 255) - sdl_renderclear(render) - - # Draw the clock components - draw_clock(render, xp, yp, size, h, m, s, pi) - - sdl_renderpresent(render) - sdl_delay(100) -end - -# Clean up -sdl_destroyrenderer(render) -sdl_destroywindow(window) -sdl_quit() - -func draw_clock render, x, y, r, h, m, s, pi - # 1. Draw Clock Face (White circle outline) - sdl_setrenderdrawcolor(render, 255, 255, 255, 255) - for i = 0 to 360 step 1 - angle = i * pi / 180 - sdl_renderdrawpoint(render, x + r * cos(angle), y + r * sin(angle)) - next - - # 2. Draw Hour Markers (Ticks) - sdl_setrenderdrawcolor(render, 255, 255, 255, 255) - for i = 1 to 12 - angle = i * 30 * pi / 180 - x1 = x + r * 0.95 * sin(angle) - y1 = y - r * 0.95 * cos(angle) - x2 = x + r * 0.85 * sin(angle) - y2 = y - r * 0.85 * cos(angle) - sdl_renderdrawline(render, x1, y1, x2, y2) - next - - # Calculate angles for hands - s_angle = (s / 60) * 2 * pi - m_angle = ((m + s/60) / 60) * 2 * pi - h_angle = ((h % 12 + m/60) / 12) * 2 * pi - - # 3. Draw Hands (Thickened) - - # Hour Hand (Green - thickest: 5px) - sdl_setrenderdrawcolor(render, 0, 255, 0, 255) - for i = -2 to 2 - sdl_renderdrawline(render, x+i, y+i, x + r*0.5*sin(h_angle)+i, y - r*0.5*cos(h_angle)+i) - next - - # Minute Hand (Blue - medium: 3px) - sdl_setrenderdrawcolor(render, 0, 100, 255, 255) - for i = -1 to 1 - sdl_renderdrawline(render, x+i, y+i, x + r*0.8*sin(m_angle)+i, y - r*0.8*cos(m_angle)+i) - next - - # Second Hand (Red - 2px) - sdl_setrenderdrawcolor(render, 255, 0, 0, 255) - for i = 0 to 1 - sdl_renderdrawline(render, x+i, y+i, x + r*0.9*sin(s_angle)+i, y - r*0.9*cos(s_angle)+i) - next - - # 4. Center Cap (Axis) - sdl_setrenderdrawcolor(render, 200, 200, 200, 255) - for i = 0 to 360 step 10 - angle = i * pi / 180 - for radius = 0 to 5 - sdl_renderdrawpoint(render, x + radius * cos(angle), y + radius * sin(angle)) - next - next diff --git a/Task/Draw-a-clock/Run-BASIC/draw-a-clock.basic b/Task/Draw-a-clock/Run-BASIC/draw-a-clock.basic index db2e14893c..ba1d79746f 100644 --- a/Task/Draw-a-clock/Run-BASIC/draw-a-clock.basic +++ b/Task/Draw-a-clock/Run-BASIC/draw-a-clock.basic @@ -1,10 +1,10 @@ ' -------------------------------------------- ' clock. I got nothing but time ' --------------------------------------------- -n = 12 ' num of points -r = 95 ' radius -pi = 22/7 -alpha = pi * 2 / n +n = 12 ' num of points +r = 95 ' radius +pi = 22/7 +alpha = pi * 2 / n dim points(n) graphic #g2, 200, 200 ' -------------------------------------- @@ -22,58 +22,58 @@ graphic #g2, 200, 200 #g2 place(90,185) #g2 "\6" for i = 0 to n - 1 - theta = alpha * i - px = cos( theta ) * r - py = sin( theta ) * r - px = px + 100 - py = py + 100 - #g2 place(px,py) - #g2 circle(2) + theta = alpha * i + px = cos( theta ) * r + py = sin( theta ) * r + px = px + 100 + py = py + 100 + #g2 place(px,py) + #g2 circle(2) next i [shoTime] ' ------------------------- ' clear previous sec,min,hr ' ------------------------- -r = 63 -p = se +r = 63 +p = se #g2 color("white") gosub [h2Dot] -r = 50 -p = mi +r = 50 +p = mi #g2 color("white") gosub [h2Dot] -r = 30 ' radius -p = hr * 5 +r = 30 ' radius +p = hr * 5 #g2 color("white") gosub [h2Dot] ' ------------------------- ' Show new time ' ------------------------- -a$ = time$() -hr = val(word$(a$,1,":")) -mi = val(word$(a$,2,":")) -se = val(word$(a$,3,":")) +a$ = time$() +hr = val(word$(a$,1,":")) +mi = val(word$(a$,2,":")) +se = val(word$(a$,3,":")) ' put time on the clock - gimme a hand #g2 size(4) ' second hand -n = 60 -r = 63 -p = se +n = 60 +r = 63 +p = se #g2 color("blue") gosub [h2Dot] ' minute hand -r = 50 -p = mi +r = 50 +p = mi #g2 color("green") gosub [h2Dot] ' hour hand -r = 30 ' radius -p = hr * 5 +r = 30 ' radius +p = hr * 5 #g2 color("red") gosub [h2Dot] @@ -82,13 +82,13 @@ end ' a one liner [h2Dot] -alpha = pi * 2 / n -i = p - 15 -theta = alpha * i -px = cos( theta ) * r -py = sin( theta ) * r -px = px + 100 -py = py + 100 +alpha = pi * 2 / n +i = p - 15 +theta = alpha * i +px = cos( theta ) * r +py = sin( theta ) * r +px = px + 100 +py = py + 100 #g2 place(px,py) #g2 circle(2) #g2 line(100,100,px,py) diff --git a/Task/Draw-a-clock/Rust/draw-a-clock.rs b/Task/Draw-a-clock/Rust/draw-a-clock.rust similarity index 100% rename from Task/Draw-a-clock/Rust/draw-a-clock.rs rename to Task/Draw-a-clock/Rust/draw-a-clock.rust diff --git a/Task/Draw-a-clock/Scheme/draw-a-clock.scm b/Task/Draw-a-clock/Scheme/draw-a-clock.ss similarity index 100% rename from Task/Draw-a-clock/Scheme/draw-a-clock.scm rename to Task/Draw-a-clock/Scheme/draw-a-clock.ss diff --git a/Task/Draw-a-clock/Seed7/draw-a-clock.seed7 b/Task/Draw-a-clock/Seed7/draw-a-clock.seed7 index 8979c14f90..21481fb4f6 100644 --- a/Task/Draw-a-clock/Seed7/draw-a-clock.seed7 +++ b/Task/Draw-a-clock/Seed7/draw-a-clock.seed7 @@ -22,7 +22,7 @@ const proc: main is func screen(WINDOW_WIDTH, WINDOW_HEIGHT); clear(curr_win, BACKGROUND); KEYBOARD := GRAPH_KEYBOARD; - command := getc(KEYBOARD, NO_WAIT); + command := busy_getc(KEYBOARD); while command <> 'q' do start_time := truncToSecond(time(NOW)); clear(curr_win, BACKGROUND); @@ -64,8 +64,8 @@ const proc: main is func 100 + round(sin(alpha)*50.0), FOREGROUND); fcircle(100, 100, 7, CLOCKCOLOR); circle(100, 100, 7, FOREGROUND); - flushGraphic; + DRAW_FLUSH; await(start_time + 1 . SECONDS); - command := getc(KEYBOARD, NO_WAIT); + command := busy_getc(KEYBOARD); end while; end func; diff --git a/Task/Draw-a-clock/Tcl/draw-a-clock.tcl b/Task/Draw-a-clock/Tcl/draw-a-clock.tcl index 807543cf21..9facb5b050 100644 --- a/Task/Draw-a-clock/Tcl/draw-a-clock.tcl +++ b/Task/Draw-a-clock/Tcl/draw-a-clock.tcl @@ -13,9 +13,9 @@ proc updateClock t { set m [expr {$m + $s/60.0}] set h [expr {($h % 12 + $m/60.0) * 5}] foreach tag {hour minute second} value [list $h $m $s] len {50 80 80} { - .c coords $tag 100 100 \ - [expr {100 + $len*sin($value/30.0*3.14159)}] \ - [expr {100 - $len*cos($value/30.0*3.14159)}] + .c coords $tag 100 100 \ + [expr {100 + $len*sin($value/30.0*3.14159)}] \ + [expr {100 - $len*cos($value/30.0*3.14159)}] } } @@ -26,8 +26,8 @@ proc ticker {} { set t [clock seconds] after 250 ticker if {$t != $time} { - set time $t - updateClock $t + set time $t + updateClock $t } } ticker diff --git a/Task/Draw-a-clock/V-(Vlang)/draw-a-clock.v b/Task/Draw-a-clock/V-(Vlang)/draw-a-clock.v index f09fa7b1a3..dc23e77300 100644 --- a/Task/Draw-a-clock/V-(Vlang)/draw-a-clock.v +++ b/Task/Draw-a-clock/V-(Vlang)/draw-a-clock.v @@ -7,164 +7,164 @@ import math import time const ( - // All coordinates are designed for a clock size of this many pixel. - // You cannot change the size of the clock by adjusting this value. - design_size = 700 - center = 350 + // All coordinates are designed for a clock size of this many pixel. + // You cannot change the size of the clock by adjusting this value. + design_size = 700 + center = 350 - // Half the width of a tic-mark. - tw = 9 - // Height of a minute tic-mark. (hour is twice, 3-hour is thrice) - th = 25 - // Padding of tic-mark to window border - tp = 10 + // Half the width of a tic-mark. + tw = 9 + // Height of a minute tic-mark. (hour is twice, 3-hour is thrice) + th = 25 + // Padding of tic-mark to window border + tp = 10 - tic_color = gx.Color{ - r: 50 - g: 50 - b: 50 - } - hand_color = gx.black - second_hand_color = gx.red + tic_color = gx.Color{ + r: 50 + g: 50 + b: 50 + } + hand_color = gx.black + second_hand_color = gx.red ) struct App { - minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, - tp + 1 * th, center - tw, tp + 1 * th] - hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 2 * th, - center - tw, tp + 2 * th] - hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 3 * th, - center - tw, tp + 3 * th] + minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, + tp + 1 * th, center - tw, tp + 1 * th] + hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 2 * th, + center - tw, tp + 2 * th] + hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 3 * th, + center - tw, tp + 3 * th] - hour_hand []f32 = [f32(329), 161, 350, 140, 371, 161, 371, 413, 329, 413] - minute_hand []f32 = [f32(334.25), 40.25, 350, 24.5, 365.75, 40.25, 365.75, 427, 334.25, 427] - second_hand []f32 = [f32(345.8), 38.5, 350, 34.3, 354.2000, 38.5, 358.75, 427, 341.25, 427] - mut: - gg &gg.Context = unsafe { nil } - draw_flag bool = true - dpi_scale f32 = 1.0 + hour_hand []f32 = [f32(329), 161, 350, 140, 371, 161, 371, 413, 329, 413] + minute_hand []f32 = [f32(334.25), 40.25, 350, 24.5, 365.75, 40.25, 365.75, 427, 334.25, 427] + second_hand []f32 = [f32(345.8), 38.5, 350, 34.3, 354.2000, 38.5, 358.75, 427, 341.25, 427] + mut: + gg &gg.Context = unsafe { nil } + draw_flag bool = true + dpi_scale f32 = 1.0 } fn on_frame(mut app App) { - if !app.draw_flag { - return - } - app.gg.begin() + if !app.draw_flag { + return + } + app.gg.begin() - for i in 0 .. 60 { // draw minute tics - draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.minutes_tic, tic_color, - i * 6) - } - for i in 0 .. 12 { // hours - draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.hours_tic, tic_color, i * 30) - } - for i in 0 .. 4 { // 3 hours - draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.hours3_tic, tic_color, - i * 90) - } + for i in 0 .. 60 { // draw minute tics + draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.minutes_tic, tic_color, + i * 6) + } + for i in 0 .. 12 { // hours + draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.hours_tic, tic_color, i * 30) + } + for i in 0 .. 4 { // 3 hours + draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.hours3_tic, tic_color, + i * 90) + } - n := time.now() + n := time.now() - // draw hour hand - i := f32(n.hour) + f32(n.minute) / 60.0 - draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.hour_hand, hand_color, i * 30) + // draw hour hand + i := f32(n.hour) + f32(n.minute) / 60.0 + draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.hour_hand, hand_color, i * 30) - // draw minute hand - mut j := f32(n.minute) - if n.second == 59 { // make minute hand move smoothly - j += f32(math.sin(f32(n.microsecond) / 1e6 * math.pi / 2.0)) - } - draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.minute_hand, hand_color, j * 6) + // draw minute hand + mut j := f32(n.minute) + if n.second == 59 { // make minute hand move smoothly + j += f32(math.sin(f32(n.microsecond) / 1e6 * math.pi / 2.0)) + } + draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.minute_hand, hand_color, j * 6) - // draw second hand with smooth transition - k := f32(n.second) + f32(math.sin(f32(n.microsecond) / 1e6 * math.pi / 2.0)) - draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.second_hand, second_hand_color, - 0 + k * 6) + // draw second hand with smooth transition + k := f32(n.second) + f32(math.sin(f32(n.microsecond) / 1e6 * math.pi / 2.0)) + draw_convex_poly_rotate(mut app.gg, app.dpi_scale, app.second_hand, second_hand_color, + 0 + k * 6) - app.gg.end() + app.gg.end() } // Rotate a polygon round the centerpoint [manualfree] fn draw_convex_poly_rotate(mut ctx gg.Context, dpi_scale f32, points []f32, c gx.Color, angle f32) { - sa := math.sin(math.pi * angle / 180.0) - ca := math.cos(math.pi * angle / 180.0) + sa := math.sin(math.pi * angle / 180.0) + ca := math.cos(math.pi * angle / 180.0) - mut rotated_points := []f32{cap: points.len} - for i := 0; i < points.len / 2; i++ { - x := points[2 * i] - y := points[2 * i + 1] - xn := f32((x - center) * ca - (y - center) * sa) - yn := f32((x - center) * sa + (y - center) * ca) - rotated_points << (xn + center) * dpi_scale - rotated_points << (yn + center) * dpi_scale - } - ctx.draw_convex_poly(rotated_points, c) - unsafe { rotated_points.free() } + mut rotated_points := []f32{cap: points.len} + for i := 0; i < points.len / 2; i++ { + x := points[2 * i] + y := points[2 * i + 1] + xn := f32((x - center) * ca - (y - center) * sa) + yn := f32((x - center) * sa + (y - center) * ca) + rotated_points << (xn + center) * dpi_scale + rotated_points << (yn + center) * dpi_scale + } + ctx.draw_convex_poly(rotated_points, c) + unsafe { rotated_points.free() } } fn (mut app App) resize() { - size := gg.window_size() - // avoid calls when minimized - if size.width < 2 && size.height < 2 { - return - } - w := f32(size.width) / design_size - h := f32(size.height) / design_size - app.dpi_scale = if w < h { w } else { h } + size := gg.window_size() + // avoid calls when minimized + if size.width < 2 && size.height < 2 { + return + } + w := f32(size.width) / design_size + h := f32(size.height) / design_size + app.dpi_scale = if w < h { w } else { h } } fn on_event(e &gg.Event, mut app App) { - match e.typ { - .resized, .resumed { - app.resize() - } - .iconified { - app.draw_flag = false - } - .restored { - app.draw_flag = true - app.resize() - } - else { - if e.typ == .key_down { - match e.key_code { - .q { - println('Good bye.') - // do we need to free anything here? - app.gg.quit() - } - else {} - } - } - } - } + match e.typ { + .resized, .resumed { + app.resize() + } + .iconified { + app.draw_flag = false + } + .restored { + app.draw_flag = true + app.resize() + } + else { + if e.typ == .key_down { + match e.key_code { + .q { + println('Good bye.') + // do we need to free anything here? + app.gg.quit() + } + else {} + } + } + } + } } fn on_init(mut app App) { - app.resize() + app.resize() } fn main() { - println("Press 'q' to quit.") - mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf')) - $if android { - font_path = 'fonts/RobotoMono-Regular.ttf' - } + println("Press 'q' to quit.") + mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf')) + $if android { + font_path = 'fonts/RobotoMono-Regular.ttf' + } - mut app := &App{} + mut app := &App{} - app.gg = gg.new_context( - width: design_size - height: design_size - window_title: 'Clock!' - bg_color: gx.white - user_data: app - frame_fn: on_frame - event_fn: on_event - init_fn: on_init - font_path: font_path - ) + app.gg = gg.new_context( + width: design_size + height: design_size + window_title: 'Clock!' + bg_color: gx.white + user_data: app + frame_fn: on_frame + event_fn: on_event + init_fn: on_init + font_path: font_path + ) - app.gg.run() + app.gg.run() } diff --git a/Task/Draw-a-clock/VBScript/draw-a-clock.vbs b/Task/Draw-a-clock/VBScript/draw-a-clock.vb similarity index 100% rename from Task/Draw-a-clock/VBScript/draw-a-clock.vbs rename to Task/Draw-a-clock/VBScript/draw-a-clock.vb diff --git a/Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 b/Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 deleted file mode 100644 index bc2a9acaa1..0000000000 --- a/Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 +++ /dev/null @@ -1,48 +0,0 @@ -include xpllib; \for DrawCircle, DrawLine, LineWidth, MovePen, Deg2Rad -def X0=400, Y0=300; \center coordinate -int Hour, Minute, Second; - -proc DrawHand(Angle, Length, Width, Color); -real Angle, Length; -int Width, Color; -int X, Y; -[X:= fix(Length*Sin(Angle)); - Y:= fix(Length*Cos(Angle)); -LineWidth:= Width; -MovePen(X0, Y0); -DrawLine(X0+X, Y0-Y, Color); -]; - -proc DrawClock; \Show analog clock with current time -real Angle; -int N, X, Y; -[DrawCircle(X0, Y0, 299, LCyan, true); -Angle:= 0.; -for N:= 0 to 59 do \draw tick marks - [X:= fix(260.*Cos(Angle)); - Y:= fix(260.*Sin(Angle)); - DrawCircle(X+X0, Y+Y0, if rem(N/5) then 4 else 8, Black, true); - Angle:= Angle + 6.*Deg2Rad; - ]; -Angle:= float((Hour*60+Minute)/2) * Deg2Rad; -DrawHand(Angle, 210., 8, Black); -Angle:= float((Minute*60+Second)/10) * Deg2Rad; -DrawHand(Angle, 240., 5, Black); -Angle:= float(Second*6) * Deg2Rad; -DrawHand(Angle, 260., 3, LRed); -DrawCircle(X0, Y0, 8, Black, true); -]; - -int Second0; -char Time; -[SetVid($103); \800x600x8 -InitDraw; -repeat Time:= GetDateTime; - Hour:= Time(3); - if Hour>=12 then Hour:= Hour-12; - Minute:= Time(4); - Second:= Time(5); - if Second # Second0 then - [Second0:= Second; DrawClock]; -until KeyHit; -] diff --git a/Task/Draw-a-clock/Yabasic/draw-a-clock-2.basic b/Task/Draw-a-clock/Yabasic/draw-a-clock-2.basic deleted file mode 100644 index b45d5ff708..0000000000 --- a/Task/Draw-a-clock/Yabasic/draw-a-clock-2.basic +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/yabasic -REM yaclock -DEG_PER_RAD = 57.257751 - -winx = 480 -winy = 480 - -radius = min(winx,winy) / 2 - 1 -hx = (winx/2) - 1 -hy = (winy/2) - 1 - -REM length of the hands (90% of the radius of the clock face) -shand = int(radius * .9) -mhand = int(radius * .9) -hhand = int(radius * .5) - -REM drop coords by one since graphics are 0 based - -winx = winx - 1 -winy = winy - 1 - -clear screen - -open window winx,winy - -clockface() - -do - - hour = val(mid$(time$,1,2)) - mins = val(mid$(time$,4,2)) - sec = val(mid$(time$,7,2)) - - updatehand("sec") - updatehand("mins") - updatehand("hour") - - pause .25 - -loop - -sub updatehand(hand$) - - switch(hand$) - case "sec" - h_len = shand - angle = sec * 6 - width = 6 - color 255,0,0 - ox = osx - oy = osy - oxm1 = osxm1 - oxm2 = osxm2 - oym1 = osym1 - oym2 = osym2 - break - case "mins" - h_len = mhand - angle = mins * 6 + int(sec/10) - width = 12 - color 0,255,0 - ox = omx - oy = omy - oxm1 = omxm1 - oxm2 = omxm2 - oym1 = omym1 - oym2 = omym2 - break - case "hour" - h_len = hhand - angle = ((hour * 30) + (minutes / 12) * 6) + int(mins/2) - width = 15 - color 0,0,255 - ox = ohx - oy = ohy - oxm1 = ohxm1 - oxm2 = ohxm2 - oym1 = ohym1 - oym2 = ohym2 - break - end switch - - h_angle1 = angle - width - if h_angle1 < 0 then - h_angle1 = h_angle1 + 360 - endif - h_angle1 = h_angle1 / DEG_PER_RAD - - h_angle2 = angle + width - if h_angle2 > 360 then - h_angle2 = h_angle2 - 360 - endif - h_angle2 = h_angle2 / DEG_PER_RAD - - angle = angle / DEG_PER_RAD - - x = (hx + (sin(angle) * h_len)) - xm1 = (hx + (sin(h_angle1) * int(h_len * .2))) - xm2 = (hx + (sin(h_angle2) * int(h_len * .2))) - - y = (hy - (cos(angle) * h_len)) - ym1 = (hy - (cos(h_angle1) * int(h_len * .2))) - ym2 = (hy - (cos(h_angle2) * int(h_len * .2))) - - clear line hx,hy,oxm1,oym1 - clear line hx,hy,oxm2,oym2 - clear line oxm1,oym1,ox,oy - clear line oxm2,oym2,ox,oy - line hx,hy,xm1,ym1 - line hx,hy,xm2,ym2 - line xm1,ym1,x,y - line xm2,ym2,x,y - - REM save off the old vals - switch(hand$) - case "sec" - osx = x - osy = y - osxm1 = xm1 - osxm2 = xm2 - osym1 = ym1 - osym2 = ym2 - break - case "mins" - omx = x - omy = y - omxm1 = xm1 - omxm2 = xm2 - omym1 = ym1 - omym2 = ym2 - break - case "hour" - ohx = x - ohy = y - ohxm1 = xm1 - ohxm2 = xm2 - ohym1 = ym1 - ohym2 = ym2 - break - end switch -end sub - -sub clockface() - circle hx,hy,radius - - htick = radius / 10 - mtick = htick / 2 - - for z=0 to 360 step 6 - REM Begin at zero deg and stop before 360 deg - - REM draw the hour markers - angle = z - angle = angle / DEG_PER_RAD - x2 = (hx + (sin(angle) * radius)) - y2 = (hy - (cos(angle) * radius)) - if mod(z,30) = 0 then - tick = htick - else - tick = mtick - endif - x3 = (hx + (sin(angle) * (radius - tick))) - y3 = (hy - (cos(angle) * (radius - tick))) - color 255,0,0 - line x2,y2,x3,y3 - color 0,0,0 - next z -end sub diff --git a/Task/Draw-a-clock/Yabasic/draw-a-clock-1.basic b/Task/Draw-a-clock/Yabasic/draw-a-clock.basic similarity index 100% rename from Task/Draw-a-clock/Yabasic/draw-a-clock-1.basic rename to Task/Draw-a-clock/Yabasic/draw-a-clock.basic diff --git a/Task/Draw-a-clock/Zkl/draw-a-clock.zkl b/Task/Draw-a-clock/Zkl/draw-a-clock.zkl index 50f06ab266..9819c7b3a4 100644 --- a/Task/Draw-a-clock/Zkl/draw-a-clock.zkl +++ b/Task/Draw-a-clock/Zkl/draw-a-clock.zkl @@ -4,7 +4,7 @@ var while(True){ x:=Time.Date.ctime()[11,8] // or Time.Date.to24HString() (no seconds) .pump(List,fcn(n){ n.toAsc() - 0x30 }); //-->L(2,3,10,4,3,10,5,2) - print("\e[H\e[J"); // home and clear screen on ANSI terminals + print("\e[H\e[J"); // home and clear screen on ANSI terminals println(x.pump(String,t.get),"\n",x.pump(String,b.get)); Atomic.sleep(1); } diff --git a/Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg b/Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg deleted file mode 100644 index a10b794b17..0000000000 --- a/Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg +++ /dev/null @@ -1,58 +0,0 @@ -BEGIN # draw some cuboids using ASCII art # - - # draws a cuboid standing on one edge using ASCII art # - PROC aa cuboid = ( INT h, w, l )VOID: - BEGIN - # top line # - TO l DO print( ( " " ) ) OD; - TO w + 1 DO print( ( "_" ) ) OD; - print( ( newline ) ); - # rest of the top face and part of the visible side # - INT face width := 0; - INT edge pos := 0; - FOR i TO l DO - TO l - i DO print( ( " " ) ) OD; - print( ( "/" ) ); - TO w DO print( ( IF i = l THEN "_" ELSE " " FI ) ) OD; - print( ( "/" ) ); - edge pos +:= 1; - IF edge pos <= h THEN - # drsw the back edge # - face width := 2 * ( edge pos - 1 ); - TO face width DO print( ( " " ) ) OD; - print( ( "\" ) ) - ELSE - # draw the bottom edge # - TO face width + 1 DO print( ( " " ) ) OD; - print( ( "/" ) ) - FI; - print( ( newline ) ) - OD; - # other vidible face # - FOR i TO h DO - TO i - 1 DO print( ( " " ) ) OD; - print( ( "\" ) ); - TO w DO print( ( IF i = h THEN "_" ELSE " " FI ) ) OD; - print( ( "\" ) ); - edge pos +:= 1; - IF edge pos <= h THEN - # drsw the back edge # - TO face width + 1 DO print( ( " " ) ) OD; - print( ( "\" ) ) - ELSE - # draw the bottom edge # - TO face width DO print( ( " " ) ) OD; - face width -:= 2; - print( ( "/" ) ) - FI; - print( ( newline ) ) - OD - - END # aa cuboid # ; - - aa cuboid( 3, 2, 4 ); - aa cuboid( 4, 3, 2 ); - aa cuboid( 2, 4, 3 ); - aa cuboid( 2, 3, 4 ) - -END diff --git a/Task/Draw-a-cuboid/Ada/draw-a-cuboid.adb b/Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada similarity index 100% rename from Task/Draw-a-cuboid/Ada/draw-a-cuboid.adb rename to Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada diff --git a/Task/Draw-a-cuboid/Delphi/draw-a-cuboid.pas b/Task/Draw-a-cuboid/Delphi/draw-a-cuboid.delphi similarity index 100% rename from Task/Draw-a-cuboid/Delphi/draw-a-cuboid.pas rename to Task/Draw-a-cuboid/Delphi/draw-a-cuboid.delphi diff --git a/Task/Draw-a-cuboid/EasyLang/draw-a-cuboid.easy b/Task/Draw-a-cuboid/EasyLang/draw-a-cuboid.easy deleted file mode 100644 index 382a35c46e..0000000000 --- a/Task/Draw-a-cuboid/EasyLang/draw-a-cuboid.easy +++ /dev/null @@ -1,71 +0,0 @@ -node[][] = [ [ -1 -2 -2 ] [ -1 -2 1 ] [ -1 2 -2 ] [ -1 2 1 ] [ 1 -2 -2 ] [ 1 -2 1 ] [ 1 2 -2 ] [ 1 2 1 ] ] -edge[][] = [ [ 1 2 ] [ 2 4 ] [ 4 3 ] [ 3 1 ] [ 5 6 ] [ 6 8 ] [ 8 7 ] [ 7 5 ] [ 1 5 ] [ 2 6 ] [ 3 7 ] [ 4 8 ] ] -# -proc scale f . - for i = 1 to len node[][] : for d = 1 to 3 - node[i][d] *= f - . -. -proc rotate angx angy . - sinx = sin angx - cosx = cos angx - siny = sin angy - cosy = cos angy - for i = 1 to len node[][] - x = node[i][1] - z = node[i][3] - node[i][1] = x * cosx - z * sinx - y = node[i][2] - z = z * cosx + x * sinx - node[i][2] = y * cosy - z * siny - node[i][3] = z * cosy + y * siny - . -. -len nd[] 3 -proc draw . - gclear - gtext 2 2 "Arrow keys to rotate" - m = 99999 - mi = -1 - for i = 1 to len node[][] - if node[i][3] < m - m = node[i][3] - mi = i - . - . - ix = 1 - for i = 1 to len edge[][] - if edge[i][1] = mi - nd[ix] = edge[i][2] - ix += 1 - elif edge[i][2] = mi - nd[ix] = edge[i][1] - ix += 1 - . - . - for ni = 1 to len nd[] : for i = 1 to len edge[][] - if edge[i][1] = nd[ni] or edge[i][2] = nd[ni] - x1 = node[edge[i][1]][1] - y1 = node[edge[i][1]][2] - x2 = node[edge[i][2]][1] - y2 = node[edge[i][2]][2] - gline x1 + 50 y1 + 50 x2 + 50 y2 + 50 - . - . -. -gtextsize 3 -scale 15 -rotate 45 45 -draw -on key_down - if keybkey = "ArrowUp" - rotate 0 1 - elif keybkey = "ArrowDown" - rotate 0 -1 - elif keybkey = "ArrowLeft" - rotate -1 0 - elif keybkey = "ArrowRight" - rotate 1 0 - . - draw -. diff --git a/Task/Draw-a-cuboid/Elixir/draw-a-cuboid.ex b/Task/Draw-a-cuboid/Elixir/draw-a-cuboid.elixir similarity index 100% rename from Task/Draw-a-cuboid/Elixir/draw-a-cuboid.ex rename to Task/Draw-a-cuboid/Elixir/draw-a-cuboid.elixir diff --git a/Task/Draw-a-cuboid/Evaldraw/draw-a-cuboid-1.evaldraw b/Task/Draw-a-cuboid/Evaldraw/draw-a-cuboid-1.evaldraw deleted file mode 100644 index c46cf5542d..0000000000 --- a/Task/Draw-a-cuboid/Evaldraw/draw-a-cuboid-1.evaldraw +++ /dev/null @@ -1,53 +0,0 @@ -static points_x[8] = {-2.0, +2.0, +2.0, -2.0, -2.0, +2.0, +2.0, -2.0}; -static points_y[8] = {-1.5, -1.5, +1.5, +1.5, -1.5, -1.5, +1.5, +1.5}; -static points_z[8] = {-1.0, -1.0, -1.0, -1.0, +1.0, +1.0, +1.0, +1.0}; -static segment[2*12] = {0,1, 1,2, 2,3, 3,0, 4,5, 5,6, 6,7, 7,4, 0,4, 1,5, 2,6, 3,7}; -static size=50, sz=0.008, sx=-0.013; // drawing size and tumbling speeds -() { - mind = 0.0; si=0; - for(i=0; i<8; i++) { - if (points_z[i] < mind) { mind=points_z[i]; si=i;} - } - cls(0); // Clear Color Buffer - - for(i=0; i<2*12-1; i+=2) { - j=segment[i]; - x0 = points_x[j]*size + xres/2; - y0 = points_y[j]*size + yres/2; - k=segment[i+1]; - x1 = points_x[k]*size + xres/2; - y1 = points_y[k]*size + yres/2; - - if (j!=si && k!=si) { - setcol(255,0,0); - moveto(x0,y0); lineto(x1,y1); - } else { - setcol(255,255,0); - drawLineStipple(x0,y0,x1,y1,8); - } - } - sleep(16); // Sleep for 16 millis so cube tumbles slowly - for(i=0; i<8; i++) { - points_x[i] = points_x[i] + points_y[i]*Sz; //rotate vertices in X-Y plane - points_y[i] = points_y[i] - points_x[i]*Sz; - points_y[i] = points_y[i] + points_z[i]*Sx; //rotate vertices in Y-Z plane - points_z[i] = points_z[i] - points_y[i]*Sx; - } -} - -drawLineStipple(x1,y1,x2,y2,stipple_dist) { - xdist = x1-x2; ydist=y1-y2; - stipple_dist2 = stipple_dist / 2; - if ( abs(xdist^2 + ydist^2) < stipple_dist2^2 ) return; - if(xdist < 0) xdist=-xdist; - if(ydist < 0) ydist=-ydist; - mv=0; if(ydist > xdist) mv = ydist; else mv = xdist; - x = x1; y = y1; - stepx = xdist/mv; if(x1 > x2) stepx = -stepx; - stepy = ydist/mv; if(y1 > y2) stepy = -stepy; - - for(nc=0; nc 0 THEN DO; - DO I = 1 TO COUNT; CALL PR$CHAR( CH ); END; - END; - END REPEAT$CHAR; - UNDERSCORES: PROCEDURE( COUNT ); /* PRINTS COUNT UNDERSCORES */ - DECLARE COUNT BYTE; - CALL REPEAT$CHAR( 95, COUNT ); - END UNDERSCORES; - - /* TOP LINE */ - CALL REPEAT$CHAR( ' ', L ); CALL UNDERSCORES( W + 1 ); CALL PR$NL; - /* REST OF THE TOP FACE AND PART OF THE VISIBLE SIDE */ - FACE$WIDTH = 0; - EDGE$POS = 0; - DO I = 1 TO L; - CALL REPEAT$CHAR( ' ', L - I ); - CALL PR$CHAR( '/' ); - IF I = L THEN CALL UNDERSCORES( W ); - ELSE CALL REPEAT$CHAR( ' ', W ); - CALL PR$CHAR( '/' ); - EDGE$POS = EDGE$POS + 1; - IF EDGE$POS <= H THEN DO; - /* DRAW THE BACK EDGE */ - FACE$WIDTH = 2 * ( EDGE$POS - 1 ); - CALL REPEAT$CHAR( ' ', FACE$WIDTH ); - CALL BACKSLASH; - END; - ELSE DO; - /* DRAW THE BOTTOM EDGE AND THE MORE OF THE VISIBLE SIDE */ - CALL REPEAT$CHAR( ' ', FACE$WIDTH + 1 ); - CALL PR$CHAR( '/' ); - END; - CALL PR$NL; - END; - /* OTHER VISIBLE FACE */ - DO I = 1 TO H; - CALL REPEAT$CHAR( ' ', I - 1 ); - CALL BACKSLASH; - IF I = H THEN CALL UNDERSCORES( W ); - ELSE CALL REPEAT$CHAR( ' ', W ); - CALL BACKSLASH; - EDGE$POS = EDGE$POS + 1; - IF EDGE$POS <= H THEN DO; - /* DRAW THE BACK EDGE */ - CALL REPEAT$CHAR( ' ', FACE$WIDTH + 1 ); - CALL BACKSLASH; - END; - ELSE DO; - /* DRAW THE BOTTOM EDGE */ - CALL REPEAT$CHAR( ' ', FACE$WIDTH ); - FACE$WIDTH = FACE$WIDTH - 2; - CALL PR$CHAR( '/' ); - END; - CALL PR$NL; - END; - END DRAW$CUBOID; - - CALL DRAW$CUBOID( 3, 2, 4 ); - CALL DRAW$CUBOID( 4, 3, 2 ); - CALL DRAW$CUBOID( 2, 4, 3 ); - CALL DRAW$CUBOID( 2, 3, 4 ); - -EOF diff --git a/Task/Draw-a-cuboid/R/draw-a-cuboid.r b/Task/Draw-a-cuboid/R/draw-a-cuboid.r deleted file mode 100644 index ea0ab1b2f8..0000000000 --- a/Task/Draw-a-cuboid/R/draw-a-cuboid.r +++ /dev/null @@ -1,14 +0,0 @@ -cuboid <- function(w, h, d){ - plot(x=NA, xlim=c(0,(w+d)*sqrt(3)/2), ylim=c(0,h+(w+d)/2), xlab=NA, ylab=NA, asp=1) - polygon(x=c(0, w*sqrt(3)/2, w*sqrt(3)/2, 0), - y=c(w/2, 0, h, h+w/2), - col="red") - polygon(x=c(0, w*sqrt(3)/2, (w+d)*sqrt(3)/2, d*sqrt(3)/2), - y=c(h+w/2, h, h+d/2, h+(w+d)/2), - col="blue") - polygon(x=c(w*sqrt(3)/2, (w+d)*sqrt(3)/2, (w+d)*sqrt(3)/2, w*sqrt(3)/2), - y=c(0, d/2, h+d/2, h), - col="yellow") -} - -cuboid(2, 3, 4) diff --git a/Task/Draw-a-cuboid/V-(Vlang)/draw-a-cuboid.v b/Task/Draw-a-cuboid/V-(Vlang)/draw-a-cuboid.v deleted file mode 100644 index 19ec039f32..0000000000 --- a/Task/Draw-a-cuboid/V-(Vlang)/draw-a-cuboid.v +++ /dev/null @@ -1,32 +0,0 @@ -fn cuboid(dx int, dy int, dz int) { - println("cuboid $dx $dy $dz:") - cub_line(dy + 1, dx, 0, "+-|") - for i in 1 .. dy + 1 { - cub_line(dy - i + 1, dx, i - 1, "/ |") - } - cub_line(0, dx, dy, "+-|") - for _ in 0 .. (4 * dz - dy - 2) { - cub_line(0, dx, dy, "| |") - } - cub_line(0, dx, dy, "| +") - for i in 1 .. dy + 1 { - cub_line(0, dx, dy - i, "| /") - } - last_line := "+-" - print("".repeat(1) + last_line[0].ascii_str()) - println(last_line[1].ascii_str().repeat(9 * dx - 1) + last_line[0].ascii_str()) -} - -fn cub_line(nir int, dx int, dy int, cde string) { - if cde.len < 3 { return } - print(" ".repeat(nir + 1) + cde[0].ascii_str()) - print(cde[1].ascii_str().repeat(9 * dx - 1)) - print(cde[0].ascii_str()) - println(" ".repeat(dy + 1) + cde[2].ascii_str()) -} - -fn main() { - cuboid(2, 3, 4) - cuboid(1, 1, 1) - cuboid(6, 2, 1) -} diff --git a/Task/Draw-a-cuboid/VBScript/draw-a-cuboid.vbs b/Task/Draw-a-cuboid/VBScript/draw-a-cuboid.vb similarity index 100% rename from Task/Draw-a-cuboid/VBScript/draw-a-cuboid.vbs rename to Task/Draw-a-cuboid/VBScript/draw-a-cuboid.vb diff --git a/Task/Draw-a-cuboid/Wren/draw-a-cuboid.wren b/Task/Draw-a-cuboid/Wren/draw-a-cuboid.wren index 0a35aca5a0..dc62a2bb3c 100644 --- a/Task/Draw-a-cuboid/Wren/draw-a-cuboid.wren +++ b/Task/Draw-a-cuboid/Wren/draw-a-cuboid.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var cubLine = Fn.new { |n, dx, dy, cde| Fmt.write("$*s", n + 1, cde[0]) diff --git a/Task/Draw-a-pixel/ARM-Assembly/draw-a-pixel.arm b/Task/Draw-a-pixel/ARM-Assembly/draw-a-pixel.arm index 1e582d7d8b..78039d03f4 100644 --- a/Task/Draw-a-pixel/ARM-Assembly/draw-a-pixel.arm +++ b/Task/Draw-a-pixel/ARM-Assembly/draw-a-pixel.arm @@ -47,7 +47,7 @@ szTexte2: .asciz "Press q for close window or clic X in system me szLibDW: .asciz "WM_DELETE_WINDOW" @ special label for correct close error /*************************************************/ -szMessErr: .ascii "Error code hexa : " +szMessErr: .ascii "Error code hexa : " sHexa: .space 9,' ' .ascii " decimal : " sDeci: .space 15,' ' @@ -441,7 +441,7 @@ conversion16: and r0,r3,r4 @value register and mask lsr r0,r2 @ move right cmp r0,#10 @ compare value - addlt r0,#48 @ <10 ->digit + addlt r0,#48 @ <10 ->digit addge r0,#55 @ >10 ->letter A-F strb r0,[r1],#1 @ store digit on area and + 1 in area address lsr r4,#4 @ shift mask 4 positions @@ -507,7 +507,7 @@ divisionpar10U: sub r1,r4,r2, lsl #1 @ r1 <- r4 - (r2 * 2) = r4 - (r0 * 10) pop {r2,r3,r4,lr} bx lr @ leave function -iMagicNumber: .int 0xCCCCCCCD +iMagicNumber: .int 0xCCCCCCCD /***************************************************/ /* integer division unsigned */ /***************************************************/ diff --git a/Task/Draw-a-pixel/Ada/draw-a-pixel.adb b/Task/Draw-a-pixel/Ada/draw-a-pixel.ada similarity index 100% rename from Task/Draw-a-pixel/Ada/draw-a-pixel.adb rename to Task/Draw-a-pixel/Ada/draw-a-pixel.ada diff --git a/Task/Draw-a-pixel/Applesoft-BASIC/draw-a-pixel.basic b/Task/Draw-a-pixel/Applesoft-BASIC/draw-a-pixel.basic deleted file mode 100644 index 370428862e..0000000000 --- a/Task/Draw-a-pixel/Applesoft-BASIC/draw-a-pixel.basic +++ /dev/null @@ -1,29 +0,0 @@ - 100 WIDTH = 320 - 110 HEIGHT = 240 - 120 C = 1: REM RED - 130 X = 100 - 140 Y = 100 - 150 DEF FN X(X) = INT ((X - 1) / 14) - 160 DEF FN Y(Y) = INT ((Y - 1) / 8) - 170 W = FN X(WIDTH) - 180 H = FN Y(HEIGHT) - 190 WX = INT ( RND (1) * (40 - W)) - 200 WY = INT ( RND (1) * (48 - H)) - 210 C$ = "0123456789:;<=>?" - 220 C$ = MID$ (C$,C,I) + MID$ (C$,C + 2, LEN (C$) - C - 1) - 230 I = INT ( RND (1) * LEN (C$)) - 240 COLOR= ASC ( MID$ (C$,I + 1)) - 48 - 250 C$ = MID$ (C$,1,I) + MID$ (C$,I + 2, LEN (C$) - I - 1) - 260 A = PEEK (49234) + PEEK (49240) + PEEK (49232) - 270 FOR I = 0 TO 39 - 280 VLIN 0,47 AT I - 290 NEXT - 300 COLOR= ASC ( MID$ (C$, INT ( RND (1) * LEN (C$)) + 1)) - 48 - 310 FOR I = WX TO WX + W - 320 VLIN WY,WY + H AT I - 330 NEXT - 340 COLOR= C - 350 PLOT WX + FN X(X),WY + FN Y(Y) - 360 WAIT 49152,128 - 370 TEXT - 380 HOME diff --git a/Task/Draw-a-pixel/AutoHotkey/draw-a-pixel.ahk b/Task/Draw-a-pixel/AutoHotkey/draw-a-pixel.ahk index aa35877040..86bccdddd4 100644 --- a/Task/Draw-a-pixel/AutoHotkey/draw-a-pixel.ahk +++ b/Task/Draw-a-pixel/AutoHotkey/draw-a-pixel.ahk @@ -4,9 +4,9 @@ Gui, Show, w320 h240, Example return CreatePixel(Color, Handle) { - VarSetCapacity(BMBITS, 4, 0), Numput("0x" . Color, &BMBITS, 0, "UInt") - hBM := DllCall("Gdi32.dll\CreateBitmap", "Int", 1, "Int", 1, "UInt", 1, "UInt", 24, "Ptr", 0, "Ptr") - hBM := DllCall("User32.dll\CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "Ptr") - DllCall("Gdi32.dll\SetBitmapBits", "Ptr", hBM, "UInt", 3, "Ptr", &BMBITS) - DllCall("User32.dll\SendMessage", "Ptr", Handle, "UInt", 0x172, "Ptr", 0, "Ptr", hBM) + VarSetCapacity(BMBITS, 4, 0), Numput("0x" . Color, &BMBITS, 0, "UInt") + hBM := DllCall("Gdi32.dll\CreateBitmap", "Int", 1, "Int", 1, "UInt", 1, "UInt", 24, "Ptr", 0, "Ptr") + hBM := DllCall("User32.dll\CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "Ptr") + DllCall("Gdi32.dll\SetBitmapBits", "Ptr", hBM, "UInt", 3, "Ptr", &BMBITS) + DllCall("User32.dll\SendMessage", "Ptr", Handle, "UInt", 0x172, "Ptr", 0, "Ptr", hBM) } diff --git a/Task/Draw-a-pixel/BBC-BASIC/draw-a-pixel.basic b/Task/Draw-a-pixel/BBC-BASIC/draw-a-pixel.basic index 8c21868954..eff5cc12bd 100644 --- a/Task/Draw-a-pixel/BBC-BASIC/draw-a-pixel.basic +++ b/Task/Draw-a-pixel/BBC-BASIC/draw-a-pixel.basic @@ -1 +1 @@ - VDU 23, 22, 320; 240; 8, 8, 8, 128, 18, 0, 9, 25, 69, 100; 100; + VDU 23, 22, 320; 240; 8, 8, 8, 0, 18, 0, 1, 25, 69, 100; 100; diff --git a/Task/Draw-a-pixel/C/draw-a-pixel-1.c b/Task/Draw-a-pixel/C/draw-a-pixel-1.c deleted file mode 100644 index 3bbd254b80..0000000000 --- a/Task/Draw-a-pixel/C/draw-a-pixel-1.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -int main() -{ - initwindow(320,240,"Red Pixel"); - - putpixel(100,100,RED); - - getch(); - - return 0; -} diff --git a/Task/Draw-a-pixel/C/draw-a-pixel-2.c b/Task/Draw-a-pixel/C/draw-a-pixel-2.c deleted file mode 100644 index 41626fc1f6..0000000000 --- a/Task/Draw-a-pixel/C/draw-a-pixel-2.c +++ /dev/null @@ -1,71 +0,0 @@ -// dotrosetta.c - https://rosettacode.org/wiki/Draw_a_pixel - -#include -#include -#include - -int -main(void) - { - Atom wm_both_protocols[1]; - Atom wm_delete; - Atom wm_protocols; - Display *display; - GC gc; - Window root; - Window window; - XEvent event; - XSetWindowAttributes attr; - int more = 1; - - display = XOpenDisplay(NULL); - if(display == NULL) - { - fprintf(stderr,"Error: The display cannot be opened\n"); - exit(1); - } - root = DefaultRootWindow(display); - wm_delete = XInternAtom(display, "WM_DELETE_WINDOW", False); - wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False); - attr.background_pixel = 0x000000; - attr.event_mask = ExposureMask; - window = XCreateWindow(display, root, - 0, 0, 320, 240, 0, - CopyFromParent, InputOutput, CopyFromParent, - CWBackPixel | CWEventMask, - &attr - ); - XStoreName(display, window, "Draw a Pixel"); - wm_both_protocols[0] = wm_delete; - XSetWMProtocols(display, window, wm_both_protocols, 1); - gc = XCreateGC(display, window, 0, NULL); - XSetForeground(display, gc, 0xFF0000); - XMapWindow(display, window); - - while(more) - { - XNextEvent(display, &event); - switch(event.type) - { - case Expose: - XDrawPoint(display, window, gc, 100, 100); - break; - - case ClientMessage: // for close request from WM - if(event.xclient.window == window && - event.xclient.message_type == wm_protocols && - event.xclient.format == 32 && - event.xclient.data.l[0] == wm_delete) - { - more = 0; - } - break; - - default: - printf("unexpected event.type %d\n", event.type);; - } - } - - XCloseDisplay(display); - exit(0); - } diff --git a/Task/Draw-a-pixel/C/draw-a-pixel.c b/Task/Draw-a-pixel/C/draw-a-pixel.c new file mode 100644 index 0000000000..a9ce8075bf --- /dev/null +++ b/Task/Draw-a-pixel/C/draw-a-pixel.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + initwindow(320,240,"Red Pixel"); + + putpixel(100,100,RED); + + getch(); + + return 0; +} diff --git a/Task/Draw-a-pixel/Delphi/draw-a-pixel.pas b/Task/Draw-a-pixel/Delphi/draw-a-pixel.delphi similarity index 100% rename from Task/Draw-a-pixel/Delphi/draw-a-pixel.pas rename to Task/Draw-a-pixel/Delphi/draw-a-pixel.delphi diff --git a/Task/Draw-a-pixel/EasyLang/draw-a-pixel.easy b/Task/Draw-a-pixel/EasyLang/draw-a-pixel.easy index cba3accc14..017be6b5e2 100644 --- a/Task/Draw-a-pixel/EasyLang/draw-a-pixel.easy +++ b/Task/Draw-a-pixel/EasyLang/draw-a-pixel.easy @@ -1,2 +1,3 @@ -gcolor 900 -grect 50 50 0.5 0.5 +color 900 +move 99 99 +rect 1 1 diff --git a/Task/Draw-a-pixel/Evaldraw/draw-a-pixel.evaldraw b/Task/Draw-a-pixel/Evaldraw/draw-a-pixel.evaldraw deleted file mode 100644 index c535799310..0000000000 --- a/Task/Draw-a-pixel/Evaldraw/draw-a-pixel.evaldraw +++ /dev/null @@ -1,4 +0,0 @@ -() -cls(0); -setcol(255,0,0); -setpix(100,100); diff --git a/Task/Draw-a-pixel/Forth/draw-a-pixel.fth b/Task/Draw-a-pixel/Forth/draw-a-pixel.fth index 5d6ed34ccc..5df2b5490a 100644 --- a/Task/Draw-a-pixel/Forth/draw-a-pixel.fth +++ b/Task/Draw-a-pixel/Forth/draw-a-pixel.fth @@ -1,13 +1,13 @@ \ Bindings to SDL2 functions s" SDL2" add-lib \c #include -c-function sdl-init SDL_Init n -- n -c-function sdl-quit SDL_Quit -- void -c-function sdl-createwindow SDL_CreateWindow a n n n n n -- a -c-function sdl-createrenderer SDL_CreateRenderer a n n -- a -c-function sdl-setdrawcolor SDL_SetRenderDrawColor a n n n n -- n -c-function sdl-drawpoint SDL_RenderDrawPoint a n n -- n -c-function sdl-renderpresent SDL_RenderPresent a -- void +c-function sdl-init SDL_Init n -- n +c-function sdl-quit SDL_Quit -- void +c-function sdl-createwindow SDL_CreateWindow a n n n n n -- a +c-function sdl-createrenderer SDL_CreateRenderer a n n -- a +c-function sdl-setdrawcolor SDL_SetRenderDrawColor a n n n n -- n +c-function sdl-drawpoint SDL_RenderDrawPoint a n n -- n +c-function sdl-renderpresent SDL_RenderPresent a -- void c-function sdl-delay SDL_Delay n -- void : pixel ( -- ) diff --git a/Task/Draw-a-pixel/Frink/draw-a-pixel.frink b/Task/Draw-a-pixel/Frink/draw-a-pixel.frink deleted file mode 100644 index d291521c4a..0000000000 --- a/Task/Draw-a-pixel/Frink/draw-a-pixel.frink +++ /dev/null @@ -1,3 +0,0 @@ -i = new image[320,240] -i.setPixel[100,100,1,0,0] -i.show[] diff --git a/Task/Draw-a-pixel/GML/draw-a-pixel.gml b/Task/Draw-a-pixel/GML/draw-a-pixel.gml index e29266b1f2..cf522016a3 100644 --- a/Task/Draw-a-pixel/GML/draw-a-pixel.gml +++ b/Task/Draw-a-pixel/GML/draw-a-pixel.gml @@ -1,2 +1 @@ -draw_set_color(c_red) -draw_point(100, 100) +draw_point(100, 100); diff --git a/Task/Draw-a-pixel/Go/draw-a-pixel-2.go b/Task/Draw-a-pixel/Go/draw-a-pixel-2.go index 7a083d1030..89d068dd45 100644 --- a/Task/Draw-a-pixel/Go/draw-a-pixel-2.go +++ b/Task/Draw-a-pixel/Go/draw-a-pixel-2.go @@ -1,22 +1,22 @@ package main import ( - "image" - "image/color" - "image/draw" - "image/png" - "os" + "image" + "image/color" + "image/draw" + "image/png" + "os" ) func main() { - // Create a 320 x 240 image - img := image.NewRGBA(image.Rect(0, 0, 320, 240)) - // fill img in white - draw.Draw(img, img.Bounds(), &image.Uniform{color.RGBA{0, 0, 0, 0}}, image.ZP, draw.Src) - // Draw a red dot at (100, 100) - img.Set(100, 100, color.RGBA{255, 0, 0, 255}) - // Save to new.png - w, _ := os.OpenFile("new.png", os.O_WRONLY|os.O_CREATE, 0600) - defer w.Close() - png.Encode(w, img) + // Create a 320 x 240 image + img := image.NewRGBA(image.Rect(0, 0, 320, 240)) + // fill img in white + draw.Draw(img, img.Bounds(), &image.Uniform{color.RGBA{0, 0, 0, 0}}, image.ZP, draw.Src) + // Draw a red dot at (100, 100) + img.Set(100, 100, color.RGBA{255, 0, 0, 255}) + // Save to new.png + w, _ := os.OpenFile("new.png", os.O_WRONLY|os.O_CREATE, 0600) + defer w.Close() + png.Encode(w, img) } diff --git a/Task/Draw-a-pixel/Go/draw-a-pixel-3.go b/Task/Draw-a-pixel/Go/draw-a-pixel-3.go index f6bc3aace1..9fb62304ea 100644 --- a/Task/Draw-a-pixel/Go/draw-a-pixel-3.go +++ b/Task/Draw-a-pixel/Go/draw-a-pixel-3.go @@ -4,7 +4,7 @@ package main import "github.com/zserge/webview" func main() { - // Open wikipedia in a 320*240 resizable window - webview.Open("Minimal webview example", - "https://en.m.wikipedia.org/wiki/Main_Page", 320, 240, true) + // Open wikipedia in a 320*240 resizable window + webview.Open("Minimal webview example", + "https://en.m.wikipedia.org/wiki/Main_Page", 320, 240, true) } diff --git a/Task/Draw-a-pixel/Java/draw-a-pixel-1.java b/Task/Draw-a-pixel/Java/draw-a-pixel-1.java index 7636004f0b..51805bb233 100644 --- a/Task/Draw-a-pixel/Java/draw-a-pixel-1.java +++ b/Task/Draw-a-pixel/Java/draw-a-pixel-1.java @@ -3,18 +3,18 @@ import java.awt.Graphics; import javax.swing.JFrame; public class DrawAPixel extends JFrame{ - public DrawAPixel() { - super("Red Pixel"); - setSize(320, 240); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setVisible(true); - } - @Override - public void paint(Graphics g) { - g.setColor(new Color(255, 0, 0)); - g.drawRect(100, 100, 1, 1); - } - public static void main(String[] args) { - new DrawAPixel(); - } + public DrawAPixel() { + super("Red Pixel"); + setSize(320, 240); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setVisible(true); + } + @Override + public void paint(Graphics g) { + g.setColor(new Color(255, 0, 0)); + g.drawRect(100, 100, 1, 1); + } + public static void main(String[] args) { + new DrawAPixel(); + } } diff --git a/Task/Draw-a-pixel/Java/draw-a-pixel-2.java b/Task/Draw-a-pixel/Java/draw-a-pixel-2.java index ecb25f50b5..c4f07a05b8 100644 --- a/Task/Draw-a-pixel/Java/draw-a-pixel-2.java +++ b/Task/Draw-a-pixel/Java/draw-a-pixel-2.java @@ -4,30 +4,30 @@ import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; -public class DrawAPixel extends JPanel{ - private BufferedImage puffer; - private JFrame window; - private Graphics g; - public DrawAPixel() { - window = new JFrame("Red Pixel"); - window.setSize(320, 240); - window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - window.setLayout(null); - setBounds(0, 0, 320, 240); - window.add(this); - window.setVisible(true); - } - @Override - public void paint(Graphics gr) { - if(g == null) { - puffer = (BufferedImage) createImage(getWidth(), getHeight()); - g = puffer.getGraphics(); - } - g.setColor(new Color(255, 0, 0)); - g.drawRect(100, 100, 1, 1); - gr.drawImage(puffer, 0, 0, this); - } - public static void main(String[] args) { - new DrawAPixel(); - } +public class DrawAPixel extends JPanel{ + private BufferedImage puffer; + private JFrame window; + private Graphics g; + public DrawAPixel() { + window = new JFrame("Red Pixel"); + window.setSize(320, 240); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setLayout(null); + setBounds(0, 0, 320, 240); + window.add(this); + window.setVisible(true); + } + @Override + public void paint(Graphics gr) { + if(g == null) { + puffer = (BufferedImage) createImage(getWidth(), getHeight()); + g = puffer.getGraphics(); + } + g.setColor(new Color(255, 0, 0)); + g.drawRect(100, 100, 1, 1); + gr.drawImage(puffer, 0, 0, this); + } + public static void main(String[] args) { + new DrawAPixel(); + } } diff --git a/Task/Draw-a-pixel/Julia/draw-a-pixel.jl b/Task/Draw-a-pixel/Julia/draw-a-pixel.julia similarity index 100% rename from Task/Draw-a-pixel/Julia/draw-a-pixel.jl rename to Task/Draw-a-pixel/Julia/draw-a-pixel.julia diff --git a/Task/Draw-a-pixel/Kotlin/draw-a-pixel.kts b/Task/Draw-a-pixel/Kotlin/draw-a-pixel.kotlin similarity index 100% rename from Task/Draw-a-pixel/Kotlin/draw-a-pixel.kts rename to Task/Draw-a-pixel/Kotlin/draw-a-pixel.kotlin diff --git a/Task/Draw-a-pixel/Lua/draw-a-pixel.lua b/Task/Draw-a-pixel/Lua/draw-a-pixel.lua index 7050f8b22d..525421de1f 100644 --- a/Task/Draw-a-pixel/Lua/draw-a-pixel.lua +++ b/Task/Draw-a-pixel/Lua/draw-a-pixel.lua @@ -2,9 +2,9 @@ local SDL = require "SDL" local ret = SDL.init { SDL.flags.Video } local window = SDL.createWindow { - title = "Pixel", - height = 320, - width = 240 + title = "Pixel", + height = 320, + width = 240 } local renderer = SDL.createRenderer(window, 0, 0) diff --git a/Task/Draw-a-pixel/Maxima/draw-a-pixel.maxima b/Task/Draw-a-pixel/Maxima/draw-a-pixel.maxima deleted file mode 100644 index f0d6369d6a..0000000000 --- a/Task/Draw-a-pixel/Maxima/draw-a-pixel.maxima +++ /dev/null @@ -1,5 +0,0 @@ -/* Matrix that represents the window and the pixel positioned in it */ -ematrix(320,240,1,100,100)$ - -/* Drawing the window and the pixel as needed */ -wxdraw2d(palette = [white,gray,red], image(%,0,0,320,240))$ diff --git a/Task/Draw-a-pixel/OCaml/draw-a-pixel-1.ml b/Task/Draw-a-pixel/OCaml/draw-a-pixel-1.ocaml similarity index 100% rename from Task/Draw-a-pixel/OCaml/draw-a-pixel-1.ml rename to Task/Draw-a-pixel/OCaml/draw-a-pixel-1.ocaml diff --git a/Task/Draw-a-pixel/OCaml/draw-a-pixel-2.ml b/Task/Draw-a-pixel/OCaml/draw-a-pixel-2.ocaml similarity index 100% rename from Task/Draw-a-pixel/OCaml/draw-a-pixel-2.ml rename to Task/Draw-a-pixel/OCaml/draw-a-pixel-2.ocaml diff --git a/Task/Draw-a-pixel/OPL/draw-a-pixel.opl b/Task/Draw-a-pixel/OPL/draw-a-pixel.opl deleted file mode 100644 index f880013ec3..0000000000 --- a/Task/Draw-a-pixel/OPL/draw-a-pixel.opl +++ /dev/null @@ -1,11 +0,0 @@ -REM Psion devices up to Series 5 have no colour, so the pixel is black. The Series 7 and later do have colour, but I don't own any of those, so I can neither test it nor am I familiar with OPL beyond Series 5. -REM The Series 3 also has a resolution of only 480x160, so the window falls off the screen. - -PROC main: - LOCAL wndw% - wndw%=gCREATE(80,0,320,240,1,1) - gXBORDER 1,1 - gAT 100,100 - gLINEBY 0,0 - GET -ENDP diff --git a/Task/Draw-a-pixel/Oberon/draw-a-pixel.oberon b/Task/Draw-a-pixel/Oberon/draw-a-pixel.oberon index 12a93b93a9..8a9cf70323 100644 --- a/Task/Draw-a-pixel/Oberon/draw-a-pixel.oberon +++ b/Task/Draw-a-pixel/Oberon/draw-a-pixel.oberon @@ -1,9 +1,9 @@ MODULE pixel; - IMPORT XYplane; - + IMPORT XYplane; + BEGIN - XYplane.Open; - XYplane.Dot(100, 100, XYplane.draw); - REPEAT UNTIL XYplane.Key() = "q" + XYplane.Open; + XYplane.Dot(100, 100, XYplane.draw); + REPEAT UNTIL XYplane.Key() = "q" END pixel. diff --git a/Task/Draw-a-pixel/Odin/draw-a-pixel-2.odin b/Task/Draw-a-pixel/Odin/draw-a-pixel-2.odin deleted file mode 100644 index ee0880c648..0000000000 --- a/Task/Draw-a-pixel/Odin/draw-a-pixel-2.odin +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import rl "vendor:raylib" - -main :: proc() { - rl.InitWindow(320, 240, "Rosetta Code - Draw a pixel") - - for !rl.WindowShouldClose() { - rl.BeginDrawing() - - rl.ClearBackground(rl.BLACK) - - rl.DrawPixelV({100, 100}, {255, 0, 0, 255}) - - rl.EndDrawing() - } - - rl.CloseWindow() -} diff --git a/Task/Draw-a-pixel/Odin/draw-a-pixel-1.odin b/Task/Draw-a-pixel/Odin/draw-a-pixel.odin similarity index 100% rename from Task/Draw-a-pixel/Odin/draw-a-pixel-1.odin rename to Task/Draw-a-pixel/Odin/draw-a-pixel.odin diff --git a/Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas b/Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas deleted file mode 100644 index caaee3cf72..0000000000 --- a/Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas +++ /dev/null @@ -1,6 +0,0 @@ -uses GraphWPF; - -begin - Window.SetSize(320,240); - SetPixel(100,100,Colors.Red); -end. diff --git a/Task/Draw-a-pixel/Perl/draw-a-pixel-2.pl b/Task/Draw-a-pixel/Perl/draw-a-pixel-2.pl deleted file mode 100644 index 6964a0063e..0000000000 --- a/Task/Draw-a-pixel/Perl/draw-a-pixel-2.pl +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/perl - -use strict; # https://rosettacode.org/wiki/Draw_a_pixel -use warnings; -use Tk; - -my $mw = MainWindow->new; -my $canvas = $mw->Canvas( -width => 320, -height => 240 )->pack; -$canvas->createRectangle( 100, 100, 100, 100, -outline => 'red' ); -MainLoop; diff --git a/Task/Draw-a-pixel/Perl/draw-a-pixel-3.pl b/Task/Draw-a-pixel/Perl/draw-a-pixel-3.pl deleted file mode 100644 index 37bdd615b4..0000000000 --- a/Task/Draw-a-pixel/Perl/draw-a-pixel-3.pl +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/perl - -use strict; # https://rosettacode.org/wiki/Draw_a_pixel -use warnings; -use X11::Protocol; - -my $x = new X11::Protocol or die "X11 connection failed"; -$x->CreateWindow(my $id = $x->new_rsrc, $x->root, 'InputOutput', - $x->root_depth, 'CopyFromParent', - 0, 0, 320, 240, 0, - background_pixel => 0x000000, - event_mask => $x->pack_event_mask( qw( Exposure )), - ); -$x->ChangeProperty($id, $x->atom('WM_NAME'), $x->atom('STRING'), - 8, 'Replace', 'Draw a Pixel'); -$x->ChangeProperty($id, $x->atom('WM_PROTOCOLS'), $x->atom('ATOM'), - 32, 'Replace', pack('L', $x->atom('WM_DELETE_WINDOW'))); -$x->CreateGC(my $gc = $x->new_rsrc, $id, foreground => 0xff0000); -$x->MapWindow($id); -$x->event_handler('queue'); - -my ($more, $name, %e) = 1; -while($more) - { - %e = $x->next_event; - $name = $e{name}; - EVENT->$name; - } - -sub EVENT::Expose { $x->PolyPoint($id, $gc, 'ORIGIN', 100, 100) } -sub EVENT::ConfigureNotify { } -sub EVENT::ClientMessage - { - if($e{type} == $x->atom('WM_PROTOCOLS') && - unpack('L', $e{data}) == $x->atom('WM_DELETE_WINDOW')) - { - $more = 0; - } - else - { - warn "Unknown $name, $e{type}\n"; - } - } -sub EVENT::AUTOLOAD { die "Sorry, no handler for $name\n" } diff --git a/Task/Draw-a-pixel/Perl/draw-a-pixel-1.pl b/Task/Draw-a-pixel/Perl/draw-a-pixel.pl similarity index 100% rename from Task/Draw-a-pixel/Perl/draw-a-pixel-1.pl rename to Task/Draw-a-pixel/Perl/draw-a-pixel.pl diff --git a/Task/Draw-a-pixel/R/draw-a-pixel.r b/Task/Draw-a-pixel/R/draw-a-pixel.r deleted file mode 100644 index 4fd8762de5..0000000000 --- a/Task/Draw-a-pixel/R/draw-a-pixel.r +++ /dev/null @@ -1,9 +0,0 @@ -disp_h <- 240 -disp_w <- 320 -mat <- matrix(0, nrow = disp_w, ncol = disp_h) -mat[100, 100] <- 1 -png("DrawPixel-R.png", disp_w, disp_h) -op <- par(mar = rep(0, 4), mai = rep(0, 4)) -image(mat, col = c("white", "red"), useRaster = TRUE, axes = FALSE) -par(op) -dev.off() diff --git a/Task/Draw-a-pixel/ReScript/draw-a-pixel-1.res b/Task/Draw-a-pixel/ReScript/draw-a-pixel-1.re similarity index 100% rename from Task/Draw-a-pixel/ReScript/draw-a-pixel-1.res rename to Task/Draw-a-pixel/ReScript/draw-a-pixel-1.re diff --git a/Task/Draw-a-pixel/ReScript/draw-a-pixel-2.res b/Task/Draw-a-pixel/ReScript/draw-a-pixel-2.re similarity index 100% rename from Task/Draw-a-pixel/ReScript/draw-a-pixel-2.res rename to Task/Draw-a-pixel/ReScript/draw-a-pixel-2.re diff --git a/Task/Draw-a-pixel/Rebol/draw-a-pixel.rebol b/Task/Draw-a-pixel/Rebol/draw-a-pixel.rebol deleted file mode 100644 index 657fa8b619..0000000000 --- a/Task/Draw-a-pixel/Rebol/draw-a-pixel.rebol +++ /dev/null @@ -1,10 +0,0 @@ -Rebol [ - title: "Rosetta code: Draw a pixel" - file: %Draw_a_pixel.r3 - url: https://rosettacode.org/wiki/Draw_a_pixel -] - -img: make image! 320x240 ;; Create a new image of size 320x240 pixels -img/(100x100): 255.0.0 ;; Set the pixel at position 100x100 to pure red -save %test.png img ;; Save the image to a PNG file named "test.png" -browse %test.png ;; Open the saved image file using the default browser diff --git a/Task/Draw-a-pixel/Rust/draw-a-pixel.rs b/Task/Draw-a-pixel/Rust/draw-a-pixel.rust similarity index 100% rename from Task/Draw-a-pixel/Rust/draw-a-pixel.rs rename to Task/Draw-a-pixel/Rust/draw-a-pixel.rust diff --git a/Task/Draw-a-pixel/Uiua/draw-a-pixel.uiua b/Task/Draw-a-pixel/Uiua/draw-a-pixel.uiua deleted file mode 100644 index c45ca1b7cf..0000000000 --- a/Task/Draw-a-pixel/Uiua/draw-a-pixel.uiua +++ /dev/null @@ -1,2 +0,0 @@ -↯240_320_3 0 -⍜(⊡[100 100]|[1 0 0]◌) diff --git a/Task/Draw-a-pixel/V-(Vlang)/draw-a-pixel.v b/Task/Draw-a-pixel/V-(Vlang)/draw-a-pixel.v index 80701bae65..f8ec8e887e 100644 --- a/Task/Draw-a-pixel/V-(Vlang)/draw-a-pixel.v +++ b/Task/Draw-a-pixel/V-(Vlang)/draw-a-pixel.v @@ -1,4 +1,5 @@ import gg +import gx fn main() { mut context := gg.new_context( @@ -11,6 +12,6 @@ fn main() { fn frame(mut ctx gg.Context) { ctx.begin() - ctx.draw_pixel(100, 100, gg.red) + ctx.draw_pixel(100, 100, gx.red) ctx.end() } diff --git a/Task/Draw-a-rotating-cube/Ada/draw-a-rotating-cube.adb b/Task/Draw-a-rotating-cube/Ada/draw-a-rotating-cube.ada similarity index 100% rename from Task/Draw-a-rotating-cube/Ada/draw-a-rotating-cube.adb rename to Task/Draw-a-rotating-cube/Ada/draw-a-rotating-cube.ada diff --git a/Task/Draw-a-rotating-cube/Chipmunk-Basic/draw-a-rotating-cube.basic b/Task/Draw-a-rotating-cube/Chipmunk-Basic/draw-a-rotating-cube.basic deleted file mode 100644 index a3dab8ee28..0000000000 --- a/Task/Draw-a-rotating-cube/Chipmunk-Basic/draw-a-rotating-cube.basic +++ /dev/null @@ -1,35 +0,0 @@ -100 cls -110 graphics 0 -120 graphics color 0,0,0 -130 while true -140 graphics cls -150 x = cos(t)*20 -160 y = sin(t)*18 -170 r = sin(t+t) -180 moveto (x+40),(y+40-r) -190 lineto (-y+40),(x+40-r) -200 moveto (-y+40),(x+40-r) -210 lineto (-x+40),(-y+40-r) -220 moveto (-x+40),(-y+40-r) -230 lineto (y+40),(-x+40-r) -240 moveto (y+40),(-x+40-r) -250 lineto (x+40),(y+40-r) -260 moveto (x+40),(y+20+r) -270 lineto (-y+40),(x+20+r) -280 moveto (-y+40),(x+20+r) -290 lineto (-x+40),(-y+20+r) -300 moveto (-x+40),(-y+20+r) -310 lineto (y+40),(-x+20+r) -320 moveto (y+40),(-x+20+r) -330 lineto (x+40),(y+20+r) -340 moveto (x+40),(y+40-r) -350 lineto (x+40),(y+20+r) -360 moveto (-y+40),(x+40-r) -370 lineto (-y+40),(x+20+r) -380 moveto (-x+40),(-y+40-r) -390 lineto (-x+40),(-y+20+r) -400 moveto (y+40),(-x+40-r) -410 lineto (y+40),(-x+20+r) -420 for i = 1 to 1000 : next i -430 t = t+0.15 -440 wend diff --git a/Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-1.pas b/Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-1.delphi similarity index 100% rename from Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-1.pas rename to Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-1.delphi diff --git a/Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-2.pas b/Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-2.delphi similarity index 100% rename from Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-2.pas rename to Task/Draw-a-rotating-cube/Delphi/draw-a-rotating-cube-2.delphi diff --git a/Task/Draw-a-rotating-cube/EasyLang/draw-a-rotating-cube.easy b/Task/Draw-a-rotating-cube/EasyLang/draw-a-rotating-cube.easy index 09df71826d..b7f1a1638d 100644 --- a/Task/Draw-a-rotating-cube/EasyLang/draw-a-rotating-cube.easy +++ b/Task/Draw-a-rotating-cube/EasyLang/draw-a-rotating-cube.easy @@ -1,12 +1,14 @@ node[][] = [ [ -1 -1 -1 ] [ -1 -1 1 ] [ -1 1 -1 ] [ -1 1 1 ] [ 1 -1 -1 ] [ 1 -1 1 ] [ 1 1 -1 ] [ 1 1 1 ] ] edge[][] = [ [ 1 2 ] [ 2 4 ] [ 4 3 ] [ 3 1 ] [ 5 6 ] [ 6 8 ] [ 8 7 ] [ 7 5 ] [ 1 5 ] [ 2 6 ] [ 3 7 ] [ 4 8 ] ] # -proc scale f . - for i = 1 to len node[][] : for d = 1 to 3 - node[i][d] *= f +proc scale f . . + for i = 1 to len node[][] + for d = 1 to 3 + node[i][d] *= f + . . . -proc rotate angx angy . +proc rotate angx angy . . sinx = sin angx cosx = cos angx siny = sin angy @@ -22,8 +24,8 @@ proc rotate angx angy . . . len nd[] 3 -proc draw . - gclear +proc draw . . + clear m = 999 mi = -1 for i = 1 to len node[][] @@ -42,20 +44,23 @@ proc draw . ix += 1 . . - for ni = 1 to len nd[] : for i = 1 to len edge[][] - if edge[i][1] = nd[ni] or edge[i][2] = nd[ni] - x1 = node[edge[i][1]][1] - y1 = node[edge[i][1]][2] - x2 = node[edge[i][2]][1] - y2 = node[edge[i][2]][2] - gline x1 + 50 y1 + 50 x2 + 50 y2 + 50 + for ni = 1 to len nd[] + for i = 1 to len edge[][] + if edge[i][1] = nd[ni] or edge[i][2] = nd[ni] + x1 = node[edge[i][1]][1] + y1 = node[edge[i][1]][2] + x2 = node[edge[i][2]][1] + y2 = node[edge[i][2]][2] + move x1 + 50 y1 + 50 + line x2 + 50 y2 + 50 + . . . . -scale 25 -rotate 45 atan sqrt 2 -draw +call scale 25 +call rotate 45 atan sqrt 2 +call draw on animate - rotate 1 0 - draw + call rotate 1 0 + call draw . diff --git a/Task/Draw-a-rotating-cube/Evaldraw/draw-a-rotating-cube.evaldraw b/Task/Draw-a-rotating-cube/Evaldraw/draw-a-rotating-cube.evaldraw deleted file mode 100644 index e41b9fe913..0000000000 --- a/Task/Draw-a-rotating-cube/Evaldraw/draw-a-rotating-cube.evaldraw +++ /dev/null @@ -1,108 +0,0 @@ -// We can define our own vec3 struct -struct vec3{x,y,z;} -static modelMatrix[9]; -() { - cls(0x828282); // clear screen - clz(1e32); // clear depth buffer - setcam(0,0,-3,0,0); // set camera some units back - - // create two local arrays to hold rotation matrices - double roty[9], rotz[9]; - - static otim; - tim=klock(0); dt=tim-otim; otim=tim; - static degrees = 0; - degrees+=200*dt; - rads = degrees/180*pi; - rotateZ( rotz, rads ); - rotateY( roty, rads ); - - // evaldraw does support some GL-like drawing - // modes, but any transformations must be done by hand - // Here we use a global model matrix that - // transforms vertices created by the myVertex function - mult(modelMatrix, roty, rotz); - glSetTex("cloud.png"); - drawcuboid(0,0,0,1,1,1); -} - -drawcuboid(x,y,z,sx,sy,sz) { - glBegin(GL_QUADS); - setcol(192,32,32); - glTexCoord(0,0); myVertex(x-sx,y-sy,z-sz); - glTexCoord(1,0); myVertex(x+sx,y-sy,z-sz); - glTexCoord(1,1); myVertex(x+sx,y+sy,z-sz); - glTexCoord(0,1); myVertex(x-sx,y+sy,z-sz); - - setcol(32,192,32); - glTexCoord(0,0); myVertex(x-sx,y-sy,z+sz); - glTexCoord(1,0); myVertex(x-sx,y-sy,z-sz); - glTexCoord(1,1); myVertex(x-sx,y+sy,z-sz); - glTexCoord(0,1); myVertex(x-sx,y+sy,z+sz); - - setcol(32,32,192); - glTexCoord(0,0); myVertex(x+sx,y-sy,z+sz); - glTexCoord(1,0); myVertex(x-sx,y-sy,z+sz); - glTexCoord(1,1); myVertex(x-sx,y+sy,z+sz); - glTexCoord(0,1); myVertex(x+sx,y+sy,z+sz); - - setcol(192,192,32); - glTexCoord(0,0); myVertex(x+sx,y-sy,z-sz); - glTexCoord(1,0); myVertex(x+sx,y-sy,z+sz); - glTexCoord(1,1); myVertex(x+sx,y+sy,z+sz); - glTexCoord(0,1); myVertex(x+sx,y+sy,z-sz); - - setcol(192,32,192); - glTexCoord(0,0); myVertex(x-sx,y-sy,z+sz); - glTexCoord(1,0); myVertex(x+sx,y-sy,z+sz); - glTexCoord(1,1); myVertex(x+sx,y-sy,z-sz); - glTexCoord(0,1); myVertex(x-sx,y-sy,z-sz); - - setcol(32,192,192); - glTexCoord(0,0); myVertex(x-sx,y+sy,z-sz); - glTexCoord(1,0); myVertex(x+sx,y+sy,z-sz); - glTexCoord(1,1); myVertex(x+sx,y+sy,z+sz); - glTexCoord(0,1); myVertex(x-sx,y+sy,z+sz); - glEnd(); -} -myVertex(x,y,z) { - // Initialize a struct value - vec3 v = {x,y,z}; - - // Apply global model matrix transformation - transformPoint(v, modelMatrix); - - // Submit the vertex to draw list - glVertex(v.x, v.y, v.z); -} -rotateY(m[9], r) { - c = cos(r); s=sin(r); - m[0] = c; m[1] = 0; m[2] = s; - m[3] = 0; m[4] = 1; m[5] = 0; - m[6] = -s; m[7] = 0; m[8] = c; -} - -rotateZ(m[9], r) { - c = cos(r); s=sin(r); - m[0] = c; m[1] = -s; m[2] = 0; - m[3] = s; m[4] = c; m[5] = 0; - m[6] = 0; m[7] = 0; m[8] = 1; -} -transformPoint(vec3 v, m[9]) { - x2 = v.x * m[0] + v.y * m[1] + v.z * m[2]; - y2 = v.x * m[3] + v.y * m[4] + v.z * m[5]; - z2 = v.x * m[6] + v.y * m[7] + v.z * m[8]; - // Mutate the struct v with new values - v.x=x2; v.y=y2; v.z=z2; -} -mult(c[9],a[9],b[9]) { // C = AB - // multiply a row in A with a column in B - for(i=0; i<3; i++) - for(j=0; j<3; j++) { - sum = 0.0; - for(k=0; k<3; k++) { - sum += A[k*3+i] * B[k*3+j]; - } - C[i*3+j] = sum; - } -} diff --git a/Task/Draw-a-rotating-cube/GW-BASIC/draw-a-rotating-cube.basic b/Task/Draw-a-rotating-cube/GW-BASIC/draw-a-rotating-cube.basic deleted file mode 100644 index 5ce0043d6e..0000000000 --- a/Task/Draw-a-rotating-cube/GW-BASIC/draw-a-rotating-cube.basic +++ /dev/null @@ -1,20 +0,0 @@ -100 SCREEN 2 -110 WHILE 1 -120 CLS -130 X = COS(T)*20 -140 Y = SIN(T)*18 -150 R = SIN(T+T) -160 LINE (( X+40),( Y+40-R))-((-Y+40),( X+40-R)) -170 LINE ((-Y+40),( X+40-R))-((-X+40),(-Y+40-R)) -180 LINE ((-X+40),(-Y+40-R))-(( Y+40),(-X+40-R)) -190 LINE (( Y+40),(-X+40-R))-(( X+40),( Y+40-R)) -200 LINE (( X+40),( Y+20+R))-((-Y+40),( X+20+R)) -210 LINE ((-Y+40),( X+20+R))-((-X+40),(-Y+20+R)) -220 LINE ((-X+40),(-Y+20+R))-(( Y+40),(-X+20+R)) -230 LINE (( Y+40),(-X+20+R))-(( X+40),( Y+20+R)) -240 LINE (( X+40),( Y+40-R))-(( X+40),( Y+20+R)) -250 LINE ((-Y+40),( X+40-R))-((-Y+40),( X+20+R)) -260 LINE ((-X+40),(-Y+40-R))-((-X+40),(-Y+20+R)) -270 LINE (( Y+40),(-X+40-R))-(( Y+40),(-X+20+R)) -280 T = T+.15 -290 WEND diff --git a/Task/Draw-a-rotating-cube/Julia/draw-a-rotating-cube.jl b/Task/Draw-a-rotating-cube/Julia/draw-a-rotating-cube.julia similarity index 100% rename from Task/Draw-a-rotating-cube/Julia/draw-a-rotating-cube.jl rename to Task/Draw-a-rotating-cube/Julia/draw-a-rotating-cube.julia diff --git a/Task/Draw-a-rotating-cube/Kotlin/draw-a-rotating-cube.kts b/Task/Draw-a-rotating-cube/Kotlin/draw-a-rotating-cube.kotlin similarity index 100% rename from Task/Draw-a-rotating-cube/Kotlin/draw-a-rotating-cube.kts rename to Task/Draw-a-rotating-cube/Kotlin/draw-a-rotating-cube.kotlin diff --git a/Task/Draw-a-rotating-cube/MSX-Basic/draw-a-rotating-cube.basic b/Task/Draw-a-rotating-cube/MSX-Basic/draw-a-rotating-cube.basic deleted file mode 100644 index 257ecea43a..0000000000 --- a/Task/Draw-a-rotating-cube/MSX-Basic/draw-a-rotating-cube.basic +++ /dev/null @@ -1,21 +0,0 @@ -100 SCREEN 2 -110 COLOR 15 -120 CLS -130 X = COS(T)*20 -140 Y = SIN(T)*18 -150 R = SIN(T+T) -160 LINE (( X+40),( Y+40-R))-((-Y+40),( X+40-R)) -170 LINE ((-Y+40),( X+40-R))-((-X+40),(-Y+40-R)) -180 LINE ((-X+40),(-Y+40-R))-(( Y+40),(-X+40-R)) -190 LINE (( Y+40),(-X+40-R))-(( X+40),( Y+40-R)) -200 LINE (( X+40),( Y+20+R))-((-Y+40),( X+20+R)) -210 LINE ((-Y+40),( X+20+R))-((-X+40),(-Y+20+R)) -220 LINE ((-X+40),(-Y+20+R))-(( Y+40),(-X+20+R)) -230 LINE (( Y+40),(-X+20+R))-(( X+40),( Y+20+R)) -240 LINE (( X+40),( Y+40-R))-(( X+40),( Y+20+R)) -250 LINE ((-Y+40),( X+40-R))-((-Y+40),( X+20+R)) -260 LINE ((-X+40),(-Y+40-R))-((-X+40),(-Y+20+R)) -270 LINE (( Y+40),(-X+40-R))-(( Y+40),(-X+20+R)) -280 FOR I = 1 TO 40 : NEXT I -290 T = T+0.15 -300 GOTO 120 diff --git a/Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas b/Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas deleted file mode 100644 index 37d716f15c..0000000000 --- a/Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas +++ /dev/null @@ -1,6 +0,0 @@ -uses Graph3D; - -begin - var Cube := Box(Origin,Sz3D(3,3,3),Colors.Green); - Cube.AnimRotate(OrtZ,180).Forever.Begin -end. diff --git a/Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube-2.py b/Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube-2.py deleted file mode 100644 index f7a42efcbe..0000000000 --- a/Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube-2.py +++ /dev/null @@ -1,14 +0,0 @@ -import bpy -import math -bpy.context.preferences.edit.keyframe_new_interpolation_type="LINEAR" -bpy.ops.object.select_all(action="SELECT") -bpy.ops.object.delete() -bpy.ops.mesh.primitive_cube_add() -bpy.context.active_object.name="spinningcube" -spinningcube=bpy.data.objects["spinningcube"] -spinningcube.rotation_euler=(math.radians(45),math.radians(35.264),math.radians(0)) -spinningcube.keyframe_insert(data_path="rotation_euler",frame=1) -spinningcube.rotation_euler=(math.radians(45),math.radians(35.264),math.radians(2700)) -spinningcube.keyframe_insert(data_path="rotation_euler",frame=250) -bpy.context.scene.frame_set(1) -bpy.ops.screen.animation_play() diff --git a/Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube-1.py b/Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube.py similarity index 100% rename from Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube-1.py rename to Task/Draw-a-rotating-cube/Python/draw-a-rotating-cube.py diff --git a/Task/Draw-a-rotating-cube/V-(Vlang)/draw-a-rotating-cube.v b/Task/Draw-a-rotating-cube/V-(Vlang)/draw-a-rotating-cube.v deleted file mode 100644 index 597f4f3661..0000000000 --- a/Task/Draw-a-rotating-cube/V-(Vlang)/draw-a-rotating-cube.v +++ /dev/null @@ -1,122 +0,0 @@ -import gg -import gx -import math - -struct RotatingCube { - mut: - width int - height int - fore gx.Color - nodes [][]f64 - edges [][]int - scale_f f64 -} - -fn new_rotating_cube(width int, height int) RotatingCube { - mut nodes := [ - [f64(-1.0), -1, -1], - [f64(-1.0), -1, 1], - [f64(-1.0), 1, -1], - [f64(-1.0), 1, 1], - [f64(1.0), -1, -1], - [f64(1.0), -1, 1], - [f64(1.0), 1, -1], - [f64(1.0), 1, 1], - ] - mut edges := [ - [0, 1], - [1, 3], - [3, 2], - [2, 0], - [4, 5], - [5, 7], - [7, 6], - [6, 4], - [0, 4], - [1, 5], - [2, 6], - [3, 7], - ] - mut cube := RotatingCube{ - width: width - height: height - fore: gx.blue - nodes: nodes - edges: edges - scale_f: 100.0 - } - cube.scale(cube.scale_f) - cube.rotate_cube(math.pi / 4, math.sqrt(math.atan(2.0))) - return cube -} - -fn (mut rc RotatingCube) scale(s f64) { - for i in 0 .. rc.nodes.len { - for j in 0 .. 3 { - rc.nodes[i][j] = rc.nodes[i][j] * s - } - } -} - -fn (mut rc RotatingCube) rotate_cube(angle_x f64, angle_y f64) { - sin_x := math.sin(angle_x) - cos_x := math.cos(angle_x) - sin_y := math.sin(angle_y) - cos_y := math.cos(angle_y) - for i in 0 .. rc.nodes.len { - x := rc.nodes[i][0] - y := rc.nodes[i][1] - z := rc.nodes[i][2] - rc.nodes[i][0] = x * cos_x - z * sin_x - rc.nodes[i][2] = z * cos_x + x * sin_x - z_new := rc.nodes[i][2] - rc.nodes[i][1] = y * cos_y - z_new * sin_y - rc.nodes[i][2] = z_new * cos_y + y * sin_y - } -} - -fn (mut rc RotatingCube) draw_cube(mut ctx gg.Context) { - ctx.begin() - cx := f32(rc.width / 2) - cy := f32(rc.height / 2) - for edge in rc.edges { - n1 := rc.nodes[edge[0]] - n2 := rc.nodes[edge[1]] - x1 := f32(n1[0]) + cx - y1 := f32(n1[1]) + cy - x2 := f32(n2[0]) + cx - y2 := f32(n2[1]) + cy - ctx.draw_line(x1, y1, x2, y2, rc.fore) - } - for node in rc.nodes { - x := f32(node[0]) + cx - 4 - y := f32(node[1]) + cy - 4 - ctx.draw_rect_filled(x, y, 8, 8, rc.fore) - } - ctx.end() -} - -fn (mut rc RotatingCube) update() { - rc.rotate_cube(math.pi / 180, 0) -} - -fn frame(mut cube RotatingCube) { - mut ctx := gg.Context{} - cube.update() - cube.draw_cube(mut ctx) -} - -fn main() { - width := 640 - height := 640 - mut cube := new_rotating_cube(width, height) - mut context := gg.new_context( - width: width - height: height - window_title: "Rotating cube" - bg_color: gx.white - frame_fn: frame - user_data: &cube - ) - context.run() -} diff --git a/Task/Draw-a-rotating-cube/Zig/draw-a-rotating-cube.zig b/Task/Draw-a-rotating-cube/Zig/draw-a-rotating-cube.zig index 71e488cbe7..cde1f8bf6c 100644 --- a/Task/Draw-a-rotating-cube/Zig/draw-a-rotating-cube.zig +++ b/Task/Draw-a-rotating-cube/Zig/draw-a-rotating-cube.zig @@ -15,8 +15,8 @@ pub fn main() !void { const size = c.Vector3{ .x = cube_side, .y = cube_side, .z = cube_side }; const position = c.Vector3{ .x = 0, .y = 0, .z = 0 }; const x_rot = 45; - const y_center: f32 = std.math.sqrt(3.0) * cube_side / 2.0; - const z_rot = std.math.radiansToDegrees(f32, std.math.atan(@as(f32, std.math.sqrt1_2))); + const y_center = std.math.sqrt(@as(f32, 3)) * cube_side / 2; + const z_rot = std.math.atan(@as(f32, std.math.sqrt1_2)) * 180 / std.math.pi; c.SetConfigFlags(c.FLAG_WINDOW_RESIZABLE | c.FLAG_VSYNC_HINT); c.InitWindow(screen_width, screen_height, "Draw a Rotating Cube"); diff --git a/Task/Draw-a-sphere/Ada/draw-a-sphere-1.adb b/Task/Draw-a-sphere/Ada/draw-a-sphere-1.ada similarity index 100% rename from Task/Draw-a-sphere/Ada/draw-a-sphere-1.adb rename to Task/Draw-a-sphere/Ada/draw-a-sphere-1.ada diff --git a/Task/Draw-a-sphere/Ada/draw-a-sphere-2.adb b/Task/Draw-a-sphere/Ada/draw-a-sphere-2.ada similarity index 100% rename from Task/Draw-a-sphere/Ada/draw-a-sphere-2.adb rename to Task/Draw-a-sphere/Ada/draw-a-sphere-2.ada diff --git a/Task/Draw-a-sphere/Delphi/draw-a-sphere.pas b/Task/Draw-a-sphere/Delphi/draw-a-sphere.delphi similarity index 100% rename from Task/Draw-a-sphere/Delphi/draw-a-sphere.pas rename to Task/Draw-a-sphere/Delphi/draw-a-sphere.delphi diff --git a/Task/Draw-a-sphere/EasyLang/draw-a-sphere.easy b/Task/Draw-a-sphere/EasyLang/draw-a-sphere.easy deleted file mode 100644 index 972b539b5d..0000000000 --- a/Task/Draw-a-sphere/EasyLang/draw-a-sphere.easy +++ /dev/null @@ -1,25 +0,0 @@ -func vdot a[] b[] . - for i to len a[] : r += a[i] * b[i] - return r -. -func[] norm v[] . - d = vdot v[] v[] - invl = 1 / sqrt d - for i to 3 : r[] &= v[i] * invl - return r[] -. -proc sphere r k amb dir[] . - for x = -r to r : for y = -r to r - z = r * r - x * x - y * y - if z >= 0 - s = vdot dir[] norm [ x y sqrt z ] - if s < 0 : s = 0 - lum = (pow s k + amb) / (1 + amb) - gcolor3 lum lum lum - grect 50 + x / 5, 50 + y / 5, 0.3 0.3 - . - . -. -gbackground 000 -gclear -sphere 200 1.5 0.2 norm [ -30 30 50 ] diff --git a/Task/Draw-a-sphere/Emacs-Lisp/draw-a-sphere.el b/Task/Draw-a-sphere/Emacs-Lisp/draw-a-sphere.l similarity index 100% rename from Task/Draw-a-sphere/Emacs-Lisp/draw-a-sphere.el rename to Task/Draw-a-sphere/Emacs-Lisp/draw-a-sphere.l diff --git a/Task/Draw-a-sphere/Evaldraw/draw-a-sphere.evaldraw b/Task/Draw-a-sphere/Evaldraw/draw-a-sphere.evaldraw deleted file mode 100644 index 82bee3d360..0000000000 --- a/Task/Draw-a-sphere/Evaldraw/draw-a-sphere.evaldraw +++ /dev/null @@ -1,6 +0,0 @@ -() -cls(0); -clz(1e32); -setcam(0,0,-5,0,0); -setcol(128,64,64); -drawsph(0,0,0,1); diff --git a/Task/Draw-a-sphere/Julia/draw-a-sphere-1.jl b/Task/Draw-a-sphere/Julia/draw-a-sphere-1.julia similarity index 100% rename from Task/Draw-a-sphere/Julia/draw-a-sphere-1.jl rename to Task/Draw-a-sphere/Julia/draw-a-sphere-1.julia diff --git a/Task/Draw-a-sphere/Julia/draw-a-sphere-2.jl b/Task/Draw-a-sphere/Julia/draw-a-sphere-2.julia similarity index 100% rename from Task/Draw-a-sphere/Julia/draw-a-sphere-2.jl rename to Task/Draw-a-sphere/Julia/draw-a-sphere-2.julia diff --git a/Task/Draw-a-sphere/Kotlin/draw-a-sphere.kts b/Task/Draw-a-sphere/Kotlin/draw-a-sphere.kotlin similarity index 100% rename from Task/Draw-a-sphere/Kotlin/draw-a-sphere.kts rename to Task/Draw-a-sphere/Kotlin/draw-a-sphere.kotlin diff --git a/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic b/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic deleted file mode 100644 index c343edc95d..0000000000 --- a/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic +++ /dev/null @@ -1,32 +0,0 @@ -10 MODE 2:ORIGIN 320,200:INK 0,0:INK 1,26 -20 DIM v(2),vec(2) -30 v(0)=30:v(1)=30:v(2)=-50 -40 lung=SQR(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)) -50 v(0)=v(0)/lung -60 v(1)=v(1)/lung -70 v(2)=v(2)/lung -80 r=180:k=1.5:ambient=0.03 -90 FOR i=INT(-r) TO INT(r) -100 x=i -110 FOR j=INT(-2*r) TO INT(2*r) -120 y=j/2 -130 IF (x*x+y*y<=r*r) THEN GOSUB 1000 -140 NEXT j -160 NEXT i -170 END -1000 vec(0)=x -1010 vec(1)=y -1020 vec(2)=SQR(r*r-x*x-y*y) -1030 GOSUB 2000 -1040 GOSUB 3000 -1050 b=(d^k+ambient)/(1+ambient) -1060 IF b>rnd THEN PLOT x,-y -1100 RETURN -2000 lung=SQR(vec(0)*vec(0)+vec(1)*vec(1)+vec(2)*vec(2)) -2010 vec(0)=vec(0)/lung -2020 vec(1)=vec(1)/lung -2030 vec(2)=vec(2)/lung -2040 RETURN -3000 d=v(0)*vec(0)+v(1)*vec(1)+v(2)*vec(2) -3010 IF d<0 THEN d=-d ELSE d=0 -3020 RETURN diff --git a/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-1.basic b/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere.basic similarity index 100% rename from Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-1.basic rename to Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere.basic diff --git a/Task/Draw-a-sphere/Odin/draw-a-sphere.odin b/Task/Draw-a-sphere/Odin/draw-a-sphere.odin deleted file mode 100644 index 394ba7fcef..0000000000 --- a/Task/Draw-a-sphere/Odin/draw-a-sphere.odin +++ /dev/null @@ -1,32 +0,0 @@ -package sphere - -import rl "vendor:raylib" - -main :: proc() { - rl.InitWindow(640, 480, "Rosetta Code - draw a sphere") - - camera: rl.Camera3D - camera.fovy = 45 - camera.position = {0, 2.5, 5} - camera.up = {0, 1, 0} - - for !rl.WindowShouldClose() { - rl.UpdateCamera(&camera, .ORBITAL) - - rl.BeginDrawing() - - rl.ClearBackground(rl.RAYWHITE) - - rl.BeginMode3D(camera) - - rl.DrawGrid(10, .5) - - rl.DrawSphere({}, .5, rl.LIME) - - rl.EndMode3D() - - rl.EndDrawing() - } - - rl.CloseWindow() -} diff --git a/Task/Draw-a-sphere/Pluto/draw-a-sphere.pluto b/Task/Draw-a-sphere/Pluto/draw-a-sphere.pluto deleted file mode 100644 index 2c693f9de4..0000000000 --- a/Task/Draw-a-sphere/Pluto/draw-a-sphere.pluto +++ /dev/null @@ -1,8 +0,0 @@ -require "bitmap" - -local bmp = bitmap.of(400, 400, color.white, "Draw a sphere") -for n = 1, 100 do - local clr = bitmap.rgbColor(2 * n, 2 * n, 2 * n) - bmp:circle(math.round(150-2 * n / 3) + 50, math.round(150 - n / 2) + 50, 150 - n, clr) -end -bmp:view() diff --git a/Task/Draw-a-sphere/R/draw-a-sphere.r b/Task/Draw-a-sphere/R/draw-a-sphere.r deleted file mode 100644 index c6f8e5fbd1..0000000000 --- a/Task/Draw-a-sphere/R/draw-a-sphere.r +++ /dev/null @@ -1,12 +0,0 @@ -library(lattice) -theta <- seq(0, pi, length.out=100) -phi <- seq(0, 2*pi, length.out=100) -x <- outer(sin(theta), cos(phi)) -y <- outer(sin(theta), sin(phi)) -z <- sqrt(1-x^2-y^2) -xx <- kronecker(matrix(1, 2, 2), x) -yy <- kronecker(matrix(1, 2, 2), y) -zz <- kronecker(matrix(c(1, -1, -1, 1), 2, 2), z) -png(filename="Sphere-R.png", width=1000, height=1000) -wireframe(zz ~ xx*yy) -dev.off() diff --git a/Task/Draw-a-sphere/Rust/draw-a-sphere.rs b/Task/Draw-a-sphere/Rust/draw-a-sphere.rust similarity index 100% rename from Task/Draw-a-sphere/Rust/draw-a-sphere.rs rename to Task/Draw-a-sphere/Rust/draw-a-sphere.rust diff --git a/Task/Draw-a-sphere/VBScript/draw-a-sphere.vbs b/Task/Draw-a-sphere/VBScript/draw-a-sphere.vb similarity index 100% rename from Task/Draw-a-sphere/VBScript/draw-a-sphere.vbs rename to Task/Draw-a-sphere/VBScript/draw-a-sphere.vb diff --git a/Task/Duffinian-numbers/APL/duffinian-numbers.apl b/Task/Duffinian-numbers/APL/duffinian-numbers.apl deleted file mode 100644 index 1a8eab109a..0000000000 --- a/Task/Duffinian-numbers/APL/duffinian-numbers.apl +++ /dev/null @@ -1,8 +0,0 @@ -duffinian_numbers←{ - sigma ← +/(⍸0=⍳|⊢) - duff ← sigma((1=∨)∧⊣>1+⊢)⊢ - ⎕←'First 50 Duffinian numbers:' - ⎕←5 10⍴(⊢(/⍨)duff¨)⍳220 - ⎕←'First 15 Duffinian triplets:' - ⎕←(0 1 2∘.+⍨⊢(/⍨)0 1 2(⊃∧.⌽)(⊂duff¨))⍳8500 -} diff --git a/Task/Duffinian-numbers/Applesoft-BASIC/duffinian-numbers.basic b/Task/Duffinian-numbers/Applesoft-BASIC/duffinian-numbers.basic deleted file mode 100644 index 1dbdd40b2e..0000000000 --- a/Task/Duffinian-numbers/Applesoft-BASIC/duffinian-numbers.basic +++ /dev/null @@ -1,56 +0,0 @@ - 100 DEF FN MOD(NUM) = NUM - INT (NUM / DIV) * DIV: REM NUM MOD DIV - 110 M = 50:N = 4 - 120 PRINT "FIRST "M" DUFFINIAN NUMBERS:" - 130 FOR C = 0 TO M STEP 0 - 140 GOSUB 600"DUFF - 150 IF DUFF THEN PRINT RIGHT$ (" " + STR$ (N),4);:C = C + 1 - 160 N = N + 1 - 170 NEXT C - 180 M = 15:S = 4:M$ = CHR$ (13) - 190 PRINT M$M$"FIRST "M" DUFFINIAN TRIPLETS:" - 200 FOR C = 0 TO M STEP 0 - 210 FOR D = 2 TO 0 STEP - 1:N = S + D: GOSUB 600: IF DUFF THEN NEXT D - 220 IF D < 0 THEN C = C + 1: PRINT RIGHT$ (" " + STR$ (S) + "-",5) LEFT$ ( STR$ (S + 2) + " ",5);:D = 0 - 230 S = S + D + 1 - 240 NEXT C - 250 END - - REM ISPRIME V RETURNS ISPRIME - 260 ISPRIME = FALSE: IF V < 2 THEN RETURN - 270 DIV = 2:ISPRIME = FN MOD(V): IF NOT ISPRIME THEN ISPRIME = V = 2: RETURN - 280 LIMIT = SQR (V): IF LIMIT > = 3 THEN FOR DIV = 3 TO LIMIT STEP 2:ISPRIME = FN MOD(V): IF ISPRIME THEN NEXT DIV - 290 RETURN - - REM GREATEST COMMON DIVISOR (GCD) A B RETURNS GCD - 300 A = ABS ( INT (A)) - 310 B = ABS ( INT (B)) - 320 GCD = A * NOT NOT B - 330 FOR B = B + A * NOT B TO 0 STEP 0 - 340 A = GCD - 350 GCD = B - 360 B = A - INT (A / GCD) * GCD - 370 NEXT B - 380 RETURN - - REM SUMDIV NUM RETURNS SUM - 400 DIV = 2 - 410 SUM = 0 - 420 QUOT = NUM / DIV - 430 IF DIV > QUOT THEN SUM = 1: RETURN - 440 FOR LOOP = 0 TO 1 STEP 0 - 450 IF FN MOD(NUM) = 0 THEN SUM = SUM + DIV: IF DIV < > QUOT THEN SUM = SUM + QUOT - 460 DIV = DIV + 1 - 470 QUOT = NUM / DIV - 480 LOOP = DIV > QUOT - 500 NEXT LOOP - 510 SUM = SUM + 1 - 520 RETURN - - REM DUFF N RETURNS DUFF - 600 DUFF = FALSE - 610 V = N: GOSUB 260"ISPRIME - 620 IF ISPRIME THEN RETURN - 630 NUM = N: GOSUB 400"SUMDIV - 640 A = SUM:B = N: GOSUB 300"GCD - 650 DUFF = GCD = 1 - 660 RETURN diff --git a/Task/Duffinian-numbers/Arturo/duffinian-numbers.arturo b/Task/Duffinian-numbers/Arturo/duffinian-numbers.arturo index 67e076411f..5aca5135af 100644 --- a/Task/Duffinian-numbers/Arturo/duffinian-numbers.arturo +++ b/Task/Duffinian-numbers/Arturo/duffinian-numbers.arturo @@ -5,7 +5,7 @@ duffinian?: function [n]-> [1] = intersection factors sum fn fn ] -first50: [] +first50: new [] i: 0 while [50 > size first50][ if duffinian? i -> 'first50 ++ i @@ -17,7 +17,7 @@ loop split.every: 10 first50 'row [ print map to [:string] row 'item -> pad item 3 ] -first15: [] +first15: new [] i: 0 while [15 > size first15][ if every? i..i+2 => duffinian? [ @@ -30,5 +30,5 @@ while [15 > size first15][ print "" print "The first 15 Duffinian triplets:" loop split.every: 5 first15 'row [ - print map row 'item -> pad.right express item 17 + print map row 'item -> pad.right as.code item 17 ] diff --git a/Task/Duffinian-numbers/BCPL/duffinian-numbers.bcpl b/Task/Duffinian-numbers/BCPL/duffinian-numbers.bcpl deleted file mode 100644 index ce5c01c911..0000000000 --- a/Task/Duffinian-numbers/BCPL/duffinian-numbers.bcpl +++ /dev/null @@ -1,45 +0,0 @@ -get "libhdr" - -let calcsigmas(sig, n) be -$( sig!0 := 0 - for i = 0 to n do sig!i := 0 - for i = 1 to n/2 do - $( let j = i - while 0 < j <= n do - $( sig!j := sig!j + i - j := j + i - $) - $) -$) - -let gcd(m, n) = n=0 -> m, gcd(n, m rem n) - -let duff(sig, n) = sig!n > n+1 & gcd(n, sig!n) = 1 -let triple(sig, n) = duff(sig, n) & duff(sig, n+1) & duff(sig, n+2) - -let first(sig, f, max, cb) be -$( let n = 0 - for i = 1 to max - $( n := n+1 repeatuntil f(sig, n) - cb(i, n) - $) -$) - -let start() be -$( let showsingle(i, n) be - $( writef("%I4", n) - if i rem 10=0 then wrch('*N') - $) - - let showtriple(i, n) be writef("%I2: %I6 %I6 %I6*N", i, n, n+1, n+2) - - let sig = getvec(20000) - calcsigmas(sig, 20000) - - writes("First 50 Duffinian numbers:*N") - first(sig, duff, 50, showsingle) - - writes("*NFirst 15 Duffinian triples:*N") - first(sig, triple, 15, showtriple) - freevec(sig) -$) diff --git a/Task/Duffinian-numbers/Delphi/duffinian-numbers.pas b/Task/Duffinian-numbers/Delphi/duffinian-numbers.delphi similarity index 100% rename from Task/Duffinian-numbers/Delphi/duffinian-numbers.pas rename to Task/Duffinian-numbers/Delphi/duffinian-numbers.delphi diff --git a/Task/Duffinian-numbers/Draco/duffinian-numbers.draco b/Task/Duffinian-numbers/Draco/duffinian-numbers.draco deleted file mode 100644 index a2732a600e..0000000000 --- a/Task/Duffinian-numbers/Draco/duffinian-numbers.draco +++ /dev/null @@ -1,58 +0,0 @@ -word MAXSIGMA = 10000; -[MAXSIGMA+1]word sigma; - -proc calcsigma() void: - word i, j; - for i from 0 upto MAXSIGMA do sigma[i] := 0 od; - for i from 1 upto MAXSIGMA do - for j from i by i upto MAXSIGMA do - sigma[j] := sigma[j] + i - od - od -corp - -proc gcd(word a, b) word: - word c; - while b > 0 do - c := a % b; - a := b; - b := c; - od; - a -corp - -proc duff(word n) bool: - sigma[n] > n+1 and gcd(n, sigma[n]) = 1 -corp - -proc triplet(word n) bool: - duff(n) and duff(n+1) and duff(n+2) -corp - -proc first(word n; proc(word n)bool pred; proc(word i,n)void cb) void: - word i, cur; - cur := 0; - for i from 1 upto n do - while cur := cur + 1; not pred(cur) do od; - cb(i, cur) - od -corp - -proc tablenum(word i, n) void: - write(n:5); - if i%10 = 0 then writeln() fi -corp - -proc tripletline(word i, n) void: - writeln(i:2, ' ', n:6, n+1:6, n+2:6) -corp - -proc main() void: - calcsigma(); - writeln("First 50 Duffinian numbers:"); - first(50, duff, tablenum); - writeln(); - - writeln("First 15 Duffinian triplets:"); - first(15, triplet, tripletline) -corp diff --git a/Task/Duffinian-numbers/EasyLang/duffinian-numbers.easy b/Task/Duffinian-numbers/EasyLang/duffinian-numbers.easy deleted file mode 100644 index b50d820e3d..0000000000 --- a/Task/Duffinian-numbers/EasyLang/duffinian-numbers.easy +++ /dev/null @@ -1,59 +0,0 @@ -fastfunc isprim num . - i = 2 - while i <= sqrt num - if num mod i = 0 : return 0 - i += 1 - . - return 1 -. -func gcd a b . - while b <> 0 - h = b - b = a mod b - a = h - . - return a -. -func sumdiv num . - d = 2 - repeat - quot = num div d - until d > quot - if num mod d = 0 - sum += d - if d <> quot : sum += quot - . - d += 1 - . - return sum + 1 -. -func isduff n . - if isprim n = 0 and gcd sumdiv n n = 1 - return 1 - . - return 0 -. -proc duffs . - print "First 50 Duffinian numbers:" - n = 4 - repeat - if isduff n = 1 - write n & " " - cnt += 1 - . - until cnt = 50 - n += 1 - . - cnt = 0 - n = 4 - print "\n\nFirst 15 Duffinian triplets:" - repeat - if isduff n = 1 and isduff (n + 1) = 1 and isduff (n + 2) = 1 - print n & " - " & n + 2 - cnt += 1 - . - until cnt = 15 - n += 1 - . -. -duffs diff --git a/Task/Duffinian-numbers/Forth/duffinian-numbers.fth b/Task/Duffinian-numbers/Forth/duffinian-numbers.fth deleted file mode 100644 index 264737eeb8..0000000000 --- a/Task/Duffinian-numbers/Forth/duffinian-numbers.fth +++ /dev/null @@ -1,61 +0,0 @@ -: gcd ( u1 u2 -- u3 ) - dup 0= if drop exit then - tuck mod recurse ; - -: duffinian? ( u -- ? ) - dup 2 = if drop false exit then - 1 >r dup 2 - begin - over 2 mod 0= - while - dup r> + >r 2* swap 2/ swap - repeat - drop 3 - begin - 2dup dup * >= - while - dup 1 >r - begin - 2 pick 2 pick mod 0= - while - dup r> + >r over * >r tuck / swap r> - repeat - 2r> * >r drop 2 + - repeat - drop - 2dup = if 2drop rdrop false exit then - dup 1 > if 1+ r> * else drop r> then - gcd 1 = ; - -: main - ." First 50 Duffinian numbers:" cr - 0 1 - begin - over 50 < - while - dup duffinian? if - dup 3 .r - swap 1+ swap - over 10 mod 0= if cr else space then - then - 1+ - repeat - 2drop - cr ." First 30 Duffinian triplets:" cr - 0 >r 0 1 - begin - r@ 30 < - while - dup duffinian? if swap 1+ swap else nip 0 swap then - over 3 = if - r> 1+ >r - dup 2 - 5 .r space - dup 1- 5 .r space - dup 5 .r cr - then - 1+ - repeat - rdrop 2drop ; - -main -bye diff --git a/Task/Duffinian-numbers/Free-Pascal-Lazarus/duffinian-numbers.pas b/Task/Duffinian-numbers/Free-Pascal-Lazarus/duffinian-numbers.pas deleted file mode 100644 index 17e3029649..0000000000 --- a/Task/Duffinian-numbers/Free-Pascal-Lazarus/duffinian-numbers.pas +++ /dev/null @@ -1,79 +0,0 @@ -program DuffinianNumbers; - -CONST - MaxSigma = 10000; - -VAR - seen, cur: CARDINAL; - sigma: ARRAY [1..MaxSigma] OF CARDINAL; - -PROCEDURE CalculateSigmaTable; - VAR i, j: CARDINAL; -BEGIN - FOR i := 1 TO MaxSigma DO - BEGIN - sigma[i] := 0 - END; - FOR i := 1 TO MaxSigma DO - BEGIN - j := i;//2*i -> sigma(n)-n - WHILE j <= MaxSigma DO - Begin - INC(sigma[j], i); - INC(j, i); - END - END -END;// CalculateSigmaTable; - -FUNCTION GCD(a, b: CARDINAL): CARDINAL; -VAR c: CARDINAL; -BEGIN - WHILE b <>0 DO - Begin - c := a MOD b; - a := b; - b := c - END; - EXIT(A) -END;// GCD; - -function IsDuffinian(n: CARDINAL): BOOLEAN; -BEGIN - EXIT( (sigma[n] > n+1) AND (GCD(n, sigma[n]) = 1)) -END;// IsDuffinian; - -FUNCTION IsDuffinianTriple(n: CARDINAL): BOOLEAN; -BEGIN - EXIT(IsDuffinian(n) AND IsDuffinian(n+1) AND IsDuffinian(n+2)); -END;// IsDuffinianTriple; - -BEGIN - CalculateSigmaTable; - Writeln('First 50 Duffinian numbers:'); - WriteLn; - cur := 0; - FOR seen := 1 TO 50 DO - Begin - REPEAT - INC(cur) - UNTIL IsDuffinian(cur); - Write(cur:4); - IF seen MOD 10 = 0 THEN - WriteLn; - END; - - WriteLn; - WriteLn('First 15 Duffinian triples:'); - WriteLn; - cur := 0; - FOR seen := 1 TO 15 DO - BEGIN - REPEAT - INC(cur) - UNTIL IsDuffinianTriple(cur); - Write(cur:6); - Write(cur+1:6); - Write(cur+2:6); - WriteLn; - END -END.// DuffinianNumbers. diff --git a/Task/Duffinian-numbers/FutureBasic/duffinian-numbers.basic b/Task/Duffinian-numbers/FutureBasic/duffinian-numbers.basic deleted file mode 100644 index 9a313e155a..0000000000 --- a/Task/Duffinian-numbers/FutureBasic/duffinian-numbers.basic +++ /dev/null @@ -1,70 +0,0 @@ -local fn IsPrime( n as NSUInteger ) as BOOL - BOOL isPrime = YES - NSUInteger i - - if n < 2 then exit fn = NO - if n = 2 then exit fn = YES - if n mod 2 == 0 then exit fn = NO - for i = 3 to int(n^.5) step 2 - if n mod i == 0 then exit fn = NO - next -end fn = isPrime - -local fn GCD( a as long, b as long ) as long - long r - - if ( a == 0 ) then r = b else r = fn GCD( b mod a, a ) -end fn = r - -local fn SumDiv( num as NSUInteger ) as NSUInteger - NSUInteger div = 2, sum = 0, quot, result - - while (1) - quot = num / div - if ( div > quot ) then result = 0 : exit while - if ( num mod div == 0 ) - sum += div - if ( div != quot ) then sum += quot - end if - div++ - wend - result = sum + 1 -end fn = result - -local fn IsDuffinian( n as NSUInteger) as BOOL - BOOL result = NO - - if ( fn IsPrime(n) == NO && fn GCD( fn SumDiv(n), n ) == 1 ) then exit fn = YES -end fn = result - -local fn FindDuffinians - long c = 0, n = 4 - - print "First 50 Duffinian numbers:" - do - if ( fn IsDuffinian(n) ) - printf @"%4d \b", n - c++ - if ( c mod 10 == 0 ) then print - end if - n++ - until ( c >= 50 ) - - c = 0 : n = 4 - printf @"\n\nFirst 56 Duffinian triplets:" - do - if ( fn IsDuffinian(n) and fn IsDuffinian(n + 1) and fn IsDuffinian(n + 2) ) - printf @" [%6ld %6ld %6ld] \b", n, n+1, n+2 - c++ - if ( c mod 4 == 0 ) then print - end if - n++ - until ( c >= 56 ) -end fn - -CFTimeInterval t -t = fn CACurrentMediaTime -fn FindDuffinians -printf @"\nCompute time: %.3f ms",(fn CACurrentMediaTime-t)*1000 - -HandleEvents diff --git a/Task/Duffinian-numbers/Haskell/duffinian-numbers.hs b/Task/Duffinian-numbers/Haskell/duffinian-numbers.hs deleted file mode 100644 index 9bc2ce04f3..0000000000 --- a/Task/Duffinian-numbers/Haskell/duffinian-numbers.hs +++ /dev/null @@ -1,50 +0,0 @@ -import Data.List ( tail ) -import qualified Data.Set as S -import Data.List.Split ( divvy ) - -divisors :: Int -> [Int] -divisors n = [d | d <- [1..n] , mod n d == 0] - -primeFactors :: Int -> [Int] -primeFactors n = snd $ until ( (== 1 ) . fst ) step (n , [] ) - where - step :: (Int , [Int]) -> (Int , [Int]) - step ( aNumber , factors ) = ( div aNumber smallest , factors ++ - [smallest] ) - where - smallest :: Int - smallest = head $ tail $ divisors aNumber - -isRelativelyPrime :: Int -> Int -> Bool -isRelativelyPrime a b = S.null $ S.intersection ( S.fromList $ - primeFactors a ) ( S.fromList $ primeFactors b ) - -isDuffinian :: Int -> Bool -isDuffinian n = and [(length $ primeFactors n ) > 1 , isRelativelyPrime - ( sum $ divisors n ) n] - -solution :: [Int] -solution = take 50 $ filter isDuffinian [1..] - -findTriplets :: [[Int]] -findTriplets = take 15 $ filter condition $ divvy 3 1 $ filter - isDuffinian [1..] - where - condition :: [Int] -> Bool - condition [a , b , c] = b == a + 1 && c == b + 1 - -outputTriplet :: [Int] -> String -outputTriplet [a , b , c] = "(" ++ replicate ( 6 - length sa ) ' ' ++ - sa ++ replicate (6 - length sb) ' ' ++ sb ++ replicate (6 - length sc ) - ' ' ++ sc ++ " )" - where - sa = show a - sb = show b - sc = show c - -main :: IO ( ) -main = do - putStrLn "The first 50 Duffinian numbers are :" - print solution - putStrLn "The first 15 Duffinian triplets are:" - mapM_ (\t -> putStrLn $ outputTriplet t ) findTriplets diff --git a/Task/Duffinian-numbers/Icon/duffinian-numbers.icon b/Task/Duffinian-numbers/Icon/duffinian-numbers.icon deleted file mode 100644 index 5ca26be44f..0000000000 --- a/Task/Duffinian-numbers/Icon/duffinian-numbers.icon +++ /dev/null @@ -1,28 +0,0 @@ -procedure main(A) - write("The first 50 Duffian numbers:") - every writes(" ",isduffinian(seq())\50) - write("\n") - limit := 15 - write("The first ",limit," Duffian triples:") - every (isduffinian(n := seq()),isduffinian(n+1),isduffinian(n+2))\limit do - write("\t(",n,",",n+1,",",n+2,")") -end - -procedure isduffinian(n) - x := \cfact(n)**\afact(sumfactors(n)) - return (*\x = 1, !x = 1, n) -end - -procedure cfact(n) # all factors of n if n is a composite number - return (*(f := afact(n)) > 2, f) -end - -procedure afact(n) # all factors of n - every (f := set(), i := 1 to n, n%i = 0,insert(f,i)) - return f -end - -procedure sumfactors(n) - every (s := 0, i := 1 to n, n%i = 0) do s +:= i - return s -end diff --git a/Task/Duffinian-numbers/Java/duffinian-numbers.java b/Task/Duffinian-numbers/Java/duffinian-numbers.java deleted file mode 100644 index 47f094d86a..0000000000 --- a/Task/Duffinian-numbers/Java/duffinian-numbers.java +++ /dev/null @@ -1,61 +0,0 @@ -import java.util.Arrays; - -public final class DuffianNumbers { - - public static void main(String[] aArgs) { - int[] duffians = createDuffians(11_000); - - System.out.println("The first 50 Duffinian numbers:"); - int count = 0; - int n = 1; - while ( count < 50 ) { - if ( duffians[n] > 0 ) { - System.out.print(String.format("%4d%s", n, ( ++count % 25 == 0 ? "\n" : "" ))); - } - n += 1; - } - System.out.println(); - - System.out.println("The first 16 Duffinian triplets:"); - count = 0; - n = 3; - while( count < 16 ) { - if ( duffians[n - 2] > 0 && duffians[n - 1] > 0 && duffians[n] > 0 ) { - System.out.print(String.format("%22s%s", - "(" + ( n - 2 ) + ", " + ( n - 1 ) + ", " + n + ")", ( ++count % 4 == 0 ? "\n" : "" ))); - } - n += 1; - } - System.out.println(); - } - - private static int[] createDuffians(int aLimit) { - // Create a list where list[i] is the divisor sum of i. - int[] result = new int[aLimit]; - Arrays.fill(result, 1); - for ( int i = 2; i < aLimit; i++ ) { - for ( int j = i; j < aLimit; j += i ) { - result[j] += i; - } - } - - // Set the divisor sum of non-Duffinian numbers to 0. - result[1] = 0; // 1 is not a Duffinian number. - for ( int n = 2; n < aLimit; n++ ) { - int resultN = result[n]; - if ( resultN == n + 1 || gcd(n, resultN) != 1 ) { - // n is prime, or it is not relatively prime to its divisor sum. - result[n] = 0; - } - } - return result; - } - - private static int gcd(int aOne, int aTwo) { - if ( aTwo == 0 ) { - return aOne; - } - return gcd(aTwo, aOne % aTwo); - } - -} diff --git a/Task/Duffinian-numbers/JavaScript/duffinian-numbers.js b/Task/Duffinian-numbers/JavaScript/duffinian-numbers.js deleted file mode 100644 index 1c0331bc11..0000000000 --- a/Task/Duffinian-numbers/JavaScript/duffinian-numbers.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -// ---------- helpers ---------- -const gcd = (a, b) => { - while (b !== 0) [a, b] = [b, a % b]; - return a; -}; - -// ---------- core logic ---------- -function createDuffians(limit) { - // divisor-sum table: divSum[i] = σ(i) - const divSum = new Array(limit).fill(1); - for (let i = 2; i < limit; ++i) { - for (let j = i; j < limit; j += i) divSum[j] += i; - } - - // mark non-Duffinians with 0 - divSum[1] = 0; // 1 is not Duffinian - for (let n = 2; n < limit; ++n) { - const s = divSum[n]; - if (s === n + 1 || gcd(n, s) !== 1) divSum[n] = 0; - } - return divSum; -} - -// ---------- main ---------- -const duffians = createDuffians(11_000); - -console.log('The first 50 Duffinian numbers:'); -let count = 0, n = 1; -while (count < 50) { - if (duffians[n] > 0) { - process.stdout.write(String(n).padStart(4) + (++count % 25 ? '' : '\n')); - } - ++n; -} -console.log(); - -console.log('The first 16 Duffinian triplets:'); -count = 0; -n = 3; -while (count < 16) { - if (duffians[n - 2] && duffians[n - 1] && duffians[n]) { - const triplet = `(${n - 2}, ${n - 1}, ${n})`; - process.stdout.write(triplet.padStart(22) + (++count % 4 ? '' : '\n')); - } - ++n; -} -console.log(); diff --git a/Task/Duffinian-numbers/Julia/duffinian-numbers.jl b/Task/Duffinian-numbers/Julia/duffinian-numbers.julia similarity index 100% rename from Task/Duffinian-numbers/Julia/duffinian-numbers.jl rename to Task/Duffinian-numbers/Julia/duffinian-numbers.julia diff --git a/Task/Duffinian-numbers/Lua/duffinian-numbers.lua b/Task/Duffinian-numbers/Lua/duffinian-numbers.lua deleted file mode 100644 index a8422b4049..0000000000 --- a/Task/Duffinian-numbers/Lua/duffinian-numbers.lua +++ /dev/null @@ -1,58 +0,0 @@ -function gcd(a, b) - while b ~= 0 do - a, b = b, a % b - end - return a -end - -function duffinian(n) - if n == 2 then return false end - local total = 1 - local power = 2 - local m = n - while (n & 1) == 0 do - total = total + power - power = power << 1 - n = n >> 1 - end - local p = 3 - while p * p <= n do - local sum = 1 - local power = p - while n % p == 0 do - sum = sum + power - power = power * p - n = n / p - end - total = total * sum - p = p + 2 - end - if m == n then return false end - if n > 1 then total = total * (n + 1) end - return gcd(total, m) == 1 -end - -print("First 50 Duffinian numbers:") -count = 0 -n = 1 -while count < 50 do - if duffinian(n) then - count = count + 1 - if count % 10 == 0 then space = 10 else space = 32 end - io.write(string.format('%3d%c', n, space)) - end - n = n + 1 -end - -print("\nFirst 30 Duffinian triplets:") -n = 1 -m = 0 -count = 0 -while count < 30 do - if duffinian(n) then m = m + 1 else m = 0 end - if m == 3 then - count = count + 1 - print(string.format('%d, %d, %d', n - 2, n - 1, n)) - end - n = n + 1 -end diff --git a/Task/Duffinian-numbers/MAD/duffinian-numbers.mad b/Task/Duffinian-numbers/MAD/duffinian-numbers.mad deleted file mode 100644 index d665371ab0..0000000000 --- a/Task/Duffinian-numbers/MAD/duffinian-numbers.mad +++ /dev/null @@ -1,51 +0,0 @@ - NORMAL MODE IS INTEGER - DIMENSION SIGMA(10000),OUTROW(10) - - INTERNAL FUNCTION(AA,BB) - ENTRY TO GCD. - A = AA - B = BB -STEP WHENEVER A.E.B, FUNCTION RETURN A - WHENEVER A.G.B, A = A-B - WHENEVER A.L.B, B = B-A - TRANSFER TO STEP - END OF FUNCTION - - INTERNAL FUNCTION(N) - ENTRY TO DUFF. - SIG = SIGMA(N) - FUNCTION RETURN SIG.G.N+1 .AND. GCD.(N,SIG).E.1 - END OF FUNCTION - - INTERNAL FUNCTION(N) - ENTRY TO TRIP. - FUNCTION RETURN DUFF.(N) .AND. - 0 DUFF.(N+1) .AND. DUFF.(N+2) - END OF FUNCTION - - THROUGH SZERO, FOR I=1, 1, I.G.10000 -SZERO SIGMA(I) = 0 - THROUGH SCALC, FOR I=1, 1, I.G.10000 - THROUGH SCALC, FOR J=I, I, J.G.10000 -SCALC SIGMA(J) = SIGMA(J) + I - - PRINT COMMENT $ FIRST 50 DUFFINIAN NUMBERS$ - CAND = 0 - THROUGH DUFROW, FOR R=0, 1, R.GE.5 - THROUGH DUFCOL, FOR C=0, 1, C.GE.10 -SCHDUF THROUGH SCHDUF, FOR CAND=CAND+1, 1, DUFF.(CAND) -DUFCOL OUTROW(C) = CAND -DUFROW PRINT FORMAT ROWFMT,OUTROW(0),OUTROW(1),OUTROW(2), - 0 OUTROW(3),OUTROW(4),OUTROW(5),OUTROW(6), - 1 OUTROW(7),OUTROW(8),OUTROW(9) - - PRINT COMMENT $ $ - PRINT COMMENT $ FIRST 15 DUFFINIAN TRIPLETS$ - CAND = 0 - THROUGH DUFTRI, FOR S=0, 1, S.GE.15 -SCHTRP THROUGH SCHTRP, FOR CAND=CAND+1, 1, TRIP.(CAND) -DUFTRI PRINT FORMAT TRIFMT,CAND,CAND+1,CAND+2 - - VECTOR VALUES ROWFMT = $10(I5)*$ - VECTOR VALUES TRIFMT = $3(I7)*$ - END OF PROGRAM diff --git a/Task/Duffinian-numbers/Maxima/duffinian-numbers.maxima b/Task/Duffinian-numbers/Maxima/duffinian-numbers.maxima deleted file mode 100644 index d4fb007771..0000000000 --- a/Task/Duffinian-numbers/Maxima/duffinian-numbers.maxima +++ /dev/null @@ -1,21 +0,0 @@ -/* Predicate functions that checks wether an integer is a Duffinian number or not */ -duffinianp(n):=if n#1 and not primep(n) and gcd(n,divsum(n))=1 then true$ - -/* Function that returns a list of the first len Duffinian numbers */ -duffinian_count(len):=block( - [i:1,count:0,result:[]], - while count n+1) AND (GCD(n, sigma[n]) = 1) -END IsDuffinian; - -PROCEDURE IsDuffinianTriple(n: CARDINAL): BOOLEAN; -BEGIN - RETURN IsDuffinian(n) AND IsDuffinian(n+1) AND IsDuffinian(n+2) -END IsDuffinianTriple; - -BEGIN - CalculateSigmaTable; - WriteString("First 50 Duffinian numbers:"); - WriteLn; - cur := 0; - FOR seen := 1 TO 50 DO - REPEAT INC(cur) UNTIL IsDuffinian(cur); - WriteCard(cur, 4); - IF seen MOD 10 = 0 THEN WriteLn END - END; - - WriteLn; - WriteString("First 15 Duffinian triples:"); - WriteLn; - cur := 0; - FOR seen := 1 TO 15 DO - REPEAT INC(cur) UNTIL IsDuffinianTriple(cur); - WriteCard(cur, 6); - WriteCard(cur+1, 6); - WriteCard(cur+2, 6); - WriteLn - END -END DuffinianNumbers. diff --git a/Task/Duffinian-numbers/PARI-GP/duffinian-numbers.parigp b/Task/Duffinian-numbers/PARI-GP/duffinian-numbers.parigp deleted file mode 100644 index dfdeaaa0d6..0000000000 --- a/Task/Duffinian-numbers/PARI-GP/duffinian-numbers.parigp +++ /dev/null @@ -1,26 +0,0 @@ -isDuffinian(n) = (!isprime(n)) && (gcd(n, sigma(n)) == 1); - -testDuffinians()= -{ - print("First 50 Duffinian numbers:"); - count = 0; n = 2; - while(count < 50, - if (isDuffinian(n), - print1(n, " "); - count++; - ); - n++; - ); - - print("\n\nFifteen Duffinian triplets:"); - count = 0; n = 2; - while (count < 15, - if (isDuffinian(n) && isDuffinian(n + 1) && isDuffinian(n + 2), - print(n, " ", n + 1, " ", n + 2); - count++; - ); - n++; - ); -} - -testDuffinians(); diff --git a/Task/Duffinian-numbers/PL-I/duffinian-numbers.pli b/Task/Duffinian-numbers/PL-I/duffinian-numbers.pli deleted file mode 100644 index d23d50c2bd..0000000000 --- a/Task/Duffinian-numbers/PL-I/duffinian-numbers.pli +++ /dev/null @@ -1,58 +0,0 @@ -duffinianNumbers: procedure options(main); - %replace MAXSIGMA by 10000; - declare sigma (1:MAXSIGMA) fixed; - - calculateSigmaTable: procedure; - declare (i, j) fixed; - do i=1 to MAXSIGMA; - sigma(i) = 0; - end; - do i=1 to MAXSIGMA; - do j=i to MAXSIGMA by i; - sigma(j) = sigma(j) + i; - end; - end; - end calculateSigmaTable; - - gcd: procedure(aa,bb) returns(fixed); - declare (a, aa, b, bb, c) fixed; - a = aa; - b = bb; - do while(b > 0); - c = mod(a,b); - a = b; - b = c; - end; - return(a); - end gcd; - - duffinian: procedure(n) returns(bit); - declare n fixed; - return(sigma(n) > n+1 & gcd(n, sigma(n)) = 1); - end duffinian; - - triplet: procedure(n) returns(bit); - declare n fixed; - return(duffinian(n) & duffinian(n+1) & duffinian(n+2)); - end triplet; - - declare (i, n) fixed; - - call calculateSigmaTable; - put skip list('First 50 Duffinian numbers:'); - put skip; - n=0; - do i=1 to 50; - do n=n+1 repeat(n+1) while(^duffinian(n)); end; - put edit(n) (F(5)); - if mod(i,10) = 0 then put skip; - end; - - put skip; - put skip list('First 15 Duffinian triplets:'); - n=0; - do i=1 to 15; - do n=n+1 repeat(n+1) while(^triplet(n)); end; - put skip edit(n, n+1, n+2) (F(7),F(7),F(7)); - end; -end duffinianNumbers; diff --git a/Task/Duffinian-numbers/PL-M/duffinian-numbers.plm b/Task/Duffinian-numbers/PL-M/duffinian-numbers.plm deleted file mode 100644 index 0e3eeefe87..0000000000 --- a/Task/Duffinian-numbers/PL-M/duffinian-numbers.plm +++ /dev/null @@ -1,80 +0,0 @@ -100H: -BDOS: PROCEDURE (F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS; -EXIT: PROCEDURE; GO TO 0; END EXIT; -PR$CHAR: PROCEDURE (C); DECLARE C BYTE; CALL BDOS(2,C); END PR$CHAR; -PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT; - -PR$NUM: PROCEDURE (N, WIDTH); - DECLARE N ADDRESS, WIDTH BYTE; - DECLARE S (6) BYTE INITIAL ('.....$'); - DECLARE P ADDRESS, DG BASED P BYTE; - P = .S(5); -DIGIT: - P = P - 1; - DG = '0' + N MOD 10; - IF WIDTH > 0 THEN WIDTH = WIDTH - 1; - IF (N := N / 10) > 0 THEN GO TO DIGIT; - CALL PRINT(P); - DO WHILE WIDTH > 0; - CALL PR$CHAR(' '); - WIDTH = WIDTH - 1; - END; -END PR$NUM; - -DECLARE MAX$SIGMA LITERALLY '10$001'; -DECLARE SIGMA (MAX$SIGMA) ADDRESS; -CALC$SIGMA: PROCEDURE; - DECLARE (I, J) ADDRESS; - DO I = 1 TO MAX$SIGMA-1; - SIGMA(I) = 0; - END; - DO I = 1 TO MAX$SIGMA-1; - DO J = I TO MAX$SIGMA-1 BY I; - SIGMA(J) = SIGMA(J) + I; - END; - END; -END CALC$SIGMA; - -GCD: PROCEDURE (X, Y) ADDRESS; - DECLARE (X, Y, Z) ADDRESS; - DO WHILE Y > 0; - Z = X MOD Y; - X = Y; - Y = Z; - END; - RETURN X; -END GCD; - -DUFF: PROCEDURE (N) BYTE; - DECLARE N ADDRESS; - RETURN SIGMA(N) > N+1 AND GCD(N, SIGMA(N)) = 1; -END DUFF; - -DUFF$TRIPLE: PROCEDURE (N) BYTE; - DECLARE N ADDRESS; - RETURN DUFF(N) AND DUFF(N+1) AND DUFF(N+2); -END DUFF$TRIPLE; - -DECLARE N ADDRESS, I BYTE; - -CALL CALC$SIGMA; -CALL PRINT(.('FIRST 50 DUFFINIAN NUMBERS:',13,10,'$')); -N = 0; -DO I = 1 TO 50; - DO WHILE NOT DUFF(N := N+1); END; - CALL PR$NUM(N, 4); - IF I MOD 10 = 0 THEN CALL PRINT(.(13,10,'$')); -END; - -CALL PRINT(.(13,10,'FIRST 15 DUFFINIAN TRIPLES:',13,10,'$')); -N = 0; -DO I = 1 TO 15; - DO WHILE NOT DUFF$TRIPLE(N := N+1); END; - CALL PR$NUM(N, 6); - CALL PR$NUM(N+1, 6); - CALL PR$NUM(N+2, 6); - CALL PRINT(.(13,10,'$')); -END; - -CALL EXIT; -EOF diff --git a/Task/Duffinian-numbers/PascalABC.NET/duffinian-numbers.pas b/Task/Duffinian-numbers/PascalABC.NET/duffinian-numbers.pas deleted file mode 100644 index e0d2dd58cb..0000000000 --- a/Task/Duffinian-numbers/PascalABC.NET/duffinian-numbers.pas +++ /dev/null @@ -1,36 +0,0 @@ -uses school; - -function is_duffinian(x: integer) := - (gcd(x, divisors(x).Sum) = 1) and - (divisors(x).ToArray.Length > 2); - -begin - var count := 0; - var i := 0; - writeln('First 50 Duffinian numbers:'); - while count < 50 do - begin - if is_duffinian(i) then - begin - write(i:4); - count += 1; - if count mod 10 = 0 then writeln; - end; - i += 1 - end; - - count := 0; - i := 0; - writeln; - writeln('First 15 Duffinian triplets:'); - while count < 15 do - begin - if is_duffinian(i) and is_duffinian(i + 1) and is_duffinian(i + 2) then - begin - writeln(i:6, i + 1:6, i + 2:6); - count += 1; - i += 3; - end; - i += 1; - end; -end. diff --git a/Task/Duffinian-numbers/Python/duffinian-numbers.py b/Task/Duffinian-numbers/Python/duffinian-numbers.py deleted file mode 100644 index e27a0586d0..0000000000 --- a/Task/Duffinian-numbers/Python/duffinian-numbers.py +++ /dev/null @@ -1,30 +0,0 @@ -# duffinian.py by xing216 - -def factors(n): - factors = [] - for i in range(1, n + 1): - if n % i == 0: - factors.append(i) - return factors -def gcd(a, b): - while b != 0: - a, b = b, a % b - return a -is_relively_prime = lambda a, b: gcd(a, b) == 1 -sigma_sum = lambda x: sum(factors(x)) -is_duffinian = lambda x: is_relively_prime(x, sigma_sum(x)) and len(factors(x)) > 2 -count = 0 -i = 0 -while count < 50: - if is_duffinian(i): - print(i, end=' ') - count += 1 - i+=1 -count2 = 0 -j = 0 -while count2 < 20: - if is_duffinian(j) and is_duffinian(j+1) and is_duffinian(j+2): - print(f"({j},{j+1},{j+2})", end=' ') - count2 += 1 - j+=3 - j+=1 diff --git a/Task/Duffinian-numbers/Refal/duffinian-numbers.refal b/Task/Duffinian-numbers/Refal/duffinian-numbers.refal deleted file mode 100644 index 576fa3f49d..0000000000 --- a/Task/Duffinian-numbers/Refal/duffinian-numbers.refal +++ /dev/null @@ -1,76 +0,0 @@ -$ENTRY Go { - = - >> - - - >; -}; - -ShowTriple { - s.N = >; -}; - -Each { - s.F = ; - s.F t.I e.X = ; -}; - -Group { - s.N = ; - s.N e.X, : (e.1) e.2 = (e.1) ; -}; - -Gen { - s.N s.F = ; - 0 s.F s.I = ; - s.N s.F s.I, : { - True = s.I s.F >; - False = >; - }; -}; - -DuffinianTriple { - s.N, - > - >: True True True = True; - s.N = False; -}; - -Duffinian { - s.N, : s.S, - : s.P, - s.S : { - s.P s.1 = False; - s.Q 1 = True; - s.1 s.2 = False; - }; -}; - -Gcd { - s.A 0 = s.A; - s.A s.B = >; -}; - -SigmaSum { - s.N = 2 >; - s.N s.Sum s.D s.Max, : '+' = s.Sum; - s.N s.Sum s.D s.Max, : s.N = ; - s.N s.Sum s.D s.Max, : 0 = - >> - s.Max>; - s.N s.Sum s.D s.Max = s.Max>; -}; - -Sqrt { - 0 = 1; - 1 = 1; - s.N = >; - s.N s.X0, -
> 2>: s.X1, - : { - '+' = ; - s.C = s.X0; - }; -}; diff --git a/Task/Duffinian-numbers/Ring/duffinian-numbers.ring b/Task/Duffinian-numbers/Ring/duffinian-numbers.ring deleted file mode 100644 index c7de980c3e..0000000000 --- a/Task/Duffinian-numbers/Ring/duffinian-numbers.ring +++ /dev/null @@ -1,97 +0,0 @@ -Load "stdlibcore.ring" - -nr = 0 -num = 0 -sig1 = 0 -cmp = 0 - -see "FIRST 50 DUFFINIAN NUMBERS:" + nl - -while nr < 50 - num = num + 1 - sigma = 0 - cmp = comp(num) - if cmp = 1 - sgm = sigm1(num) - relat1prim() - ok -end - -nr = 0 -fok = 0 -numc = 1 -sig1 = 0 -sig2 = 0 -sig3 = 0 - -see nl + "FIRST 15 DUFFINIAN TRIPLETS:" + nl - -while nr < 15 - - num1 = numc - num2 = num1 + 1 - num3 = num2 + 1 - cmp1 = comp(num1) - cmp2 = comp(num2) - cmp3 = comp(num3) - if (cmp1 = 1) and (cmp2 = 1) and (cmp3 = 1) - sigm1(num1) - sigm2(num2) - sigm3(num3) - ok - numc = numc + 1 -end - -func comp(nm) - fok = 0 - flag = 0 - for n = 1 to nm - if nm%n = 0 - flag = flag + 1 - ok - if flag > 2 - fok = 1 - exit - ok - next - return fok - -func sigm1(num1) - sig1 = 0 - for n = 1 to num1 - if num1%n = 0 - sig1 = sig1 + n - ok - next - -func sigm2(num2) - sig2 = 0 - for n = 1 to num2 - if num2%n = 0 - sig2 = sig2 + n - ok - next - -func sigm3(num3) - sig3 = 0 - for n = 1 to num3 - if num3%n = 0 - sig3 = sig3 + n - ok - next - - relat2prim() - -func relat1prim() - if (gcd(num,sig1) = 1) - nr = nr + 1 - see "" + num + " " - ok - return nr - -func relat2prim() - if ((gcd(num1,sig1) = 1) and (gcd(num2,sig2) = 1) and (gcd(num3,sig3) = 1)) - nr = nr + 1 - see "" + num1 + "-" + num3 + " " - ok - return nr diff --git a/Task/Duffinian-numbers/Ruby/duffinian-numbers.rb b/Task/Duffinian-numbers/Ruby/duffinian-numbers.rb deleted file mode 100644 index e20e2fdf47..0000000000 --- a/Task/Duffinian-numbers/Ruby/duffinian-numbers.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "prime" - -class Integer - - def proper_divisors(prim_div = prime_division) - return [] if self == 1 - primes = prim_div.flat_map{|prime, freq| [prime] * freq} - (1...primes.size).each_with_object([1]) do |n, res| - primes.combination(n).map{|combi| res << combi.inject(:*)} - end.flatten.uniq - end - - def duffinian? - pd = prime_division - return false if pd.sum(&:last) < 2 - gcd(proper_divisors(pd).sum + self) == 1 - end - -end - -n = 50 -puts "The first #{n} Duffinian numbers:" -(1..).lazy.select(&:duffinian?).first(n).each_slice(10) do |slice| - puts "%4d" * slice.size % slice -end - -puts "\nThe first #{n} Duffinian triplets:" -(1..).each_cons(3).lazy.select{|slice| slice.all?(&:duffinian?)}.first(n).each do |group| - puts "%8d" * group.size % group -end diff --git a/Task/Duffinian-numbers/Rust/duffinian-numbers.rs b/Task/Duffinian-numbers/Rust/duffinian-numbers.rs deleted file mode 100644 index e6b44a1472..0000000000 --- a/Task/Duffinian-numbers/Rust/duffinian-numbers.rs +++ /dev/null @@ -1,97 +0,0 @@ -fn gcd(mut a: i32, mut b: i32) -> i32 { - while b != 0 { - let temp = b; - b = a % b; - a = temp; - } - a -} - -fn duffinian(n: i32) -> bool { - if n == 2 { - return false; - } - - let mut total = 1; - let mut power = 2; - let m = n; - let mut n = n; - - // Handle powers of 2 - while (n & 1) == 0 { - total += power; - power <<= 1; - n >>= 1; - } - - // Handle odd prime factors - let mut p = 3; - while p * p <= n { - let mut sum = 1; - power = p; - while n % p == 0 { - sum += power; - power *= p; - n /= p; - } - total *= sum; - p += 2; - } - - // Check if n is composite - if m == n { - return false; - } - - // Handle remaining prime factor - if n > 1 { - total *= n + 1; - } - - gcd(total, m) == 1 -} - -fn main() { - println!("First 50 Duffinian numbers:"); - let mut count = 0; - let mut n = 1; - - while count < 50 { - if duffinian(n) { - print!("{:3}", n); - count += 1; - if count % 10 == 0 { - println!(); - } else { - print!(" "); - } - } - n += 1; - } - - println!("\nFirst 50 Duffinian triplets:"); - let mut n = 1; - let mut m = 0; - let mut count = 0; - - while count < 50 { - if duffinian(n) { - m += 1; - } else { - m = 0; - } - - if m == 3 { - let triplet = format!("({}, {}, {})", n - 2, n - 1, n); - print!("{:<24}", triplet); - count += 1; - if count % 3 == 0 { - println!(); - } else { - print!(" "); - } - } - n += 1; - } - println!(); -} diff --git a/Task/Duffinian-numbers/SETL/duffinian-numbers.setl b/Task/Duffinian-numbers/SETL/duffinian-numbers.setl deleted file mode 100644 index 792e5adddc..0000000000 --- a/Task/Duffinian-numbers/SETL/duffinian-numbers.setl +++ /dev/null @@ -1,48 +0,0 @@ -program duffinian_numbers; - init sigma := divisor_sum_table(20000); - - print("First 50 Duffinian numbers:"); - loop for n in first(50, routine is_duffinian) do - nprint(lpad(str n, 6)); - if (col +:= 1) mod 10 = 0 then print; end if; - end loop; - - print; - print("First 15 Duffinian triplets:"); - loop for n in first(15, routine is_duffinian_triplet) do - print(+/[lpad(str i, 6) : i in [n,n+1,n+2]]); - end loop; - - proc first(num, pred); - ls := []; - loop while #ls < num do - loop until call(pred, n) do - n +:= 1; - end loop; - ls with:= n; - end loop; - return ls; - end proc; - - proc is_duffinian_triplet(n); - return and/[is_duffinian(i) : i in [n,n+1,n+2]]; - end proc; - - proc is_duffinian(n); - return sigma(n) > n+1 and gcd(n, sigma(n)) = 1; - end proc; - - proc gcd(a,b); - return if b=0 then a else gcd(b, a mod b) end; - end proc; - - proc divisor_sum_table(sz); - ds := [0] * sz; - loop for i in [1..sz] do - loop for j in [i,i+i..sz] do - ds(j) +:= i; - end loop; - end loop; - return ds; - end proc; -end program; diff --git a/Task/Duffinian-numbers/Wren/duffinian-numbers.wren b/Task/Duffinian-numbers/Wren/duffinian-numbers.wren index 319dea5ef4..3ed0e06725 100644 --- a/Task/Duffinian-numbers/Wren/duffinian-numbers.wren +++ b/Task/Duffinian-numbers/Wren/duffinian-numbers.wren @@ -1,4 +1,5 @@ import "./math" for Int +import "./seq" for Lst import "./fmt" for Fmt var limit = 200000 // say diff --git a/Task/Dutch-national-flag-problem/ANSI-BASIC/dutch-national-flag-problem.basic b/Task/Dutch-national-flag-problem/ANSI-BASIC/dutch-national-flag-problem.basic deleted file mode 100644 index 1c951186b3..0000000000 --- a/Task/Dutch-national-flag-problem/ANSI-BASIC/dutch-national-flag-problem.basic +++ /dev/null @@ -1,59 +0,0 @@ -100 REM Dutch national flag problem -110 DECLARE EXTERNAL SUB PrintColorSeq -120 DECLARE EXTERNAL SUB SortByColor -130 REM 0: blue, 1: while, 2: red -140 DIM T(0 TO 19) -150 LET UP = UBOUND(T) -160 REM Set colors -170 RANDOMIZE -180 FOR I = 0 TO UP -190 LET T(I) = INT(RND * 3) -200 NEXT I -210 PRINT "Unsorted:" -220 CALL PrintColorSeq(T) -230 CALL SortByColor(T) -240 PRINT -250 PRINT "Sorted:" -260 CALL PrintColorSeq(T) -270 END -280 ! -290 EXTERNAL SUB PrintColorSeq (T()) -300 FOR I = 0 TO UBOUND(T) -310 SELECT CASE T(I) -320 CASE 0 -330 PRINT "B"; -340 CASE 1 -350 PRINT "W"; -360 CASE 2 -370 PRINT "R"; -380 END SELECT -390 NEXT I -400 PRINT -410 END SUB -420 ! -430 EXTERNAL SUB SortByColor (T()) -440 DECLARE EXTERNAL SUB Swap -450 LET B = 0 -460 LET W = 0 -470 LET R = UBOUND(T) -480 DO WHILE W <= R -490 SELECT CASE T(W) -500 CASE 1 -510 LET W = W + 1 -520 CASE 0 -530 CALL Swap(T(B), T(W)) -540 LET B = B + 1 -550 LET W = W + 1 -560 CASE 2 -570 call Swap(T(W), T(R)) -580 LET R = R - 1 -590 END SELECT -600 LOOP -610 END SUB -620 ! -630 EXTERNAL SUB Swap(A, B) -640 REM Some implementations have the SWAP statement, but it is not standard -650 LET Tmp = A -660 LET A = B -670 LET B = Tmp -680 END SUB diff --git a/Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.adb b/Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.ada similarity index 100% rename from Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.adb rename to Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.ada diff --git a/Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.au3 b/Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.autoit similarity index 100% rename from Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.au3 rename to Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.autoit diff --git a/Task/Dutch-national-flag-problem/BQN/dutch-national-flag-problem.bqn b/Task/Dutch-national-flag-problem/BQN/dutch-national-flag-problem.bqn deleted file mode 100644 index bfa3b6664a..0000000000 --- a/Task/Dutch-national-flag-problem/BQN/dutch-national-flag-problem.bqn +++ /dev/null @@ -1,5 +0,0 @@ -Make ← •rand.Range⟜≠⊏⊢ -IsSorted ← ∧´·≤˝˘2↕⊐ -Arrange ← /⁼∘⊐/⊣ - -20(⊢(⊢⋈IsSorted)⎉1⊢(⊢≍Arrange)Make)"RWB" diff --git a/Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem-2.cs b/Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem-2.cs deleted file mode 100644 index 4a1787555d..0000000000 --- a/Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem-2.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Dutch national flag problem -using System; - -class DutchFlagProblem -{ - enum Color {Blue, White, Red}; - - static void WriteColorSeq(Color[] t) - { - uint n = (uint)t.Length; - for (uint i = 0; i < n; i++) - { - switch (t[i]) - { - case Color.Blue: - Console.Write("B"); - break; - case Color.White: - Console.Write("W"); - break; - case Color.Red: - Console.Write("R"); - break; - }; - } - Console.WriteLine(); - } - - static void Swap(ref Color x, ref Color y) - { - Color temp = x; - x = y; - y = temp; - } - - static void SortByColor(Color[] t) - { - uint b = 0, w = 0, r = (uint)t.Length - 1; - while (w <= r) - { - switch (t[w]) - { - case Color.White: - w++; - break; - case Color.Blue: - Swap(ref t[b], ref t[w]); - b++; - w++; - break; - case Color.Red: - Swap(ref t[w], ref t[r]); - r--; - break; - } - } - } - - static void Main() - { - const uint N = 20; - Color[] t = new Color[N]; - - // Set colors - Random rand = new Random(); - for (uint i = 0; i < N; i++) - t[i] = (Color)(rand.Next(3)); - - Console.WriteLine("Unsorted:"); - WriteColorSeq(t); - SortByColor(t); - Console.WriteLine(); - Console.WriteLine("Sorted:"); - WriteColorSeq(t); - } -} diff --git a/Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem-1.cs b/Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem.cs similarity index 100% rename from Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem-1.cs rename to Task/Dutch-national-flag-problem/C-sharp/dutch-national-flag-problem.cs diff --git a/Task/Dutch-national-flag-problem/Crystal/dutch-national-flag-problem.cr b/Task/Dutch-national-flag-problem/Crystal/dutch-national-flag-problem.cr deleted file mode 100644 index 3bbbfee1f8..0000000000 --- a/Task/Dutch-national-flag-problem/Crystal/dutch-national-flag-problem.cr +++ /dev/null @@ -1,34 +0,0 @@ -enum FlagColor - Red - White - Blue - - def to_s - ["🔴", "⚪", "🔵"][value] - end -end - -module Indexable - def sorted? - (1...size).each do |i| - if self[i] < self[i-1] - return false - end - end - true - end -end - -balls = loop do - arr = Array.new(20) { FlagColor.values.sample } - break arr unless arr.sorted? -end - -puts balls.join -puts "Sorted: #{balls.sorted?}" -puts - -balls.sort! - -puts balls.join -puts "Sorted: #{balls.sorted?}" diff --git a/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d index bed0a7a25d..afeef682f4 100644 --- a/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d +++ b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d @@ -3,7 +3,7 @@ import std.stdio, std.random, std.algorithm, std.traits, std.array; enum DutchColors { red, white, blue } void dutchNationalFlagSort(DutchColors[] items) pure nothrow @nogc { - ulong lo, mid, hi = items.length - 1; + int lo, mid, hi = items.length - 1; while (mid <= hi) final switch (items[mid]) { diff --git a/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d index f6ba27017a..03a077347b 100644 --- a/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d +++ b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d @@ -62,7 +62,7 @@ void main() { // More tests: foreach (i; 0 .. 100_000) { - ulong n = uniform(0, balls.length); + int n = uniform(0, balls.length); foreach (ref ball; balls[0 .. n]) ball = [EnumMembers!DutchColors][uniform(0, $)]; balls[0 .. n].dutchNationalFlagSort(DutchColors.red, diff --git a/Task/Dutch-national-flag-problem/Delphi/dutch-national-flag-problem.pas b/Task/Dutch-national-flag-problem/Delphi/dutch-national-flag-problem.delphi similarity index 100% rename from Task/Dutch-national-flag-problem/Delphi/dutch-national-flag-problem.pas rename to Task/Dutch-national-flag-problem/Delphi/dutch-national-flag-problem.delphi diff --git a/Task/Dutch-national-flag-problem/EasyLang/dutch-national-flag-problem.easy b/Task/Dutch-national-flag-problem/EasyLang/dutch-national-flag-problem.easy deleted file mode 100644 index 10f3b5828a..0000000000 --- a/Task/Dutch-national-flag-problem/EasyLang/dutch-national-flag-problem.easy +++ /dev/null @@ -1,23 +0,0 @@ -col$[] = [ "red" "white" "blue" ] -for i to 8 - b[] &= random 1 3 -. -for b in b[] - write col$[b] & " " - if b < b0 : not_sorted = 1 - b0 = b -. -print "" -print "" -if not_sorted = 0 - print "already sorted" -else - for i = 1 to len b[] - 1 - for j = i + 1 to len b[] - if b[j] < b[i] : swap b[j] b[i] - . - . - for b in b[] - write col$[b] & " " - . -. diff --git a/Task/Dutch-national-flag-problem/Elixir/dutch-national-flag-problem.ex b/Task/Dutch-national-flag-problem/Elixir/dutch-national-flag-problem.elixir similarity index 100% rename from Task/Dutch-national-flag-problem/Elixir/dutch-national-flag-problem.ex rename to Task/Dutch-national-flag-problem/Elixir/dutch-national-flag-problem.elixir diff --git a/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl b/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl index 4015d07d23..53fef5d216 100644 --- a/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl +++ b/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl @@ -5,7 +5,7 @@ ball(red) -> 1; ball(white) -> 2; ball(blue) -> 3. -random_ball() -> lists:nth(rand:uniform(3), [red, white, blue]). +random_ball() -> lists:nth(random:uniform(3), [red, white, blue]). random_balls(N) -> random_balls(N,[]). random_balls(0,L) -> L; diff --git a/Task/Dutch-national-flag-problem/Free-Pascal-Lazarus/dutch-national-flag-problem.pas b/Task/Dutch-national-flag-problem/Free-Pascal-Lazarus/dutch-national-flag-problem.pas deleted file mode 100644 index 8745222d90..0000000000 --- a/Task/Dutch-national-flag-problem/Free-Pascal-Lazarus/dutch-national-flag-problem.pas +++ /dev/null @@ -1,74 +0,0 @@ -program DutchF; - - { Dutch national flag problem } - -type - TColor = (Blue, White, Red); - -const - N = 20; - -var - T: array [0 .. N - 1] of TColor; - I: cardinal; - - procedure Swap(var A, B: TColor); - var - Tmp: TColor; - begin - Tmp := A; - A := B; - B := Tmp; - end; - - procedure WriteColorSeq(T: array of TColor); - var - I: cardinal; - begin - for I := low(T) to high(T) do - case T[I] of - Blue: Write('B'); - White: Write('W'); - Red: Write('R'); - end; - WriteLn; - end; - - procedure SortByColor(var T: array of TColor); - var - B, W, R: cardinal; - begin - B := Low(T); - W := Low(T); - R := High(T); - while W <= R do - case T[W] of - White: - Inc(W); - Blue: - begin - Swap(T[B], T[W]); - Inc(B); - Inc(W); - end; - Red: - begin - Swap(T[W], T[R]); - Dec(R); - end; - end; - end; - -begin - { Set colors } - Randomize; - for I := 0 to N - 1 do - T[I] := TColor(Random(3)); - writeln('Unsorted:'); - WriteColorSeq(T); - SortByColor(T); - WriteLn; - writeln('Sorted:'); - WriteColorSeq(T); - {readln;} -end. diff --git a/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic b/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic deleted file mode 100644 index f7c621a282..0000000000 --- a/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic +++ /dev/null @@ -1,43 +0,0 @@ -void local fn DrawBalls( y as long, balls as CFArrayRef, sort as BOOL ) - long col, prevCol = 0, x = 10 - CFArrayRef cols = @[fn ColorWithSRGB(.78,.06,.18,1.0),fn ColorWhite,fn ColorWithSRGB(0,.24,.65,1.0)] - if ( sort ) then balls = fn ArraySortedArrayUsingSelector( balls, @"compare:" ) - - pen -1 - for long i = 0 to len(balls) - 1 - col = intval(balls[i]) - if ( sort == YES ) - if ( col != prevCol ) then y += 30 : x = 10 - else - if ( i > 0 && i % 15 == 0 ) then y += 30 : x = 10 - end if - oval fill (x,y,30,30), cols[col] - x += 30 - prevCol = col - next -end fn - -void local fn DutchNationalFlagProblem - window 1, @"Dutch national flag problem", (0,0,470,230) - WindowSetBackgroundColor( 1, fn ColorWithSRGB(1.0,.61,0,1.0) ) - - CFMutableArrayRef balls = fn MutableArrayNew - - text @"Menlo-Bold",, fn ColorWhite - - for long i = 0 to 29 - balls[i] = @(rnd(3)-1) - next - - print @"Unsorted:" - fn DrawBalls( 20, balls, NO ) - - print %(3,100)@"Sorted:" - fn DrawBalls( 120, balls, YES ) -end fn - -random - -fn DutchNationalFlagProblem - -HandleEvents diff --git a/Task/Dutch-national-flag-problem/GW-BASIC/dutch-national-flag-problem.basic b/Task/Dutch-national-flag-problem/GW-BASIC/dutch-national-flag-problem.basic deleted file mode 100644 index d0fd2bce6a..0000000000 --- a/Task/Dutch-national-flag-problem/GW-BASIC/dutch-national-flag-problem.basic +++ /dev/null @@ -1,42 +0,0 @@ -100 REM Dutch national flag problem -110 REM 0: blue, 1: while, 2: red -120 OPTION BASE 0 -130 N% = 20 -140 UP% = N% - 1 -150 DIM T%(UP%) -160 REM Set colors -170 RANDOMIZE -180 FOR I% = 0 TO UP% -190 T%(I%) = INT(RND * 3) -200 NEXT I% -210 PRINT "Unsorted:" -220 GOSUB 1000 -230 GOSUB 2000 -240 PRINT -250 PRINT "Sorted:" -260 GOSUB 1000 -270 END -1000 REM ** Print color sequence -1010 FOR I% = 0 TO UP% -1020 IF T%(I%) = 0 THEN PRINT "B"; ELSE IF T%(I%) = 1 THEN PRINT "W"; ELSE PRINT "R"; -1030 NEXT I% -1040 PRINT -1050 RETURN -2000 REM ** Sort by color -2010 B% = 0: W% = 0: R% = UP% -2020 WHILE W% <= R% -2030 IF T%(W%) <> 1 THEN 2070 -2040 REM white -2050 W% = W% + 1 -2060 GOTO 2160 -2070 IF T%(W%) <> 0 THEN 2130 -2080 REM blue -2090 SWAP T%(B%), T%(W%) -2100 B% = B% + 1 -2110 W% = W% + 1 -2120 GOTO 2160 -2130 REM red -2140 SWAP T%(W%), T%(R%) -2150 R% = R% - 1 -2160 WEND -2170 RETURN diff --git a/Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem-2.java b/Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem-2.java deleted file mode 100644 index 3c8b7d46da..0000000000 --- a/Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem-2.java +++ /dev/null @@ -1,79 +0,0 @@ -// Dutch national flag problem - -public class Main { - - enum Color {BLUE, WHITE, RED}; - - static final int N = 20; - - static void printColorSeq(Color[] t) { - int n = t.length; - for (int i = 0; i < n; i++) { - switch (t[i]) { - case BLUE: - System.out.print("B"); - break; - case WHITE: - System.out.print("W"); - break; - case RED: - System.out.print("R"); - break; - } - } - System.out.println(); - } - - static void swapElems(Color[] arr, int i, int j) { - Color temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } - - static void sortByColor(Color[] t) { - int b = 0, w = 0, r = t.length - 1; - while (w <= r) { - switch (t[w]) { - case WHITE: - w++; - break; - case BLUE: - swapElems(t, b, w); - b++; - w++; - break; - case RED: - swapElems(t, w, r); - r--; - break; - } - } - } - - public static void main(String[] args) { - Color[] t = new Color[N]; - - // Set colors - for (int i = 0; i < N; i++) { - int ci = (int)(Math.random() * 3); - switch (ci) { - case 0: - t[i] = Color.BLUE; - break; - case 1: - t[i] = Color.WHITE; - break; - case 2: - t[i] = Color.RED; - break; - } - } - - System.out.println("Unsorted:"); - printColorSeq(t); - sortByColor(t); - System.out.println(); - System.out.println("Sorted:"); - printColorSeq(t); - } -} diff --git a/Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem-1.java b/Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem.java similarity index 100% rename from Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem-1.java rename to Task/Dutch-national-flag-problem/Java/dutch-national-flag-problem.java diff --git a/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-1.jl b/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-1.jl deleted file mode 100644 index 5aa84ff6c8..0000000000 --- a/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-1.jl +++ /dev/null @@ -1,26 +0,0 @@ -using Printf - -const COLORS = ["red", "white", "blue"] - -function dutchsort!(a::AbstractVector, lo=COLORS[1], hi=COLORS[end]) - i = 1 - j = 1 - n = length(a) - while j <= n - if a[j] == lo - a[i], a[j] = a[j], a[i] - i += 1 - j += 1 - elseif a[j] == hi - a[j], a[n] = a[n], a[j] - n -= 1 - else - j += 1 - end - end - return a -end - -function dutchsort(a::AbstractVector, lo=COLORS[1], hi=COLORS[end]) - dutchsort!(copy(a), lo, hi) -end diff --git a/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-1.julia b/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-1.julia new file mode 100644 index 0000000000..6ac9875975 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-1.julia @@ -0,0 +1,24 @@ +const COLORS = ["red", "white", "blue"] + +function dutchsort!(a::Array{ASCIIString,1}, lo=COLORS[1], hi=COLORS[end]) + i = 1 + j = 1 + n = length(a) + while j <= n + if a[j] == lo + a[i], a[j] = a[j], a[i] + i += 1 + j += 1 + elseif a[j] == hi + a[j], a[n] = a[n], a[j] + n -= 1 + else + j += 1 + end + end + return a +end + +function dutchsort(a::Array{ASCIIString,1}, lo=COLORS[1], hi=COLORS[end]) + dutchsort!(copy(a), lo, hi) +end diff --git a/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-2.jl b/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-2.jl deleted file mode 100644 index fc37d7ec80..0000000000 --- a/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-2.jl +++ /dev/null @@ -1,30 +0,0 @@ -function formatdf(a::AbstractVector) - i = 0 - s = " " - for c in a - s *= @sprintf "%6s" c - i += 1 - i %= 8 - if i == 0 - s *= "\n " - end - end - return s -end - -const cnum = 20 -const d = [COLORS[rand(1:3)] for i in 1:cnum] -while d == dutchsort(d) - d .= [COLORS[rand(1:3)] for i in 1:cnum] -end - -println("The original list is:") -println(formatdf(d)) - -print("Sorting with dutchsort, after") -@time e = dutchsort(d) -println(formatdf(e)) - -print("Sorting conventionally, after") -@time e = sort(d, by = x -> findfirst(==(x), COLORS)) -println(formatdf(e)) diff --git a/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-2.julia b/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-2.julia new file mode 100644 index 0000000000..d597551c58 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Julia/dutch-national-flag-problem-2.julia @@ -0,0 +1,30 @@ +function formatdf(a::Array{ASCIIString,1}) + i = 0 + s = " " + for c in a + s *= @sprintf "%6s" c + i += 1 + i %= 8 + if i == 0 + s *= "\n " + end + end + return s +end + +cnum = 20 +d = [COLORS[rand(1:3)] for i in 1:cnum] +while d == dutchsort(d) + d = [COLORS[rand(1:3)] for i in 1:cnum] +end + +println("The original list is:") +println(formatdf(d)) + +print("Sorting with dutchsort, ") +@time e = dutchsort(d) +println(formatdf(e)) + +print("Sorting conventionally, ") +@time e = sort(d, by=x->findfirst(COLORS, x)) +println(formatdf(e)) diff --git a/Task/Dutch-national-flag-problem/Kotlin/dutch-national-flag-problem.kts b/Task/Dutch-national-flag-problem/Kotlin/dutch-national-flag-problem.kotlin similarity index 100% rename from Task/Dutch-national-flag-problem/Kotlin/dutch-national-flag-problem.kts rename to Task/Dutch-national-flag-problem/Kotlin/dutch-national-flag-problem.kotlin diff --git a/Task/Dutch-national-flag-problem/Loglan82/dutch-national-flag-problem.loglan82 b/Task/Dutch-national-flag-problem/Loglan82/dutch-national-flag-problem.loglan82 deleted file mode 100644 index dee8475b53..0000000000 --- a/Task/Dutch-national-flag-problem/Loglan82/dutch-national-flag-problem.loglan82 +++ /dev/null @@ -1,71 +0,0 @@ -(* Dutch national flag problem *) - -block -const - c_blue = 0, c_white = 1, c_red = 2, - n = 20; -var - i: integer, - t: arrayof integer; - - unit writeln_color_seq: procedure (t: arrayof integer); - var - i: integer; - begin - for i := lower(t) to upper(t) - do - case t(i) - when c_blue: - write("B"); - when c_white: - write("W"); - when c_red: - write("R"); - esac; - od; - writeln; - end writeln_color_seq; - - unit swap: procedure (inout a, b: integer); - var - tmp: integer; - begin - tmp := a; - a := b; - b := tmp - end swap; - - unit sort_by_color: procedure (t: arrayof integer); - var - b, w, r: integer; - begin - b, w := lower(t); - r := upper(t); - while (w <= r) - do - case t(w) - when c_white: - w := w + 1; - when c_blue: - call swap(t(b), t(w)); - b := b + 1; - w := w + 1; - when c_red: - call swap(t(w), t(r)); - r := r - 1; - esac - od; - end sort_by_color; - -begin - array t dim (0 : n - 1); - - (* Set colors *) - for i := 0 to n - 1 do t(i) := entier(random * 3) od; - writeln("Unsorted:"); - call writeln_color_seq(t); - call sort_by_color(t); - writeln; - writeln("Sorted:"); - call writeln_color_seq(t); -end; diff --git a/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-1.m2000 b/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-1.m2000 deleted file mode 100644 index 12e0137b20..0000000000 --- a/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-1.m2000 +++ /dev/null @@ -1,23 +0,0 @@ - SortElse=lambda white (a(), &swaps, &compares)->{ - long mid=white - long i, j, k=len(a())-1 - while j<=k - - if a(j)mid then - compares+=2 - swap a(j), a(k) - swaps++ - k-- - else - compares+=2 - j++ - end if - end while - =a() - } diff --git a/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-2.m2000 b/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-2.m2000 deleted file mode 100644 index acaf408117..0000000000 --- a/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-2.m2000 +++ /dev/null @@ -1,88 +0,0 @@ -function Dutch_national_flag_problem { - enum bands {red=1, white, blue} - s=red - check_in_order=lambda s, (a as array) ->{ - boolean true=@true, false - k=each(a) - m=s - Z=S - =true - while k - z=array(k) - if m=z else - if m=blue then - =false - break - else - m++ - if m=z else =false : break - end if - end if - end while - } - SortElse=lambda (m(), &swaps, &compares)->{ - long t=len(m()) - dim c(1 to 3)=t - c=1 - for i=0 to len(m())-1 - rem ? "pos:";i;" "; - w=m(i) - if w0 - if c(k)=t then k-- : continue - if m(j)c(k) then c(m(j))=c(k) - rem ? "swap:";m(j);" at pos "+j;" with ";m(c(k)); " at pos ";c(k) - swap m(j), m(c(k)) - rem ? "just swapped array :", m()#str$() - rem ? "c()", c()#str$() - swaps++ - j=c(k) - c(k)++ - end if - k-- - rem ? "k=";k, c(k) - end while - else.if w>c then - c=w - if i-c(c)>1 else c(c)=i - end if - next - =m() - } - random_band=lambda->random(1, 3) - n=random(10, 20) - if n<3 then exit ' need at least 3 colors for the flag - although n now didn't get value 3 we place it to remember it later - do - do - dim balls(n)< { + if size<1 then size=1 + randomitem=lambda a->a#val(random(0,2)) + dim a(size)<{ + Document r$=eval$(array(s)) + if len(s)>1 then + For i=1 to len(s)-1 { + r$=", "+eval$(array(s,i)) + } + end if + =r$ +} +TestSort$=lambda$ (s as array)-> { + ="unsorted: " + x=array(s) + for i=1 to len(s)-1 { + k=array(s,i) + if x>k then break + swap x, k + } + ="sorted: " +} +Positions=lambda mid=White (a as array) ->{ + m=len(a) + dim Base 0, b(m)=-1 + low=-1 + high=m + m-- + i=0 + medpos=stack + link a to a() + for i=m to 0 { + if a(i)<=mid then exit + high-- + b(high)=high + } + for i=0 to m { + if a(i)>=mid then exit + low++ + b(low)=low + } + if high-low>1 then + for i=low+1 to high-1 { + select case a(i)<=>Mid + case -1 + low++ : b(low)=i + case 1 + { + high-- :b(high)=i + if High0 then + dim c() + c()=array(medpos) + stock c(0) keep len(c()), b(low+1) + for i=low+1 to high-1 + if b(i)>low and b(i)i then swap b(b(i)), b(i) + next i + end if + if low>0 then + for i=0 to low + if b(i)<=low and b(i)<>i then swap b(b(i)), b(i) + next + end if + if High=High and b(i)<>i then swap b(b(i)), b(i) + next + end if + =b() +} +InPlace=Lambda (&p(), &Final()) ->{ + def i=0, j=-1, k=-1, many=0 + for i=0 to len(p())-1 + if p(i)<>i then + j=i + z=final(j) + do + final(j)=final(p(j)) + k=j + j=p(j) + p(k)=k + many++ + until j=i + final(k)=z + end if + next + =many +} + + +Dim final(), p(), second(), p1() +Rem final()=(White,Red,Blue,White,Red, Red, Blue) +Rem final()=(white, blue, red, blue, white) + +final()=fillarray(30) +Print "Items: ";len(final()) +Report TestSort$(final())+Display$(final()) +\\ backup for final() for second example +second()=final() +p()=positions(final()) +\\ backup p() to p1() for second example +p1()=p() + + +Report Center, "InPlace" +rem Print p() ' show array items +many=InPlace(&p(), &final()) +rem print p() ' show array items +Report TestSort$(final())+Display$(final()) +print "changes: "; many + + +Report Center, "Using another array to make the changes" +final()=second() +\\ using a second array to place only the changes +item=each(p1()) +many=0 +While item { + if item^=array(item) else final(item^)=second(array(item)) : many++ +} +Report TestSort$(final())+Display$(final()) +print "changes: "; many +Module three_way_partition (A as array, mid as balls, &swaps) { + Def i, j, k + k=Len(A) + Link A to A() + While j < k + if A(j) < mid Then + Swap A(i), A(j) + swaps++ + i++ + j++ + Else.if A(j) > mid Then + k-- + Swap A(j), A(k) + swaps++ + Else + j++ + End if + End While +} +Many=0 +Z=second() +Print +Report center, {Three Way Partition +} +Report TestSort$(Z)+Display$(Z) +three_way_partition Z, White, &many +Print +Report TestSort$(Z)+Display$(Z) +Print "changes: "; many diff --git a/Task/Dutch-national-flag-problem/Modula-2/dutch-national-flag-problem.mod2 b/Task/Dutch-national-flag-problem/Modula-2/dutch-national-flag-problem.mod2 deleted file mode 100644 index 2802b39ad3..0000000000 --- a/Task/Dutch-national-flag-problem/Modula-2/dutch-national-flag-problem.mod2 +++ /dev/null @@ -1,80 +0,0 @@ -MODULE DutchF; -(* Dutch national flag problem *) - -FROM RandomNumbers IMPORT - Rnd; -FROM STextIO IMPORT - WriteLn, WriteString; - -TYPE - TColor = (Blue, White, Red); - -CONST - N = 20; - -VAR - T: ARRAY [0 .. N - 1] OF TColor; - I: CARDINAL; - -PROCEDURE Swap(VAR A, B: TColor); -VAR - Tmp: TColor; -BEGIN - Tmp := A; - A := B; - B := Tmp -END Swap; - -PROCEDURE WriteColorSeq(T: ARRAY OF TColor); -VAR - I: CARDINAL; -BEGIN - FOR I := 0 TO HIGH(T) DO - CASE T[I] OF - | Blue: - WriteString("B"); - | White: - WriteString("W"); - | Red: - WriteString("R"); - END - END; - WriteLn; -END WriteColorSeq; - -PROCEDURE SortByColor(VAR T: ARRAY OF TColor); -VAR - B, W, R: CARDINAL; -BEGIN - B := 0; - W := 0; - R := HIGH(T); - WHILE W <= R DO - CASE T[W] OF - | White: - W := W + 1; - | Blue: - Swap(T[B], T[W]); - B := B + 1; - W := W + 1; - | Red: - Swap(T[W], T[R]); - R := R - 1; - END; - END; -END SortByColor; - -BEGIN - (* Set colors *) - FOR I := 0 TO N - 1 DO - T[I] := VAL(TColor, Rnd(3)); - END; - WriteString("Unsorted:"); - WriteLn; - WriteColorSeq(T); - SortByColor(T); - WriteLn; - WriteString("Sorted:"); - WriteLn; - WriteColorSeq(T); -END DutchF. diff --git a/Task/Dutch-national-flag-problem/PascalABC.NET/dutch-national-flag-problem.pas b/Task/Dutch-national-flag-problem/PascalABC.NET/dutch-national-flag-problem.pas deleted file mode 100644 index eaa7d1319a..0000000000 --- a/Task/Dutch-national-flag-problem/PascalABC.NET/dutch-national-flag-problem.pas +++ /dev/null @@ -1,33 +0,0 @@ -type - colors = (red, white, blue); - -procedure threeWayPartition(a: array of colors; mid: colors); -begin - var (i, j) := (0, 0); - var k := a.High; - while j <= k do - if a[j] < mid then - begin - swap(a[i], a[j]); - i += 1; - j += 1; - end - else if a[j] > mid then - begin - swap(a[j], a[k]); - k -= 1; - end - else j += 1; -end; - -begin - var balls: array of colors; - repeat - balls := ArrGen(10, i -> |red, white, blue|.randomelement); - until balls <> balls.Sorted; - - println('Original ball order:', balls); - threewaypartition(balls, white); - println('Sorted ball order: ', balls); - assert(balls <> balls.sorted, 'Not sorted!'); -end. diff --git a/Task/Dutch-national-flag-problem/Phix/dutch-national-flag-problem.phix b/Task/Dutch-national-flag-problem/Phix/dutch-national-flag-problem.phix index 6167e25ead..a0357d6a9b 100644 --- a/Task/Dutch-national-flag-problem/Phix/dutch-national-flag-problem.phix +++ b/Task/Dutch-national-flag-problem/Phix/dutch-national-flag-problem.phix @@ -1,39 +1,41 @@ -with javascript_semantics -function three_way_partition(sequence s, integer mid) - integer i=1, j=1, n = length(s) - while j <= n do - if s[j] < mid then - {s[i],s[j]} = {s[j],s[i]} - i += 1 - j += 1 - elsif s[j] > mid then - {s[j],s[n]} = {s[n],s[j]} - n -= 1 - else - j += 1 - end if - end while - return s -end function +(phixonline)--> + with javascript_semantics + function three_way_partition(sequence s, integer mid) + integer i=1, j=1, n = length(s) + while j <= n do + if s[j] < mid then + {s[i],s[j]} = {s[j],s[i]} + i += 1 + j += 1 + elsif s[j] > mid then + {s[j],s[n]} = {s[n],s[j]} + n -= 1 + else + j += 1 + end if + end while + return s + end function -constant colours = {"red","white","blue"} -enum /*red,*/ white = 2, blue, maxc = blue + constant colours = {"red","white","blue"} + enum /*red,*/ white = 2, blue, maxc = blue -procedure show(string msg, sequence s) - sequence t = repeat(0,length(s)) - for i=1 to length(s) do - t[i] = colours[s[i]] - end for - printf(1,"%s: %s\n",{msg,join(t)}) -end procedure + procedure show(string msg, sequence s) + sequence t = repeat(0,length(s)) + for i=1 to length(s) do + t[i] = colours[s[i]] + end for + printf(1,"%s: %s\n",{msg,join(t)}) + end procedure -sequence unsorted, sorted -while 1 do - unsorted = sq_rand(repeat(maxc,12)) --- sorted = sort(deep_copy(unsorted)) -- (works just as well) - sorted = three_way_partition(deep_copy(unsorted), white) - if unsorted!=sorted then exit end if - ?"oops" -end while -show("Unsorted",unsorted) -show("Sorted",sorted) + sequence unsorted, sorted + while 1 do + unsorted = sq_rand(repeat(maxc,12)) + -- sorted = sort(deep_copy(unsorted)) -- (works just as well) + sorted = three_way_partition(deep_copy(unsorted), white) + if unsorted!=sorted then exit end if + ?"oops" + end while + show("Unsorted",unsorted) + show("Sorted",sorted) + n ) - [ 2 ] is white ( --> n ) - [ 3 ] is blue ( --> n ) - - randomise - - [] ' [ red white blue ] - witheach - [ nested swap - 5 random times [ over join ] - swap join ] - - dup [ shuffle 2dup != until ] nip - - say "Before sorting: " dup echo cr - say " After sorting: " sortwith [ dip do do > ] echo cr diff --git a/Task/Dutch-national-flag-problem/QuickBASIC/dutch-national-flag-problem.basic b/Task/Dutch-national-flag-problem/QuickBASIC/dutch-national-flag-problem.basic deleted file mode 100644 index cca5c51dbe..0000000000 --- a/Task/Dutch-national-flag-problem/QuickBASIC/dutch-national-flag-problem.basic +++ /dev/null @@ -1,57 +0,0 @@ -' Dutch national flag problem -DECLARE SUB PrintColorSeq (T() AS INTEGER) -DECLARE SUB SortByColor (T() AS INTEGER) - -CONST CBLUE% = 0, CWHITE% = 1, CRED% = 2 -CONST N% = 20 -DIM T(0 TO N% - 1) AS INTEGER -DIM I AS INTEGER - -' Set colors -RANDOMIZE TIMER -FOR I = 0 TO N% - 1 - T(I) = INT(RND * 3) -NEXT I - -PRINT "Unsorted:" -CALL PrintColorSeq(T()) -CALL SortByColor(T()) -PRINT -PRINT "Sorted:" -CALL PrintColorSeq(T()) -END - -SUB PrintColorSeq (T() AS INTEGER) - DIM I AS INTEGER - FOR I = 0 TO UBOUND(T) - SELECT CASE T(I) - CASE CBLUE% - PRINT "B"; - CASE CWHITE% - PRINT "W"; - CASE CRED% - PRINT "R"; - END SELECT - NEXT I - PRINT -END SUB - -SUB SortByColor (T() AS INTEGER) - DIM B AS INTEGER, W AS INTEGER, R AS INTEGER - B = 0 - W = 0 - R = UBOUND(T) - DO WHILE W <= R - SELECT CASE T(W) - CASE CWHITE% - W = W + 1 - CASE CBLUE% - SWAP T(B), T(W) - B = B + 1 - W = W + 1 - CASE CRED% - SWAP T(W), T(R) - R = R - 1 - END SELECT - LOOP -END SUB diff --git a/Task/Dutch-national-flag-problem/R/dutch-national-flag-problem.r b/Task/Dutch-national-flag-problem/R/dutch-national-flag-problem.r deleted file mode 100644 index bf63f230ae..0000000000 --- a/Task/Dutch-national-flag-problem/R/dutch-national-flag-problem.r +++ /dev/null @@ -1,26 +0,0 @@ -colours <- c("Red", "White", "Blue") - -rand_balls <- function(v, f){ - repeat{ - balls <- sample(v, sample(10:20, 1), replace=TRUE) - balls_sorted <- f(balls) - if(!identical(balls, balls_sorted)){ - print(list("Unsorted"=balls, "Sorted"=balls_sorted), quote=FALSE) - break - } - } -} - -#Method 1: converting the vector of colours to a factor and using the built-in sort() function - -colours_ordered <- factor(1:3, labels=colours) -rand_balls(colours_ordered, sort) - -#Method 2: simple counting sort (showcasing the conciseness of R's rep() function) - -counting_sort <- function(v){ - counts <- sapply(1:3, function(n) sum(v==colours[n])) - rep(colours, times=counts) -} - -rand_balls(colours, counting_sort) diff --git a/Task/Dutch-national-flag-problem/Rust/dutch-national-flag-problem.rs b/Task/Dutch-national-flag-problem/Rust/dutch-national-flag-problem.rs deleted file mode 100644 index 325af2792e..0000000000 --- a/Task/Dutch-national-flag-problem/Rust/dutch-national-flag-problem.rs +++ /dev/null @@ -1,43 +0,0 @@ -extern crate rand; // 0.10.0 used - -use rand::prelude::*; - -// Color enums will be sorted by their top-to-bottom declaration order -#[derive(Eq,Ord,PartialOrd,PartialEq,Debug)] -enum Color { - Red, - White, - Blue -} - -fn is_sorted(list: &Vec) -> bool { - let mut state = &Color::Red; - for current in list.iter() { - if current < state { return false; } - if current > state { state = current; } - } - true -} - -fn main() { - let mut rng = rand::rng(); - let mut colors: Vec = Vec::new(); - - for _ in 1..10 { - let r = rng.random_range(0..3); - if r == 0 { colors.push(Color::Red); } - else if r == 1 { colors.push(Color::White); } - else if r == 2 { colors.push(Color::Blue); } - } - - while is_sorted(&colors) { - colors.shuffle(&mut rng); - } - - println!("Before: {:?}", colors); - colors.sort(); - println!("After: {:?}", colors); - if !is_sorted(&colors) { - println!("Oops, did not sort colors correctly!"); - } -} diff --git a/Task/Dutch-national-flag-problem/Rust/dutch-national-flag-problem.rust b/Task/Dutch-national-flag-problem/Rust/dutch-national-flag-problem.rust new file mode 100644 index 0000000000..0a6e2a4972 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Rust/dutch-national-flag-problem.rust @@ -0,0 +1,44 @@ +extern crate rand; + +use rand::Rng; + +// Color enums will be sorted by their top-to-bottom declaration order +#[derive(Eq,Ord,PartialOrd,PartialEq,Debug)] +enum Color { + Red, + White, + Blue +} + +fn is_sorted(list: &Vec) -> bool { + let mut state = &Color::Red; + for current in list.iter() { + if current < state { return false; } + if current > state { state = current; } + } + true +} + + +fn main() { + let mut rng = rand::thread_rng(); + let mut colors: Vec = Vec::new(); + + for _ in 1..10 { + let r = rng.gen_range(0, 3); + if r == 0 { colors.push(Color::Red); } + else if r == 1 { colors.push(Color::White); } + else if r == 2 { colors.push(Color::Blue); } + } + + while is_sorted(&colors) { + rng.shuffle(&mut colors); + } + + println!("Before: {:?}", colors); + colors.sort(); + println!("After: {:?}", colors); + if !is_sorted(&colors) { + println!("Oops, did not sort colors correctly!"); + } +} diff --git a/Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua b/Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua deleted file mode 100644 index 354f52209c..0000000000 --- a/Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua +++ /dev/null @@ -1,3 +0,0 @@ -&p.[⍥(⊡⌊×3⚂"RWB")30] # Build it. -&p.⊏▽⊸>2⍏⊛.⊂"RWB" # Sort it, providing model for sort order. -&p⨬("oops"|"good")≍⊏⊸⍏.⊛ # Confirm it's sorted. diff --git a/Task/Dutch-national-flag-problem/V-(Vlang)/dutch-national-flag-problem.v b/Task/Dutch-national-flag-problem/V-(Vlang)/dutch-national-flag-problem.v deleted file mode 100644 index 7f5ba932b3..0000000000 --- a/Task/Dutch-national-flag-problem/V-(Vlang)/dutch-national-flag-problem.v +++ /dev/null @@ -1,25 +0,0 @@ -import rand - -fn main() { - flag := ["Red","White","Blue"] - mut balls := [10]string{} - mut color :="" - mut number := 0 - - print("Random: |") - for idx in 0..10 { - number = rand.int_in_range(0, 3) or {println("Error: invalid number") exit(1)} - balls[idx] = flag[number] - print("${balls[idx]}" + " |") - } - println("") - - print("Sorted: |") - for idx in 0..3 { - color = flag[idx] - for jdx in 0..10 { - if balls[jdx] == color {print("${balls[jdx]}" + " |")} - } - } - println("") -} diff --git a/Task/Dutch-national-flag-problem/VBScript/dutch-national-flag-problem.vbs b/Task/Dutch-national-flag-problem/VBScript/dutch-national-flag-problem.vb similarity index 100% rename from Task/Dutch-national-flag-problem/VBScript/dutch-national-flag-problem.vbs rename to Task/Dutch-national-flag-problem/VBScript/dutch-national-flag-problem.vb diff --git a/Task/Dutch-national-flag-problem/Wren/dutch-national-flag-problem.wren b/Task/Dutch-national-flag-problem/Wren/dutch-national-flag-problem.wren index 6eef39ff82..71c5a9ee23 100644 --- a/Task/Dutch-national-flag-problem/Wren/dutch-national-flag-problem.wren +++ b/Task/Dutch-national-flag-problem/Wren/dutch-national-flag-problem.wren @@ -1,5 +1,5 @@ import "random" for Random -import "./sort" for Sort +import "/sort" for Sort var colors = ["Red", "White", "Blue"] var colorMap = { "Red": 0, "White": 1, "Blue": 2 } diff --git a/Task/Dynamic-variable-names/ALGOL-68/dynamic-variable-names.alg b/Task/Dynamic-variable-names/ALGOL-68/dynamic-variable-names.alg deleted file mode 100644 index 7a8a5853f6..0000000000 --- a/Task/Dynamic-variable-names/ALGOL-68/dynamic-variable-names.alg +++ /dev/null @@ -1,77 +0,0 @@ -BEGIN # Simulate dynamic variables using an array, translation of the FreeBASIC sample # - - MODE DYNAMICVARIABLE = STRUCT( STRING name, value ); - - OP LCASE = ( CHAR c )CHAR: - IF c >= "A" AND c <= "Z" THEN REPR( ( ABS c - ABS "A" ) + ABS "a" ) ELSE c FI; - OP LCASE = ( STRING s )STRING: - BEGIN - STRING lc := s; - FOR i FROM LWB lc TO UPB lc DO lc[ i ] := LCASE lc[ i ] OD; - lc - END # LCASE # ; - OP TRIM = ( STRING s )STRING: - BEGIN - INT left := LWB s, right := UPB s; - WHILE IF left > right THEN FALSE ELSE s[ left ] = " " FI DO left +:= 1 OD; - WHILE IF right < left THEN FALSE ELSE s[ right ] = " " FI DO right -:= 1 OD; - s[ left : right ] - END # TRIM # ; - - PROC find variable index = ( []DYNAMICVARIABLE dyvar, STRING v, INT n elements )INT: - BEGIN - STRING name = LCASE TRIM v; - INT index := LWB dyvar - 1; - INT max index = index + n elements; - FOR i FROM LWB dyvar TO max index WHILE index < LWB dyvar DO - IF name OF dyvar[ i ] = name THEN index := i FI - OD; - index - END # find variable index # ; - - INT n; - WHILE - print( ( "How many variables do you want to create (max 5) " ) ); - read( ( n, newline ) ); - n < 0 OR n > 5 - DO SKIP OD; - - [ 1 : n ]DYNAMICVARIABLE a; - - print( ( newline, "OK, enter the variable names and their values, below", newline ) ); - - FOR i TO n DO - WHILE - print( ( " Variable ", whole( i, 0 ), newline ) ); - print( ( " Name : " ) ); - read( ( name OF a[ i ], newline ) ); - name OF a[ i ] := LCASE TRIM name OF a[ i ]; - # identifiers should not be case-sensitive in Algol 68 though # - # in upper stropped sources (such as this one) they have to # - # be in lower case # - find variable index( a, name OF a[ i ], i - 1 ) > 0 - DO - print( ( " Sorry, you've already created a variable of that name, try again", newline ) ) - OD; - print( ( " Value : " ) ); - read( ( value OF a[ i ], newline ) ); - value OF a[ i ] := TRIM value OF a[ i ] - OD; - - print( ( newline, "Press q to quit" ) ); - WHILE - STRING v; - print( ( newline, "Which variable do you want to inspect ? " ) ); - read( ( v, newline ) ); - v /= "q" AND v /= "Q" - DO - IF INT index = find variable index( a, v, n ); - index = 0 - THEN - print( ( "Sorry there's no variable of that name, try again", newline ) ) - ELSE - print( ( "It's value is ", value OF a[ index ], newline ) ) - FI - OD - -END diff --git a/Task/Dynamic-variable-names/Ballerina/dynamic-variable-names.ballerina b/Task/Dynamic-variable-names/Ballerina/dynamic-variable-names.ballerina deleted file mode 100644 index 6019bb031b..0000000000 --- a/Task/Dynamic-variable-names/Ballerina/dynamic-variable-names.ballerina +++ /dev/null @@ -1,16 +0,0 @@ -import ballerina/io; - -public function main() returns error? { - map nvs = {}; - io:println("Enter three variables:"); - foreach var _ in 0...2 { - string name = io:readln("\n name : "); - string value = io:readln(" value : "); - nvs[name] = check int:fromString(value); - } - - io:println("\nYour variables are:\n"); - foreach string name in nvs.keys() { - io:println(` ${name} = ${nvs[name]}`); - } -} diff --git a/Task/Dynamic-variable-names/C++/dynamic-variable-names.cpp b/Task/Dynamic-variable-names/C++/dynamic-variable-names.cpp deleted file mode 100644 index 264b0269b7..0000000000 --- a/Task/Dynamic-variable-names/C++/dynamic-variable-names.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include -#include - -int main() { - std::unordered_map variables; - - std::string name; - std::cout << "Enter your variable name: " << std::endl; - std::cin >> name; - - int32_t value; - std::cout << "Enter your variable value: " << std::endl; - std::cin >> value; - - variables[name] = value; - - std::cout << "You have created a variable '" << name << "' with a value of " << value << ":" << std::endl; - - std::for_each(variables.begin(), variables.end(), - [](std::pair pair) { - std::cout << pair.first << " = " << pair.second << std::endl; - } - ); -} diff --git a/Task/Dynamic-variable-names/C/dynamic-variable-names.c b/Task/Dynamic-variable-names/C/dynamic-variable-names.c deleted file mode 100644 index d48225edc0..0000000000 --- a/Task/Dynamic-variable-names/C/dynamic-variable-names.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -static inline uint64_t hash(void const *cp, size_t n) { - uint64_t h = 0; - uint64_t const e = UINT64_C(2718281828459045235); // e * 10**18 - for(uint8_t const *cb = cp; n > 0; n--) { - h = ((h + n) * e) ^ ((*cb++ & 0xFF) * e); - } - return h; -} - -static void *dup(void const *cp, size_t n) { - void *p = malloc(n); - return memcpy(p, cp, n); -} - -static void *nodup(void const *cp, size_t n) { - return (void*)cp; -} - -#define MAPPED struct mapped_s -MAPPED { - size_t n; - char const *s; -}; -#define MAP struct map_s -MAP { - size_t u; - size_t w; - size_t m; - char a[]; -}; - -static MAP *map_alloc(size_t m, size_t z) { - const size_t N = (((m * z) + (sizeof(MAP)-1)) / sizeof(MAP)) + 1; - MAP *t = calloc(N, sizeof(MAP)); - t->m = m; - t->w = 3 * m / 4; - return t; -} - -static void *map(MAP **t, size_t z, char const *s, size_t n, void *(*dup)(void const *, size_t)) { - if(!*t) { - *t = map_alloc(sizeof(size_t) * CHAR_BIT, z); - } - MAP *f = *t; - uint64_t const h = hash(s, n); - size_t x = (h / f->m) % f->m; - size_t const k = x + !x; - size_t const l = f->m - k; - size_t const y = h % f->m; - x = y; - do { - MAPPED *p = (MAPPED *)&f->a[x*z]; - if((p->n == n) && (memcmp(p->s, s, n) == 0)) { - return p; - } - if((p->n == 0) && dup) { - if(f->u == f->w) { - *t = map_alloc(2 * f->m, z); - for(size_t i = 0; f->u < f->w; i++) { - MAPPED *q = (MAPPED *)&f->a[i*z]; - if(q->n > 0) { - (void)map(t, z, q->s, q->n, nodup); - } - } - free(f); - return map(t, z, s, n, dup); - } - f->u++; - p->n = n; - p->s = dup(s, n); - return p; - } - x = (x >= l) ? ((x + 1) % k) : (x + k); - } while(x != y) - ; - return NULL; -} - -static double mapf(char const *s, double v, void *(*dup)(void const *, size_t)) { - static MAP *t = NULL; - struct { - MAPPED; - double v; - } *p = map(&t, sizeof(*p), s, strlen(s), dup); - if(p) { - if(dup) p->v = v; - return p->v; - } - return NAN; -} - -static inline double assignf(char const *s, double v) { - return mapf(s, v, dup); -} - -static inline double valuef(char const *s) { - return mapf(s, 0, 0); -} - -static char *enter(char const *prompt) { - static char buf[256]; - fputs(prompt, stdout); fflush(stdout); - fgets(buf, sizeof(buf), stdin); - char *s = buf; - for(; *s && !isgraph(*s); s++) - ; - char *t = s + strlen(s); - for(; (t > s) && !isgraph(*(t-1)); t--) - ; - *t = '\0'; - return s; -} - -int main(int argc, char **argv) { - for(;;) { - char const *name = enter("Enter: "); - if(!*name) break; - char *val = strchr(name, '='); - if(val) { - *val++ = '\0'; - assignf(name, strtod(val, NULL)); - } else { - printf("%s = %F\n", name, valuef(name)); - } - } - return 0; -} diff --git a/Task/Dynamic-variable-names/DuckDB/dynamic-variable-names.duckdb b/Task/Dynamic-variable-names/DuckDB/dynamic-variable-names.duckdb deleted file mode 100644 index e5e9804bf2..0000000000 --- a/Task/Dynamic-variable-names/DuckDB/dynamic-variable-names.duckdb +++ /dev/null @@ -1 +0,0 @@ -select COLUMNS(x -> x = getenv('variablename')) from t; diff --git a/Task/Dynamic-variable-names/EMal/dynamic-variable-names.emal b/Task/Dynamic-variable-names/EMal/dynamic-variable-names.emal deleted file mode 100644 index f55c9b8919..0000000000 --- a/Task/Dynamic-variable-names/EMal/dynamic-variable-names.emal +++ /dev/null @@ -1,37 +0,0 @@ -^|EMal doesn't support the creation of user-defined variable names. - |It can manage symbolic references to existing variables. - |It can use Records to dynamically create fields. - |^ -Record data ← [] -fun fillData ← void by block - for ever - ^|we ask for key/value pairs|^ - text key ← ask(text, "Enter the key or press Enter to quit: ") - if key æ Text.EMPTY do break end - text value ← ask(text, "Enter the value: ") - data[key] ← value ^|here we set the user-defined key field - |on the record data, with the provided value - |^ - end - writeLine() -end -^|here we show how symbolic reference works by using var("variableName")|^ -fun dumpData ← void by text recordName - writeLine("dumping the fields for the record named '", recordName, "'") - Record.keys(var(recordName)).list( 5 { - n = strconv.atoi(os.input("Integer variables (max 5): ")) or { - println("Invalid input!") - continue - } - } - for i <= n { - println("OK, enter the variable names and their values, below:") - println("Variable ${i}") - name = os.input_opt(" Name: ") or { panic("Invalid input!") } - for { - value = strconv.atoi(os.input(" Value: ")) or { - println("Must be a valid number!") - continue - } - break - } - vars[name] += value - i++ - } - println("\n" + "Enter q to quit") - for { - name = os.input_opt("Which variable do you want to inspect: ") or { panic("Invalid input!") } - if name.to_lower() == "q" { break } - if name !in vars { println("Sorry there's no variable of that name, try again!") } - else { println("Its value is ${vars[name]}") } - } -} diff --git a/Task/Dynamic-variable-names/Wren/dynamic-variable-names.wren b/Task/Dynamic-variable-names/Wren/dynamic-variable-names.wren index c2926585e1..19260ccddb 100644 --- a/Task/Dynamic-variable-names/Wren/dynamic-variable-names.wren +++ b/Task/Dynamic-variable-names/Wren/dynamic-variable-names.wren @@ -1,14 +1,18 @@ -import "./ioutil" for Input -import "./trait" for Var +import "io" for Stdin, Stdout +var userVars = {} System.print("Enter three variables:") for (i in 0..2) { - var name = Input.text("\n name : ") - var value = Input.text(" value : ") - Var[name] = Num.fromString(value) + System.write("\n name : ") + Stdout.flush() + var name = Stdin.readLine() + System.write(" value: ") + Stdout.flush() + var value = Num.fromString(Stdin.readLine()) + userVars[name] = value } System.print("\nYour variables are:\n") -for (kv in Var.entries) { +for (kv in userVars) { System.print(" %(kv.key) = %(kv.value)") } diff --git a/Task/EKG-sequence-convergence/00-TASK.txt b/Task/EKG-sequence-convergence/00-TASK.txt index 4c8d88d972..58bd17a3f1 100644 --- a/Task/EKG-sequence-convergence/00-TASK.txt +++ b/Task/EKG-sequence-convergence/00-TASK.txt @@ -27,7 +27,6 @@ If an algorithm that keeps track of the minimum amount of numbers and their corr ;Related Tasks: # [[Greatest common divisor]] # [[Sieve of Eratosthenes]] -# [[Yellowstone sequence]]
;Reference: * [https://www.youtube.com/watch?v=yd2jr30K2R4 The EKG Sequence and the Tree of Numbers]. (Video). diff --git a/Task/EKG-sequence-convergence/Ada/ekg-sequence-convergence.adb b/Task/EKG-sequence-convergence/Ada/ekg-sequence-convergence.ada similarity index 100% rename from Task/EKG-sequence-convergence/Ada/ekg-sequence-convergence.adb rename to Task/EKG-sequence-convergence/Ada/ekg-sequence-convergence.ada diff --git a/Task/EKG-sequence-convergence/Arturo/ekg-sequence-convergence.arturo b/Task/EKG-sequence-convergence/Arturo/ekg-sequence-convergence.arturo deleted file mode 100644 index 6f6c56d98c..0000000000 --- a/Task/EKG-sequence-convergence/Arturo/ekg-sequence-convergence.arturo +++ /dev/null @@ -1,37 +0,0 @@ -ekg: function [start, limit][ - result: @[1 start] - - while [limit > size result][ - candidate: 2 - while ø [ - if and? [not? contains? result candidate] - [1 < gcd @[last result candidate]][ - 'result ++ candidate - break - ] - inc 'candidate - ] - ] - - return result -] - -loop [2 5 7 9 10] 'n -> - print ["EKG(" ++ (to :string n) ++ "):" join.with:", " ekg n 10] - -print "" -ekg5: ekg 5 100 -ekg7: ekg 7 100 - -converged?: false -loop 2..99 'i [ - if and? -> ekg5\[i] = ekg7\[i] - -> equal? sort slice ekg5 0 i sort slice ekg7 0 i [ - print ["EKG(5) and EKG(7) converge at term" i+1] - converged?: true - break - ] -] - -unless converged? -> - print "EKG(5) and EKG(7) do not converge within 100 terms" diff --git a/Task/EKG-sequence-convergence/C++/ekg-sequence-convergence.cpp b/Task/EKG-sequence-convergence/C++/ekg-sequence-convergence.cpp deleted file mode 100644 index 09597f1d6e..0000000000 --- a/Task/EKG-sequence-convergence/C++/ekg-sequence-convergence.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include -#include -#include - -void print_vector(const std::vector& list) { - std::cout << "["; - for ( uint64_t i = 0; i < list.size() - 1; ++i ) { - std::cout << list[i] << ", "; - } - std::cout << list.back() << "]" << std::endl; -} - -bool contains(const std::vector& list, const int32_t& n) { - return std::find(list.begin(), list.end(), n) != list.end(); -} - -bool same_sequence(const std::vector& seq1, const std::vector& seq2, const int32_t& n) { - for ( uint64_t i = n ; i < seq1.size() ; ++i ) { - if ( seq1[i] != seq2[i] ) { - return false; - } - } - return true; -} - -std::vector ekg(const int32_t& second_term, const uint64_t& term_count) { - std::vector result = { 1, second_term }; - int32_t candidate = 2; - while ( result.size() < term_count ) { - if ( ! contains(result, candidate) && std::gcd(result.back(), candidate) > 1 ) { - result.push_back(candidate); - candidate = 2; - } else { - candidate++; - } - } - return result; -} - -int main() { - std::cout << "The first 10 members of EKG[2], EKG[5], EKG[7], EKG[9] and EKG[10] are:" << std::endl; - for ( int32_t i : { 2, 5, 7, 9, 10 } ) { - std::cout << "EKG[" << std::setw(2) << i << "] = "; print_vector(ekg(i, 10)); - } - std::cout << std::endl; - - std::vector ekg5 = ekg(5, 100); - std::vector ekg7 = ekg(7, 100); - int32_t i = 1; - while ( ! ( ekg5[i] == ekg7[i] && same_sequence(ekg5, ekg7, i) ) ) { - i++; - } - // Converting from 0-based to 1-based index - std::cout << "EKG[5] and EKG[7] converge at index " << i + 1 - << " with a common value of " << ekg5[i] << "." << std::endl; -} diff --git a/Task/EKG-sequence-convergence/EasyLang/ekg-sequence-convergence.easy b/Task/EKG-sequence-convergence/EasyLang/ekg-sequence-convergence.easy deleted file mode 100644 index 3c42057e99..0000000000 --- a/Task/EKG-sequence-convergence/EasyLang/ekg-sequence-convergence.easy +++ /dev/null @@ -1,22 +0,0 @@ -func contains a[] b . - for a in a[] : if a = b : return 1 - return 0 -. -func gcd a b . - if b = 0 : return a - return gcd b (a mod b) -. -starts[] = [ 2 5 7 9 10 ] -len ekg[][] 5 -for s to 5 - ekg[s][] = [ 1 starts[s] ] - for n = 2 to 10 - for i = 2 to 1 / 0 - if contains ekg[s][] i = 0 and gcd ekg[s][n], i > 1 - ekg[s][] &= i - break 1 - . - . - . - print ekg[s][] -. diff --git a/Task/EKG-sequence-convergence/Fortran/ekg-sequence-convergence.f b/Task/EKG-sequence-convergence/Fortran/ekg-sequence-convergence.f deleted file mode 100644 index fddf573531..0000000000 --- a/Task/EKG-sequence-convergence/Fortran/ekg-sequence-convergence.f +++ /dev/null @@ -1,168 +0,0 @@ - ! EKG sequence convergence - ! tested with Intel ifx (IFX) 2025.2.0 20250605 on Kubuntu 25.04 - ! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 - ! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 - ! Note that VMS requires switch $Fortran/ccdefault=LIST - ! otherwise 1st character of each output line is interpreted as - ! Carriage Control character. - ! -module EKG -implicit none - -integer, parameter :: nElementsToPrint=10 - - -contains - -subroutine ekgSequence (secondElm, nElm, isq) - ! - ! Construct first 'nElm' elements of the EKG Sequence that has 'secondElm' - ! as second element, knowing first element ios always 1. - ! - - integer, intent(in) :: secondElm - integer, intent(in) :: nElm - - integer, intent(out) :: isq (*) - - integer :: candidate=2 - integer :: ncurrent - - isq(1) = 1 ! 1st element always 1 - isq(2) = secondElm ! 2nd element from argument - ncurrent = 2 ! index to highest known element of sequence isq - - do while (ncurrent .le. nElm) - ! 'candidate' is next element of isq if it is not already in this sequence AND - ! if it shares at least 1 prime factor with highest known element if isq - ! which means GCD(candidate, highest element of isq) is >1 - if ( (.not. containsElement (isq, ncurrent, candidate)) & - .and. gcd(isq(ncurrent), candidate) > 1 ) then - ! found next element of isq - ncurrent = ncurrent + 1 - isq(ncurrent) = candidate - candidate = 2; ! start over again - else - ! Not a candidate: try next one. - candidate= candidate + 1 - end if - end do -end subroutine ekgSequence - -function containsElement (isq, nElm, elm) result (yes) - ! - ! return .true. if number 'elm' can be found within - ! first 'nElm' elements of sequence 'isq' . - ! - integer, intent(in) :: nElm - integer, intent(in) :: isq (nElm) - integer, intent(in) :: elm - logical :: yes - integer :: ii - - ! Straightforward: Loop until elm found or - ! last element reached - do ii = 1, nElm - if (isq(ii) == elm) then - yes=.true. - return - end if - end do - yes=.false. - return -end function containsElement - - -function gcd (n,m) result (rgcd) - ! - ! euclid's algorithm - ! to find greatest common divisor - ! - integer, intent(in) :: n,m - integer :: rgcd - integer :: a - integer :: b - - a=n - b=m - - if (a .eq. 0) then - rgcd = 0 - else - do while (b .ne. 0) - if ( a .gt. b ) then - a = a - b - else - b = b - a; - end if - end do - rgcd =a - end if -end function gcd - - -subroutine printThem (isq) -! -! Print the pedefined number of elements of sequence isq -! -integer, intent(in) :: isq(nElementsToPrint) -integer :: ii - -! print the Introduction like EKG(2) and first elemment -write (6, '("EKG(", I2,") = [", i1,x)', advance='no') isq(2), isq(1) - -! print remaining elements except the last -do ii = 2, nElementsToPrint-1 - write (6,'(i2, x)', advance = 'no' ) isq(ii) -end do - -! Terminate output line: last element and close "]" -write (6,'(I2, "]")') isq(nElementsToPrint) - -end subroutine printThem - -end module EKG - - -program EKGMain - - use EKG - - implicit none - - integer :: myekg(100) - integer :: ekg5 (100) - integer :: ekg7 (100) - integer :: nx(5) = [2,5,7,9,10] - integer :: match - integer:: ii, jj - ! - ! Produce and print first 10 elements of first 5 sequences - ! - do ii=1,5 - call ekgSequence (nx(ii), nElementsToPrint, myekg) - call printThem (myekg) - end do - ! - ! Produce 100 elements of EKG(5) and EKG(7) - ! - call ekgSequence (5, 100, ekg5) - call ekgSequence (7, 100, ekg7) - ! - ! see where they converge - ! - match = -1 - do ii=2, 100 - if (ekg5(ii) .eq. ekg7(ii)) then - ! Memoize first identical elements and - ! see if all following elements are identical as well. - if (match .lt. 0) match = ii - do jj=ii+1,100 - if (ekg5(jj) .ne. ekg7(jj)) then - match = -1 ! Not same - endif - end do - end if - end do - write (6, "( /'EKG(5) and EKG(7) converge at index ', i0, '.')") match -end program EKGMain diff --git a/Task/EKG-sequence-convergence/FreeBASIC/ekg-sequence-convergence.basic b/Task/EKG-sequence-convergence/FreeBASIC/ekg-sequence-convergence.basic deleted file mode 100644 index 2f4f0eb704..0000000000 --- a/Task/EKG-sequence-convergence/FreeBASIC/ekg-sequence-convergence.basic +++ /dev/null @@ -1,52 +0,0 @@ -Const limite = 30 -Dim Shared As Integer n, A(limite + 1) - -Function Used(m As Integer) As Boolean 'Return 'True' if m is in array A - For i As Integer = 1 To n - 1 - If m = A(i) Then Return True - Next i - Return False -End Function - -Function MinFactor(num As Integer) As Integer 'Return minimum unused factor - Dim As Integer factor, valor, min - - factor = 2 - min = &H7FFFFFFF - Do - If num Mod factor = 0 Then 'found a factor - valor = factor - Do - If Used(valor) Then - valor+ = factor - Else - If valor < min Then min = valor - Exit Do - End If - Loop - num \= factor - Else - factor += 1 - End If - Loop Until factor > num - Return min -End Function - -Sub EKG(m As Integer) 'Calculate and show EKG sequence - A(1) = 1: A(2) = m - For n = 3 To limite - A(n) = MinFactor(A(n - 1)) - Next n - Print Using "EKG(##):"; m; - For i As Integer = 1 To limite - Print Using "###"; A(i); - Next i - Print -End Sub - -Dim starts(4) As Integer = {2, 5, 7, 9, 10} -For i As Integer = 0 To 4 - EKG(starts(i)) -Next i - -Sleep diff --git a/Task/EKG-sequence-convergence/JavaScript/ekg-sequence-convergence.js b/Task/EKG-sequence-convergence/JavaScript/ekg-sequence-convergence.js deleted file mode 100644 index 8ffa394a5c..0000000000 --- a/Task/EKG-sequence-convergence/JavaScript/ekg-sequence-convergence.js +++ /dev/null @@ -1,71 +0,0 @@ -// Calculate and show here the first 10 members of EKG[2], EKG[5], EKG[7], EKG[9] and EKG[10] -for (const i of [2, 5, 7, 9, 10]) { - console.log(`EKG[${i}] = [${ekg(i, 10).join(', ')}]`); -} - -console.log("Calculate and show here at which term EKG[5] and EKG[7] converge."); -const ekg5 = ekg(5, 100); -const ekg7 = ekg(7, 100); - -for (let i = 1; i < ekg5.length; i++) { - if (ekg5[i] === ekg7[i] && sameSeq(ekg5, ekg7, i)) { - console.log(`EKG[5](${i + 1}) = EKG[7](${i + 1}) = ${ekg5[i]}, and are identical from this term on`); - break; - } -} - -// Same last element, and all elements in sequence are identical -function sameSeq(seq1, seq2, n) { - const list1 = seq1.slice(0, n).sort((a, b) => a - b); - const list2 = seq2.slice(0, n).sort((a, b) => a - b); - - for (let i = 0; i < n; i++) { - if (list1[i] !== list2[i]) { - return false; - } - } - return true; -} - -// Without Map to identify seen terms, need to examine list. -// Calculating 3000 terms in this manner takes 10 seconds -// With Map to identify the seen terms, calculating 3000 terms takes .1 sec. -function ekg(two, maxN) { - const result = []; - result.push(1); - result.push(two); - - const seen = new Map(); - seen.set(1, 1); - seen.set(two, 1); - - let minUnseen = two === 2 ? 3 : 2; - let prev = two; - - for (let n = 3; n <= maxN; n++) { - let test = minUnseen - 1; - while (true) { - test++; - if (!seen.has(test) && gcd(test, prev) > 1) { - result.push(test); - seen.set(test, n); - prev = test; - - if (minUnseen === test) { - do { - minUnseen++; - } while (seen.has(minUnseen)); - } - break; - } - } - } - return result; -} - -function gcd(a, b) { - if (b === 0) { - return a; - } - return gcd(b, a % b); -} diff --git a/Task/EKG-sequence-convergence/Julia/ekg-sequence-convergence.jl b/Task/EKG-sequence-convergence/Julia/ekg-sequence-convergence.julia similarity index 100% rename from Task/EKG-sequence-convergence/Julia/ekg-sequence-convergence.jl rename to Task/EKG-sequence-convergence/Julia/ekg-sequence-convergence.julia diff --git a/Task/EKG-sequence-convergence/Kotlin/ekg-sequence-convergence.kts b/Task/EKG-sequence-convergence/Kotlin/ekg-sequence-convergence.kotlin similarity index 100% rename from Task/EKG-sequence-convergence/Kotlin/ekg-sequence-convergence.kts rename to Task/EKG-sequence-convergence/Kotlin/ekg-sequence-convergence.kotlin diff --git a/Task/EKG-sequence-convergence/MATLAB/ekg-sequence-convergence.m b/Task/EKG-sequence-convergence/MATLAB/ekg-sequence-convergence.m deleted file mode 100644 index 2363b9b1e0..0000000000 --- a/Task/EKG-sequence-convergence/MATLAB/ekg-sequence-convergence.m +++ /dev/null @@ -1,43 +0,0 @@ -% Displaying EKG sequences and the convergence point -for i = [2, 5, 7, 9, 10] - ekg = ekgsequence(i, 30); - fprintf('EKG(%d): %s\n', i, num2str(ekg)); -end - -convergencePoint = convergeat(5, 7); -fprintf('EKGs of 5 & 7 converge at term %d\n', convergencePoint); - - - -function ekg = ekgsequence(n, limit) - ekg = [1, n]; - while length(ekg) < limit - for i = 2:2^18 - if all(ekg ~= i) && gcd(ekg(end), i) > 1 - ekg = [ekg, i]; - break; - end - end - end -end - -function point = convergeat(n, m, max) - if nargin < 3 - max = 100; - end - - ekgn = ekgsequence(n, max); - ekgm = ekgsequence(m, max); - - point = 0; - for i = 3:max - if ekgn(i) == ekgm(i) && sum(ekgn(1:i+1)) == sum(ekgm(1:i+1)) - point = i; - return; - end - end - - if point == 0 - warning('No convergence in %d terms', max); - end -end diff --git a/Task/EKG-sequence-convergence/Pluto/ekg-sequence-convergence.pluto b/Task/EKG-sequence-convergence/Pluto/ekg-sequence-convergence.pluto deleted file mode 100644 index e2e276d6ff..0000000000 --- a/Task/EKG-sequence-convergence/Pluto/ekg-sequence-convergence.pluto +++ /dev/null @@ -1,38 +0,0 @@ -require "table2" -local int = require "int" -local fmt = require "fmt" - -local limit = 100 -local starts = {2, 5, 7, 9, 10} -local ekg = {} -for i = 1, 5 do ekg[i] = table.rep(limit, 0) end -local s = 1 -for starts as start do - ekg[s][1] = 1 - ekg[s][2] = start - for n = 3, limit do - local i = 2 - while true do - -- A potential sequence member cannot already have been used - -- and must have a factor in common with previous member. - if !ekg[s]:slice(1, n):contains(i) and int.gcd(ekg[s][n - 1], i) > 1 then - ekg[s][n] = i - break - end - i += 1 - end - end - fmt.write("EKG(%2d): ", start) - fmt.tprint("%2d", ekg[s]:slice(1, 30), 30) - s += 1 -end - --- Now compare EKG5 and EKG7 for convergence. -for i = 3, limit do - if ekg[2][i] == ekg[3][i] and - table.same(ekg[2]:slice(1, i - 1):sort(), ekg[3]:slice(1, i - 1):sort()) then - print($"\nEKG(5) and EKG(7) converge at term {i}.") - os.exit() - end -end -print($"\nEKG5(5) and EKG(7) do not converge within {limit} terms.") diff --git a/Task/EKG-sequence-convergence/Rust/ekg-sequence-convergence.rs b/Task/EKG-sequence-convergence/Rust/ekg-sequence-convergence.rs deleted file mode 100644 index bae4e3df9c..0000000000 --- a/Task/EKG-sequence-convergence/Rust/ekg-sequence-convergence.rs +++ /dev/null @@ -1,34 +0,0 @@ -use gcd::Gcd; - -fn ekg_sequence(n: u64, limit: usize) -> Vec { - let mut ekg = [1_u64, n].to_vec(); - while ekg.len() < limit { - for i in 2..2<<18 { - if ekg.iter().all(|j| *j != i) && Gcd::gcd(ekg[ekg.len()-1], i) > 1 { - ekg.push(i); - break; - } - } - } - return ekg; -} - - -fn converge_at(n: u64, m: u64, tmax: usize) -> usize { - let a = ekg_sequence(n, tmax); - let b = ekg_sequence(m, tmax); - for i in 2..tmax { - if a[i] == b[i] && a[0..i+1].iter().sum::() == (b[0..i+1]).iter().sum::() { - return i + 1; - } - } - println!("Error: no convergence in {tmax} terms"); - return 0; -} - -fn main() { - for i in [2_u64, 5, 7, 9, 10] { - println!("EKG({i:2}): {:?}", ekg_sequence(i, 30_usize)); - } - println!("EKGs of 5 & 7 converge after term {:?}", converge_at(5, 7, 50)); -} diff --git a/Task/EKG-sequence-convergence/Wren/ekg-sequence-convergence.wren b/Task/EKG-sequence-convergence/Wren/ekg-sequence-convergence.wren index cea8792b48..959502e010 100644 --- a/Task/EKG-sequence-convergence/Wren/ekg-sequence-convergence.wren +++ b/Task/EKG-sequence-convergence/Wren/ekg-sequence-convergence.wren @@ -1,6 +1,6 @@ -import "./sort" for Sort -import "./math" for Int -import "./fmt" for Fmt +import "/sort" for Sort +import "/math" for Int +import "/fmt" for Fmt var areSame = Fn.new { |s, t| var le = s.count diff --git a/Task/Earliest-difference-between-prime-gaps/EasyLang/earliest-difference-between-prime-gaps.easy b/Task/Earliest-difference-between-prime-gaps/EasyLang/earliest-difference-between-prime-gaps.easy deleted file mode 100644 index c91415599e..0000000000 --- a/Task/Earliest-difference-between-prime-gaps/EasyLang/earliest-difference-between-prime-gaps.easy +++ /dev/null @@ -1,41 +0,0 @@ -fastfunc nextPrimeOdd n . - i = n + 2 - repeat - j = 3 - while j <= sqrt i and i mod j <> 0 - j += 2 - . - until j > sqrt i - i += 2 - . - return i -. -lastPrime = 3 -len gapStarts[] 1e7 -# -func findGapStart gap . - if gapStarts[gap] <> 0 : return gapStarts[gap] - repeat - prev = lastPrime - lastPrime = nextPrimeOdd lastPrime - diff = lastPrime - prev - if gapStarts[diff] = 0 : gapStarts[diff] = prev - until gap = diff - . - return prev -. -# -gap = 2 -pm = 10 -repeat - start1 = findGapStart gap - start2 = findGapStart (gap + 2) - diff = abs (start2 - start1) - if diff > pm - print "> " & pm & ": gaps " & gap & "/" & gap + 2 & " range " & start1 & "-" & start2 & " (" & diff & ")" - pm *= 10 - else - gap += 2 - . - until pm = 1e7 -. diff --git a/Task/Earliest-difference-between-prime-gaps/Free-Pascal-Lazarus/earliest-difference-between-prime-gaps.pas b/Task/Earliest-difference-between-prime-gaps/Free-Pascal/earliest-difference-between-prime-gaps.pas similarity index 100% rename from Task/Earliest-difference-between-prime-gaps/Free-Pascal-Lazarus/earliest-difference-between-prime-gaps.pas rename to Task/Earliest-difference-between-prime-gaps/Free-Pascal/earliest-difference-between-prime-gaps.pas diff --git a/Task/Earliest-difference-between-prime-gaps/FreeBASIC/earliest-difference-between-prime-gaps.basic b/Task/Earliest-difference-between-prime-gaps/FreeBASIC/earliest-difference-between-prime-gaps.basic deleted file mode 100644 index a20865e78c..0000000000 --- a/Task/Earliest-difference-between-prime-gaps/FreeBASIC/earliest-difference-between-prime-gaps.basic +++ /dev/null @@ -1,49 +0,0 @@ -Type PrimeGaps - As Ulong lastPrime - As Ulongint gapStarts(1 To 1e7) -End Type - -Function NextPrime(n As Ulong) As Ulong - Dim As Ulong j, i = n + 1 - Do - For j = 2 To Sqr(i) - If i Mod j = 0 Then Exit For - Next j - If j > Sqr(i) Then Return i - i += 1 - Loop -End Function - -Function findGapStart(Byref pg As PrimeGaps, gap As Ulongint) As Ulongint - Dim As Ulongint prev, diff - If pg.gapStarts(gap) <> 0 Then Return pg.gapStarts(gap) - Do - prev = pg.lastPrime - pg.lastPrime = NextPrime(pg.lastPrime) - diff = pg.lastPrime - prev - If pg.gapStarts(diff) = 0 Then pg.gapStarts(diff) = prev - If gap = diff Then Return prev - Loop -End Function - -Dim Shared As PrimeGaps pg -pg.lastPrime = NextPrime(2) -Dim As Ulongint limit = 1e7 -Dim As Integer pm = 10 -Dim As Ulongint start1, start2, gap1 = 2, gap2, diff -Do - start1 = findGapStart(pg, gap1) - gap2 = gap1 + 2 - start2 = findGapStart(pg, gap2) - diff = Abs(start2 - start1) - If diff > pm Then - Print "Earliest difference >"; pm; " between adjacent prime gap starting primes:" - Print "Gap "; gap1; " starts at "; start1; ", gap "; gap2; " starts at "; start2; ", difference is "; diff; !".\n" - If pm = limit Then Exit Do - pm *= 10 - Else - gap1 = gap2 - End If -Loop - -Sleep diff --git a/Task/Earliest-difference-between-prime-gaps/Jq/earliest-difference-between-prime-gaps.jq b/Task/Earliest-difference-between-prime-gaps/Jq/earliest-difference-between-prime-gaps.jq deleted file mode 100644 index 85f8ddcaec..0000000000 --- a/Task/Earliest-difference-between-prime-gaps/Jq/earliest-difference-between-prime-gaps.jq +++ /dev/null @@ -1,73 +0,0 @@ -# If $j is 0, then an error condition is raised; -# otherwise, assuming infinite-precision integer arithmetic, -# if the input and $j are integers, then the result will be an integer. -def idivide($j): - (. % $j) as $mod - | (. - $mod) / $j ; - -def properfactors: - . as $in - | [2, $in, false] - | recurse( - . as [$p, $q, $valid, $s] - | if $q == 1 then empty - elif $q % $p == 0 then [$p, ($q|idivide($p)), true] - elif $p == 2 then [3, $q, false, $s] - else ($s // ($q | sqrt)) as $s - | if ($p + 2) <= $s then [$p + 2, $q, false, $s] - else [$q, 1, true] - end - end ) - | if .[2] and .[0] != $in then .[0] else empty end ; - -def stream_of_primes: - 2, (range(3; infinite; 2) | if first(properfactors) // null then empty else . end); - -# Emit a sequence of objects {gap, p, previous} starting with -# {"gap":2,"p":5,"previous":3} -# {"gap":6,"p":29,"previous":23} -# The stream of .previous values corresponds to the OEIS sequence https://oeis.org/A000230 -# except that `gaps` starts with .previous equal to 3 because 5-3 is the first occurrence of 2. -def gaps: - foreach stream_of_primes as $p (null; - if . == null then { $p, next: 2 } - else (.next|tostring) as $next - | if .[$next] then .emit = .[$next] | del( .[$next] ) | .next += 2 else .emit = null end - | .emit2 = null - | ($p - .p) as $gap - | .previous = .p - | .p = $p - | if $gap < .next then . - else ($gap|tostring) as $s - | if $gap == .next then .emit2 = {$gap, p, previous} | .next += 2 | del( .[$s] ) - elif .[$s] then . - else .[$s] = {$gap, p, previous} - end - end - end; - if .emit then .emit else empty end, - if .emit2 then .emit2 else empty end - ); - -# Report $n results, one for each order of magnitude starting with 10 -def earliest_difference($n): - - def report($gap): - if (($gap.previous - .previous)|length) > .magnitude - then .emit += [del(.emit) + {p: $gap.previous}] - | .magnitude *= 10 - | report($gap) - else . - end; - - limit($n; - foreach gaps as $gap (null; - if . == null then {magnitude: 10, n:0, previous: $gap.previous } - else .emit = null - | .n += 1 - | report($gap) - | .previous = $gap.previous - end) - | select(.emit).emit[]); - -earliest_difference(7) diff --git a/Task/Earliest-difference-between-prime-gaps/Julia/earliest-difference-between-prime-gaps.jl b/Task/Earliest-difference-between-prime-gaps/Julia/earliest-difference-between-prime-gaps.julia similarity index 100% rename from Task/Earliest-difference-between-prime-gaps/Julia/earliest-difference-between-prime-gaps.jl rename to Task/Earliest-difference-between-prime-gaps/Julia/earliest-difference-between-prime-gaps.julia diff --git a/Task/Earliest-difference-between-prime-gaps/Phix/earliest-difference-between-prime-gaps.phix b/Task/Earliest-difference-between-prime-gaps/Phix/earliest-difference-between-prime-gaps.phix index 6db651adc0..330c9e14e2 100644 --- a/Task/Earliest-difference-between-prime-gaps/Phix/earliest-difference-between-prime-gaps.phix +++ b/Task/Earliest-difference-between-prime-gaps/Phix/earliest-difference-between-prime-gaps.phix @@ -1,33 +1,35 @@ -with javascript_semantics -constant limit = iff(platform()=JS?1e7:1e8), - gslim = 250 -sequence primes = get_primes_le(limit*4), - gapstarts = repeat(0,gslim) -for i=2 to length(primes) do - integer gap = primes[i]-primes[i-1] - if gapstarts[gap]=0 then - gapstarts[gap] = primes[i-1] - end if -end for +(phixonline)--> + with javascript_semantics + constant limit = iff(platform()=JS?1e7:1e8), + gslim = 250 + sequence primes = get_primes_le(limit*4), + gapstarts = repeat(0,gslim) + for i=2 to length(primes) do + integer gap = primes[i]-primes[i-1] + if gapstarts[gap]=0 then + gapstarts[gap] = primes[i-1] + end if + end for -integer pm = 10, gap1 = 2 -while true do - while gapstarts[gap1]=0 do gap1 += 2 end while - integer start1 = gapstarts[gap1], - gap2 = gap1 + 2 - if gapstarts[gap2]=0 then - gap1 = gap2 + 2 - else - integer start2 = gapstarts[gap2], - diff = abs(start2 - start1) - if diff>pm then - printf(1,"Earliest difference >%,d between adjacent prime gap starting primes:\n",{pm}) - printf(1,"Gap %d starts at %,d, gap %d starts at %,d, difference is %,d.\n\n", - {gap1, start1, gap2, start2, diff}) - if pm=limit then exit end if - pm *= 10 - else - gap1 = gap2 - end if - end if -end while + integer pm = 10, gap1 = 2 + while true do + while gapstarts[gap1]=0 do gap1 += 2 end while + integer start1 = gapstarts[gap1], + gap2 = gap1 + 2 + if gapstarts[gap2]=0 then + gap1 = gap2 + 2 + else + integer start2 = gapstarts[gap2], + diff = abs(start2 - start1) + if diff>pm then + printf(1,"Earliest difference >%,d between adjacent prime gap starting primes:\n",{pm}) + printf(1,"Gap %d starts at %,d, gap %d starts at %,d, difference is %,d.\n\n", + {gap1, start1, gap2, start2, diff}) + if pm=limit then exit end if + pm *= 10 + else + gap1 = gap2 + end if + end if + end while + + requires(64) + enum X, Y -- rational ec point + enum A, B, N, G, R -- elliptic curve parameters + -- also signature pair(A,B) -constant mxN = 1073741789 -- maximum modulus -constant mxr = 1073807325 -- max order G = mxN + 65536 -constant inf = -2147483647 -- symbolic infinity + constant mxN = 1073741789 -- maximum modulus + constant mxr = 1073807325 -- max order G = mxN + 65536 + constant inf = -2147483647 -- symbolic infinity -sequence e = {0,0,0,{0,0},0} -- single global curve -constant zerO = {inf,0} -- point at infinity zerO + sequence e = {0,0,0,{0,0},0} -- single global curve + constant zerO = {inf,0} -- point at infinity zerO -bool inverr -- impossible inverse mod N + bool inverr -- impossible inverse mod N -function exgcd(atom v, u) --- return mod(v^-1, u) -atom q, t, r = 0, s = 1 - if v<0 then v += u end if + function exgcd(atom v, u) + -- return mod(v^-1, u) + atom q, t, r = 0, s = 1 + if v<0 then v += u end if - while v do - q = floor(u/v) - t = u-q*v - u = v - v = t - t = r-q*s - r = s - s = t - end while + while v do + q = floor(u/v) + t = u-q*v + u = v + v = t + t = r-q*s + r = s + s = t + end while - if u!=1 then - printf(1," impossible inverse mod N, gcd = %d\n",{u}) - inverr = true - end if + if u!=1 then + printf(1," impossible inverse mod N, gcd = %d\n",{u}) + inverr = true + end if - return r -end function + return r + end function -function modn(atom a) --- return mod(a, N) - a = mod(a,e[N]) - if a<0 then a += e[N] end if - return a -end function + function modn(atom a) + -- return mod(a, N) + a = mod(a,e[N]) + if a<0 then a += e[N] end if + return a + end function -function modr(atom a) --- return mod(a, r) - a = mod(a,e[R]) - if a<0 then a += e[R] end if - return a -end function + function modr(atom a) + -- return mod(a, r) + a = mod(a,e[R]) + if a<0 then a += e[R] end if + return a + end function -function disc() --- return the discriminant of E - atom a = e[A], b = e[B], - c = 4*modn(a*modn(a*a)) - return modn(-16*(c+27*modn(b*b))) -end function + function disc() + -- return the discriminant of E + atom a = e[A], b = e[B], + c = 4*modn(a*modn(a*a)) + return modn(-16*(c+27*modn(b*b))) + end function -function isO(sequence p) --- return true if P = zerO - return (p[X]=inf and p[Y]=0) -end function + function isO(sequence p) + -- return true if P = zerO + return (p[X]=inf and p[Y]=0) + end function -function ison(sequence p) --- return true if P is on curve E - atom r = 0, s = 0 - if not isO(p) then - r = modn(e[B]+p[X]*modn(e[A]+p[X]*p[X])) - s = modn(p[Y]*p[Y]) - end if - return (r=s) -end function + function ison(sequence p) + -- return true if P is on curve E + atom r = 0, s = 0 + if not isO(p) then + r = modn(e[B]+p[X]*modn(e[A]+p[X]*p[X])) + s = modn(p[Y]*p[Y]) + end if + return (r=s) + end function -procedure pprint(string f, sequence p) --- print point P with prefix f - if isO(p) then - printf(1,"%s (0)\n",{f}) - else - atom y = p[Y] - if y>e[N]-y then y -= e[N] end if - printf(1,"%s (%d,%d)\n",{f,p[X],y}) - end if -end procedure + procedure pprint(string f, sequence p) + -- print point P with prefix f + if isO(p) then + printf(1,"%s (0)\n",{f}) + else + atom y = p[Y] + if y>e[N]-y then y -= e[N] end if + printf(1,"%s (%d,%d)\n",{f,p[X],y}) + end if + end procedure -function padd(sequence p, q) --- full ec point addition -atom la, t + function padd(sequence p, q) + -- full ec point addition + atom la, t - if isO(p) then return q end if - if isO(q) then return p end if + if isO(p) then return q end if + if isO(q) then return p end if - if p[X]!=q[X] then -- R := P + Q - t = p[Y]-q[Y] - la = modn(t*exgcd(p[X]-q[X], e[N])) + if p[X]!=q[X] then -- R := P + Q + t = p[Y]-q[Y] + la = modn(t*exgcd(p[X]-q[X], e[N])) - else -- P = Q, R := 2P - if (p[Y]=q[Y]) and (p[Y]!=0) then - t = modn(3*modn(p[X]*p[X])+e[A]) - la = modn(t*exgcd(2*p[Y], e[N])) - else - return zerO -- P = -Q, R := O - end if - end if + else -- P = Q, R := 2P + if (p[Y]=q[Y]) and (p[Y]!=0) then + t = modn(3*modn(p[X]*p[X])+e[A]) + la = modn(t*exgcd(2*p[Y], e[N])) + else + return zerO -- P = -Q, R := O + end if + end if - t = modn(la*la-p[X]-q[X]) - sequence r = deep_copy(zerO) - r[Y] = modn(la*(p[X]-t)-p[Y]) - r[X] = t - if inverr then r = zerO end if - return r -end function + t = modn(la*la-p[X]-q[X]) + sequence r = deep_copy(zerO) + r[Y] = modn(la*(p[X]-t)-p[Y]) + r[X] = t + if inverr then r = zerO end if + return r + end function -function pmul(sequence p, atom k) --- R:= multiple kP - sequence s = zerO, q = p + function pmul(sequence p, atom k) + -- R:= multiple kP + sequence s = zerO, q = p - while k do - if and_bits(k,1) then - s = padd(s, q) - end if - if inverr then s = zerO; exit end if - k = floor(k/2) - q = padd(q, q) - end while - return s -end function + while k do + if and_bits(k,1) then + s = padd(s, q) + end if + if inverr then s = zerO; exit end if + k = floor(k/2) + q = padd(q, q) + end while + return s + end function -function ellinit(sequence i) --- initialize elliptic curve -atom a = i[1], b = i[2] - inverr = false - e[N] = i[3] + function ellinit(sequence i) + -- initialize elliptic curve + atom a = i[1], b = i[2] + inverr = false + e[N] = i[3] - if (e[N]<5) or (e[N]>mxN) then return 0 end if + if (e[N]<5) or (e[N]>mxN) then return 0 end if - e[A] = modn(a) - e[B] = modn(b) - e[G][X] = modn(i[4]) - e[G][Y] = modn(i[5]) - e[R] = i[6] + e[A] = modn(a) + e[B] = modn(b) + e[G][X] = modn(i[4]) + e[G][Y] = modn(i[5]) + e[R] = i[6] - if (e[R]<5) or (e[R]>mxr) then return 0 end if + if (e[R]<5) or (e[R]>mxr) then return 0 end if - printf(1,"E: y^2 = x^3 + %dx + %d (mod %d)\n",{a,b,e[N]}) - pprint("base point G", e[G]) - printf(1,"order(G, E) = %d\n",{e[R]}) + printf(1,"E: y^2 = x^3 + %dx + %d (mod %d)\n",{a,b,e[N]}) + pprint("base point G", e[G]) + printf(1,"order(G, E) = %d\n",{e[R]}) - return -1 -end function + return -1 + end function -function signature(atom s, f) --- signature primitive -atom c, d, u, u1 -sequence V + function signature(atom s, f) + -- signature primitive + atom c, d, u, u1 + sequence V - printf(1,"signature computation\n") - while true do - while true do --- u = rand(e[R]-1) - u = 571533488 -- match FreeBASIC output --- u = 605163545 -- match C output - V = pmul(e[G], u) - c = modr(V[X]) - if c!=0 then exit end if - end while + printf(1,"signature computation\n") + while true do + while true do + -- u = rand(e[R]-1) + u = 571533488 -- match FreeBASIC output + -- u = 605163545 -- match C output + V = pmul(e[G], u) + c = modr(V[X]) + if c!=0 then exit end if + end while - u1 = exgcd(u, e[R]) - d = modr(u1*(f+modr(s*c))) - if d!=0 then exit end if - end while - printf(1,"one-time u = %d\n",u) - pprint("V = uG", V) - return {c,d} -end function + u1 = exgcd(u, e[R]) + d = modr(u1*(f+modr(s*c))) + if d!=0 then exit end if + end while + printf(1,"one-time u = %d\n",u) + pprint("V = uG", V) + return {c,d} + end function -function verify(sequence W, atom f, sequence sg) --- verification primitive -atom c = sg[A], d = sg[B], - t, c1, h1, h2, h -sequence V, V2 + function verify(sequence W, atom f, sequence sg) + -- verification primitive + atom c = sg[A], d = sg[B], + t, c1, h1, h2, h + sequence V, V2 - --domain check - t = (c>0) and (c0) and (d--domain check + t = (c>0) and (c<e[R]) + t = t and (d>0) and (d<e[R]) + if not t then return 0 end if - printf(1,"\nsignature verification\n") - h = exgcd(d, e[R]) - h1 = modr(f*h) - h2 = modr(c*h) - printf(1,"h1,h2 = %d,%d\n",{h1,h2}) - V = pmul(e[G], h1) - V2 = pmul(W, h2) - pprint("h1G", V) - pprint("h2W", V2) - V = padd(V, V2) - pprint("+ =", V) - if isO(V) then return 0 end if - c1 = modr(V[X]) - printf(1,"c' = %d\n",c1) + printf(1,"\nsignature verification\n") + h = exgcd(d, e[R]) + h1 = modr(f*h) + h2 = modr(c*h) + printf(1,"h1,h2 = %d,%d\n",{h1,h2}) + V = pmul(e[G], h1) + V2 = pmul(W, h2) + pprint("h1G", V) + pprint("h2W", V2) + V = padd(V, V2) + pprint("+ =", V) + if isO(V) then return 0 end if + c1 = modr(V[X]) + printf(1,"c' = %d\n",c1) - return (c1=c) -end function + return (c1=c) + end function -procedure errmsg() - printf(1,"invalid parameter set\n") - printf(1,"_____________________\n") -end procedure + procedure errmsg() + printf(1,"invalid parameter set\n") + printf(1,"_____________________\n") + end procedure -procedure ec_dsa(atom f, d) --- digital signature on message hash f, error bit d -atom i, s, t -sequence sg, W + procedure ec_dsa(atom f, d) + -- digital signature on message hash f, error bit d + atom i, s, t + sequence sg, W - --parameter check - t = (disc()=0) - t = t or isO(e[G]) - W = pmul(e[G], e[R]) - t = t or not isO(W) - t = t or not ison(e[G]) - if t then errmsg() return end if + --parameter check + t = (disc()=0) + t = t or isO(e[G]) + W = pmul(e[G], e[R]) + t = t or not isO(W) + t = t or not ison(e[G]) + if t then errmsg() return end if - puts(1,"\nkey generation\n") --- s = rand(e[R] - 1) - s = 509100772 -- match FreeBASIC output --- s = 1343570 -- match C output - W = pmul(e[G], s) - printf(1,"private key s = %d\n",{s}) - pprint("public key W = sG", W) + puts(1,"\nkey generation\n") + -- s = rand(e[R] - 1) + s = 509100772 -- match FreeBASIC output + -- s = 1343570 -- match C output + W = pmul(e[G], s) + printf(1,"private key s = %d\n",{s}) + pprint("public key W = sG", W) - --next highest power of 2 - 1 - t = e[R] - i = 1 - while i<32 do - t = or_bits(t,floor(t/power(2,i))) - i *= 2 - end while - while f>t do - f = floor(f/2) - end while - printf(1,"\naligned hash %x\n\n",{f}) + --next highest power of 2 - 1 + t = e[R] + i = 1 + while i<32 do + t = or_bits(t,floor(t/power(2,i))) + i *= 2 + end while + while f>t do + f = floor(f/2) + end while + printf(1,"\naligned hash %x\n\n",{f}) - sg = signature(s, f) - if inverr then errmsg() return end if - printf(1,"signature c,d = %d,%d\n",sg) + sg = signature(s, f) + if inverr then errmsg() return end if + printf(1,"signature c,d = %d,%d\n",sg) - if d>0 then - while d>t do - d = floor(d/2) - end while - f = xor_bits(f,d) - printf(1,"corrupted hash %x\n",{f}) - end if + if d>0 then + while d>t do + d = floor(d/2) + end while + f = xor_bits(f,d) + printf(1,"corrupted hash %x\n",{f}) + end if - t = verify(W, f, sg) - if inverr then errmsg() return end if - if t then - printf(1,"Valid\n_____\n") - else - printf(1,"invalid\n_______\n") - end if -end procedure + t = verify(W, f, sg) + if inverr then errmsg() return end if + if t then + printf(1,"Valid\n_____\n") + else + printf(1,"invalid\n_______\n") + end if + end procedure ---Test vectors: elliptic curve domain parameters, ---short Weierstrass model y^2 = x^3 + ax + b (mod N) + --Test vectors: elliptic curve domain parameters, + --short Weierstrass model y^2 = x^3 + ax + b (mod N) -constant tests = { --- a, b, modulus N, base point G, order(G, E), cofactor - {355, 671, 1073741789, 13693, 10088, 1073807281}, - { 0, 7, 67096021, 6580, 779, 16769911}, -- 4 - { -3, 1, 877073, 0, 1, 878159}, - { 0, 14, 22651, 63, 30, 151}, -- 151 - { 3, 2, 5, 2, 1, 5}, + constant tests = { + -- a, b, modulus N, base point G, order(G, E), cofactor + {355, 671, 1073741789, 13693, 10088, 1073807281}, + { 0, 7, 67096021, 6580, 779, 16769911}, -- 4 + { -3, 1, 877073, 0, 1, 878159}, + { 0, 14, 22651, 63, 30, 151}, -- 151 + { 3, 2, 5, 2, 1, 5}, - --ecdsa may fail if... - --the base point is of composite order - { 0, 7, 67096021, 2402, 6067, 33539822}, -- 2 - --the given order is a multiple of the true order - { 0, 7, 67096021, 6580, 779, 67079644}, -- 1 - --the modulus is not prime (deceptive example) - { 0, 7, 877069, 3, 97123, 877069}, - --fails if the modulus divides the discriminant - { 39, 387, 22651, 95, 27, 22651}} + --ecdsa may fail if... + --the base point is of composite order + { 0, 7, 67096021, 2402, 6067, 33539822}, -- 2 + --the given order is a multiple of the true order + { 0, 7, 67096021, 6580, 779, 67079644}, -- 1 + --the modulus is not prime (deceptive example) + { 0, 7, 877069, 3, 97123, 877069}, + --fails if the modulus divides the discriminant + { 39, 387, 22651, 95, 27, 22651}} ---Digital signature on message hash f, ---set d > 0 to simulate corrupted data -atom f = #789ABCDE, - d = 0 + --Digital signature on message hash f, + --set d > 0 to simulate corrupted data + atom f = #789ABCDE, + d = 0 ---for i=1 to length(tests) do -for i=1 to 1 do - if not ellinit(tests[i]) then exit end if - ec_dsa(f, d) -end for + --for i=1 to length(tests) do + for i=1 to 1 do + if not ellinit(tests[i]) then exit end if + ec_dsa(f, d) + end for + + with javascript_semantics + constant X=1, Y=2, bCoeff=7, INF = 1e300*1e300 -type point(object pt) - return sequence(pt) and length(pt)=2 and atom(pt[X]) and atom(pt[Y]) -end type + type point(object pt) + return sequence(pt) and length(pt)=2 and atom(pt[X]) and atom(pt[Y]) + end type -function zero() - point pt = {INF, INF} - return pt -end function + function zero() + point pt = {INF, INF} + return pt + end function -function is_zero(point p) - return p[X]>1e20 or p[X]<-1e20 -end function + function is_zero(point p) + return p[X]>1e20 or p[X]<-1e20 + end function -function neg(point p) - p = {p[X], -p[Y]} - return p -end function + function neg(point p) + p = {p[X], -p[Y]} + return p + end function -function dbl(point p) - point r = p - if not is_zero(p) then - atom L = (3*p[X]*p[X])/(2*p[Y]) - atom x = L*L-2*p[X] - r = {x, L*(p[X]-x)-p[Y]} - end if - return r -end function + function dbl(point p) + point r = p + if not is_zero(p) then + atom L = (3*p[X]*p[X])/(2*p[Y]) + atom x = L*L-2*p[X] + r = {x, L*(p[X]-x)-p[Y]} + end if + return r + end function -function add(point p, point q) - if p==q then return dbl(p) end if - if is_zero(p) then return q end if - if is_zero(q) then return p end if - atom L = (q[Y]-p[Y])/(q[X]-p[X]) - atom x = L*L-p[X]-q[X] - point r = {x, L*(p[X]-x)-p[Y]} - return r -end function + function add(point p, point q) + if p==q then return dbl(p) end if + if is_zero(p) then return q end if + if is_zero(q) then return p end if + atom L = (q[Y]-p[Y])/(q[X]-p[X]) + atom x = L*L-p[X]-q[X] + point r = {x, L*(p[X]-x)-p[Y]} + return r + end function -function mul(point p, integer n) - point r = zero() - integer i = 1 - while i<=n do - if and_bits(i, n) then r = add(r, p) end if - p = dbl(p) - i = i*2 - end while - return r -end function + function mul(point p, integer n) + point r = zero() + integer i = 1 + while i<=n do + if and_bits(i, n) then r = add(r, p) end if + p = dbl(p) + i = i*2 + end while + return r + end function -procedure show(string s, point p) - puts(1, s&iff(is_zero(p)?"Zero\n":sprintf("(%.3f, %.3f)\n", p))) -end procedure + procedure show(string s, point p) + puts(1, s&iff(is_zero(p)?"Zero\n":sprintf("(%.3f, %.3f)\n", p))) + end procedure -function cbrt(atom c) - return iff(c>=0?power(c,1/3):-power(-c,1/3)) -end function + function cbrt(atom c) + return iff(c>=0?power(c,1/3):-power(-c,1/3)) + end function -function from_y(atom y) - point r = {cbrt(y*y-bCoeff), y} - return r -end function + function from_y(atom y) + point r = {cbrt(y*y-bCoeff), y} + return r + end function -point a, b, c, d + point a, b, c, d -a = from_y(1) -b = from_y(2) -c = add(a, b) -d = neg(c) + a = from_y(1) + b = from_y(2) + c = add(a, b) + d = neg(c) -show("a = ", a) -show("b = ", b) -show("c = a + b = ", c) -show("d = -c = ", d) -show("c + d = ", add(c, d)) -show("a + b + d = ", add(a, add(b, d))) -show("a * 12345 = ", mul(a, 12345)) + show("a = ", a) + show("b = ", b) + show("c = a + b = ", c) + show("d = -c = ", d) + show("c + d = ", add(c, d)) + show("a + b + d = ", add(a, add(b, d))) + show("a * 12345 = ", mul(a, 12345)) + + with javascript_semantics + sequence emirps = {} -function rev(integer n) - integer res = 0 - while n do - res = res*10+remainder(n,10) - n = floor(n/10) - end while - return res -end function + function rev(integer n) + integer res = 0 + while n do + res = res*10+remainder(n,10) + n = floor(n/10) + end while + return res + end function -function emirp(integer n) - if is_prime(n) then - integer r = rev(n) - if r!=n and is_prime(r) then - return true - end if - end if - return false -end function + function emirp(integer n) + if is_prime(n) then + integer r = rev(n) + if r!=n and is_prime(r) then + return true + end if + end if + return false + end function -procedure usage() - printf(1,"use a single command line argument, with no spaces, eg \"1-20\" (first 20), \n") - printf(1,"\"7700..8000\" (between 7700 and 8000), or \"10000\" (the 10,000th).\n") - {} = wait_key() - abort(0) -end procedure + procedure usage() + printf(1,"use a single command line argument, with no spaces, eg \"1-20\" (first 20), \n") + printf(1,"\"7700..8000\" (between 7700 and 8000), or \"10000\" (the 10,000th).\n") + {} = wait_key() + abort(0) + end procedure -procedure main(string arg3) - sequence args - integer n,m - emirps = {} - if find('-',arg3) then -- nth to mth emirp range - args = scanf(arg3,"%d-%d") - if length(args)!=1 then usage() end if - {{n,m}} = args - integer k = 1 - while length(emirps)n then - for j=i to length(emirps) do - if emirps[j]>m then - printf(1,"emirps between %d and %d: %v\n",{n,m,emirps[i..j-1]}) - exit - end if - end for - exit - end if - end for - else -- nth emirp - args = scanf(arg3,"%d") - if length(args)!=1 then usage() end if - {{n}} = args - integer k = 1 - while length(emirps)procedure main(string arg3) + sequence args + integer n,m + if find('-',arg3) then -- nth to mth emirp range + args = scanf(arg3,"%d-%d") + if length(args)!=1 then usage() end if + {{n,m}} = args + integer k = 1 + while length(emirps)<m do + if emirp(k) then emirps &= k end if + k += 1 + end while + printf(1,"emirps %d to %d: %v\n",{n,m,emirps[n..m]}) + elsif match("..",arg3) then -- emirps between n amd m + args = scanf(arg3,"%d..%d") + if length(args)!=1 then usage() end if + {{n,m}} = args + integer k = 1 + while length(emirps)=0 or emirps[$]<m do + if emirp(k) then emirps &= k end if + k += 1 + end while + sequence s = {} + for i=1 to length(emirps) do + if emirps[i]>n then + for j=i to length(emirps) do + if emirps[j]>m then + printf(1,"emirps between %d and %d: %v\n",{n,m,emirps[i..j-1]}) + exit + end if + end for + exit + end if + end for + else -- nth emirp + args = scanf(arg3,"%d") + if length(args)!=1 then usage() end if + {{n}} = args + integer k = 1 + while length(emirps)<n do + if emirp(k) then emirps &= k end if + k += 1 + end while + printf(1,"emirp %d: %d\n",{n,emirps[n]}) + end if + end procedure -sequence cl = command_line() -if length(cl)=2 then - main("1-20") - main("7700..8000") - main("10000") -elsif length(cl)=3 then - main(cl[3]) -else - usage() -end if + sequence cl = command_line() + if length(cl)=2 then + main("1-20") + main("7700..8000") + main("10000") + elsif length(cl)=3 then + main(cl[3]) + else + usage() + end if + + without js -- command_line, file i/o + function entropy(sequence s) + sequence symbols = {}, + counts = {} + integer N = length(s) + for i=1 to N do + object si = s[i] + integer k = find(si,symbols) + if k=0 then + symbols = append(symbols,si) + counts = append(counts,1) + else + counts[k] += 1 + end if + end for + atom H = 0 + for i=1 to length(counts) do + atom ci = counts[i]/N + H -= ci*log2(ci) + end for + return H + end function -?entropy(get_text(open(substitute(command_line()[2],".exe",".exw")),"rb")) + ?entropy(get_text(open(substitute(command_line()[2],".exe",".exw")),"rb")) + + enum apple, banana, orange + enum apple=5, banana=10, orange= + + without js -- none such in a browser, that I know of + ?getenv("PATH") + + with javascript_semantics + atom t0 = time() + atom ps = 2, -- current prime sum + cs = 4 -- current composite sum + integer psn = 1, npi = 1, -- (see below) + csn = 1, nci = 3, nc = 4, ncp = 5, + found = 0 + constant limit = iff(platform()=JS?10:11) + while found<limit do + integer c = compare(ps,cs) -- {-1,0,+1} + if c=0 then + printf(1,"%,21d - %,10d%s prime sum, %,10d%s composite sum (%s)\n", + {ps, psn, ord(psn), csn, ord(csn), elapsed(time()-t0)}) + found += 1 + end if + if c<=0 then + psn += 1 -- prime sum number + npi += 1 -- next prime index + ps += get_prime(npi) + end if + if c>=0 then + csn += 1 -- composite sum number + nc += 1 -- next composite? + if nc=ncp then -- "", erm no + nci += 1 -- next prime index + ncp = get_prime(nci) + nc += 1 -- next composite (even!) + end if + cs += nc + end if + end while + $ ) - - [ stack ] is primecount ( --> s ) - [ stack ] is recentprime ( --> s ) - [ stack ] is primesum ( --> s ) - [ stack ] is compcount ( --> s ) - [ stack ] is recentcomp ( --> s ) - [ stack ] is compsum ( --> s ) - - [ recentprime take - [ 1+ dup isprime iff - [ 1 primecount tally - dup recentprime put - primesum tally ] - done - again ] ] is nextprime ( --> ) - - [ recentcomp take - [ 1+ dup isprime not iff - [ 1 compcount tally - dup recentcomp put - compsum tally ] - done - again ] ] is nextcomp ( --> ) - - 1 primecount put - 2 recentprime put - 2 primesum put - 1 compcount put - 4 recentcomp put - 4 compsum put - [] - [ primesum share - compsum share - 2dup > iff - [ 2drop nextcomp ] - again - < iff nextprime again - compsum share - primecount share - compcount share - join join nested join - dup size 7 < while - nextcomp - nextprime - again ] - primecount release - recentprime release - primesum release - compcount release - recentcomp release - compsum release - say " sum prime composite" cr - witheach - [ witheach - [ 11 r-echo ] - cr ] diff --git a/Task/Equal-prime-and-composite-sums/Unicon/equal-prime-and-composite-sums.unicon b/Task/Equal-prime-and-composite-sums/Unicon/equal-prime-and-composite-sums.unicon deleted file mode 100644 index 688c70829d..0000000000 --- a/Task/Equal-prime-and-composite-sums/Unicon/equal-prime-and-composite-sums.unicon +++ /dev/null @@ -1,28 +0,0 @@ -link fastprime -global pidx, cidx - -procedure main(A) - limit := \A[1] | 6 - c1 := create sumprime() - c2 := create sumcomp() - - (cnt := 0, sump := @c1, sumc := @c2) - while cnt < limit do { - if (sump = sumc) then (cnt +:= 1, write("(",pidx,",",cidx,"): ",sump)) - (sump := @c1, sumc := @c2) - while (sump < sumc, sump := @c1) - while (sumc < sump, sumc := @c2) - } -end - -procedure sumprime() -static sum -initial (sum := 0, pidx := 0) - every (sum +:= genprimes(), pidx +:= 1) do suspend sum -end - -procedure sumcomp() -static sum -initial (sum := 0, cidx := 0) - every n := seq(3) do if (not is_prime(n), cidx +:=1) then suspend sum +:= n -end diff --git a/Task/Equal-prime-and-composite-sums/Wren/equal-prime-and-composite-sums.wren b/Task/Equal-prime-and-composite-sums/Wren/equal-prime-and-composite-sums.wren index 7a8f1a53f0..ac2ee2dddc 100644 --- a/Task/Equal-prime-and-composite-sums/Wren/equal-prime-and-composite-sums.wren +++ b/Task/Equal-prime-and-composite-sums/Wren/equal-prime-and-composite-sums.wren @@ -1,6 +1,6 @@ import "./math" for Int import "./sort" for Find -import "./fmt" for Fmt +import "/fmt" for Fmt var limit = 4 * 1e8 var c = Int.primeSieve(limit - 1, false) diff --git a/Task/Equal-prime-and-composite-sums/Yabasic/equal-prime-and-composite-sums.basic b/Task/Equal-prime-and-composite-sums/Yabasic/equal-prime-and-composite-sums.basic deleted file mode 100644 index 39840f0362..0000000000 --- a/Task/Equal-prime-and-composite-sums/Yabasic/equal-prime-and-composite-sums.basic +++ /dev/null @@ -1,35 +0,0 @@ -//import isprime - -i = 0 -IndN = 1 : IndM = 1 -NumP = 2 : NumC = 4 -SumP = 2 : SumC = 4 -print " sum prime sum composite sum" -do - if SumC > SumP then - repeat - NumP = NumP + 1 - until isPrime(NumP) - SumP = SumP + NumP - IndN = IndN + 1 - fi - if SumP > SumC then - repeat - NumC = NumC + 1 - until not isPrime(NumC) - SumC = SumC + NumC - IndM = IndM + 1 - fi - if SumP = SumC then - print SumP using ("##,###,###,###,###"), " - ", IndN using ("##,###,###"), " - ", IndM using ("##,###,###") - i = i + 1 - if i >= 9 break - repeat - NumC = NumC + 1 - until not isPrime(NumC) - SumC = SumC + NumC - IndM = IndM + 1 - fi -loop -print -end diff --git a/Task/Equilibrium-index/ANSI-BASIC/equilibrium-index.basic b/Task/Equilibrium-index/ANSI-BASIC/equilibrium-index.basic deleted file mode 100644 index 3cdf6ceee4..0000000000 --- a/Task/Equilibrium-index/ANSI-BASIC/equilibrium-index.basic +++ /dev/null @@ -1,85 +0,0 @@ -100 REM Equilibrium index -110 DECLARE EXTERNAL SUB PrintArray -120 DECLARE EXTERNAL SUB PrintIndicesOfTrue -130 DECLARE EXTERNAL SUB GetIndices -140 DIM X1(0 TO 6), X1Result(0 TO 6) -150 FOR I = 0 TO 6 -160 READ X1(I) -170 NEXT I -180 DATA -7, 1, 5, 2, -4, 3, 0 -190 CALL GetIndices(X1, X1Result) -200 DIM X2(0 TO 2), X2Result(0 TO 2) -210 FOR I = 0 TO 2 -220 READ X2(I) -230 NEXT I -240 DATA 2, 4, 6 -250 CALL GetIndices(X2, X2Result) -260 DIM X3(0 TO 2), X3Result(0 TO 2) -270 FOR I = 0 TO 2 -280 READ X3(I) -290 NEXT I -300 DATA 2, 9, 2 -310 CALL GetIndices(X3, X3Result) -320 DIM X4(0 TO 6), X4Result(0 TO 6) -330 FOR I = 0 TO 6 -340 READ X4(I) -350 NEXT I -360 DATA 1, -1, 1, -1, 1 ,-1, 1 -370 CALL GetIndices(X4, X4Result) -380 PRINT "Results:" -390 PRINT -400 PRINT "X1:"; -410 CALL PrintArray(X1, 1) -420 PRINT "Eqs:"; -430 CALL PrintIndicesOfTrue(X1Result, 1) -440 PRINT -450 PRINT "X2:"; -460 CALL PrintArray(X2, 1) -470 PRINT "Eqs:"; -480 CALL PrintIndicesOfTrue(X2Result, 1) -490 PRINT -500 PRINT "X3:"; -510 CALL PrintArray(X3, 1) -520 PRINT "Eqs:"; -530 CALL PrintIndicesOfTrue(X3Result, 1) -540 PRINT -550 PRINT "X4:"; -560 CALL PrintArray(X4, 1) -570 PRINT "Eqs:"; -580 CALL PrintIndicesOfTrue(X4Result, 1) -590 END -600 ! -610 EXTERNAL SUB PrintArray(Nums(), NL) -620 FOR I = LBOUND(Nums) TO UBOUND(Nums) -630 PRINT Nums(I); -640 NEXT I -650 IF NL <> 0 THEN PRINT -660 END SUB -670 ! -680 EXTERNAL SUB PrintIndicesOfTrue(Bools(), NL) -690 FOR I = LBOUND(Bools) TO UBOUND(Bools) -700 IF Bools(I) <> 0 THEN PRINT I; -710 NEXT I -720 IF NL <> 0 THEN PRINT -730 END SUB -740 ! -750 EXTERNAL SUB GetIndices(Nums(), Result()) -760 IF (LBOUND(Nums) <> LBOUND(Result)) OR (UBOUND(Nums) <> UBOUND(Result)) THEN -770 PRINT "Range of indices in both arrays should be the same" -780 STOP -790 END IF -800 LET LeftSum = 0 -810 LET RightSum = 0 -820 FOR I = LBOUND(Nums) TO UBOUND(Nums) -830 LET RightSum = RightSum + Nums (I) -840 NEXT I -850 FOR I = LBOUND(Nums) TO UBOUND(Nums) -860 LET RightSum = RightSum - Nums (I) -870 IF LeftSum = RightSum THEN -880 LET Result(I) = 1 -890 ELSE -900 LET Result(I) = 0 -910 END IF -920 LET LeftSum = LeftSum + Nums(I) -930 NEXT I -940 END SUB diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-1.adb b/Task/Equilibrium-index/Ada/equilibrium-index-1.ada similarity index 100% rename from Task/Equilibrium-index/Ada/equilibrium-index-1.adb rename to Task/Equilibrium-index/Ada/equilibrium-index-1.ada diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-2.adb b/Task/Equilibrium-index/Ada/equilibrium-index-2.ada similarity index 100% rename from Task/Equilibrium-index/Ada/equilibrium-index-2.adb rename to Task/Equilibrium-index/Ada/equilibrium-index-2.ada diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-3.adb b/Task/Equilibrium-index/Ada/equilibrium-index-3.ada similarity index 100% rename from Task/Equilibrium-index/Ada/equilibrium-index-3.adb rename to Task/Equilibrium-index/Ada/equilibrium-index-3.ada diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-4.adb b/Task/Equilibrium-index/Ada/equilibrium-index-4.ada similarity index 100% rename from Task/Equilibrium-index/Ada/equilibrium-index-4.adb rename to Task/Equilibrium-index/Ada/equilibrium-index-4.ada diff --git a/Task/Equilibrium-index/Arturo/equilibrium-index.arturo b/Task/Equilibrium-index/Arturo/equilibrium-index.arturo index 6dd2750e1c..624287eca3 100644 --- a/Task/Equilibrium-index/Arturo/equilibrium-index.arturo +++ b/Task/Equilibrium-index/Arturo/equilibrium-index.arturo @@ -2,7 +2,7 @@ eqIndex: function [row][ suml: 0 delayed: 0 sumr: sum row - result: [] + result: new [] loop.with:'i row 'r [ suml: suml + delayed sumr: sumr - r diff --git a/Task/Equilibrium-index/Crystal/equilibrium-index.cr b/Task/Equilibrium-index/Crystal/equilibrium-index.cr deleted file mode 100644 index aa9d7e4716..0000000000 --- a/Task/Equilibrium-index/Crystal/equilibrium-index.cr +++ /dev/null @@ -1,15 +0,0 @@ -def equilibrium_indices (arr) - left = 0 - right = arr.sum - indices = [] of Int32 - (0...arr.size).each do |i| - right -= arr[i] - indices << i if left == right - left += arr[i] - end - indices -end - -[[-7, 1, 5, 2, -4, 3, 0], [2, 4, 6], [2, 9, 2], [1,-1, 1,-1, 1,-1, 1]].each do |arr| - print arr, ": ", equilibrium_indices(arr), "\n" -end diff --git a/Task/Equilibrium-index/DuckDB/equilibrium-index.duckdb b/Task/Equilibrium-index/DuckDB/equilibrium-index.duckdb deleted file mode 100644 index 1ff1e8357e..0000000000 --- a/Task/Equilibrium-index/DuckDB/equilibrium-index.duckdb +++ /dev/null @@ -1,15 +0,0 @@ -create or replace function equilibrium_indices(lst) as table ( - with recursive cte as ( - select 0 as ix, 0 as before, 0 as pivotor, list_sum(lst) as after - union all - select ix+1, - before+pivotor, - lst[ix+1], - after - lst[ix+1] - from cte - where ix0 -); diff --git a/Task/Equilibrium-index/EasyLang/equilibrium-index.easy b/Task/Equilibrium-index/EasyLang/equilibrium-index.easy deleted file mode 100644 index 9308a64972..0000000000 --- a/Task/Equilibrium-index/EasyLang/equilibrium-index.easy +++ /dev/null @@ -1,10 +0,0 @@ -func[] equind a[] . - for v in a[] : sumr += v - for i to len a[] - sumr -= a[i] - if suml = sumr : r[] &= i - suml += a[i] - . - return r[] -. -print equind [ -7 1 5 2 -4 3 0 ] diff --git a/Task/Equilibrium-index/Elena/equilibrium-index.elena b/Task/Equilibrium-index/Elena/equilibrium-index.elena index f5baa94494..874de88bda 100644 --- a/Task/Equilibrium-index/Elena/equilibrium-index.elena +++ b/Task/Equilibrium-index/Elena/equilibrium-index.elena @@ -29,7 +29,7 @@ class EquilibriumEnumerator : Enumerator while(en.next()) { - var element := *en; + var element := en.get(); right -= element; bool found := (left == right); left += element; @@ -56,13 +56,13 @@ class EquilibriumEnumerator : Enumerator en.reset(); } - get Value() = index; + get() = index; enumerable() => en; } -public Program() +public program() { EquilibriumEnumerator.new(new int[]{ -7, 1, 5, 2, -4, 3, 0 }) - .forEach(PrintingLn) + .forEach:printingLn } diff --git a/Task/Equilibrium-index/Elixir/equilibrium-index-1.ex b/Task/Equilibrium-index/Elixir/equilibrium-index-1.elixir similarity index 100% rename from Task/Equilibrium-index/Elixir/equilibrium-index-1.ex rename to Task/Equilibrium-index/Elixir/equilibrium-index-1.elixir diff --git a/Task/Equilibrium-index/Elixir/equilibrium-index-2.ex b/Task/Equilibrium-index/Elixir/equilibrium-index-2.elixir similarity index 100% rename from Task/Equilibrium-index/Elixir/equilibrium-index-2.ex rename to Task/Equilibrium-index/Elixir/equilibrium-index-2.elixir diff --git a/Task/Equilibrium-index/Elixir/equilibrium-index-3.ex b/Task/Equilibrium-index/Elixir/equilibrium-index-3.elixir similarity index 100% rename from Task/Equilibrium-index/Elixir/equilibrium-index-3.ex rename to Task/Equilibrium-index/Elixir/equilibrium-index-3.elixir diff --git a/Task/Equilibrium-index/Euphoria/equilibrium-index.eu b/Task/Equilibrium-index/Euphoria/equilibrium-index.euphoria similarity index 100% rename from Task/Equilibrium-index/Euphoria/equilibrium-index.eu rename to Task/Equilibrium-index/Euphoria/equilibrium-index.euphoria diff --git a/Task/Equilibrium-index/FutureBasic/equilibrium-index.basic b/Task/Equilibrium-index/FutureBasic/equilibrium-index.basic deleted file mode 100644 index e187317767..0000000000 --- a/Task/Equilibrium-index/FutureBasic/equilibrium-index.basic +++ /dev/null @@ -1,27 +0,0 @@ -CFArrayRef local fn EquilibriumIndexes( arr as CFArrayRef ) - NSInteger count = len(arr) - if ( count == 0 ) then return @[] - - CFNumberRef sumLeft = @0, sumRight, sumAll = fn ObjectValueForKeyPath( arr, @"@sum.self" ) - CFMutableArrayRef result = fn MutableArrayNew - for NSUInteger i = 0 to count - 1 - CFNumberRef currVal = arr[i] - sumRight = @(dblval(sumAll) - dblval(sumLeft) - dblval(currVal)) - if ( fn NumberIsEqual( sumLeft, sumRight ) ) - MutableArrayAddObject( result, @(i) ) - end if - sumLeft = @(dblval(sumLeft) + dblval(currVal)) - next -end fn = result - -void local fn DoIt - CFArrayRef arr = @[@(-7), @1, @5, @2, @(-4), @3, @0] - - CFArrayRef eqIndexes = fn EquilibriumIndexes( arr ) - - printf @"Equilibrium indexes of [%@]: [%@]",fn ArrayComponentsJoinedByString( arr, @", " ) ,fn ArrayComponentsJoinedByString( eqIndexes, @", " ) -end fn - -fn DoIt - -HandleEvents diff --git a/Task/Equilibrium-index/Julia/equilibrium-index.jl b/Task/Equilibrium-index/Julia/equilibrium-index.jl deleted file mode 100644 index cc3b137d7b..0000000000 --- a/Task/Equilibrium-index/Julia/equilibrium-index.jl +++ /dev/null @@ -1,17 +0,0 @@ -function equindex2pass(data::Array) - rst = Int[] - suml, sumr, ddelayed = 0, sum(data), 0 - for (i, d) in enumerate(data) - suml += ddelayed - sumr -= d - ddelayed = d - if suml == sumr - push!(rst, i) - end - end - return rst -end - -@show equindex2pass([1, -1, 1, -1, 1, -1, 1]) -@show equindex2pass([1, 2, 2, 1]) -@show equindex2pass([-7, 1, 5, 2, -4, 3, 0]) diff --git a/Task/Equilibrium-index/Julia/equilibrium-index.julia b/Task/Equilibrium-index/Julia/equilibrium-index.julia new file mode 100644 index 0000000000..aeb11cadc0 --- /dev/null +++ b/Task/Equilibrium-index/Julia/equilibrium-index.julia @@ -0,0 +1,17 @@ +function equindex2pass(data::Array) + rst = Vector{Int}(0) + suml, sumr, ddelayed = 0, sum(data), 0 + for (i, d) in enumerate(data) + suml += ddelayed + sumr -= d + ddelayed = d + if suml == sumr + push!(rst, i) + end + end + return rst +end + +@show equindex2pass([1, -1, 1, -1, 1, -1, 1]) +@show equindex2pass([1, 2, 2, 1]) +@show equindex2pass([-7, 1, 5, 2, -4, 3, 0]) diff --git a/Task/Equilibrium-index/Kotlin/equilibrium-index.kotlin b/Task/Equilibrium-index/Kotlin/equilibrium-index.kotlin new file mode 100644 index 0000000000..5b629c3c9d --- /dev/null +++ b/Task/Equilibrium-index/Kotlin/equilibrium-index.kotlin @@ -0,0 +1,25 @@ +// version 1.1 + +fun equilibriumIndices(a: IntArray): MutableList { + val ei = mutableListOf() + if (a.isEmpty()) return ei // empty list + val sumAll = a.sumBy { it } + var sumLeft = 0 + var sumRight: Int + for (i in 0 until a.size) { + sumRight = sumAll - sumLeft - a[i] + if (sumLeft == sumRight) ei.add(i) + sumLeft += a[i] + } + return ei +} + +fun main(args: Array) { + val a = intArrayOf(-7, 1, 5, 2, -4, 3, 0) + val ei = equilibriumIndices(a) + when (ei.size) { + 0 -> println("There are no equilibrium indices") + 1 -> println("The only equilibrium index is : ${ei[0]}") + else -> println("The equilibrium indices are : ${ei.joinToString(", ")}") + } +} diff --git a/Task/Equilibrium-index/Kotlin/equilibrium-index.kts b/Task/Equilibrium-index/Kotlin/equilibrium-index.kts deleted file mode 100644 index 192d329198..0000000000 --- a/Task/Equilibrium-index/Kotlin/equilibrium-index.kts +++ /dev/null @@ -1,25 +0,0 @@ -// version 1.1 - -fun equilibriumIndices(a: IntArray): MutableList { - val ei = mutableListOf() - if (a.isEmpty()) return ei // empty list - val sumAll = a.sumOf { it } - var sumLeft = 0 - var sumRight: Int - for (i in 0 until a.size) { - sumRight = sumAll - sumLeft - a[i] - if (sumLeft == sumRight) ei.add(i) - sumLeft += a[i] - } - return ei -} - -fun main(args: Array) { - val a = intArrayOf(-7, 1, 5, 2, -4, 3, 0) - val ei = equilibriumIndices(a) - when (ei.size) { - 0 -> println("There are no equilibrium indices") - 1 -> println("The only equilibrium index is : ${ei[0]}") - else -> println("The equilibrium indices are : ${ei.joinToString(", ")}") - } -} diff --git a/Task/Equilibrium-index/Loglan82/equilibrium-index.loglan82 b/Task/Equilibrium-index/Loglan82/equilibrium-index.loglan82 deleted file mode 100644 index 3be605e218..0000000000 --- a/Task/Equilibrium-index/Loglan82/equilibrium-index.loglan82 +++ /dev/null @@ -1,88 +0,0 @@ -program equilibrium; -(* Equilibrium index *) - -var - x1, x2, x3, x4: arrayof integer, - x1_eqs, x2_eqs, x3_eqs, x4_eqs: arrayof boolean; - - unit write_array: procedure (nums: arrayof integer; nl: boolean); - var - i: integer; - begin - for i := lower(nums) to upper(nums) - do - write(nums(i): 1, " ") - od; - if nl then writeln fi - end write_array; - - unit write_inds_of_true: procedure (bools: arrayof boolean; nl: boolean); - var - i: integer; - begin - for i := lower(bools) to upper(bools) - do - if bools(i) then write(i: 1, " ") fi; - od; - if nl then writeln fi - end write_inds_of_true; - - unit get_inds: procedure (nums: arrayof integer; bools: arrayof boolean); - var - left_sum, right_sum: integer, - i: integer; - begin - left_sum, right_sum := 0; - for i := lower(nums) to upper(nums) - do - right_sum := right_sum + nums(i) - od; - for i := lower(nums) to upper(nums) - do - right_sum := right_sum - nums(i); - bools(i) := (left_sum = right_sum); - left_sum := left_sum + nums(i); - od - end get_inds; - -begin - array x1 dim (0 : 6); - array x1_eqs dim (0 : 6); - x1(0) := -7; x1(1) := 1; x1(2) := 5; x1(3) := 2; - x1(4) := -4; x1(5) := 3; x1(6) := 0; - call get_inds(x1, x1_eqs); - array x2 dim (0 : 2); - array x2_eqs dim (0 : 2); - x2(0) := 2; x2(1) := 4; x2(2) := 6; - call get_inds(x2, x2_eqs); - array x3 dim (0 : 2); - array x3_eqs dim (0 : 2); - x3(0) := 2; x3(1) := 9; x3(2) := 2; - call get_inds(x3, x3_eqs); - array x4 dim (0 : 6); - array x4_eqs dim (0 : 6); - x4(0) := 1; x4(1) := -1; x4(2) := 1; x4(3) := -1; - x4(4) := 1; x4(5) := -1; x4(6) := 1; - call get_inds(x4, x4_eqs); - writeln("Results:"); - writeln; - write("X1: "); - call write_array(x1, true); - write("Eqs: "); - call write_inds_of_true(x1_eqs, true); - writeln; - write("X2: "); - call write_array(x2, true); - write("Eqs: "); - call write_inds_of_true(x2_eqs, true); - writeln; - write("X3: "); - call write_array(x3, true); - write("Eqs: "); - call write_inds_of_true(x3_eqs, true); - writeln; - write("X4: "); - call write_array(x4, true); - write("Eqs: "); - call write_inds_of_true(x4_eqs, true); -end equilibrium. diff --git a/Task/Equilibrium-index/M2000-Interpreter/equilibrium-index.m2000 b/Task/Equilibrium-index/M2000-Interpreter/equilibrium-index.m2000 deleted file mode 100644 index c8824b1e31..0000000000 --- a/Task/Equilibrium-index/M2000-Interpreter/equilibrium-index.m2000 +++ /dev/null @@ -1,23 +0,0 @@ -Module Equilibrium_index{ - Function equilibriumIndices(a as tuple) { - flush ' empty stack of values - sum=a#sum() - b=each(a) - double sumleft, sumright - while b - sumright=sum-sumleft-array(b) - if sumleft=sumright then - data b^ ' put index to end of stack (used as FIFO) - end if - sumleft+=array(b) - end while - =array([]) - } - a=(-7, 1, 5, 2, -4, 3, 0) - b=equilibriumIndices(a)#str$() - Print "["+b+"]" - Print "["+equilibriumIndices((2, 4, 6))#str$()+"]" - Print "["+equilibriumIndices((2, 9, 2))#str$()+"]" - Print "["+equilibriumIndices((1, -1, 1, -1, 1, -1, 1))#str$()+"]" -} -Equilibrium_index diff --git a/Task/Equilibrium-index/Modula-2/equilibrium-index.mod2 b/Task/Equilibrium-index/Modula-2/equilibrium-index.mod2 deleted file mode 100644 index ec598413e4..0000000000 --- a/Task/Equilibrium-index/Modula-2/equilibrium-index.mod2 +++ /dev/null @@ -1,99 +0,0 @@ -MODULE Equilibrium; -(* Equilibrium index *) -FROM STextIO IMPORT - WriteLn, WriteString; -FROM SWholeIO IMPORT - WriteInt; - -TYPE - (* These types are for easier initialization in the main program.*) - TData7Items = ARRAY [0 .. 6] OF INTEGER; - TData3Items = ARRAY [0 .. 2] OF INTEGER; - -VAR - X1: TData7Items; - X1Eqs: ARRAY [0 .. 6] OF BOOLEAN; - X2: TData3Items; - X2Eqs: ARRAY [0 .. 2] OF BOOLEAN; - X3: TData3Items; - X3Eqs: ARRAY [0 .. 2] OF BOOLEAN; - X4: TData7Items; - X4Eqs: ARRAY [0 .. 6] OF BOOLEAN; - -PROCEDURE WriteArray(Nums: ARRAY OF INTEGER; NL: BOOLEAN); -VAR - I: CARDINAL; -BEGIN - FOR I := 0 TO HIGH(Nums) DO - WriteInt(Nums[I], 1); - WriteString(" ") - END; - IF NL THEN - WriteLn - END -END WriteArray; - -PROCEDURE WriteIndicesOfTrue(Bools: ARRAY OF BOOLEAN; NL: BOOLEAN); -VAR - I: CARDINAL; -BEGIN - FOR I := 0 TO HIGH(Bools) DO - IF Bools[I] THEN - WriteInt(I, 1); - WriteString(" ") - END; - END; - IF NL THEN - WriteLn - END -END WriteIndicesOfTrue; - -PROCEDURE GetIndices(Nums: ARRAY OF INTEGER; VAR OUT Result: ARRAY OF BOOLEAN); -VAR - LeftSum, RightSum: INTEGER; - I: CARDINAL; -BEGIN - LeftSum := 0; - RightSum := 0; - FOR I := 0 TO HIGH(Nums) DO - RightSum := RightSum + Nums[I] - END; - FOR I := 0 TO HIGH(Nums) DO - RightSum := RightSum - Nums[I]; - Result[I] := (LeftSum = RightSum); - LeftSum := LeftSum + Nums[I] - END; -END GetIndices; - -BEGIN - X1 := TData7Items{-7, 1, 5, 2, -4, 3, 0}; - GetIndices(X1, X1Eqs); - X2 := TData3Items{2, 4, 6}; - GetIndices(X2, X2Eqs); - X3 := TData3Items{2, 9, 2}; - GetIndices(X3, X3Eqs); - X4 := TData7Items{1, -1, 1, -1, 1 ,-1, 1}; - GetIndices(X4, X4Eqs); - WriteString("Results:"); - WriteLn; - WriteLn; - WriteString("X1: "); - WriteArray(X1, TRUE); - WriteString("Eqs: "); - WriteIndicesOfTrue(X1Eqs, TRUE); - WriteLn; - WriteString("X2: "); - WriteArray(X2, TRUE); - WriteString("Eqs: "); - WriteIndicesOfTrue(X2Eqs, TRUE); - WriteLn; - WriteString("X3: "); - WriteArray(X3, TRUE); - WriteString("Eqs: "); - WriteIndicesOfTrue(X3Eqs, TRUE); - WriteLn; - WriteString("X4: "); - WriteArray(X4, TRUE); - WriteString("Eqs: "); - WriteIndicesOfTrue(X4Eqs, TRUE); -END Equilibrium. diff --git a/Task/Equilibrium-index/OCaml/equilibrium-index.ml b/Task/Equilibrium-index/OCaml/equilibrium-index.ocaml similarity index 100% rename from Task/Equilibrium-index/OCaml/equilibrium-index.ml rename to Task/Equilibrium-index/OCaml/equilibrium-index.ocaml diff --git a/Task/Equilibrium-index/PascalABC.NET/equilibrium-index.pas b/Task/Equilibrium-index/PascalABC.NET/equilibrium-index.pas deleted file mode 100644 index b57a212dac..0000000000 --- a/Task/Equilibrium-index/PascalABC.NET/equilibrium-index.pas +++ /dev/null @@ -1,18 +0,0 @@ -## -function eqindex2Pass(data: array of integer): sequence of integer; -begin - var (suml, sumr, ddelayed) := (0, data.sum, 0); - foreach var d in data index i do - begin - suml += ddelayed; - sumr -= d; - ddelayed := d; - if suml = sumr then - yield i - end; -end; - -var d := ||-7, 1, 5, 2, -4, 3, 0|, |2, 4, 6|, |2, 9, 2|, |1, -1, 1, -1, 1, -1, 1||; - -foreach var data in d do - println('d =', data, '->', eqindex2pass(data)); diff --git a/Task/Equilibrium-index/Phix/equilibrium-index.phix b/Task/Equilibrium-index/Phix/equilibrium-index.phix index 22441c8018..dc802eeadf 100644 --- a/Task/Equilibrium-index/Phix/equilibrium-index.phix +++ b/Task/Equilibrium-index/Phix/equilibrium-index.phix @@ -1,23 +1,18 @@ -with javascript_semantics -function equilibrium(sequence s) - atom lower_sum = 0, - higher_sum = sum(s) - sequence res = {} - for i,si in s do - higher_sum -= si - if lower_sum=higher_sum then - res &= i - end if - lower_sum += si - end for - return res -end function +(phixonline)--> + with javascript_semantics + function equilibrium(sequence s) + atom lower_sum = 0, + higher_sum = sum(s) + sequence res = {} + for i=1 to length(s) do + higher_sum -= s[i] + if lower_sum=higher_sum then + res &= i + end if + lower_sum += s[i] + end for + return res + end function -constant tests = {{-7,1,5,2,-4,3,0}, - {2,4,6},{2,9,2}, - {1,-1,1,-1,1,-1,1}, - {1},{}} -printf(1,"The equilibrium indices for the following sequences are:\n") -for t in tests do - printf(1,"%24v -> %v\n", {t,equilibrium(t)}) -end for + ?equilibrium({-7,1,5,2,-4,3,0}) + + with javascript_semantics + sequence escache = {} -function es_cat(integer p) - if p>length(escache) and platform()!=JS then - escache &= repeat(0,p-length(escache)) - end if - integer category = escache[p] - if not category then - sequence f = filter(prime_factors(p+1,false,-1),">",3) - category = 1 - if length(f) then - category += max(apply(f,es_cat)) - end if - escache[p] = category - end if - return category -end function + function es_cat(integer p) + if p>length(escache) and platform()!=JS then + escache &= repeat(0,p-length(escache)) + end if + integer category = escache[p] + if not category then + sequence f = filter(prime_factors(p+1,false,-1),">",3) + category = 1 + if length(f) then + category += max(apply(f,es_cat)) + end if + escache[p] = category + end if + return category + end function -procedure categorise(integer n) - sequence p = get_primes(n) - printf(1,"First %,d primes:\n",n) - atom t1 = time() - sequence es = {} - for i=1 to n do - if time()>t1 then - progress("categorising %d/%d...",{i,n}) - t1 = time()+1 - end if - integer category = es_cat(p[i]) - while length(es)procedure categorise(integer n) + sequence p = get_primes(n) + printf(1,"First %,d primes:\n",n) + atom t1 = time() + sequence es = {} + for i=1 to n do + if time()>t1 then + progress("categorising %d/%d...",{i,n}) + t1 = time()+1 + end if + integer category = es_cat(p[i]) + while length(es)<category do + es = append(es,{}) + end while + es[category] &= p[i] + end for + progress("") + for c=1 to length(es) do + sequence e = es[c] + if n=200 then + printf(1,"Category %d: %s\n",{c,join(shorten(e,"primes",5,"%d"),",")}) + else + printf(1,"Category %2d: %7d .. %-8d Count: %d\n",{c,e[1],e[$],length(e)}) + end if + end for + printf(1,"\n") + end procedure -atom t0 = time() -categorise(200) -categorise(1e6) -?elapsed(time()-t0) + atom t0 = time() + categorise(200) + categorise(1e6) + ?elapsed(time()-t0) + + constant aleph = "0123456789ABCDEF" -function efill(string s, integer ch, i) - -- min-fill, like 10101 or 54321 or 32101 - s[i] = ch - for j=i+1 to length(s) do - ch = iff(ch>='1'?iff(ch='A'?'9':ch-1):'1') - s[j] = ch - end for - return s -end function + function efill(string s, integer ch, i) + -- min-fill, like 10101 or 54321 or 32101 + s[i] = ch + for j=i+1 to length(s) do + ch = iff(ch>='1'?iff(ch='A'?'9':ch-1):'1') + s[j] = ch + end for + return s + end function -function esthetic(string s, integer base = 10) - -- generate the next esthetic number after s - -- the special case of s="" always yields "1" - -- (nb otherwise s is assumed to be esthetic) - for i=length(s) to 1 by -1 do - integer ch = s[i], cp = iff(i>1?s[i-1]:'0') - if chfunction esthetic(string s, integer base = 10) + -- generate the next esthetic number after s + -- (nb unpredictable results if s is not esthetic, or "") + for i=length(s) to 1 by -1 do + integer ch = s[i], cp = iff(i>1?s[i-1]:'0') + if ch<cp and cp<aleph[base] then + return efill(s,aleph[find(ch,aleph)+2],i) + elsif i=1 and ch<aleph[base] then + return efill(s,iff(ch='9'?'A':ch+1),i) + end if + end for + return efill("1"&s,'1',1) + end function -string s -sequence res -for base=2 to 16 do - integer hi = base*6, - lo = base*4 - {s,res} = {"",{}} - for i=1 to hi do - s = esthetic(s, base) - if i>=lo then - res = append(res,s) - end if - end for - res = join(shorten(res,"numbers",4)) - printf(1,"Base %d esthetic numbers[%d..%d]: %s\n",{base,lo,hi,res}) -end for + string s + sequence res + for base=2 to 16 do + integer hi = base*6, + lo = base*4 + {s,res} = {"",{}} + for i=1 to hi do + s = esthetic(s, base) + if i>=lo then + res = append(res,s) + end if + end for + res = join(shorten(res,"numbers",4)) + printf(1,"Base %d esthetic numbers[%d..%d]: %s\n",{base,lo,hi,res}) + end for -{s,res} = {efill("1000",'1',1),{}} -while length(s)=4 do - res = append(res,s) - s = esthetic(s) -end while -res = {join(shorten(res,"numbers",5))} -printf(1,"\nBase 10 esthetic numbers between 1,000 and 9,999: %s\n\n",res) + {s,res} = {efill("1000",'1',1),{}} + while length(s)=4 do + res = append(res,s) + s = esthetic(s) + end while + res = {join(shorten(res,"numbers",5))} + printf(1,"\nBase 10 esthetic numbers between 1,000 and 9,999: %s\n\n",res) -function comma(string s) - for i=length(s)-2 to 2 by -3 do - s[i..i-1] = "," - end for - return s -end function + function comma(string s) + for i=length(s)-2 to 2 by -3 do + s[i..i-1] = "," + end for + return s + end function -for k=7 to 19 by 3 do - string f = "10"&repeat('0',k), - t = "13"&repeat('0',k) - {s,res} = {efill(f,'1',1),{}} - while sfor k=7 to 19 by 3 do + string f = "10"&repeat('0',k), + t = "13"&repeat('0',k) + {s,res} = {efill(f,'1',1),{}} + while s<t do + res = append(res,s) + s = esthetic(s) + end while + res = join(shorten(res,"numbers",1)) + printf(1,"Base 10 esthetic numbers between %s and %s: %s\n", + {comma(f),comma(t),res}) + end for + + function count_esthetic(integer len, start=0) + -- a start digit of 0 means sum all 1..9 + sequence dc = repeat(repeat(1,10),len) -- nb 0..9 logically + for i=2 to len do + for d=0 to 9 do + dc[i][d+1] = iff(d=0?0:dc[i-1][d]) + iff(d=9?0:dc[i-1][d+2]) + end for + end for + if start=0 then return sum(dc[len][1..9]) end if -- (see note) + return dc[len][start+1] + end function -sequence t = tagset(iff(machine_bits()=64?63:57),9,3), - r = columnize({apply(true,count_esthetic,{t,1}),t}) -papply(true,printf,{1,{"There are %,26d %2d-digit esthetic numbers beginning with 1\n"},r}) -if machine_bits()=64 then - printf(1,"There are %,26d 64-digit esthetic numbers\n",{count_esthetic(64)}) - printf(1,"There are %,26d esthetic numbers with max 65 digits\n",{sum(apply(tagset(64),count_esthetic))}) -end if + sequence t = tagset(iff(machine_bits()=64?63:57),9,3), + r = columnize({apply(true,count_esthetic,{t,1}),t}) + papply(true,printf,{1,{"There are %,26d %2d-digit esthetic numbers beginning with 1\n"},r}) + if machine_bits()=64 then + printf(1,"There are %,26d 64-digit esthetic numbers\n",{count_esthetic(64)}) + printf(1,"There are %,26d esthetic numbers with max 65 digits\n",{sum(apply(tagset(64),count_esthetic))}) + end if + stdout // $0 is a temp register - LDA str,BUF+19 % points after the end of the string -2H SUB str,str,1 % update buffer pointer - DIV acc,acc,10 % do a divide and mod - GET $0,rR % get digit from special purpose reg. rR - % containing the remainder of the division - INCL $0,'0' % convert to ascii - STBU $0,str % place digit in buffer - PBNZ acc,2B % next - % 'str' points to the start of the result - TRAP 0,Fputs,StdOut % output answer to stdout - TRAP 0,Halt,0 % exit + LDA str,BUF+19 % points after the end of the string +2H SUB str,str,1 % update buffer pointer + DIV acc,acc,10 % do a divide and mod + GET $0,rR % get digit from special purpose reg. rR + % containing the remainder of the division + INCL $0,'0' % convert to ascii + STBU $0,str % place digit in buffer + PBNZ acc,2B % next + % 'str' points to the start of the result + TRAP 0,Fputs,StdOut % output answer to stdout + TRAP 0,Halt,0 % exit diff --git a/Task/Ethiopian-multiplication/Maxima/ethiopian-multiplication.maxima b/Task/Ethiopian-multiplication/Maxima/ethiopian-multiplication.maxima deleted file mode 100644 index a39f137c36..0000000000 --- a/Task/Ethiopian-multiplication/Maxima/ethiopian-multiplication.maxima +++ /dev/null @@ -1,16 +0,0 @@ -/* Function to halve */ -halve(n):=floor(n/2)$ - -/* Function to double */ -double(n):=2*n$ - -/* Predicate function to check wether an integer is even */ -my_evenp(n):=if mod(n,2)=0 then true$ - -/* Function that implements ethiopian function using the three previously defined functions */ -ethiopian(n1,n2):=block(cn1:n1,cn2:n2,list_w:[], - while cn1>0 do (list_w:endcons(cn1,list_w),cn1:halve(cn1)), - n2_list:append([cn2],makelist(cn2:double(cn2),length(list_w)-1)), - sublist_indices(list_w,lambda([x],not my_evenp(x))), - makelist(n2_list[i],i,%%), - apply("+",%%))$ diff --git a/Task/Ethiopian-multiplication/MoonRock/ethiopian-multiplication.moonrock b/Task/Ethiopian-multiplication/MoonRock/ethiopian-multiplication.moonrock deleted file mode 100644 index 4a1893471c..0000000000 --- a/Task/Ethiopian-multiplication/MoonRock/ethiopian-multiplication.moonrock +++ /dev/null @@ -1,54 +0,0 @@ -' Ethiopian multiplication -BEGIN DEF -pointer word PtrA~ -pointer word PtrIsEven~ -SUB Double(PtrA~) -SUB Halve(PtrA~) -SUB CheckIfEven(PtrA~, PtrIsEven~) -SUB PrintStr(S$, Width%) - -BEGIN CODE -X% = 17 -Y% = 34 -Tot% = 0 -WHILE X% >= 1 - CALL PrintStr(STR(X%), 6) - PRINT " " - CALL CheckIfEven(X%, VARPTR(IsEven%)) - IF IsEven% = FALSE THEN - Tot% = Tot% + Y% - CALL PrintStr(STR(Y%), 6) - ENDIF - PRINT "\n" - CALL Halve(VARPTR(X%)) - CALL Double(VARPTR(Y%)) -WEND -PRINT "= " -CALL PrintStr(STR(Tot%), 6) -PRINT "\n" -END - -' Subroutines are required, though -' they complicate the code - -SUB Double(PtrA~) -[PtrA~] = 2 * [PtrA~] -END SUB - -SUB Halve(PtrA~) -[PtrA~] = [PtrA~] \ 2 -END SUB - -SUB CheckIfEven(A%, PtrIsEven~) -[PtrIsEven~] = A% MOD 2 -[PtrIsEven~] = [PtrIsEven~] - 1 -END SUB - -SUB PrintStr(S$, Width%) -IF LEN(S$) > Width% THEN - PRINT S$ -ELSE - S$ = SPACE(Width%) + S$ - PRINT RIGHT(S$, Width%) -ENDIF -END SUB diff --git a/Task/Ethiopian-multiplication/OCaml/ethiopian-multiplication.ml b/Task/Ethiopian-multiplication/OCaml/ethiopian-multiplication.ocaml similarity index 100% rename from Task/Ethiopian-multiplication/OCaml/ethiopian-multiplication.ml rename to Task/Ethiopian-multiplication/OCaml/ethiopian-multiplication.ocaml diff --git a/Task/Ethiopian-multiplication/Oberon-07/ethiopian-multiplication.oberon b/Task/Ethiopian-multiplication/Oberon-07/ethiopian-multiplication.oberon deleted file mode 100644 index c6fe2e64c9..0000000000 --- a/Task/Ethiopian-multiplication/Oberon-07/ethiopian-multiplication.oberon +++ /dev/null @@ -1,42 +0,0 @@ -MODULE EthopianMultiplication; (* translation of Loglan82 *) - IMPORT Out; - - VAR x, y, outp : INTEGER; - multiplying : BOOLEAN; - - PROCEDURE half( a : INTEGER ) : INTEGER; - BEGIN - RETURN a DIV 2 - END half; - - PROCEDURE doub( a : INTEGER ) : INTEGER; - BEGIN - RETURN a * 2 - END doub; - - PROCEDURE isEven( a : INTEGER ) : BOOLEAN; - BEGIN - RETURN ~ ODD( a ) - END isEven; - -BEGIN - x := 17; - y := 34; - outp := 0; - multiplying := TRUE; - WHILE multiplying DO - Out.Int( x, 6 );Out.String( " " ); - IF ~ isEven(x) THEN - outp := outp + y; - Out.Int( y, 6 ) - END; - Out.Ln; - IF x < 2 THEN - multiplying := FALSE - ELSE - x := half(x); - y := doub(y) - END - END; - Out.String( " = " );Out.Int( outp, 6 );Out.Ln -END EthopianMultiplication. diff --git a/Task/Ethiopian-multiplication/Octave/ethiopian-multiplication.octave b/Task/Ethiopian-multiplication/Octave/ethiopian-multiplication.octave index c6a81160b1..18d3a0af83 100644 --- a/Task/Ethiopian-multiplication/Octave/ethiopian-multiplication.octave +++ b/Task/Ethiopian-multiplication/Octave/ethiopian-multiplication.octave @@ -18,12 +18,12 @@ function r = ethiopicmult(plier, plicand, tutor=false) while(plier >= 1) if ( iseven(plier) ) if (tutor) - printf("%4d %6d struck\n", plier, plicand); + printf("%4d %6d struck\n", plier, plicand); endif else r = r + plicand; if (tutor) - printf("%4d %6d kept\n", plier, plicand); + printf("%4d %6d kept\n", plier, plicand); endif endif plier = halve(plier); diff --git a/Task/Ethiopian-multiplication/Oz/ethiopian-multiplication.oz b/Task/Ethiopian-multiplication/Oz/ethiopian-multiplication.oz index 2c5a6825bd..4eaecb27c7 100644 --- a/Task/Ethiopian-multiplication/Oz/ethiopian-multiplication.oz +++ b/Task/Ethiopian-multiplication/Oz/ethiopian-multiplication.oz @@ -10,9 +10,9 @@ declare L in X; L>0; {Halve L} %% C-like iterator: "Init; While; Next" R in Y; true; {Double R} collect:Collect - do - {Collect L#R} - end + do + {Collect L#R} + end OddRows = {Filter Rows LeftIsOdd} RightColumn = {Map OddRows SelectRight} diff --git a/Task/Ethiopian-multiplication/Pascal-P/ethiopian-multiplication.pas b/Task/Ethiopian-multiplication/Pascal-P/ethiopian-multiplication.pas deleted file mode 100644 index 1046cc6565..0000000000 --- a/Task/Ethiopian-multiplication/Pascal-P/ethiopian-multiplication.pas +++ /dev/null @@ -1,47 +0,0 @@ -program ethiopian(output); - (* Ethiopian multiplication *) -var - x, y, outp: integer; - - function doub(a: integer): integer; - begin - doub := a * 2; - end; - - function half(a: integer): integer; - begin - half := a div 2; - end; - - function iseven(a: integer): boolean; - begin - iseven := a mod 2 = 0; - end; - -begin - x := 17; - y := 34; - write(x: 6); - if not (iseven(x)) then - begin - outp := outp + y; - writeln(' ', y: 6); - end - else - writeln; - while x >= 2 do - begin - x := half(x); - y := doub(y); - write(x: 6); - if not (iseven(x)) then - begin - outp := outp + y; - writeln(' ', y: 6); - end - else - writeln; - end; - writeln(' = ', outp: 6); - (* readln; *) -end. diff --git a/Task/Ethiopian-multiplication/Pascal/ethiopian-multiplication.pas b/Task/Ethiopian-multiplication/Pascal/ethiopian-multiplication.pas new file mode 100644 index 0000000000..826258d7fd --- /dev/null +++ b/Task/Ethiopian-multiplication/Pascal/ethiopian-multiplication.pas @@ -0,0 +1,34 @@ +program EthiopianMultiplication; + {$IFDEF FPC} + {$MODE DELPHI} + {$ENDIF} + function Double(Number: Integer): Integer; + begin + Result := Number * 2 + end; + + function Halve(Number: Integer): Integer; + begin + Result := Number div 2 + end; + + function Even(Number: Integer): Boolean; + begin + Result := Number mod 2 = 0 + end; + + function Ethiopian(NumberA, NumberB: Integer): Integer; + begin + Result := 0; + while NumberA >= 1 do + begin + if not Even(NumberA) then + Result := Result + NumberB; + NumberA := Halve(NumberA); + NumberB := Double(NumberB) + end + end; + +begin + Write(Ethiopian(17, 34)) +end. diff --git a/Task/Ethiopian-multiplication/PascalABC.NET/ethiopian-multiplication.pas b/Task/Ethiopian-multiplication/PascalABC.NET/ethiopian-multiplication.pas deleted file mode 100644 index 64d7022701..0000000000 --- a/Task/Ethiopian-multiplication/PascalABC.NET/ethiopian-multiplication.pas +++ /dev/null @@ -1,17 +0,0 @@ -function halve(x: integer): integer := x div 2; -function double(x: integer): integer := x * 2; -function odd(x: integer): boolean := x mod 2 <> 0; - -function ethiopian(x, y: integer): integer; -begin - while x >= 1 do - begin - if odd(x) then result += y; - x := halve(x); - y := double(y); - end; -end; - -begin - ethiopian(17, 34).println; -end. diff --git a/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl b/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl index 85d7454124..9ffe136ab9 100644 --- a/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl +++ b/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl @@ -11,12 +11,12 @@ sub ethiopicmult my $r = 0; while ($plier >= 1) { - $r += $plicand unless iseven($plier); - if ($tutor) { - print "$plier, $plicand ", (iseven($plier) ? " struck" : " kept"), "\n"; - } - $plier = halve($plier); - $plicand = double($plicand); + $r += $plicand unless iseven($plier); + if ($tutor) { + print "$plier, $plicand ", (iseven($plier) ? " struck" : " kept"), "\n"; + } + $plier = halve($plier); + $plicand = double($plicand); } return $r; } diff --git a/Task/Ethiopian-multiplication/Pluto/ethiopian-multiplication.pluto b/Task/Ethiopian-multiplication/Pluto/ethiopian-multiplication.pluto deleted file mode 100644 index a0528544e6..0000000000 --- a/Task/Ethiopian-multiplication/Pluto/ethiopian-multiplication.pluto +++ /dev/null @@ -1,18 +0,0 @@ -local function halve(n) return n // 2 end - -local function double(n) return n * 2 end - -local function is_even(n) return n % 2 == 0 end - -local function ethiopian(x, y) - local sum = 0 - while x >= 1 do - if !is_even(x) then sum += y end - x = halve(x) - y = double(y) - end - return sum -end - -print($"17 x 34 = {ethiopian(17, 34)}") -print($"99 x 99 = {ethiopian(99, 99)}") diff --git a/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-1.ps1 b/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-1.ps1 deleted file mode 100644 index 7aea5a622d..0000000000 --- a/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-1.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -function isEven { - param ([int]$value) - return [bool]($value % 2 -eq 0) -} - -function doubleValue { - param ([int]$value) - return [int]($value * 2) -} - -function halveValue { - param ([int]$value) - return [int]($value / 2) -} - -function multiplyValues { - param ( - [int]$plier, - [int]$plicand, - [int]$temp = 0 - ) - - while ($plier -ge 1) - { - if (!(isEven $plier)) { - $temp += $plicand - } - $plier = halveValue $plier - $plicand = doubleValue $plicand - } - -return $temp -} - -multiplyValues 17 34 diff --git a/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-1.psh b/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-1.psh new file mode 100644 index 0000000000..04e4e45546 --- /dev/null +++ b/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-1.psh @@ -0,0 +1,35 @@ +function isEven { + param ([int]$value) + return [bool]($value % 2 -eq 0) +} + +function doubleValue { + param ([int]$value) + return [int]($value * 2) +} + +function halveValue { + param ([int]$value) + return [int]($value / 2) +} + +function multiplyValues { + param ( + [int]$plier, + [int]$plicand, + [int]$temp = 0 + ) + + while ($plier -ge 1) + { + if (!(isEven $plier)) { + $temp += $plicand + } + $plier = halveValue $plier + $plicand = doubleValue $plicand + } + +return $temp +} + +multiplyValues 17 34 diff --git a/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-2.ps1 b/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-2.ps1 deleted file mode 100644 index 1e797c3ed7..0000000000 --- a/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-2.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -function halveInt( [int] $rhs ) -{ - [math]::floor( $rhs / 2 ) -} - -function doubleInt( [int] $rhs ) -{ - $rhs*2 -} - -function isEven( [int] $rhs ) -{ - -not ( $_ % 2 ) -} - -function Ethiopian( [int] $lhs , [int] $rhs ) -{ - $scratch = @{} - 1..[math]::floor( [math]::log( $lhs , 2 ) + 1 ) | - ForEach-Object { - $scratch[$lhs] = $rhs - $lhs - $lhs = halveInt( $lhs ) - $rhs = doubleInt( $rhs ) } | - Where-Object { -not ( isEven $_ ) } | - ForEach-Object { $sum = 0 } { $sum += $scratch[$_] } { $sum } -} - -Ethiopian 17 34 diff --git a/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-2.psh b/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-2.psh new file mode 100644 index 0000000000..5ba27a7a0e --- /dev/null +++ b/Task/Ethiopian-multiplication/PowerShell/ethiopian-multiplication-2.psh @@ -0,0 +1,29 @@ +function halveInt( [int] $rhs ) +{ + [math]::floor( $rhs / 2 ) +} + +function doubleInt( [int] $rhs ) +{ + $rhs*2 +} + +function isEven( [int] $rhs ) +{ + -not ( $_ % 2 ) +} + +function Ethiopian( [int] $lhs , [int] $rhs ) +{ + $scratch = @{} + 1..[math]::floor( [math]::log( $lhs , 2 ) + 1 ) | + ForEach-Object { + $scratch[$lhs] = $rhs + $lhs + $lhs = halveInt( $lhs ) + $rhs = doubleInt( $rhs ) } | + Where-Object { -not ( isEven $_ ) } | + ForEach-Object { $sum = 0 } { $sum += $scratch[$_] } { $sum } +} + +Ethiopian 17 34 diff --git a/Task/Ethiopian-multiplication/Powerbuilder/ethiopian-multiplication.powerbuilder b/Task/Ethiopian-multiplication/Powerbuilder/ethiopian-multiplication.powerbuilder index af6a22f8fb..119c89c29a 100644 --- a/Task/Ethiopian-multiplication/Powerbuilder/ethiopian-multiplication.powerbuilder +++ b/Task/Ethiopian-multiplication/Powerbuilder/ethiopian-multiplication.powerbuilder @@ -11,13 +11,13 @@ public function long wf_ethiopianmultiplication (long al_multiplicand, long al_m long ll_product DO WHILE al_multiplicand >= 1 - IF wf_iseven(al_multiplicand) THEN - // do nothing - ELSE - ll_product += al_multiplier - END IF - al_multiplicand = wf_halve(al_multiplicand) - al_multiplier = wf_double(al_multiplier) + IF wf_iseven(al_multiplicand) THEN + // do nothing + ELSE + ll_product += al_multiplier + END IF + al_multiplicand = wf_halve(al_multiplicand) + al_multiplier = wf_double(al_multiplier) LOOP return ll_product diff --git a/Task/Ethiopian-multiplication/QuickBASIC/ethiopian-multiplication.basic b/Task/Ethiopian-multiplication/QuickBASIC/ethiopian-multiplication.basic deleted file mode 100644 index 6fdbb1e5c2..0000000000 --- a/Task/Ethiopian-multiplication/QuickBASIC/ethiopian-multiplication.basic +++ /dev/null @@ -1,33 +0,0 @@ -' Ethiopian multiplication -DECLARE FUNCTION Half% (A AS INTEGER) -DECLARE FUNCTION Doub% (A AS INTEGER) -DECLARE FUNCTION IsEven% (A AS INTEGER) - -DIM X AS INTEGER, Y AS INTEGER, OutP AS INTEGER -X = 17 -Y = 34 -DO - PRINT X, - IF NOT (IsEven(X)) THEN - OutP = OutP + Y - PRINT Y - ELSE - PRINT - END IF - IF X < 2 THEN EXIT DO - X = Half(X) - Y = Doub(Y) -LOOP -PRINT " =", OutP - -FUNCTION Doub% (A AS INTEGER) - Doub% = A * 2 -END FUNCTION - -FUNCTION Half% (A AS INTEGER) - Half% = A \ 2 -END FUNCTION - -FUNCTION IsEven% (A AS INTEGER) - IsEven% = (A MOD 2) - 1 -END FUNCTION diff --git a/Task/Ethiopian-multiplication/R/ethiopian-multiplication-2.r b/Task/Ethiopian-multiplication/R/ethiopian-multiplication-2.r index 5c2f395556..d105b32b1d 100644 --- a/Task/Ethiopian-multiplication/R/ethiopian-multiplication-2.r +++ b/Task/Ethiopian-multiplication/R/ethiopian-multiplication-2.r @@ -3,13 +3,13 @@ double <- function(a) a*2 iseven <- function(a) (a%%2)==0 ethiopicmult<-function(x,y){ - res<-ifelse(iseven(y),0,x) - while(!y==1){ - x<-double(x) - y<-halve(y) - if(!iseven(y)) res<-res+x - } - return(res) + res<-ifelse(iseven(y),0,x) + while(!y==1){ + x<-double(x) + y<-halve(y) + if(!iseven(y)) res<-res+x + } + return(res) } print(ethiopicmult(17,34)) diff --git a/Task/Ethiopian-multiplication/Raku/ethiopian-multiplication-1.raku b/Task/Ethiopian-multiplication/Raku/ethiopian-multiplication-1.raku index 00d9e4165a..1fb06da87d 100644 --- a/Task/Ethiopian-multiplication/Raku/ethiopian-multiplication-1.raku +++ b/Task/Ethiopian-multiplication/Raku/ethiopian-multiplication-1.raku @@ -5,9 +5,9 @@ sub even (Int $n --> Bool) { $n %% 2 } sub ethiopic-mult (Int $a is copy, Int $b is copy --> Int) { my Int $r = 0; while $a { - even $a or $r += $b; - halve $a; - double $b; + even $a or $r += $b; + halve $a; + double $b; } return $r; } diff --git a/Task/Ethiopian-multiplication/Rascal/ethiopian-multiplication.rascal b/Task/Ethiopian-multiplication/Rascal/ethiopian-multiplication.rascal index 63ddce167b..7efe02722d 100644 --- a/Task/Ethiopian-multiplication/Rascal/ethiopian-multiplication.rascal +++ b/Task/Ethiopian-multiplication/Rascal/ethiopian-multiplication.rascal @@ -7,12 +7,12 @@ public int double(int n) = n*2; public bool uneven(int n) = (n % 2) != 0); public int ethiopianMul(int n, int m) { - result = 0; - while(n >= 1) { - if(uneven(n)) - result += m; - n = halve(n); - m = double(m); - } - return result; + result = 0; + while(n >= 1) { + if(uneven(n)) + result += m; + n = halve(n); + m = double(m); + } + return result; } diff --git a/Task/Ethiopian-multiplication/Rebol/ethiopian-multiplication.rebol b/Task/Ethiopian-multiplication/Rebol/ethiopian-multiplication.rebol deleted file mode 100644 index 6d70881ef7..0000000000 --- a/Task/Ethiopian-multiplication/Rebol/ethiopian-multiplication.rebol +++ /dev/null @@ -1,31 +0,0 @@ -Rebol [ - title: "Rosetta code: Ethiopian multiplication" - file: %Ethiopian_multiplication.r3 - url: https://rosettacode.org/wiki/Ethiopian_multiplication -] - -halve: function [n][n >> 1] -double: function [n][n << 1] - -ethiopian-multiply: function [ - "Returns the product of two integers using Ethiopian multiplication, with a printed trace" - a [integer!] "The multiplicand (column halved)" - b [integer!] "The multiplier (column doubled)" -][ - result: 0 - while [a <> 0][ - prin pad a -7 - either odd? a [ - result: result + b - print [as-green pad b -5 "(keep)"] - ][ print pad b -5] - a: halve a - b: double b - ] - print "-------------" - print as-yellow pad result -12 - result -] - -; Example: should print the layout shown for input 17 and 34 -ethiopian-multiply 17 34 diff --git a/Task/Ethiopian-multiplication/Rust/ethiopian-multiplication.rs b/Task/Ethiopian-multiplication/Rust/ethiopian-multiplication.rust similarity index 100% rename from Task/Ethiopian-multiplication/Rust/ethiopian-multiplication.rs rename to Task/Ethiopian-multiplication/Rust/ethiopian-multiplication.rust diff --git a/Task/Ethiopian-multiplication/SNOBOL4/ethiopian-multiplication.sno b/Task/Ethiopian-multiplication/SNOBOL4/ethiopian-multiplication.sno index 1486374343..143f93f2f2 100644 --- a/Task/Ethiopian-multiplication/SNOBOL4/ethiopian-multiplication.sno +++ b/Task/Ethiopian-multiplication/SNOBOL4/ethiopian-multiplication.sno @@ -1,21 +1,21 @@ - define('halve(num)') :(halve_end) -halve eq(num,1) :s(freturn) - halve = num / 2 :(return) + define('halve(num)') :(halve_end) +halve eq(num,1) :s(freturn) + halve = num / 2 :(return) halve_end - define('double(num)') :(double_end) -double double = num * 2 :(return) + define('double(num)') :(double_end) +double double = num * 2 :(return) double_end - define('odd(num)') :(odd_end) -odd eq(num,1) :s(return) - eq(num,double(halve(num))) :s(freturn)f(return) + define('odd(num)') :(odd_end) +odd eq(num,1) :s(return) + eq(num,double(halve(num))) :s(freturn)f(return) -odd_end l = trim(input) - r = trim(input) - s = 0 -next s = odd(l) s + r - r = double(r) - l = halve(l) :s(next) -stop output = s +odd_end l = trim(input) + r = trim(input) + s = 0 +next s = odd(l) s + r + r = double(r) + l = halve(l) :s(next) +stop output = s end diff --git a/Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.scm b/Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.ss similarity index 100% rename from Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.scm rename to Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.ss diff --git a/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st b/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st index 9a607ae2c2..2d25a1a5cf 100644 --- a/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st +++ b/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st @@ -20,7 +20,7 @@ Number extend [ ifTrue: [ tutor ifTrue: [ ('%1, %2 struck' % { multiplier. multiplicand }) - displayNl + displayNl ] ]. multiplier := multiplier halve. diff --git a/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl b/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl index 873c47d443..5f594c4172 100644 --- a/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl +++ b/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl @@ -9,22 +9,22 @@ function even n {($n & 1) == 0} function mult {a b} { $a < 1 ? 0 : even($a) ? [logmult STRUCK] + mult(halve($a), double($b)) - : [logmult KEPT] + mult(halve($a), double($b)) + $b + : [logmult KEPT] + mult(halve($a), double($b)) + $b } # Wrapper to set up the logging proc ethiopianMultiply {a b {tutor false}} { if {$tutor} { - set wa [expr {[string length $a]+1}] - set wb [expr {$wa+[string length $b]-1}] - puts stderr "Ethiopian multiplication of $a and $b" - interp alias {} logmult {} apply {{wa wb msg} { - upvar 1 a a b b - puts stderr [format "%*d %*d %s" $wa $a $wb $b $msg] - return 0 - }} $wa $wb + set wa [expr {[string length $a]+1}] + set wb [expr {$wa+[string length $b]-1}] + puts stderr "Ethiopian multiplication of $a and $b" + interp alias {} logmult {} apply {{wa wb msg} { + upvar 1 a a b b + puts stderr [format "%*d %*d %s" $wa $a $wb $b $msg] + return 0 + }} $wa $wb } else { - proc logmult args {return 0} + proc logmult args {return 0} } return [expr {mult($a,$b)}] } diff --git a/Task/Ethiopian-multiplication/True-BASIC/ethiopian-multiplication.basic b/Task/Ethiopian-multiplication/True-BASIC/ethiopian-multiplication.basic index 938dbf5dca..2e096710f7 100644 --- a/Task/Ethiopian-multiplication/True-BASIC/ethiopian-multiplication.basic +++ b/Task/Ethiopian-multiplication/True-BASIC/ethiopian-multiplication.basic @@ -1,29 +1,29 @@ !RosettaCode: Ethiopian Multiplication ! True BASIC v6.007 PROGRAM EthiopianMultiplication - DECLARE DEF FNdouble - DECLARE DEF FNhalve - DECLARE DEF FNeven - - LET x = 17 - LET y = 34 - - DO - IF FNeven(x) = 0 THEN - LET p = p + y - PRINT x,y - ELSE - PRINT x," ---" - END IF - - LET x = FNhalve(x) - LET y = FNdouble(y) - LOOP UNTIL x = 0 - PRINT " ", " ===" - PRINT " ", p - GET KEY done - - DEF FNdouble(A) = A * 2 - DEF FNhalve(A) = INT(A / 2) - DEF FNeven(A) = MOD(A+1,2) + DECLARE DEF FNdouble + DECLARE DEF FNhalve + DECLARE DEF FNeven + + LET x = 17 + LET y = 34 + + DO + IF FNeven(x) = 0 THEN + LET p = p + y + PRINT x,y + ELSE + PRINT x," ---" + END IF + + LET x = FNhalve(x) + LET y = FNdouble(y) + LOOP UNTIL x = 0 + PRINT " ", " ===" + PRINT " ", p + GET KEY done + + DEF FNdouble(A) = A * 2 + DEF FNhalve(A) = INT(A / 2) + DEF FNeven(A) = MOD(A+1,2) END diff --git a/Task/Ethiopian-multiplication/UNIX-Shell/ethiopian-multiplication-1.sh b/Task/Ethiopian-multiplication/UNIX-Shell/ethiopian-multiplication-1.sh index f9a0dc4ee0..21f4a8aaaf 100644 --- a/Task/Ethiopian-multiplication/UNIX-Shell/ethiopian-multiplication-1.sh +++ b/Task/Ethiopian-multiplication/UNIX-Shell/ethiopian-multiplication-1.sh @@ -19,9 +19,9 @@ ethiopicmult() plicand=$2 r=0 while [ "$plier" -ge 1 ]; do - is_even "$plier" || r=`expr $r + "$plicand"` - plier=`halve "$plier"` - plicand=`double "$plicand"` + is_even "$plier" || r=`expr $r + "$plicand"` + plier=`halve "$plier"` + plicand=`double "$plicand"` done echo $r } diff --git a/Task/Ethiopian-multiplication/Uiua/ethiopian-multiplication.uiua b/Task/Ethiopian-multiplication/Uiua/ethiopian-multiplication.uiua deleted file mode 100644 index 8f809a29aa..0000000000 --- a/Task/Ethiopian-multiplication/Uiua/ethiopian-multiplication.uiua +++ /dev/null @@ -1,10 +0,0 @@ -Halve ← ⌊÷2 -Double ← ×2 -Odd ← ◿2 -EMul ← ◌◌⍢(⊓Halve Double⍥⊙⟜+⊸Odd)±⊙⊙0 - -┌─╴test - ⍤⤙≍ 578 EMul 17 34 - ⍤⤙≍ 0 EMul 17 0 - ⍤⤙≍ 6 EMul 2 3 -└─╴ diff --git a/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-1.vb b/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-1.vb new file mode 100644 index 0000000000..0746c78f8e --- /dev/null +++ b/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-1.vb @@ -0,0 +1,89 @@ +option explicit + +class List + private theList + private nOccupiable + private nTop + + sub class_initialize + nTop = 0 + nOccupiable = 100 + redim theList( nOccupiable ) + end sub + + public sub store( x ) + if nTop >= nOccupiable then + nOccupiable = nOccupiable + 100 + redim preserve theList( nOccupiable ) + end if + theList( nTop ) = x + nTop = nTop + 1 + end sub + + public function recall( n ) + if n >= 0 and n <= nOccupiable then + recall = theList( n ) + else + err.raise vbObjectError + 1000,,"Recall bounds error" + end if + end function + + public sub replace( n, x ) + if n >= 0 and n <= nOccupiable then + theList( n ) = x + else + err.raise vbObjectError + 1001,,"Replace bounds error" + end if + end sub + + public property get listCount + listCount = nTop + end property + +end class + +function halve( n ) + halve = int( n / 2 ) +end function + +function twice( n ) + twice = int( n * 2 ) +end function + +function iseven( n ) + iseven = ( ( n mod 2 ) = 0 ) +end function + + +function multiply( n1, n2 ) + dim LL + set LL = new List + + dim RR + set RR = new List + + LL.store n1 + RR.store n2 + + do while n1 <> 1 + n1 = halve( n1 ) + LL.store n1 + n2 = twice( n2 ) + RR.store n2 + loop + + dim i + for i = 0 to LL.listCount + if iseven( LL.recall( i ) ) then + RR.replace i, 0 + end if + next + + dim total + total = 0 + for i = 0 to RR.listCount + total = total + RR.recall( i ) + next + + multiply = total +end function diff --git a/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-1.vbs b/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-1.vbs deleted file mode 100644 index ff896c9b1a..0000000000 --- a/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-1.vbs +++ /dev/null @@ -1,89 +0,0 @@ -option explicit - -class List - private theList - private nOccupiable - private nTop - - sub class_initialize - nTop = 0 - nOccupiable = 100 - redim theList( nOccupiable ) - end sub - - public sub store( x ) - if nTop >= nOccupiable then - nOccupiable = nOccupiable + 100 - redim preserve theList( nOccupiable ) - end if - theList( nTop ) = x - nTop = nTop + 1 - end sub - - public function recall( n ) - if n >= 0 and n <= nOccupiable then - recall = theList( n ) - else - err.raise vbObjectError + 1000,,"Recall bounds error" - end if - end function - - public sub replace( n, x ) - if n >= 0 and n <= nOccupiable then - theList( n ) = x - else - err.raise vbObjectError + 1001,,"Replace bounds error" - end if - end sub - - public property get listCount - listCount = nTop - end property - -end class - -function halve( n ) - halve = int( n / 2 ) -end function - -function twice( n ) - twice = int( n * 2 ) -end function - -function iseven( n ) - iseven = ( ( n mod 2 ) = 0 ) -end function - - -function multiply( n1, n2 ) - dim LL - set LL = new List - - dim RR - set RR = new List - - LL.store n1 - RR.store n2 - - do while n1 <> 1 - n1 = halve( n1 ) - LL.store n1 - n2 = twice( n2 ) - RR.store n2 - loop - - dim i - for i = 0 to LL.listCount - if iseven( LL.recall( i ) ) then - RR.replace i, 0 - end if - next - - dim total - total = 0 - for i = 0 to RR.listCount - total = total + RR.recall( i ) - next - - multiply = total -end function diff --git a/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-2.vbs b/Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-2.vb similarity index 100% rename from Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-2.vbs rename to Task/Ethiopian-multiplication/VBScript/ethiopian-multiplication-2.vb diff --git a/Task/Ethiopian-multiplication/X86-Assembly/ethiopian-multiplication-1.x86 b/Task/Ethiopian-multiplication/X86-Assembly/ethiopian-multiplication-1.x86 index ff6e3762ae..3d078eced9 100644 --- a/Task/Ethiopian-multiplication/X86-Assembly/ethiopian-multiplication-1.x86 +++ b/Task/Ethiopian-multiplication/X86-Assembly/ethiopian-multiplication-1.x86 @@ -1,109 +1,109 @@ - extern printf - global main + extern printf + global main - section .text + section .text halve - shr ebx, 1 - ret + shr ebx, 1 + ret double - shl ebx, 1 - ret + shl ebx, 1 + ret iseven - and ebx, 1 - cmp ebx, 0 - ret ; ret preserves flags + and ebx, 1 + cmp ebx, 0 + ret ; ret preserves flags main - push 1 ; tutor = true - push 34 ; 2nd operand - push 17 ; 1st operand - call ethiopicmult - add esp, 12 + push 1 ; tutor = true + push 34 ; 2nd operand + push 17 ; 1st operand + call ethiopicmult + add esp, 12 - push eax ; result of 17*34 - push fmt - call printf - add esp, 8 + push eax ; result of 17*34 + push fmt + call printf + add esp, 8 - ret + ret %define plier 8 %define plicand 12 %define tutor 16 - + ethiopicmult - enter 0, 0 - cmp dword [ebp + tutor], 0 - je .notut0 - push dword [ebp + plicand] - push dword [ebp + plier] - push preamblefmt - call printf - add esp, 12 + enter 0, 0 + cmp dword [ebp + tutor], 0 + je .notut0 + push dword [ebp + plicand] + push dword [ebp + plier] + push preamblefmt + call printf + add esp, 12 .notut0 - xor eax, eax ; eax -> result - mov ecx, [ebp + plier] ; ecx -> plier - mov edx, [ebp + plicand] ; edx -> plicand + xor eax, eax ; eax -> result + mov ecx, [ebp + plier] ; ecx -> plier + mov edx, [ebp + plicand] ; edx -> plicand .whileloop - cmp ecx, 1 - jl .multend - cmp dword [ebp + tutor], 0 - je .notut1 - call tutorme + cmp ecx, 1 + jl .multend + cmp dword [ebp + tutor], 0 + je .notut1 + call tutorme .notut1 - mov ebx, ecx - call iseven - je .iseven - add eax, edx ; result += plicand + mov ebx, ecx + call iseven + je .iseven + add eax, edx ; result += plicand .iseven - mov ebx, ecx ; plier >>= 1 - call halve - mov ecx, ebx + mov ebx, ecx ; plier >>= 1 + call halve + mov ecx, ebx - mov ebx, edx ; plicand <<= 1 - call double - mov edx, ebx - - jmp .whileloop + mov ebx, edx ; plicand <<= 1 + call double + mov edx, ebx + + jmp .whileloop .multend - leave - ret + leave + ret tutorme - push eax - push strucktxt - mov ebx, ecx - call iseven - je .nostruck - mov dword [esp], kepttxt + push eax + push strucktxt + mov ebx, ecx + call iseven + je .nostruck + mov dword [esp], kepttxt .nostruck - push edx - push ecx - push tutorfmt - call printf - add esp, 4 - pop ecx - pop edx - add esp, 4 - pop eax - ret + push edx + push ecx + push tutorfmt + call printf + add esp, 4 + pop ecx + pop edx + add esp, 4 + pop eax + ret - section .data + section .data fmt - db "%d", 10, 0 + db "%d", 10, 0 preamblefmt - db "ethiopic multiplication of %d and %d", 10, 0 + db "ethiopic multiplication of %d and %d", 10, 0 tutorfmt - db "%4d %6d %s", 10, 0 + db "%4d %6d %s", 10, 0 strucktxt - db "struck", 0 + db "struck", 0 kepttxt - db "kept", 0 + db "kept", 0 diff --git a/Task/Ethiopian-multiplication/Yabasic/ethiopian-multiplication.basic b/Task/Ethiopian-multiplication/Yabasic/ethiopian-multiplication.basic index 345137d134..38ab4861d9 100644 --- a/Task/Ethiopian-multiplication/Yabasic/ethiopian-multiplication.basic +++ b/Task/Ethiopian-multiplication/Yabasic/ethiopian-multiplication.basic @@ -3,28 +3,28 @@ x = 17 y = 34 do - print x, chr$(09); - if not (isEven(x)) then - outP = outP + y - print y - else - print - fi - if x < 2 break - x = half(x) - y = doub(y) + print x, chr$(09); + if not (isEven(x)) then + outP = outP + y + print y + else + print + fi + if x < 2 break + x = half(x) + y = doub(y) loop print "=", chr$(09), outP end sub doub (a) - return a * 2 + return a * 2 end sub sub half (a) - return int(a / 2) + return int(a / 2) end sub sub isEven (a) - return mod(a, 2) - 1 + return mod(a, 2) - 1 end sub diff --git a/Task/Ethiopian-multiplication/Z80-Assembly/ethiopian-multiplication.z80 b/Task/Ethiopian-multiplication/Z80-Assembly/ethiopian-multiplication.z80 index 5641a4f8c2..cbc6ebf0a0 100644 --- a/Task/Ethiopian-multiplication/Z80-Assembly/ethiopian-multiplication.z80 +++ b/Task/Ethiopian-multiplication/Z80-Assembly/ethiopian-multiplication.z80 @@ -1,114 +1,114 @@ - org &8000 + org &8000 - ld hl,17 - call Halve_Until_1 - - push bc - ld hl,34 - call Double_Until_1 - pop bc - - call SumOddEntries - ;returns Ethiopian product in IX. - - call NewLine - - call Primm - byte "0x",0 - - push ix - pop hl - - ld a,H - call ShowHex - ;Output should be in decimal but hex is easier. - ld a,L - call ShowHex - - ret + ld hl,17 + call Halve_Until_1 + + push bc + ld hl,34 + call Double_Until_1 + pop bc + + call SumOddEntries + ;returns Ethiopian product in IX. + + call NewLine + + call Primm + byte "0x",0 + + push ix + pop hl + + ld a,H + call ShowHex + ;Output should be in decimal but hex is easier. + ld a,L + call ShowHex + + ret Halve_Until_1: - ;input: HL = number you wish to halve. HL is unsigned. - ld de,Column_1 - ld a,1 - ld (Column_1),HL - inc de - inc de + ;input: HL = number you wish to halve. HL is unsigned. + ld de,Column_1 + ld a,1 + ld (Column_1),HL + inc de + inc de loop_HalveUntil_1: - SRL H - RR L - inc b - push af - ld a,L - ld (de),a - inc de - ld a,H - ld (de),a - inc de - pop af - CP L - jr nz,loop_HalveUntil_1 - ;b tracks how many times to double the second factor. - ret - + SRL H + RR L + inc b + push af + ld a,L + ld (de),a + inc de + ld a,H + ld (de),a + inc de + pop af + CP L + jr nz,loop_HalveUntil_1 + ;b tracks how many times to double the second factor. + ret + Double_Until_1: - ;doubles second factor B times. B is calculated by Halve_until_1 - ld de,Column_2 - ld (Column_2),HL - inc de - inc de + ;doubles second factor B times. B is calculated by Halve_until_1 + ld de,Column_2 + ld (Column_2),HL + inc de + inc de loop_double_until_1: - SLA L - RL H - PUSH AF - LD A,L - LD (DE),A - INC DE - LD A,H - LD (DE),A - INC DE - POP AF - DJNZ loop_double_until_1 - ret - + SLA L + RL H + PUSH AF + LD A,L + LD (DE),A + INC DE + LD A,H + LD (DE),A + INC DE + POP AF + DJNZ loop_double_until_1 + ret + SumOddEntries: - sla b ;double loop counter, this is also the offset to the "last" entry of - ;each table - ld h,>Column_1 - ld d,>Column_2 ;aligning the tables lets us get away with this. - ld l,b - ld e,b - ld ix,0 + sla b ;double loop counter, this is also the offset to the "last" entry of + ;each table + ld h,>Column_1 + ld d,>Column_2 ;aligning the tables lets us get away with this. + ld l,b + ld e,b + ld ix,0 loop: - ld a,(hl) - rrca ;we only need the result of the odd/even test. - jr nc,skipEven - push hl - push de - ld a,(de) - ld L,a - inc de - ld a,(de) - ld H,a - ex de,hl - add ix,de - pop de - pop hl + ld a,(hl) + rrca ;we only need the result of the odd/even test. + jr nc,skipEven + push hl + push de + ld a,(de) + ld L,a + inc de + ld a,(de) + ld H,a + ex de,hl + add ix,de + pop de + pop hl skipEven: - dec de - dec de - dec hl - dec hl - djnz loop - ret ;ix should contain the answer + dec de + dec de + dec hl + dec hl + djnz loop + ret ;ix should contain the answer - - align 8 ;aligns Column_1 to the nearest 256 byte boundary. This makes offsetting easier. + + align 8 ;aligns Column_1 to the nearest 256 byte boundary. This makes offsetting easier. Column_1: - ds 16,0 - - align 8 ;aligns Column_2 to the nearest 256 byte boundary. This makes offsetting easier. + ds 16,0 + + align 8 ;aligns Column_2 to the nearest 256 byte boundary. This makes offsetting easier. Column_2: - ds 16,0 + ds 16,0 diff --git a/Task/Euclid-Mullin-sequence/ALGOL-W/euclid-mullin-sequence.alg b/Task/Euclid-Mullin-sequence/ALGOL-W/euclid-mullin-sequence.alg deleted file mode 100644 index 4614fbc786..0000000000 --- a/Task/Euclid-Mullin-sequence/ALGOL-W/euclid-mullin-sequence.alg +++ /dev/null @@ -1,22 +0,0 @@ -begin % find elements of the Euclid-Mullin sequence: starting from 2, % - % the next element is the smallest prime factor of 1 + the product % - % of the previous elements % - integer product; - write( "2" ); - product := 2; - for i := 2 until 8 do begin - integer nextV, p; - logical found; - nextV := product + 1; - % find the first prime factor of nextV % - p := 3; - found := false; - while p * p <= nextV and not found do begin - found := nextV rem p = 0; - if not found then p := p + 2 - end while_p_squared_le_nextV_and_not_found ; - if found then nextV := p; - writeon( i_w := 1, s_w := 0, " ", nextV ); - product := product * nextV - end for_i -end. diff --git a/Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence-2.awk b/Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence-2.awk deleted file mode 100644 index 9396392f84..0000000000 --- a/Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence-2.awk +++ /dev/null @@ -1,24 +0,0 @@ -# find elements of the Euclid-Mullin sequence: starting from 2, -# the next element is the smallest prime factor of 1 + the product -# of the previous elements -BEGIN { - printf( "2" ); - product = 2; - for( i = 2; i <= 8; i ++ ) - { - nextV = product + 1; - # find the first prime factor of nextV - p = 3; - found = 0; - while( p * p <= nextV && ! ( found = nextV % p == 0 ) ) - { - p += 2; - } - if( found ) - { - nextV = p; - } - printf( " %d", nextV ); - product *= nextV - } -} diff --git a/Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence-1.awk b/Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence.awk similarity index 100% rename from Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence-1.awk rename to Task/Euclid-Mullin-sequence/AWK/euclid-mullin-sequence.awk diff --git a/Task/Euclid-Mullin-sequence/C++/euclid-mullin-sequence.cpp b/Task/Euclid-Mullin-sequence/C++/euclid-mullin-sequence.cpp deleted file mode 100644 index 11e98dc402..0000000000 --- a/Task/Euclid-Mullin-sequence/C++/euclid-mullin-sequence.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -uint64_t product = 2; - -uint64_t smallest_prime_factor(const uint64_t& number) { - if ( number % 3 == 0 ) { return 3; } - if ( number % 5 == 0 ) { return 5; } - - for ( uint64_t divisor = 7; divisor * divisor <= number; divisor += 2 ) { - if ( number % divisor == 0 ) { return divisor; } - } - - return number; -} - -uint64_t next_euclid_mullin() { - const uint64_t smallest_prime = smallest_prime_factor(product + 1); - product *= smallest_prime; - return smallest_prime; -} - -int main() { - std::cout << "The first 9 terms of the Euclid-Mullin sequence:" << "\n"; - std::cout << 2 << " "; - for ( uint32_t i = 1; i < 9; ++i ) { - std::cout << next_euclid_mullin() << " "; - } - std::cout << "\n"; -} diff --git a/Task/Euclid-Mullin-sequence/Craft-Basic/euclid-mullin-sequence.basic b/Task/Euclid-Mullin-sequence/Craft-Basic/euclid-mullin-sequence.basic index 0344004627..562a7a1d4e 100644 --- a/Task/Euclid-Mullin-sequence/Craft-Basic/euclid-mullin-sequence.basic +++ b/Task/Euclid-Mullin-sequence/Craft-Basic/euclid-mullin-sequence.basic @@ -2,7 +2,7 @@ define size = 16, em = 0 dim list[size] let list[0] = 2 -print 2, " ", +print 2 for i = 1 to 15 @@ -14,16 +14,16 @@ for i = 1 to 15 for j = 0 to i - 1 - let em = (em * list[j]) % k + let em = ( em * list[j] ) % k next j - let em = (em + 1) % k + let em = ( em + 1 ) % k if em = 0 then let list[i] = k - print list[i], " ", + print list[i] break endif @@ -35,3 +35,7 @@ for i = 1 to 15 loop next i + +print "done." + +end diff --git a/Task/Euclid-Mullin-sequence/EasyLang/euclid-mullin-sequence.easy b/Task/Euclid-Mullin-sequence/EasyLang/euclid-mullin-sequence.easy deleted file mode 100644 index 0bbed926a2..0000000000 --- a/Task/Euclid-Mullin-sequence/EasyLang/euclid-mullin-sequence.easy +++ /dev/null @@ -1,17 +0,0 @@ -arr[] = [ 2 ] -fastproc . - for i = 2 to 8 - k = 3 - repeat - em = 1 - for j = 1 to i - 1 - em = em * arr[j] mod k - . - em = (em + 1) mod k - until em = 0 - k += 2 - . - arr[] &= k - . -. -print arr[] diff --git a/Task/Euclid-Mullin-sequence/Fennel/euclid-mullin-sequence.fennel b/Task/Euclid-Mullin-sequence/Fennel/euclid-mullin-sequence.fennel deleted file mode 100644 index 5f18e0534c..0000000000 --- a/Task/Euclid-Mullin-sequence/Fennel/euclid-mullin-sequence.fennel +++ /dev/null @@ -1,18 +0,0 @@ -(do ;;; find elements of the Euclid-Mullin sequence: starting from 2, - ;;; the next element is the smallest prime factor of 1 + the product - ;;; of the previous elements - - (io.write "2") - (var product 2) - (for [i 2 9] - (var (nextV p found) (values (+ product 1) 3 false)) - ; find the first prime factor of nextV - (while (and (<= (* p p) nextV) (not found)) - (set found (= 0 (% nextV p))) - (when (not found) (set p (+ p 2))) - ) - (when found (set nextV p)) - (io.write (.. " " nextV)) - (set product (* product nextV)) - ) -) diff --git a/Task/Euclid-Mullin-sequence/FutureBasic/euclid-mullin-sequence.basic b/Task/Euclid-Mullin-sequence/FutureBasic/euclid-mullin-sequence.basic deleted file mode 100644 index f6c83a34f6..0000000000 --- a/Task/Euclid-Mullin-sequence/FutureBasic/euclid-mullin-sequence.basic +++ /dev/null @@ -1,57 +0,0 @@ -// -// Euclid-Mullin Sequence -// Using FutureBasic 7.0.35 -// -// September 2025, R.W. -// - -include "gmp.incl" - -_TERMS = 16 // first 16 Euclid–Mullin Sequence - -// Return a non-trivial factor of n using Pollard-Rho - -void local fn PollardRho( n as mpz_t, out as mpz_t ) - mpz_t x,y,c,d,absDiff - mpz_inits( x, y, c, d, absDiff, 0 ) - mpz_set_ui( x, 2 ) : mpz_set_ui( y, 2 ) : mpz_set_ui( c, 1 ) - mpz_set_ui( d, 1 ) - while fn mpz_cmp_ui( d, 1 ) == 0 - // x = (x*x + c) mod n - mpz_mul( x, x, x ) : mpz_add( x, x, c ) : mpz_mod( x, x, n ) - // y = f(f(y)) - mpz_mul( y, y, y ) : mpz_add( y, y, c ) : mpz_mod( y, y, n ) - mpz_mul( y, y, y ) : mpz_add( y, y, c ) : mpz_mod( y, y, n ) - // d = gcd(|x-y|, n) - mpz_sub( absDiff, x, y ) : mpz_abs( absDiff, absDiff ) - fn mpz_gcd( d, absDiff, n ) - wend - mpz_set( out, d ) - mpz_clears( x,y,c,d,absDiff,0 ) -end fn - -void local fn EuclidMullin( terms as long ) - CFStringRef result - mpz_t total, tmp, factor - mpz_inits( total, tmp, factor, 0 ) - mpz_set_ui( total, 1 ) - print @ - print @"First ";terms;" numbers of Euclid-Mullin sequence" - print @ - long k - for k = 1 to _TERMS - mpz_add_ui( tmp, total, 1 ) // tmp = total + 1 - fn PollardRho( tmp, factor ) // factor = some factor of tmp - result = fn mpz_cf2( factor ) - print result - mpz_mul( total, total, factor ) // total *= factor - next - - mpz_clears( total, tmp, factor, 0 ) -end fn - -window 1, @"Euclid-Mullin Sequence" - -fn EuclidMullin(_TERMS ) - -handleEvents diff --git a/Task/Euclid-Mullin-sequence/Go/euclid-mullin-sequence.go b/Task/Euclid-Mullin-sequence/Go/euclid-mullin-sequence.go index 328d2b9bb8..695ab60ff7 100644 --- a/Task/Euclid-Mullin-sequence/Go/euclid-mullin-sequence.go +++ b/Task/Euclid-Mullin-sequence/Go/euclid-mullin-sequence.go @@ -15,7 +15,7 @@ var ( five = big.NewInt(5) six = big.NewInt(6) ten = big.NewInt(10) - k100 = big.NewInt(100000) + max = big.NewInt(100000) ) func pollardRho(n, c *big.Int) *big.Int { @@ -51,7 +51,7 @@ func pollardRho(n, c *big.Int) *big.Int { return d } -func smallestPrimeFactorWheel(n, max *big.Int) *big.Int { +func smallestPrimeFactorWheel(n *big.Int) *big.Int { if n.ProbablyPrime(15) { return n } @@ -82,13 +82,13 @@ func smallestPrimeFactorWheel(n, max *big.Int) *big.Int { } func smallestPrimeFactor(n *big.Int) *big.Int { - s := smallestPrimeFactorWheel(n, k100) + s := smallestPrimeFactorWheel(n) if s != nil { return s } c := big.NewInt(1) s = new(big.Int).Set(n) - for { + for n.Cmp(max) > 0 { d := pollardRho(n, c) if d.Cmp(zero) == 0 { if c.Cmp(ten) == 0 { @@ -96,21 +96,20 @@ func smallestPrimeFactor(n *big.Int) *big.Int { } c.Add(c, one) } else { - // get the smallest prime factor of 'd' - factor := smallestPrimeFactorWheel(d, d) - // check whether n/d has a smaller prime factor - s = smallestPrimeFactorWheel(n.Quo(n, d), factor) - if s != nil { - if s.Cmp(factor) < 0 { - return s - } else { - return factor + // can't be sure PR will find the smallest prime factor first + if d.Cmp(s) < 0 { + s.Set(d) + } + n.Quo(n, d) + if n.ProbablyPrime(5) { + if n.Cmp(s) < 0 { + return n } - } else { - return factor + return s } } } + return s } func main() { diff --git a/Task/Euclid-Mullin-sequence/J/euclid-mullin-sequence.j b/Task/Euclid-Mullin-sequence/J/euclid-mullin-sequence.j deleted file mode 100644 index 4c1210c282..0000000000 --- a/Task/Euclid-Mullin-sequence/J/euclid-mullin-sequence.j +++ /dev/null @@ -1,2 +0,0 @@ - 2x (, <./@(>:&.(*/)))@[&_~ 15 -2 3 7 43 13 53 5 6221671 38709183810571 139 2801 11 17 5471 52662739 23003 diff --git a/Task/Euclid-Mullin-sequence/Java/euclid-mullin-sequence.java b/Task/Euclid-Mullin-sequence/Java/euclid-mullin-sequence.java index 6c4836716f..5b6dd746e1 100644 --- a/Task/Euclid-Mullin-sequence/Java/euclid-mullin-sequence.java +++ b/Task/Euclid-Mullin-sequence/Java/euclid-mullin-sequence.java @@ -4,20 +4,20 @@ import java.util.BitSet; import java.util.List; import java.util.concurrent.ThreadLocalRandom; -public final class EuclidMullinSequence { +public class EulerMullinSequence { public static void main(String[] aArgs) { primes = listPrimesUpTo(1_000_000); - System.out.println("The first 27 terms of the Euclid-Mullin sequence:"); - System.out.print(2 + " "); + System.out.println("The first 27 terms of the Euler-Mullin sequence:"); + System.out.println(2); for ( int i = 1; i < 27; i++ ) { - System.out.print( - String.format("%s%s", nextEuclidMullin(), ( i == 14 || i == 27 ) ? "\n" : " ")); + System.out.println(nextEulerMullin()); } + } - private static BigInteger nextEuclidMullin() { + private static BigInteger nextEulerMullin() { BigInteger smallestPrime = smallestPrimeFactor(product.add(BigInteger.ONE)); product = product.multiply(smallestPrime); @@ -25,7 +25,7 @@ public final class EuclidMullinSequence { } private static BigInteger smallestPrimeFactor(BigInteger aNumber) { - if ( aNumber.isProbablePrime(CERTAINTY_LEVEL) ) { + if ( aNumber.isProbablePrime(probabilityLevel) ) { return aNumber; } @@ -67,8 +67,9 @@ public final class EuclidMullinSequence { BitSet sieve = new BitSet(aLimit + 1); sieve.set(2, aLimit + 1); - for ( int i = 2; i * i <= aLimit; i = sieve.nextSetBit(i + 1) ) { - for ( int j = i * i; j <= aLimit; j += i ) { + final int squareRoot = (int) Math.sqrt(aLimit); + for ( int i = 2; i <= squareRoot; i = sieve.nextSetBit(i + 1) ) { + for ( int j = i * i; j <= aLimit; j = j + i ) { sieve.clear(j); } } @@ -85,6 +86,6 @@ public final class EuclidMullinSequence { private static BigInteger product = BigInteger.TWO; private static ThreadLocalRandom random = ThreadLocalRandom.current(); - private static final int CERTAINTY_LEVEL = 20; + private static final int probabilityLevel = 20; } diff --git a/Task/Euclid-Mullin-sequence/JavaScript/euclid-mullin-sequence.js b/Task/Euclid-Mullin-sequence/JavaScript/euclid-mullin-sequence.js deleted file mode 100644 index 05dfefc61c..0000000000 --- a/Task/Euclid-Mullin-sequence/JavaScript/euclid-mullin-sequence.js +++ /dev/null @@ -1,20 +0,0 @@ - let product = 2n; - function smallestPrimeFactor(number) { - if (number % 3n === 0n) { return 3n; } - if (number % 5n === 0n) { return 5n; } - for (let divisor = 7n; divisor * divisor <= number; divisor += 2n) { - if (number % divisor === 0n) { return divisor; } - } - return number; - } - function nextEuclidMullin() { - const smallestPrime = smallestPrimeFactor(product + 1n); - product *= smallestPrime; - return smallestPrime; - } - console.log("The first 9 terms of the Euclid-Mullin sequence:"); - process.stdout.write(2 + " "); - for (let i = 1; i < 9; ++i) { - process.stdout.write(nextEuclidMullin() + " "); - } - console.log("\n"); diff --git a/Task/Euclid-Mullin-sequence/Julia/euclid-mullin-sequence.jl b/Task/Euclid-Mullin-sequence/Julia/euclid-mullin-sequence.julia similarity index 100% rename from Task/Euclid-Mullin-sequence/Julia/euclid-mullin-sequence.jl rename to Task/Euclid-Mullin-sequence/Julia/euclid-mullin-sequence.julia diff --git a/Task/Euclid-Mullin-sequence/Lua/euclid-mullin-sequence-1.lua b/Task/Euclid-Mullin-sequence/Lua/euclid-mullin-sequence-1.lua deleted file mode 100644 index d8ed7d4919..0000000000 --- a/Task/Euclid-Mullin-sequence/Lua/euclid-mullin-sequence-1.lua +++ /dev/null @@ -1,18 +0,0 @@ --- find elements of the Euclid-Mullin sequence: starting from 2, --- the next element is the smallest prime factor of 1 + the product --- of the previous elements -do - io.write( "2" ) - local product = 2 - for i = 2, 9 do - local nextV, p, found = product + 1, 3, false - -- find the first prime factor of nextV - while p * p <= nextV and not found do - found = nextV % p == 0 - if not found then p = p + 2 end - end - if found then nextV = p end - io.write( " ", nextV ) - product = product * nextV - end -end diff --git a/Task/Euclid-Mullin-sequence/Lua/euclid-mullin-sequence-2.lua b/Task/Euclid-Mullin-sequence/Lua/euclid-mullin-sequence-2.lua deleted file mode 100644 index d352302ed7..0000000000 --- a/Task/Euclid-Mullin-sequence/Lua/euclid-mullin-sequence-2.lua +++ /dev/null @@ -1,24 +0,0 @@ -function gcd(a,b) - while b~=0 do - a,b=b,a%b - end - return math.abs(a) -end -function pollard_rho(n) - local x, y, d = 2, 2, 1 - local g = function(x) return (x*x+1) % n end - while d == 1 do - x = g(x) - y = g(g(y)) - d = gcd(math.abs(x-y),n) - end - if d == n then return d end - return math.min(d, math.floor( n/d ) ) -end - -local ar, product = {2}, 2 -repeat - ar[ #ar + 1 ] = pollard_rho( product + 1 ) - product = product * ar[ #ar ] -until #ar >= 8 -print( table.concat(ar, " ") ) diff --git a/Task/Euclid-Mullin-sequence/Maxima/euclid-mullin-sequence.maxima b/Task/Euclid-Mullin-sequence/Maxima/euclid-mullin-sequence.maxima deleted file mode 100644 index 7f74057ca2..0000000000 --- a/Task/Euclid-Mullin-sequence/Maxima/euclid-mullin-sequence.maxima +++ /dev/null @@ -1,4 +0,0 @@ -euclid_mullin(n):=if n=1 then 2 else ifactors(1+product(euclid_mullin(i),i,1,n-1))[1][1]$ - -/* Test case */ -makelist(euclid_mullin(k),k,16); diff --git a/Task/Euclid-Mullin-sequence/MiniScript/euclid-mullin-sequence.mini b/Task/Euclid-Mullin-sequence/MiniScript/euclid-mullin-sequence.mini deleted file mode 100644 index 37cc90325a..0000000000 --- a/Task/Euclid-Mullin-sequence/MiniScript/euclid-mullin-sequence.mini +++ /dev/null @@ -1,19 +0,0 @@ -// find elements of the Euclid-Mullin sequence: starting from 2, -// the next element is the smallest prime factor of 1 + the product -// of the previous elements -seq = [2] -product = 2 -for i in range( 2, 8 ) - nextV = product + 1 - // find the first prime factor of nextV - p = 3 - found = false - while p * p <= nextV and not found - found = nextV % p == 0 - if not found then p = p + 2 - end while - if found then nextV = p - seq.push( nextV ) - product = product * nextV -end for -print seq.join( " ") diff --git a/Task/Euclid-Mullin-sequence/Oberon-07/euclid-mullin-sequence.oberon b/Task/Euclid-Mullin-sequence/Oberon-07/euclid-mullin-sequence.oberon deleted file mode 100644 index 178ae1c826..0000000000 --- a/Task/Euclid-Mullin-sequence/Oberon-07/euclid-mullin-sequence.oberon +++ /dev/null @@ -1,29 +0,0 @@ -MODULE EuclidMullinSequence; (* find elements of the Euclid-Mullin sequence: *) - IMPORT Out; (* starting from 2, the next element is the smallest *) - (* prime factor of 1 + the product of the previous *) - (* elements *) - - (* assuming INTEGER is 32-bit, we should be able to *) - (* find 8 elements, before the product overflows *) - - VAR product, i, nextV, p : INTEGER; - found : BOOLEAN; - -BEGIN - - Out.String( "2" ); - product := 2; - FOR i := 2 TO 8 DO - nextV := product + 1; - (* find the first prime factor of nextV *) - p := 3; - found := FALSE; - WHILE ~ found & ( p * p <= nextV ) DO - found := nextV MOD p = 0; - IF ~ found THEN INC( p, 2 ) END - END; - IF found THEN nextV := p END; - Out.String( " " );Out.Int( nextV, 0 ); - product := product * nextV - END -END EuclidMullinSequence. diff --git a/Task/Euclid-Mullin-sequence/Oberon/euclid-mullin-sequence.oberon b/Task/Euclid-Mullin-sequence/Oberon/euclid-mullin-sequence.oberon deleted file mode 100644 index b735a6b4c2..0000000000 --- a/Task/Euclid-Mullin-sequence/Oberon/euclid-mullin-sequence.oberon +++ /dev/null @@ -1,29 +0,0 @@ -MODULE EuclidMullinSequence; (* find elements of the Euclid-Mullin sequence: *) - IMPORT Out; (* starting from 2, the next element is the smallest *) - (* prime factor of 1 + the product of the previous *) - (* elements *) - - (* assuming LONGINT is 64-bit, we should be able to *) - (* find 9 elements, before the product overflows *) - - VAR product, i, nextV, p : LONGINT; - found : BOOLEAN; - -BEGIN - - Out.String( "2" ); - product := 2; - FOR i := 2 TO 9 DO - nextV := product + 1; - (* find the first prime factor of nextV *) - p := 3; - found := FALSE; - WHILE ~ found & ( p * p <= nextV ) DO - found := nextV MOD p = 0; - IF ~ found THEN INC( p, 2 ) END - END; - IF found THEN nextV := p END; - Out.String( " " );Out.Int( nextV, 0 ); - product := product * nextV - END -END EuclidMullinSequence. diff --git a/Task/Euclid-Mullin-sequence/PascalABC.NET/euclid-mullin-sequence.pas b/Task/Euclid-Mullin-sequence/PascalABC.NET/euclid-mullin-sequence.pas deleted file mode 100644 index 38999023a9..0000000000 --- a/Task/Euclid-Mullin-sequence/PascalABC.NET/euclid-mullin-sequence.pas +++ /dev/null @@ -1,29 +0,0 @@ -function smallest_prime_factor(number: biginteger): biginteger; -begin - var divisor := 3bi; - repeat - if (number mod divisor) = 0 then - begin - result := divisor; - exit - end; - divisor += 2; - until divisor * divisor > number; - result := number; -end; - -function euclid_mullin(): sequence of biginteger; -begin - var product := 2bi; - yield product; - while true do - begin - var smallest_prime := smallest_prime_factor(product + 1); - product *= smallest_prime; - yield smallest_prime; - end; -end; - -begin - euclid_mullin.take(16).println; -end. diff --git a/Task/Euclid-Mullin-sequence/Pluto/euclid-mullin-sequence.pluto b/Task/Euclid-Mullin-sequence/Pluto/euclid-mullin-sequence.pluto deleted file mode 100644 index 9e6b45651e..0000000000 --- a/Task/Euclid-Mullin-sequence/Pluto/euclid-mullin-sequence.pluto +++ /dev/null @@ -1,22 +0,0 @@ --- find elements of the Euclid-Mullin sequence: starting from 2, --- the next element is the smallest prime factor of 1 + the product --- of the previous elements -do - local bigint = require( "pluto:bigint" ) -- use the standard bigint library - - io.write( "2" ) - local b0 , b1 , b2 , b3 - = new bigint( 0 ), new bigint( 1 ), new bigint( 2 ), new bigint( 3 ) - local product = new bigint( 2 ) - for _ = 2, 16 do - local nextV, p, found = product + b1, b3, false - -- find the first prime factor of nextV - while p * p <= nextV and not found do - found = nextV % p == b0 - if not found then p += b2 end - end - if found then nextV = p end - io.write( $" { nextV:tostring() }" ) - product *= nextV - end -end diff --git a/Task/Euclid-Mullin-sequence/R/euclid-mullin-sequence.r b/Task/Euclid-Mullin-sequence/R/euclid-mullin-sequence.r deleted file mode 100644 index d81fa0cb94..0000000000 --- a/Task/Euclid-Mullin-sequence/R/euclid-mullin-sequence.r +++ /dev/null @@ -1,10 +0,0 @@ -library(gmp) - -next_term <- function(v) min(factorize(prod(v)+1)) -euclid_mullin <- function(n){ - v <- as.bigz(2) - replicate(n-1, v <<- c(v, next_term(v))) - print(v, initLine=FALSE) -} - -euclid_mullin(16) diff --git a/Task/Euclid-Mullin-sequence/REXX/euclid-mullin-sequence.rexx b/Task/Euclid-Mullin-sequence/REXX/euclid-mullin-sequence.rexx deleted file mode 100644 index c681066ff1..0000000000 --- a/Task/Euclid-Mullin-sequence/REXX/euclid-mullin-sequence.rexx +++ /dev/null @@ -1,22 +0,0 @@ --- 23 Aug 2025 -include Setting - -say 'EUCLID-MULLIN SEQUENCE' -say version -say -numeric digits 100 -call Euclids 16 -call Task 16 -say Format(Time('e'),,3) 'seconds' -exit - -Task: -arg xx -say 'The first' xx 'Euclid-Mullin numbers are:' -do i = 1 to xx - call Charout ,eucl.i' ' -end -say -return - -include Math diff --git a/Task/Euclid-Mullin-sequence/Ring/euclid-mullin-sequence.ring b/Task/Euclid-Mullin-sequence/Ring/euclid-mullin-sequence.ring deleted file mode 100644 index 5a4239f730..0000000000 --- a/Task/Euclid-Mullin-sequence/Ring/euclid-mullin-sequence.ring +++ /dev/null @@ -1,18 +0,0 @@ -// find elements of the Euclid-Mullin sequence: starting from 2, -// the next element is the smallest prime factor of 1 + the product -// of the previous elements -see "2" -product = 2 -for i = 2 to 8 - nextV = product + 1 - // find the first prime factor of nextV - p = 3 - found = false - while p * p <= nextV and not found - found = ( nextV % p ) = 0 - if not found p = p + 2 ok - end - if found nextV = p ok - see " " + nextV - product = product * nextV -next diff --git a/Task/Euclid-Mullin-sequence/Ruby/euclid-mullin-sequence.rb b/Task/Euclid-Mullin-sequence/Ruby/euclid-mullin-sequence.rb deleted file mode 100644 index 2351ffe3ee..0000000000 --- a/Task/Euclid-Mullin-sequence/Ruby/euclid-mullin-sequence.rb +++ /dev/null @@ -1,15 +0,0 @@ -def pollard_rho(n) - x, y, d = 2, 2, 1 - g = proc{|x|(x*x+1) % n} - while d == 1 do - x = g[x] - y = g[g[y]] - d = (x-y).abs.gcd(n) - end - return d if d == n - [d, n/d].compact.min -end - -ar = [2] -ar << pollard_rho(ar.inject(&:*)+1) until ar.size >= 16 -puts ar.join(", ") diff --git a/Task/Euclid-Mullin-sequence/SETL/euclid-mullin-sequence.setl b/Task/Euclid-Mullin-sequence/SETL/euclid-mullin-sequence.setl deleted file mode 100644 index 41731276ee..0000000000 --- a/Task/Euclid-Mullin-sequence/SETL/euclid-mullin-sequence.setl +++ /dev/null @@ -1,19 +0,0 @@ -program euclid_mullin; - print(2); - product := 2; - loop for i in [2..16] do - next := smallest_factor(product + 1); - product *:= next; - print(next); - end loop; - - op smallest_factor(n); - if even n then return 2; end if; - d := 3; - loop while d*d <= n do - if n mod d=0 then return d; end if; - d +:= 2; - end loop; - return n; - end op; -end program; diff --git a/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-1.wren b/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-1.wren index f4cb0f99b6..648d20f2bf 100644 --- a/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-1.wren +++ b/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-1.wren @@ -4,9 +4,33 @@ var zero = BigInt.zero var one = BigInt.one var two = BigInt.two var ten = BigInt.ten -var k100 = BigInt.new(100000) +var max = BigInt.new(100000) -var smallestPrimeFactorWheel = Fn.new { |n, max| +var pollardRho = Fn.new { |n, c| + var g = Fn.new { |x, y| (x*x + c) % n } + var x = two + var y = two + var z = one + var d = max + one + var count = 0 + while (true) { + x = g.call(x, n) + y = g.call(g.call(y, n), n) + d = (x - y).abs % n + z = z * d + count = count + 1 + if (count == 100) { + d = BigInt.gcd(z, n) + if (d != one) break + z = one + count = 0 + } + } + if (d == n) return zero + return d +} + +var smallestPrimeFactorWheel = Fn.new { |n| if (n.isProbablePrime(5)) return n if (n % 2 == zero) return BigInt.two if (n % 3 == zero) return BigInt.three @@ -23,22 +47,23 @@ var smallestPrimeFactorWheel = Fn.new { |n, max| } var smallestPrimeFactor = Fn.new { |n| - var s = smallestPrimeFactorWheel.call(n, k100) + var s = smallestPrimeFactorWheel.call(n) if (s) return s var c = one - while (true) { - var d = BigInt.pollardRho(n, 2, c) + s = n + while (n > max) { + var d = pollardRho.call(n, c) if (d == 0) { if (c == ten) Fiber.abort("Pollard Rho doesn't appear to be working.") c = c + one } else { - // get the smallest prime factor of 'd' - var factor = smallestPrimeFactorWheel.call(d, d) - // check whether n/d has a smaller prime factor - s = smallestPrimeFactorWheel.call(n/d, factor) - return s ? BigInt.min(s, factor) : factor + // can't be sure PR will find the smallest prime factor first + s = BigInt.min(s, d) + n = n / d + if (n.isProbablePrime(2)) return BigInt.min(s, n) } } + return s } var k = 16 diff --git a/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-2.wren b/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-2.wren index b0d73b9fa1..69fded1753 100644 --- a/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-2.wren +++ b/Task/Euclid-Mullin-sequence/Wren/euclid-mullin-sequence-2.wren @@ -1,39 +1,46 @@ -/* Euclid_mullin_sequence_2.wren */ +/* euclid_mullin_gmp.wren */ import "./gmp" for Mpz -var k100 = Mpz.from(100000) +var max = Mpz.from(100000) -var smallestPrimeFactorTrial = Fn.new { |n, max| +var smallestPrimeFactorWheel = Fn.new { |n| if (n.probPrime(15) > 0) return n - var k = Mpz.one + if (n.isEven) return Mpz.two + if (n.isDivisibleUi(3)) return Mpz.three + if (n.isDivisibleUi(5)) return Mpz.five + var k = Mpz.from(7) + var i = 0 + var inc = [4, 2, 4, 2, 4, 6, 2, 6] while (k * k <= n) { - k.nextPrime - if (k > max) return null if (n.isDivisible(k)) return k + k.add(inc[i]) + if (k > max) return null + i = (i + 1) % 8 } } var smallestPrimeFactor = Fn.new { |n| - var s = smallestPrimeFactorTrial.call(n, k100) + var s = smallestPrimeFactorWheel.call(n) if (s) return s var c = Mpz.one - while (true) { + s = n.copy() + while (n > max) { var d = Mpz.pollardRho(n, 2, c) if (d.isZero) { if (c == 100) Fiber.abort("Pollard Rho doesn't appear to be working.") c.inc } else { - // get the smallest prime factor of 'd' - var factor = smallestPrimeFactorTrial.call(d, d) - // check whether n/d has a smaller prime factor - s = smallestPrimeFactorTrial.call(n/d, factor) - return s ? Mpz.min(s, factor) : factor + // can't be sure PR will find the smallest prime factor first + s.min(d) + n.div(d) + if (n.probPrime(5) > 0) return Mpz.min(s, n) } } + return s } -var k = 27 +var k = 19 System.print("First %(k) terms of the Euclid–Mullin sequence:") System.print(2) var prod = Mpz.two diff --git a/Task/Euler-method/Ada/euler-method-1.adb b/Task/Euler-method/Ada/euler-method-1.ada similarity index 100% rename from Task/Euler-method/Ada/euler-method-1.adb rename to Task/Euler-method/Ada/euler-method-1.ada diff --git a/Task/Euler-method/Ada/euler-method-2.adb b/Task/Euler-method/Ada/euler-method-2.ada similarity index 100% rename from Task/Euler-method/Ada/euler-method-2.adb rename to Task/Euler-method/Ada/euler-method-2.ada diff --git a/Task/Euler-method/Ada/euler-method-3.adb b/Task/Euler-method/Ada/euler-method-3.ada similarity index 100% rename from Task/Euler-method/Ada/euler-method-3.adb rename to Task/Euler-method/Ada/euler-method-3.ada diff --git a/Task/Euler-method/Applesoft-BASIC/euler-method.basic b/Task/Euler-method/Applesoft-BASIC/euler-method.basic deleted file mode 100644 index 5bb3f0bab6..0000000000 --- a/Task/Euler-method/Applesoft-BASIC/euler-method.basic +++ /dev/null @@ -1,27 +0,0 @@ -100 HOME -110 PRINT "Time "; -120 FOR S = 0 TO 100.1 STEP 10 -130 PRINT S; " "; -140 NEXT S -150 PRINT -160 PRINT "Dif eq "; -170 FOR S = 0 TO 100.1 STEP 10 -180 LET T = 20+(100-20)*EXP(-.07*S) -190 PRINT LEFT$(STR$(T),5); " "; -200 NEXT S -210 PRINT -220 LET P = 2 : GOSUB 260 -230 LET P = 5 : GOSUB 260 -240 LET P = 10 : GOSUB 260 -250 END -260 REM Euler(paso) -270 LET S = 0 -280 LET T = 100 -290 PRINT "Step ";P; " "; -300 FOR S = 0 TO 100 STEP P -310 IF S - (S/10) * 10 = 0 THEN PRINT LEFT$(STR$(T),5); " "; -320 LET T = T+(P)*(-.07*(T-20)) -330 IF S > 100 THEN GOTO 350 -340 NEXT S -350 PRINT -360 RETURN diff --git a/Task/Euler-method/BASIC256/euler-method.basic b/Task/Euler-method/BASIC256/euler-method.basic deleted file mode 100644 index 54074d0bd6..0000000000 --- a/Task/Euler-method/BASIC256/euler-method.basic +++ /dev/null @@ -1,34 +0,0 @@ -print "Time "; -tiempo = 0.0 -while tiempo <= 100.1 - print rjust(string(tiempo), 5); " "; - tiempo += 10.0 -end while -print - -print "Dif eq "; -tiempo = 0.0 -while tiempo <= 100.1 - temperatura = 20.0 + (100.0-20.0) * exp(-0.07*tiempo) - print rjust(left(string(temperatura), 5), 5); " "; - tiempo += 10.0 -end while -print - -call Euler(2) -call Euler(5) -call Euler(10) -end - -subroutine Euler(paso) - tiempo = 0 - temperatura = 100.0 - print "Step "; rjust(string(paso), 2); " "; - - while tiempo <= 100 - if (tiempo mod 10) = 0 then print rjust(left(string(temperatura), 5), 5); " "; - temperatura += float(paso) * (-0.07*(temperatura-20.0)) - tiempo += paso - end while - print -end subroutine diff --git a/Task/Euler-method/C-sharp/euler-method.cs b/Task/Euler-method/C-sharp/euler-method.cs index 0491640ac8..9b7d1f041f 100644 --- a/Task/Euler-method/C-sharp/euler-method.cs +++ b/Task/Euler-method/C-sharp/euler-method.cs @@ -2,37 +2,37 @@ using System; namespace prog { - class MainClass - { - const float T0 = 100f; - const float TR = 20f; - const float k = 0.07f; - readonly static float[] delta_t = {2.0f,5.0f,10.0f}; - const int n = 100; - - public delegate float func(float t); - static float NewtonCooling(float t) - { - return -k * (t-TR); - } - - public static void Main (string[] args) - { - func f = new func(NewtonCooling); - for(int i=0; i x2 and x_start > x2) - ) - from cte -); - -create or replace function euler(x_start, y_start, x2, h) as ( - select last(y order by x) from euler_method(x_start, y_start, x2, h) -); - -## Example: -create or replace function cooling(x,y) as - -0.07 * (y - 20); - -select h, euler(0,100, 100, h) from unnest([1,2,5,10,20]) _(h); diff --git a/Task/Euler-method/EasyLang/euler-method.easy b/Task/Euler-method/EasyLang/euler-method.easy deleted file mode 100644 index db168de994..0000000000 --- a/Task/Euler-method/EasyLang/euler-method.easy +++ /dev/null @@ -1,38 +0,0 @@ -TR = 20 -K = -0.07 -ytxt = 95 -drawgrid -glinewidth 0.3 -gtextsize 3 -# -func newton_cooling temp . - return K * (temp - TR) -. -proc draw_euler y t t2 step col . - gcolor col - gtext 80 ytxt "step: " & step - ytxt -= 5 - gpenup - while t <= t2 - glineto t y - t += step - y += step * newton_cooling y - . -. -func analytic T0 t . - return TR + (T0 - TR) * pow 2.71828 (K * t) -. -proc draw_analytic a b . - gcolor 009 - gtext 80 ytxt "analytic" - ytxt -= 5 - gpenup - for t = a to b - y = analytic 100 t - glineto t y - . -. -draw_euler 100 0 100 10 900 -draw_euler 100 0 100 5 555 -draw_euler 100 0 100 2 090 -draw_analytic 0 100 diff --git a/Task/Euler-method/Elixir/euler-method.ex b/Task/Euler-method/Elixir/euler-method.elixir similarity index 100% rename from Task/Euler-method/Elixir/euler-method.ex rename to Task/Euler-method/Elixir/euler-method.elixir diff --git a/Task/Euler-method/Erlang/euler-method.erl b/Task/Euler-method/Erlang/euler-method.erl index 4bf8857e9e..4f1549d0c4 100644 --- a/Task/Euler-method/Erlang/euler-method.erl +++ b/Task/Euler-method/Erlang/euler-method.erl @@ -2,37 +2,37 @@ -export([main/0, euler/5]). cooling(_Time, Temperature) -> - (-0.07)*(Temperature-20). + (-0.07)*(Temperature-20). euler(_, Y, T, _, End) when End == T -> - io:fwrite("\n"), - Y; + io:fwrite("\n"), + Y; euler(Func, Y, T, Step, End) -> - if - T rem 10 == 0 -> - io:fwrite("~.3f ",[float(Y)]); - true -> - ok - end, - euler(Func, Y + Step * Func(T, Y), T + Step, Step, End). + if + T rem 10 == 0 -> + io:fwrite("~.3f ",[float(Y)]); + true -> + ok + end, + euler(Func, Y + Step * Func(T, Y), T + Step, Step, End). analytic(T, End) when T == End -> - io:fwrite("\n"), - T; + io:fwrite("\n"), + T; analytic(T, End) -> - Y = (20 + 80 * math:exp(-0.07 * T)), - io:fwrite("~.3f ", [Y]), - analytic(T+10, End). + Y = (20 + 80 * math:exp(-0.07 * T)), + io:fwrite("~.3f ", [Y]), + analytic(T+10, End). main() -> - io:fwrite("Analytic:\n"), - analytic(0, 100), - io:fwrite("Step 2:\n"), - euler(fun cooling/2, 100, 0, 2, 100), - io:fwrite("Step 5:\n"), - euler(fun cooling/2, 100, 0, 5, 100), - io:fwrite("Step 10:\n"), - euler(fun cooling/2, 100, 0, 10, 100), - ok. + io:fwrite("Analytic:\n"), + analytic(0, 100), + io:fwrite("Step 2:\n"), + euler(fun cooling/2, 100, 0, 2, 100), + io:fwrite("Step 5:\n"), + euler(fun cooling/2, 100, 0, 5, 100), + io:fwrite("Step 10:\n"), + euler(fun cooling/2, 100, 0, 10, 100), + ok. diff --git a/Task/Euler-method/FutureBasic/euler-method.basic b/Task/Euler-method/FutureBasic/euler-method.basic deleted file mode 100644 index dfb5d86659..0000000000 --- a/Task/Euler-method/FutureBasic/euler-method.basic +++ /dev/null @@ -1,33 +0,0 @@ -include "NSLog.incl" - -double local fn Cooling( t as double, temp as double ) - return -0.07 * (temp - 20 ) -end fn = 0.0 - -void local fn Euler( y as double, stepSize as int, endTime as double ) - int t = 0 - NSLog( @"\n Step %2d: \b", stepSize ) - while ( t <= endTime ) - if ( t % 10 == 0 ) then NSLog( @" %7.3f \b", y ) - y += stepSize * fn Cooling( t, y ) - t += stepSize - wend -end fn - -void local fn Analytic - NSLog( @" Time: \b" ) - for int t1 = 0 to 100 step 10 - NSLog( @" %8d\b", t1 ) - next - NSLog( @"\nAnalytic: \b" ) - for int t2 = 0 to 100 step 10 - NSLog( @"%9.3f\b", 20 + 80 * exp(-0.07 * t2 ) ) - next -end fn - -fn Analytic -fn Euler( 100.0, 2.0, 100.0 ) -fn Euler( 100.0, 5.0, 100.0 ) -fn Euler( 100.0, 10.0, 100.0 ) - -HandleEvents diff --git a/Task/Euler-method/GW-BASIC/euler-method.basic b/Task/Euler-method/GW-BASIC/euler-method.basic deleted file mode 100644 index c047ea310a..0000000000 --- a/Task/Euler-method/GW-BASIC/euler-method.basic +++ /dev/null @@ -1,27 +0,0 @@ -100 CLS -110 PRINT "Time "; -120 FOR TIEMPO = 0 TO 100.1 STEP 10 -130 PRINT USING " ###";TIEMPO; -140 NEXT TIEMPO -150 PRINT -160 PRINT "Dif eq "; -170 FOR TIEMPO = 0 TO 100.1 STEP 10 -180 TEMPERATURA = 20+(100-20)*EXP(-.07*TIEMPO) -190 PRINT USING "###.##";TEMPERATURA; -200 NEXT TIEMPO -210 PRINT -220 PASO = 2 : GOSUB 260 -230 PASO = 5 : GOSUB 260 -240 PASO = 10 : GOSUB 260 -250 END -260 REM Euler(paso) -270 TIEMPO = 0 -280 TEMPERATURA = 100 -290 PRINT USING "Step ## ";PASO; -300 FOR TIEMPO = 0 TO 100 STEP PASO -310 IF (TIEMPO MOD 10) = 0 THEN PRINT USING "###.##";TEMPERATURA; -320 TEMPERATURA = TEMPERATURA+(PASO)*(-.07*(TEMPERATURA-20)) -330 IF TIEMPO > 100 THEN EXIT FOR -340 NEXT TIEMPO -350 PRINT -360 RETURN diff --git a/Task/Euler-method/Gambas/euler-method.gambas b/Task/Euler-method/Gambas/euler-method.gambas deleted file mode 100644 index 5079a41121..0000000000 --- a/Task/Euler-method/Gambas/euler-method.gambas +++ /dev/null @@ -1,42 +0,0 @@ -Public Sub Main() - - Dim tiempo As Float, temperatura As Float - - Print "Time "; - tiempo = 0.0 - While tiempo <= 100.1 - Print Format$(tiempo, "#######"); - tiempo += 10.0 - Wend - Print - - Print "Dif eq "; - tiempo = 0.0 - While tiempo <= 100.1 - temperatura = 20.0 + (100.0 - 20.0) * Exp(-0.07 * tiempo) - Print Format$(temperatura, "####.#0"); - tiempo += 10.0 - Wend - Print - - Euler(2) - Euler(5) - Euler(10) - -End - -Public Sub Euler(paso As Integer) - - Dim tiempo As Integer = 0 - Dim temperatura As Float = 100.0 - - Print "Step "; Format$(paso, "##"); " "; - - Do While tiempo <= 100 - If (tiempo Mod 10) = 0 Then Print Format$(temperatura, "####.#0"); - temperatura += (paso) * (-0.07 * (temperatura - 20.0)) - tiempo += paso - Loop - Print - -End Sub diff --git a/Task/Euler-method/JavaScript/euler-method.js b/Task/Euler-method/JavaScript/euler-method.js index edff7b850d..69666fe2e1 100644 --- a/Task/Euler-method/JavaScript/euler-method.js +++ b/Task/Euler-method/JavaScript/euler-method.js @@ -1,29 +1,29 @@ // Function that takes differential-equation, initial condition, // ending x, and step size as parameters function eulersMethod(f, x1, y1, x2, h) { - // Header - console.log("\tX\t|\tY\t"); - console.log("------------------------------------"); + // Header + console.log("\tX\t|\tY\t"); + console.log("------------------------------------"); - // Initial Variables - var x=x1, y=y1; + // Initial Variables + var x=x1, y=y1; - // While we're not done yet - // Both sides of the OR let you do Euler's Method backwards - while ((xx2 && x1>x2)) { - // Print what we have - console.log("\t" + x + "\t|\t" + y); + // While we're not done yet + // Both sides of the OR let you do Euler's Method backwards + while ((xx2 && x1>x2)) { + // Print what we have + console.log("\t" + x + "\t|\t" + y); - // Calculate the next values - y += h*f(x, y) - x += h; - } + // Calculate the next values + y += h*f(x, y) + x += h; + } - return y; + return y; } function cooling(x, y) { - return -0.07 * (y-20); + return -0.07 * (y-20); } eulersMethod(cooling, 0, 100, 100, 10); diff --git a/Task/Euler-method/Jq/euler-method-1.jq b/Task/Euler-method/Jq/euler-method-1.jq index 3121a16965..4036e91460 100644 --- a/Task/Euler-method/Jq/euler-method-1.jq +++ b/Task/Euler-method/Jq/euler-method-1.jq @@ -7,7 +7,7 @@ def euler_method(df; x1; y1; x2; h): | [x1, y1] | recurse( if ((.[0] < x2 and x1 < x2) or (.[0] > x2 and x1 > x2)) then - [ (.[0] + $h), (.[1] + $h*df) ] + [ (.[0] + $h), (.[1] + $h*df) ] else empty end ) | .[1] ; diff --git a/Task/Euler-method/Jq/euler-method-2.jq b/Task/Euler-method/Jq/euler-method-2.jq index dad3672557..cbb1cefb18 100644 --- a/Task/Euler-method/Jq/euler-method-2.jq +++ b/Task/Euler-method/Jq/euler-method-2.jq @@ -4,7 +4,7 @@ def euler_solution(df; x1; y1; x2; h): | [x1, y1] | recursion( if ((.[0] < x2 and x1 < x2) or (.[0] > x2 and x1 > x2)) then - [ (.[0] + $h), (.[1] + $h*df) ] + [ (.[0] + $h), (.[1] + $h*df) ] else empty end ) | .[1] ; diff --git a/Task/Euler-method/Julia/euler-method.jl b/Task/Euler-method/Julia/euler-method.julia similarity index 100% rename from Task/Euler-method/Julia/euler-method.jl rename to Task/Euler-method/Julia/euler-method.julia diff --git a/Task/Euler-method/K/euler-method.k b/Task/Euler-method/K/euler-method.k deleted file mode 100644 index 1bb3a2cd8c..0000000000 --- a/Task/Euler-method/K/euler-method.k +++ /dev/null @@ -1,15 +0,0 @@ -// make global variables with :: because while is only locally scoped -tn1::100 -tn::100 -// to store solution -sol::() -// these are constant, so only local scope -k:-0.07 -time:100 -steps:10 -h:time%steps -tr:20 -// applying x+h to 0 outside to end while loop -// bind to a variable to surpress output -var: {x<100}{tn1::tn+h*k*(tn-tr);sol::sol,tn;tn::tn1;x+h}\0 -sol diff --git a/Task/Euler-method/Kotlin/euler-method.kts b/Task/Euler-method/Kotlin/euler-method.kotlin similarity index 100% rename from Task/Euler-method/Kotlin/euler-method.kts rename to Task/Euler-method/Kotlin/euler-method.kotlin diff --git a/Task/Euler-method/Lambdatalk/euler-method.lambdatalk b/Task/Euler-method/Lambdatalk/euler-method.lambdatalk index 8f70a445a6..62f2efe8fb 100644 --- a/Task/Euler-method/Lambdatalk/euler-method.lambdatalk +++ b/Task/Euler-method/Lambdatalk/euler-method.lambdatalk @@ -14,14 +14,14 @@ {eulersMethod cooling 100 0 100 10} -> - 0 100 - 10 44 - 20 27.2 - 30 22.16 - 40 20.648 - 50 20.194 - 60 20.058 - 70 20.017 - 80 20.005 - 90 20.002 - 100 20 + 0 100 + 10 44 + 20 27.2 + 30 22.16 + 40 20.648 + 50 20.194 + 60 20.058 + 70 20.017 + 80 20.005 + 90 20.002 + 100 20 diff --git a/Task/Euler-method/Lua/euler-method.lua b/Task/Euler-method/Lua/euler-method.lua index e72469b893..bd34fd6cc1 100644 --- a/Task/Euler-method/Lua/euler-method.lua +++ b/Task/Euler-method/Lua/euler-method.lua @@ -10,8 +10,8 @@ NewtonCooling = function( t ) return -k * ( t - TR ) end function Euler( f, y0, n, h ) local y = y0 for x = 0, n, h do - print( "", x, y ) - y = y + h * f( y ) + print( "", x, y ) + y = y + h * f( y ) end end diff --git a/Task/Euler-method/MATLAB/euler-method.m b/Task/Euler-method/MATLAB/euler-method.m deleted file mode 100644 index 14e8b6882a..0000000000 --- a/Task/Euler-method/MATLAB/euler-method.m +++ /dev/null @@ -1,40 +0,0 @@ -clear all;close all;clc; -format longG; - -% Main Script -for h = [5, 10] - fprintf('Step %d:\n\n', h); - tabular(15, 'Time', 'Euler', 'Analytic'); - T0 = 100.0; - t0 = 0; - t1 = 100; - T = euler(@(T) -0.07 * (T - 20.0), T0, t0, t1, h); - for i = 1:length(T) - t = (i-1) * h; - analytic = 20.0 + 80.0 * exp(-0.07 * t); - tabular(15, t, round(T(i), 6), round(analytic, 6)); - end - fprintf('\n'); -end - -function T = euler(f, T0, t0, t1, h) - % EULER A simple implementation of Euler's method for solving ODEs - % f - function handle for the derivative - % T0 - initial temperature - % t0, t1 - start and end times - % h - step size - T = T0; - for t = t0:h:t1 - T(end+1) = T(end) + h * f(T(end)); - end -end - -function tabular(width, varargin) - % TABULAR Prints a series of values in a tabular form - % width - cell width - % varargin - variable number of arguments representing cells - for i = 1:length(varargin) - fprintf('%-*s', width, num2str(varargin{i})); - end - fprintf('\n'); -end diff --git a/Task/Euler-method/Maple/euler-method-2.maple b/Task/Euler-method/Maple/euler-method-2.maple index 3c782c1955..491e6ef422 100644 --- a/Task/Euler-method/Maple/euler-method-2.maple +++ b/Task/Euler-method/Maple/euler-method-2.maple @@ -1,16 +1,16 @@ f := y -> (-0.07) * (y - 20): EulerMethod := proc(f, start_time, end_time, y0, h) # y0: initial value #h: step size - local cur, y, rate: - cur := start_time; - y := y0; - while cur <= end_time do - printf("%g %g\n", cur, y); - cur := cur + h; - rate := f(y); - y := y + h * rate; - end do; - return y; + local cur, y, rate: + cur := start_time; + y := y0; + while cur <= end_time do + printf("%g %g\n", cur, y); + cur := cur + h; + rate := f(y); + y := y + h * rate; + end do; + return y; end proc: # step size = 2 diff --git a/Task/Euler-method/OCaml/euler-method-1.ml b/Task/Euler-method/OCaml/euler-method-1.ocaml similarity index 100% rename from Task/Euler-method/OCaml/euler-method-1.ml rename to Task/Euler-method/OCaml/euler-method-1.ocaml diff --git a/Task/Euler-method/OCaml/euler-method-2.ml b/Task/Euler-method/OCaml/euler-method-2.ocaml similarity index 100% rename from Task/Euler-method/OCaml/euler-method-2.ml rename to Task/Euler-method/OCaml/euler-method-2.ocaml diff --git a/Task/Euler-method/Odin/euler-method.odin b/Task/Euler-method/Odin/euler-method.odin deleted file mode 100644 index b8f110cd72..0000000000 --- a/Task/Euler-method/Odin/euler-method.odin +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import "core:fmt" -import "core:math" - -ivp_euler ::proc(y:f32,step:i32,end:i32){ - - y:=y - t:=i32(0) - - for ;t<=end;t+=step{ - if(t%10==0){fmt.printfln("%.3f", y)} - y+=f32(step)*cooling(f32(t),y) - } -} - -cooling :: proc(t:f32,temp:f32)-> f32{ - return -0.07* (temp-20.0) -} - -analytic :: proc(){ - for t := 0; t <= 100; t += 10{ - fmt.printfln("%.3f",20+80*math.exp_f32(f32(-0.07)*f32(t))) - } -} - -main :: proc() { - fmt.println("Step: 2 Seconds") - ivp_euler(100.0, 2,100) - fmt.println("Step: 5 Seconds") - ivp_euler(100.0, 5, 100) - fmt.println("Step: 10 Seconds") - ivp_euler(100.0, 10, 100) - fmt.println("Analytic") - analytic() -} diff --git a/Task/Euler-method/Pascal/euler-method.pas b/Task/Euler-method/Pascal/euler-method.pas index 598e3d480b..52a98641e0 100644 --- a/Task/Euler-method/Pascal/euler-method.pas +++ b/Task/Euler-method/Pascal/euler-method.pas @@ -3,47 +3,47 @@ PROGRAM Euler; TYPE TNewtonCooling = FUNCTION (t: REAL) : REAL; -CONST T0 : REAL = 100.0; -CONST TR : REAL = 20.0; -CONST k : REAL = 0.07; -CONST time : INTEGER = 100; -CONST step : INTEGER = 10; -CONST dt : ARRAY[0..3] of REAL = (1.0,2.0,5.0,10.0); +CONST T0 : REAL = 100.0; +CONST TR : REAL = 20.0; +CONST k : REAL = 0.07; +CONST time : INTEGER = 100; +CONST step : INTEGER = 10; +CONST dt : ARRAY[0..3] of REAL = (1.0,2.0,5.0,10.0); -VAR i : INTEGER; +VAR i : INTEGER; FUNCTION NewtonCooling(t: REAL) : REAL; - BEGIN - NewtonCooling := -k * (t-TR); - END; - + BEGIN + NewtonCooling := -k * (t-TR); + END; + PROCEDURE Euler(F: TNewtonCooling; y, h : REAL; n: INTEGER); - VAR i: INTEGER = 0; - BEGIN - WRITE('dt=',trunc(h):2,':'); - REPEAT - IF (i mod 10 = 0) THEN WRITE(' ',y:2:3); - INC(i,trunc(h)); - y := y + h * F(y); - UNTIL (i >= n); - WRITELN; - END; + VAR i: INTEGER = 0; + BEGIN + WRITE('dt=',trunc(h):2,':'); + REPEAT + IF (i mod 10 = 0) THEN WRITE(' ',y:2:3); + INC(i,trunc(h)); + y := y + h * F(y); + UNTIL (i >= n); + WRITELN; + END; PROCEDURE Sigma; - VAR t: INTEGER = 0; - BEGIN - WRITE('Sigma:'); - REPEAT - WRITE(' ',(20 + 80 * exp(-0.07 * t)):2:3); - INC(t,step); - UNTIL (t>=time); - WRITELN; - END; + VAR t: INTEGER = 0; + BEGIN + WRITE('Sigma:'); + REPEAT + WRITE(' ',(20 + 80 * exp(-0.07 * t)):2:3); + INC(t,step); + UNTIL (t>=time); + WRITELN; + END; BEGIN - WRITELN('Newton cooling function: Analytic solution (Sigma) with 3 Euler approximations.'); - WRITELN('Time: ',0:7,10:7,20:7,30:7,40:7,50:7,60:7,70:7,80:7,90:7); - Sigma; - FOR i := 1 to 3 DO - Euler(NewtonCooling,T0,dt[i],time); + WRITELN('Newton cooling function: Analytic solution (Sigma) with 3 Euler approximations.'); + WRITELN('Time: ',0:7,10:7,20:7,30:7,40:7,50:7,60:7,70:7,80:7,90:7); + Sigma; + FOR i := 1 to 3 DO + Euler(NewtonCooling,T0,dt[i],time); END. diff --git a/Task/Euler-method/PascalABC.NET/euler-method.pas b/Task/Euler-method/PascalABC.NET/euler-method.pas deleted file mode 100644 index 474986e8f7..0000000000 --- a/Task/Euler-method/PascalABC.NET/euler-method.pas +++ /dev/null @@ -1,31 +0,0 @@ -procedure euler(f: (real) -> real; y0, a, b, h: real); -begin - var (t, y) := (a, y0); - write(' Step', h:3, ':'); - while t <= b do - begin - if integer(t) mod 10 = 0 then write(y:8:3); - t += h; - y += h * f(y); - end; - writeln; -end; - -procedure analytic(); -begin - write(' Time:'); - for var t := 0 to 100 step 10 do write(t:8); - writeln; - write('Analytic:'); - for var t := 0 to 100 step 10 do - write(20.0 + 80.0 * exp(-0.07 * t):8:3); - println(); -end; - -function newtoncooling(temp: real): real := -0.07 * (temp - 20); - -begin -analytic; -foreach var i in |2, 5, 10| do - euler(newtoncooling, 100.0, 0.0, 100.0, i) -end. diff --git a/Task/Euler-method/Pluto/euler-method.pluto b/Task/Euler-method/Pluto/euler-method.pluto deleted file mode 100644 index f0d8207f4e..0000000000 --- a/Task/Euler-method/Pluto/euler-method.pluto +++ /dev/null @@ -1,25 +0,0 @@ -local fmt = require "fmt" - -local function euler(f, y, step, finish) - fmt.write(" Step %2d: ", step) - for t = 0, finish, step do - if t % 10 == 0 then fmt.write(" %7.3f", y) end - y += step * f(y) - end - print() -end - -local function analytic() - io.write(" Time: ") - for t = 0, 100, 10 do fmt.write(" %7d", t) end - io.write("\nAnalytic: ") - for t = 0, 100, 10 do - fmt.write(" %7.3f", 20 + 80 * math.exp(-0.07 * t)) - end - print() -end - -local cooling = |temp| -> -0.07 * (temp - 20) - -analytic() -for {2, 5, 10} as i do euler(cooling, 100, i, 100) end diff --git a/Task/Euler-method/PowerShell/euler-method.ps1 b/Task/Euler-method/PowerShell/euler-method.psh similarity index 100% rename from Task/Euler-method/PowerShell/euler-method.ps1 rename to Task/Euler-method/PowerShell/euler-method.psh diff --git a/Task/Euler-method/Python/euler-method.py b/Task/Euler-method/Python/euler-method.py index ff0bcc8723..1c00e47cfe 100644 --- a/Task/Euler-method/Python/euler-method.py +++ b/Task/Euler-method/Python/euler-method.py @@ -1,11 +1,11 @@ def euler(f,y0,a,b,h): - t,y = a,y0 - while t <= b: - print "%6.3f %6.3f" % (t,y) - t += h - y += h * f(t,y) + t,y = a,y0 + while t <= b: + print "%6.3f %6.3f" % (t,y) + t += h + y += h * f(t,y) def newtoncooling(time, temp): - return -0.07 * (temp - 20) + return -0.07 * (temp - 20) euler(newtoncooling,100,0,100,10) diff --git a/Task/Euler-method/Q/euler-method.q b/Task/Euler-method/Q/euler-method.q deleted file mode 100644 index a788e246d6..0000000000 --- a/Task/Euler-method/Q/euler-method.q +++ /dev/null @@ -1,10 +0,0 @@ -t:0 -time:100 -k:-0.07 -tr:20 -sol:() -steps:10 -h:time%steps -tn:100 -while [t xn - if x//10 = 0 then - call Show x,y - y+=dx*Dy(y); x+=dx -end -say -return - -Show: --- Display a line -procedure expose Memo. -arg xx,yy -yt=True(xx) -say Format(xx,3,0) Format(yy,3,7) Format(yt,3,7), - Left(Std(Abs(yy-yt)),9) Left(Std(Abs(yy/yt-1)),9) -return - -Dy: --- Differential equation -procedure -arg yy -return -0.07*(yy-20) - -True: --- Real solution -procedure expose Memo. -arg xx -return 20+(100-20)*Exp(-0.07*xx) - -include Math +/*REXX pgm solves example of Newton's cooling law via Euler's method (diff. step sizes).*/ +e=2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138 +numeric digits length(e) - length(.) /*use the number of decimal digits in E*/ +parse arg Ti Tr cc tt ss /*obtain optional arguments from the CL*/ +if Ti='' | Ti="," then Ti= 100 /*given? Default: initial temp in ºC.*/ +if Tr='' | Tr="," then Tr= 20 /* " " room " " " */ +if cc='' | cc="," then cc= 0.07 /* " " cooling constant. */ +if tt='' | tt="," then tt= 100 /* " " total time seconds. */ +if ss='' | ss="," then ss= 2 5 10 /* " " the step sizes. */ +@= '═' /*the character used in title separator*/ + do sSize=1 for words(ss); say; say; say center('time in' , 11) + say center('seconds' , 11, @) center('Euler method', 16, @) , + center('analytic', 18, @) center('difference' , 14, @) + $=Ti; inc= word(ss, sSize) /*the 1st value; obtain the increment.*/ + do t=0 to Ti by inc /*step through calculations by the inc.*/ + a= format(Tr + (Ti-Tr)/exp(cc*t),6,10) /*calculate the analytic (exact) value.*/ + say center(t,11) format($,6,3) 'ºC ' a "ºC" format(abs(a-$)/a*100,6,2) '%' + $= $ + inc * cc * (Tr-$) /*calc. next value via Euler's method. */ + end /*t*/ + end /*sSize*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +exp: procedure expose e; arg x; ix= x%1; if abs(x-ix)>.5 then ix=ix+sign(x); x= x-ix; z=1 + _=1; w=1; do j=1; _= _*x/j; z= (z+_)/1; if z==w then leave; w=z + end /*j*/; if z\==0 then z= e**ix * z; return z diff --git a/Task/Euler-method/Rebol/euler-method.rebol b/Task/Euler-method/Rebol/euler-method.rebol deleted file mode 100644 index 3fbd56d1cc..0000000000 --- a/Task/Euler-method/Rebol/euler-method.rebol +++ /dev/null @@ -1,34 +0,0 @@ -Rebol [ - title: "Rosetta code: Euler method" - file: %Euler_method.r3 - url: https://rosettacode.org/wiki/Euler_method -] - -euler: func[ - "Euler's method for Newton's cooling law, with formatted comparison" - step [integer!] "time step in seconds" - precision [decimal!] "rounding granularity for printed numbers" -][ - print ["^/STEP:" step] - print "Time Euler Analytic" - print "-------------------------" - - ;; Initialize: - ;; b: upper time bound (seconds) — here we reuse the initial temperature value 100 - ;; y: the current Euler-approximated temperature; initial condition T(0) = 100 - b: y: 100 - for time 0 b step [ - printf [-3 " | " 9 "| "] reduce [ - time - round/to y precision - round/to (20 + (80 * exp (-0.07 * time))) precision - ] - ;; Euler step update: - ;; This applies the discrete forward Euler update using the ODE's RHS - y: y + (step * (-0.07 * (y - 20))) - ] -] -;; Run three experiments with different step sizes -euler 2 0.0001 -euler 5 0.0001 -euler 10 0.0001 diff --git a/Task/Euler-method/Rust/euler-method.rs b/Task/Euler-method/Rust/euler-method.rust similarity index 100% rename from Task/Euler-method/Rust/euler-method.rs rename to Task/Euler-method/Rust/euler-method.rust diff --git a/Task/Euler-method/SequenceL/euler-method.sequencel b/Task/Euler-method/SequenceL/euler-method.sequencel index c795f7cb74..8c3703f0a3 100644 --- a/Task/Euler-method/SequenceL/euler-method.sequencel +++ b/Task/Euler-method/SequenceL/euler-method.sequencel @@ -6,20 +6,20 @@ TR := 20.0; k := 0.07; main(args(2)) := - let - results[i] := euler(newtonCooling, T0, 100, stringToInt(args[i]), 0, "delta_t = " ++ args[i]); - in - delimit(results, '\n'); + let + results[i] := euler(newtonCooling, T0, 100, stringToInt(args[i]), 0, "delta_t = " ++ args[i]); + in + delimit(results, '\n'); newtonCooling(t) := -k * (t - TR); euler: (float -> float) * float * int * int * int * char(1) -> char(1); euler(f, y, n, h, x, output(1)) := - let - newOutput := output ++ "\n\t" ++ intToString(x) ++ "\t" ++ floatToString(y, 3); - newY := y + h * f(y); - newX := x + h; - in - output when x > n - else - euler(f, newY, n, h, newX, newOutput); + let + newOutput := output ++ "\n\t" ++ intToString(x) ++ "\t" ++ floatToString(y, 3); + newY := y + h * f(y); + newX := x + h; + in + output when x > n + else + euler(f, newY, n, h, newX, newOutput); diff --git a/Task/Euler-method/Smalltalk/euler-method.st b/Task/Euler-method/Smalltalk/euler-method.st index 52f6dd908b..7dd18f966b 100644 --- a/Task/Euler-method/Smalltalk/euler-method.st +++ b/Task/Euler-method/Smalltalk/euler-method.st @@ -1,13 +1,13 @@ ODESolver>>eulerOf: f init: y0 from: a to: b step: h - | t y | - t := a. - y := y0. - [ t < b ] - whileTrue: [ - Transcript - show: t asString, ' ' , (y printShowingDecimalPlaces: 3); - cr. - t := t + h. - y := y + (h * (f value: t value: y)) ] + | t y | + t := a. + y := y0. + [ t < b ] + whileTrue: [ + Transcript + show: t asString, ' ' , (y printShowingDecimalPlaces: 3); + cr. + t := t + h. + y := y + (h * (f value: t value: y)) ] ODESolver new eulerOf: [:time :temp| -0.07 * (temp - 20)] init: 100 from: 0 to: 100 step: 10 diff --git a/Task/Euler-method/Tcl/euler-method-1.tcl b/Task/Euler-method/Tcl/euler-method-1.tcl index a7854e5399..6073ea9839 100644 --- a/Task/Euler-method/Tcl/euler-method-1.tcl +++ b/Task/Euler-method/Tcl/euler-method-1.tcl @@ -2,8 +2,8 @@ proc euler {f y0 a b h} { puts "computing $f over \[$a..$b\], step $h" set y [expr {double($y0)}] for {set t [expr {double($a)}]} {$t < $b} {set t [expr {$t + $h}]} { - puts [format "%.3f\t%.3f" $t $y] - set y [expr {$y + $h * double([$f $t $y])}] + puts [format "%.3f\t%.3f" $t $y] + set y [expr {$y + $h * double([$f $t $y])}] } puts "done" } diff --git a/Task/Euler-method/True-BASIC/euler-method.basic b/Task/Euler-method/True-BASIC/euler-method.basic deleted file mode 100644 index 4989b823c4..0000000000 --- a/Task/Euler-method/True-BASIC/euler-method.basic +++ /dev/null @@ -1,32 +0,0 @@ -SUB euler (paso) - LET tiempo = 0 - LET temperatura = 100 - PRINT USING "Step ## ": paso; - DO WHILE tiempo <= 100 - IF (REMAINDER(tiempo,10)) = 0 THEN PRINT USING "###.##": temperatura; - LET temperatura = temperatura+paso*(-.07*(temperatura-20)) - LET tiempo = tiempo+paso - LOOP - PRINT -END SUB - -PRINT "Time "; -LET tiempo = 0 -DO WHILE tiempo <= 100.1 - PRINT USING "######": tiempo; - LET tiempo = tiempo+10 -LOOP -PRINT -PRINT "Dif eq "; -LET tiempo = 0 -DO WHILE tiempo <= 100.1 - LET temperatura = 20+(100-20)*EXP(-.07*tiempo) - PRINT USING "###.##": temperatura; - LET tiempo = tiempo+10 -LOOP -PRINT - -CALL Euler (2) -CALL Euler (5) -CALL Euler (10) -END diff --git a/Task/Euler-method/Uiua/euler-method.uiua b/Task/Euler-method/Uiua/euler-method.uiua deleted file mode 100644 index 0d577690a3..0000000000 --- a/Task/Euler-method/Uiua/euler-method.uiua +++ /dev/null @@ -1,22 +0,0 @@ -"Euler Solution" -T ← 100 # initial starting temp -TR ← 20 # room temp -TMINUSTR ← - TR T -h ← 10 # step size -k ← 0.07 # coefficent -TEND ← 100 # end time -n ← ÷ h 100 # steps -# inital starting point -T -. -# .. clone the top of stack and take if for next step -# repeat the steps n times with ⍥ -Solution ← [⍥(.. - × h × k - TR)]+ n 1 -⇌ ⊂ Solution T - -# analytical solution -"Analytical Solution" -# apply function to LIST -List ← × k × h ⇡n -# Analytical solution applied -+ TR × TMINUSTR ⁿ ¯List e diff --git a/Task/Euler-method/Wren/euler-method.wren b/Task/Euler-method/Wren/euler-method.wren index cf86fb3800..67ca037670 100644 --- a/Task/Euler-method/Wren/euler-method.wren +++ b/Task/Euler-method/Wren/euler-method.wren @@ -1,5 +1,5 @@ -import "./fmt" for Fmt -import "./iterate" for Stepped +import "/fmt" for Fmt +import "/iterate" for Stepped var euler = Fn.new { |f, y, step, end| Fmt.write(" Step $2d: ", step) diff --git a/Task/Euler-method/XBasic/euler-method.basic b/Task/Euler-method/XBasic/euler-method.basic deleted file mode 100644 index ad06196e05..0000000000 --- a/Task/Euler-method/XBasic/euler-method.basic +++ /dev/null @@ -1,43 +0,0 @@ -PROGRAM "Euclidean rhythm" -VERSION "0.0001" -IMPORT "xma" - -DECLARE FUNCTION Entry () -DECLARE FUNCTION Euler (paso) - -FUNCTION Entry () - PRINT "Time "; - tiempo! = 0.0 - DO WHILE tiempo! <= 100.1 - PRINT FORMAT$ ("#######", tiempo!); - tiempo! = tiempo! + 10.0 - LOOP - PRINT - - PRINT "Dif eq "; - tiempo! = 0.0 - DO WHILE tiempo! <= 100.1 - temperatura! = 20.0 + (100.0 - 20.0) * EXP(-0.07 * tiempo!) - PRINT FORMAT$ ("####.##", temperatura!); - tiempo! = tiempo! + 10.0 - LOOP - PRINT - - Euler(2) - Euler(5) - Euler(10) -END FUNCTION - -FUNCTION Euler (paso) - tiempo! = 0 - temperatura! = 100.0 - PRINT FORMAT$ ("Step ## ", paso); - - DO WHILE tiempo! <= 100 - IF (tiempo! MOD 10) = 0 THEN PRINT FORMAT$ ("####.##", temperatura!); - temperatura! = temperatura! + SINGLE(paso) * (-0.07 * (temperatura! - 20.0)) - tiempo! = tiempo! + paso - LOOP - PRINT -END FUNCTION -END PROGRAM diff --git a/Task/Euler-method/Yabasic/euler-method.basic b/Task/Euler-method/Yabasic/euler-method.basic deleted file mode 100644 index 6e34a8d04b..0000000000 --- a/Task/Euler-method/Yabasic/euler-method.basic +++ /dev/null @@ -1,35 +0,0 @@ -print "Time "; -tiempo = 0.0 -while tiempo <= 100.1 - print tiempo using "#######"; - tiempo = tiempo + 10.0 -wend -print - -print "Dif eq "; -tiempo = 0.0 -while tiempo <= 100.1 - temperatura = 20.0 + (100.0-20.0) * exp(-0.07*tiempo) - print temperatura using "####.##"; - tiempo = tiempo + 10.0 -wend -print - -Euler_(2) -Euler_(5) -Euler_(10) -end - -sub Euler_(paso) - local tiempo, temperatura - tiempo = 0 - temperatura = 100.0 - print "Step ", paso using "##", " "; - - while tiempo <= 100 - if mod(tiempo, 10) = 0 print temperatura using "####.##"; - temperatura = temperatura + (paso) * (-0.07*(temperatura-20.0)) - tiempo = tiempo + paso - end while - print -end sub diff --git a/Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg b/Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg deleted file mode 100644 index 4b49f4d0c2..0000000000 --- a/Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg +++ /dev/null @@ -1,89 +0,0 @@ -begin % calculate Euler's constant, translated from the XPL0 sample % - % which is translated from the C sample % - - long real A, B, H, N2, R, U, V; - long real array S ( 0 :: 1 ); - long real array B2( 0 :: 9 ); - long real Epsilon; - integer K, K2, M, N; - - Epsilon := 1'-6; - - % set output format % - i_w := 1; s_w := 0; r_w := 18; r_d := 15; r_format := "A"; - - write( "From the definition, error 3e-10" ); - N := 400; H := 1.0; - for K1 := 2 until N do H := H + 1.0 / K1; - comment Faster convergence: Negoi, 1997 ; - A := Ln( N + 0.5 + 1.0/( 24.0 * N ) ); - write( "Hn ", H ); - write( "gamma ", H - A ); write( "K = ", N ); write(); - - write( "Sweeney, 1963, error 3e-10" ); - N := 21; S( 0 ) := 0; S( 1 ) := N; - R := N; K:= 1; - while begin K := K + 1; - R := R * N / K; - S( K rem 2 ) := S( K rem 2 ) + R / K; - R > Epsilon - end - do begin end; - write( "gamma ", S( 1 ) - S( 0 ) - ln( N ) );write( "K = ", K ); write(); - - write( "Bailey, 1988" ); - N := 5; A := 1; H := 1; - N2 := 2 ** N; - R := 1; K := 1; - while begin K := K + 1; - R := R * N2 / K; - H := H + 1 / K; - B := A; A := A + R * H; - abs( B - A ) > Epsilon - end - do begin end; - A := A * N2 / Exp(N2); - write( "gamma ", A - N * Ln( 2 ) ); write( "K = ", K ); write(); - - write( "Brent-McMillan, 1980" ); - N := 13; A := -Ln( N ); - B := 1; U := A; V := B; - N2 := N * N; K2 := 0; K := 0; - while begin K2 := K2 + 2 * K + 1; - K := K + 1; - A := A * N2 / K; - B := B * N2 / K2; - A := ( A + B ) / K; - U := U + A; - V := V + B; - abs( A ) > Epsilon - end - do begin end; - write( "gamma ", U / V ); write( "K = ", K ); write(); - - write( "How Euler did it in 1735" ); - comment Bernoulli numbers with even indices; - - B2( 0 ) := 1; B2( 1 ) := 1 / 6; B2( 2 ) := -1 / 30; - B2( 3 ) := 1 / 42; B2( 4 ) := -1 / 30; B2( 5 ) := 5 / 66; - B2( 6 ) := -691 / 2730; B2( 7 ) := 7 / 6; B2( 8 ) := -3617 / 510; - B2( 9 ) := 43867 / 98; - M := 7; N := 10; - comment Nth harmonic number; - H := 1; - for K1 := 2 until N do H := H + 1 / K1; - write( "Hn ", H ); - H := H - Ln( N ); - write( " -ln ", H ); - comment Expansion C:= -digamma(1); - A := -1 / ( 2 * N ); - N2 := N * N; - R := 1; - for K1 := 1 until M do begin - R := R * N2; - A := A + B2( K1 ) / (2 * K1 * R ) - end for_K1; - write( "err ", A ); write( "gamma ", H + A ); write( "K = ", N + M ); - write(); - write( "C = 0.57721566490153286..." ); write() -end. diff --git a/Task/Eulers-constant-0.5772.../AWK/eulers-constant-0.5772....awk b/Task/Eulers-constant-0.5772.../AWK/eulers-constant-0.5772....awk deleted file mode 100644 index cb7e954b31..0000000000 --- a/Task/Eulers-constant-0.5772.../AWK/eulers-constant-0.5772....awk +++ /dev/null @@ -1,12 +0,0 @@ -# syntax: GAWK -f EULERS_CONSTANT.AWK -# converted from LUA -BEGIN { - Hn = 1 - n = 10^8 - for (i=2; i<=n; i++) { - Hn += (1/i) - } - gamma = Hn - log(n) - printf("%.8f\n",gamma) - exit(0) -} diff --git a/Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....adb b/Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....adb deleted file mode 100644 index b27ada83d7..0000000000 --- a/Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....adb +++ /dev/null @@ -1,47 +0,0 @@ -with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; -with Ada.Numerics.Long_Elementary_Functions; use Ada.Numerics.Long_Elementary_Functions; -with Ada.Text_IO; use Ada.Text_IO; - -procedure Eulers_Constant is - - function Euler_Vacca (Iterations : Integer) return Long_Float is - Gamma : Long_Float := 1.0; - Term : Long_Float; - Power : Long_Integer; - Sign : Long_Float; - begin - Gamma := 0.5 - (1.0 / 3.0); - for I in 2 .. Iterations loop - Power := 2 ** Natural (I); - Sign := -1.0; - Term := 0.0; - for Domin in Power .. (2 * Power - 1) loop - Sign := - (Sign); - Term := Term + Sign / Long_Float (Domin); - end loop; - Gamma := Gamma + (Long_Float (I) * Term); - end loop; - return Gamma; - end Euler_Vacca; - - -- Ada Float type is IEEE 754 32-bit, giving 9 decimal digits of precision - Euler_Castellanos_Float : constant Float := - (((80.0 ** 3) + 92.0) / - (61.0 ** 4)) ** (1.0 / 6.0); - - -- Ada Long_Float type is IEEE 754 32-bit, giving 14 decimal digits of precision - Euler_Castellanos_Long_Float : constant Long_Float := - (990.0 ** 3 - 55.0 ** 3 - 79.0 ** 2 - 16.0) / - 70.0 ** 5; - - Iters : Integer; -begin - Put_Line ("Its. Vacca"); - Iters := 2; - while Iters <= 32 loop - Put_Line (Iters'Image & " " & Euler_Vacca (Iters)'Image); - Iters := Iters + 2; - end loop; - Put_Line ("Castellanos approximation for standard Float (9 digits): " & Euler_Castellanos_Float'Image); - Put_Line ("Castellanos approximation for Long Float (14 digits): " & Euler_Castellanos_Long_Float'Image); -end Eulers_Constant; diff --git a/Task/Eulers-constant-0.5772.../Delphi/eulers-constant-0.5772....delphi b/Task/Eulers-constant-0.5772.../Delphi/eulers-constant-0.5772....delphi new file mode 100644 index 0000000000..d9e8de7c73 --- /dev/null +++ b/Task/Eulers-constant-0.5772.../Delphi/eulers-constant-0.5772....delphi @@ -0,0 +1,39 @@ +function ComputeEuler(N: int64): double; +{Compute Eurler number with N-number of iterations} +var I: integer; +var A: double; +begin +Result:=0; +for I:=1 to N-1 do + Result:=Result + 1 / I; +A:=Ln(N + 0.5 + 1/(24.0*N)); +Result:=Result-A; +end; + + + +procedure ShowEulersNumber(Memo: TMemo); +{Show Euler numbers at various levels of precision} +var Euler,G,A,Error: double; +var N: integer; +const Correct =0.57721566490153286060651209008240243104215933593992; + + procedure ShowEulerError(N: int64); + {Show Euler number and Error} + begin + Euler:=ComputeEuler(N); + Error:=Correct-Euler; + Memo.Lines.Add('N = '+FloatToStrF(N,ffNumber,18,0)); + Memo.Lines.Add('Euler='+FloatToStrF(Euler,ffFixed,18,18)); + Memo.Lines.Add('Error='+FloatToStrF(Error,ffFixed,18,18)); + Memo.Lines.Add(''); + end; + +begin +{Compute Euler number with iterations ranging 10 to 10^9} +for N:=1 to 9 do + begin + ShowEulerError(Trunc(Power(10,N))); + end; + +end; diff --git a/Task/Eulers-constant-0.5772.../Delphi/eulers-constant-0.5772....pas b/Task/Eulers-constant-0.5772.../Delphi/eulers-constant-0.5772....pas deleted file mode 100644 index 3f1952a8f7..0000000000 --- a/Task/Eulers-constant-0.5772.../Delphi/eulers-constant-0.5772....pas +++ /dev/null @@ -1,39 +0,0 @@ -function ComputeEuler(N: int64): double; -{Compute Eurler number with N-number of iterations} -var I: integer; -var A: double; -begin -Result:=0; -for I:=1 to N-1 do - Result:=Result + 1 / I; -A:=Ln(N + 0.5 + 1/(24.0*N)); -Result:=Result-A; -end; - - - -procedure ShowEulersNumber(Memo: TMemo); -{Show Euler numbers at various levels of precision} -var Euler,G,A,Error: double; -var N: integer; -const Correct =0.57721566490153286060651209008240243104215933593992; - - procedure ShowEulerError(N: int64); - {Show Euler number and Error} - begin - Euler:=ComputeEuler(N); - Error:=Correct-Euler; - Memo.Lines.Add('N = '+FloatToStrF(N,ffNumber,18,0)); - Memo.Lines.Add('Euler='+FloatToStrF(Euler,ffFixed,18,18)); - Memo.Lines.Add('Error='+FloatToStrF(Error,ffFixed,18,18)); - Memo.Lines.Add(''); - end; - -begin -{Compute Euler number with iterations ranging 10 to 10^9} -for N:=1 to 9 do - begin - ShowEulerError(Trunc(Power(10,N))); - end; - -end; diff --git a/Task/Eulers-constant-0.5772.../DuckDB/eulers-constant-0.5772....duckdb b/Task/Eulers-constant-0.5772.../DuckDB/eulers-constant-0.5772....duckdb deleted file mode 100644 index fd6a135180..0000000000 --- a/Task/Eulers-constant-0.5772.../DuckDB/eulers-constant-0.5772....duckdb +++ /dev/null @@ -1,21 +0,0 @@ -# Bailey, 1988 -create or replace function bailey(n, eps) as ( - with recursive n2 as (select pow(2, n) as n2), - cte as ( - select 1 as k, 1.0::DOUBLE as r, 1.0::DOUBLE as h, 0.0::DOUBLE as b, 1.0::DOUBLE as a - union all - select - k + 1 as k, - r * (n2 / (k+1)) as r, - h + (1.0 / (k+1)) as h, - a as b, - a + (r * (n2 / (k+1)) * (h + (1.0 / (k+1)))) as a - from cte, n2 - where @(b - a) > eps - ), - a as (select last(a order by k) as a from cte) - select (a * n2 / exp(n2) ) - (n * ln(2)) - from a, n2 -); - -select bailey(5, 1E-6) as gamma; diff --git a/Task/Eulers-constant-0.5772.../EasyLang/eulers-constant-0.5772....easy b/Task/Eulers-constant-0.5772.../EasyLang/eulers-constant-0.5772....easy deleted file mode 100644 index 16bd541d9a..0000000000 --- a/Task/Eulers-constant-0.5772.../EasyLang/eulers-constant-0.5772....easy +++ /dev/null @@ -1,11 +0,0 @@ -fastfunc gethn n . - i = 1 - while i <= n - hn += 1 / i - i += 1 - . - return hn -. -n = 10e8 -numfmt 0 9 -print gethn n - log n 0 diff --git a/Task/Eulers-constant-0.5772.../Fortran/eulers-constant-0.5772....f b/Task/Eulers-constant-0.5772.../Fortran/eulers-constant-0.5772....f deleted file mode 100644 index 868106567d..0000000000 --- a/Task/Eulers-constant-0.5772.../Fortran/eulers-constant-0.5772....f +++ /dev/null @@ -1,131 +0,0 @@ -program euler_constant - implicit none - ! Define constants and variables - real(16), parameter :: EULER_GAMMA = 0.57721566490153286_16 - real(16), parameter :: eps = epsilon(1.0e-6_16) - real(16) :: a, b, h, n2, r, u, v - integer :: k, k2, m, n - real(16) :: s(0:1), B2(0:9) - real(16), parameter :: eps_high = eps !1.0e-12_16 - - ! Method 1: From the definition (Negoi, 1997) - write(*, '(a)') "From the definition, err. 3e-10" - n = 400 - h = 1.0_16 - do k = 2, n - h = h + 1.0_16 / k - end do - a = log(real(n, 16) + 0.5_16 + 1.0_16 / (24.0_16 * n)) - write(*, '(a, f18.16)') "Hn ", h - write(*, '(a, f18.16, /, a, i0, /)') "gamma ", h - a, "k = ", n - write(*, '(a, f18.16, /)') "error ", abs(h - a - EULER_GAMMA) - - ! Method 2: Sweeney, 1963 - write(*, '(a)') "Sweeney, 1963, err. idem" - n = 21 - s = [0.0_16, real(n, 16)] - r = real(n, 16) - k = 1 - do - k = k + 1 - r = r * real(n, 16) / k - s(mod(k, 2)) = s(mod(k, 2)) + r / k - if (r <= eps) exit - end do - write(*, '(a, f18.16, /, a, i0, /)') "gamma ", s(1) - s(0) - log(real(n, 16_16)), "k = ", k - write(*, '(a, f18.16, /)') "error ", abs(s(1) - s(0) - log(real(n, 16)) - EULER_GAMMA) - - ! Method 3: Bailey, 1988 - write(*, '(a)') "Bailey, 1988" - n = 5 - a = 1.0_16 - h = 1.0_16 - n2 = 2.0_16 ** n - r = 1.0_16 - k = 1 - do - k = k + 1 - r = r * n2 / k - h = h + 1.0_16 / k - b = a - a = a + r * h - if (abs(b - a) <= eps) exit - end do - a = a * n2 / exp(n2) - write(*, '(a, f18.16, /, a, i0, /)') "gamma ", a - n * log(2.0_16), "k = ", k - write(*, '(a, f18.16, /)') "error ", abs(a - n * log(2.0_16) - EULER_GAMMA) - - ! Method 4: Brent-McMillan, 1980 (original) - write(*, '(a)') "Brent-McMillan, 1980 (original)" - n = 13 - a = -log(real(n, 16)) - b = 1.0_16 - u = a - v = b - n2 = real(n, 16) * n - k2 = 0 - k = 0 - do - k2 = k2 + 2 * k + 1 - k = k + 1 - a = a * n2 / k - b = b * n2 / k2 - a = (a + b) / k - u = u + a - v = v + b - if (abs(a) <= eps) exit - end do - write(*, '(a, f18.16, /, a, i0, /)') "gamma ", u / v, "k = ", k - write(*, '(a, f18.16, /)') "error ", abs(u / v - EULER_GAMMA) - - ! Method 5: Brent-McMillan, 1980 (enhanced for higher precision) - write(*, '(a)') "Brent-McMillan, 1980 (enhanced)" - n = 50 - a = -log(real(n, 16)) - b = 1.0_16 - u = a - v = b - n2 = real(n, 16) * n - k2 = 0 - k = 0 - do - k2 = k2 + 2 * k + 1 - k = k + 1 - a = a * n2 / k - b = b * n2 / k2 - a = (a + b) / k - u = u + a - v = v + b - if (abs(a) <= eps_high) exit - end do - write(*, '(a, f18.16, /, a, i0, /)') "gamma ", u / v, "k = ", k - write(*, '(a, f18.16, /)') "error ", abs(u / v - EULER_GAMMA) - - ! Method 6: Euler's method, 1735 - write(*, '(a)') "How Euler did it in 1735" - B2 = [1.0_16, 1.0_16/6, -1.0_16/30, 1.0_16/42, -1.0_16/30, & - 5.0_16/66, -691.0_16/2730, 7.0_16/6, -3617.0_16/510, 43867.0_16/798] - m = 7 - if (m > 9) stop - n = 10 - h = 1.0_16 - do k = 2, n - h = h + 1.0_16 / k - end do - write(*, '(a, f18.16)') "Hn ", h - h = h - log(real(n, 16)) - write(*, '(a, f18.16)') " -ln ", h - a = -1.0_16 / (2.0_16 * n) - n2 = real(n, 16) * n - r = 1.0_16 - do k = 1, m - r = r * n2 - a = a + B2(k) / (2.0_16 * k * r) - end do - write(*, '(a, f18.16, /, a, f18.16, /, a, i0)') & - "err ", a, "gamma ", h + a, "k = ", n + m - write(*, '(a, f18.16, /)') "error ", abs(h + a - EULER_GAMMA) - - ! Reference value - write(*, '(a, f18.16, /)') "C = ", EULER_GAMMA -end program euler_constant diff --git a/Task/Eulers-constant-0.5772.../FutureBasic/eulers-constant-0.5772....basic b/Task/Eulers-constant-0.5772.../FutureBasic/eulers-constant-0.5772....basic deleted file mode 100644 index f10d0ff0e1..0000000000 --- a/Task/Eulers-constant-0.5772.../FutureBasic/eulers-constant-0.5772....basic +++ /dev/null @@ -1,22 +0,0 @@ -void local fn Euler - long n = 10000000, k - double a, h = 1.0 - - for k = 2 to n - h += 1 / k - next - a = log( n + 0.5 + 1 / ( 24 * n ) ) - - printf @"From the definition, err. 3e-10" - printf @"Hn %.15f", h - printf @"gamma %.15f", h - a - printf @"k = %ld\n", n - printf @"C %.15f", 0.5772156649015328 -end fn - -CFTimeInterval t -t = fn CACurrentMediaTime -fn Euler -printf @"\vCompute time: %.3f ms",(fn CACurrentMediaTime-t)*1000 - -HandleEvents diff --git a/Task/Eulers-constant-0.5772.../Java/eulers-constant-0.5772....java b/Task/Eulers-constant-0.5772.../Java/eulers-constant-0.5772....java index ab644548fd..dbab8b5182 100644 --- a/Task/Eulers-constant-0.5772.../Java/eulers-constant-0.5772....java +++ b/Task/Eulers-constant-0.5772.../Java/eulers-constant-0.5772....java @@ -5,20 +5,20 @@ */ public class EulerConstant { - public static void main(String[] args) { - System.out.println(gamma(1_000_000)); - } + public static void main(String[] args) { + System.out.println(gamma(1_000_000)); + } private static double gamma(int N) { - double gamma = 0.0; - - for ( int n = 1; n <= N; n++ ) { - gamma += 1.0 / n; - } - - gamma -= Math.log(N) + 1.0 / ( 2 * N ); - - return gamma; - } - + double gamma = 0.0; + + for ( int n = 1; n <= N; n++ ) { + gamma += 1.0 / n; + } + + gamma -= Math.log(N) + 1.0 / ( 2 * N ); + + return gamma; + } + } diff --git a/Task/Eulers-constant-0.5772.../JavaScript/eulers-constant-0.5772....js b/Task/Eulers-constant-0.5772.../JavaScript/eulers-constant-0.5772....js deleted file mode 100644 index 42188fb06e..0000000000 --- a/Task/Eulers-constant-0.5772.../JavaScript/eulers-constant-0.5772....js +++ /dev/null @@ -1,45 +0,0 @@ -function ByVaccaSeries(numTerms) { - // this method is simple but converges slowly - // calculate gamma by: - // 1 * (1/2 - 1/3) + - // 2 * (1/4 - 1/5 + 1/6 - 1/7) + - // 3 * (1/8 - 1/9 + 1/10 - 1/11 + 1/12 - 1/13 + 1/14 - 1/15) + - // 4 * ( . . . ) + - // . . . - let gamma = 0; - let next = 4; - for (let numerator = 1; numerator < numTerms; ++numerator) { - let delta = 0; - for (let denominator = next / 2; denominator < next; denominator += 2) { - // calculate terms two at a time - delta += 1.0 / denominator - 1.0 / (denominator + 1); - } - gamma += numerator * delta; - next *= 2; - } - return gamma; -} -// based on the C entry -function ByEulersMethod() { - //Bernoulli numbers with even indices - const B2 = [1.0, 1.0 / 6, -1.0 / 30, 1.0 / 42, -1.0 / 30, - 5.0 / 66, -691.0 / 2730, 7.0 / 6]; - const n = 10; - //n-th harmonic number - const h = (() => // immediately invoked function expression - { - let sum = 1; - for (let k = 2; k <= n; k++) { sum += 1.0 / k; } - return sum - Math.log(n); - })(); - //expansion C = -digamma(1) - let a = -1.0 / (2 * n); - let r = 1; - for (let k = 1; k < B2.length; k++) { - r *= n * n; - a += B2[k] / (2 * k * r); - } - return h + a; -} -console.log("Vacca series: " + ByVaccaSeries(32).toPrecision(16)); -console.log("Eulers method: " + ByEulersMethod().toPrecision(16)); diff --git a/Task/Eulers-constant-0.5772.../Julia/eulers-constant-0.5772....jl b/Task/Eulers-constant-0.5772.../Julia/eulers-constant-0.5772....julia similarity index 100% rename from Task/Eulers-constant-0.5772.../Julia/eulers-constant-0.5772....jl rename to Task/Eulers-constant-0.5772.../Julia/eulers-constant-0.5772....julia diff --git a/Task/Eulers-constant-0.5772.../Maxima/eulers-constant-0.5772....maxima b/Task/Eulers-constant-0.5772.../Maxima/eulers-constant-0.5772....maxima deleted file mode 100644 index 3763cc1f71..0000000000 --- a/Task/Eulers-constant-0.5772.../Maxima/eulers-constant-0.5772....maxima +++ /dev/null @@ -1 +0,0 @@ -%gamma,numer; diff --git a/Task/Eulers-constant-0.5772.../PascalABC.NET/eulers-constant-0.5772....pas b/Task/Eulers-constant-0.5772.../PascalABC.NET/eulers-constant-0.5772....pas deleted file mode 100644 index d0df6f507a..0000000000 --- a/Task/Eulers-constant-0.5772.../PascalABC.NET/eulers-constant-0.5772....pas +++ /dev/null @@ -1,9 +0,0 @@ -const - n = 1_000_000; - -begin - var result := 1.0; - for var i := 2 to n do - result += 1 / i; - writeln(result - ln(n)); -end. diff --git a/Task/Eulers-constant-0.5772.../Phix/eulers-constant-0.5772...-1.phix b/Task/Eulers-constant-0.5772.../Phix/eulers-constant-0.5772...-1.phix index 1840979093..72fb81b799 100644 --- a/Task/Eulers-constant-0.5772.../Phix/eulers-constant-0.5772...-1.phix +++ b/Task/Eulers-constant-0.5772.../Phix/eulers-constant-0.5772...-1.phix @@ -1,4 +1,6 @@ --- demo\rosetta\Eulers_constant.exw -with javascript_semantics -constant C = sum(sq_div(1,tagset(1e6)))-log(1e6) -printf(1,"gamma %.12f (max 12d.p. of accuracy)\n",C) +(phixonline)--> + -- demo\rosetta\Eulers_constant.exw + with javascript_semantics + constant C = sum(sq_div(1,tagset(1e6)))-log(1e6) + printf(1,"gamma %.12f (max 12d.p. of accuracy)\n",C) + + without js -- no mpfr_get_d_2exp() in mpfr.js as yet + requires("1.0.2") -- mpfr_get_d_2exp(), mpfr_addmul_si() + include mpfr.e + mpfr u, v, k2; + integer e, e10, e2 + atom f -//log(x/y) with the Taylor series for atanh(x-y/x+y) -procedure ln(mpfr s, integer x, y) - mpfr d = u, q = v; - assert((x-y)==1) - mpfr_set_si(s, x+y) - mpfr_si_div(s, 1, s) // s = 1 / (x + y) - mpfr_mul(k2, s, s) // k2 = s * s - mpfr_set(d, s) - integer k = 1 - while true do - k += 2; - mpfr_mul(d, d, k2) // d *= k2 - mpfr_div_si(q, d, k) // q = d / k - mpfr_add(s, s, q) // s += q - {f,e} = mpfr_get_d_2exp(q) - if abs(e)>=e2 then exit end if - end while - mpfr_mul_si(s, s, 2) //s *= 2 -end procedure + //log(x/y) with the Taylor series for atanh(x-y/x+y) + procedure ln(mpfr s, integer x, y) + mpfr d = u, q = v; + assert((x-y)==1) + mpfr_set_si(s, x+y) + mpfr_si_div(s, 1, s) // s = 1 / (x + y) + mpfr_mul(k2, s, s) // k2 = s * s + mpfr_set(d, s) + integer k = 1 + while true do + k += 2; + mpfr_mul(d, d, k2) // d *= k2 + mpfr_div_si(q, d, k) // q = d / k + mpfr_add(s, s, q) // s += q + {f,e} = mpfr_get_d_2exp(q) + if abs(e)>=e2 then exit end if + end while + mpfr_mul_si(s, s, 2) //s *= 2 + end procedure -mpfr a, b -integer k, - n = 60, -- (required precision in decimal dp *6/10) - n2, - r = 41, - s = 30, - t = 18; + mpfr a, b + integer k, + n = 60, -- (required precision in decimal dp *6/10) + n2, + r = 41, + s = 30, + t = 18; -// n = 2^i * 3^j * 5^k + // n = 2^i * 3^j * 5^k -// log(n) = r * log(16/15) + s * log(25/24) + t * log(81/80) + // log(n) = r * log(16/15) + s * log(25/24) + t * log(81/80) -// solve linear system for r, s, t -// 4 -3 -4| i -// -1 -1 4| j -// -1 2 -1| k + // solve linear system for r, s, t + // 4 -3 -4| i + // -1 -1 4| j + // -1 2 -1| k -//decimal precision -e10 = floor(n/0.6) -//binary precision -e2 = floor((1 + e10) / 0.30103) + //decimal precision + e10 = floor(n/0.6) + //binary precision + e2 = floor((1 + e10) / 0.30103) -mpfr_set_default_precision(e2) -{a, b, u, v, k2} = mpfr_inits(5) + mpfr_set_default_precision(e2) + {a, b, u, v, k2} = mpfr_inits(5) -//Compute log terms -ln(b, 16, 15) mpfr_mul_si(a, b, r) // a = r * b -ln(b, 25, 24) mpfr_addmul_si(a, b, s) // a += s * b -ln(b, 81, 80) mpfr_addmul_si(a, b, t) // a += t * b + //Compute log terms + ln(b, 16, 15) mpfr_mul_si(a, b, r) // a = r * b + ln(b, 25, 24) mpfr_addmul_si(a, b, s) // a += s * b + ln(b, 81, 80) mpfr_addmul_si(a, b, t) // a += t * b -mpfr_neg(a, a) // a = -a -mpfr_set_si(b, 1) // b = 1 -mpfr_set (u, a) -mpfr_set (v, b) + mpfr_neg(a, a) // a = -a + mpfr_set_si(b, 1) // b = 1 + mpfr_set (u, a) + mpfr_set (v, b) -k = 0; -n2 = n * n; -mpfr_set_si(k2, 0) // k2 = k * k (as below) -while true do - mpfr_add_si(k2, k2, k*2+1) // k2 += 2k + 1 - k += 1; + k = 0; + n2 = n * n; + mpfr_set_si(k2, 0) // k2 = k * k (as below) + while true do + mpfr_add_si(k2, k2, k*2+1) // k2 += 2k + 1 + k += 1; - mpfr_div(b, b, k2) - mpfr_mul_si(b, b, n2) // b = b * n2 / k2 + mpfr_div(b, b, k2) + mpfr_mul_si(b, b, n2) // b = b * n2 / k2 - mpfr_div_si(a, a, k) - mpfr_mul_si(a, a, n2) - mpfr_add (a, a, b) - mpfr_div_si(a, a, k) // a = (a * n2 / k + b) / k + mpfr_div_si(a, a, k) + mpfr_mul_si(a, a, n2) + mpfr_add (a, a, b) + mpfr_div_si(a, a, k) // a = (a * n2 / k + b) / k - mpfr_add(u, u, a) // u += a - mpfr_add(v, v, b) // v += b + mpfr_add(u, u, a) // u += a + mpfr_add(v, v, b) // v += b - {f,e} = mpfr_get_d_2exp (a) - if abs(e)>=e2 then exit end if -end while + {f,e} = mpfr_get_d_2exp (a) + if abs(e)>=e2 then exit end if + end while -mpfr_div(u, u, v) -string su = mpfr_get_fixed(u,e10) -printf(1,"gamma %s (maxerr. 1e-%d)\n", {su, e10}) + mpfr_div(u, u, v) + string su = mpfr_get_fixed(u,e10) + printf(1,"gamma %s (maxerr. 1e-%d)\n", {su, e10}) + + without js -- no mpfr_const_euler() in mpfr.js as yet + requires("1.0.1") -- mpfr_const_euler() + include mpfr.e + mpfr gamma = mpfr_init(0,-100) + mpfr_const_euler(gamma) + printf(1,"gamma %s (mpfr_const_euler)\n",{mpfr_get_fixed(gamma,100)}) + + with javascript_semantics + include builtins\complex.e + complex i = complex_new(0,1), + res = complex_add(complex_exp(complex_mul(PI,i)),1) + ?complex_sprint(res,both:=true) + ?complex_sprint(complex_round(res,1e16),true) + ?complex_sprint(complex_round(res,1e15),true) + + with javascript_semantics + procedure reduce(string s) + constant rules = {{"-1+1","0"}, + {"-1+0","-1"}, + {"i*0","0"}, + {"sin(pi)","0"}, + {"cos(pi)","-1"}, + {"exp(i*pi)","cos(pi)+i*sin(pi)"}} + string t = s + sequence seen = {} -- (be safe and avoid infinite loops) + while not find(t,seen) -- "" re-treading + and length(t)<10000 do -- "" ever-growing + seen = append(seen,t) + bool found = false + for i=1 to length(rules) do + string {r,e} = rules[i] + if match(r,t) then + found = true + t = substitute(t,r,e) + end if + end for + if not found then exit end if + printf(1,"%s = %s\n",{s,t}) + s = repeat(' ',length(s)) + end while + end procedure -procedure reduce(string s) - string t = s - sequence seen = {} -- (be safe and avoid infinite loops) - while not find(t,seen) -- "" re-treading - and length(t)<10000 do -- "" ever-growing - seen = append(seen,t) - bool found = false - for i=1 to length(rules) do - string {r,e} = rules[i] - if match(r,t) then - found = true - t = substitute(t,r,e) - end if - end for - if not found then exit end if - printf(1,"%s = %s\n",{s,t}) - s = repeat(' ',length(s)) - end while -end procedure - -reduce("exp(i*pi)+1") + reduce("exp(i*pi)+1") + + with javascript_semantics + constant MAX = 250 -constant p5 = new_dict(), - sum2 = new_dict() + constant p5 = new_dict(), + sum2 = new_dict() -atom t0 = time() -for i=1 to MAX do - atom i5 = power(i,5) - setd(i5,i,p5) - for j=1 to i-1 do - atom j5 = power(j,5) - setd(j5+i5,{i,j},sum2) - end for -end for + atom t0 = time() + for i=1 to MAX do + atom i5 = power(i,5) + setd(i5,i,p5) + for j=1 to i-1 do + atom j5 = power(j,5) + setd(j5+i5,{j,i},sum2) + end for + end for -printf(1,"created %d + %d dictionary entries (%gs)\n", - {dict_size(p5),dict_size(sum2),time()-t0}) + ?time()-t0 -bool found = false -function forsum2(object s, data, p) - if p<=s then return 0 end if - integer k = getd_index(p-s,sum2) - if k!=NULL then - printf(1,"%d^5 + %d^5 + %d^5 +%d^5 = %d^5 (%gs)\n", - getd_by_index(k,sum2)&data&getd(p,p5)&(time()-t0)) - found = true - return 0 -- (show one solution per p) - end if - return 1 -end function + function forsum2(object s, object data, object p) + if p<=s then return 0 end if + integer k = getd_index(p-s,sum2) + if k!=NULL then + ?getd(p,p5)&data&getd_by_index(k,sum2) + return 0 -- (show one solution per p) + end if + return 1 + end function -function forp5(object key, /*data*/, /*user_data*/) - traverse_dict(forsum2,key,sum2) - return not found -end function + function forp5(object key, object /*data*/, object /*user_data*/) + traverse_dict(forsum2,key,sum2) + return 1 + end function -traverse_dict(forp5,0,p5) + traverse_dict(forp5,0,p5) + + ?time()-t0 + + global function choose(integer n, k) + atom res = 1 + for i=1 to k do + res = (res*(n-i+1))/i + end for + return res + end function + + ?choose(5,3) + + with javascript_semantics + include builtins\mpfr.e + sequence tests = {{5,3},{100,50},{60,30},{1200,120}} + mpz r = mpz_init() + for i=1 to length(tests) do + integer {n,k} = tests[i] + mpz_bin_uiui(r,n,k) + ?mpz_get_str(r) + end for + n ) + [ i 1+ / ] ] is binomial ( n n --> ) 5 3 binomial echo diff --git a/Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-1.rs b/Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-1.rust similarity index 100% rename from Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-1.rs rename to Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-1.rust diff --git a/Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-2.rs b/Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-2.rust similarity index 100% rename from Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-2.rs rename to Task/Evaluate-binomial-coefficients/Rust/evaluate-binomial-coefficients-2.rust diff --git a/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.scm b/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.ss similarity index 100% rename from Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.scm rename to Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.ss diff --git a/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.scm b/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.ss similarity index 100% rename from Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.scm rename to Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.ss diff --git a/Task/Evaluate-binomial-coefficients/Standard-ML/evaluate-binomial-coefficients.ml b/Task/Evaluate-binomial-coefficients/Standard-ML/evaluate-binomial-coefficients.ml deleted file mode 100644 index 5c7ded2667..0000000000 --- a/Task/Evaluate-binomial-coefficients/Standard-ML/evaluate-binomial-coefficients.ml +++ /dev/null @@ -1,5 +0,0 @@ -fun binomial n k = - if k > n then 0 else - let fun f (_, 0) = 1 - | f (i, d) = f (i + 1, d - 1) * i div d - in f (n - k + 1, k) end diff --git a/Task/Evaluate-binomial-coefficients/True-BASIC/evaluate-binomial-coefficients-1.basic b/Task/Evaluate-binomial-coefficients/True-BASIC/evaluate-binomial-coefficients-1.basic deleted file mode 100644 index 1e8fe03440..0000000000 --- a/Task/Evaluate-binomial-coefficients/True-BASIC/evaluate-binomial-coefficients-1.basic +++ /dev/null @@ -1,35 +0,0 @@ -FUNCTION factorial(n) - IF n < 1 THEN LET factorial = 1 - - LET product = 1 - FOR i = 2 TO n - LET product = product*i - NEXT i - - LET factorial = product -END FUNCTION - -FUNCTION binomial(n, k) - ! Special cases - IF k = 0 OR k = n THEN LET binomial = 1 - IF k < 0 OR k > n THEN LET binomial = 0 - - ! For efficiency, we use the smallest value of k or (n-k) - IF k > n-k THEN LET k = n-k - LET product = 1 - - FOR i = 1 TO k - LET product = product*(n-k+i)/i - NEXT i - - LET binomial = INT(product+0.5) -END FUNCTION - -FOR n = 0 TO 14 - FOR k = 0 TO n - PRINT USING " ####": binomial(n,k); - NEXT k - PRINT -NEXT n - -END diff --git a/Task/Evaluate-binomial-coefficients/True-BASIC/evaluate-binomial-coefficients-2.basic b/Task/Evaluate-binomial-coefficients/True-BASIC/evaluate-binomial-coefficients-2.basic deleted file mode 100644 index f3d149d7c5..0000000000 --- a/Task/Evaluate-binomial-coefficients/True-BASIC/evaluate-binomial-coefficients-2.basic +++ /dev/null @@ -1,25 +0,0 @@ - REM PASCAL'S TRIANGLE - LET N=0 - 10 LET K=0 - 20 GOSUB 30 - PRINT B," " - LET K=K+1 - IF K<=N THEN GOTO 20 - PRINT "" - LET N=N+1 - IF N<=10 THEN GOTO 10 - END - 30 REM BINOMIAL - IF K=0 THEN GOTO 50 - IF K=N THEN GOTO 50 - LET P=1 - LET I=1 - 40 LET T=N-K+I - LET P=P*T/I - LET I=I+1 - IF I<=K THEN GOTO 40 - LET B=P - RETURN - 50 LET B=1 - RETURN - diff --git a/Task/Evaluate-binomial-coefficients/VBScript/evaluate-binomial-coefficients.vbs b/Task/Evaluate-binomial-coefficients/VBScript/evaluate-binomial-coefficients.vb similarity index 100% rename from Task/Evaluate-binomial-coefficients/VBScript/evaluate-binomial-coefficients.vbs rename to Task/Evaluate-binomial-coefficients/VBScript/evaluate-binomial-coefficients.vb diff --git a/Task/Evaluate-binomial-coefficients/Wren/evaluate-binomial-coefficients.wren b/Task/Evaluate-binomial-coefficients/Wren/evaluate-binomial-coefficients.wren index 61bfa38f0e..91af7b9424 100644 --- a/Task/Evaluate-binomial-coefficients/Wren/evaluate-binomial-coefficients.wren +++ b/Task/Evaluate-binomial-coefficients/Wren/evaluate-binomial-coefficients.wren @@ -1,5 +1,5 @@ -import "./fmt" for Fmt -import "./math" for Int +import "/fmt" for Fmt +import "/math" for Int var binomial = Fn.new { |n, k| if (n < 0 || k < 0) Fiber.abort("Arguments must be non-negative integers") diff --git a/Task/Evaluate-binomial-coefficients/Yabasic/evaluate-binomial-coefficients.basic b/Task/Evaluate-binomial-coefficients/Yabasic/evaluate-binomial-coefficients.basic deleted file mode 100644 index b4066edf86..0000000000 --- a/Task/Evaluate-binomial-coefficients/Yabasic/evaluate-binomial-coefficients.basic +++ /dev/null @@ -1,33 +0,0 @@ -for n = 0 to 14 - for k = 0 to n - print binomial(n, k) using "####"; - next k - print -next n -end - -sub factorial(n) - local product, i - - if n < 1 return 1 - - product = 1 - for i = 2 to n - product = product * i - next - - return product -end sub - -sub binomial(n, k) - local product, i - - if n < 0 or k < 0 or n <= k return 1 - - product = 1 - for i = n - k + 1 to n - product = product * i - next - - return int(product / factorial(k)) -end sub diff --git a/Task/Even-or-odd/ALGOL-60/even-or-odd.alg b/Task/Even-or-odd/ALGOL-60/even-or-odd.alg deleted file mode 100644 index 314105fd32..0000000000 --- a/Task/Even-or-odd/ALGOL-60/even-or-odd.alg +++ /dev/null @@ -1,21 +0,0 @@ -begin - -integer i; - -boolean procedure even(n); - value n; integer n; -begin - even := (n = entier(n/2) * 2); -end; - -comment - exercise the function; -for i := 1 step 3 until 12 do - begin - outinteger(1,i); - if even(i) then - outstring(1,"is even\n") - else - outstring(1,"is odd\n"); - end; - -end diff --git a/Task/Even-or-odd/Ada/even-or-odd.adb b/Task/Even-or-odd/Ada/even-or-odd.ada similarity index 100% rename from Task/Even-or-odd/Ada/even-or-odd.adb rename to Task/Even-or-odd/Ada/even-or-odd.ada diff --git a/Task/Even-or-odd/Adina/even-or-odd-1.adina b/Task/Even-or-odd/Adina/even-or-odd-1.adina deleted file mode 100644 index 07565c1f09..0000000000 --- a/Task/Even-or-odd/Adina/even-or-odd-1.adina +++ /dev/null @@ -1,4 +0,0 @@ -чётное число = - число % 2 == 0 -нечётное число = - число % 2 == 1 diff --git a/Task/Even-or-odd/Adina/even-or-odd-2.adina b/Task/Even-or-odd/Adina/even-or-odd-2.adina deleted file mode 100644 index e700193dbc..0000000000 --- a/Task/Even-or-odd/Adina/even-or-odd-2.adina +++ /dev/null @@ -1,4 +0,0 @@ -even x = - x % 2 == 0 -odd x = - x % 2 == 1 diff --git a/Task/Even-or-odd/ArkScript/even-or-odd.ark b/Task/Even-or-odd/ArkScript/even-or-odd.ark deleted file mode 100644 index 76058b09e1..0000000000 --- a/Task/Even-or-odd/ArkScript/even-or-odd.ark +++ /dev/null @@ -1,5 +0,0 @@ -(let is_even (fun (i) - (= 0 (mod i 2)))) - -(let is_odd (fun (i) - (= 1 (mod i 2)))) diff --git a/Task/Even-or-odd/Arturo/even-or-odd.arturo b/Task/Even-or-odd/Arturo/even-or-odd.arturo index eb282edf42..7dfd05748b 100644 --- a/Task/Even-or-odd/Arturo/even-or-odd.arturo +++ b/Task/Even-or-odd/Arturo/even-or-odd.arturo @@ -1,4 +1,4 @@ loop (neg 5)..5 [x][ - switch even? x -> print [pad to :string x 4 ": even"] - -> print [pad to :string x 4 ": odd"] + if? even? x -> print [pad to :string x 4 ": even"] + else -> print [pad to :string x 4 ": odd"] ] diff --git a/Task/Even-or-odd/Ballerina/even-or-odd.ballerina b/Task/Even-or-odd/Ballerina/even-or-odd.ballerina deleted file mode 100644 index 28dfdbd94a..0000000000 --- a/Task/Even-or-odd/Ballerina/even-or-odd.ballerina +++ /dev/null @@ -1,13 +0,0 @@ -import ballerina/io; - -function isEven(int n) returns boolean { - return n % 2 == 0; -} - -public function main() { - int i = -3; - io:println(`isEven(${i}): ${isEven(i)}`); - foreach int t in -2...4 { - io:println(`isEven(${t}): ${isEven(t)}`); - } -} diff --git a/Task/Even-or-odd/Batch-File/even-or-odd.bat b/Task/Even-or-odd/Batch-File/even-or-odd.bat index 4f48361e73..808359977b 100644 --- a/Task/Even-or-odd/Batch-File/even-or-odd.bat +++ b/Task/Even-or-odd/Batch-File/even-or-odd.bat @@ -1,12 +1,14 @@ @echo off -setlocal set /p i=Insert number: ::bitwise and set /a "test1=%i%&1" +::divide last character by 2 +set /a test2=%i:~-1%/2 + ::modulo -set /a test2=%i% %% 2 +set /a test3=%i% %% 2 set test pause>nul diff --git a/Task/Even-or-odd/COBOL/even-or-odd.cob b/Task/Even-or-odd/COBOL/even-or-odd.cobol similarity index 100% rename from Task/Even-or-odd/COBOL/even-or-odd.cob rename to Task/Even-or-odd/COBOL/even-or-odd.cobol diff --git a/Task/Even-or-odd/Crystal/even-or-odd.cr b/Task/Even-or-odd/Crystal/even-or-odd.cr deleted file mode 100644 index fbc489e27d..0000000000 --- a/Task/Even-or-odd/Crystal/even-or-odd.cr +++ /dev/null @@ -1,40 +0,0 @@ -#Using bitwise shift - def isEven_bShift(n) - n == ((n >> 1) << 1) - end - def isOdd_bShift(n) - n != ((n >> 1) << 1) - end -#Using modulo operator - def isEven_mod(n) - (n % 2) == 0 - end - def isOdd_mod(n) - (n % 2) != 0 - end -# Using bitwise "and" - def isEven_bAnd(n) - (n & 1) == 0 - end - def isOdd_bAnd(n) - (n & 1) != 0 - end -# Using integer predicates - def isEven_even(n) - n.even? - end - def isOdd_odd(n) - n.odd? - end - -puts isEven_bShift(7) -puts isOdd_bShift(7) - -puts isEven_mod(12) -puts isOdd_mod(12) - -puts isEven_bAnd(21) -puts isOdd_bAnd(21) - -puts isEven_even(32) -puts isOdd_odd(32) diff --git a/Task/Even-or-odd/Crystal/even-or-odd.crystal b/Task/Even-or-odd/Crystal/even-or-odd.crystal new file mode 100644 index 0000000000..b214424476 --- /dev/null +++ b/Task/Even-or-odd/Crystal/even-or-odd.crystal @@ -0,0 +1,30 @@ +#Using bitwise shift + def isEven_bShift(n) + n == ((n >> 1) << 1) + end + def isOdd_bShift(n) + n != ((n >> 1) << 1) + end +#Using modulo operator + def isEven_mod(n) + (n % 2) == 0 + end + def isOdd_mod(n) + (n % 2) != 0 + end +# Using bitwise "and" + def isEven_bAnd(n) + (n & 1) == 0 + end + def isOdd_bAnd(n) + (n & 1) != 0 + end + +puts isEven_bShift(7) +puts isOdd_bShift(7) + +puts isEven_mod(12) +puts isOdd_mod(12) + +puts isEven_bAnd(21) +puts isOdd_bAnd(21) diff --git a/Task/Even-or-odd/Delphi/even-or-odd.pas b/Task/Even-or-odd/Delphi/even-or-odd.delphi similarity index 100% rename from Task/Even-or-odd/Delphi/even-or-odd.pas rename to Task/Even-or-odd/Delphi/even-or-odd.delphi diff --git a/Task/Even-or-odd/DuckDB/even-or-odd-1.duckdb b/Task/Even-or-odd/DuckDB/even-or-odd-1.duckdb deleted file mode 100644 index fc23a91ef4..0000000000 --- a/Task/Even-or-odd/DuckDB/even-or-odd-1.duckdb +++ /dev/null @@ -1,3 +0,0 @@ -create or replace function evenp(i) as ( - i = trunc(i) and i%2 = 0 -); diff --git a/Task/Even-or-odd/DuckDB/even-or-odd-2.duckdb b/Task/Even-or-odd/DuckDB/even-or-odd-2.duckdb deleted file mode 100644 index f59859511f..0000000000 --- a/Task/Even-or-odd/DuckDB/even-or-odd-2.duckdb +++ /dev/null @@ -1 +0,0 @@ -select i, evenp(i), evenp(i::DOUBLE + 0.1) from range(-1,3) _(i); diff --git a/Task/Even-or-odd/EMal/even-or-odd.emal b/Task/Even-or-odd/EMal/even-or-odd.emal index ee2b7e1cd8..0292abacd4 100644 --- a/Task/Even-or-odd/EMal/even-or-odd.emal +++ b/Task/Even-or-odd/EMal/even-or-odd.emal @@ -1,16 +1,20 @@ -List evenCheckers ← fun[ - int.is_odd - |> bool.to_string - |> io.println - - 2 - |> int.is_even - |> bool.to_string - |> io.println -} diff --git a/Task/Even-or-odd/Insitux/even-or-odd.insitux b/Task/Even-or-odd/Insitux/even-or-odd.insitux deleted file mode 100644 index 75d0ec88bc..0000000000 --- a/Task/Even-or-odd/Insitux/even-or-odd.insitux +++ /dev/null @@ -1,2 +0,0 @@ -(if (even? some-var) (do-even-stuff)) -(if (odd? some-var) (do-odd-stuff)) diff --git a/Task/Even-or-odd/Julia/even-or-odd.jl b/Task/Even-or-odd/Julia/even-or-odd.julia similarity index 100% rename from Task/Even-or-odd/Julia/even-or-odd.jl rename to Task/Even-or-odd/Julia/even-or-odd.julia diff --git a/Task/Even-or-odd/Kotlin/even-or-odd.kts b/Task/Even-or-odd/Kotlin/even-or-odd.kotlin similarity index 100% rename from Task/Even-or-odd/Kotlin/even-or-odd.kts rename to Task/Even-or-odd/Kotlin/even-or-odd.kotlin diff --git a/Task/Even-or-odd/Nom/even-or-odd.num b/Task/Even-or-odd/Nom/even-or-odd.num deleted file mode 100644 index b67372cd5e..0000000000 --- a/Task/Even-or-odd/Nom/even-or-odd.num +++ /dev/null @@ -1,8 +0,0 @@ -# Least signficant digit method - read; - ![:space:] { - whilenot [:space:]; - [0-9] { E"1",E"3",E"5",E"7",E"9" { add " *ODD!*"; } } - print; clear; - } - [:space:] { while [:space:]; print; clear; } diff --git a/Task/Even-or-odd/Nu/even-or-odd.nu b/Task/Even-or-odd/Nu/even-or-odd.nu deleted file mode 100644 index df29fd8256..0000000000 --- a/Task/Even-or-odd/Nu/even-or-odd.nu +++ /dev/null @@ -1,7 +0,0 @@ -def is-even [x: int] { - ($x bit-and 1) == 0 -} - -def is-odd [x: int] { - ($x bit-and 1) == 1 -} diff --git a/Task/Even-or-odd/OCaml/even-or-odd-1.ml b/Task/Even-or-odd/OCaml/even-or-odd-1.ocaml similarity index 100% rename from Task/Even-or-odd/OCaml/even-or-odd-1.ml rename to Task/Even-or-odd/OCaml/even-or-odd-1.ocaml diff --git a/Task/Even-or-odd/OCaml/even-or-odd-2.ml b/Task/Even-or-odd/OCaml/even-or-odd-2.ocaml similarity index 100% rename from Task/Even-or-odd/OCaml/even-or-odd-2.ml rename to Task/Even-or-odd/OCaml/even-or-odd-2.ocaml diff --git a/Task/Even-or-odd/OCaml/even-or-odd-3.ml b/Task/Even-or-odd/OCaml/even-or-odd-3.ocaml similarity index 100% rename from Task/Even-or-odd/OCaml/even-or-odd-3.ml rename to Task/Even-or-odd/OCaml/even-or-odd-3.ocaml diff --git a/Task/Even-or-odd/Oberon-2/even-or-odd.oberon b/Task/Even-or-odd/Oberon-2/even-or-odd.oberon new file mode 100644 index 0000000000..e010e2ed06 --- /dev/null +++ b/Task/Even-or-odd/Oberon-2/even-or-odd.oberon @@ -0,0 +1,21 @@ +MODULE EvenOrOdd; +IMPORT + S := SYSTEM, + Out; +VAR + x: INTEGER; + s: SET; + +BEGIN + x := 10;Out.Int(x,0); + IF ODD(x) THEN Out.String(" odd") ELSE Out.String(" even") END; + Out.Ln; + + x := 11;s := S.VAL(SET,LONG(x));Out.Int(x,0); + IF 0 IN s THEN Out.String(" odd") ELSE Out.String(" even") END; + Out.Ln; + + x := 12;Out.Int(x,0); + IF x MOD 2 # 0 THEN Out.String(" odd") ELSE Out.String(" even") END; + Out.Ln +END EvenOrOdd. diff --git a/Task/Even-or-odd/PascalABC.NET/even-or-odd.pas b/Task/Even-or-odd/PascalABC.NET/even-or-odd.pas deleted file mode 100644 index d3cc8e5417..0000000000 --- a/Task/Even-or-odd/PascalABC.NET/even-or-odd.pas +++ /dev/null @@ -1,14 +0,0 @@ -function IsOddRemainder(x: integer) := x mod 2 <> 0; - -function IsEvenRemainder(x: integer) := x mod 2 = 0; - -function IsOddBitwise(x: integer) := x and 1 = 1; - -function IsEvenBitwise(x: integer) := x and 1 = 0; - -begin - var x := 3; - Println(x.IsEven,x.IsOdd); // Standard Predicates - Println(IsEvenRemainder(x),IsOddRemainder(x)); - Println(IsEvenBitwise(x),IsOddBitwise(x)); -end. diff --git a/Task/Even-or-odd/Pluto/even-or-odd.pluto b/Task/Even-or-odd/Pluto/even-or-odd.pluto deleted file mode 100644 index 670ade3ec5..0000000000 --- a/Task/Even-or-odd/Pluto/even-or-odd.pluto +++ /dev/null @@ -1,4 +0,0 @@ -local n = 123 -if n % 2 == 0 do - print('even') -else print('odd') end diff --git a/Task/Even-or-odd/PowerShell/even-or-odd-1.ps1 b/Task/Even-or-odd/PowerShell/even-or-odd-1.psh similarity index 100% rename from Task/Even-or-odd/PowerShell/even-or-odd-1.ps1 rename to Task/Even-or-odd/PowerShell/even-or-odd-1.psh diff --git a/Task/Even-or-odd/PowerShell/even-or-odd-2.ps1 b/Task/Even-or-odd/PowerShell/even-or-odd-2.psh similarity index 100% rename from Task/Even-or-odd/PowerShell/even-or-odd-2.ps1 rename to Task/Even-or-odd/PowerShell/even-or-odd-2.psh diff --git a/Task/Even-or-odd/PowerShell/even-or-odd-3.ps1 b/Task/Even-or-odd/PowerShell/even-or-odd-3.psh similarity index 100% rename from Task/Even-or-odd/PowerShell/even-or-odd-3.ps1 rename to Task/Even-or-odd/PowerShell/even-or-odd-3.psh diff --git a/Task/Even-or-odd/ReScript/even-or-odd.res b/Task/Even-or-odd/ReScript/even-or-odd.re similarity index 100% rename from Task/Even-or-odd/ReScript/even-or-odd.res rename to Task/Even-or-odd/ReScript/even-or-odd.re diff --git a/Task/Even-or-odd/Rust/even-or-odd-1.rs b/Task/Even-or-odd/Rust/even-or-odd-1.rust similarity index 100% rename from Task/Even-or-odd/Rust/even-or-odd-1.rs rename to Task/Even-or-odd/Rust/even-or-odd-1.rust diff --git a/Task/Even-or-odd/Rust/even-or-odd-2.rs b/Task/Even-or-odd/Rust/even-or-odd-2.rust similarity index 100% rename from Task/Even-or-odd/Rust/even-or-odd-2.rs rename to Task/Even-or-odd/Rust/even-or-odd-2.rust diff --git a/Task/Even-or-odd/Rye/even-or-odd.rye b/Task/Even-or-odd/Rye/even-or-odd.rye deleted file mode 100644 index c1822096c6..0000000000 --- a/Task/Even-or-odd/Rye/even-or-odd.rye +++ /dev/null @@ -1,2 +0,0 @@ -print is-even 2 -print is-odd 2 diff --git a/Task/Even-or-odd/Scheme/even-or-odd.scm b/Task/Even-or-odd/Scheme/even-or-odd.ss similarity index 100% rename from Task/Even-or-odd/Scheme/even-or-odd.scm rename to Task/Even-or-odd/Scheme/even-or-odd.ss diff --git a/Task/Even-or-odd/Swift/even-or-odd.swift b/Task/Even-or-odd/Swift/even-or-odd.swift index d1923eb659..a697ee6e29 100644 --- a/Task/Even-or-odd/Swift/even-or-odd.swift +++ b/Task/Even-or-odd/Swift/even-or-odd.swift @@ -1,3 +1,13 @@ -// Swift has Int.isMultiple(of:Int) -> Bool +func isEven(n:Int) -> Bool { -var isEven: (_:Int) -> Bool = {$0.isMultiple(of: 2)} + // Bitwise check + if (n & 1 != 0) { + return false + } + + // Mod check + if (n % 2 != 0) { + return false + } + return true +} diff --git a/Task/Even-or-odd/VBScript/even-or-odd.vbs b/Task/Even-or-odd/VBScript/even-or-odd.vb similarity index 100% rename from Task/Even-or-odd/VBScript/even-or-odd.vbs rename to Task/Even-or-odd/VBScript/even-or-odd.vb diff --git a/Task/Even-or-odd/Wren/even-or-odd.wren b/Task/Even-or-odd/Wren/even-or-odd.wren index b2801820b1..a081e12c32 100644 --- a/Task/Even-or-odd/Wren/even-or-odd.wren +++ b/Task/Even-or-odd/Wren/even-or-odd.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var isEven1 = Fn.new { |i| i & 1 == 0 } diff --git a/Task/Even-or-odd/YAMLScript/even-or-odd.ys b/Task/Even-or-odd/YAMLScript/even-or-odd.ys deleted file mode 100644 index 36ee519cd2..0000000000 --- a/Task/Even-or-odd/YAMLScript/even-or-odd.ys +++ /dev/null @@ -1,7 +0,0 @@ -!YS-v0 - -defn main(*xs): - each x xs: - if x:even?: - say: "$x is even" - say: "$x is odd" diff --git a/Task/Events/Ada/events-1.adb b/Task/Events/Ada/events-1.ada similarity index 100% rename from Task/Events/Ada/events-1.adb rename to Task/Events/Ada/events-1.ada diff --git a/Task/Events/Ada/events-2.adb b/Task/Events/Ada/events-2.ada similarity index 100% rename from Task/Events/Ada/events-2.adb rename to Task/Events/Ada/events-2.ada diff --git a/Task/Events/Ada/events-3.adb b/Task/Events/Ada/events-3.ada similarity index 100% rename from Task/Events/Ada/events-3.adb rename to Task/Events/Ada/events-3.ada diff --git a/Task/Events/Delphi/events.pas b/Task/Events/Delphi/events.delphi similarity index 100% rename from Task/Events/Delphi/events.pas rename to Task/Events/Delphi/events.delphi diff --git a/Task/Events/EasyLang/events.easy b/Task/Events/EasyLang/events.easy deleted file mode 100644 index 18092d262e..0000000000 --- a/Task/Events/EasyLang/events.easy +++ /dev/null @@ -1,8 +0,0 @@ -on timer - gcircle randomf * 100 randomf * 100 2 - timer 1 -. -on mouse_down - gcircle mouse_x mouse_y 2 -. -timer 0 diff --git a/Task/Events/Elixir/events.ex b/Task/Events/Elixir/events.elixir similarity index 100% rename from Task/Events/Elixir/events.ex rename to Task/Events/Elixir/events.elixir diff --git a/Task/Events/FutureBasic/events.basic b/Task/Events/FutureBasic/events.basic deleted file mode 100644 index b1138f1074..0000000000 --- a/Task/Events/FutureBasic/events.basic +++ /dev/null @@ -1,5 +0,0 @@ -timerbegin, 0.1, YES - cls : printf @"%@", time(@"h:mm:ss a zzz") -timerend - -HandleEvents diff --git a/Task/Events/Java/events.java b/Task/Events/Java/events.java deleted file mode 100644 index 67effa5bba..0000000000 --- a/Task/Events/Java/events.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.Timer; -import java.util.TimerTask; -import java.util.Date; - -public class Main { - public static void main(String[] args) { - Timer timer = new Timer(); - TimerTask task = new TimerTask() { - @Override - public void run() { - System.out.println(new Date()); - timer.cancel(); - } - }; - System.out.println(new Date()); - timer.schedule(task, 1000); - } -} diff --git a/Task/Events/Julia/events.jl b/Task/Events/Julia/events.julia similarity index 100% rename from Task/Events/Julia/events.jl rename to Task/Events/Julia/events.julia diff --git a/Task/Events/PascalABC.NET/events.pas b/Task/Events/PascalABC.NET/events.pas deleted file mode 100644 index 7f24ba7e63..0000000000 --- a/Task/Events/PascalABC.NET/events.pas +++ /dev/null @@ -1,13 +0,0 @@ -procedure OnElapsed(sender: object; eventArgs: System.Timers.ElapsedEventArgs); -begin - Writeln(eventArgs.SignalTime); - system.Timers.Timer(sender).Stop; -end; - -begin - var timer := System.Timers.Timer.Create(1000); - timer.Elapsed += OnElapsed; - Writeln(DateTime.Now); - timer.Start; - Console.ReadLine; -end. diff --git a/Task/Events/PowerShell/events.ps1 b/Task/Events/PowerShell/events.psh similarity index 100% rename from Task/Events/PowerShell/events.ps1 rename to Task/Events/PowerShell/events.psh diff --git a/Task/Events/Rust/events.rs b/Task/Events/Rust/events.rust similarity index 100% rename from Task/Events/Rust/events.rs rename to Task/Events/Rust/events.rust diff --git a/Task/Evolutionary-algorithm/8080-Assembly/evolutionary-algorithm.8080 b/Task/Evolutionary-algorithm/8080-Assembly/evolutionary-algorithm.8080 index bebda07f74..dafadfb1b4 100644 --- a/Task/Evolutionary-algorithm/8080-Assembly/evolutionary-algorithm.8080 +++ b/Task/Evolutionary-algorithm/8080-Assembly/evolutionary-algorithm.8080 @@ -1,162 +1,162 @@ -MRATE: equ 26 ; Chance of mutation (MRATE/256) -COPIES: equ 100 ; Amount of copies to make -fname1: equ 5Dh ; First filename on command line (used for RNG seed) -fname2: equ 6Dh ; Second filename (also used for RNG seed) - org 100h - ;;; Make random seed from the two CP/M 'filenames' - lxi b,rnddat - lxi h,fname1 - xra a - call seed ; First four bytes from fn1 make X - call seed ; Second four bytes from fn1 make A - mvi l,fname2 - call seed ; First four bytes from fn2 make B - call seed ; Second four bytes from fn2 make C - ;;; Create the first parent (random string) - lxi h,parent - mvi e,tgtsz-1 -genchr: call rndchr ; Get random character - mov m,a ; Store it - inx h - dcr e - jnz genchr - mvi m,'$' ; CP/M string terminator - ;;; Main loop -loop: lxi d,parent - push d - call puts ; Print current parent - pop h ; Calculate fitness - call fitnes - xra a ; If it is 0, all characters match, - ora d - rz ; So we stop. - lxi h,kids ; Otherwise, set HL to start of children, - mvi a,0FFh ; Initialize maximum fitness value - sta maxfit - mvi a,COPIES ; Initialize copy counter - sta copies - ;;; Make copies -copy: push h ; Store the place where the copy will go - call mutcpy ; Make a mutated copy of the parent - pop h ; Get the place where the copy went - push h ; But keep it on the stack - call fitnes ; Calculate the fitness of that copy - pop h ; Get place where copy went - lda maxfit ; Get current best fitness - cmp d ; Compare to fitness of current copy - jc next ; If it wasn't better, next copy - shld maxptr ; If it was better, store pointer - mov a,d - sta maxfit ; And new max fitness -next: lxi b,tgtsz ; Get place for next copy - dad b - xchg ; Keep in DE - lxi h,copies - dcr m ; Any copies left to make? - xchg - jnz copy ; Then make another copy - lhld maxptr ; Otherwise, get location of copy with best fitness - lxi b,parent ; Make that the new parent -pcopy: mov a,m ; Get character from copy - inx h - stax b ; Store into location of parent - inx b - cpi '$' ; Check for string terminator - jnz pcopy ; If it isn't, copy next character - jmp loop ; Otherwise, mutate new parent - ;;; Make a copy of the parent, mutate it, and store it at [HL]. -mutcpy: lxi b,parent -mcloop: ldax b ; Get current character - inx b - mov m,a ; Write it to new location - inx h - cpi '$' ; Was it the string terminator? - rz ; Then stop - call rand ; Otherwise, get random value - cpi MRATE ; Should we mutate this character? - jnc mcloop ; If not, just copy next character - call rndchr ; Otherwise, get a random character - dcx h ; And store it instead of the character we had - mov m,a - inx h - jmp mcloop - ;;; Calculate fitness of candidate under [HL], fitness is - ;;; returned in D. Fitness is "inverted", i.e. a fitness of 0 - ;;; means everything matches. -fitnes: lxi b,target - lxi d,tgtsz ; E=counter, D=fitness -floop: dcr e ; Done yet? - rz ; If so, return. - ldax b ; Get target character - inx b - cmp m ; Compare to current character - inx h - jz floop ; If they match, don't do anything - inr d ; If they don't match, count this - jmp floop - ;;; Generate a random uppercase letter, or a space - ;;; Return in A, other registers preserved -rndchr: call rand ; Get a random value - ani 31 ; from 0 to 31 - cpi 28 ; If 28 or higher, - jnc rndchr ; get another value - adi 'A' ; Make uppercase letter - cpi 'Z'+1 ; If the result is 'Z' or lower, - rc ; then return it, - mvi a,' ' ; otherwise return a space - ret - ;;; Load 4 bytes from [HL] and use them, plus A, as part of seed - ;;; in [BC] -seed: mvi e,4 ; 4 bytes -sloop: xra m - inx h - dcr e - jnz sloop - stax b - inx b - ret - ;;; Random number generator using XABC algorithm -rand: push h - lxi h,rnddat - inr m ; X++ - mov a,m ; X - inx h - xra m ; ^ C - inx h - xra m ; ^ A - mov m,a ; -> A - inx h - add m ; + B - mov m,a ; -> B - rar ; >>1 (ish) - dcx h - xra m ; ^ A - dcx h - add m ; + C - mov m,a ; -> C - pop h - ret - ;;; Print string to console using CP/M, saving all registers -puts: push h - push d - push b - push psw - mvi c,9 ; CP/M print string - call 5 - lxi d,nl ; Print a newline as well - mvi c,9 - call 5 - pop b - pop d - pop h - pop psw - ret -nl: db 13,10,'$' -target: db 'METHINKS IT IS LIKE A WEASEL$' -tgtsz: equ $-target -rnddat: ds 4 ; RNG state -copies: ds 1 ; Copies left to make -maxfit: ds 1 ; Best fitness seen -maxptr: ds 2 ; Pointer to copy with best fitness -parent: equ $ ; Store current parent here -kids: equ $+tgtsz ; Store mutated copies here +MRATE: equ 26 ; Chance of mutation (MRATE/256) +COPIES: equ 100 ; Amount of copies to make +fname1: equ 5Dh ; First filename on command line (used for RNG seed) +fname2: equ 6Dh ; Second filename (also used for RNG seed) + org 100h + ;;; Make random seed from the two CP/M 'filenames' + lxi b,rnddat + lxi h,fname1 + xra a + call seed ; First four bytes from fn1 make X + call seed ; Second four bytes from fn1 make A + mvi l,fname2 + call seed ; First four bytes from fn2 make B + call seed ; Second four bytes from fn2 make C + ;;; Create the first parent (random string) + lxi h,parent + mvi e,tgtsz-1 +genchr: call rndchr ; Get random character + mov m,a ; Store it + inx h + dcr e + jnz genchr + mvi m,'$' ; CP/M string terminator + ;;; Main loop +loop: lxi d,parent + push d + call puts ; Print current parent + pop h ; Calculate fitness + call fitnes + xra a ; If it is 0, all characters match, + ora d + rz ; So we stop. + lxi h,kids ; Otherwise, set HL to start of children, + mvi a,0FFh ; Initialize maximum fitness value + sta maxfit + mvi a,COPIES ; Initialize copy counter + sta copies + ;;; Make copies +copy: push h ; Store the place where the copy will go + call mutcpy ; Make a mutated copy of the parent + pop h ; Get the place where the copy went + push h ; But keep it on the stack + call fitnes ; Calculate the fitness of that copy + pop h ; Get place where copy went + lda maxfit ; Get current best fitness + cmp d ; Compare to fitness of current copy + jc next ; If it wasn't better, next copy + shld maxptr ; If it was better, store pointer + mov a,d + sta maxfit ; And new max fitness +next: lxi b,tgtsz ; Get place for next copy + dad b + xchg ; Keep in DE + lxi h,copies + dcr m ; Any copies left to make? + xchg + jnz copy ; Then make another copy + lhld maxptr ; Otherwise, get location of copy with best fitness + lxi b,parent ; Make that the new parent +pcopy: mov a,m ; Get character from copy + inx h + stax b ; Store into location of parent + inx b + cpi '$' ; Check for string terminator + jnz pcopy ; If it isn't, copy next character + jmp loop ; Otherwise, mutate new parent + ;;; Make a copy of the parent, mutate it, and store it at [HL]. +mutcpy: lxi b,parent +mcloop: ldax b ; Get current character + inx b + mov m,a ; Write it to new location + inx h + cpi '$' ; Was it the string terminator? + rz ; Then stop + call rand ; Otherwise, get random value + cpi MRATE ; Should we mutate this character? + jnc mcloop ; If not, just copy next character + call rndchr ; Otherwise, get a random character + dcx h ; And store it instead of the character we had + mov m,a + inx h + jmp mcloop + ;;; Calculate fitness of candidate under [HL], fitness is + ;;; returned in D. Fitness is "inverted", i.e. a fitness of 0 + ;;; means everything matches. +fitnes: lxi b,target + lxi d,tgtsz ; E=counter, D=fitness +floop: dcr e ; Done yet? + rz ; If so, return. + ldax b ; Get target character + inx b + cmp m ; Compare to current character + inx h + jz floop ; If they match, don't do anything + inr d ; If they don't match, count this + jmp floop + ;;; Generate a random uppercase letter, or a space + ;;; Return in A, other registers preserved +rndchr: call rand ; Get a random value + ani 31 ; from 0 to 31 + cpi 28 ; If 28 or higher, + jnc rndchr ; get another value + adi 'A' ; Make uppercase letter + cpi 'Z'+1 ; If the result is 'Z' or lower, + rc ; then return it, + mvi a,' ' ; otherwise return a space + ret + ;;; Load 4 bytes from [HL] and use them, plus A, as part of seed + ;;; in [BC] +seed: mvi e,4 ; 4 bytes +sloop: xra m + inx h + dcr e + jnz sloop + stax b + inx b + ret + ;;; Random number generator using XABC algorithm +rand: push h + lxi h,rnddat + inr m ; X++ + mov a,m ; X + inx h + xra m ; ^ C + inx h + xra m ; ^ A + mov m,a ; -> A + inx h + add m ; + B + mov m,a ; -> B + rar ; >>1 (ish) + dcx h + xra m ; ^ A + dcx h + add m ; + C + mov m,a ; -> C + pop h + ret + ;;; Print string to console using CP/M, saving all registers +puts: push h + push d + push b + push psw + mvi c,9 ; CP/M print string + call 5 + lxi d,nl ; Print a newline as well + mvi c,9 + call 5 + pop b + pop d + pop h + pop psw + ret +nl: db 13,10,'$' +target: db 'METHINKS IT IS LIKE A WEASEL$' +tgtsz: equ $-target +rnddat: ds 4 ; RNG state +copies: ds 1 ; Copies left to make +maxfit: ds 1 ; Best fitness seen +maxptr: ds 2 ; Pointer to copy with best fitness +parent: equ $ ; Store current parent here +kids: equ $+tgtsz ; Store mutated copies here diff --git a/Task/Evolutionary-algorithm/8086-Assembly/evolutionary-algorithm.8086 b/Task/Evolutionary-algorithm/8086-Assembly/evolutionary-algorithm.8086 index e38567385b..9b3c1c704f 100644 --- a/Task/Evolutionary-algorithm/8086-Assembly/evolutionary-algorithm.8086 +++ b/Task/Evolutionary-algorithm/8086-Assembly/evolutionary-algorithm.8086 @@ -1,123 +1,123 @@ - bits 16 - cpu 8086 -MRATE: equ 26 ; Mutation rate (MRATE/256) -COPIES: equ 100 ; Amount of copies to make -gettim: equ 02Ch ; MS-DOS get time function -pstr: equ 9 ; MS-DOS print string -section .text - org 100h - ;;; Use MS-DOS time to set random seed - mov ah,gettim - int 21h - mov [rnddat],cx - mov [rnddat+2],dx - ;;; Make first parent (random characters) - mov di,parent - mov cx,target.size-1 -getchr: call rndchr ; Get random character - stosb ; Store in parent - loop getchr - mov al,'$' ; Write string terminator - stosb - ;;; Main loop. -loop: mov bx,parent ; Print current parent - mov dx,bx - call puts - call fitnes ; Check fitness - test cl,cl ; If zero, we're done - jnz nxmut ; If not, do another mutation - ret ; Quit to DOS -nxmut: mov dl,0FFh ; DL = best fitness yet - mov di,kids ; Set DI to start of memory for children - mov ch,COPIES ; CH = amount of copies to make - xor bp,bp - ;;; Make copy, mutate, and test fitness -copy: mov bx,di ; Let BX = where next copy will go - call mutcpy ; Make the copy (and adjust DI) - call fitnes ; Check fitness - cmp cl,dl ; Is it better than the previous best one? - ja next ; If not, just do the next one, - mov dl,cl ; Otherwise, this is now the best one - lea bp,[di-target.size] ; Store a pointer to it in BP -next: dec ch ; One copy less - jnz copy ; Make another copy if we need to - mov si,bp ; We're done, the best child becomes - mov di,parent ; the parent for the next generation - mov cx,target.size - rep movsb - jmp loop ; Next generation - ;;; Make copy of parent, mutating as we go, and store at [DI] -mutcpy: mov si,parent -.loop: lodsb ; Get byte from parent - stosb ; Store in copy - cmp al,'$' ; Is it '$'? - je .out ; Then we're done - call rand ; Otherwise, should we mutate? - cmp al,MRATE - ja .loop ; If not, do next character - call rndchr ; But if so, get random character, - mov [di-1],al ; and overwrite the current character. - jmp .loop ; Then do the next character. -.out: ret - ;;; Get fitness of character in [BX] -fitnes: mov si,target - xor cl,cl ; Fitness -.loop: lodsb ; Get target character - cmp al,'$' ; Done? - je .out ; Then stop - cmp al,[bx] ; Equal to character under [BX]? - lahf ; Keep flags - inc bx ; Increment BX - sahf ; Restore flags (was al=[bx]?) - je .loop ; If equal, do next character - inc cx ; Otherwise, count this as a mismatch - jmp .loop -.out: ret - ;;; Generate random character, [A-Z] or space. -rndchr: call rand ; Get random number - and al,31 ; Lower five bits - cmp al,27 ; One of 27 characters? - jae rndchr ; If not, get new random number - add al,'A' ; Make uppercase letter - cmp al,'Z' ; More than 'Z'? - jbe .out ; If not, it's OK - mov al,' ' ; Otherwise, give a space -.out: ret - ;;; Random number generator using XABC algorithm - ;;; Returns random byte in AL -rand: push cx - push dx - mov cx,[rnddat] ; CH=X CL=A - mov dx,[rnddat+2] ; DH=B DL=C - inc ch ; X++ - xor cl,ch ; A ^= X - xor cl,dl ; A ^= C - add dh,cl ; B += A - mov al,dh ; C' = B - shr al,1 ; C' >>= 1 - xor al,cl ; C' ^= A - add al,dl ; C' += C - mov dl,al ; C = C' - mov [rnddat],cx - mov [rnddat+2],dx - pop dx - pop cx - ret - ;;; Print string in DX, plus a newline, saving registers -puts: push ax - push dx - mov ah,pstr - int 21h - mov dx,nl - int 21h - pop dx - pop ax - ret -section .data -nl: db 13,10,'$' -target: db 'METHINKS IT IS LIKE A WEASEL$' -.size: equ $-target -section .bss -rnddat: resb 4 ; RNG state -parent: resb target.size ; Place to store current parent -kids: resb COPIES*target.size ; Place to store children + bits 16 + cpu 8086 +MRATE: equ 26 ; Mutation rate (MRATE/256) +COPIES: equ 100 ; Amount of copies to make +gettim: equ 02Ch ; MS-DOS get time function +pstr: equ 9 ; MS-DOS print string +section .text + org 100h + ;;; Use MS-DOS time to set random seed + mov ah,gettim + int 21h + mov [rnddat],cx + mov [rnddat+2],dx + ;;; Make first parent (random characters) + mov di,parent + mov cx,target.size-1 +getchr: call rndchr ; Get random character + stosb ; Store in parent + loop getchr + mov al,'$' ; Write string terminator + stosb + ;;; Main loop. +loop: mov bx,parent ; Print current parent + mov dx,bx + call puts + call fitnes ; Check fitness + test cl,cl ; If zero, we're done + jnz nxmut ; If not, do another mutation + ret ; Quit to DOS +nxmut: mov dl,0FFh ; DL = best fitness yet + mov di,kids ; Set DI to start of memory for children + mov ch,COPIES ; CH = amount of copies to make + xor bp,bp + ;;; Make copy, mutate, and test fitness +copy: mov bx,di ; Let BX = where next copy will go + call mutcpy ; Make the copy (and adjust DI) + call fitnes ; Check fitness + cmp cl,dl ; Is it better than the previous best one? + ja next ; If not, just do the next one, + mov dl,cl ; Otherwise, this is now the best one + lea bp,[di-target.size] ; Store a pointer to it in BP +next: dec ch ; One copy less + jnz copy ; Make another copy if we need to + mov si,bp ; We're done, the best child becomes + mov di,parent ; the parent for the next generation + mov cx,target.size + rep movsb + jmp loop ; Next generation + ;;; Make copy of parent, mutating as we go, and store at [DI] +mutcpy: mov si,parent +.loop: lodsb ; Get byte from parent + stosb ; Store in copy + cmp al,'$' ; Is it '$'? + je .out ; Then we're done + call rand ; Otherwise, should we mutate? + cmp al,MRATE + ja .loop ; If not, do next character + call rndchr ; But if so, get random character, + mov [di-1],al ; and overwrite the current character. + jmp .loop ; Then do the next character. +.out: ret + ;;; Get fitness of character in [BX] +fitnes: mov si,target + xor cl,cl ; Fitness +.loop: lodsb ; Get target character + cmp al,'$' ; Done? + je .out ; Then stop + cmp al,[bx] ; Equal to character under [BX]? + lahf ; Keep flags + inc bx ; Increment BX + sahf ; Restore flags (was al=[bx]?) + je .loop ; If equal, do next character + inc cx ; Otherwise, count this as a mismatch + jmp .loop +.out: ret + ;;; Generate random character, [A-Z] or space. +rndchr: call rand ; Get random number + and al,31 ; Lower five bits + cmp al,27 ; One of 27 characters? + jae rndchr ; If not, get new random number + add al,'A' ; Make uppercase letter + cmp al,'Z' ; More than 'Z'? + jbe .out ; If not, it's OK + mov al,' ' ; Otherwise, give a space +.out: ret + ;;; Random number generator using XABC algorithm + ;;; Returns random byte in AL +rand: push cx + push dx + mov cx,[rnddat] ; CH=X CL=A + mov dx,[rnddat+2] ; DH=B DL=C + inc ch ; X++ + xor cl,ch ; A ^= X + xor cl,dl ; A ^= C + add dh,cl ; B += A + mov al,dh ; C' = B + shr al,1 ; C' >>= 1 + xor al,cl ; C' ^= A + add al,dl ; C' += C + mov dl,al ; C = C' + mov [rnddat],cx + mov [rnddat+2],dx + pop dx + pop cx + ret + ;;; Print string in DX, plus a newline, saving registers +puts: push ax + push dx + mov ah,pstr + int 21h + mov dx,nl + int 21h + pop dx + pop ax + ret +section .data +nl: db 13,10,'$' +target: db 'METHINKS IT IS LIKE A WEASEL$' +.size: equ $-target +section .bss +rnddat: resb 4 ; RNG state +parent: resb target.size ; Place to store current parent +kids: resb COPIES*target.size ; Place to store children diff --git a/Task/Evolutionary-algorithm/ABC/evolutionary-algorithm.abc b/Task/Evolutionary-algorithm/ABC/evolutionary-algorithm.abc deleted file mode 100644 index 8b34ace597..0000000000 --- a/Task/Evolutionary-algorithm/ABC/evolutionary-algorithm.abc +++ /dev/null @@ -1,39 +0,0 @@ -PUT "ABCDEFGHIJKLMNOPQRSTUVWXYZ " IN alphabet - -HOW TO RETURN initial.state target: - SHARE alphabet - PUT "" IN state - FOR c IN target: PUT state^choice alphabet IN state - RETURN state - -HOW TO RETURN state fitness target: - PUT #target IN score - FOR i IN {1..#target}: - IF state item i = target item i: PUT score-1 IN score - RETURN score - -HOW TO RETURN chance mutate state: - SHARE alphabet - PUT "" IN mutated - FOR i IN {1..#state}: - SELECT: - random < chance: PUT choice alphabet IN next - ELSE: PUT state item i IN next - PUT mutated^next IN mutated - RETURN mutated - -HOW TO EVOLVE TOWARD target: - PUT 0.1 IN mutation.rate - PUT 100 IN generation.size - PUT initial.state target IN state - WHILE state fitness target > 0: - WRITE (state fitness target)>>2, ": ", state/ - PUT {} IN next.generation - FOR i IN {1..generation.size}: - PUT mutation.rate mutate state IN child - PUT child fitness target IN score - PUT child IN next.generation[score] - PUT next.generation[min keys next.generation] IN state - WRITE (state fitness target)>>2, ": ", state/ - -EVOLVE TOWARD "METHINKS IT IS LIKE A WEASEL" diff --git a/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg b/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg index 0c866fc0c9..a3cf92424b 100644 --- a/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg +++ b/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg @@ -34,7 +34,7 @@ PROC evolve = VOID: [100]FLEX[UPB target]CHAR kid; INT iters := 0; kid[LWB kid] := LOC[UPB target]CHAR; - REAL mutate rate = 0.05; + REAL mutate rate; # initialize # FOR i FROM LWB parent TO UPB parent DO @@ -42,9 +42,10 @@ PROC evolve = VOID: OD; fits := fitness(parent); - WHILE + WHILE fits < 100.0 DO INT j; REAL kf; + mutate rate := 1.0 - exp(- (100.0 - fits)/400.0); FOR j FROM LWB kid TO UPB kid DO mutate(kid[j], parent, mutate rate) OD; @@ -55,9 +56,9 @@ PROC evolve = VOID: parent := kid[j] FI OD; - fits < 100.0 - DO - kewe( parent, iters, fits, mutate rate ); + IF iters MOD 100 = 0 THEN + kewe( parent, iters, fits, mutate rate ) + FI; iters+:=1 OD; kewe( parent, iters, fits, mutate rate ) diff --git a/Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.adb b/Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.ada similarity index 100% rename from Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.adb rename to Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.ada diff --git a/Task/Evolutionary-algorithm/Arturo/evolutionary-algorithm.arturo b/Task/Evolutionary-algorithm/Arturo/evolutionary-algorithm.arturo index a816314b35..06f157c7f5 100644 --- a/Task/Evolutionary-algorithm/Arturo/evolutionary-algorithm.arturo +++ b/Task/Evolutionary-algorithm/Arturo/evolutionary-algorithm.arturo @@ -1,5 +1,5 @@ target: "METHINKS IT IS LIKE A WEASEL" -alphabet: [' '] ++ @'A'..'Z' +alphabet: [` `] ++ @`A`..`Z` p: 0.05 c: 100 diff --git a/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk b/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk index f38f1ef32d..003524e349 100644 --- a/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk +++ b/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk @@ -2,55 +2,55 @@ output := "" target := "METHINKS IT IS LIKE A WEASEL" targetLen := StrLen(target) Loop, 26 - possibilities_%A_Index% := Chr(A_Index+64) ; A-Z + possibilities_%A_Index% := Chr(A_Index+64) ; A-Z possibilities_27 := " " C := 100 parent := "" Loop, %targetLen% { - Random, randomNum, 1, 27 + Random, randomNum, 1, 27 parent .= possibilities_%randomNum% } Loop, { - If (target = parent) - Break - If (Mod(A_Index,10) = 0) - output .= A_Index ": " parent ", fitness: " fitness(parent, target) "`n" - bestFit := 0 - Loop, %C% - If ((fitness := fitness(spawn := mutate(parent), target)) > bestFit) - bestSpawn := spawn , bestFit := fitness - parent := bestFit > fitness(parent, target) ? bestSpawn : parent - iter := A_Index + If (target = parent) + Break + If (Mod(A_Index,10) = 0) + output .= A_Index ": " parent ", fitness: " fitness(parent, target) "`n" + bestFit := 0 + Loop, %C% + If ((fitness := fitness(spawn := mutate(parent), target)) > bestFit) + bestSpawn := spawn , bestFit := fitness + parent := bestFit > fitness(parent, target) ? bestSpawn : parent + iter := A_Index } output .= parent ", " iter MsgBox, % output ExitApp mutate(parent) { - local output, replaceChar, newChar - output := "" - Loop, %targetLen% - { - Random, replaceChar, 0, 9 - If (replaceChar != 0) - output .= SubStr(parent, A_Index, 1) - else - { - Random, newChar, 1, 27 - output .= possibilities_%newChar% - } - } - Return output + local output, replaceChar, newChar + output := "" + Loop, %targetLen% + { + Random, replaceChar, 0, 9 + If (replaceChar != 0) + output .= SubStr(parent, A_Index, 1) + else + { + Random, newChar, 1, 27 + output .= possibilities_%newChar% + } + } + Return output } fitness(string, target) { - totalFit := 0 - Loop, % StrLen(string) - If (SubStr(string, A_Index, 1) = SubStr(target, A_Index, 1)) - totalFit++ - Return totalFit + totalFit := 0 + Loop, % StrLen(string) + If (SubStr(string, A_Index, 1) = SubStr(target, A_Index, 1)) + totalFit++ + Return totalFit } diff --git a/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c b/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c index 682c8e6ae6..1cf726bc37 100644 --- a/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c +++ b/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c @@ -12,56 +12,56 @@ const char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; /* returns random integer from 0 to n - 1 */ int irand(int n) { - int r, rand_max = RAND_MAX - (RAND_MAX % n); - while((r = rand()) >= rand_max); - return r / (rand_max / n); + int r, rand_max = RAND_MAX - (RAND_MAX % n); + while((r = rand()) >= rand_max); + return r / (rand_max / n); } /* number of different chars between a and b */ int unfitness(const char *a, const char *b) { - int i, sum = 0; - for (i = 0; a[i]; i++) - sum += (a[i] != b[i]); - return sum; + int i, sum = 0; + for (i = 0; a[i]; i++) + sum += (a[i] != b[i]); + return sum; } /* each char of b has 1/MUTATE chance of differing from a */ void mutate(const char *a, char *b) { - int i; - for (i = 0; a[i]; i++) - b[i] = irand(MUTATE) ? a[i] : tbl[irand(CHOICE)]; + int i; + for (i = 0; a[i]; i++) + b[i] = irand(MUTATE) ? a[i] : tbl[irand(CHOICE)]; - b[i] = '\0'; + b[i] = '\0'; } int main() { - int i, best_i, unfit, best, iters = 0; - char specimen[COPIES][sizeof(target) / sizeof(char)]; + int i, best_i, unfit, best, iters = 0; + char specimen[COPIES][sizeof(target) / sizeof(char)]; - /* init rand string */ - for (i = 0; target[i]; i++) - specimen[0][i] = tbl[irand(CHOICE)]; - specimen[0][i] = 0; + /* init rand string */ + for (i = 0; target[i]; i++) + specimen[0][i] = tbl[irand(CHOICE)]; + specimen[0][i] = 0; - do { - for (i = 1; i < COPIES; i++) - mutate(specimen[0], specimen[i]); + do { + for (i = 1; i < COPIES; i++) + mutate(specimen[0], specimen[i]); - /* find best fitting string */ - for (best_i = i = 0; i < COPIES; i++) { - unfit = unfitness(target, specimen[i]); - if(unfit < best || !i) { - best = unfit; - best_i = i; - } - } + /* find best fitting string */ + for (best_i = i = 0; i < COPIES; i++) { + unfit = unfitness(target, specimen[i]); + if(unfit < best || !i) { + best = unfit; + best_i = i; + } + } - if (best_i) strcpy(specimen[0], specimen[best_i]); - printf("iter %d, score %d: %s\n", iters++, best, specimen[0]); - } while (best); + if (best_i) strcpy(specimen[0], specimen[best_i]); + printf("iter %d, score %d: %s\n", iters++, best, specimen[0]); + } while (best); - return 0; + return 0; } diff --git a/Task/Evolutionary-algorithm/COBOL/evolutionary-algorithm.cob b/Task/Evolutionary-algorithm/COBOL/evolutionary-algorithm.cobol similarity index 100% rename from Task/Evolutionary-algorithm/COBOL/evolutionary-algorithm.cob rename to Task/Evolutionary-algorithm/COBOL/evolutionary-algorithm.cobol diff --git a/Task/Evolutionary-algorithm/Ceylon/evolutionary-algorithm.ceylon b/Task/Evolutionary-algorithm/Ceylon/evolutionary-algorithm.ceylon index 4ff54da5dd..2c501ca07d 100644 --- a/Task/Evolutionary-algorithm/Ceylon/evolutionary-algorithm.ceylon +++ b/Task/Evolutionary-algorithm/Ceylon/evolutionary-algorithm.ceylon @@ -1,49 +1,49 @@ import ceylon.random { - - DefaultRandom + + DefaultRandom } shared void run() { - - value mutationRate = 0.05; - value childrenPerGeneration = 100; - value target = "METHINKS IT IS LIKE A WEASEL"; - value alphabet = {' ', *('A'..'Z')}; - value random = DefaultRandom(); - - value randomLetter => random.nextElement(alphabet); - - function fitness(String a, String b) => - count {for([c1, c2] in zipPairs(a, b)) c1 == c2}; - - function mutate(String string) => - String { - for(letter in string) - if(random.nextFloat() < mutationRate) - then randomLetter - else letter - }; - - function makeCopies(String string) => - {for(i in 1..childrenPerGeneration) mutate(string)}; - - function chooseFittest(String+ children) => - children - .map((String element) => element->fitness(element, target)) - .max(increasingItem) - .key; - - variable value parent = String {for(i in 1..target.size) randomLetter}; - variable value generationCount = 0; - function display() => print("``generationCount``: ``parent``"); - - display(); - while(parent != target) { - parent = chooseFittest(parent, *makeCopies(parent)); - generationCount++; - display(); - } - - print("mutated into target in ``generationCount`` generations!"); - + + value mutationRate = 0.05; + value childrenPerGeneration = 100; + value target = "METHINKS IT IS LIKE A WEASEL"; + value alphabet = {' ', *('A'..'Z')}; + value random = DefaultRandom(); + + value randomLetter => random.nextElement(alphabet); + + function fitness(String a, String b) => + count {for([c1, c2] in zipPairs(a, b)) c1 == c2}; + + function mutate(String string) => + String { + for(letter in string) + if(random.nextFloat() < mutationRate) + then randomLetter + else letter + }; + + function makeCopies(String string) => + {for(i in 1..childrenPerGeneration) mutate(string)}; + + function chooseFittest(String+ children) => + children + .map((String element) => element->fitness(element, target)) + .max(increasingItem) + .key; + + variable value parent = String {for(i in 1..target.size) randomLetter}; + variable value generationCount = 0; + function display() => print("``generationCount``: ``parent``"); + + display(); + while(parent != target) { + parent = chooseFittest(parent, *makeCopies(parent)); + generationCount++; + display(); + } + + print("mutated into target in ``generationCount`` generations!"); + } diff --git a/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp index 838aa4eaa5..0d38dbc62d 100644 --- a/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp +++ b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp @@ -1,23 +1,23 @@ (defun unfit (s1 s2) (loop for a across s1 - for b across s2 count(char/= a b))) + for b across s2 count(char/= a b))) (defun mutate (str alp n) ; n: number of chars to mutate (let ((out (copy-seq str))) (dotimes (i n) (setf (char out (random (length str))) - (char alp (random (length alp))))) + (char alp (random (length alp))))) out)) (defun evolve (changes alpha target) (loop for gen from 1 - with f2 with s2 - with str = (mutate target alpha 100) - with fit = (unfit target str) - while (plusp fit) do - (setf s2 (mutate str alpha changes) - f2 (unfit target s2)) - (when (> fit f2) - (setf str s2 fit f2) - (format t "~5d: ~a (~d)~%" gen str fit)))) + with f2 with s2 + with str = (mutate target alpha 100) + with fit = (unfit target str) + while (plusp fit) do + (setf s2 (mutate str alpha changes) + f2 (unfit target s2)) + (when (> fit f2) + (setf str s2 fit f2) + (format t "~5d: ~a (~d)~%" gen str fit)))) (evolve 1 " ABCDEFGHIJKLMNOPQRSTUVWXYZ" "METHINKS IT IS LIKE A WEASEL") diff --git a/Task/Evolutionary-algorithm/Crystal/evolutionary-algorithm.cr b/Task/Evolutionary-algorithm/Crystal/evolutionary-algorithm.cr deleted file mode 100644 index b38ba00a51..0000000000 --- a/Task/Evolutionary-algorithm/Crystal/evolutionary-algorithm.cr +++ /dev/null @@ -1,33 +0,0 @@ -TARGET = "METHINKS IT IS LIKE A WEASEL".chars -ALPHABET = ('A'..'Z').to_a << ' ' -C = 200 -RATE = 0.05 - -def fitness (current, target) - current.zip(target).count {|a, b| a == b } / current.size -end - -def mutate (current, rate) - current.map {|ch| Random.rand < rate ? ALPHABET.sample : ch } -end - -def next_parent (current, target, c, rate) - candidate = current - candidate_fitness = fitness(current, target) - c.times do - child = mutate(current, rate) - child_fitness = fitness(child, target) - if child_fitness > candidate_fitness - candidate, candidate_fitness = child, child_fitness - end - end - candidate -end - -parent = TARGET.map { ALPHABET.sample } - -(1..).each do |gen| - printf "%4d %s\n", gen, parent.join - break if parent == TARGET - parent = next_parent(parent, TARGET, C, RATE) -end diff --git a/Task/Evolutionary-algorithm/Dart/evolutionary-algorithm.dart b/Task/Evolutionary-algorithm/Dart/evolutionary-algorithm.dart deleted file mode 100644 index 34a176b6c5..0000000000 --- a/Task/Evolutionary-algorithm/Dart/evolutionary-algorithm.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'dart:math'; - -class EvoAlgo { - static final String target = "METHINKS IT IS LIKE A WEASEL"; - static final List possibilities = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ".split(''); - static int c = 100; // Number of spawn per generation - static double minMutateRate = 0.09; - static int perfectFitness = target.length; - static String parent = ''; - static Random rand = Random(); - - static int fitness(String trial) { - int retVal = 0; - for (int i = 0; i < trial.length; i++) { - if (trial[i] == target[i]) retVal++; - } - return retVal; - } - - static double newMutateRate() { - return (((perfectFitness - fitness(parent)) / perfectFitness) * (1 - minMutateRate)); - } - - static String mutate(String parent, double rate) { - String retVal = ''; - for (int i = 0; i < parent.length; i++) { - retVal += (rand.nextDouble() <= rate) - ? possibilities[rand.nextInt(possibilities.length)] - : parent[i]; - } - return retVal; - } - - static void main() { - parent = mutate(target, 1); - int iter = 0; - while (parent != target) { - double rate = newMutateRate(); - iter++; - if (iter % 100 == 0) { - print('$iter: $parent, fitness: ${fitness(parent)}, rate: $rate'); - } - String bestSpawn; - int bestFit = 0; - for (int i = 0; i < c; i++) { - String spawn = mutate(parent, rate); - int fit = fitness(spawn); - if (fit > bestFit) { - bestSpawn = spawn; - bestFit = fit; - } - } - if (bestFit > fitness(parent)) { - parent = bestSpawn; - } - } - print('$parent, $iter'); - } -} - -void main() { - EvoAlgo.main(); -} diff --git a/Task/Evolutionary-algorithm/EasyLang/evolutionary-algorithm.easy b/Task/Evolutionary-algorithm/EasyLang/evolutionary-algorithm.easy deleted file mode 100644 index c7b8c72d26..0000000000 --- a/Task/Evolutionary-algorithm/EasyLang/evolutionary-algorithm.easy +++ /dev/null @@ -1,37 +0,0 @@ -target$ = "METHINKS IT IS LIKE A WEASEL" -abc$[] = strchars " ABCDEFGHIJLKLMNOPQRSTUVWXYZ" -P = 0.05 -C = 100 -func fitness trial$ . - for i to len trial$ - res += if substr trial$ i 1 <> substr target$ i 1 - . - return res -. -func$ mutate parent$ . - for c$ in strchars parent$ - if randomf < P - res$ &= abc$[random 1 len abc$[]] - else - res$ &= c$ - . - . - return res$ -. -for i to len target$ - parent$ &= abc$[random 1 len abc$[]] -. -while fitness parent$ > 0 - copies$[] = [ ] - for i to C - copies$[] &= mutate parent$ - . - parent$ = copies$[1] - for s$ in copies$[] - if fitness s$ < fitness parent$ - parent$ = s$ - . - . - step += 1 - print step & " " & parent$ -. diff --git a/Task/Evolutionary-algorithm/EchoLisp/evolutionary-algorithm.l b/Task/Evolutionary-algorithm/EchoLisp/evolutionary-algorithm.l index 5dcec7d3ee..33ebb8503a 100644 --- a/Task/Evolutionary-algorithm/EchoLisp/evolutionary-algorithm.l +++ b/Task/Evolutionary-algorithm/EchoLisp/evolutionary-algorithm.l @@ -3,36 +3,36 @@ (vector-push ALPHABET " ") (define (fitness source target) ;; score >=0, best is 0 - (for/sum [(s source)(t target)] - (if (= s t) 0 1))) - + (for/sum [(s source)(t target)] + (if (= s t) 0 1))) + (define (mutate source rate) - (for/string [(s source)] - (if (< (random) rate) [ALPHABET (random 27)] s))) - + (for/string [(s source)] + (if (< (random) rate) [ALPHABET (random 27)] s))) + (define (select parent target rate copies (copy) (score)) - (define best (fitness parent target)) - (define selected parent) - (for [(i copies)] - (set! copy (mutate parent rate)) - (set! score (fitness copy target)) - (when (< score best) - (set! selected copy) - (set! best score))) - selected ) - + (define best (fitness parent target)) + (define selected parent) + (for [(i copies)] + (set! copy (mutate parent rate)) + (set! score (fitness copy target)) + (when (< score best) + (set! selected copy) + (set! best score))) + selected ) + (define MUTATION_RATE 0.05) ;; 5% chances to change (define COPIES 100) (define TARGET "METHINKS IT IS LIKE A WEASEL") (define (task (rate MUTATION_RATE) (copies COPIES) (target TARGET) (score)) - (define parent ;; random source - (for/string + (define parent ;; random source + (for/string [(i (string-length target))] [ALPHABET (random 27)])) - - (for [(i (in-naturals))] - (set! score (fitness parent target)) - (writeln i parent 'score score) - #:break (zero? score) - (set! parent (select parent target rate copies)) - )) + + (for [(i (in-naturals))] + (set! score (fitness parent target)) + (writeln i parent 'score score) + #:break (zero? score) + (set! parent (select parent target rate copies)) + )) diff --git a/Task/Evolutionary-algorithm/Elena/evolutionary-algorithm.elena b/Task/Evolutionary-algorithm/Elena/evolutionary-algorithm.elena index b26b81a6d0..235e31d6bd 100644 --- a/Task/Evolutionary-algorithm/Elena/evolutionary-algorithm.elena +++ b/Task/Evolutionary-algorithm/Elena/evolutionary-algorithm.elena @@ -8,7 +8,7 @@ const string AllowedCharacters = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int C = 100; const real P = 0.05r; -rnd = Random; +rnd = randomGenerator; randomChar = AllowedCharacters[rnd.nextInt(AllowedCharacters.Length)]; @@ -16,61 +16,61 @@ randomChar extension evoHelper { randomString() - = 0.repeatTill(self).selectBy::(x => randomChar).summarize(new StringWriter()); + = 0.repeatTill(self).selectBy:(x => randomChar).summarize(new StringWriter()); fitnessOf(s) - = self.zipBy(s, (a,b => (a==b) ? 1 : 0)).summarize(new Integer()).toInt(); + = self.zipBy(s, (a,b => a==b ? 1 : 0)).summarize(new Integer()).toInt(); mutate(p) - = self.selectBy::(ch => (rnd.nextReal() <= p) ? randomChar : ch).summarize(new StringWriter()); + = self.selectBy:(ch => rnd.nextReal() <= p ? randomChar : ch).summarize(new StringWriter()); } class EvoAlgorithm : Enumerator { - object _target; - object? _current; - object _variantCount; + object theTarget; + object theCurrent; + object theVariantCount; constructor new(s,count) { - _target := s; - _variantCount := count.toInt(); + theTarget := s; + theVariantCount := count.toInt(); } - get Value() = _current; + get() = theCurrent; bool next() { - if (nil == _current) - { _current := _target.Length.randomString(); ^ true }; + if (nil == theCurrent) + { theCurrent := theTarget.Length.randomString(); ^ true }; - if (_target == _current) + if (theTarget == theCurrent) { ^ false }; - auto variants := Array.allocate(_variantCount).populate::(x => _current.mutate(P) ); + auto variants := Array.allocate(theVariantCount).populate:(x => theCurrent.mutate:P ); - _current := variants.sort::(a,b => a.fitnessOf(Target) > b.fitnessOf(Target) ).at(0); + theCurrent := variants.sort:(a,b => a.fitnessOf:Target > b.fitnessOf:Target ).at:0; ^ true } reset() { - _current := nil + theCurrent := nil } - enumerable() => _target; + enumerable() => theTarget; } -public Program() +public program() { var attempt := new Integer(); - EvoAlgorithm.new(Target,C).forEach::(current) + EvoAlgorithm.new(Target,C).forEach:(current) { - Console + console .printPaddingLeft(10,"#",attempt.append(1)) .printLine(" ",current," fitness: ",current.fitnessOf(Target)) }; - Console.readChar() + console.readChar() } diff --git a/Task/Evolutionary-algorithm/Elixir/evolutionary-algorithm.ex b/Task/Evolutionary-algorithm/Elixir/evolutionary-algorithm.elixir similarity index 100% rename from Task/Evolutionary-algorithm/Elixir/evolutionary-algorithm.ex rename to Task/Evolutionary-algorithm/Elixir/evolutionary-algorithm.elixir diff --git a/Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.eu b/Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.euphoria similarity index 100% rename from Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.eu rename to Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.euphoria diff --git a/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f b/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f index 4cbf77fb0d..e16722f652 100644 --- a/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f +++ b/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f @@ -1,135 +1,135 @@ !*************************************************************************************************** - module evolve_routines + module evolve_routines !*************************************************************************************************** - implicit none - - !the target string: - character(len=*),parameter :: targ = 'METHINKS IT IS LIKE A WEASEL' - - contains + implicit none + + !the target string: + character(len=*),parameter :: targ = 'METHINKS IT IS LIKE A WEASEL' + + contains !*************************************************************************************************** - + !******************************************************************** - pure elemental function fitness(member) result(n) + pure elemental function fitness(member) result(n) !******************************************************************** ! The fitness function. The lower the value, the better the match. ! It is zero if they are identical. !******************************************************************** - - implicit none - integer :: n - character(len=*),intent(in) :: member - - integer :: i - - n=0 - do i=1,len(targ) - n = n + abs( ichar(targ(i:i)) - ichar(member(i:i)) ) - end do - + + implicit none + integer :: n + character(len=*),intent(in) :: member + + integer :: i + + n=0 + do i=1,len(targ) + n = n + abs( ichar(targ(i:i)) - ichar(member(i:i)) ) + end do + !******************************************************************** - end function fitness + end function fitness !******************************************************************** - + !******************************************************************** - pure elemental subroutine mutate(member,factor) + pure elemental subroutine mutate(member,factor) !******************************************************************** ! mutate a member of the population. !******************************************************************** - - implicit none - character(len=*),intent(inout) :: member !population member - real,intent(in) :: factor !mutation factor - - integer,parameter :: n_chars = 27 !number of characters in set - character(len=n_chars),parameter :: chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' - - real :: rnd_val - integer :: i,j,n - - n = len(member) - - do i=1,n - rnd_val = rand() - if (rnd_val<=factor) then !mutate this element - rnd_val = rand() - j = int(rnd_val*n_chars)+1 !an integer between 1 and n_chars - member(i:i) = chars(j:j) - end if - end do - + + implicit none + character(len=*),intent(inout) :: member !population member + real,intent(in) :: factor !mutation factor + + integer,parameter :: n_chars = 27 !number of characters in set + character(len=n_chars),parameter :: chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' + + real :: rnd_val + integer :: i,j,n + + n = len(member) + + do i=1,n + rnd_val = rand() + if (rnd_val<=factor) then !mutate this element + rnd_val = rand() + j = int(rnd_val*n_chars)+1 !an integer between 1 and n_chars + member(i:i) = chars(j:j) + end if + end do + !******************************************************************** - end subroutine mutate + end subroutine mutate !******************************************************************** !*************************************************************************************************** - end module evolve_routines + end module evolve_routines !*************************************************************************************************** !*************************************************************************************************** - program evolve + program evolve !*************************************************************************************************** ! The main program !*************************************************************************************************** - use evolve_routines - - implicit none - - !Tuning parameters: - integer,parameter :: seed = 12345 !random number generator seed - integer,parameter :: max_iter = 10000 !maximum number of iterations - integer,parameter :: population_size = 200 !size of the population - real,parameter :: factor = 0.04 ![0,1] mutation factor - integer,parameter :: iprint = 5 !print every iprint iterations - - !local variables: - integer :: i,iter - integer,dimension(1) :: i_best - character(len=len(targ)),dimension(population_size) :: population - - !initialize random number generator: - call srand(seed) - - !create initial population: - ! [the first element of the population will hold the best member] - population(1) = 'PACQXJB CQPWEYKSVDCIOUPKUOJY' !initial guess - iter=0 - - write(*,'(A10,A30,A10)') 'iter','best','fitness' - write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) - - do - - iter = iter + 1 !iteration counter - - !write the iteration: - if (mod(iter,iprint)==0) write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) - - !check exit conditions: - if ( iter>max_iter .or. fitness(population(1))==0 ) exit - - !copy best member and mutate: - population = population(1) - do i=2,population_size - call mutate(population(i),factor) - end do - - !select the new best population member: - ! [the best has the lowest value] - i_best = minloc(fitness(population)) - population(1) = population(i_best(1)) - - end do - - !write the last iteration: - if (mod(iter,iprint)/=0) write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) - - if (iter>max_iter) then - write(*,*) 'No solution found.' - else - write(*,*) 'Solution found.' - end if - + use evolve_routines + + implicit none + + !Tuning parameters: + integer,parameter :: seed = 12345 !random number generator seed + integer,parameter :: max_iter = 10000 !maximum number of iterations + integer,parameter :: population_size = 200 !size of the population + real,parameter :: factor = 0.04 ![0,1] mutation factor + integer,parameter :: iprint = 5 !print every iprint iterations + + !local variables: + integer :: i,iter + integer,dimension(1) :: i_best + character(len=len(targ)),dimension(population_size) :: population + + !initialize random number generator: + call srand(seed) + + !create initial population: + ! [the first element of the population will hold the best member] + population(1) = 'PACQXJB CQPWEYKSVDCIOUPKUOJY' !initial guess + iter=0 + + write(*,'(A10,A30,A10)') 'iter','best','fitness' + write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) + + do + + iter = iter + 1 !iteration counter + + !write the iteration: + if (mod(iter,iprint)==0) write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) + + !check exit conditions: + if ( iter>max_iter .or. fitness(population(1))==0 ) exit + + !copy best member and mutate: + population = population(1) + do i=2,population_size + call mutate(population(i),factor) + end do + + !select the new best population member: + ! [the best has the lowest value] + i_best = minloc(fitness(population)) + population(1) = population(i_best(1)) + + end do + + !write the last iteration: + if (mod(iter,iprint)/=0) write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) + + if (iter>max_iter) then + write(*,*) 'No solution found.' + else + write(*,*) 'Solution found.' + end if + !*************************************************************************************************** - end program evolve + end program evolve !*************************************************************************************************** diff --git a/Task/Evolutionary-algorithm/FutureBasic/evolutionary-algorithm.basic b/Task/Evolutionary-algorithm/FutureBasic/evolutionary-algorithm.basic deleted file mode 100644 index 36c9824034..0000000000 --- a/Task/Evolutionary-algorithm/FutureBasic/evolutionary-algorithm.basic +++ /dev/null @@ -1,80 +0,0 @@ -include "NSLog.incl" - -begin globals - CFStringRef target - CFStringRef alphabet - NSInteger c - CGFloat p -end globals - -target = @"METHINKS IT IS LIKE A WEASEL" -alphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ " -c = 100 -p = 0.06 - -toolbox fn arc4random_uniform( UInt32 upperbound ) = UInt32 - -local fn Fitness( s as CFStringRef ) as NSInteger - NSInteger score = len(target) - for NSInteger i = 0 to len(target) -1 - if ( ucc(s,i) == ucc(target,i) ) then score-- - next -end fn = score - -local fn Mutate( s as CFStringRef, rate as CGFloat ) as CFStringRef - CFMutableStringRef result = fn MutableStringWithString( @"" ) - for NSInteger i = 0 to len(s) -1 - if ( ( fn arc4random_uniform(100) / 100.0) < rate ) - NSInteger idx = fn arc4random_uniform( (UInt32)len(alphabet) ) - MutableStringAppendFormat( result, @"%C", ucc( alphabet, idx ) ) - else - MutableStringAppendFormat( result, @"%C", ucc( s, i ) ) - end if - next -end fn = result - -local fn RandomString( length as NSInteger ) as CFStringRef - CFMutableStringRef result = fn MutableStringWithString( @"" ) - for NSInteger i = 0 to length -1 - NSInteger idx = fn arc4random_uniform( (UInt32)len(alphabet) ) - MutableStringAppendFormat( result, @"%C", ucc( alphabet, idx ) ) - next -end fn = result - -void local fn PrintStep( stepNum as NSInteger, s as CFStringRef, fit as NSInteger, result as CFMutableStringRef ) - MutableStringAppendFormat( result, @"%3ld: %@ Distance: %ld\n", (long)stepNum, s, (long)fit ) -end fn - -local fn EvolveString as CFStringRef - CFMutableStringRef result = fn MutableStringNew - CFStringRef parent = fn RandomString( len(target) ) - fn PrintStep( 0, parent, fn Fitness(parent), result ) - - NSInteger stepNum = 0 - while ( fn StringIsEqual( parent, target ) == NO ) - NSInteger bestFitness = len(target) + 1 - CFStringRef bestChild = @"" - CFStringRef child - NSInteger fit - - for NSInteger i = 0 to c -1 - child = fn Mutate( parent, p ) - fit = fn Fitness( child ) - if ( fit < bestFitness ) - bestFitness = fit - bestChild = child - end if - next - parent = bestChild - stepNum++ - fn PrintStep( stepNum, parent, bestFitness, result ) - wend -end fn = result - -CFTimeInterval t : t = fn CACurrentMediaTime -CFStringRef result : result = fn EvolveString -NSLog( @"\nCompute time: %.3f ms\n",(fn CACurrentMediaTime-t)*1000 ) -NSLog( @"%@", result ) -NSLogScrollToTop - -HandleEvents diff --git a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-1.icon b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-1.icon deleted file mode 100644 index b601df08e4..0000000000 --- a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-1.icon +++ /dev/null @@ -1,51 +0,0 @@ -global target, chars, parent, C, M, current_fitness - -procedure fitness(s) - fit := 0 - #Increment the fitness for every position in the string s that matches the target - every i := 1 to *target & s[i] == target[i] do fit +:= 1 - return fit -end - -procedure mutate(s) - #If a random number between 0 and 1 is inside the bounds of mutation randomly alter a character in the string - if (?0 <= M) then ?s := ?chars - return s -end - -procedure generation() - population := [ ] - next_parent := "" - next_fitness := -1 - - #Create the next population - every 1 to C do push(population, mutate(parent)) - #Find the member of the population with highest fitness, or use the last one inspected - every x := !population & (xf := fitness(x)) > next_fitness do { - next_parent := x - next_fitness := xf - } - - parent := next_parent - - return next_fitness -end - -procedure main() - target := "METHINKS IT IS LIKE A WEASEL" #Our target string - chars := &ucase ++ " " #Set of usable characters - parent := "" & every 1 to *target do parent ||:= ?chars #The universal common ancestor! - current_fitness := fitness(parent) #The best fitness we have so far - - - C := 50 #Population size in each generation - M := 0.5 #Mutation rate per individual in a generation - - gen := 1 - #Until current fitness reaches a score of perfect match with the target string keep generating new populations - until ((current_fitness := generation()) = *target) do { - write(gen || " " || current_fitness || " " || parent) - gen +:= 1 - } - write("At generation " || gen || " we found a string with perfect fitness at " || current_fitness || " reading: " || parent) -end diff --git a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-2.icon b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-2.icon deleted file mode 100644 index 543e63dbd6..0000000000 --- a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-2.icon +++ /dev/null @@ -1,7 +0,0 @@ -(var c 100 ;number of children in each generation - p 0.05) ;mutation probability - -(var target "METHINKS IT IS LIKE A WEASEL" - tsize (len target)) - -(var alphabet (to-vec " ABCDEFGHIJLKLMNOPQRSTUVWXYZ")) diff --git a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-3.icon b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-3.icon deleted file mode 100644 index 9d992a43d1..0000000000 --- a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-3.icon +++ /dev/null @@ -1,5 +0,0 @@ -(var fitness (comp @(map = target) (count val))) -(var perfect-fit? (comp fitness (= tsize))) - -(var rand-char #(rand-pick alphabet)) -(var mutate (map #(if (< (rand) p) (rand-char) %))) diff --git a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-4.icon b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-4.icon deleted file mode 100644 index 8209d3fa09..0000000000 --- a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm-4.icon +++ /dev/null @@ -1,12 +0,0 @@ -(function evolve generation parent - - (print (pad-left " " 3 generation) " " (... str parent) " " (fitness parent)) - - (return-when (perfect-fit? parent)) - - (let children (times c #(mutate parent)) - fittest (max-by fitness (... vec parent children))) - - (recur (inc generation) fittest)) - -(evolve 1 (times tsize rand-char)) diff --git a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm.icon b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm.icon new file mode 100644 index 0000000000..039ac0694b --- /dev/null +++ b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm.icon @@ -0,0 +1,51 @@ +global target, chars, parent, C, M, current_fitness + +procedure fitness(s) + fit := 0 + #Increment the fitness for every position in the string s that matches the target + every i := 1 to *target & s[i] == target[i] do fit +:= 1 + return fit +end + +procedure mutate(s) + #If a random number between 0 and 1 is inside the bounds of mutation randomly alter a character in the string + if (?0 <= M) then ?s := ?chars + return s +end + +procedure generation() + population := [ ] + next_parent := "" + next_fitness := -1 + + #Create the next population + every 1 to C do push(population, mutate(parent)) + #Find the member of the population with highest fitness, or use the last one inspected + every x := !population & (xf := fitness(x)) > next_fitness do { + next_parent := x + next_fitness := xf + } + + parent := next_parent + + return next_fitness +end + +procedure main() + target := "METHINKS IT IS LIKE A WEASEL" #Our target string + chars := &ucase ++ " " #Set of usable characters + parent := "" & every 1 to *target do parent ||:= ?chars #The universal common ancestor! + current_fitness := fitness(parent) #The best fitness we have so far + + + C := 50 #Population size in each generation + M := 0.5 #Mutation rate per individual in a generation + + gen := 1 + #Until current fitness reaches a score of perfect match with the target string keep generating new populations + until ((current_fitness := generation()) = *target) do { + write(gen || " " || current_fitness || " " || parent) + gen +:= 1 + } + write("At generation " || gen || " we found a string with perfect fitness at " || current_fitness || " reading: " || parent) +end diff --git a/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm-1.js b/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm-1.js deleted file mode 100644 index 3162d81a5a..0000000000 --- a/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm-1.js +++ /dev/null @@ -1,230 +0,0 @@ -// ------------------------------------- Cross-browser Compatibility ------------------------------------- - -/* Compatibility code to reduce an array - * Source: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce - */ -if (!Array.prototype.reduce) { - Array.prototype.reduce = function (fun /*, initialValue */ ) { - "use strict"; - - if (this === void 0 || this === null) throw new TypeError(); - - var t = Object(this); - var len = t.length >>> 0; - if (typeof fun !== "function") throw new TypeError(); - - // no value to return if no initial value and an empty array - if (len == 0 && arguments.length == 1) throw new TypeError(); - - var k = 0; - var accumulator; - if (arguments.length >= 2) { - accumulator = arguments[1]; - } else { - do { - if (k in t) { - accumulator = t[k++]; - break; - } - - // if array contains no values, no initial value to return - if (++k >= len) throw new TypeError(); - } - while (true); - } - - while (k < len) { - if (k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t); - k++; - } - - return accumulator; - }; -} - -/* Compatibility code to map an array - * Source: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Map - */ -if (!Array.prototype.map) { - Array.prototype.map = function (fun /*, thisp */ ) { - "use strict"; - - if (this === void 0 || this === null) throw new TypeError(); - - var t = Object(this); - var len = t.length >>> 0; - if (typeof fun !== "function") throw new TypeError(); - - var res = new Array(len); - var thisp = arguments[1]; - for (var i = 0; i < len; i++) { - if (i in t) res[i] = fun.call(thisp, t[i], i, t); - } - - return res; - }; -} - -/* ------------------------------------- Generator ------------------------------------- - * Generates a fixed length gene sequence via a gene strategy object. - * The gene strategy object must have two functions: - * - "create": returns create a new gene - * - "mutate(existingGene)": returns mutation of an existing gene - */ -function Generator(length, mutationRate, geneStrategy) { - this.size = length; - this.mutationRate = mutationRate; - this.geneStrategy = geneStrategy; -} - -Generator.prototype.spawn = function () { - var genes = [], - x; - for (x = 0; x < this.size; x += 1) { - genes.push(this.geneStrategy.create()); - } - return genes; -}; - -Generator.prototype.mutate = function (parent) { - return parent.map(function (char) { - if (Math.random() > this.mutationRate) { - return char; - } - return this.geneStrategy.mutate(char); - }, this); -}; - -/* ------------------------------------- Population ------------------------------------- - * Helper class that holds and spawns a new population. - */ -function Population(size, generator) { - this.size = size; - this.generator = generator; - - this.population = []; - // Build initial popuation; - for (var x = 0; x < this.size; x += 1) { - this.population.push(this.generator.spawn()); - } -} - -Population.prototype.spawn = function (parent) { - this.population = []; - for (var x = 0; x < this.size; x += 1) { - this.population.push(this.generator.mutate(parent)); - } -}; - -/* ------------------------------------- Evolver ------------------------------------- - * Attempts to converge a population based a fitness strategy object. - * The fitness strategy object must have three function - * - "score(individual)": returns a score for an individual. - * - "compare(scoreA, scoreB)": return true if scoreA is better (ie more fit) then scoreB - * - "done( score )": return true if score is acceptable (ie we have successfully converged). - */ -function Evolver(size, generator, fitness) { - this.done = false; - this.fitness = fitness; - this.population = new Population(size, generator); -} - -Evolver.prototype.getFittest = function () { - return this.population.population.reduce(function (best, individual) { - var currentScore = this.fitness.score(individual); - if (best === null || this.fitness.compare(currentScore, best.score)) { - return { - score: currentScore, - individual: individual - }; - } else { - return best; - } - }, null); -}; - -Evolver.prototype.doGeneration = function () { - this.fittest = this.getFittest(); - this.done = this.fitness.done(this.fittest.score); - if (!this.done) { - this.population.spawn(this.fittest.individual); - } -}; - -Evolver.prototype.run = function (onCheckpoint, checkPointFrequency) { - checkPointFrequency = checkPointFrequency || 10; // Default to Checkpoints every 10 generations - var generation = 0; - while (!this.done) { - this.doGeneration(); - if (generation % checkPointFrequency === 0) { - onCheckpoint(generation, this.fittest); - } - generation += 1; - } - onCheckpoint(generation, this.fittest); - return this.fittest; -}; - -// ------------------------------------- Exports ------------------------------------- -window.Generator = Generator; -window.Evolver = Evolver; - - -// helper utitlity to combine elements of two arrays. -Array.prototype.zip = function (b, func) { - var result = [], - max = Math.max(this.length, b.length), - x; - for (x = 0; x < max; x += 1) { - result.push(func(this[x], b[x])); - } - return result; -}; - -var target = "METHINKS IT IS LIKE A WEASEL", geneStrategy, fitness, target, generator, evolver, result; - -geneStrategy = { - // The allowed character set (as an array) - characterSet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ ".split(""), - - /* - Pick a random character from the characterSet - */ - create: function getRandomGene() { - var randomNumber = Math.floor(Math.random() * this.characterSet.length); - return this.characterSet[randomNumber]; - } -}; -geneStrategy.mutate = geneStrategy.create; // Our mutation stragtegy is to simply get a random gene -fitness = { - // The target (as an array of characters) - target: target.split(""), - equal: function (geneA, geneB) { - return (geneA === geneB ? 0 : 1); - }, - sum: function (runningTotal, value) { - return runningTotal + value; - }, - - /* - We give one point to for each corect letter - */ - score: function (genes) { - var diff = genes.zip(this.target, this.equal); // create an array of ones and zeros - return diff.reduce(this.sum, 0); // Sum the array values together. - }, - compare: function (scoreA, scoreB) { - return scoreA <= scoreB; // Lower scores are better - }, - done: function (score) { - return score === 0; // We have matched the target string. - } -}; - -generator = new Generator(target.length, 0.05, geneStrategy); -evolver = new Evolver(100, generator, fitness); - -function showProgress(generation, fittest) { - document.write("Generation: " + generation + ", Best: " + fittest.individual.join("") + ", fitness:" + fittest.score + "
"); -} -result = evolver.run(showProgress); diff --git a/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm-2.js b/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm-2.js deleted file mode 100644 index 19c61c1e13..0000000000 --- a/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm-2.js +++ /dev/null @@ -1,125 +0,0 @@ -"use strict" -const TARGET = "METHINKS IT IS LIKE A WEASEL"; -const GENE_POOL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '; -const C = 100; -const MUTATION_RATE = 0.3; - -function randomIdGenerator(length) { - return Math.floor(Math.random() * length); -} -function getGene() { - return GENE_POOL[randomIdGenerator(GENE_POOL.length)]; -} - -class Parent { - _arrayLength; - _genePool; - _geneGenerator; - - constructor(arrayLength, genePool, geneGenerator) { - if (typeof arrayLength === 'number' && arrayLength > 0) { - this._arrayLength = arrayLength; - } - - if (typeof genePool === 'string' && genePool.length > 0) { - this._genePool = [...genePool]; - } - - if (typeof geneGenerator === 'function') { - this._geneGenerator = geneGenerator; - } - } - generate() { - const letters = []; - - while (letters.length < this._arrayLength) { - letters.push(this._geneGenerator()); - } - - return letters.join(''); - } -} - -function fitness(needle, target) { - if (needle.length !== target.length) return 0; - - const needleArray = [...needle]; - let count = 0; - - [...target].forEach((item, index) => { - if (item === needleArray[index]) count++; - }); - - return count; -} - -function mutate({ source, mutationRate }) { - if (typeof source !== 'string' || source.length === 0) return ''; - const sourceLength = source.length; - const iterations = Math.floor(sourceLength * mutationRate); - const stringArray = [...source]; - - for(let i = 0; i < iterations; i++) { - const shouldReplace = Boolean(Math.floor(Math.random() * 2)); - - if(shouldReplace) { - const id = randomIdGenerator(sourceLength); - stringArray[id] = getGene(); - } - } - - return stringArray.join(''); -} - -function createMutants(parent, mutantNumber) { - const mutantArray = []; - - for (let i = 0; i < mutantNumber; i++) { - const mutant = mutate({source: parent, mutationRate: MUTATION_RATE}); - - mutantArray.push( - { - mutant, - fitness: fitness(mutant, TARGET), - }, - ); - } - - return mutantArray; -} - -function helperInit(parentString, parentFitness) { - const mutant = createMutants(parentString, C) - .sort( (a,b) => a.fitness - b.fitness ).pop(); - - if (mutant.fitness >= parentFitness) { - return { - string: mutant.mutant, - fitness: mutant.fitness, - }; - } - - return { - string: parentString, - fitness: parentFitness, - }; -} - -function run() { - const parent = new Parent(TARGET.length, GENE_POOL, getGene); - let parentString = parent.generate(); - let parentFitness = fitness(parentString, TARGET); - let genCount = 0; - - while(parentString !== TARGET) { - const init = helperInit(parentString, parentFitness); - parentString = init.string; - parentFitness = init.fitness; - console.log(init.string); - genCount++; - } - - console.log(`Ended in ${genCount} generations`); -} - -run(); diff --git a/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js b/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js new file mode 100644 index 0000000000..42c57caec0 --- /dev/null +++ b/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js @@ -0,0 +1,230 @@ +// ------------------------------------- Cross-browser Compatibility ------------------------------------- + +/* Compatibility code to reduce an array + * Source: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce + */ +if (!Array.prototype.reduce) { + Array.prototype.reduce = function (fun /*, initialValue */ ) { + "use strict"; + + if (this === void 0 || this === null) throw new TypeError(); + + var t = Object(this); + var len = t.length >>> 0; + if (typeof fun !== "function") throw new TypeError(); + + // no value to return if no initial value and an empty array + if (len == 0 && arguments.length == 1) throw new TypeError(); + + var k = 0; + var accumulator; + if (arguments.length >= 2) { + accumulator = arguments[1]; + } else { + do { + if (k in t) { + accumulator = t[k++]; + break; + } + + // if array contains no values, no initial value to return + if (++k >= len) throw new TypeError(); + } + while (true); + } + + while (k < len) { + if (k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t); + k++; + } + + return accumulator; + }; +} + +/* Compatibility code to map an array + * Source: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Map + */ +if (!Array.prototype.map) { + Array.prototype.map = function (fun /*, thisp */ ) { + "use strict"; + + if (this === void 0 || this === null) throw new TypeError(); + + var t = Object(this); + var len = t.length >>> 0; + if (typeof fun !== "function") throw new TypeError(); + + var res = new Array(len); + var thisp = arguments[1]; + for (var i = 0; i < len; i++) { + if (i in t) res[i] = fun.call(thisp, t[i], i, t); + } + + return res; + }; +} + +/* ------------------------------------- Generator ------------------------------------- + * Generates a fixed length gene sequence via a gene strategy object. + * The gene strategy object must have two functions: + * - "create": returns create a new gene + * - "mutate(existingGene)": returns mutation of an existing gene + */ +function Generator(length, mutationRate, geneStrategy) { + this.size = length; + this.mutationRate = mutationRate; + this.geneStrategy = geneStrategy; +} + +Generator.prototype.spawn = function () { + var genes = [], + x; + for (x = 0; x < this.size; x += 1) { + genes.push(this.geneStrategy.create()); + } + return genes; +}; + +Generator.prototype.mutate = function (parent) { + return parent.map(function (char) { + if (Math.random() > this.mutationRate) { + return char; + } + return this.geneStrategy.mutate(char); + }, this); +}; + +/* ------------------------------------- Population ------------------------------------- + * Helper class that holds and spawns a new population. + */ +function Population(size, generator) { + this.size = size; + this.generator = generator; + + this.population = []; + // Build initial popuation; + for (var x = 0; x < this.size; x += 1) { + this.population.push(this.generator.spawn()); + } +} + +Population.prototype.spawn = function (parent) { + this.population = []; + for (var x = 0; x < this.size; x += 1) { + this.population.push(this.generator.mutate(parent)); + } +}; + +/* ------------------------------------- Evolver ------------------------------------- + * Attempts to converge a population based a fitness strategy object. + * The fitness strategy object must have three function + * - "score(individual)": returns a score for an individual. + * - "compare(scoreA, scoreB)": return true if scoreA is better (ie more fit) then scoreB + * - "done( score )": return true if score is acceptable (ie we have successfully converged). + */ +function Evolver(size, generator, fitness) { + this.done = false; + this.fitness = fitness; + this.population = new Population(size, generator); +} + +Evolver.prototype.getFittest = function () { + return this.population.population.reduce(function (best, individual) { + var currentScore = this.fitness.score(individual); + if (best === null || this.fitness.compare(currentScore, best.score)) { + return { + score: currentScore, + individual: individual + }; + } else { + return best; + } + }, null); +}; + +Evolver.prototype.doGeneration = function () { + this.fittest = this.getFittest(); + this.done = this.fitness.done(this.fittest.score); + if (!this.done) { + this.population.spawn(this.fittest.individual); + } +}; + +Evolver.prototype.run = function (onCheckpoint, checkPointFrequency) { + checkPointFrequency = checkPointFrequency || 10; // Default to Checkpoints every 10 generations + var generation = 0; + while (!this.done) { + this.doGeneration(); + if (generation % checkPointFrequency === 0) { + onCheckpoint(generation, this.fittest); + } + generation += 1; + } + onCheckpoint(generation, this.fittest); + return this.fittest; +}; + +// ------------------------------------- Exports ------------------------------------- +window.Generator = Generator; +window.Evolver = Evolver; + + +// helper utitlity to combine elements of two arrays. +Array.prototype.zip = function (b, func) { + var result = [], + max = Math.max(this.length, b.length), + x; + for (x = 0; x < max; x += 1) { + result.push(func(this[x], b[x])); + } + return result; +}; + +var target = "METHINKS IT IS LIKE A WEASEL", geneStrategy, fitness, target, generator, evolver, result; + +geneStrategy = { + // The allowed character set (as an array) + characterSet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ ".split(""), + + /* + Pick a random character from the characterSet + */ + create: function getRandomGene() { + var randomNumber = Math.floor(Math.random() * this.characterSet.length); + return this.characterSet[randomNumber]; + } +}; +geneStrategy.mutate = geneStrategy.create; // Our mutation stragtegy is to simply get a random gene +fitness = { + // The target (as an array of characters) + target: target.split(""), + equal: function (geneA, geneB) { + return (geneA === geneB ? 0 : 1); + }, + sum: function (runningTotal, value) { + return runningTotal + value; + }, + + /* + We give one point to for each corect letter + */ + score: function (genes) { + var diff = genes.zip(this.target, this.equal); // create an array of ones and zeros + return diff.reduce(this.sum, 0); // Sum the array values together. + }, + compare: function (scoreA, scoreB) { + return scoreA <= scoreB; // Lower scores are better + }, + done: function (score) { + return score === 0; // We have matched the target string. + } +}; + +generator = new Generator(target.length, 0.05, geneStrategy); +evolver = new Evolver(100, generator, fitness); + +function showProgress(generation, fittest) { + document.write("Generation: " + generation + ", Best: " + fittest.individual.join("") + ", fitness:" + fittest.score + "
"); +} +result = evolver.run(showProgress); diff --git a/Task/Evolutionary-algorithm/Jq/evolutionary-algorithm.jq b/Task/Evolutionary-algorithm/Jq/evolutionary-algorithm.jq deleted file mode 100644 index 5800f10a0f..0000000000 --- a/Task/Evolutionary-algorithm/Jq/evolutionary-algorithm.jq +++ /dev/null @@ -1,64 +0,0 @@ -# Assumption: input consists of random three-digit numbers i.e. 000 to 999 -def rand: input; - -def set: "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; - -def abs: - if . < 0 then -. else . end; - -def ichar: - if type == "number" then . else explode[0] end; - -# Output: a pseudo-random character from set. -# $n should be a random number drawn from range(0; N) inclusive where N > set|length -# Input: an admissible character from `set` (ignored in this implementation) -def shift($n): - ($n % (set|length)) as $i - | set[$i:$i+1]; - -# fitness: 0 indicates a perfect fit; greater numbers indicate worse fit. -def fitness($gold): - def diff($c; $d): ($c|ichar) - ($d|ichar) | abs; - . as $in - | reduce range(0;length) as $i (0; . + diff($in[$i:$i+1]; $gold[$i:$i+1])); - -# Input: a string -# Output: a mutation of . such that each character is mutated with probability $r -def mutate($r): - # Output: a pseudo-random character from set - # $n should be a random number drawn from range(0; N) inclusive where N > set|length - def letter($n): - ($n % (set|length)) as $i - | set[$i:$i+1]; - - . as $p - | reduce range(0;length) as $i (""; - rand as $rand - | if ($rand/1000) < $r then . + letter($rand) - else . + $p[$i:$i+1] - end ); - -# An array of $n children of the parent provided as input; $r is the mutation probability -def children($n; $r): - [range(0;$n) as $i | mutate($r)]; - -# Input: a "parent" -# Output: a single string -def next_generation($gold; $r): - ([.] + children(100; $r)) - | min_by( fitness($gold) ); - -# Evolve towards the target string provided as input, using $r as the mutation rate; -# `recurse` is used in order to show progress conveniently. -def evolve($r): - . as $gold - | (set|length) as $s - | (reduce range(0; $n) as $i (""; (rand % $s) as $j | . + set[$j:$j+1])) as $string - | {count: 0, $string } - | recurse ( - if .string | fitness($gold) == 0 then empty - else .string |= next_generation($gold; $r) - | .count += 1 - end); - -"METHINKS IT IS LIKE A WEASEL" | evolve(0.05) diff --git a/Task/Evolutionary-algorithm/Julia/evolutionary-algorithm.jl b/Task/Evolutionary-algorithm/Julia/evolutionary-algorithm.julia similarity index 100% rename from Task/Evolutionary-algorithm/Julia/evolutionary-algorithm.jl rename to Task/Evolutionary-algorithm/Julia/evolutionary-algorithm.julia diff --git a/Task/Evolutionary-algorithm/Kotlin/evolutionary-algorithm.kts b/Task/Evolutionary-algorithm/Kotlin/evolutionary-algorithm.kotlin similarity index 100% rename from Task/Evolutionary-algorithm/Kotlin/evolutionary-algorithm.kts rename to Task/Evolutionary-algorithm/Kotlin/evolutionary-algorithm.kotlin diff --git a/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua b/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua index 7d955f14ff..2d3d272d00 100644 --- a/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua +++ b/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua @@ -3,37 +3,37 @@ local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " local c, p = 100, 0.06 local function fitness(s) - local score = #target - for i = 1,#target do - if s:sub(i,i) == target:sub(i,i) then score = score - 1 end - end - return score + local score = #target + for i = 1,#target do + if s:sub(i,i) == target:sub(i,i) then score = score - 1 end + end + return score end local function mutate(s, rate) - local result, idx = "" - for i = 1,#s do - if math.random() < rate then - idx = math.random(#alphabet) - result = result .. alphabet:sub(idx,idx) - else - result = result .. s:sub(i,i) - end - end - return result, fitness(result) + local result, idx = "" + for i = 1,#s do + if math.random() < rate then + idx = math.random(#alphabet) + result = result .. alphabet:sub(idx,idx) + else + result = result .. s:sub(i,i) + end + end + return result, fitness(result) end local function randomString(len) - local result, idx = "" - for i = 1,len do - idx = math.random(#alphabet) - result = result .. alphabet:sub(idx,idx) - end - return result + local result, idx = "" + for i = 1,len do + idx = math.random(#alphabet) + result = result .. alphabet:sub(idx,idx) + end + return result end local function printStep(step, s, fit) - print(string.format("%04d: ", step) .. s .. " [" .. fit .."]") + print(string.format("%04d: ", step) .. s .. " [" .. fit .."]") end math.randomseed(os.time()) @@ -42,11 +42,11 @@ printStep(0, parent, fitness(parent)) local step = 0 while parent ~= target do - local bestFitness, bestChild, child, fitness = #target + 1 - for i = 1,c do - child, fitness = mutate(parent, p) - if fitness < bestFitness then bestFitness, bestChild = fitness, child end - end - parent, step = bestChild, step + 1 - printStep(step, parent, bestFitness) + local bestFitness, bestChild, child, fitness = #target + 1 + for i = 1,c do + child, fitness = mutate(parent, p) + if fitness < bestFitness then bestFitness, bestChild = fitness, child end + end + parent, step = bestChild, step + 1 + printStep(step, parent, bestFitness) end diff --git a/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-4.m b/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-4.m index 4bafdb7261..8fbb9f76e6 100644 --- a/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-4.m +++ b/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-4.m @@ -5,7 +5,7 @@ Gen: 4 | Fitness: 322 | KI8M5LAS�GJ�IS�SP�@)D�V@ JCP Gen: 5 | Fitness: 295 | UAUR08AS�GJ�IS�8HG*�+�=C?UB( Gen: 6 | Fitness: 259 | VCUQH35S�HR4.L�ISJQ%J�OC*T=E -Gen: 7 | Fitness: 226 | LFB8GPET(LODKQ�KQBQGF Gen: 9 | Fitness: 159 | N8R7?SOU�NO$OK O?K?!;�MB?QHG Gen: 10 | Fitness: 146 | TGN@EQR4)PS%IS#TFJQ%A!U>BVLI diff --git a/Task/Evolutionary-algorithm/Nanoquery/evolutionary-algorithm.nanoquery b/Task/Evolutionary-algorithm/Nanoquery/evolutionary-algorithm.nanoquery index d022b35839..d695b42ab6 100644 --- a/Task/Evolutionary-algorithm/Nanoquery/evolutionary-algorithm.nanoquery +++ b/Task/Evolutionary-algorithm/Nanoquery/evolutionary-algorithm.nanoquery @@ -8,77 +8,77 @@ rand = new(Random) // returns a random string of the specified length def rand_string(length) - global tbl - global rand + global tbl + global rand - ret = "" + ret = "" - for i in range(1, length) - ret += tbl[rand.getInt(len(tbl))] - end + for i in range(1, length) + ret += tbl[rand.getInt(len(tbl))] + end - return ret + return ret end // gets the fitness of a given string def fitness(string) - global target - fit = 0 + global target + fit = 0 - for i in range(0, len(string) - 1) - if string[i] != target[i] - fit -= 1 - end - end + for i in range(0, len(string) - 1) + if string[i] != target[i] + fit -= 1 + end + end - return fit + return fit end // mutates the specified string with a chance of 0.09 by default def mutate(string) - global chance - global rand - global tbl - mutated = string + global chance + global rand + global tbl + mutated = string - for i in range(0, len(mutated) - 1) - if rand.getFloat() <= chance - mutated[i] = tbl[rand.getInt(len(tbl))] - end - end + for i in range(0, len(mutated) - 1) + if rand.getFloat() <= chance + mutated[i] = tbl[rand.getInt(len(tbl))] + end + end - return mutated + return mutated end // a function to find the index of the string with the best fitness def most_fit(strlist) - global target + global target + + best_score = -(len(target) + 1) + best_index = 0 + + for j in range(0, len(strlist) - 1) + fit = fitness(strlist[j]) + if fit > best_score + best_index = j + best_score = fit + end + end - best_score = -(len(target) + 1) - best_index = 0 - - for j in range(0, len(strlist) - 1) - fit = fitness(strlist[j]) - if fit > best_score - best_index = j - best_score = fit - end - end - - return {best_index, best_score} + return {best_index, best_score} end parent = rand_string(len(target)); iter = 1 while parent != target - children = {} + children = {} - for i in range(1, 30) - children.append(mutate(parent)) - end + for i in range(1, 30) + children.append(mutate(parent)) + end - fit = most_fit(children) - parent = children[fit[0]] - print format("iter %d, score %d: %s\n", iter, fit[1], parent) + fit = most_fit(children) + parent = children[fit[0]] + print format("iter %d, score %d: %s\n", iter, fit[1], parent) - iter += 1 + iter += 1 end diff --git a/Task/Evolutionary-algorithm/OCaml/evolutionary-algorithm.ml b/Task/Evolutionary-algorithm/OCaml/evolutionary-algorithm.ocaml similarity index 100% rename from Task/Evolutionary-algorithm/OCaml/evolutionary-algorithm.ml rename to Task/Evolutionary-algorithm/OCaml/evolutionary-algorithm.ocaml diff --git a/Task/Evolutionary-algorithm/PARI-GP/evolutionary-algorithm.parigp b/Task/Evolutionary-algorithm/PARI-GP/evolutionary-algorithm.parigp index 8fbb6b82fa..e33c81e794 100644 --- a/Task/Evolutionary-algorithm/PARI-GP/evolutionary-algorithm.parigp +++ b/Task/Evolutionary-algorithm/PARI-GP/evolutionary-algorithm.parigp @@ -4,43 +4,43 @@ dist(u,v)=sum(i=1,min(#u,#v),u[i]!=v[i])+abs(#u-#v); letter()=my(r=random(27)); if(r==26, " ", Strchr(r+65)); insert(v,x=letter())= { - my(r=random(#v+1)); - if(r==0, return(concat([x],v))); - if(r==#v, return(concat(v,[x]))); - concat(concat(v[1..r],[x]),v[r+1..#v]); + my(r=random(#v+1)); + if(r==0, return(concat([x],v))); + if(r==#v, return(concat(v,[x]))); + concat(concat(v[1..r],[x]),v[r+1..#v]); } delete(v)= { - if(#v<2, return([])); - my(r=random(#v)+1); - if(r==1, return(v[2..#v])); - if(r==#v, return(v[1..#v-1])); - concat(v[1..r-1],v[r+1..#v]); + if(#v<2, return([])); + my(r=random(#v)+1); + if(r==1, return(v[2..#v])); + if(r==#v, return(v[1..#v-1])); + concat(v[1..r-1],v[r+1..#v]); } mutate(s,rateM,rateI,rateD)= { - my(v=Vec(s)); - if(random(1.)best, best=t; parent=v[i]) - ); - ct++ - ); - print(parent" "fitness(parent)); - ct; + my(parent=concat(vector(#target,i,letter())),ct=0); + while(parent != target, + print(parent" "fitness(parent)); + my(v=vector(C,i,mutate(parent,rate,0,0)),best,t); + best=fitness(parent=v[1]); + for(i=2,C, + t=fitness(v[i]); + if(t>best, best=t; parent=v[i]) + ); + ct++ + ); + print(parent" "fitness(parent)); + ct; } evolve(35,.05) diff --git a/Task/Evolutionary-algorithm/Pascal/evolutionary-algorithm.pas b/Task/Evolutionary-algorithm/Pascal/evolutionary-algorithm.pas index 821c4a0a6d..97f638a700 100644 --- a/Task/Evolutionary-algorithm/Pascal/evolutionary-algorithm.pas +++ b/Task/Evolutionary-algorithm/Pascal/evolutionary-algorithm.pas @@ -1,108 +1,108 @@ PROGRAM EVOLUTION (OUTPUT); CONST - TARGET = 'METHINKS IT IS LIKE A WEASEL'; - COPIES = 100; (* 100 children in each generation. *) - RATE = 1000; (* About one character in 1000 will be a mutation. *) + TARGET = 'METHINKS IT IS LIKE A WEASEL'; + COPIES = 100; (* 100 children in each generation. *) + RATE = 1000; (* About one character in 1000 will be a mutation. *) TYPE - STRLIST = ARRAY [1..COPIES] OF STRING; + STRLIST = ARRAY [1..COPIES] OF STRING; FUNCTION RANDCHAR : CHAR; (* Generate a random letter or space. *) VAR RANDNUM : INTEGER; BEGIN - RANDNUM := RANDOM(27); - IF RANDNUM = 26 THEN - RANDCHAR := ' ' - ELSE - RANDCHAR := CHR(RANDNUM + ORD('A')) + RANDNUM := RANDOM(27); + IF RANDNUM = 26 THEN + RANDCHAR := ' ' + ELSE + RANDCHAR := CHR(RANDNUM + ORD('A')) END; FUNCTION RANDSTR (SIZE : INTEGER) : STRING; (* Generate a random string. *) VAR - N : INTEGER; - S : STRING; + N : INTEGER; + S : STRING; BEGIN - S := ''; - FOR N := 1 TO SIZE DO - INSERT(RANDCHAR, S, 1); - RANDSTR := S + S := ''; + FOR N := 1 TO SIZE DO + INSERT(RANDCHAR, S, 1); + RANDSTR := S END; FUNCTION FITNESS (CANDIDATE, GOAL : STRING) : INTEGER; (* Count the number of correct letters in the correct places *) VAR N, MATCHES : INTEGER; BEGIN - MATCHES := 0; - FOR N := 1 TO LENGTH(GOAL) DO - IF CANDIDATE[N] = GOAL[N] THEN - MATCHES := MATCHES + 1; - FITNESS := MATCHES + MATCHES := 0; + FOR N := 1 TO LENGTH(GOAL) DO + IF CANDIDATE[N] = GOAL[N] THEN + MATCHES := MATCHES + 1; + FITNESS := MATCHES END; FUNCTION MUTATE (RATE : INTEGER; S : STRING) : STRING; (* Randomly alter a string. Characters change with probability 1/RATE. *) VAR - N : INTEGER; - CHANGE : BOOLEAN; + N : INTEGER; + CHANGE : BOOLEAN; BEGIN - FOR N := 1 TO LENGTH(TARGET) DO - BEGIN - CHANGE := RANDOM(RATE) = 0; - IF CHANGE THEN - S[N] := RANDCHAR - END; - MUTATE := S + FOR N := 1 TO LENGTH(TARGET) DO + BEGIN + CHANGE := RANDOM(RATE) = 0; + IF CHANGE THEN + S[N] := RANDCHAR + END; + MUTATE := S END; PROCEDURE REPRODUCE (RATE : INTEGER; PARENT : STRING; VAR CHILDREN : STRLIST); (* Generate children with random mutations. *) VAR N : INTEGER; BEGIN - FOR N := 1 TO COPIES DO - CHILDREN[N] := MUTATE(RATE, PARENT) + FOR N := 1 TO COPIES DO + CHILDREN[N] := MUTATE(RATE, PARENT) END; FUNCTION FITTEST(CHILDREN : STRLIST; GOAL : STRING) : STRING; (* Measure the fitness of each child and return the fittest. *) (* If multiple children equally match the target, then return the first. *) VAR - MATCHES, MOST_MATCHES, BEST_INDEX, N : INTEGER; + MATCHES, MOST_MATCHES, BEST_INDEX, N : INTEGER; BEGIN - MOST_MATCHES := 0; - BEST_INDEX := 1; - FOR N := 1 TO COPIES DO - BEGIN - MATCHES := FITNESS(CHILDREN[N], GOAL); - IF MATCHES > MOST_MATCHES THEN - BEGIN - MOST_MATCHES := MATCHES; - BEST_INDEX := N - END - END; - FITTEST := CHILDREN[BEST_INDEX] + MOST_MATCHES := 0; + BEST_INDEX := 1; + FOR N := 1 TO COPIES DO + BEGIN + MATCHES := FITNESS(CHILDREN[N], GOAL); + IF MATCHES > MOST_MATCHES THEN + BEGIN + MOST_MATCHES := MATCHES; + BEST_INDEX := N + END + END; + FITTEST := CHILDREN[BEST_INDEX] END; VAR - PARENT, BEST_CHILD : STRING; - CHILDREN : STRLIST; - GENERATIONS : INTEGER; + PARENT, BEST_CHILD : STRING; + CHILDREN : STRLIST; + GENERATIONS : INTEGER; BEGIN - RANDOMIZE; - GENERATIONS := 0; - PARENT := RANDSTR(LENGTH(TARGET)); - WHILE NOT (PARENT = TARGET) DO - BEGIN - IF (GENERATIONS MOD 100) = 0 THEN WRITELN(PARENT); - GENERATIONS := GENERATIONS + 1; - REPRODUCE(RATE, PARENT, CHILDREN); - BEST_CHILD := FITTEST(CHILDREN, TARGET); - IF FITNESS(PARENT, TARGET) < FITNESS(BEST_CHILD, TARGET) THEN - PARENT := BEST_CHILD - END; - WRITE('The string was matched in '); - WRITELN(GENERATIONS, ' generations.') + RANDOMIZE; + GENERATIONS := 0; + PARENT := RANDSTR(LENGTH(TARGET)); + WHILE NOT (PARENT = TARGET) DO + BEGIN + IF (GENERATIONS MOD 100) = 0 THEN WRITELN(PARENT); + GENERATIONS := GENERATIONS + 1; + REPRODUCE(RATE, PARENT, CHILDREN); + BEST_CHILD := FITTEST(CHILDREN, TARGET); + IF FITNESS(PARENT, TARGET) < FITNESS(BEST_CHILD, TARGET) THEN + PARENT := BEST_CHILD + END; + WRITE('The string was matched in '); + WRITELN(GENERATIONS, ' generations.') END. diff --git a/Task/Evolutionary-algorithm/PascalABC.NET/evolutionary-algorithm.pas b/Task/Evolutionary-algorithm/PascalABC.NET/evolutionary-algorithm.pas deleted file mode 100644 index 9b763a6711..0000000000 --- a/Task/Evolutionary-algorithm/PascalABC.NET/evolutionary-algorithm.pas +++ /dev/null @@ -1,24 +0,0 @@ -const - Target = 'METHINKS IT IS LIKE A WEASEL'; - Alphabet = ' ABCDEFGHIJLKLMNOPQRSTUVWXYZ'; - P = 0.05; - C = 100; - -function negFitness(trial: string) := - trial.Zip(Target, (x, y) -> (if x = y then 0 else 1)).Sum; - -function mutate(parent: string) := - parent.Aggregate('', (mut, ch) -> mut + (if Random(1.0) < P then Alphabet.RandomElement else ch)); - -begin - var parent := (1..Target.Length).Aggregate('', (p, x)-> p + Alphabet.RandomElement); - var i := 0; - while parent <> Target do - begin - var copies := ArrGen(C, x -> mutate(parent)); - parent := copies.Aggregate((p, x) -> (if negFitness(x) < negFitness(p) then x else p)); - if i mod 10 = 0 then Println(i, ' ', parent); - i += 1; - end; - Println(i, ' ', parent) -end. diff --git a/Task/Evolutionary-algorithm/Pony/evolutionary-algorithm-1.pony b/Task/Evolutionary-algorithm/Pony/evolutionary-algorithm-1.pony index 5a092513f6..0c7a28f78e 100644 --- a/Task/Evolutionary-algorithm/Pony/evolutionary-algorithm-1.pony +++ b/Task/Evolutionary-algorithm/Pony/evolutionary-algorithm-1.pony @@ -2,10 +2,10 @@ use "random" actor Main let _env: Env - let _rand: MT = MT // Mersenne Twister + let _rand: MT = MT // Mersenne Twister let _target: String = "METHINKS IT IS LIKE A WEASEL" let _possibilities: String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " - let _c: U16 = 100 // number of spawn per generation + let _c: U16 = 100 // number of spawn per generation let _min_mutate_rate: F64 = 0.09 let _perfect_fitness: USize = _target.size() var _parent: String = "" diff --git a/Task/Evolutionary-algorithm/Prolog/evolutionary-algorithm.pro b/Task/Evolutionary-algorithm/Prolog/evolutionary-algorithm.pro index d3f325a38f..2733079aa6 100644 --- a/Task/Evolutionary-algorithm/Prolog/evolutionary-algorithm.pro +++ b/Task/Evolutionary-algorithm/Prolog/evolutionary-algorithm.pro @@ -1,7 +1,7 @@ target("METHINKS IT IS LIKE A WEASEL"). rndAlpha(64, 32). % Generate a single random character -rndAlpha(P, P). % 32 is a space, and 65->90 are upper case +rndAlpha(P, P). % 32 is a space, and 65->90 are upper case rndAlpha(Ch) :- random(N), P is truncate(64+(N*27)), !, rndAlpha(P, Ch). rndTxt(0, []). % Generate some random text (fixed length) @@ -17,16 +17,16 @@ mutate(P, [H|Txt], [H|Mut]) :- random(R), R < P, !, mutate(P, Txt, Mut). mutate(P, [_|Txt], [M|Mut]) :- rndAlpha(M), !, mutate(P, Txt, Mut). weasel(Tries, _, _, mutation(0, Result)) :- % No differences=success - format('~w~4|:~w~3| - ~s\n', [Tries, 0, Result]). -weasel(Tries, Chance, Target, mutation(S, Value)) :- % output progress - format('~w~4|:~w~3| - ~s\n', [Tries, S, Value]), !, % and call again - weasel(Tries, Chance, Target, Value). + format('~w~4|:~w~3| - ~s\n', [Tries, 0, Result]). +weasel(Tries, Chance, Target, mutation(S, Value)) :- % output progress + format('~w~4|:~w~3| - ~s\n', [Tries, S, Value]), !, % and call again + weasel(Tries, Chance, Target, Value). weasel(Tries, Chance, Target, Start) :- - findall(mutation(S,M), % Generate 30 mutations, select the best. - (between(1, 30, _), mutate(Chance, Start, M), score(M,S,Target)), - Mutations), % List of 30 mutations and their scores - sort(Mutations, [Best|_]), succ(Tries, N), - !, weasel(N, Chance, Target, Best). + findall(mutation(S,M), % Generate 30 mutations, select the best. + (between(1, 30, _), mutate(Chance, Start, M), score(M,S,Target)), + Mutations), % List of 30 mutations and their scores + sort(Mutations, [Best|_]), succ(Tries, N), + !, weasel(N, Chance, Target, Best). weasel :- % Chance->probability for a mutation, T=Target, Start=initial text - target(T), length(T, Len), rndTxt(Len, Start), Chance is 1 - (1/(Len+1)), - !, weasel(0, Chance, T, Start). + target(T), length(T, Len), rndTxt(Len, Start), Chance is 1 - (1/(Len+1)), + !, weasel(0, Chance, T, Start). diff --git a/Task/Evolutionary-algorithm/Raku/evolutionary-algorithm.raku b/Task/Evolutionary-algorithm/Raku/evolutionary-algorithm.raku index 09c87c8067..56588bf0ee 100644 --- a/Task/Evolutionary-algorithm/Raku/evolutionary-algorithm.raku +++ b/Task/Evolutionary-algorithm/Raku/evolutionary-algorithm.raku @@ -10,4 +10,3 @@ sub fitness(Str $string) { [+] $string.comb Zeq target.comb } printf "\r%6d: '%s'", $++, $_ for @alphabet.roll(target.chars).join, { max :by(&fitness), mutate($_, .001) xx C } ... target; -print "\n"; diff --git a/Task/Evolutionary-algorithm/Rebol/evolutionary-algorithm.rebol b/Task/Evolutionary-algorithm/Rebol/evolutionary-algorithm.rebol deleted file mode 100644 index a2ce3d5ab3..0000000000 --- a/Task/Evolutionary-algorithm/Rebol/evolutionary-algorithm.rebol +++ /dev/null @@ -1,65 +0,0 @@ -Rebol [ - title: "Rosetta code: Evolutionary algorithm" - file: %Evolutionary_algorithm.r3 - url: https://rosettacode.org/wiki/Evolutionary_algorithm - note: "Based on Red language solution" -] - -evolve: function/with [ - target [string!] "target phrase to evolve toward" - childs [integer!] "number of offspring per generation" - rate [number!] "per-character mutation probability (0.0..1.0)" -][ - ;; create initial random parent of same length as target - parent: clear "" - repeat i length? target [ - append parent random/only alphabet - ] - ;; main loop: generate children, select fittest, repeat until exact match - mutations: 0 - while [parent != target] [ - clear children - repeat i childs [ - append children mutate parent rate ;; produce a mutated child from parent - ] - sort/compare children :sort-fitness ;; sort children by fitness (best first) - parent: first children ;; select best child as new parent - ++ mutations - prin #"^M" ;; carriage return to overwrite line - prin parent - ] - prin #"^M" ;; move to line start - print parent ;; final perfect match - mutations -][ - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ " ;; allowed gene pool (uppercase letters + space) - children: copy [] ;; reusable buffer for a generation's children - - ;; compute closeness of 'string' to 'target' as Hamming distance (lower is better) - fitness: function [string] [ - sum: 0 - repeat i length? string [ - if string/:i <> target/:i [ ++ sum ] ;; count mismatched positions - ] - sum - ] - - ;; return a mutated copy of 'string'; each position mutates with probability 'rate' - mutate: function [string rate] [ - result: copy string - repeat i length? result [ - if rate > random 1.0 [ - result/:i: random/only alphabet ;; replace char with random from alphabet - ] - ] - result - ] - - ;; comparison function for sorting: a < b if fitness(a) < fitness(b) - sort-fitness: function [a b] [lesser? fitness a fitness b] -] - -;; run the evolution demo -random/seed 1 -m: evolve "METHINKS IT IS LIKE A WEASEL" 20 0.05 -print ["Target found using" as-yellow m "mutations."] diff --git a/Task/Evolutionary-algorithm/Rust/evolutionary-algorithm.rs b/Task/Evolutionary-algorithm/Rust/evolutionary-algorithm.rust similarity index 100% rename from Task/Evolutionary-algorithm/Rust/evolutionary-algorithm.rs rename to Task/Evolutionary-algorithm/Rust/evolutionary-algorithm.rust diff --git a/Task/Evolutionary-algorithm/SETL/evolutionary-algorithm.setl b/Task/Evolutionary-algorithm/SETL/evolutionary-algorithm.setl deleted file mode 100644 index 5148a59ccc..0000000000 --- a/Task/Evolutionary-algorithm/SETL/evolutionary-algorithm.setl +++ /dev/null @@ -1,40 +0,0 @@ -program weasel; - setrandom(0); - - target := "METHINKS IT IS LIKE A WEASEL"; - charset := {c : c in " ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; - mutation_rate := 0.1; - generation_size := 100; - - loop init - current := +/[random charset : c in target]; - doing - print(lpad(str fitness(current, target), 3), current); - while current /= target do - current := next_generation( - current, target, mutation_rate, generation_size, charset); - end loop; - - proc fitness(candidate, target); - return #[i : i in [1..#target] | candidate(i) /= target(i)]; - end proc; - - proc mutate(candidate, mutation_rate, charset); - return +/[ - if random 1.0 < mutation_rate - then random charset - else c - end - : c in candidate - ]; - end proc; - - proc next_generation( - parent, target, mutation_rate, generation_size, charset); - children := { - [fitness(c:=mutate(parent, mutation_rate, charset), target), c] - : i in [1..generation_size] - }; - return random children{min/domain children}; - end proc; -end program; diff --git a/Task/Evolutionary-algorithm/Scheme/evolutionary-algorithm.scm b/Task/Evolutionary-algorithm/Scheme/evolutionary-algorithm.ss similarity index 100% rename from Task/Evolutionary-algorithm/Scheme/evolutionary-algorithm.scm rename to Task/Evolutionary-algorithm/Scheme/evolutionary-algorithm.ss diff --git a/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-1.sequencel b/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-1.sequencel index e1ab201b68..836c3aba77 100644 --- a/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-1.sequencel +++ b/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-1.sequencel @@ -5,19 +5,19 @@ AllowedChars := " ABCDEFGHIJKLMNOPQRSTUVWXYZ"; initializeParent(randChars(1)) := AllowedChars[randChars]; Fitness(target(1), current(1)) := - let - fit[i] := true when target[i] = current[i]; - in - size(fit); - + let + fit[i] := true when target[i] = current[i]; + in + size(fit); + Mutate(letter(0), rate(0), randRate(0), randChar(0)) := - letter when randRate > rate - else - AllowedChars[randChar]; + letter when randRate > rate + else + AllowedChars[randChar]; evolve(target(1), parent(1), C(0), P(0), rateRands(2), charRands(2)) := - let - mutations[i] := Mutate(parent, P, rateRands[i], charRands[i]) foreach i within 1 ... C; - fitnesses := Fitness(target, mutations); - in - mutations[firstIndexOf(fitnesses, vectorMax(fitnesses))]; + let + mutations[i] := Mutate(parent, P, rateRands[i], charRands[i]) foreach i within 1 ... C; + fitnesses := Fitness(target, mutations); + in + mutations[firstIndexOf(fitnesses, vectorMax(fitnesses))]; diff --git a/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-2.sequencel b/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-2.sequencel index 75782dae66..3dc141f523 100644 --- a/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-2.sequencel +++ b/Task/Evolutionary-algorithm/SequenceL/evolutionary-algorithm-2.sequencel @@ -6,45 +6,45 @@ using namespace std; int main(int argc, char** argv) { - int threads = 0; + int threads = 0; - char* targetString = "METHINKS IT IS LIKE A WEASEL"; - if(argc > 1) targetString = argv[1]; - int C = 100; - if(argc > 2) C = atoi(argv[2]); - SL_FLOAT P = 0.05; - if(argc > 3) P = atof(argv[3]); - int seed = time(NULL); - if(argc > 4) seed = atoi(argv[4]); + char* targetString = "METHINKS IT IS LIKE A WEASEL"; + if(argc > 1) targetString = argv[1]; + int C = 100; + if(argc > 2) C = atoi(argv[2]); + SL_FLOAT P = 0.05; + if(argc > 3) P = atof(argv[3]); + int seed = time(NULL); + if(argc > 4) seed = atoi(argv[4]); - int targetDims[] = {strlen(targetString), 0}; - Sequence target((void*)targetString, targetDims); + int targetDims[] = {strlen(targetString), 0}; + Sequence target((void*)targetString, targetDims); - sl_init(threads); + sl_init(threads); - Sequence parent; - Sequence newParent; - Sequence parentRands; - sl_create(seed++, 1, 27, target.size(), threads, parentRands); - sl_initializeParent(parentRands, threads, parent); + Sequence parent; + Sequence newParent; + Sequence parentRands; + sl_create(seed++, 1, 27, target.size(), threads, parentRands); + sl_initializeParent(parentRands, threads, parent); - Sequence< Sequence > charRands; - Sequence< Sequence > rateRands; + Sequence< Sequence > charRands; + Sequence< Sequence > rateRands; - cout << "Start:\t" << parent << endl; - for(int i = 1; !(parent == target); i++) - { - sl_create(seed++, 1, 27, C, target.size(), threads, charRands); - sl_create(seed++, 0.0, 1.0, C, target.size(), threads, rateRands); + cout << "Start:\t" << parent << endl; + for(int i = 1; !(parent == target); i++) + { + sl_create(seed++, 1, 27, C, target.size(), threads, charRands); + sl_create(seed++, 0.0, 1.0, C, target.size(), threads, rateRands); - sl_evolve(target, parent, C, P, rateRands, charRands, threads, newParent); - parent = newParent; + sl_evolve(target, parent, C, P, rateRands, charRands, threads, newParent); + parent = newParent; - cout << "#" << i << ":\t" << parent << endl; - } - cout << "End:\t" << parent << endl; + cout << "#" << i << ":\t" << parent << endl; + } + cout << "End:\t" << parent << endl; - sl_done(); + sl_done(); - return 0; + return 0; } diff --git a/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl index 98e4050b03..30d954617d 100644 --- a/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl +++ b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl @@ -21,7 +21,7 @@ proc fitness s { global target set count 0 foreach c1 $s c2 $target { - if {$c1 eq $c2} {incr count} + if {$c1 eq $c2} {incr count} } return [expr {$count/double([llength $target])}] } @@ -32,14 +32,14 @@ proc mutateRate {parent} { proc mutate {rate} { global charset parent foreach c $parent { - lappend result [expr {rand() <= $rate ? randchar($charset) : $c}] + lappend result [expr {rand() <= $rate ? randchar($charset) : $c}] } return $result } proc que {} { global iterations parent puts [format "#%-4i, fitness %4.1f%%, '%s'" \ - $iterations [expr {[fitness $parent]*100}] [join $parent {}]] + $iterations [expr {[fitness $parent]*100}] [join $parent {}]] } while {$parent ne $target} { @@ -47,7 +47,7 @@ while {$parent ne $target} { if {!([incr iterations] % 100)} que set copies [list [list $parent [fitness $parent]]] for {set i 0} {$i < $C} {incr i} { - lappend copies [list [set copy [mutate $rate]] [fitness $copy]] + lappend copies [list [set copy [mutate $rate]] [fitness $copy]] } set parent [lindex [lsort -real -decreasing -index 1 $copies] 0 0] } diff --git a/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl index c6f4858a44..0a794b47c6 100644 --- a/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl +++ b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl @@ -13,7 +13,7 @@ set C 100 proc fitnessByEquality {target s} { set count 0 foreach c1 $s c2 $target { - if {$c1 eq $c2} {incr count} + if {$c1 eq $c2} {incr count} } return [expr {$count / double([llength $target])}] } @@ -29,7 +29,7 @@ proc mutationRate {individual} { # Mutate a string at a particular rate (per character) proc mutate {parent rate} { foreach c $parent { - lappend child [expr {rand() <= $rate ? randchar() : $c}] + lappend child [expr {rand() <= $rate ? randchar() : $c}] } return $child } @@ -37,7 +37,7 @@ proc mutate {parent rate} { # Pretty printer proc prettyPrint {iterations parent} { puts [format "#%-4i, fitness %5.1f%%, '%s'" $iterations \ - [expr {[fitness $parent]*100}] [join $parent {}]] + [expr {[fitness $parent]*100}] [join $parent {}]] } # The evolutionary algorithm itself @@ -48,18 +48,18 @@ proc evolve {initialString} { set parent [split $initialString {}] for {set iterations 0} {[fitness $parent] < 1} {incr iterations} { - set rate [mutationRate $parent] + set rate [mutationRate $parent] - if {$iterations % 100 == 0} { - prettyPrint $iterations $parent - } + if {$iterations % 100 == 0} { + prettyPrint $iterations $parent + } - set copies [list [list $parent [fitness $parent]]] - for {set i 0} {$i < $C} {incr i} { - lappend copies [list \ - [set copy [mutate $parent $rate]] [fitness $copy]] - } - set parent [lindex [lsort -real -decreasing -index 1 $copies] 0 0] + set copies [list [list $parent [fitness $parent]]] + for {set i 0} {$i < $C} {incr i} { + lappend copies [list \ + [set copy [mutate $parent $rate]] [fitness $copy]] + } + set parent [lindex [lsort -real -decreasing -index 1 $copies] 0 0] } puts "" prettyPrint $iterations $parent diff --git a/Task/Evolutionary-algorithm/VBScript/evolutionary-algorithm.vbs b/Task/Evolutionary-algorithm/VBScript/evolutionary-algorithm.vb similarity index 100% rename from Task/Evolutionary-algorithm/VBScript/evolutionary-algorithm.vbs rename to Task/Evolutionary-algorithm/VBScript/evolutionary-algorithm.vb diff --git a/Task/Evolutionary-algorithm/Zig/evolutionary-algorithm.zig b/Task/Evolutionary-algorithm/Zig/evolutionary-algorithm.zig deleted file mode 100644 index 46c9e63f24..0000000000 --- a/Task/Evolutionary-algorithm/Zig/evolutionary-algorithm.zig +++ /dev/null @@ -1,114 +0,0 @@ -const std = @import("std"); -const math = std.math; -const print = std.debug.print; - -pub fn main() !void { - const target = "METHINKS IT IS LIKE A WEASEL"; - const copies: usize = 100; - const mutation_rate: u32 = 20; // 1/20 = 0.05 = 5% - - var prng = std.Random.DefaultPrng.init(@as(u64, @intCast(std.time.milliTimestamp()))); - const rng = prng.random(); - - // Generate first sentence, mutating each character - const start = try mutate(rng, target, 1, std.heap.page_allocator); // 1/1 = 1 = 100% - - print("{s}\n", .{target}); - print("{s}\n", .{start}); - - _ = try evolve(rng, target, start, copies, mutation_rate, std.heap.page_allocator); -} - -/// Evolution algorithm -/// -/// Evolves `parent` to match `target`. Returns the number of evolutions performed. -fn evolve( - rng: std.Random, - target: []const u8, - parent: []const u8, - copies: usize, - mutation_rate: u32, - allocator: std.mem.Allocator, -) !usize { - var counter: usize = 0; - var parent_fitness: usize = target.len + 1; - var current_parent = try allocator.dupe(u8, parent); - defer allocator.free(current_parent); - - while (true) { - counter += 1; - - var best_fitness: usize = std.math.maxInt(usize); - const best_sentence = try allocator.alloc(u8, target.len); - - for (0..copies) |_| { - // Copy and mutate a new sentence - const sentence = try mutate(rng, current_parent, mutation_rate, allocator); - defer allocator.free(sentence); - - // Find the fitness of the new mutation - const current_fitness = fitness(target, sentence); - - if (current_fitness < best_fitness) { - best_fitness = current_fitness; - @memcpy( best_sentence, sentence); - } - } - - // If the best mutation of this generation is better than `parent` then "the fittest - // survives" and the next parent becomes the best of this generation. - if (best_fitness < parent_fitness) { - allocator.free(current_parent); - current_parent = best_sentence; - parent_fitness = best_fitness; - print("{s} : generation {} with fitness {}\n", .{ current_parent, counter, best_fitness }); - - if (best_fitness == 0) { - return counter; - } - } else { - allocator.free(best_sentence); - } - } -} - -/// Computes the fitness of a sentence against a target string, returning the number of -/// incorrect characters. -fn fitness(target: []const u8, sentence: []const u8) usize { - var count: usize = 0; - for (sentence, 0..) |c, i| { - if (c != target[i]) { - count += 1; - } - } - return count; -} - -/// Mutation algorithm. -/// -/// It mutates each character of a string, according to a `mutation_rate`. -fn mutate( - rng: std.Random, - sentence: []const u8, - mutation_rate: u32, - allocator: std.mem.Allocator, -) ![]u8 { - var result = try allocator.alloc(u8, sentence.len); - - for (sentence, 0..) |c, i| { - if (rng.int(u32) % mutation_rate == 0) { - result[i] = randomChar(rng); - } else { - result[i] = c; - } - } - - return result; -} - -/// Generates a random letter or space. -fn randomChar(rng: std.Random) u8 { - // Returns a value in the range [A, Z] + an extra slot for the space character. - const c = rng.intRangeAtMost(u8, 'A', 'Z' + 1); - return if (c == 'Z' + 1) ' ' else c; -} diff --git a/Task/Evolutionary-algorithm/Zkl/evolutionary-algorithm.zkl b/Task/Evolutionary-algorithm/Zkl/evolutionary-algorithm.zkl index 0b9d38526e..67c2e69115 100644 --- a/Task/Evolutionary-algorithm/Zkl/evolutionary-algorithm.zkl +++ b/Task/Evolutionary-algorithm/Zkl/evolutionary-algorithm.zkl @@ -9,6 +9,6 @@ fcn mutate(s){ s.apply(fcn(c){ if((0.0).random(1) < P) rnd() else c }) } parent := target.len().pump(String,rnd); // random string of "A..Z " gen:=0; do{ // mutate C copies of parent and pick the fittest parent = (0).pump(C,List,T(Void,parent),mutate) - .reduce(fcn(a,b){ if(fitness(a) - -Main - e=0, se="" - Try - Gosub 'Foo' - Catch (e) - Get msg exception, and Move to 'se' - Printnl ("+-MAIN-FOO CALL Error: ",e, " : ", se ) - Finish -End - -Subrutines - -Define ' Foo ' - Gosub ' Bar ' -Return - -Define ' Bar ' - Set '0', Gosub ' Biz ' - Set '1', Gosub ' Biz ' -Return - -Define ' Biz, x ' - a=0, b=0 - If ( x ) - Let ' b:=Sqrt(-1) ' - Nan( a ) do{ Raise (1000,"\n+----Func BIZ: NaN!") } - Else - #( a=log(-1) + log(-1) ) - Nan( a ) do{ Raise (1001,"\n+----Func BIZ: NaN!") } - End If - - Printnl ' "a = ", a, " b = ", b ' - -Return diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Amazing-Hopper/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hopper b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Amazing-Hopper/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hopper deleted file mode 100644 index 51375f9be7..0000000000 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Amazing-Hopper/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hopper +++ /dev/null @@ -1,53 +0,0 @@ -#include - -Main - e=0, se="" - Try - Gosub 'Foo' - Catch (e) - Get msg exception, and Move to 'se' - Printnl ("+-MAIN Error: ",e, " : ", se ) - Finish -End - -Subrutines - -/* -This "Try" is not considered nested, then, it is necessary -to capture the error and raise the error -*/ -Define ' Foo ' - Try - Gosub ' Bar ' - Catch (e) - Get msg exception, and Move to 'se' - Free try // absolutly nessesary in this chase! - Raise (e, Cat ("\n+--FUNC FOO: ", se) ) - Finish -Return - -Define ' Bar ' - Try - Set '0', Gosub ' Biz ' - Set '1', Gosub ' Biz ' - Catch(e) - Get msg exception, and Move to 'se' - Free try // absolutly nessesary in this chase! - Raise (e, Cat ("\n+---FUNC BAR: ", se) ) - Finish - -Return - -Define ' Biz, x ' - a=0, b=0 - If ( x ) - Let ' b:=Sqrt(-1) ' - Nan( a ) do{ Raise (1000,"\n+----Func BIZ: NaN!") } - Else - #( a=log(-1) + log(-1) ) - Nan( a ) do{ Raise (1001,"\n+----Func BIZ: NaN!") } - End If - - Printnl ' "a = ", a, " b = ", b ' - -Return diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Crystal/exceptions-catch-an-exception-thrown-in-a-nested-call.cr b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Crystal/exceptions-catch-an-exception-thrown-in-a-nested-call.crystal similarity index 100% rename from Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Crystal/exceptions-catch-an-exception-thrown-in-a-nested-call.cr rename to Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Crystal/exceptions-catch-an-exception-thrown-in-a-nested-call.crystal diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.pas b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.delphi similarity index 100% rename from Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.pas rename to Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.delphi diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elena/exceptions-catch-an-exception-thrown-in-a-nested-call.elena b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elena/exceptions-catch-an-exception-thrown-in-a-nested-call.elena index c9fc7fe9ff..4dab55fb0c 100644 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elena/exceptions-catch-an-exception-thrown-in-a-nested-call.elena +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elena/exceptions-catch-an-exception-thrown-in-a-nested-call.elena @@ -2,52 +2,52 @@ import extensions; class U0 : Exception { - constructor new() - <= super new("U0 exception"); + constructor new() + <= new(); } class U1 : Exception { - constructor new() - <= super new("U1 exception"); + constructor new() + <= new(); } singleton Exceptions { - static int i; + static int i; - bar() - <= baz(); + bar() + <= baz(); - baz() - { - if (i == 0) - { - U0.raise() - } - else - { - U1.raise() - } - } + baz() + { + if (i == 0) + { + U0.raise() + } + else + { + U1.raise() + } + } - foo() - { - for(i := 0; i < 2; i := i + 1) - { - try - { - self.bar() - } - catch(U0 e) - { - Console.printLine("U0 Caught") - } - } + foo() + { + for(i := 0, i < 2, i += 1) + { + try + { + self.bar() + } + catch(U0 e) + { + console.printLine("U0 Caught") + } + } } } -public Program() +public program() { Exceptions.foo() } diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elixir/exceptions-catch-an-exception-thrown-in-a-nested-call.ex b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elixir/exceptions-catch-an-exception-thrown-in-a-nested-call.elixir similarity index 100% rename from Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elixir/exceptions-catch-an-exception-thrown-in-a-nested-call.ex rename to Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Elixir/exceptions-catch-an-exception-thrown-in-a-nested-call.elixir diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/FutureBasic/exceptions-catch-an-exception-thrown-in-a-nested-call.basic b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/FutureBasic/exceptions-catch-an-exception-thrown-in-a-nested-call.basic deleted file mode 100644 index a521798899..0000000000 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/FutureBasic/exceptions-catch-an-exception-thrown-in-a-nested-call.basic +++ /dev/null @@ -1,33 +0,0 @@ -include "NSLog.incl" - -void local fn Baz( i as int ) - if ( i == 0 ) - throw fn ExceptionWithName( @"U0", @"U0", NULL ) - else - throw fn ExceptionWithName( @"U1", @"U1", NULL ) - end if -end fn - -void local fn Bar( i as int ) - fn Baz(i) -end fn - -void local fn Foo - ExceptionRef e - - for int i = 0 to 1 - try - fn Bar(i) - end try - - catch ( e ) - if ( fn StringIsEqual( fn ExceptionName(e), @"U0" ) ) - NSLog(@"Function Foo caught exception %@",e) - end if - end catch - next -end fn - -fn Foo - -HandleEvents diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Julia/exceptions-catch-an-exception-thrown-in-a-nested-call.jl b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Julia/exceptions-catch-an-exception-thrown-in-a-nested-call.julia similarity index 100% rename from Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Julia/exceptions-catch-an-exception-thrown-in-a-nested-call.jl rename to Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Julia/exceptions-catch-an-exception-thrown-in-a-nested-call.julia diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Kotlin/exceptions-catch-an-exception-thrown-in-a-nested-call.kts b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Kotlin/exceptions-catch-an-exception-thrown-in-a-nested-call.kotlin similarity index 100% rename from Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Kotlin/exceptions-catch-an-exception-thrown-in-a-nested-call.kts rename to Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Kotlin/exceptions-catch-an-exception-thrown-in-a-nested-call.kotlin diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur index 3d04dbf4b1..49ffd0c354 100644 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur @@ -1,15 +1,15 @@ -val U0 = {"msg": "U0"} -val U1 = {"msg": "U1"} +val .U0 = h{"msg": "U0"} +val .U1 = h{"msg": "U1"} -val baz = fn(i) { throw if(i==0: U0; U1) } -val bar = fn(i) { baz(i) } +val .baz = f(.i) throw if(.i==0: .U0; .U1) +val .bar = f(.i) .baz(.i) -val foo = fn*() { - for i in [0, 1] { - bar(i) +val .foo = f() { + for .i in [0, 1] { + .bar(.i) catch { - if _err'msg == U0'msg { - writeln "caught U0 in foo()" + if _err["msg"] == .U0["msg"] { + writeln "caught .U0 in .foo()" } else { throw } @@ -17,4 +17,4 @@ val foo = fn*() { } } -foo() +.foo() diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/OCaml/exceptions-catch-an-exception-thrown-in-a-nested-call.ml b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/OCaml/exceptions-catch-an-exception-thrown-in-a-nested-call.ocaml similarity index 100% rename from Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/OCaml/exceptions-catch-an-exception-thrown-in-a-nested-call.ml rename to Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/OCaml/exceptions-catch-an-exception-thrown-in-a-nested-call.ocaml diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PascalABC.NET/exceptions-catch-an-exception-thrown-in-a-nested-call.pas b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PascalABC.NET/exceptions-catch-an-exception-thrown-in-a-nested-call.pas deleted file mode 100644 index 35b369bc26..0000000000 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PascalABC.NET/exceptions-catch-an-exception-thrown-in-a-nested-call.pas +++ /dev/null @@ -1,26 +0,0 @@ -type - U0 = class (Exception) end; - U1 = class (Exception) end; - -procedure baz(i: integer); -begin - if (i = 0) then raise new U0 - else - raise new U1; -end; - -procedure bar(i: integer) := baz(i); - -procedure foo; -begin - for var i := 0 to 1 do - try - bar(i); - except - on U0 do Writeln('U0 Caught'); - end; -end; - -begin - foo; -end. diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Phix/exceptions-catch-an-exception-thrown-in-a-nested-call.phix b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Phix/exceptions-catch-an-exception-thrown-in-a-nested-call.phix index f1b728fd16..e1abb814ee 100644 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Phix/exceptions-catch-an-exception-thrown-in-a-nested-call.phix +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Phix/exceptions-catch-an-exception-thrown-in-a-nested-call.phix @@ -1,35 +1,37 @@ -constant U0 = 0, - U1 = 1 +--> + constant U0 = 0, + U1 = 1 -integer count = 0 + integer count = 0 -procedure baz() - count += 1 - if count=1 then - throw(U0,{{"any",{{"thing"},"you"}},"like"}) - else - throw(U1) - end if -end procedure + procedure baz() + count += 1 + if count=1 then + throw(U0,{{"any",{{"thing"},"you"}},"like"}) + else + throw(U1) + end if + end procedure -procedure bar() - baz() -end procedure + procedure bar() + baz() + end procedure -procedure foo() - for i=1 to 2 do - try - bar() - catch e - if e[E_CODE]=U0 then - ?e[E_USER] - else - throw(e) -- (terminates) - end if - end try - puts(1,"still running...\n") - end for - puts(1,"not still running...\n") -end procedure + procedure foo() + for i=1 to 2 do + try + bar() + catch e + if e[E_CODE]=U0 then + ?e[E_USER] + else + throw(e) -- (terminates) + end if + end try + puts(1,"still running...\n") + end for + puts(1,"not still running...\n") + end procedure -foo() + foo() + - print obj - print @"no exception" - end try - - catch ( e ) // handle exception - print : print @"" - print e - end catch - - finally // finally is always executed - print : print @"" - - // ... cleanup - - end finally -end fn - -fn DoSomething - -HandleEvents diff --git a/Task/Exceptions/FutureBasic/exceptions-2.basic b/Task/Exceptions/FutureBasic/exceptions-2.basic deleted file mode 100644 index 203d2eb6c3..0000000000 --- a/Task/Exceptions/FutureBasic/exceptions-2.basic +++ /dev/null @@ -1,15 +0,0 @@ -void local fn ThrowException - ExceptionRef e = fn ExceptionWithName( @"Oops!", @"Something went wrong", NULL ) - - try - throw e - end try - - catch (e) - print fn ExceptionName( e ), fn ExceptionReason( e ) - end catch -end fn - -fn ThrowException - -HandleEvents diff --git a/Task/Exceptions/Julia/exceptions.jl b/Task/Exceptions/Julia/exceptions.julia similarity index 100% rename from Task/Exceptions/Julia/exceptions.jl rename to Task/Exceptions/Julia/exceptions.julia diff --git a/Task/Exceptions/Kotlin/exceptions.kts b/Task/Exceptions/Kotlin/exceptions.kotlin similarity index 100% rename from Task/Exceptions/Kotlin/exceptions.kts rename to Task/Exceptions/Kotlin/exceptions.kotlin diff --git a/Task/Exceptions/Langur/exceptions-1.langur b/Task/Exceptions/Langur/exceptions-1.langur index d9858c6b98..ffcc58321f 100644 --- a/Task/Exceptions/Langur/exceptions-1.langur +++ b/Task/Exceptions/Langur/exceptions-1.langur @@ -1,7 +1,8 @@ +# do something throw "not a math exception" -catch[e] { - if e'cat == "math" { +catch .e { + if .e["cat"] == "math" { # change result... } else { # rethrow the exception @@ -9,4 +10,5 @@ catch[e] { } } else { # no exception + ... } diff --git a/Task/Exceptions/Langur/exceptions-2.langur b/Task/Exceptions/Langur/exceptions-2.langur index a66e180efb..d8d1f0f6bd 100644 --- a/Task/Exceptions/Langur/exceptions-2.langur +++ b/Task/Exceptions/Langur/exceptions-2.langur @@ -1,11 +1,10 @@ 100 / 0 catch { - if _err'cat == "math" { + if _err["cat"] == "math" { # change result 123 } else { - # rethrow the exception throw } } diff --git a/Task/Exceptions/Langur/exceptions-3.langur b/Task/Exceptions/Langur/exceptions-3.langur index 6a5d424c46..c8a06fa37a 100644 --- a/Task/Exceptions/Langur/exceptions-3.langur +++ b/Task/Exceptions/Langur/exceptions-3.langur @@ -1,3 +1,3 @@ -val safediv = fn(x number, y number) { x / y ; catch : 0 } -safediv(7, 7) # 1 -safediv(7, 0) # 0 +val .safediv = f { .x / .y ; catch { 0 } } +.safediv(7, 7) # 1 +.safediv(7, 0) # 0 diff --git a/Task/Exceptions/Lua/exceptions-2.lua b/Task/Exceptions/Lua/exceptions-2.lua index 064945f28b..9590ae5df0 100644 --- a/Task/Exceptions/Lua/exceptions-2.lua +++ b/Task/Exceptions/Lua/exceptions-2.lua @@ -6,8 +6,6 @@ end -- 'status' is false if 'throw_error' threw an error -- otherwise, when everything went well, it will be true. --- 'errmsg' contains the error message, plus filename --- and line number of where the error occurred - -local status, errmsg = pcall(throw_error) +-- 'errmsg' contains the error message, plus filename and line number of where the error occured +status, errmsg = pcall(throw_error) print("errmsg = ", errmsg) diff --git a/Task/Exceptions/Lua/exceptions-3.lua b/Task/Exceptions/Lua/exceptions-3.lua index ed58b6092d..b2db587ba0 100644 --- a/Task/Exceptions/Lua/exceptions-3.lua +++ b/Task/Exceptions/Lua/exceptions-3.lua @@ -1,10 +1,8 @@ -function throw_error_with_arg(arg) - error(string.format("Whoops! argument = %s", arg)) +function throw_error_with_argment(argument) + error(string.format("Whoops! argument = %s", argument)) -- won't ever appear, due to previous error() call return "hello!" end -local status, errmsg = pcall(throw_error_with_arg, "foobar 123") -if (status ~= 0) then - print("errmsg = ", errmsg) -end +status, errmsg = pcall(throw_error_with_argment, "foobar 123") +print("errmsg = ", errmsg) diff --git a/Task/Exceptions/Lua/exceptions-4.lua b/Task/Exceptions/Lua/exceptions-4.lua index fc6c18b0d0..f182968d75 100644 --- a/Task/Exceptions/Lua/exceptions-4.lua +++ b/Task/Exceptions/Lua/exceptions-4.lua @@ -1,10 +1,6 @@ -function throw_error_with_arg(arg) +function throw_error_with_argment(argument) return "hello!" end -local status, result = pcall(throw_error_with_arg, "foobar 123") -if (status ~= 0) - print("function returned ", result, ", but had errors.") -else - print("result = ", result) -end +status, errmsg = pcall(throw_error_with_argment, "foobar 123") +print("errmsg = ", errmsg) diff --git a/Task/Exceptions/OCaml/exceptions-1.ml b/Task/Exceptions/OCaml/exceptions-1.ocaml similarity index 100% rename from Task/Exceptions/OCaml/exceptions-1.ml rename to Task/Exceptions/OCaml/exceptions-1.ocaml diff --git a/Task/Exceptions/OCaml/exceptions-2.ml b/Task/Exceptions/OCaml/exceptions-2.ocaml similarity index 100% rename from Task/Exceptions/OCaml/exceptions-2.ml rename to Task/Exceptions/OCaml/exceptions-2.ocaml diff --git a/Task/Exceptions/OCaml/exceptions-3.ml b/Task/Exceptions/OCaml/exceptions-3.ocaml similarity index 100% rename from Task/Exceptions/OCaml/exceptions-3.ml rename to Task/Exceptions/OCaml/exceptions-3.ocaml diff --git a/Task/Exceptions/PascalABC.NET/exceptions-1.pas b/Task/Exceptions/PascalABC.NET/exceptions-1.pas deleted file mode 100644 index 3234ceef1c..0000000000 --- a/Task/Exceptions/PascalABC.NET/exceptions-1.pas +++ /dev/null @@ -1 +0,0 @@ -type MyException = class(Exception) end; diff --git a/Task/Exceptions/PascalABC.NET/exceptions-2.pas b/Task/Exceptions/PascalABC.NET/exceptions-2.pas deleted file mode 100644 index d48f94c6ed..0000000000 --- a/Task/Exceptions/PascalABC.NET/exceptions-2.pas +++ /dev/null @@ -1 +0,0 @@ -raise new MyException; diff --git a/Task/Exceptions/PascalABC.NET/exceptions-3.pas b/Task/Exceptions/PascalABC.NET/exceptions-3.pas deleted file mode 100644 index 15454868bd..0000000000 --- a/Task/Exceptions/PascalABC.NET/exceptions-3.pas +++ /dev/null @@ -1,6 +0,0 @@ -try - ... -except - on e: MyException do - statement -end; diff --git a/Task/Exceptions/Pluto/exceptions.pluto b/Task/Exceptions/Pluto/exceptions.pluto deleted file mode 100644 index 654a1a1a78..0000000000 --- a/Task/Exceptions/Pluto/exceptions.pluto +++ /dev/null @@ -1,22 +0,0 @@ -local function get_day_no(day) - -- Throws an error if day is invalid. - return switch day:lower() do - case "monday" -> 1 - case "tuesday" -> 2 - case "wednesday" -> 3 - case "thursday" -> 4 - case "friday" -> 5 - case "saturday" -> 6 - case "sunday" -> 7 - default -> error($"'{day}' is not a valid day in English.") - end -end - -for {"thursday", "jeudi"} as day do - local ok, res = pcall(get_day_no, day) - if ok then - print($"'{day}' is day number {res}") - else - print(res) - end -end diff --git a/Task/Exceptions/PowerShell/exceptions-1.ps1 b/Task/Exceptions/PowerShell/exceptions-1.psh similarity index 100% rename from Task/Exceptions/PowerShell/exceptions-1.ps1 rename to Task/Exceptions/PowerShell/exceptions-1.psh diff --git a/Task/Exceptions/PowerShell/exceptions-2.ps1 b/Task/Exceptions/PowerShell/exceptions-2.psh similarity index 100% rename from Task/Exceptions/PowerShell/exceptions-2.ps1 rename to Task/Exceptions/PowerShell/exceptions-2.psh diff --git a/Task/Exceptions/PowerShell/exceptions-3.ps1 b/Task/Exceptions/PowerShell/exceptions-3.psh similarity index 100% rename from Task/Exceptions/PowerShell/exceptions-3.ps1 rename to Task/Exceptions/PowerShell/exceptions-3.psh diff --git a/Task/Exceptions/PowerShell/exceptions-4.ps1 b/Task/Exceptions/PowerShell/exceptions-4.psh similarity index 100% rename from Task/Exceptions/PowerShell/exceptions-4.ps1 rename to Task/Exceptions/PowerShell/exceptions-4.psh diff --git a/Task/Exceptions/REXX/exceptions.rexx b/Task/Exceptions/REXX/exceptions.rexx index 50931581b8..836b4ea7b9 100644 --- a/Task/Exceptions/REXX/exceptions.rexx +++ b/Task/Exceptions/REXX/exceptions.rexx @@ -1,13 +1,13 @@ --- 25 Apr 2026 -include Setting - -say 'EXCEPTIONS' -say version -say -say 'Square root of 10 is' SqRt(10)/1 -say 'Square root of 0 is' SqRt(0) -say 'Square root of -1 is' SqRt(-1) -exit - --- Abend; Sqrt -include Math +/*REXX program demonstrates handling an exception (negative #); catching is via a label.*/ + do j=9 by -5 + say 'the square root of ' j " is " sqrt(j) + end /*j*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); h=d+6; m.=9 + numeric digits; numeric form; if x<0 then signal .sqrtNeg + parse value format(x, 2, 1, , 0) 'E0' with g 'E' _ .; g=g * .5'e'_ % 2 + do j=0 while h>9; m.j=h; h=h%2 + 1; end /*j*/ + do k=j+5 to 0 by -1; numeric digits m.k; g=(g+x/g) * .5; end /*k*/ + numeric digits d; return g/1 +.sqrtNeg: say 'illegal SQRT argument (argument is negative):' x; exit 13 diff --git a/Task/Exceptions/Rust/exceptions.rs b/Task/Exceptions/Rust/exceptions.rust similarity index 100% rename from Task/Exceptions/Rust/exceptions.rs rename to Task/Exceptions/Rust/exceptions.rust diff --git a/Task/Exceptions/Rye/exceptions.rye b/Task/Exceptions/Rye/exceptions.rye deleted file mode 100644 index 2e2e54c6b4..0000000000 --- a/Task/Exceptions/Rye/exceptions.rye +++ /dev/null @@ -1,4 +0,0 @@ -str: "abc" -num: 5 -try { 123 + str } |is-error .either { "error" } { print str } -try { 123 + num } |is-error .either { "error" } { print num } diff --git a/Task/Exceptions/Scheme/exceptions.scm b/Task/Exceptions/Scheme/exceptions.ss similarity index 100% rename from Task/Exceptions/Scheme/exceptions.scm rename to Task/Exceptions/Scheme/exceptions.ss diff --git a/Task/Exceptions/Sidef/exceptions.sidef b/Task/Exceptions/Sidef/exceptions.sidef index e4560cc5c3..1d17620d81 100644 --- a/Task/Exceptions/Sidef/exceptions.sidef +++ b/Task/Exceptions/Sidef/exceptions.sidef @@ -1,10 +1,11 @@ try { - die "I'm dead!" # throws an exception -} -catch { |msg| - say "msg: #{msg}" # msg: I'm dead! at test.sf line 2. + die "I'm dead!"; # throws an exception of type 'error' } +catch { |type, msg| + say "type: #{type}"; # type: error + say "msg: #{msg}"; # msg: I'm dead! at test.sf line 2. +}; -say "I'm alive..." -die "Now I'm dead!" # this line terminates the program -say "Or am I?" # Yes, you are! +say "I'm alive..."; +die "Now I'm dead!"; # this line terminates the program +say "Or am I?"; # Yes, you are! diff --git a/Task/Exceptions/Tcl/exceptions-2.tcl b/Task/Exceptions/Tcl/exceptions-2.tcl deleted file mode 100644 index 5086244b35..0000000000 --- a/Task/Exceptions/Tcl/exceptions-2.tcl +++ /dev/null @@ -1,26 +0,0 @@ -set f "non-existent-file.txt" - -try { - puts "try begin" - - set fd [open $f "r" ] - - set contents [read $fd] - - puts "try end" - -} on error { results options } { - puts stderr "results: $results" - - foreach {opt val} $options { - puts stderr "options:\t$opt $val" - - } -} -puts "after try block" - -if {[info exists contents] } { - puts "$contents" -} else { - puts stderr "no contents read" -} diff --git a/Task/Exceptions/Tcl/exceptions-1.tcl b/Task/Exceptions/Tcl/exceptions.tcl similarity index 100% rename from Task/Exceptions/Tcl/exceptions-1.tcl rename to Task/Exceptions/Tcl/exceptions.tcl diff --git a/Task/Exceptions/Uiua/exceptions.uiua b/Task/Exceptions/Uiua/exceptions.uiua deleted file mode 100644 index 20d6fd1c37..0000000000 --- a/Task/Exceptions/Uiua/exceptions.uiua +++ /dev/null @@ -1,2 +0,0 @@ -⍣(⋕|0) "123" # parses okay -⍣(⋕|0) "notanumber" # supplies 0 on error diff --git a/Task/Executable-library/Ada/executable-library-1.adb b/Task/Executable-library/Ada/executable-library-1.ada similarity index 100% rename from Task/Executable-library/Ada/executable-library-1.adb rename to Task/Executable-library/Ada/executable-library-1.ada diff --git a/Task/Executable-library/Ada/executable-library-2.adb b/Task/Executable-library/Ada/executable-library-2.ada similarity index 100% rename from Task/Executable-library/Ada/executable-library-2.adb rename to Task/Executable-library/Ada/executable-library-2.ada diff --git a/Task/Executable-library/Ada/executable-library-3.adb b/Task/Executable-library/Ada/executable-library-3.ada similarity index 100% rename from Task/Executable-library/Ada/executable-library-3.adb rename to Task/Executable-library/Ada/executable-library-3.ada diff --git a/Task/Executable-library/Ada/executable-library-4.adb b/Task/Executable-library/Ada/executable-library-4.ada similarity index 100% rename from Task/Executable-library/Ada/executable-library-4.adb rename to Task/Executable-library/Ada/executable-library-4.ada diff --git a/Task/Executable-library/FreeBASIC/executable-library-1.basic b/Task/Executable-library/FreeBASIC/executable-library-1.basic deleted file mode 100644 index 9999f103b4..0000000000 --- a/Task/Executable-library/FreeBASIC/executable-library-1.basic +++ /dev/null @@ -1,37 +0,0 @@ -Function hailstone(number As Uinteger) As Uinteger - Dim As Uinteger count = 1 - - While number <> 1 - If (number And 1) = 1 Then - number += number Shr 1 + 1 - count += 2 - Else - number Shr= 1 - count += 1 - End If - Wend - Return count -End Function - -Sub Main() - Dim As Uinteger seqlen - seqlen = hailstone(27) - Print "Sequence length for 27 is "; seqlen - - Dim maxlen As uInteger = 0 - Dim maxnum As uInteger = 0 - For number As Uinteger = 2 To 100000 - seqlen = hailstone(number) - If seqlen > maxlen Then - maxlen = seqlen - maxnum = number - End If - Next - Print "The number with the longest hailstone sequence is "; maxnum - Print "Its sequence length is "; maxlen - Print -End Sub - -Main() - -Sleep diff --git a/Task/Executable-library/FreeBASIC/executable-library-2.basic b/Task/Executable-library/FreeBASIC/executable-library-2.basic deleted file mode 100644 index 3a5a72c7a9..0000000000 --- a/Task/Executable-library/FreeBASIC/executable-library-2.basic +++ /dev/null @@ -1,23 +0,0 @@ -Declare Function hailstone Alias "hailstone" (Byval arg As Uinteger) As Uinteger - -Dim Shared freq(351) As Uinteger - -For number As Uinteger = 2 To 100000 - Dim seqlen As Uinteger = hailstone(number) - freq(seqlen) += 1 -Next - -Dim max As Uinteger = 0 -Dim mostcommon As Uinteger - -For i As Uinteger = 0 To 351 - If freq(i) > max Then - max = freq(i) - mostcommon = i - End If -Next - -Print "The most common sequence length is "; mostcommon -Print "It occurs "; max; " times" - -Sleep diff --git a/Task/Executable-library/J/executable-library-1.j b/Task/Executable-library/J/executable-library-1.j index d81fc19c6d..715f13ff13 100644 --- a/Task/Executable-library/J/executable-library-1.j +++ b/Task/Executable-library/J/executable-library-1.j @@ -3,10 +3,10 @@ hailseq=: -:`(1 3&p.)@.(2&|) ^:(1 ~: ]) ^:a:"0 9!:29]1 9!:27'main 0' main=:3 :0 - echo 'Hailstone sequence for the number 27' - echo hailseq 27 - echo '' - echo 'Finding number with longest hailstone sequence which is' - echo 'less than 100000 (and finding that sequence length):' - echo (I.@(= >./),>./) #@hailseq i.1e5 + smoutput 'Hailstone sequence for the number 27' + smoutput hailseq 27 + smoutput '' + smoutput 'Finding number with longest hailstone sequence which is' + smoutput 'less than 100000 (and finding that sequence length):' + smoutput (I.@(= >./),>./) #@hailseq i.1e5 ) diff --git a/Task/Executable-library/J/executable-library-3.j b/Task/Executable-library/J/executable-library-3.j index 4f77a3c89e..2bb186622c 100644 --- a/Task/Executable-library/J/executable-library-3.j +++ b/Task/Executable-library/J/executable-library-3.j @@ -2,7 +2,7 @@ require '~temp/hailseq.ijs' 9!:29]1 9!:27'main 0' main=:3 :0 - echo 'Finding most frequent hailstone sequence length for' - echo 'Hailstone sequences for whole numbers less than 100000:' - echo {:{.\:~ (#/.~,.~.) #@hailseq }.i.1e5 + smoutput 'Finding most frequent hailstone sequence length for' + smoutput 'Hailstone sequences for whole numbers less than 100000:' + smoutput {:{.\:~ (#/.~,.~.) #@hailseq }.i.1e5 ) diff --git a/Task/Executable-library/Julia/executable-library.jl b/Task/Executable-library/Julia/executable-library.julia similarity index 100% rename from Task/Executable-library/Julia/executable-library.jl rename to Task/Executable-library/Julia/executable-library.julia diff --git a/Task/Executable-library/Sidef/executable-library-1.sidef b/Task/Executable-library/Sidef/executable-library-1.sidef index 0c21e726d0..9fc471fa73 100644 --- a/Task/Executable-library/Sidef/executable-library-1.sidef +++ b/Task/Executable-library/Sidef/executable-library-1.sidef @@ -2,16 +2,16 @@ func hailstone(n) { gather { while (n > 1) { take(n) - n = (n.is_even ? (n/2) : (take(3*n + 1)/2)) + n = (n.is_even ? n/2 : (3*n + 1)) } take(1) } } - +  if (__FILE__ == __MAIN__) { # true when not imported var seq = hailstone(27) - say "hailstone(27) - #{seq.len} elements: #{seq.first(4)} [...] #{seq.last(4)}" - + say "hailstone(27) - #{seq.len} elements: #{seq.ft(0, 3)} [...] #{seq.ft(-4)}" +  var n = 0 var max = 0 100_000.times { |i| @@ -21,6 +21,6 @@ if (__FILE__ == __MAIN__) { # true when not imported n = i } } - +  say "Longest sequence is for #{n}: #{max}" } diff --git a/Task/Executable-library/Wren/executable-library-1.wren b/Task/Executable-library/Wren/executable-library-1.wren index f94e82a732..13928a04ad 100644 --- a/Task/Executable-library/Wren/executable-library-1.wren +++ b/Task/Executable-library/Wren/executable-library-1.wren @@ -1,4 +1,4 @@ -/* Executable_library.wren */ +/* hailstone.wren */ var Hailstone = Fn.new { |n| if (n < 1) Fiber.abort("Parameter must be a positive integer.") @@ -34,6 +34,6 @@ var libMain_ = Fn.new { // Check if it's being used as a library or not. import "os" for Process -if (Process.allArguments[1] == "Executable_library.wren") { // if true, not a library +if (Process.allArguments[1] == "hailstone.wren") { // if true, not a library libMain_.call() } diff --git a/Task/Executable-library/Wren/executable-library-2.wren b/Task/Executable-library/Wren/executable-library-2.wren index f84d5804c7..e6cc7cbd0a 100644 --- a/Task/Executable-library/Wren/executable-library-2.wren +++ b/Task/Executable-library/Wren/executable-library-2.wren @@ -1,6 +1,6 @@ -/* Executable_library_2.wren */ +/* hailstone2.wren */ -import "./Executable_library" for Hailstone +import "/hailstone" for Hailstone var freq = {} for (i in 1...100000) { diff --git a/Task/Execute-Brain-/ALGOL-68/execute-brain--1.alg b/Task/Execute-Brain-/ALGOL-68/execute-brain--1.alg index 6f36b9cea2..c74c21fd7b 100644 --- a/Task/Execute-Brain-/ALGOL-68/execute-brain--1.alg +++ b/Task/Execute-Brain-/ALGOL-68/execute-brain--1.alg @@ -86,10 +86,11 @@ BEGIN # Brain**** -> Algol 68 transpiler # # get the code to transpile and output it as a comment at the start # # of the code # print( ( "CO BF> " ) ); - STRING bf code; - read( ( bf code, newline ) ); - print( ( newline, bf code, newline, "CO", newline ) ); + STRING code list; + read( ( code list, newline ) ); + print( ( newline, code list, newline, "CO", newline ) ); # transpile the code # - generate( bf code ) + generate( code list ) + END diff --git a/Task/Execute-Brain-/Agena/execute-brain-.agena b/Task/Execute-Brain-/Agena/execute-brain-.agena index 626b19af9e..becfb717b7 100644 --- a/Task/Execute-Brain-/Agena/execute-brain-.agena +++ b/Task/Execute-Brain-/Agena/execute-brain-.agena @@ -1,27 +1,89 @@ -scope # Simple BF interpreter, based on the Lua sample: "Simple meta-implementation using load" - # reads the BF code from stdin, builds an equivalent Agena program and executes it +# Brain**** interpreter - local constant bfOp := [ '>' ~ 'ptr +:= 1; ' - , '<' ~ 'ptr -:= 1; ' - , '+' ~ 'mem[ptr] +:= 1; ' - , '-' ~ 'mem[ptr] -:= 1; ' - , '[' ~ 'while mem[ptr] <> 0 do ' - , ']' ~ 'od; ' - , '.' ~ 'io.write(char(mem[ptr])); ' - , ',' ~ 'mem[ptr] := abs(io.read(io.stdin,1) or "\\0"); ' - ]; +# execute the Brain**** program in the code string +bf := proc( code :: string ) is + local address := 1; # current data address + local pc := 1; # current position in code + local data := []; # data - initially empty + local input := ""; # user input - initially empty + local bfOperations := # table of operations and their implemntations + [ ">" ~ proc() is inc address, 1 end + , "<" ~ proc() is dec address, 1 end + , "+" ~ proc() is inc data[ address ], 1 end + , "-" ~ proc() is dec data[ address ], 1 end + , "." ~ proc() is io.write( char( data[ address ] ) ) end + , "," ~ proc() is + # get next input character, converted to an integer + while input = "" + do + # no input left - get the next line + input := io.read() + od; + data[ address ] := abs( input[ 1 ] ); + # remove the latest character from the input + if size input < 2 + then + input := "" + else + input := input[ 2 to -1 ] + fi + end + , "[" ~ proc() is + if data[ address ] = 0 + then + # skip to the end of the loop + local depth := 0; + do + inc pc, 1; + if code[ pc ] = "[" + then + inc depth, 1 + elif code[ pc ] = "]" + then + dec depth, 1 + fi + until depth < 0 + fi + end + , "]" ~ proc() is + if data[ address ] <> 0 + then + # skip to the start of the loop + local depth := 0; + do + dec pc, 1; + if code[ pc ] = "[" + then + dec depth, 1 + elif code[ pc ] = "]" + then + inc depth, 1 + fi + until depth < 0 + fi + end + ]; + # execute the operations - ignore anything invalid + while pc <= size code + do + if data[ address ] = null + then + data[ address ] := 0 + fi; + if bfOperations[ code[ pc ] ] <> null + then + bfOperations[ code[ pc ] ]() + fi; + inc pc, 1 + od +end; - local bfProgram := "local mem := setmetatable([], [ '__index' ~ proc() return 0 end ]);\n" - & "local ptr := 1;\n" - ; - - for line in io.lines() do - for p to size line do - local snippet := bfOp[ line[ p ] ]; - if snippet then bfProgram &:= snippet & "\n" fi - od - od; - - loadstring( bfProgram, "bfCode" )() - -end +# prompt for Brain**** code and execute it, repeating until an empty code string is entered +scope + local code; + do + io.write( "BF> " ); + code := io.read(); + bf( code ) + until code = "" +epocs; diff --git a/Task/Execute-Brain-/Arturo/execute-brain--1.arturo b/Task/Execute-Brain-/Arturo/execute-brain--1.arturo index b30648cc5a..d84f05f32a 100644 --- a/Task/Execute-Brain-/Arturo/execute-brain--1.arturo +++ b/Task/Execute-Brain-/Arturo/execute-brain--1.arturo @@ -4,21 +4,21 @@ ; Tape: [0] -DataPointer: 0 -InstructionPointer: 0 +DataPointer: new 0 +InstructionPointer: new 0 ; Look for jumps in Code an register them ; in the Jumps table precomputeJumps: function [][ - vstack: [] - jumphash: #[] + vstack: new [] + jumphash: new #[] instrPointer: 0 while [instrPointer 'vstack ++ instrPointer - [ + if? command="[" -> 'vstack ++ instrPointer + else [ if command="]" [ target: last vstack chop 'vstack @@ -47,37 +47,36 @@ StateIsValid: function [][ interpret: function [].export:[DataPointer,InstructionPointer,Tape][ while [StateIsValid][ command: get split Code InstructionPointer - case command [ - "+" -> Tape\[DataPointer]: Tape\[DataPointer]+1 - "-" -> Tape\[DataPointer]: Tape\[DataPointer]-1 - ">" [ + case [command=] + when? ["+"] -> Tape\[DataPointer]: Tape\[DataPointer]+1 + when? ["-"] -> Tape\[DataPointer]: Tape\[DataPointer]-1 + when? [">"] [ inc 'DataPointer if DataPointer = size Tape -> Tape: Tape ++ 0 ] - "<" -> dec 'DataPointer - "." -> prints to :string to :char Tape\[DataPointer] - "," [ + when? ["<"] -> dec 'DataPointer + when? ["."] -> prints to :string to :char Tape\[DataPointer] + when? [","][ inp: to :integer input "" if inp=13 -> inp: 10 if inp=3 -> panic "something went wrong!" set Tape DataPointer inp ] - "[" -> - if 0 = get Tape DataPointer [ InstructionPointer: new Jumps\[InstructionPointer] ] + when? ["["] -> + if 0 = get Tape DataPointer [ InstructionPointer: new get Jumps InstructionPointer ] - "]" -> + when? ["]"] -> if 0 <> get Tape DataPointer [ - InstructionPointer: new Jumps\[InstructionPointer] + InstructionPointer: new get Jumps InstructionPointer ] - ] inc 'InstructionPointer ] ] Code: "" -switch 1>size arg -> Code: "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." - -> Code: read arg\0 +if? 1>size arg -> Code: "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." +else -> Code: read arg\0 CodeLength: size Code Jumps: precomputeJumps diff --git a/Task/Execute-Brain-/AutoIt/execute-brain-.au3 b/Task/Execute-Brain-/AutoIt/execute-brain-.autoit similarity index 100% rename from Task/Execute-Brain-/AutoIt/execute-brain-.au3 rename to Task/Execute-Brain-/AutoIt/execute-brain-.autoit diff --git a/Task/Execute-Brain-/Commodore-BASIC/execute-brain-.basic b/Task/Execute-Brain-/Commodore-BASIC/execute-brain-.basic deleted file mode 100644 index a156f8bebb..0000000000 --- a/Task/Execute-Brain-/Commodore-BASIC/execute-brain-.basic +++ /dev/null @@ -1,65 +0,0 @@ -100 REM BRAINF*CK FOR COMMODORE BASIC -110 DB=0:REM SET TO 1 FOR DEBUGGING -120 P$="" -130 READ C$ -140 P$=P$+C$ -150 IF LEN(C$)<>0 THEN 130 -160 REM PAIR UP BRACKETS INTO B% -170 DIM B%(LEN(P$)) -180 REM TRACK OPEN BRACKETS IN O% -190 DIM O%(INT(LEN(P$)/2)):O=0 -200 FOR I=1 TO LEN(P$) -210 : I$=MID$(P$,I,1) -220 : IF I$="[" THEN O%(O)=I:O=O+1 -230 : IF I$<>"]" THEN 270 -240 : IF O=0 THEN PRINT "UNMATCHED BRACKET AT"I". ABORTING.":END -250 : O=O-1:M=O%(O) -260 : B%(I)=M:B%(M)=I -270 NEXT I -280 IF O THEN PRINT "UNMATCHED BRACKETS AT EOF. ABORTING.":END -290 REM SET MS TO NUMBER OF MEMORY CELLS NEEDED. -300 REM THE BF SPEC REQUIRES 30000, WHICH WILL WORK ON C64 OR 48K+ PET. -310 AN UNEXPANDED VIC-20 WILL HANDLE 1000, A C-16 9000. THE DEMO ONLY NEEDS 4. -320 MS=4:DIM M%(MS/2-1):MP=0 -330 REM FUNCTION TO READ BYTE AT CELL N -340 DEF FNMP(N)=INT(M%(INT(N/2)) / (1+255*(N AND 1))) AND 255 -350 FOR I=1 TO LEN(P$) -360 : IF MP<0 OR MP>=MS THEN PRINT "ERROR: MP OUT OF RANGE AT"I:END -370 : IF DB THEN PRINT "IP:"I"("I$") MP: "MP"("FNMP(MP)")" -380 : I$=MID$(P$,I,1) -390 : IF I$<>"[" THEN 420 -400 : IF FNMP(MP)=0 THEN I=B%(I) -410 : GOTO 530 -420 : IF I$<>"]" THEN 450 -430 : IF FNMP(MP) THEN I=B%(I) -440 : GOTO 530 -450 : IF I$="<" THEN MP=MP-1:GOTO 530 -460 : IF I$=">" THEN MP=MP+1:GOTO 530 -470 : IF I$="-" THEN V=FNMP(MP)-1:GOTO 560 -480 : IF I$="+" THEN V=FNMP(MP)+1:GOTO 560 -490 : IF I$="." THEN PRINTCHR$(FNMP(MP));:GOTO 530 -500 : IF I$<>"," THEN 530 -510 : GET K$:IF K$="" THEN 510 -520 : V=ASC(K$):GOTO 560 -530 NEXT I -540 END -550 REM UPDATE CELL AT MP WITH VALUE IN V -560 M=INT(MP/2):O=M%(M):V=V AND 255 -570 N0=(O AND -256)+V -580 N1=(V*256+(O AND 255)) -590 M%(M) = (MP AND 1)*N1 - ((MP AND 1)=0)*N0 -600 GOTO 530 -610 REM HELLO, WORLD PROGRAM -620 DATA "+++++++++[>++++++++<-]>." -630 DATA "---." -640 DATA "+++++++..+++." -650 DATA ">>++++[<+++++++++++>-]<." -660 DATA ">++++[<--->-]<." -670 DATA "<++++++++." -680 DATA "--------." -690 DATA "+++." -700 DATA "------." -710 DATA "--------." -720 DATA ">>[++][<+++++++>-]<+." -730 DATA ">++++++++++." -740 DATA "" diff --git a/Task/Execute-Brain-/Crystal/execute-brain-.cr b/Task/Execute-Brain-/Crystal/execute-brain-.cr deleted file mode 100644 index 355443e3a0..0000000000 --- a/Task/Execute-Brain-/Crystal/execute-brain-.cr +++ /dev/null @@ -1,33 +0,0 @@ -def bfrun (code) - code = code.chars - data = Hash(Int32, Int32).new(0) - dp = ip = 0 - jump_to_matching = ->(dir : Int32) { - nest = 0 - while 0 <= ip < code.size - case code[ip] - when '[' then nest += dir - when ']' then nest -= dir - end - break if nest == 0 - ip += dir - end - } - while 0 <= ip < code.size - case code[ip] - when '>' then dp += 1 - when '<' then dp -= 1 - when '+' then data[dp] += 1 - when '-' then data[dp] -= 1 - when '.' then print(data[dp].chr) - when ',' then data[dp] = STDIN.read_char.not_nil!.ord - when '[' then jump_to_matching.call(1) if data[dp] == 0 - when ']' then jump_to_matching.call(-1) if data[dp] != 0 - end - ip += 1 - end -end - -hello = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." - -bfrun(hello) diff --git a/Task/Execute-Brain-/Delphi/execute-brain-.pas b/Task/Execute-Brain-/Delphi/execute-brain-.delphi similarity index 100% rename from Task/Execute-Brain-/Delphi/execute-brain-.pas rename to Task/Execute-Brain-/Delphi/execute-brain-.delphi diff --git a/Task/Execute-Brain-/EasyLang/execute-brain-.easy b/Task/Execute-Brain-/EasyLang/execute-brain-.easy deleted file mode 100644 index 35eabaabb8..0000000000 --- a/Task/Execute-Brain-/EasyLang/execute-brain-.easy +++ /dev/null @@ -1,74 +0,0 @@ -proc exec code$ . - len mem[] 100 - dp = 1 - code$[] = strchars code$ - ip = 1 - while ip <= len code$[] - if dp > len mem[] - len mem[] len mem[] + 100 - . - if dp < 1 - print "programm error" - return - . - c$ = code$[ip] - if c$ = "+" - mem[dp] += 1 - elif c$ = "-" - mem[dp] -= 1 - elif c$ = ">" - dp += 1 - elif c$ = "<" - dp -= 1 - elif c$ = "." - write strchar mem[dp] - elif c$ = "," - print "input not implemented" - elif c$ = "[" - if mem[dp] = 0 - br = 1 - repeat - ip += 1 - if code$[ip] = "[" - br += 1 - elif code$[ip] = "]" - br -= 1 - . - until br = 0 - . - else - br[] &= ip - . - elif c$ = "]" - ip = br[len br[]] - 1 - len br[] -1 - . - ip += 1 - . -. -func syntax code$ . - for i to len code$ - h$ = substr code$ i 1 - if h$ = "[" - br += 1 - elif h$ = "]" - br -= 1 - . - if br < 0 : return 0 - . - return if br = 0 -. -repeat - inp$ = input - until inp$ = "" - code$ &= inp$ -. -if syntax code$ <> 1 - print "syntax error" - return -. -exec code$ -# -input_data -++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.> ----.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. diff --git a/Task/Execute-Brain-/Factor/execute-brain-.factor b/Task/Execute-Brain-/Factor/execute-brain-.factor index 2e31e5ce88..513f3d3667 100644 --- a/Task/Execute-Brain-/Factor/execute-brain-.factor +++ b/Task/Execute-Brain-/Factor/execute-brain-.factor @@ -1,3 +1,3 @@ -USE: brainfuck +USE: brainf*** -"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." run-brainfuck +"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." run-brainf*** diff --git a/Task/Execute-Brain-/Fennel/execute-brain-.fennel b/Task/Execute-Brain-/Fennel/execute-brain-.fennel deleted file mode 100644 index 570e80ccae..0000000000 --- a/Task/Execute-Brain-/Fennel/execute-brain-.fennel +++ /dev/null @@ -1,34 +0,0 @@ -(do ;;; Simple BF interpreter, based on the Lua sample: "Simple meta-implementation using load" - ;;; reads the BF code from stdin, builds an equivalent Pluto program and executes it - - (local bf-op { ">" "ptr = ptr + 1" - "<" "ptr = ptr - 1" - "+" "mem[ptr] = mem[ptr] + 1" - "-" "mem[ptr] = mem[ptr] - 1" - "[" "while mem[ptr] ~= 0 do" - "]" "end" - "." "io.write(string.char(mem[ptr]))" - "," "mem[ptr] = string.byte(io.read(1) or \"\\0\")" - } - ) - - (var bf-program (.. "local mem = setmetatable({}, { __index = function() return 0 end })\n" - "local ptr = 1\n" - ) - ) - (each [line (io.lines)] - (for [p 1 (length line)] - (local op (. bf-op (line:sub p p))) - (when op - (set bf-program (.. bf-program op "\n")) - ) - ) - ) - (local (bf-code msg) (load bf-program)) - (if bf-code - (bf-code) - ;else - (error msg) - ) - -) diff --git a/Task/Execute-Brain-/Hare/execute-brain-.hare b/Task/Execute-Brain-/Hare/execute-brain-.hare deleted file mode 100644 index 05d315b116..0000000000 --- a/Task/Execute-Brain-/Hare/execute-brain-.hare +++ /dev/null @@ -1,74 +0,0 @@ -use fmt; -use fs; -use io; -use os; - -export fn main() void = { - if (len(os::args) != 2) { - fmt::print("Please provide a parameter pointing to a brain**** file.\n")!; - return; - }; - - let program = slurp(os::args[1])!; - let tape: [30000]u8 = [0...]; - let tp: u16 = 0; - defer free(program); - - let matches_k: []size = []; - let matches_v: []size = []; - defer free(matches_k); - defer free(matches_v); - - for (let pp: size = 0; pp < len(program); pp += 1) { - switch (program[pp]) { - case '>' => tp += 1; - case '<' => tp -= 1; - case '+' => tape[tp] += 1; - case '-' => tape[tp] -= 1; - case '.' => io::write(os::stdout, tape[tp..tp+1])!; - case ',' => io::read(os::stdin, tape[tp..tp+1])!; - case '[' => if (tape[tp] == 0) pp = find_match(pp, program, matches_k, matches_v)!; - case ']' => if (tape[tp] != 0) pp = find_match(pp, program, matches_k, matches_v)!; - case => continue; - }; - }; -}; - -fn find_match(pos: size, program: []u8, matches_k: []size, matches_v: []size) (size | !void) = { - for (let i: u16 = 0; i < len(matches_k); i += 1) - if (pos == matches_k[i]) - return matches_v[i]; - let r = pos; - switch (program[pos]) { - case '[' => { - r += 1; - for (let level = 1; level > 0; r += 1) { - switch (program[r]) { - case '[' => level += 1; - case ']' => level -= 1; - case => continue; - }; - }; - }; - case ']' => { - r -= 1; - for (let level = 1; level > 0; r -= 1) { - switch (program[r]) { - case ']' => level += 1; - case '[' => level -= 1; - case => continue; - }; - }; - }; - case => return; - }; - append(matches_k, pos)!; - append(matches_v, r)!; - return r; -}; - -fn slurp(filename: str) ([]u8 | fs::error | io::error) = { - const file = os::open(filename)?; - defer io::close(file)!; - return io::drain(file)?; -}; diff --git a/Task/Execute-Brain-/Julia/execute-brain-.jl b/Task/Execute-Brain-/Julia/execute-brain-.julia similarity index 100% rename from Task/Execute-Brain-/Julia/execute-brain-.jl rename to Task/Execute-Brain-/Julia/execute-brain-.julia diff --git a/Task/Execute-Brain-/Kotlin/execute-brain-.kts b/Task/Execute-Brain-/Kotlin/execute-brain-.kotlin similarity index 100% rename from Task/Execute-Brain-/Kotlin/execute-brain-.kts rename to Task/Execute-Brain-/Kotlin/execute-brain-.kotlin diff --git a/Task/Execute-Brain-/Lua/execute-brain-.lua b/Task/Execute-Brain-/Lua/execute-brain-.lua index 422ea849d3..8f2aec0651 100644 --- a/Task/Execute-Brain-/Lua/execute-brain-.lua +++ b/Task/Execute-Brain-/Lua/execute-brain-.lua @@ -1,22 +1,24 @@ -local repl = { - ['>'] = 'ptr = ptr + 1', - ['<'] = 'ptr = ptr - 1', - ['+'] = 'mem[ptr] = mem[ptr] + 1', - ['-'] = 'mem[ptr] = mem[ptr] - 1', - ['['] = 'while mem[ptr] ~= 0 do', - [']'] = 'end', - ['.'] = 'io.write(string.char(mem[ptr]))', - [','] = 'mem[ptr] = (io.read(1) or "\\0"):byte()', +local funs = { +['>'] = 'ptr = ptr + 1; ', +['<'] = 'ptr = ptr - 1; ', +['+'] = 'mem[ptr] = mem[ptr] + 1; ', +['-'] = 'mem[ptr] = mem[ptr] - 1; ', +['['] = 'while mem[ptr] ~= 0 do ', +[']'] = 'end; ', +['.'] = 'io.write(string.char(mem[ptr])); ', +[','] = 'mem[ptr] = (io.read(1) or "\\0"):byte(); ', } -local prog = {[[ +local prog = [[ local mem = setmetatable({}, { __index = function() return 0 end}) local ptr = 1 -]]} +]] -local source, i = io.read('*all'), 1 -for char in source:gmatch"[<>+.,%[%]%-]" do - i, prog[i] = i+1, repl[char] +local source = io.read('*all') + +for p = 1, #source do + local snippet = funs[source:sub(p,p)] + if snippet then prog = prog .. snippet end end -load( table.concat(prog, " ") )() +load(prog)() diff --git a/Task/Execute-Brain-/Miranda/execute-brain-.miranda b/Task/Execute-Brain-/Miranda/execute-brain-.miranda deleted file mode 100644 index e1686c7e26..0000000000 --- a/Task/Execute-Brain-/Miranda/execute-brain-.miranda +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/mira -exec -main :: [sys_message] -main = (interpret . read . hd . tl) $* - -interpret :: [char]->[sys_message] -interpret prog = msgs where (tape, inp, msgs) = run empty_tape $- (parse prog) - -instr ::= Left | Right | Inc | Dec | Read | Write | Loop [instr] - -run :: tape->[char]->[instr]->(tape,[char],[sys_message]) -run tape inp [] = (tape, inp, []) -run tape inp (instr:instrs) - = (tape'', inp'', sysmsg ++ sysmsgs) - where (tape', inp', sysmsg) = step tape inp instr - (tape'', inp'', sysmsgs) = run tape' inp' instrs - -step :: tape->[char]->instr->(tape,[char],[sys_message]) -step tape inp Left = (left tape, inp, []) -step tape inp Right = (right tape, inp, []) -step tape inp Inc = (apply (+1) tape, inp, []) -step tape inp Dec = (apply (+-1) tape, inp, []) -step tape inp Read = (setval ch tape, inp', []) - where (ch, inp') = getchar inp -step tape inp Write = (tape, inp, [Stdout (decode (val tape):[])]) -step tape inp (Loop prog) = (tape, inp, []), if val tape = 0 - = (tape'', inp'', sysmsgs ++ sysmsgs'), otherwise - where (tape', inp', sysmsgs) = run tape inp prog - (tape'', inp'', sysmsgs') = step tape' inp' (Loop prog) - -getchar :: [char]->(num,[char]) -getchar [] = (0, []) -getchar (x:xs) = (code x, xs) - -parse :: [char] -> [instr] -parse [] = [] -parse instrs - = Left : rest, if tok="<" - = Right : rest, if tok=">" - = Inc : rest, if tok="+" - = Dec : rest, if tok="-" - = Read : rest, if tok="," - = Write : rest, if tok="." - = Loop loop : rest, if hd tok='[' - = rest, otherwise - where (tok, next) = token instrs - rest = parse next - loop = parse (init (tl tok)) - -token :: [char] -> ([char],[char]) -token [] = ([],[]) -token (']':xs) = error "] without [" -token ('[':xs) = ('[':l, rs) where (l, rs) = getloop xs -token (x:xs) = (x:[], xs) - -getloop :: [char] -> ([char],[char]) -getloop = g 0 - where g 0 (']':xs) = ("]", xs) - g n ('[':xs) = ('[':l,rs) where (l,rs) = g (n+1) xs - g n (']':xs) = (']':l,rs) where (l,rs) = g (n-1) xs - g n (x:xs) = (x:l,rs) where (l,rs) = g n xs - g n [] = error "[ without ]" - -tape ::= Tape [num] num [num] - -empty_tape :: tape -empty_tape = Tape [] 0 [] - -left :: tape->tape -left (Tape ls c []) = Tape (c:ls) 0 [] -left (Tape ls c (r:rs)) = Tape (c:ls) r rs - -right :: tape->tape -right (Tape [] c rs) = Tape [] 0 (c:rs) -right (Tape (l:ls) c rs) = Tape ls l (c:rs) - -apply :: (num->num)->tape->tape -apply fn (Tape ls c rs) = Tape ls (fn c mod 256) rs - -val :: tape->num -val (Tape ls c rs) = c - -setval :: num->tape->tape -setval v (Tape ls c rs) = Tape ls v rs diff --git a/Task/Execute-Brain-/Odin/execute-brain-.odin b/Task/Execute-Brain-/Odin/execute-brain-.odin deleted file mode 100644 index e2898826a1..0000000000 --- a/Task/Execute-Brain-/Odin/execute-brain-.odin +++ /dev/null @@ -1,126 +0,0 @@ -package bf - -import "core:fmt" -import "core:c/libc" -import "core:os" - -cells_size :: 2000 -getinp : i32 -inp : u8 -main :: proc() { - - // comment out to give a file from command line - // data, ok := os.read_entire_file(os.args[1]) - // assert(ok, "Could not open file") - // defer delete(data) - // input := string(data) - - input := ">+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++." - size_input := len(input) - cells : [cells_size]i32 - pointer:=0 - i:=0 - direction := 1 - // moving past non matching [ ] - depth:= 0 - // loop i over input - mainloop: for ; (i <= (size_input - 1) && i >=0); { - inp = input[i] - //fmt.println(i) - switch inp{ - // move pointer right - case '>': - pointer +=1 - if (pointer>cells_size-1){ - pointer=cells_size-1 - } - i += 1 - // move pointer left - case '<': - pointer -=1 - if (pointer<0){ - pointer=0 - } - i += 1 - // increase cells at pointer - case '+': - cells[pointer] = (cells[pointer] + 1) % 256 - i += 1 - // decrease cell at pointer - case '-': - cells[pointer] = (cells[pointer] - 1) % 256 - i += 1 - // output value from cell at pointer - case '.': - res := cells[pointer] - libc.putchar(res) - i += 1 - // input value in cell at pointer - case ',': - getinp= libc.getchar() - fmt.println("input:") - cells[pointer] = getinp - i += 1 - // Jump past the matching ] if the cell at the pointer is 0 - case '[': - // if cell at pointer = 0 - if cells[pointer] == 0 { - // loop until ] - - loop1: for (inp != ']' && depth == 0) { - i +=1 - inp = input[i] - if (i > (size_input-1)){ - // if i > size input [ is unbalanced - fmt.printf("unbalanced loop ") - break mainloop - } - else if (inp == '[') { - depth += 1 - } - else if (inp == ']' && depth != 0) { - depth -= 1 - } - - fmt.println(i) - } - - } // else ignore - else { - i +=1 - } - - case ']': - // Jump back to the matching [ if the cell at the pointer is nonzero - if cells[pointer] != 0 { - - loop2: for (inp!= '[' && depth == 0) { - i -= 1 - inp = input[i] - if (i < 0) - { - fmt.printf("unbalanced loop ") - break mainloop - } - else if (inp == ']') { - depth += 1 - } - else if (inp == '[' && depth != 0) { - depth -= 1 - } - //fmt.println(input[i]) - } - - } - else { - i+=1 - } - // default: move pointer - case : - i +=1 - - } - - } - -} diff --git a/Task/Execute-Brain-/Phix/execute-brain-.phix b/Task/Execute-Brain-/Phix/execute-brain-.phix index a59f95828d..c35807b1ce 100644 --- a/Task/Execute-Brain-/Phix/execute-brain-.phix +++ b/Task/Execute-Brain-/Phix/execute-brain-.phix @@ -1,51 +1,54 @@ -procedure bfi(string pgm) - sequence jumptable = repeat(0,length(pgm)), - loopstack = {}, - data = repeat(0,10) -- size?? - integer skip = 0, ch - -- - -- compile (pack/strip comments and link jumps) - -- - for i=1 to length(pgm) do - ch = pgm[i] - switch ch do - case '[': loopstack = append(loopstack,i-skip); - pgm[i-skip] = ch; - case ']': integer loopstart = loopstack[$]; - loopstack = loopstack[1..-2]; - jumptable[i-skip] = loopstart; - jumptable[loopstart] = i-skip; - fallthrough - case '+','-','<','>',',','.': pgm[i-skip] = ch; - default: skip += 1 - end switch - end for - if length(loopstack) then ?9/0 end if - pgm = pgm[1..-1-skip] +(phixonline)--> + procedure bfi(string pgm) + sequence jumptable = repeat(0,length(pgm)), + loopstack = {}, + data = repeat(0,10) -- size?? + integer skip = 0, ch, loopstart, pc, dp + -- + -- compile (pack/strip comments and link jumps) + -- + for i=1 to length(pgm) do + ch = pgm[i] + switch ch do + case '[': loopstack = append(loopstack,i-skip); + pgm[i-skip] = ch; + case ']': loopstart = loopstack[$]; + loopstack = loopstack[1..-2]; + jumptable[i-skip] = loopstart; + jumptable[loopstart] = i-skip; + fallthrough + case '+','-','<','>',',','.': pgm[i-skip] = ch; + default: skip += 1 + end switch + end for + if length(loopstack) then ?9/0 end if + pgm = pgm[1..-1-skip] - -- - -- main execution loop - -- - integer pc = 1, dp = 1 - while pc<=length(pgm) do - ch = pgm[pc] - switch ch do - case '>': dp += 1 if dp>length(data) then dp = 1 end if - case '<': dp -= 1 if dp<1 then dp = length(data) end if - case '+': data[dp] += 1 - case '-': data[dp] -= 1 - case ',': data[dp] = iff(platform()=JS?'?':getc(0)) - case '.': puts(1,data[dp]) - case '[': if data[dp]=0 then pc = jumptable[pc] end if - case ']': if data[dp]!=0 then pc = jumptable[pc] end if - default: ?9/0 - end switch - pc += 1 - end while -end procedure + -- + -- main execution loop + -- + pc = 1 + dp = 1 + while pc<=length(pgm) do + ch = pgm[pc] + switch ch do + case '>': dp += 1 if dp>length(data) then dp = 1 end if + case '<': dp -= 1 if dp<1 then dp = length(data) end if + case '+': data[dp] += 1 + case '-': data[dp] -= 1 + case ',': data[dp] = iff(platform()=JS?'?':getc(0)) + case '.': puts(1,data[dp]) + case '[': if data[dp]=0 then pc = jumptable[pc] end if + case ']': if data[dp]!=0 then pc = jumptable[pc] end if + default: ?9/0 + end switch + pc += 1 + end while + end procedure -constant bf="++++++++[>++++[>++>++++>+++>+<<<<-]>++>->+>>+[<]<-]>>.>>.+.<.>>.<<<++.>---------.>------.<----.++++++++.>>+.>++.+++." -constant fb="++++++++[>++++[>++>++++>+++>+<<<<-]>++>->+>>+[<]<-]>>.>>.+.<.>>.<<<+++.>---.>------.++++++++.<--.>>+.>++.+++.," + constant bf="++++++++[>++++[>++>++++>+++>+<<<<-]>++>->+>>+[<]<-]>>.>>.+.<.>>.<<<++.>---------.>------.<----.++++++++.>>+.>++.+++." + constant fb="++++++++[>++++[>++>++++>+++>+<<<<-]>++>->+>>+[<]<-]>>.>>.+.<.>>.<<<+++.>---.>------.++++++++.<--.>>+.>++.+++.," -bfi(bf) -bfi(fb) + bfi(bf) + bfi(fb) +-]<." -620 DATA "<++++++++." -630 DATA "--------." -640 DATA "+++." -650 DATA "------." -660 DATA "--------." -670 DATA ">>[++][<+++++++>-]<+." -680 DATA ">++++++++++." -690 DATA "" diff --git a/Task/Execute-Brain-/VBScript/execute-brain-.vbs b/Task/Execute-Brain-/VBScript/execute-brain-.vb similarity index 100% rename from Task/Execute-Brain-/VBScript/execute-brain-.vbs rename to Task/Execute-Brain-/VBScript/execute-brain-.vb diff --git a/Task/Execute-Brain-/Vala/execute-brain-.vala b/Task/Execute-Brain-/Vala/execute-brain-.vala deleted file mode 100644 index 5e366c653e..0000000000 --- a/Task/Execute-Brain-/Vala/execute-brain-.vala +++ /dev/null @@ -1,62 +0,0 @@ -void main() { - string code = "++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++ -++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>> ->+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++. -<+++++++.--------.<<<<<+.<+++.---."; - - bf(10, code); -} - -void bf(int len, string input) { - char[] data = new char[len]; - int data_pointer = 0; - - for (int i = 0; i < input.length; i++) { - switch (input[i]) { - case '>': - data_pointer++; - break; - case '<': - data_pointer--; - break; - case '+': - data[data_pointer]++; - break; - case '-': - data[data_pointer]--; - break; - case '.': - stdout.printf("%c", data[data_pointer]); - break; - case ',': - stdin.scanf("%c", &data[data_pointer]); - break; - case '[': - if (data[data_pointer] == 0) { - for (int nc = 1; nc > 0;) { - i++; - if (input[i] == '[') { - nc++; - } - else if (input[i] == ']') { - nc--; - } - } - } - break; - case ']': - if (data[data_pointer] != 0) { - for (int nc = 1; nc > 0;) { - i--; - if (input[i] == ']') { - nc++; - } - else if (input[i] == '[') { - nc--; - } - } - } - break; - } - } -} diff --git a/Task/Execute-Brain-/Visual-Basic-.NET/execute-brain-.vb b/Task/Execute-Brain-/Visual-Basic-.NET/execute-brain-.vb deleted file mode 100644 index b258dd7b25..0000000000 --- a/Task/Execute-Brain-/Visual-Basic-.NET/execute-brain-.vb +++ /dev/null @@ -1,70 +0,0 @@ -Imports System - -Module Program - Sub Main(args As String()) - Brainfug("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.") - End Sub - - Sub Brainfug(code As String, Optional input As String = Nothing) - Dim inp As Integer = 1 ' input pointer if we use an input string - Dim tape(29999) As Integer ' yes, 29999 makes an array of 30000 - Dim p As Integer - For i = 1 To code.Length - Dim c As Char = Mid(code, i, 1) - Select c - Case ">" - p += 1 - Case "<" - p -= 1 - Case "+" - tape(p) += 1 - Case "-" - tape(p) -= 1 - Case "." - Try - Console.Write(Chr(tape(p))) - Catch ex As NotSupportedException - Console.Write(".") - End Try - Case "," - If input Is Nothing then - tape(p) = Console.Read() - Else - Try - tape(p) = AscW(Mid(input, inp, 1)) - Catch ex As ArgumentException - Console.WriteLine("Panic: Out of input!") - Environment.Exit(1) - End Try - inp += 1 - End If - Case "[" - If tape(p) = 0 - Dim nest = 1 - While nest - i += 1 - Select Mid(code, i, 1) - Case "]" - nest -= 1 - Case "[" - nest += 1 - End Select - End While - End If - Case "]" - If tape(p) <> 0 - Dim nest = 1 - While nest - i -= 1 - Select Mid(code, i, 1) - Case "[" - nest -= 1 - Case "]" - nest += 1 - End Select - End While - End If - End Select - Next - End Sub -End Module diff --git a/Task/Execute-Brain-/Vyxal/execute-brain-.vyxal b/Task/Execute-Brain-/Vyxal/execute-brain-.vyxal deleted file mode 100644 index f08e20818a..0000000000 --- a/Task/Execute-Brain-/Vyxal/execute-brain-.vyxal +++ /dev/null @@ -1,13 +0,0 @@ -"+++++++++++[>++++++>+++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." ##code -?£ƛ -:'+=["D:hi›$h$≜"| ##'+' -:'-=["D:hi‹$h$≜"| ##'-' -:'>=["0J:h›0$≜"| ##'>', auto-extends tape -:'<=[":h‹0$≜"| ##'<' -:'[=["{Dhi|"| ##'[' -:']=['}| ##']' -:'.=["DhiO#,"| ##'.' -":h0¥ᑂ$£O≜" ##',' -]” -1 0; ## initial tape T. T[0] is the pointer -$ᴥ ##run the code diff --git a/Task/Execute-Computer-Zero/C/execute-computer-zero.c b/Task/Execute-Computer-Zero/C/execute-computer-zero.c deleted file mode 100644 index 0f5e25f3f9..0000000000 --- a/Task/Execute-Computer-Zero/C/execute-computer-zero.c +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include -#include -#include - -#define EXECUTE(...) \ - execute((uint8_t[]){ __VA_ARGS__ }, sizeof((uint8_t[]){ __VA_ARGS__ })) - -#define NOP 0b000'00000 -#define LDA 0b001'00000 | -#define STA 0b010'00000 | -#define ADD 0b011'00000 | -#define SUB 0b100'00000 | -#define BRZ 0b101'00000 | -#define JMP 0b110'00000 | -#define STP 0b111'00000 - -static uint8_t execute(uint8_t program[], size_t sizeof_program) { - uint8_t mem[32]; - memcpy(mem, program, sizeof_program * sizeof(*program)); - for(uint8_t acc, pc = 0;; pc &= 0x1f) { - uint8_t oc = mem[pc++]; - uint8_t op = oc >> 5; - uint8_t oa = oc & 0x1f; - switch(op) { - case 0b000: - continue; - case 0b001: - acc = mem[oa]; - continue; - case 0b010: - mem[oa] = acc; - continue; - case 0b011: - acc += mem[oa]; - continue; - case 0b100: - acc -= mem[oa]; - continue; - case 0b101: - if(acc != 0) continue; - case 0b110: - pc = oa; - continue; - case 0b111: - return acc; - } - } -} - -int main(int argc, char **argv) { - printf(" 2+2: %"PRIu8"\n", EXECUTE( - LDA 3, - ADD 4, - STP , - 0, - 2, - 2 - )); - printf(" 7*8: %"PRIu8"\n", EXECUTE( - LDA 12, - ADD 10, - STA 12, - LDA 11, - SUB 13, - STA 11, - BRZ 8, - JMP 0, - LDA 12, - STP , - 8, - 7, - 0, - 1 - )); - printf(" fibonacci: %"PRIu8"\n", EXECUTE( - LDA 14, - STA 15, - ADD 13, - STA 14, - LDA 15, - STA 13, - LDA 16, - SUB 17, - BRZ 11, - STA 16, - JMP 0, - LDA 14, - STP , - 1, - 1, - 0, - 8, - 1 - )); - printf("linkedlist: %"PRIu8"\n", EXECUTE( - LDA 13, - ADD 15, - STA 5, - ADD 16, - STA 7, - NOP , - STA 14, - NOP , - BRZ 11, - STA 15, - JMP 0, - LDA 14, - STP , - LDA 0, - 0, - 28, - 1, - 0, - 0, - 0, - 6, - 0, - 2, - 26, - 5, - 20, - 3, - 30, - 1, - 22, - 4, - 24 - )); - printf(" prisoner: %"PRIu8"\n", EXECUTE( - NOP , - NOP , - STP , - 0, - LDA 3, - SUB 29, - BRZ 18, - LDA 3, - STA 29, - BRZ 14, - LDA 1, - ADD 31, - STA 1, - JMP 2, - LDA 0, - ADD 31, - STA 0, - JMP 2, - LDA 3, - STA 29, - LDA 1, - ADD 30, - ADD 3, - STA 1, - LDA 0, - ADD 30, - ADD 3, - STA 0, - JMP 2, - 0, - 1, - 3 - )); - return 0; -} diff --git a/Task/Execute-Computer-Zero/Delphi/execute-computer-zero.pas b/Task/Execute-Computer-Zero/Delphi/execute-computer-zero.delphi similarity index 100% rename from Task/Execute-Computer-Zero/Delphi/execute-computer-zero.pas rename to Task/Execute-Computer-Zero/Delphi/execute-computer-zero.delphi diff --git a/Task/Execute-Computer-Zero/EasyLang/execute-computer-zero.easy b/Task/Execute-Computer-Zero/EasyLang/execute-computer-zero.easy deleted file mode 100644 index 213c407e4a..0000000000 --- a/Task/Execute-Computer-Zero/EasyLang/execute-computer-zero.easy +++ /dev/null @@ -1,33 +0,0 @@ -proc run name$ mem[] . - write name$ & ": " - pc = 1 - len mem[] 32 - repeat - ppc = mem[pc] - op = ppc div 32 - addr = ppc mod 32 + 1 - pc += 1 - if op = 1 - acc = mem[addr] - elif op = 2 - mem[addr] = acc - elif op = 3 - acc = (acc + mem[addr]) mod 255 - elif op = 4 - acc = (acc - mem[addr]) mod 255 - elif op = 5 - if acc = 0 - pc = addr - . - elif op = 6 - pc = addr - . - until op = 7 or pc > 32 - . - print acc -. -run "2+2" [ 35 100 224 2 2 ] -run "7*8" [ 44 106 76 43 141 75 168 192 44 224 8 7 0 1 ] -run "Fibonacci" [ 46 79 109 78 47 77 48 145 171 80 192 46 224 1 1 0 8 1 ] -run "List" [ 45 111 69 112 71 0 78 0 171 79 192 46 224 32 0 28 1 0 0 0 6 0 2 26 5 20 3 30 1 22 4 24 ] -run "Prisoner" [ 0 0 224 0 0 35 157 178 35 93 174 33 127 65 194 32 127 64 192 35 93 33 126 99 ] diff --git a/Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic b/Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic deleted file mode 100644 index ba59ec50ab..0000000000 --- a/Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic +++ /dev/null @@ -1,120 +0,0 @@ -' Define the opcodes -Enum - NOP = 0 - LDA - STA - ADD - SUV - BRZ - JMP - STP -End Enum - -Function instr_(op As Ubyte, v As Ubyte) As Ubyte - Return (32 * op) + v -End Function - -Function NOP_(v As Ubyte) As Ubyte - Return instr_(NOP, v) -End Function - -Function LDA_(v As Ubyte) As Ubyte - Return instr_(LDA, v) -End Function - -Function STA_(v As Ubyte) As Ubyte - Return instr_(STA, v) -End Function - -Function ADD_(v As Ubyte) As Ubyte - Return instr_(ADD, v) -End Function - -Function SUB_(v As Ubyte) As Ubyte - Return instr_(SUV, v) -End Function - -Function BRZ_(v As Ubyte) As Ubyte - Return instr_(BRZ, v) -End Function - -Function JMP_(v As Ubyte) As Ubyte - Return instr_(JMP, v) -End Function - -Function STP_(v As Ubyte) As Ubyte - Return instr_(STP, v) -End Function - -Sub execute(nombre As String, program() As Ubyte) - ' Initialize memory and program counter - Dim As Ubyte m(Ubound(program)) - Dim As Short m_pos = -1 - - For i As Ubyte = Lbound(program) To Ubound(program) - m(m_pos + 1) = program(i) - m_pos += 1 - Next - - Dim As Boolean running = True - Dim As Ubyte pc = 0 - Dim As Ubyte a = 0 - Dim As Ubyte op - Dim As Ubyte operand - - While running - op = m(pc) \ 32 - operand = m(pc) Mod 32 - pc = (pc + 1) Mod 32 - - Select Case op - Case NOP - ' No operation - Case LDA - a = m(operand) - Case STA - m(operand) = a - Case ADD - a = (a + m(operand)) Mod 256 - If a > 255 Then a = 0 - Case SUV - a = (a - m(operand)) Mod 256 - If a < 0 Then a = 255 - Case BRZ - If a = 0 Then pc = operand - Case JMP - pc = operand - Case Else - ' Stop - running = False - Print Space(12 - Len(nombre)) & nombre & ": " & a - End Select - Wend -End Sub - -' Test programs -Dim poly1(4) As Ubyte = {LDA_(3), ADD_(4), STP_(0), 2, 2} -execute("2+2", poly1()) - -Dim poly2(13) As Ubyte = {LDA_(12), ADD_(10), STA_(12), LDA_(11), SUB_(13), STA_(11), BRZ_(8), JMP_(0), LDA_(12), STP_(0), 8, 7, 0, 1} -execute("7*8", poly2()) - -Dim poly3(0 To ...) As Ubyte = {LDA_(14), STA_(15), ADD_(13), STA_(14), LDA_(15), STA_(13), LDA_(16), SUB_(17), BRZ_(11), STA_(16), JMP_(0), LDA_(14), STP_(0), 1, 1, 0, 8, 1} -execute("fibonacci", poly3()) - -Dim poly4(0 To ...) As Ubyte = {LDA_(13), ADD_(15), STA_(5), ADD_(16), STA_(7), NOP_(0), STA_(14), NOP_(0), BRZ_(11), STA_(15), JMP_(0), LDA_(14), STP_(0), LDA_(0), 0, 28, 1, 0, 0, 0, 6, 0, 2, 26, 5, 20, 3, 30, 1, 22, 4, 24} -execute("linkedList", poly4()) - -Dim poly5(0 To ...) As Ubyte = {NOP_(0), NOP_(0), STP_(0), 0, LDA_(3), SUB_(29), BRZ_(18), LDA_(3), STA_(29), BRZ_(14), LDA_(1), ADD_(31), STA_(1), JMP_(2), LDA_(0), ADD_(31), STA_(0), JMP_(2), LDA_(3), STA_(29), LDA_(1), ADD_(30), ADD_(3), STA_(1), LDA_(0), ADD_(30), ADD_(3), STA_(0), JMP_(2), 0, 1, 3} -execute("prisoner", poly5()) - -Dim poly6(0 To ...) As Ubyte = {LDA_(3), SUB_(4), STP_(0), 0, 255} -execute("0-255", poly6()) - -Dim poly7(0 To ...) As Ubyte = {LDA_(3), SUB_(4), STP_(0), 0, 1} -execute("0-1", poly7()) - -Dim poly8(0 To ...) As Ubyte = {LDA_(3), ADD_(4), STP_(0), 1, 255} -execute("1+255", poly8()) - -Sleep diff --git a/Task/Execute-Computer-Zero/Jq/execute-computer-zero.jq b/Task/Execute-Computer-Zero/Jq/execute-computer-zero.jq deleted file mode 100644 index db6265f630..0000000000 --- a/Task/Execute-Computer-Zero/Jq/execute-computer-zero.jq +++ /dev/null @@ -1,75 +0,0 @@ -### Utility -def trim: sub("^ +";"") | sub(" +$";""); - -### Computer/Zero -def NOP: 0; -def LDA: 1; -def STA: 2; -def ADD: 3; -def SUB: 4; -def BRZ: 5; -def JMP: 6; -def STP: 7; - -def ops: {"NOP": NOP, "LDA": LDA, "STA": STA, "ADD": ADD, - "SUB": SUB, "BRZ": BRZ, "JMP": JMP, "STP": STP}; - -# Input: the program in the form of an array of strings, -# each string corresponding to an input line of the form -# "INSTR N" or "N" -# Output: an array of integers -def load: - map([splits(" *")] as $split - | $split[0] as $instr - | (if ($split|length == 2) then $split[1]|tonumber - else 0 - end) as $addr - | if ops[$instr] - then ops[$instr] * 32 + $addr - else try ($instr|tonumber) catch 0 - end ); - -# input: an array as produced by `load` -def interp: - { acc: 0, pc: 0, mem: .} - | until(.break; - (.mem[.pc] % 32) as $addr - | ((.mem[.pc] - $addr) / 32) as $instr - | .pc += 1 - | if $instr == LDA then .acc = .mem[$addr] - elif $instr == STA then .mem[$addr] = .acc - elif $instr == ADD then .acc += .mem[$addr] - | if .acc > 255 then .acc += -256 else . end - elif $instr == SUB then .acc += (- .mem[$addr]) - | if .acc < 0 then .acc += 256 else . end - elif $instr == BRZ - then if .acc == 0 then .pc = $addr else . end - elif $instr == JMP then .pc = $addr - else . - end - | .break = $instr == STP or .pc > 31 ) - | .acc; - -# Assume the input file consists of several programs, each structured as: -# ; program name -# one instruction per line -# -def task: - def init: map_values(null); - - foreach (inputs, null) as $line ({}; - if $line == null then .program = .buffer - elif $line[0:1] == ";" then init | .title = $line - else ($line|trim) as $line - | if $line == "" then .program = .buffer | .buffer = [] - else .buffer += [$line] - end - end) - | .title as $title - | .program - | if length == 0 then empty - else - $title, (load|interp) - end ; - -task diff --git a/Task/Execute-Computer-Zero/Julia/execute-computer-zero-1.jl b/Task/Execute-Computer-Zero/Julia/execute-computer-zero-1.julia similarity index 100% rename from Task/Execute-Computer-Zero/Julia/execute-computer-zero-1.jl rename to Task/Execute-Computer-Zero/Julia/execute-computer-zero-1.julia diff --git a/Task/Execute-Computer-Zero/Julia/execute-computer-zero-2.jl b/Task/Execute-Computer-Zero/Julia/execute-computer-zero-2.julia similarity index 100% rename from Task/Execute-Computer-Zero/Julia/execute-computer-zero-2.jl rename to Task/Execute-Computer-Zero/Julia/execute-computer-zero-2.julia diff --git a/Task/Execute-Computer-Zero/M2000-Interpreter/execute-computer-zero.m2000 b/Task/Execute-Computer-Zero/M2000-Interpreter/execute-computer-zero.m2000 deleted file mode 100644 index 90e8e54763..0000000000 --- a/Task/Execute-Computer-Zero/M2000-Interpreter/execute-computer-zero.m2000 +++ /dev/null @@ -1,155 +0,0 @@ -module Execute_Computer_Zero{ - global byte MEM[31]=0XFF, PC=0 - module ZERO (program$, f=-2, showrun, skipreadcode){ - Enum Commands { - NOP=0X0, LDA=0X20, STA=0X40, ADD=0X60, SUB=0X80, BRZ=0XA0, JMP=0XC0, STP=0XE0 - } - if skipreadcode then goto cont1 - PC<=0 - dim code$() - var crlf=chr$(13)+chr$(10) ' CRLF - var prname$="Program #1" - program$=replace$(chr$(9)," ", program$) - program$=replace$(",",crlf, program$) - program$=ucase$(filter$(program$, "().")) - code$()=piece$(program$, crlf) - document source$ - for I=0 to len(code$())-1 - tok$=trim$(LeftPart$(trim$(code$(I))+" ", " ")) - part$=trim$(RightPart$(trim$(code$(I))+" 0", " ")) - val=val(part$) MOD 32 - ch$=left$(tok$,1) - c=0 - if ch$="#" then - prname$=mid$(trim$(code$(I)), 2) - continue - end if - tok$=filter$(tok$, "+-_x!@#$%^&*/|><") - if ch$>="0" and ch$<="9" then - val=int(val(tok$)) mod 256 - source$ =" "+hex$(PC, 1)+" "+hex$(val,1)+crlf - else.if tok$="" then - continue - else.if valid(eval(tok$)) then - c=eval(tok$) - source$ =" "+hex$(PC, 1)+" "+tok$+" "+hex$(val,1)+crlf - end if - MEM[PC]<=c+VAL - PC++ - next - Print #f, "Program Name:";prname$ - Print #f, source$; - Print #f, "Program Length ";PC;"bytes" - PC<=0 -cont1: - byte A=0, ADDR=0 - structure Accumulator { - { A as Byte, Overflow as Byte - } - R as Integer - } - Accumulator AC - CM=STP - if showrun then Print #f, "PC MEM COM ADDR AC" - do - if inkey$=" " then Print "Break": exit - A=MEM[PC] - ADDR=A MOD 32 - CM=A-ADDR - if showrun then Print #f, Hex$(PC,1);" ";hex$(A,1);" ";EVAL$(CM);" ";hex$(ADDR, 1);" ";Hex$(AC|A, 1) - select case CM - case NOP - PC++ : PC|MOD 32 - case LDA - AC|R=MEM[ADDR]:PC++ : PC|MOD 32 - case STA - MEM[ADDR]<=AC|A : PC++ : PC|MOD 32 - case ADD - AC|R=AC|R+MEM[ADDR]:PC++ : PC|MOD 32 - case SUB - AC|R=uint(AC|R-MEM[ADDR]): PC++ : PC|MOD 32 - case BRZ - { - if AC|A then - PC++ : PC|MOD 32 - if showrun then Print #f, "NON ZERO - CONTINUE" - else - PC<=A MOD 32 - if showrun then Print #f, "BRANCH TO ";PC - end if - } - case JMP - PC<=A MOD 32:if showrun then Print #f, "JUMP TO ";PC - case STP - exit - end select - always - if skipreadcode else - Print #f, "STOP AT ";hex$(PC,1) - Print #f, "RESULT:";AC|A;"|0x";hex$(AC|A, 1) - Print #f, "NEGATIVE:"; IF$(AC|A>126->"1","0") - Print #f, "OVERFLOW:"; IF$(AC|Overflow>0->"1","0") - Print #f - end if - } - Flush - Data { - #add 2 - LDA 3, ADD 4, STP 0, 2, 2 - } - Data {#fibonacci - LDA 14, STA 15, ADD 13, STA 14, - LDA 15, STA 13, LDA 16, SUB 17, - BRZ 11, STA 16, JMP 0, LDA 14, - STP 0, 1, 1, 0 , 8, 1 - } - Data {#8*7 - LDA 12, ADD 10, STA 12, LDA 11, SUB 13, - STA 11, BRZ 8, JMP 0, LDA 12, STP 0, - 8, 7, 0, 1 - } - Data {#linkedList - LDA 13, ADD 15, STA 5, ADD 16, STA 7, NOP 0, STA 14, NOP 0 - , BRZ 11, STA 15, JMP 0, LDA 14, STP 0, LDA 0, 0, 28 - , 1, 0, 0, 0, 6, 0, 2, 26 - , 5, 20, 3, 30, 1, 22, 4, 24 - } - Data { #0-255 - LDA 3, SUB 4, STP 0, 0, 255 - } - Data {#0-1 - LDA 3, SUB 4, STP 0, 0, 1 - } - Data {#1+255 - LDA 3, ADD 4, STP 0, 1, 255 - } - filename="run01.txt" - open filename for wide output as #d - while not empty - Zero letter$, d, false, false - end while - Zero { #prisoner - NOP 0, NOP 0, STP 0, 0, LDA 3, SUB 29, BRZ 18, LDA 3 - , STA 29, BRZ 14, LDA 1, ADD 31, STA 1, JMP 2, LDA 0, ADD 31 - , STA 0, JMP 2, LDA 3, STA 29, LDA 1, ADD 30, ADD 3, STA 1 - , LDA 0, ADD 30, ADD 3, STA 0, JMP 2, 0, 1, 3 - }, d, false, false - - Enum Action {cooperate=0UB, defect} - byte AcA - PM=defect - for i=1 to 5 - Print #d, "Round ";i;" ";field$(eval$(PM), 10); - PC++ - mem[PC]<=pm - IF PM=cooperate THEN PM++ ELSE PM-- - PC++ - Zero {}, d, false, true - Read AcA - Print #d, "Player:";mem[0], " Computer:";mem[1] - next - close #d - if filename<>"" then win dir$+filename - -} -Execute_Computer_Zero diff --git a/Task/Execute-Computer-Zero/Perl/execute-computer-zero.pl b/Task/Execute-Computer-Zero/Perl/execute-computer-zero.pl deleted file mode 100644 index a03710fef7..0000000000 --- a/Task/Execute-Computer-Zero/Perl/execute-computer-zero.pl +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/perl - -use strict; # https://rosettacode.org/wiki/Execute_Computer/Zero -use warnings; -$SIG{__WARN__} = sub { die @_ }; - -my ($pc, $acc, $op, $addr, $mem, %ops, @memory, $program); -@ops{qw( NOP LDA STA ADD SUB BRZ JMP STP )} = map $_ << 5, 0 .. 7; -my $codes = qr/(?:@{[join '|', keys %ops ]})/; -my @inst = (sub {}, map eval "sub {$_}", split /\n/, <<'END' =~ s/#.*//gr); -$acc = $memory[$addr] # LDA -$memory[$addr] = $acc # STA -$acc = $acc + $memory[$addr] & 0xff # ADD -$acc = $acc - $memory[$addr] & 0xff # SUB -$acc or $pc = $addr # BRZ -$pc = $addr # JMP -END - -sub assemble - { - local $_ = join '', @_; # pass in array of lines or one multi-line string - $program = /;(.*)/ ? " $1" : ''; - my %labels; - @memory = (0) x 32; - s/^([a-z]\w*):/ $labels{$1} = $` =~ tr~\n~~; '' /igem; - $memory[$` =~ tr/\n//] = $1 - ? $ops{$1} | ($labels{$2 // ''} // $2 // 0) & 0b00011111 - : ($labels{$2 // ''} // $2 // 0) & 0xff - while /^\h*($codes)?(?:\h*(\b\w+))?/gm; - } - -sub run - { - $pc = $acc = 0; - $inst[$op]() while $mem = $memory[$pc], - ($op, $addr, $pc) = ($mem >> 5, $mem & 0x1f, $pc + 1 & 0b00011111), - $op < 7; - return $acc; - } - -for ( map s/\s+\z/\n/r, do { local $/ = ''; } ) - { -# print; - assemble( $_ ); - print '*' x 20," STP with acc = ", run(), "$program\n\n"; - } - -__DATA__ - LDA x ; first example program 2 + 2 - ADD y - STP -x: 2 -y: 2 - -loop: LDA a ; second example program 7 * 8 - BRZ end - SUB one - STA a - LDA prod - ADD b - STA prod - JMP loop -end: LDA prod - STP -a: 7 -b: 8 -prod: 0 -one: 1 - -loop: LDA count ; Fibonacci - BRZ end - SUB one - STA count - LDA a - ADD b - STA temp - LDA b - STA a - LDA temp - STA b - JMP loop -end: LDA b - STP -one: 1 -a: 1 -b: 1 -temp: 0 -count: 8 - -start: LDA load ; linked list - ADD car ; head of list - STA ldcar - ADD one - STA ldcdr ; next CONS cell -ldcar: NOP - STA value -ldcdr: NOP - BRZ done ; 0 stands for NIL - STA car - JMP start -done: LDA value ; CAR of last CONS - STP -load: LDA 0 -value: 0 -car: begin -one: 1 - ; order of CONS cells - ; in memory - ; does not matter - 6 - 0 ; 0 stands for NIL - 2 ; (CADR ls) - 26 ; (CDDR ls) -- etc. - 5 - 20 - 3 - 30 -begin: 1 ; value of (CAR ls) - 22 ; points to (CDR ls) - 4 - 24 - -p: 0 ; NOP in first round Prisoner's Dilemma -c: 0 -start: STP ; wait for p's move -pmove: NOP - LDA pmove - SUB cmove - BRZ same - LDA pmove - STA cmove ; tit for tat - BRZ cdeft - LDA c ; p defected, c did not - ADD three - STA c - JMP start -cdeft: LDA p - ADD three - STA p - JMP start -same: LDA pmove - STA cmove ; tit for tat - LDA p - ADD one - ADD pmove - STA p - LDA c - ADD one - ADD pmove - STA c - JMP start -cmove: 0 ; co-operate initially -one: 1 -three: 3 diff --git a/Task/Execute-Computer-Zero/Phix/execute-computer-zero.phix b/Task/Execute-Computer-Zero/Phix/execute-computer-zero.phix index 7ac5ab0ca6..6c53110702 100644 --- a/Task/Execute-Computer-Zero/Phix/execute-computer-zero.phix +++ b/Task/Execute-Computer-Zero/Phix/execute-computer-zero.phix @@ -1,51 +1,53 @@ -with javascript_semantics -constant NOP = 0b000_00000, -- no operation - LDA = 0b001_00000, -- load accumulator, a := memory [xxxxx] - STA = 0b010_00000, -- store accumulator, memory [xxxxx] := a - ADD = 0b011_00000, -- add, a := a + memory [xxxxx] - SUB = 0b100_00000, -- subtract, a := a – memory [xxxxx] - BRZ = 0b101_00000, -- branch on zero, if a = 0 then goto xxxxx - JMP = 0b110_00000, -- jump, goto xxxxx - STP = 0b111_00000, -- stop - OP = 0b111_00000, -- operator mask - ARG = 0b000_11111 -- memory location (0 based) +(phixonline)--> + with javascript_semantics + constant NOP = 0b000_00000, -- no operation + LDA = 0b001_00000, -- load accumulator, a := memory [xxxxx] + STA = 0b010_00000, -- store accumulator, memory [xxxxx] := a + ADD = 0b011_00000, -- add, a := a + memory [xxxxx] + SUB = 0b100_00000, -- subtract, a := a – memory [xxxxx] + BRZ = 0b101_00000, -- branch on zero, if a = 0 then goto xxxxx + JMP = 0b110_00000, -- jump, goto xxxxx + STP = 0b111_00000, -- stop + OP = 0b111_00000, -- operator mask + ARG = 0b000_11111 -- memory location (0 based) -procedure execute(string name, sequence program) - sequence memory = deep_copy(program) - integer pc = 1, a = 0 - while true do - integer ppc = memory[pc], - op = and_bitsu(ppc,OP), - arg = and_bits(ppc,ARG)+1 - pc += 1 - switch op do - case NOP: break - case LDA: a = memory[arg] - case STA: memory[arg] = a - case ADD: a = and_bitsu(a+memory[arg],#FF) - case SUB: a = and_bitsu(a-memory[arg],#FF) - case BRZ: if a=0 then pc = arg end if - case JMP: pc = arg - case STP: printf(1,"%12s: %3d\n",{name,a}) - return - end switch - end while -end procedure + procedure execute(string name, sequence program) + sequence memory = deep_copy(program) + integer pc = 1, a = 0 + while true do + integer ppc = memory[pc], + op = and_bitsu(ppc,OP), + arg = and_bits(ppc,ARG)+1 + pc += 1 + switch op do + case NOP: break + case LDA: a = memory[arg] + case STA: memory[arg] = a + case ADD: a = and_bitsu(a+memory[arg],#FF) + case SUB: a = and_bitsu(a-memory[arg],#FF) + case BRZ: if a=0 then pc = arg end if + case JMP: pc = arg + case STP: printf(1,"%12s: %3d\n",{name,a}) + return + end switch + end while + end procedure -execute("2+2",{LDA+3, ADD+4, STP, 2,2}) -execute("7*8",{LDA+12, ADD+10, STA+12, LDA+11, SUB+13, STA+11, BRZ+8, JMP+0, - LDA+12, STP, 8,7,0,1}) -execute("fibonacci",{LDA+14, STA+15, ADD+13, STA+14, LDA+15, STA+13, LDA+16, - SUB+17, BRZ+11, STA+16, JMP+0, LDA+14, STP, 1,1,0,8,1}) -execute("linkedList",{LDA+13, ADD+15, STA+5, ADD+16, STA+7, NOP, STA+14, NOP, - BRZ+11, STA+15, JMP+0, LDA+14, STP, LDA+0, 0,28,1,0,0, - 0,6,0,2,26,5,20,3,30,1,22,4,24}) -execute("prisoner",{NOP, NOP, STP, 0, LDA+3, SUB+29, BRZ+18, LDA+3, STA+29, - BRZ+14, LDA+1, ADD+31, STA+1, JMP+2, LDA+0, ADD+31, STA+0, - JMP+2, LDA+3, STA+29, LDA+1, ADD+30, ADD+3, STA+1, LDA+0, - ADD+30, ADD+3, STA+0, JMP+2, 0, 1, 3}) --- subtractions yielding negative results -execute("0-255",{LDA+3,SUB+4,STP, 0,255}) -execute("0-1",{LDA+3, SUB+4, STP, 0,1}) --- overflow on addition -execute("1+255",{LDA+3, ADD+4, STP, 1, 255}) + execute("2+2",{LDA+3, ADD+4, STP, 2,2}) + execute("7*8",{LDA+12, ADD+10, STA+12, LDA+11, SUB+13, STA+11, BRZ+8, JMP+0, + LDA+12, STP, 8,7,0,1}) + execute("fibonacci",{LDA+14, STA+15, ADD+13, STA+14, LDA+15, STA+13, LDA+16, + SUB+17, BRZ+11, STA+16, JMP+0, LDA+14, STP, 1,1,0,8,1}) + execute("linkedList",{LDA+13, ADD+15, STA+5, ADD+16, STA+7, NOP, STA+14, NOP, + BRZ+11, STA+15, JMP+0, LDA+14, STP, LDA+0, 0,28,1,0,0, + 0,6,0,2,26,5,20,3,30,1,22,4,24}) + execute("prisoner",{NOP, NOP, STP, 0, LDA+3, SUB+29, BRZ+18, LDA+3, STA+29, + BRZ+14, LDA+1, ADD+31, STA+1, JMP+2, LDA+0, ADD+31, STA+0, + JMP+2, LDA+3, STA+29, LDA+1, ADD+30, ADD+3, STA+1, LDA+0, + ADD+30, ADD+3, STA+0, JMP+2, 0, 1, 3}) + -- subtractions yielding negative results + execute("0-255",{LDA+3,SUB+4,STP, 0,255}) + execute("0-1",{LDA+3, SUB+4, STP, 0,1}) + -- overflow on addition + execute("1+255",{LDA+3, ADD+4, STP, 1, 255}) + n ) - [ 1 ] is LDA ( --> n ) - [ 2 ] is STA ( --> n ) - [ 3 ] is ADD ( --> n ) - [ 4 ] is SUB ( --> n ) - [ 5 ] is BRZ ( --> n ) - [ 6 ] is JMP ( --> n ) - [ 7 ] is STP ( --> n ) - - [ 0 ] is DATA ( --> n ) - [ 0 ] is -- ( --> n ) - - [ stack 0 ] is acc ( --> s ) - [ stack 0 ] is ip ( --> s ) - [ stack false ] is flag ( --> n ) - - [ 0 ip replace 0 32 of ] is computer/zero ( --> [ ) - - [ 255 & swap 5 << | - swap ip share poke - 1 ip tally ] is , ( [ --> [ ) - - [ drop ] is nop ( [ n --> [ ) - - [ dip dup peek acc replace ] is lda ( [ n --> [ ) - - [ acc share unrot poke ] is sta ( [ n --> [ ) - - [ dip dup peek - acc take + 255 & acc put ] is add ( [ n --> [ ) - - [ dip dup peek negate - acc take + 255 & acc put ] is sub ( [ n --> [ ) - - [ acc share iff drop done - ip replace ] is brz ( [ n --> [ ) - - [ ip replace ] is jmp ( [ n --> [ ) - - [ drop true flag replace ] is stp ( [ n --> [ ) - - [ false flag replace - 0 acc replace - 0 ip replace - [ dup ip share peek - 1 ip tally - dup 31 & swap 5 >> - [ table - nop lda sta add - sub brz jmp stp ] do - flag share until ] - drop - acc share - say "acc = " dup echo - dup 128 & iff - [ say " or " - 127 ~ | echo ] - else drop cr ] is execute ( [ --> ) - - cr say " 2+2: " - computer/zero - ( 00 ) LDA 03 , - ( 01 ) ADD 04 , - ( 02 ) STP -- , - ( 03 ) DATA 2 , - ( 04 ) DATA 2 , - execute - cr say " 7*8: " - computer/zero - ( 00 ) LDA 12 , - ( 01 ) ADD 10 , - ( 02 ) STA 12 , - ( 03 ) LDA 11 , - ( 04 ) SUB 13 , - ( 05 ) STA 11 , - ( 06 ) BRZ 08 , - ( 07 ) JMP 00 , - ( 08 ) LDA 12 , - ( 09 ) STP -- , - ( 10 ) DATA 8 , - ( 11 ) DATA 7 , - ( 12 ) DATA 0 , - ( 13 ) DATA 1 , - execute - cr say " Fibonacci: " - computer/zero - ( 00 ) LDA 14 , - ( 01 ) STA 15 , - ( 02 ) ADD 13 , - ( 03 ) STA 14 , - ( 04 ) LDA 15 , - ( 05 ) STA 13 , - ( 06 ) LDA 16 , - ( 07 ) SUB 17 , - ( 08 ) BRZ 11 , - ( 09 ) STA 16 , - ( 10 ) JMP 00 , - ( 11 ) LDA 14 , - ( 12 ) STP -- , - ( 13 ) DATA 1 , - ( 14 ) DATA 1 , - ( 15 ) DATA 0 , - ( 16 ) DATA 8 , - ( 17 ) DATA 1 , - execute - cr say "linked list: " - computer/zero - ( 00 ) LDA 13 , - ( 01 ) ADD 15 , - ( 02 ) STA 05 , - ( 03 ) ADD 16 , - ( 04 ) STA 07 , - ( 05 ) NOP -- , - ( 06 ) STA 14 , - ( 07 ) NOP -- , - ( 08 ) BRZ 11 , - ( 09 ) STA 15 , - ( 10 ) JMP 00 , - ( 11 ) LDA 14 , - ( 12 ) STP -- , - ( 13 ) LDA 00 , - ( 14 ) DATA 0 , - ( 15 ) DATA 28 , - ( 16 ) DATA 1 , - ( 17 ) DATA 0 , - ( 18 ) DATA 0 , - ( 19 ) DATA 0 , - ( 20 ) DATA 6 , - ( 21 ) DATA 0 , - ( 22 ) DATA 2 , - ( 23 ) DATA 26 , - ( 24 ) DATA 5 , - ( 25 ) DATA 20 , - ( 26 ) DATA 3 , - ( 27 ) DATA 30 , - ( 28 ) DATA 1 , - ( 29 ) DATA 22 , - ( 30 ) DATA 4 , - ( 31 ) DATA 24 , - execute - cr say " prisoner: " - computer/zero - ( 00 ) NOP -- , - ( 01 ) NOP -- , - ( 02 ) STP -- , - ( 03 ) NOP -- , - ( 04 ) LDA 03 , - ( 05 ) SUB 29 , - ( 06 ) BRZ 18 , - ( 07 ) LDA 03 , - ( 08 ) STA 29 , - ( 09 ) BRZ 14 , - ( 10 ) LDA 01 , - ( 11 ) ADD 31 , - ( 12 ) STA 01 , - ( 13 ) JMP 02 , - ( 14 ) LDA 00 , - ( 15 ) ADD 31 , - ( 16 ) STA 00 , - ( 17 ) JMP 02 , - ( 18 ) LDA 03 , - ( 19 ) STA 29 , - ( 20 ) LDA 01 , - ( 21 ) ADD 30 , - ( 22 ) ADD 03 , - ( 23 ) STA 01 , - ( 24 ) LDA 00 , - ( 25 ) ADD 30 , - ( 26 ) ADD 03 , - ( 27 ) STA 01 , - ( 28 ) JMP 02 , - ( 29 ) DATA 0 , - ( 30 ) DATA 1 , - ( 31 ) DATA 3 , - execute diff --git a/Task/Execute-HQ9+/11l/execute-hq9+.11l b/Task/Execute-HQ9+/11l/execute-hq9+.11l index 61c3364c3b..f78b71196e 100644 --- a/Task/Execute-HQ9+/11l/execute-hq9+.11l +++ b/Task/Execute-HQ9+/11l/execute-hq9+.11l @@ -38,7 +38,7 @@ F incr() :start: src = File(:argv[1]).read() -[Char = (() -> Void)] dispatch +[Char = (() -> N)] dispatch dispatch[Char(‘h’)] = hello dispatch[Char(‘q’)] = quine dispatch[Char(‘9’)] = bottles diff --git a/Task/Execute-HQ9+/Arturo/execute-hq9+.arturo b/Task/Execute-HQ9+/Arturo/execute-hq9+.arturo index ea2365d299..6e897e33d0 100644 --- a/Task/Execute-HQ9+/Arturo/execute-hq9+.arturo +++ b/Task/Execute-HQ9+/Arturo/execute-hq9+.arturo @@ -1,12 +1,13 @@ hq9: function [source][ acc: 0 loop split source 'ch [ - case lower ch [ - "h" -> print "Hello, world!" - "q" -> print source - "9" -> print "99 bottles here ..." - "+" -> acc: acc+1 - ] + case [(lower ch)=] + when? ["h"]-> print "Hello, world!" + when? ["q"]-> print source + when? ["9"]-> print "99 bottles here ..." + when? ["+"]-> acc: acc+1 + else [] + ] return acc ] diff --git a/Task/Execute-HQ9+/COBOL/execute-hq9+.cob b/Task/Execute-HQ9+/COBOL/execute-hq9+.cobol similarity index 100% rename from Task/Execute-HQ9+/COBOL/execute-hq9+.cob rename to Task/Execute-HQ9+/COBOL/execute-hq9+.cobol diff --git a/Task/Execute-HQ9+/Delphi/execute-hq9+.pas b/Task/Execute-HQ9+/Delphi/execute-hq9+.delphi similarity index 100% rename from Task/Execute-HQ9+/Delphi/execute-hq9+.pas rename to Task/Execute-HQ9+/Delphi/execute-hq9+.delphi diff --git a/Task/Execute-HQ9+/EasyLang/execute-hq9+.easy b/Task/Execute-HQ9+/EasyLang/execute-hq9+.easy deleted file mode 100644 index 95fb45691e..0000000000 --- a/Task/Execute-HQ9+/EasyLang/execute-hq9+.easy +++ /dev/null @@ -1,21 +0,0 @@ -proc run code$ . - for c$ in strchars code$ - if c$ = "Q" - print code$ - elif c$ = "H" - print "Hello, world!" - elif c$ = "9" - for b = 99 downto 1 - print b & " bottles of beer on the wall" - print b & " bottles of beer" - print "Take one down, pass it around" - print b & " bottles of beer on the wall" - print "" - . - elif c$ = "+" - acc += 1 - print acc - . - . -. -run "HQ9+" diff --git a/Task/Execute-HQ9+/Free-Pascal-Lazarus/execute-hq9+.pas b/Task/Execute-HQ9+/Free-Pascal/execute-hq9+.pas similarity index 100% rename from Task/Execute-HQ9+/Free-Pascal-Lazarus/execute-hq9+.pas rename to Task/Execute-HQ9+/Free-Pascal/execute-hq9+.pas diff --git a/Task/Execute-HQ9+/Haxe/execute-hq9+.hx b/Task/Execute-HQ9+/Haxe/execute-hq9+.haxe similarity index 100% rename from Task/Execute-HQ9+/Haxe/execute-hq9+.hx rename to Task/Execute-HQ9+/Haxe/execute-hq9+.haxe diff --git a/Task/Execute-HQ9+/Julia/execute-hq9+.jl b/Task/Execute-HQ9+/Julia/execute-hq9+.julia similarity index 100% rename from Task/Execute-HQ9+/Julia/execute-hq9+.jl rename to Task/Execute-HQ9+/Julia/execute-hq9+.julia diff --git a/Task/Execute-HQ9+/Kotlin/execute-hq9+.kts b/Task/Execute-HQ9+/Kotlin/execute-hq9+.kotlin similarity index 100% rename from Task/Execute-HQ9+/Kotlin/execute-hq9+.kts rename to Task/Execute-HQ9+/Kotlin/execute-hq9+.kotlin diff --git a/Task/Execute-HQ9+/OCaml/execute-hq9+.ml b/Task/Execute-HQ9+/OCaml/execute-hq9+.ocaml similarity index 100% rename from Task/Execute-HQ9+/OCaml/execute-hq9+.ml rename to Task/Execute-HQ9+/OCaml/execute-hq9+.ocaml diff --git a/Task/Execute-HQ9+/PowerShell/execute-hq9+.ps1 b/Task/Execute-HQ9+/PowerShell/execute-hq9+.psh similarity index 100% rename from Task/Execute-HQ9+/PowerShell/execute-hq9+.ps1 rename to Task/Execute-HQ9+/PowerShell/execute-hq9+.psh diff --git a/Task/Execute-HQ9+/R/execute-hq9+.r b/Task/Execute-HQ9+/R/execute-hq9+.r deleted file mode 100644 index 10b02e4152..0000000000 --- a/Task/Execute-HQ9+/R/execute-hq9+.r +++ /dev/null @@ -1,25 +0,0 @@ -library(stringr) - -bottles <- function(){ - s <- function(n) ifelse(n==1, "", "s") - z <- function(n) ifelse(n==0, "No more", n) - cat(sapply(99:1, function(n) str_glue("{n} bottle{s(n)} of beer on the wall,\n", - "{n} bottle{s(n)} of beer,\n", - "Take one down, pass it around,\n", - "{z(n-1)} bottle{s(n-1)} of beer on the wall.")), sep="\n") -} - -hq9plus <- function(s){ - accumulator <- 0 - chars <- str_split_1(str_to_upper(s),"") - for(char in chars){ - switch(char, - "H"=cat("Hello World!","\n"), - "Q"=cat(s, "\n"), - "9"=bottles(), - "+"=eval(accumulator <- accumulator+1)) - } - cat("The value of the accumulator is", accumulator) -} - -hq9plus(readline()) diff --git a/Task/Execute-HQ9+/Rust/execute-hq9+.rs b/Task/Execute-HQ9+/Rust/execute-hq9+.rust similarity index 100% rename from Task/Execute-HQ9+/Rust/execute-hq9+.rs rename to Task/Execute-HQ9+/Rust/execute-hq9+.rust diff --git a/Task/Execute-HQ9+/V-(Vlang)/execute-hq9+.v b/Task/Execute-HQ9+/V-(Vlang)/execute-hq9+.v deleted file mode 100644 index eb112af6de..0000000000 --- a/Task/Execute-HQ9+/V-(Vlang)/execute-hq9+.v +++ /dev/null @@ -1,31 +0,0 @@ -fn eval(code string) { - mut accumulator := 0 - for cal in code.trim_space().to_lower() { - match cal { - `h` { println("Hello, world!") } - `q` { println(code) } - `9` { - bottles := fn (ir int) string { - match ir { - 0 { return "No bottles" } - 1 { return "One bottle" } - else { return "$ir bottles" } - } - } - for ir := 99; ir >= 1; ir-- { - println("${bottles(ir)} of beer on the wall,") - println("${bottles(ir)} of beer,") - println("take one down and pass it around,") - println("${bottles(ir - 1)} of beer on the wall!") - println("") - } - } - `+` { accumulator++ } - else { println("syntax error") } - } - } -} - -fn main() { - eval("hq9+") -} diff --git a/Task/Execute-SNUSP/11l/execute-snusp.11l b/Task/Execute-SNUSP/11l/execute-snusp.11l index 3180c22226..5bf2bdb258 100644 --- a/Task/Execute-SNUSP/11l/execute-snusp.11l +++ b/Task/Execute-SNUSP/11l/execute-snusp.11l @@ -40,7 +40,7 @@ F snusp(store, code) ‘,’ ds[dp] = Byte(:stdin.read(1).code) ‘/’ - id = ~id + id = (-)id ‘\’ id (+)= 1 ‘!’ diff --git a/Task/Execute-SNUSP/EasyLang/execute-snusp.easy b/Task/Execute-SNUSP/EasyLang/execute-snusp.easy deleted file mode 100644 index 05ac014346..0000000000 --- a/Task/Execute-SNUSP/EasyLang/execute-snusp.easy +++ /dev/null @@ -1,59 +0,0 @@ -proc snusp dlen raw$ . - len ds[] dlen - is$[] = strsplit raw$ "\n" - for s$ in is$[] - is$[][] &= strchars s$ - . - for ipr to len is$[][] - for ipc to len is$[ipr][] - if is$[ipr][ipc] = "$" : break 2 - . - . - dp = 1 - id = 0 - # - subr step - if id mod 2 = 0 - ipc += 1 - bitand id 2 - else - ipr += 1 - bitand id 2 - . - . - while ipr >= 1 and ipr <= len is$[][] and ipc >= 1 and ipc <= len is$[ipr][] - c$ = is$[ipr][ipc] - if c$ = ">" - dp += 1 - elif c$ = "<" - dp -= 1 - elif c$ = "+" - ds[dp] += 1 - elif c$ = "-" - ds[dp] -= 1 - elif c$ = "." - write strchar ds[dp] - elif c$ = "," - # ds[dp] = strcode input - elif c$ = "/" - id = bitxor id 3 - elif c$ = "\\" - id = bitxor id 1 - elif c$ = "!" - step - elif c$ = "?" - if ds[dp] = 0 : step - . - step - . -. -s$ = input -while s$ <> "" - cod$ &= "\n" & s$ - s$ = input -. -snusp 5 cod$ -# -input_data -/++++!/===========?\>++.>+.+++++++..+++\ -\+++\ | /+>+++++++>/ /++++++++++<<.++>./ -$+++/ | \+++++++++>\ \+++++.>.+++.-----\ - \==-<<<<+>+++/ /=.>.+>.--------.-/ diff --git a/Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic b/Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic deleted file mode 100644 index 2a3ce48e9f..0000000000 --- a/Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic +++ /dev/null @@ -1,77 +0,0 @@ -' Rosetta Code problem: https://rosettacode.org/wiki/Execute_SNUSP -' by Jjuanhdez, 05/2024 -' The interpreter below implements Core SNUSP: - -Const HW = "/++++!/===========?\>++.>+.+++++++..+++" & Chr(10) & _ -"\+++\ | /+>+++++++>/ /++++++++++<<.++>./" & Chr(10) & _ -"$+++/ | \+++++++++>\ \+++++.>.+++.-----\" & Chr(10) & _ -" \==-<<<<+>+++/ /=.>.+>.--------.-/" - -Dim Shared As Integer ipf, ipc ' instruction pointers in row and column -Dim Shared As Integer direcc ' direction (0 = right, 1 = down, 2 = left, 3 = up) - -Sub Paso() - If direcc And 1 Then - ipf += 1 - (direcc And 2) - Else - ipc += 1 - (direcc And 2) - End If -End Sub - -Sub SNUSP (dsLen As Integer, SNUSPcode As String) - Dim As Ubyte ad(dsLen - 1) ' data store - Dim As Integer dp ' data pointer - Dim As String cb(dsLen) ' two-way code storage - Dim As String fila, op, linea - Dim As Integer r, i, j - - dp = 0 - i = 1 - j = 1 - ipf = 0 - ipc = 0 - direcc = 0 - - While i <= Len(SNUSPcode) - If Mid(SNUSPcode, i, 1) = Chr(10) Then - cb(j) = linea - linea = "" - j += 1 - Else - linea &= Mid(SNUSPcode, i, 1) - End If - i += 1 - Wend - cb(j) = linea - - For r = 0 To Ubound(cb) - fila = cb(r) - ipc = Instr(fila, "$") - 1 - If ipc >= 0 Then - ipf = r - Exit For - End If - Next r - - While ipf >= 0 And ipf <= Ubound(cb) And ipc >= 0 And ipc < Len(cb(ipf)) - op = Mid(cb(ipf), ipc + 1, 1) - Select Case op - Case ">": dp += 1 ' RIGTH - Case "<": dp -= 1 ' LEFT - Case "+": ad(dp) += 1 ' INCR - Case "-": ad(dp) -= 1 ' DECR - Case ",": Input ad(dp) ' READ - Case ".": Print Chr(ad(dp)); ' WRITE - Case "/": direcc = Not direcc ' RULD - Case "\": direcc Xor= 1 ' LURD - Case "!": Paso ' SKIP - Case "?": If ad(dp) = 0 Then Paso ' SKIPZ - End Select - Paso - Wend - Print Chr(ad(dp)); -End Sub - -SNUSP(5, HW) - -Sleep diff --git a/Task/Execute-SNUSP/Julia/execute-snusp.jl b/Task/Execute-SNUSP/Julia/execute-snusp.julia similarity index 100% rename from Task/Execute-SNUSP/Julia/execute-snusp.jl rename to Task/Execute-SNUSP/Julia/execute-snusp.julia diff --git a/Task/Execute-SNUSP/Kotlin/execute-snusp.kts b/Task/Execute-SNUSP/Kotlin/execute-snusp.kotlin similarity index 100% rename from Task/Execute-SNUSP/Kotlin/execute-snusp.kts rename to Task/Execute-SNUSP/Kotlin/execute-snusp.kotlin diff --git a/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l b/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l index 4c3cf6cc78..5c8a789dc8 100644 --- a/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l +++ b/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l @@ -1,4 +1,11 @@ -T Rule = (String pattern, String replacement, Bool terminating) +T Rule + String pattern + String replacement + Bool terminating + F (pattern, replacement, terminating) + .pattern = pattern + .replacement = replacement + .terminating = terminating F parse(rules) [Rule] result diff --git a/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.adb b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.ada similarity index 100% rename from Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.adb rename to Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.ada diff --git a/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.adb b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.ada similarity index 100% rename from Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.adb rename to Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.ada diff --git a/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.adb b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.ada similarity index 100% rename from Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.adb rename to Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.ada diff --git a/Task/Execute-a-Markov-algorithm/C-sharp/execute-a-markov-algorithm.cs b/Task/Execute-a-Markov-algorithm/C-sharp/execute-a-markov-algorithm.cs deleted file mode 100644 index 6d3499bb58..0000000000 --- a/Task/Execute-a-Markov-algorithm/C-sharp/execute-a-markov-algorithm.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -public class Markov -{ - /// - /// Take a ruleset and return a function which takes a string to which the rules - /// should be applied. - /// - /// String containing the rules - /// A function that takes a string and applies the rules - public static Func CreateMarkovProcessor(string ruleSet) - { - // Convert a ruleset string into a dictionary - Dictionary MakeRuleMap(string ruleset) - { - return ruleset.Split('\n') - .Where(e => !e.StartsWith("#")) - .Select(e => e.Split(new[] { " -> " }, StringSplitOptions.None)) - .ToDictionary(e => e[0], e => e[1]); - } - - // Split a string at an index - Tuple SplitAt(string s, int i) - { - return new Tuple(s.Substring(0, i), s.Substring(i)); - } - - // Strip a leading number of chars from a string. - string StripLeading(string s, string strip) - { - return s.Substring(strip.Length); - } - - // Replace the substring in the string. - string Replace(string s, string find, string rep) - { - string result = s; - if (s.IndexOf(find) >= 0) - { - var a = SplitAt(s, s.IndexOf(find)); - result = a.Item1 + rep + StripLeading(a.Item2, find); - } - return result; - } - - // Recursively apply the ruleset to the string. - string Parse(Dictionary rules, string s) - { - string o = s; - foreach (var rule in rules) - { - string k = rule.Key; - string v = rule.Value; - - if (v.StartsWith(".")) - { - s = Replace(s, k, StripLeading(v, ".")); - break; - } - else - { - s = Replace(s, k, v); - if (s != o) { break; } - } - } - return o == s ? s : Parse(rules, s); - } - - var ruleMap = MakeRuleMap(ruleSet); - return str => Parse(ruleMap, str); - } - - public static void Main() - { - string ruleset1 = @"# This rules file is extracted from Wikipedia: -# http://en.wikipedia.org/wiki/Markov_Algorithm -A -> apple -B -> bag -S -> shop -T -> the -the shop -> my brother -a never used -> .terminating rule"; - - string ruleset2 = @"# Slightly modified from the rules on Wikipedia -A -> apple -B -> bag -S -> .shop -T -> the -the shop -> my brother -a never used -> .terminating rule"; - - string ruleset3 = @"# BNF Syntax testing rules -A -> apple -WWWW -> with -Bgage -> ->.* -B -> bag -->.* -> money -W -> WW -S -> .shop -T -> the -the shop -> my brother -a never used -> .terminating rule"; - - string ruleset4 = @"### Unary Multiplication Engine, for testing Markov Algorithm implementations -### By Donal Fellows. -# Unary addition engine -_+1 -> _1+ -1+1 -> 11+ -# Pass for converting from the splitting of multiplication into ordinary -# addition -1! -> !1 -,! -> !+ -_! -> _ -# Unary multiplication by duplicating left side, right side times -1*1 -> x,@y -1x -> xX -X, -> 1,1 -X1 -> 1X -_x -> _X -,x -> ,X -y1 -> 1y -y_ -> _ -# Next phase of applying -1@1 -> x,@y -1@_ -> @_ -,@_ -> !_ -++ -> + -# Termination cleanup for addition -_1 -> 1 -1+_ -> 1 -_+_ -> "; - - string ruleset5 = @"# Turing machine: three-state busy beaver -# -# state A, symbol 0 => write 1, move right, new state B -A0 -> 1B -# state A, symbol 1 => write 1, move left, new state C -0A1 -> C01 -1A1 -> C11 -# state B, symbol 0 => write 1, move left, new state A -0B0 -> A01 -1B0 -> A11 -# state B, symbol 1 => write 1, move right, new state B -B1 -> 1B -# state C, symbol 0 => write 1, move left, new state B -0C0 -> B01 -1C0 -> B11 -# state C, symbol 1 => write 1, move left, halt -0C1 -> H01 -1C1 -> H11"; - - Console.WriteLine(CreateMarkovProcessor(ruleset1)("I bought a B of As from T S.")); - Console.WriteLine(CreateMarkovProcessor(ruleset2)("I bought a B of As from T S.")); - Console.WriteLine(CreateMarkovProcessor(ruleset3)("I bought a B of As W my Bgage from T S.")); - Console.WriteLine(CreateMarkovProcessor(ruleset4)("_1111*11111_")); - Console.WriteLine(CreateMarkovProcessor(ruleset5)("000000A000000")); - } -} diff --git a/Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic b/Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic deleted file mode 100644 index 8d0a5ec743..0000000000 --- a/Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic +++ /dev/null @@ -1,139 +0,0 @@ -Sub Markov (rules As String, entrada As String, expected As String) - Dim As String subs(), reps(), lines() - Dim As String sub_, rep, li, res - Dim As Integer i, k - Dim As Integer start = 1, finish = 1 - - While finish <= Len(rules) - If Mid(rules, finish, 1) = Chr(10) Then - Redim Preserve lines(Ubound(lines) + 1) - lines(Ubound(lines)) = Mid(rules, start, finish - start) - start = finish + 1 - End If - finish += 1 - Wend - For i = 0 To Ubound(lines) - li = lines(i) - If Len(li) > 0 And Asc(li, 1) <> Asc("#") Then - k = Instr(li, " -> ") - If k > 0 Then - Redim Preserve subs(Ubound(subs) + 1) - subs(Ubound(subs)) = Trim(Mid(li, 1, k - 1)) - Redim Preserve reps(Ubound(reps) + 1) - reps(Ubound(reps)) = Trim(Mid(li, k + 4)) - End If - End If - Next i - - res = entrada - Dim As Boolean term = False, found = False - Do - found = False - For i = 0 To Ubound(subs) - sub_ = subs(i) - k = Instr(res, sub_) - If k > 0 Then - found = True - rep = reps(i) - If Len(rep) > 0 And Asc(rep, 1) = Asc(".") Then - rep = Mid(rep, 2) - term = True - End If - Mid(res, k, Len(sub_)) = rep - Exit For - End If - If Not term Then Exit For - Next i - If Not term Or Not found Then Exit Do - Loop - Print """"; entrada;""""; ", "; """"; expected; """"; ", "; Iif(res = expected, "**ERROR**", "ok") -End Sub - -Dim As String ruleset1 = _ -"# This rules file is extracted from Wikipedia:" & _ -"# http://en.wikipedia.org/wiki/Markov_Algorithm" & _ -"A -> apple" & _ -"B -> bag" & _ -"S -> shop" & _ -"T -> the" & _ -"the shop -> my brother" & _ -"a never used -> .terminating rule" -Markov(ruleset1,"I bought a B of As from T S.","I bought a bag of apples from my brother.") - -Dim As String ruleset2 = _ -"# Slightly modified from the rules on Wikipedia" & _ -"A -> apple" & _ -"B -> bag" & _ -"S -> .shop" & _ -"T -> the" & _ -"the shop -> my brother" & _ -"a never used -> .terminating rule" -Markov(ruleset2,"I bought a B of As from T S.","I bought a bag of apples from T shop.") - -Dim As String ruleset3 = _ -"# BNF Syntax testing rules" & _ -"A -> apple" & _ -"WWWW -> with" & _ -"Bgage -> ->.*" & _ -"B -> bag" & _ -"->.* -> money" & _ -"W -> WW" & _ -"S -> .shop" & _ -"T -> the" & _ -"the shop -> my brother" & _ -"a never used -> .terminating rule""" -Markov(ruleset3,"I bought a B of As W my Bgage from T S.","I bought a bag of apples with my money from T shop.") - -Dim As String ruleset4 = _ -"### Unary Multiplication Engine, for testing Markov Algorithm implementations" & _ -"### By Donal Fellows." & _ -"# Unary addition engine" & _ -"_+1 -> _1+" & _ -"1+1 -> 11+" & _ -"# Pass for converting from the splitting of multiplication into ordinary" & _ -"# addition" & _ -"1! -> !1" & _ -",! -> !+" & _ -"_! -> _" & _ -"# Unary multiplication by duplicating left side, right side times" & _ -"1*1 -> x,@y" & _ -"1x -> xX" & _ -"X, -> 1,1" & _ -"X1 -> 1X" & _ -"_x -> _X" & _ -",x -> ,X" & _ -"y1 -> 1y" & _ -"y_ -> _" & _ -"# Next phase of applying" & _ -"1@1 -> x,@y" & _ -"1@_ -> @_" & _ -",@_ -> !_" & _ -"++ -> +" & _ -"# Termination cleanup for addition" & _ -"_1 -> 1" & _ -"1+_ -> 1" & _ -"_+_ -> " -Markov(ruleset4,"_1111*11111_","11111111111111111111") - -Dim As String ruleset5 = _ -"# Turing machine: three-state busy beaver" & _ -"#" & _ -"# state A, symbol 0 => write 1, move right, new state B" & _ -"A0 -> 1B" & _ -"# state A, symbol 1 => write 1, move left, new state C" & _ -"0A1 -> C01" & _ -"1A1 -> C11" & _ -"# state B, symbol 0 => write 1, move left, new state A" & _ -"0B0 -> A01" & _ -"1B0 -> A11" & _ -"# state B, symbol 1 => write 1, move right, new state B" & _ -"B1 -> 1B" & _ -"# state C, symbol 0 => write 1, move left, new state B" & _ -"0C0 -> B01" & _ -"1C0 -> B11" & _ -"# state C, symbol 1 => write 1, move left, halt" & _ -"0C1 -> H01" & _ -"1C1 -> H11" -Markov(ruleset5,"000000A000000","00011H1111000") - -Sleep diff --git a/Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-1.jl b/Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-1.julia similarity index 100% rename from Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-1.jl rename to Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-1.julia diff --git a/Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-2.jl b/Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-2.julia similarity index 100% rename from Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-2.jl rename to Task/Execute-a-Markov-algorithm/Julia/execute-a-markov-algorithm-2.julia diff --git a/Task/Execute-a-Markov-algorithm/Kotlin/execute-a-markov-algorithm.kts b/Task/Execute-a-Markov-algorithm/Kotlin/execute-a-markov-algorithm.kotlin similarity index 100% rename from Task/Execute-a-Markov-algorithm/Kotlin/execute-a-markov-algorithm.kts rename to Task/Execute-a-Markov-algorithm/Kotlin/execute-a-markov-algorithm.kotlin diff --git a/Task/Execute-a-Markov-algorithm/OCaml/execute-a-markov-algorithm.ml b/Task/Execute-a-Markov-algorithm/OCaml/execute-a-markov-algorithm.ocaml similarity index 100% rename from Task/Execute-a-Markov-algorithm/OCaml/execute-a-markov-algorithm.ml rename to Task/Execute-a-Markov-algorithm/OCaml/execute-a-markov-algorithm.ocaml diff --git a/Task/Execute-a-Markov-algorithm/Refal/execute-a-markov-algorithm.refal b/Task/Execute-a-Markov-algorithm/Refal/execute-a-markov-algorithm.refal deleted file mode 100644 index 482e4b3e3a..0000000000 --- a/Task/Execute-a-Markov-algorithm/Refal/execute-a-markov-algorithm.refal +++ /dev/null @@ -1,57 +0,0 @@ -$ENTRY Go { - , : e.File - , : e.Input - , : e.Lines - , : e.Rules - , : e.Result - = ; -}; - -Each { - s.F = ; - s.F (e.I) e.R = ; -}; - -ReadLines { - s.Chan e.File = - ; - (s.Chan), : { - 0 = ; - e.Line = (e.Line) ; - }; -}; - -ParseRule { - = (Empty); - '#' e.X = (Empty); - e.Pat ' -> ' e.Rep, - : e.TrPat, - : e.TrRep, - e.TrRep: { - '.' e.R = (Term (e.Pat) (e.R)); - e.R = (Nonterm (e.Pat) (e.R)); - }; -}; - -ApplyRule { - (s.Type (e.Pat) (e.Rep)) e.Subj, - e.Subj: e.X e.Pat e.Y = s.Type e.X e.Rep e.Y; - t.Rule e.Subj = NoMatch e.Subj; -}; - -Apply { - (e.Rules) () e.Subj = e.Subj; - (e.Rules) (t.Rule e.Rest) e.Subj, - : { - NoMatch e.Subj = ; - Term e.Res = e.Res; - Nonterm e.Res = ; - }; - (e.Rules) e.Subj = ; -}; - -Trim { - ' ' e.X = ; - e.X ' ' = ; - e.X = e.X; -}; diff --git a/Task/Execute-a-Markov-algorithm/Rust/execute-a-markov-algorithm.rs b/Task/Execute-a-Markov-algorithm/Rust/execute-a-markov-algorithm.rust similarity index 100% rename from Task/Execute-a-Markov-algorithm/Rust/execute-a-markov-algorithm.rs rename to Task/Execute-a-Markov-algorithm/Rust/execute-a-markov-algorithm.rust diff --git a/Task/Execute-a-Markov-algorithm/SETL/execute-a-markov-algorithm.setl b/Task/Execute-a-Markov-algorithm/SETL/execute-a-markov-algorithm.setl deleted file mode 100644 index 679a6f79b7..0000000000 --- a/Task/Execute-a-Markov-algorithm/SETL/execute-a-markov-algorithm.setl +++ /dev/null @@ -1,62 +0,0 @@ -program markov_algorithm; - magic := false; - if command_line(1) = om then - print("error: no ruleset file given"); - stop; - elseif command_line(2) = om then - print("error: no input string given"); - stop; - end if; - - rules := read_file(command_line(1)); - - input := command_line(2); - loop do - loop for [pat, repl, trm] in rules do - if pat in input then - input(pat) := repl; - if trm then - quit; - else - continue loop do; - end if; - end if; - end loop; - quit; - end loop; - print(input); - - proc read_file(file_name); - if (rulefile := open(file_name, "r")) = om then - print("error: cannot open ruleset file"); - stop; - end if; - - rules := []; - loop doing - line := getline(rulefile); - while line /= om do - rule := parse_rule(line); - if rule /= om then rules with:= rule; end if; - end loop; - return rules; - end proc; - - proc parse_rule(rule); - if rule(1) = "#" then return om; end if; $ comment - if " -> " notin rule then return om; end if; $ not a rule - - [s, e] := mark(rule, " -> "); - pattern := rule(..s-1); - repl := rule(e+1..); - - whitespace := "\t\r\n "; - span(pattern, whitespace); - rspan(pattern, whitespace); - span(repl, whitespace); - rspan(repl, whitespace); - - trm := match(repl, ".") /= ""; - return [pattern, repl, trm]; - end proc; -end program; diff --git a/Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.scm b/Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.ss similarity index 100% rename from Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.scm rename to Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.ss diff --git a/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vbs b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vb similarity index 100% rename from Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vbs rename to Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vb diff --git a/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vbs b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vb similarity index 100% rename from Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vbs rename to Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vb diff --git a/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vbs b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vb similarity index 100% rename from Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vbs rename to Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vb diff --git a/Task/Execute-a-Markov-algorithm/Wren/execute-a-markov-algorithm.wren b/Task/Execute-a-Markov-algorithm/Wren/execute-a-markov-algorithm.wren index 0012cfa75b..e3b8e66652 100644 --- a/Task/Execute-a-Markov-algorithm/Wren/execute-a-markov-algorithm.wren +++ b/Task/Execute-a-Markov-algorithm/Wren/execute-a-markov-algorithm.wren @@ -1,5 +1,5 @@ -import "./ioutil" for FileUtil, File -import "./pattern" for Pattern +import "/ioutil" for FileUtil, File +import "/pattern" for Pattern var lb = FileUtil.lineBreak diff --git a/Task/Execute-a-Markov-algorithm/Zig/execute-a-markov-algorithm.zig b/Task/Execute-a-Markov-algorithm/Zig/execute-a-markov-algorithm.zig deleted file mode 100644 index ec8bb8934d..0000000000 --- a/Task/Execute-a-Markov-algorithm/Zig/execute-a-markov-algorithm.zig +++ /dev/null @@ -1,278 +0,0 @@ -const std = @import("std"); -const testing = std.testing; -const mem = std.mem; -const Allocator = std.mem.Allocator; - -// Add a main function for Zig playground to compile -pub fn main() !void { - // Empty main function to satisfy the compiler - std.debug.print("Markov Algorithm library\n", .{}); -} - -pub const Rule = struct { - pat: []const u8, - rep: []const u8, - terminal: bool, - - pub fn init(allocator: Allocator, pat: []const u8, rep: []const u8, terminal: bool) !Rule { - const pat_owned = try allocator.dupe(u8, pat); - const rep_owned = try allocator.dupe(u8, rep); - return Rule{ - .pat = pat_owned, - .rep = rep_owned, - .terminal = terminal, - }; - } - - pub fn deinit(self: *Rule, allocator: Allocator) void { - allocator.free(self.pat); - allocator.free(self.rep); - } - - pub fn clone(self: Rule, allocator: Allocator) !Rule { - return try Rule.init(allocator, self.pat, self.rep, self.terminal); - } - - pub fn applicableRange(self: *const Rule, input: []const u8) ?struct { start: usize, end: usize } { - if (mem.indexOf(u8, input, self.pat)) |start| { - return .{ .start = start, .end = start + self.pat.len }; - } - return null; - } - - pub fn apply(self: *const Rule, s: *std.ArrayList(u8)) !bool { - if (self.applicableRange(s.items)) |range| { - try s.replaceRange(range.start, range.end - range.start, self.rep); - return true; - } - return false; - } - - pub fn fromString(allocator: Allocator, s: []const u8) !Rule { - var parts = mem.splitSequence(u8, s, " -> "); - const pat = parts.first(); - const rep_opt = parts.next(); - if (rep_opt == null) { - return error.InvalidFormat; - } - const rep = rep_opt.?; - - if (rep.len > 0 and rep[0] == '.') { - return Rule.init(allocator, pat, rep[1..], true); - } else { - return Rule.init(allocator, pat, rep, false); - } - } -}; - -pub const Rules = struct { - rules: std.ArrayList(Rule), - allocator: Allocator, - - pub fn init(allocator: Allocator) Rules { - return Rules{ - .rules = std.ArrayList(Rule).init(allocator), - .allocator = allocator, - }; - } - - pub fn deinit(self: *Rules) void { - for (self.rules.items) |*rule| { - rule.deinit(self.allocator); - } - self.rules.deinit(); - } - - pub fn clone(self: Rules) !Rules { - var new_rules = Rules.init(self.allocator); - for (self.rules.items) |rule| { - try new_rules.rules.append(try rule.clone(self.allocator)); - } - return new_rules; - } - - pub fn apply(self: *const Rules, s: *std.ArrayList(u8)) !?*const Rule { - for (self.rules.items) |*rule| { - if (try rule.apply(s)) { - return rule; - } - } - return null; - } - - pub fn execute(self: *const Rules, buffer: []const u8) ![]u8 { - var result = try std.ArrayList(u8).initCapacity(self.allocator, buffer.len); - try result.appendSlice(buffer); - - while (try self.apply(&result)) |rule| { - if (rule.terminal) { - break; - } - } - - return result.toOwnedSlice(); - } - - pub fn fromString(allocator: Allocator, s: []const u8) !Rules { - var result = Rules.init(allocator); - var lines = mem.splitScalar(u8, s, '\n'); - - while (lines.next()) |line| { - const trimmed = mem.trim(u8, line, &std.ascii.whitespace); - if (trimmed.len == 0 or trimmed[0] == '#') { - continue; - } - const rule = try Rule.fromString(allocator, trimmed); - try result.rules.append(rule); - } - - return result; - } -}; - -test "case_01" { - const allocator = std.testing.allocator; - const input = "I bought a B of As from T S."; - const rules_str = - \\# This rules file is extracted from Wikipedia: - \\# http://en.wikipedia.org/wiki/Markov_Algorithm - \\A -> apple - \\B -> bag - \\S -> shop - \\T -> the - \\the shop -> my brother - \\a never used -> .terminating rule - ; - - var rules = try Rules.fromString(allocator, rules_str); - defer rules.deinit(); - - const result = try rules.execute(input); - defer allocator.free(result); - - try testing.expectEqualStrings("I bought a bag of apples from my brother.", result); -} - -test "case_02" { - const allocator = std.testing.allocator; - const input = "I bought a B of As from T S."; - const rules_str = - \\# Slightly modified from the rules on Wikipedia - \\A -> apple - \\B -> bag - \\S -> .shop - \\T -> the - \\the shop -> my brother - \\a never used -> .terminating rule - ; - - var rules = try Rules.fromString(allocator, rules_str); - defer rules.deinit(); - - const result = try rules.execute(input); - defer allocator.free(result); - - try testing.expectEqualStrings("I bought a bag of apples from T shop.", result); -} - -test "case_03" { - const allocator = std.testing.allocator; - const input = "I bought a B of As W my Bgage from T S."; - const rules_str = - \\# BNF Syntax testing rules - \\A -> apple - \\WWWW -> with - \\Bgage -> ->.* - \\B -> bag - \\->.* -> money - \\W -> WW - \\S -> .shop - \\T -> the - \\the shop -> my brother - \\a never used -> .terminating rule - ; - - var rules = try Rules.fromString(allocator, rules_str); - defer rules.deinit(); - - const result = try rules.execute(input); - defer allocator.free(result); - - try testing.expectEqualStrings("I bought a bag of apples with my money from T shop.", result); -} - -test "case_04" { - const allocator = std.testing.allocator; - const input = "_1111*11111_"; - const rules_str = - \\### Unary Multiplication Engine, for testing Markov Algorithm implementations - \\### By Donal Fellows. - \\# Unary addition engine - \\_+1 -> _1+ - \\1+1 -> 11+ - \\# Pass for converting from the splitting of multiplication into ordinary - \\# addition - \\1! -> !1 - \\,! -> !+ - \\_! -> _ - \\# Unary multiplication by duplicating left side, right side times - \\1*1 -> x,@y - \\1x -> xX - \\X, -> 1,1 - \\X1 -> 1X - \\_x -> _X - \\,x -> ,X - \\y1 -> 1y - \\y_ -> _ - \\# Next phase of applying - \\1@1 -> x,@y - \\1@_ -> @_ - \\,@_ -> !_ - \\++ -> + - \\# Termination cleanup for addition - \\_1 -> 1 - \\1+_ -> 1 - \\_+_ -> - ; - - var rules = try Rules.fromString(allocator, rules_str); - defer rules.deinit(); - - const result = try rules.execute(input); - defer allocator.free(result); - - try testing.expectEqualStrings("11111111111111111111", result); -} - -test "case_05" { - const allocator = std.testing.allocator; - const input = "000000A000000"; - const rules_str = - \\# Turing machine: three-state busy beaver - \\# - \\# state A, symbol 0 => write 1, move right, new state B - \\A0 -> 1B - \\# state A, symbol 1 => write 1, move left, new state C - \\0A1 -> C01 - \\1A1 -> C11 - \\# state B, symbol 0 => write 1, move left, new state A - \\0B0 -> A01 - \\1B0 -> A11 - \\# state B, symbol 1 => write 1, move right, new state B - \\B1 -> 1B - \\# state C, symbol 0 => write 1, move left, new state B - \\0C0 -> B01 - \\1C0 -> B11 - \\# state C, symbol 1 => write 1, move left, halt - \\0C1 -> H01 - \\1C1 -> H11 - ; - - var rules = try Rules.fromString(allocator, rules_str); - defer rules.deinit(); - - const result = try rules.execute(input); - defer allocator.free(result); - - try testing.expectEqualStrings("00011H1111000", result); -} diff --git a/Task/Execute-a-system-command/Ada/execute-a-system-command-1.adb b/Task/Execute-a-system-command/Ada/execute-a-system-command-1.ada similarity index 100% rename from Task/Execute-a-system-command/Ada/execute-a-system-command-1.adb rename to Task/Execute-a-system-command/Ada/execute-a-system-command-1.ada diff --git a/Task/Execute-a-system-command/Ada/execute-a-system-command-2.adb b/Task/Execute-a-system-command/Ada/execute-a-system-command-2.ada similarity index 100% rename from Task/Execute-a-system-command/Ada/execute-a-system-command-2.adb rename to Task/Execute-a-system-command/Ada/execute-a-system-command-2.ada diff --git a/Task/Execute-a-system-command/Ada/execute-a-system-command-3.adb b/Task/Execute-a-system-command/Ada/execute-a-system-command-3.ada similarity index 100% rename from Task/Execute-a-system-command/Ada/execute-a-system-command-3.adb rename to Task/Execute-a-system-command/Ada/execute-a-system-command-3.ada diff --git a/Task/Execute-a-system-command/ArkScript/execute-a-system-command.ark b/Task/Execute-a-system-command/ArkScript/execute-a-system-command.ark deleted file mode 100644 index 40b7da0d2d..0000000000 --- a/Task/Execute-a-system-command/ArkScript/execute-a-system-command.ark +++ /dev/null @@ -1,3 +0,0 @@ -(import std.Sys) - -(print (sys:exec "ls")) diff --git a/Task/Execute-a-system-command/AutoIt/execute-a-system-command.au3 b/Task/Execute-a-system-command/AutoIt/execute-a-system-command.autoit similarity index 100% rename from Task/Execute-a-system-command/AutoIt/execute-a-system-command.au3 rename to Task/Execute-a-system-command/AutoIt/execute-a-system-command.autoit diff --git a/Task/Execute-a-system-command/COBOL/execute-a-system-command.cob b/Task/Execute-a-system-command/COBOL/execute-a-system-command.cobol similarity index 100% rename from Task/Execute-a-system-command/COBOL/execute-a-system-command.cob rename to Task/Execute-a-system-command/COBOL/execute-a-system-command.cobol diff --git a/Task/Execute-a-system-command/Delphi/execute-a-system-command.pas b/Task/Execute-a-system-command/Delphi/execute-a-system-command.delphi similarity index 100% rename from Task/Execute-a-system-command/Delphi/execute-a-system-command.pas rename to Task/Execute-a-system-command/Delphi/execute-a-system-command.delphi diff --git a/Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-1.el b/Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-1.l similarity index 100% rename from Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-1.el rename to Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-1.l diff --git a/Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-2.el b/Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-2.l similarity index 100% rename from Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-2.el rename to Task/Execute-a-system-command/Emacs-Lisp/execute-a-system-command-2.l diff --git a/Task/Execute-a-system-command/Euphoria/execute-a-system-command.eu b/Task/Execute-a-system-command/Euphoria/execute-a-system-command.euphoria similarity index 100% rename from Task/Execute-a-system-command/Euphoria/execute-a-system-command.eu rename to Task/Execute-a-system-command/Euphoria/execute-a-system-command.euphoria diff --git a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-1.basic b/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-1.basic deleted file mode 100644 index ea3d5ec4ce..0000000000 --- a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-1.basic +++ /dev/null @@ -1 +0,0 @@ -print unix(@"ls -A") diff --git a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-2.basic b/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-2.basic deleted file mode 100644 index 2d7ac2df38..0000000000 --- a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-2.basic +++ /dev/null @@ -1,12 +0,0 @@ -local fn DoUnixCommand( cmd as str255 ) - str255 s - - open "Unix", 2, cmd - while ( not eof(2) ) - line input #2, s - print s - wend - close 2 -end fn - -fn DoUnixCommand( "ls -A" ) diff --git a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-3.basic b/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-3.basic deleted file mode 100644 index f5c125ea63..0000000000 --- a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command-3.basic +++ /dev/null @@ -1,39 +0,0 @@ -include "NSLog.incl" - -// For remote uses like curl -// #plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES} - -local fn RunTerminalCommand( cmd as CFStringRef ) as CFStringRef -———————————————————————————————————————————————————————————————————————————————————————————————————— - ErrorRef err = NULL - CFStringRef outputStr = NULL - - TaskRef task = fn TaskInit - TaskSetExecutableURL( task, fn URLFileURLWithPath( @"/bin/zsh" ) ) - CFStringRef cmdStr = fn StringWithFormat( @"%@", cmd ) - CFArrayRef args = fn ArrayWithObjects( @"-c", cmdStr, NULL ) - TaskSetArguments( task, args ) - - PipeRef p = fn PipeInit - TaskSetStandardOutput( task, p ) - TaskSetStandardError( task, p ) - FileHandleRef fh = fn PipeFileHandleForReading( p ) - - fn TaskLaunch( task, NULL ) - TaskWaitUntilExit( task ) - - CFDataRef dta = fn FileHandleReadDataToEndOfFile( fh, @err ) - if err then NSLog( @"Error reading file: %@", fn ErrorLocalizedDescription( err ) ) : exit fn - - fn FileHandleClose( fh, @err ) - if err then NSLog( @"Error closing file: %@", fn ErrorLocalizedDescription( err ) ) : exit fn - - outputStr = fn StringWithData( dta, NSUTF8StringEncoding ) -end fn = outputStr - -CFStringRef cmd - -cmd = @"cal 2023" -NSLog( @"%@", fn RunTerminalCommand( cmd ) ) - -HandleEvents diff --git a/Task/Execute-a-system-command/FutureBasic/execute-a-system-command.basic b/Task/Execute-a-system-command/FutureBasic/execute-a-system-command.basic new file mode 100644 index 0000000000..c2af16f1dd --- /dev/null +++ b/Task/Execute-a-system-command/FutureBasic/execute-a-system-command.basic @@ -0,0 +1,14 @@ +include "ConsoleWindow" + +local fn DoUnixCommand( cmd as str255 ) + dim as str255 s + + open "Unix", 2, cmd + while ( not eof(2) ) + line input #2, s + print s + wend + close 2 +end fn + +fn DoUnixCommand( "ls -A" ) diff --git a/Task/Execute-a-system-command/Julia/execute-a-system-command.jl b/Task/Execute-a-system-command/Julia/execute-a-system-command.julia similarity index 100% rename from Task/Execute-a-system-command/Julia/execute-a-system-command.jl rename to Task/Execute-a-system-command/Julia/execute-a-system-command.julia diff --git a/Task/Execute-a-system-command/Kotlin/execute-a-system-command.kts b/Task/Execute-a-system-command/Kotlin/execute-a-system-command.kotlin similarity index 100% rename from Task/Execute-a-system-command/Kotlin/execute-a-system-command.kts rename to Task/Execute-a-system-command/Kotlin/execute-a-system-command.kotlin diff --git a/Task/Execute-a-system-command/OCaml/execute-a-system-command-1.ml b/Task/Execute-a-system-command/OCaml/execute-a-system-command-1.ocaml similarity index 100% rename from Task/Execute-a-system-command/OCaml/execute-a-system-command-1.ml rename to Task/Execute-a-system-command/OCaml/execute-a-system-command-1.ocaml diff --git a/Task/Execute-a-system-command/OCaml/execute-a-system-command-2.ml b/Task/Execute-a-system-command/OCaml/execute-a-system-command-2.ocaml similarity index 100% rename from Task/Execute-a-system-command/OCaml/execute-a-system-command-2.ml rename to Task/Execute-a-system-command/OCaml/execute-a-system-command-2.ocaml diff --git a/Task/Execute-a-system-command/OCaml/execute-a-system-command-3.ml b/Task/Execute-a-system-command/OCaml/execute-a-system-command-3.ocaml similarity index 100% rename from Task/Execute-a-system-command/OCaml/execute-a-system-command-3.ml rename to Task/Execute-a-system-command/OCaml/execute-a-system-command-3.ocaml diff --git a/Task/Execute-a-system-command/PascalABC.NET/execute-a-system-command.pas b/Task/Execute-a-system-command/PascalABC.NET/execute-a-system-command.pas deleted file mode 100644 index ab758487a0..0000000000 --- a/Task/Execute-a-system-command/PascalABC.NET/execute-a-system-command.pas +++ /dev/null @@ -1,2 +0,0 @@ -## -exec('cmd.exe','/c dir /p'); diff --git a/Task/Execute-a-system-command/Pluto/execute-a-system-command.pluto b/Task/Execute-a-system-command/Pluto/execute-a-system-command.pluto deleted file mode 100644 index 3f325c8c2e..0000000000 --- a/Task/Execute-a-system-command/Pluto/execute-a-system-command.pluto +++ /dev/null @@ -1 +0,0 @@ -os.execute("pause") diff --git a/Task/Execute-a-system-command/PowerShell/execute-a-system-command-1.ps1 b/Task/Execute-a-system-command/PowerShell/execute-a-system-command-1.psh similarity index 100% rename from Task/Execute-a-system-command/PowerShell/execute-a-system-command-1.ps1 rename to Task/Execute-a-system-command/PowerShell/execute-a-system-command-1.psh diff --git a/Task/Execute-a-system-command/PowerShell/execute-a-system-command-2.ps1 b/Task/Execute-a-system-command/PowerShell/execute-a-system-command-2.psh similarity index 100% rename from Task/Execute-a-system-command/PowerShell/execute-a-system-command-2.ps1 rename to Task/Execute-a-system-command/PowerShell/execute-a-system-command-2.psh diff --git a/Task/Execute-a-system-command/Rebol/execute-a-system-command.rebol b/Task/Execute-a-system-command/REBOL/execute-a-system-command.rebol similarity index 100% rename from Task/Execute-a-system-command/Rebol/execute-a-system-command.rebol rename to Task/Execute-a-system-command/REBOL/execute-a-system-command.rebol diff --git a/Task/Execute-a-system-command/Rust/execute-a-system-command.rs b/Task/Execute-a-system-command/Rust/execute-a-system-command.rust similarity index 100% rename from Task/Execute-a-system-command/Rust/execute-a-system-command.rs rename to Task/Execute-a-system-command/Rust/execute-a-system-command.rust diff --git a/Task/Execute-a-system-command/Rye/execute-a-system-command.rye b/Task/Execute-a-system-command/Rye/execute-a-system-command.rye deleted file mode 100644 index 97164e6532..0000000000 --- a/Task/Execute-a-system-command/Rye/execute-a-system-command.rye +++ /dev/null @@ -1,3 +0,0 @@ -cc os -ls -cwd? diff --git a/Task/Execute-a-system-command/Scheme/execute-a-system-command.scm b/Task/Execute-a-system-command/Scheme/execute-a-system-command.ss similarity index 100% rename from Task/Execute-a-system-command/Scheme/execute-a-system-command.scm rename to Task/Execute-a-system-command/Scheme/execute-a-system-command.ss diff --git a/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 b/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 index 7de9dc25a3..eafaacc2ca 100644 --- a/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 +++ b/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 @@ -3,5 +3,5 @@ $ include "seed7_05.s7i"; const proc: main is func begin - shellCmd("ls"); + cmd_sh("ls"); end func; diff --git a/Task/Execute-a-system-command/VBScript/execute-a-system-command.vbs b/Task/Execute-a-system-command/VBScript/execute-a-system-command.vb similarity index 100% rename from Task/Execute-a-system-command/VBScript/execute-a-system-command.vbs rename to Task/Execute-a-system-command/VBScript/execute-a-system-command.vb diff --git a/Task/Execute-a-system-command/Wren/execute-a-system-command-1.wren b/Task/Execute-a-system-command/Wren/execute-a-system-command-1.wren new file mode 100644 index 0000000000..a29e2c106c --- /dev/null +++ b/Task/Execute-a-system-command/Wren/execute-a-system-command-1.wren @@ -0,0 +1,8 @@ +/* run_system_command.wren */ +class Command { + foreign static exec(name, param) // the code for this is provided by Go +} + +Command.exec("ls", "-lt") +System.print() +Command.exec("dir", "") diff --git a/Task/Execute-a-system-command/Wren/execute-a-system-command-2.wren b/Task/Execute-a-system-command/Wren/execute-a-system-command-2.wren new file mode 100644 index 0000000000..ad43e08451 --- /dev/null +++ b/Task/Execute-a-system-command/Wren/execute-a-system-command-2.wren @@ -0,0 +1,39 @@ +/* run_system_command.go*/ +package main + +import ( + wren "github.com/crazyinfin8/WrenGo" + "log" + "os" + "os/exec" +) + +type any = interface{} + +func execCommand(vm *wren.VM, parameters []any) (any, error) { + name := parameters[1].(string) + param := parameters[2].(string) + var cmd *exec.Cmd + if param != "" { + cmd = exec.Command(name, param) + } else { + cmd = exec.Command(name) + } + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + log.Fatal(err) + } + return nil, nil +} + +func main() { + vm := wren.NewVM() + fileName := "run_system_command.wren" + methodMap := wren.MethodMap{"static exec(_,_)": execCommand} + classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)} + module := wren.NewModule(classMap) + vm.SetModule(fileName, module) + vm.InterpretFile(fileName) + vm.Free() +} diff --git a/Task/Execute-a-system-command/Wren/execute-a-system-command.wren b/Task/Execute-a-system-command/Wren/execute-a-system-command.wren deleted file mode 100644 index 1d97b0a9de..0000000000 --- a/Task/Execute-a-system-command/Wren/execute-a-system-command.wren +++ /dev/null @@ -1,5 +0,0 @@ -import "os" for Process - -Process.exec("ls", ["-lt"]) -System.print() -Process.exec("dir") diff --git a/Task/Exponentiation-operator/Ada/exponentiation-operator-1.adb b/Task/Exponentiation-operator/Ada/exponentiation-operator-1.ada similarity index 100% rename from Task/Exponentiation-operator/Ada/exponentiation-operator-1.adb rename to Task/Exponentiation-operator/Ada/exponentiation-operator-1.ada diff --git a/Task/Exponentiation-operator/Ada/exponentiation-operator-2.adb b/Task/Exponentiation-operator/Ada/exponentiation-operator-2.ada similarity index 100% rename from Task/Exponentiation-operator/Ada/exponentiation-operator-2.adb rename to Task/Exponentiation-operator/Ada/exponentiation-operator-2.ada diff --git a/Task/Exponentiation-operator/Ada/exponentiation-operator-3.adb b/Task/Exponentiation-operator/Ada/exponentiation-operator-3.ada similarity index 100% rename from Task/Exponentiation-operator/Ada/exponentiation-operator-3.adb rename to Task/Exponentiation-operator/Ada/exponentiation-operator-3.ada diff --git a/Task/Exponentiation-operator/Batch-File/exponentiation-operator.bat b/Task/Exponentiation-operator/Batch-File/exponentiation-operator.bat deleted file mode 100644 index f9b95744f4..0000000000 --- a/Task/Exponentiation-operator/Batch-File/exponentiation-operator.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -setlocal enableextensions enabledelayedexpansion -set /p a= -set /p b= -call :pow %a% %b% -echo %_a% -goto :eof -:pow Integer Integer -:: Right-to-left binary exponentiation -set /a "_a=1, s=%1, e=%2" -:looppow -if %e% neq 0 ( -set /a "t=e&1" -if !t! equ 1 (set /a "_a*=s") -set /a "s*=s, e>>=1" -goto looppow -) -goto :eof diff --git a/Task/Exponentiation-operator/Delphi/exponentiation-operator.pas b/Task/Exponentiation-operator/Delphi/exponentiation-operator.delphi similarity index 100% rename from Task/Exponentiation-operator/Delphi/exponentiation-operator.pas rename to Task/Exponentiation-operator/Delphi/exponentiation-operator.delphi diff --git a/Task/Exponentiation-operator/EasyLang/exponentiation-operator.easy b/Task/Exponentiation-operator/EasyLang/exponentiation-operator.easy deleted file mode 100644 index 126b429c63..0000000000 --- a/Task/Exponentiation-operator/EasyLang/exponentiation-operator.easy +++ /dev/null @@ -1,11 +0,0 @@ -func mypow n exp . - if exp < 0 - exp = -exp - n = 1 / n - . - r = 1 - for i to exp : r *= n - return r -. -print mypow pi 2 -print mypow 2 -2 diff --git a/Task/Exponentiation-operator/Elixir/exponentiation-operator.ex b/Task/Exponentiation-operator/Elixir/exponentiation-operator.elixir similarity index 100% rename from Task/Exponentiation-operator/Elixir/exponentiation-operator.ex rename to Task/Exponentiation-operator/Elixir/exponentiation-operator.elixir diff --git a/Task/Exponentiation-operator/Julia/exponentiation-operator.jl b/Task/Exponentiation-operator/Julia/exponentiation-operator.julia similarity index 100% rename from Task/Exponentiation-operator/Julia/exponentiation-operator.jl rename to Task/Exponentiation-operator/Julia/exponentiation-operator.julia diff --git a/Task/Exponentiation-operator/Kotlin/exponentiation-operator.kts b/Task/Exponentiation-operator/Kotlin/exponentiation-operator.kotlin similarity index 100% rename from Task/Exponentiation-operator/Kotlin/exponentiation-operator.kts rename to Task/Exponentiation-operator/Kotlin/exponentiation-operator.kotlin diff --git a/Task/Exponentiation-operator/MiniScript/exponentiation-operator.mini b/Task/Exponentiation-operator/MiniScript/exponentiation-operator.mini deleted file mode 100644 index e082de1366..0000000000 --- a/Task/Exponentiation-operator/MiniScript/exponentiation-operator.mini +++ /dev/null @@ -1,58 +0,0 @@ -import "qa" - -number.isInteger = function - return self == floor(self) -end function - -ipow = function(base, exp) - if not base.isInteger then qa.abort("ipow must have an integer base") - if not exp.isInteger then qa.abort("ipow must have an integer exponent") - if base == 1 or exp == 0 then return 1 - if base == -1 then - if exp%2 == 0 then return 1 - return -1 - end if - if exp < 0 then qa.abort("ipow cannot have a negative exponent") - ans = 1 - e = exp - while e > 1 - if e%2 == 1 then ans *= base - e = floor(e/2) - base *= base - end while - return ans * base -end function - -fpow = function(base, exp) - if not exp.isInteger then qa.abort("fpow must have an integer exponent") - ans = 1.0 - e = exp - if e < 0 then - base = 1 / base - e = -e - end if - while e > 0 - if e%2 == 1 then ans *= base - e = floor(e/2) - base *= base - end while - return ans -end function - -print "Using the reimplemented functions:" -print " 2 ^ 3 = " + ipow(2, 3) -print " 1 ^ -10 = " + ipow(1, -10) -print " -1 ^ -3 = " + ipow(-1, -3) -print -print " 2.0 ^ -3 = " + fpow(2.0, -3) -print " 1.5 ^ 0 = " + fpow(1.5, 0) -print " 4.5 ^ 2 = " + fpow(4.5, 2) -print -print "Using the ^ operator:" -print " 2 ^ 3 = " + 2 ^ 3 -print " 1 ^ -10 = " + 1 ^ (-10) -print " -1 ^ -3 = " + (-1) ^ (-3) -print -print " 2.0 ^ -3 = " + 2.0 ^ (-3) -print " 1.5 ^ 0 = " + 1.5 ^ 0 -print " 4.5 ^ 2 = " + 4.5 ^ 2 diff --git a/Task/Exponentiation-operator/OCaml/exponentiation-operator.ml b/Task/Exponentiation-operator/OCaml/exponentiation-operator.ocaml similarity index 100% rename from Task/Exponentiation-operator/OCaml/exponentiation-operator.ml rename to Task/Exponentiation-operator/OCaml/exponentiation-operator.ocaml diff --git a/Task/Exponentiation-operator/Phix/exponentiation-operator.phix b/Task/Exponentiation-operator/Phix/exponentiation-operator.phix index 07065b741f..79c10d37a2 100644 --- a/Task/Exponentiation-operator/Phix/exponentiation-operator.phix +++ b/Task/Exponentiation-operator/Phix/exponentiation-operator.phix @@ -1,13 +1,15 @@ -with javascript_semantics -function powir(atom b, integer i) - atom res = 1 - if i<0 then {b,i} = {1/b,abs(i)} end if - while i do - if and_bits(i,1) then res *= b end if - b *= b - i = floor(i/2) - end while - return res -end function -?powir(-3,-5) -?power(-3,-5) +(phixonline)--> + with javascript_semantics + function powir(atom b, integer i) + atom res = 1 + if i<0 then {b,i} = {1/b,abs(i)} end if + while i do + if and_bits(i,1) then res *= b end if + b *= b + i = floor(i/2) + end while + return res + end function + ?powir(-3,-5) + ?power(-3,-5) + Real) {*} -multi pow (0, 0) { fail '0**0 is undefined' } -multi pow ($base, UInt $exp) { [*] $base xx $exp } -multi pow ($base, $exp) { 1 / samewith $base, -$exp } +subset Natural of Int where { $^n >= 0 } -multi infix:<**> (Real $a, Int $b) { pow $a, $b } +multi pow (0, 0) { fail '0**0 is undefined' } +multi pow ($base, Natural $exp) { [*] $base xx $exp } +multi pow ($base, Int $exp) { 1 / pow $base, -$exp } + +sub infix:<***> ($a, $b) { pow $a, $b } # Testing say pow .75, -5; -say .75 ** -5; +say .75 *** -5; diff --git a/Task/Exponentiation-operator/Rust/exponentiation-operator.rs b/Task/Exponentiation-operator/Rust/exponentiation-operator.rust similarity index 100% rename from Task/Exponentiation-operator/Rust/exponentiation-operator.rs rename to Task/Exponentiation-operator/Rust/exponentiation-operator.rust diff --git a/Task/Exponentiation-operator/Scheme/exponentiation-operator.scm b/Task/Exponentiation-operator/Scheme/exponentiation-operator.ss similarity index 100% rename from Task/Exponentiation-operator/Scheme/exponentiation-operator.scm rename to Task/Exponentiation-operator/Scheme/exponentiation-operator.ss diff --git a/Task/Exponentiation-operator/Uiua/exponentiation-operator.uiua b/Task/Exponentiation-operator/Uiua/exponentiation-operator.uiua deleted file mode 100644 index 531cc1a574..0000000000 --- a/Task/Exponentiation-operator/Uiua/exponentiation-operator.uiua +++ /dev/null @@ -1,4 +0,0 @@ -Pow ← ∧(×⊙˙×)⊙1+1×⊙-₁(⇌⋯) -Pow 10 2 -⍜⊙°ₑ× 10 2 -⍜⊙°ₑ× 0.5 2 diff --git a/Task/Exponentiation-operator/VBScript/exponentiation-operator.vbs b/Task/Exponentiation-operator/VBScript/exponentiation-operator.vb similarity index 100% rename from Task/Exponentiation-operator/VBScript/exponentiation-operator.vbs rename to Task/Exponentiation-operator/VBScript/exponentiation-operator.vb diff --git a/Task/Exponentiation-order/ALGOL-M/exponentiation-order.alg b/Task/Exponentiation-order/ALGOL-M/exponentiation-order.alg deleted file mode 100644 index c71c310501..0000000000 --- a/Task/Exponentiation-order/ALGOL-M/exponentiation-order.alg +++ /dev/null @@ -1,7 +0,0 @@ -begin - -write("5**3**2 = ", 5**3**2); -write("(5**3)**2 = ", (5**3)**2); -write("5**(3**2) = ", 5**(3**2)); - -end diff --git a/Task/Exponentiation-order/Ada/exponentiation-order.adb b/Task/Exponentiation-order/Ada/exponentiation-order.ada similarity index 100% rename from Task/Exponentiation-order/Ada/exponentiation-order.adb rename to Task/Exponentiation-order/Ada/exponentiation-order.ada diff --git a/Task/Exponentiation-order/Crystal/exponentiation-order.cr b/Task/Exponentiation-order/Crystal/exponentiation-order.cr deleted file mode 100644 index e52dadd7de..0000000000 --- a/Task/Exponentiation-order/Crystal/exponentiation-order.cr +++ /dev/null @@ -1,3 +0,0 @@ -p 5**3**2, - (5**3)**2, - 5**(3**2) diff --git a/Task/Exponentiation-order/Delphi/exponentiation-order.pas b/Task/Exponentiation-order/Delphi/exponentiation-order.delphi similarity index 100% rename from Task/Exponentiation-order/Delphi/exponentiation-order.pas rename to Task/Exponentiation-order/Delphi/exponentiation-order.delphi diff --git a/Task/Exponentiation-order/DuckDB/exponentiation-order.duckdb b/Task/Exponentiation-order/DuckDB/exponentiation-order.duckdb deleted file mode 100644 index c5978fa615..0000000000 --- a/Task/Exponentiation-order/DuckDB/exponentiation-order.duckdb +++ /dev/null @@ -1,6 +0,0 @@ -select 5^3^2, - (5^3)^2, - 5^(3^2), - 5**3**2, - (5**3)**2, - 5**(3**2); diff --git a/Task/Exponentiation-order/EasyLang/exponentiation-order.easy b/Task/Exponentiation-order/EasyLang/exponentiation-order.easy deleted file mode 100644 index 8ebcdfd74f..0000000000 --- a/Task/Exponentiation-order/EasyLang/exponentiation-order.easy +++ /dev/null @@ -1,2 +0,0 @@ -print "(5 ^ 3) ^ 2 = " & pow (pow 5 3) 2 -print "5 ^ (3 ^ 2) = " & pow 5 pow 3 2 diff --git a/Task/Exponentiation-order/Icon/exponentiation-order.icon b/Task/Exponentiation-order/Icon/exponentiation-order.icon deleted file mode 100644 index 09203d2f40..0000000000 --- a/Task/Exponentiation-order/Icon/exponentiation-order.icon +++ /dev/null @@ -1,5 +0,0 @@ -procedure main() - write("5^3^2 = ", 5^3^2 ) - write("(5^3)^2 = ", (5^3)^2) - write("5^(3^2) = ", 5^(3^2)) -end diff --git a/Task/Exponentiation-order/JavaScript/exponentiation-order.js b/Task/Exponentiation-order/JavaScript/exponentiation-order.js deleted file mode 100644 index 43e3e33c06..0000000000 --- a/Task/Exponentiation-order/JavaScript/exponentiation-order.js +++ /dev/null @@ -1,5 +0,0 @@ -console.log(5 ** 3 ** 2); -console.log(5 ** (3 ** 2)); -console.log((5 ** 3) ** 2); -console.log(Math.pow(Math.pow(5, 3), 2)); -console.log(Math.pow(5, Math.pow(3, 2))); diff --git a/Task/Exponentiation-order/Julia/exponentiation-order.jl b/Task/Exponentiation-order/Julia/exponentiation-order.julia similarity index 100% rename from Task/Exponentiation-order/Julia/exponentiation-order.jl rename to Task/Exponentiation-order/Julia/exponentiation-order.julia diff --git a/Task/Exponentiation-order/Kotlin/exponentiation-order.kts b/Task/Exponentiation-order/Kotlin/exponentiation-order.kotlin similarity index 100% rename from Task/Exponentiation-order/Kotlin/exponentiation-order.kts rename to Task/Exponentiation-order/Kotlin/exponentiation-order.kotlin diff --git a/Task/Exponentiation-order/Maxima/exponentiation-order.maxima b/Task/Exponentiation-order/Maxima/exponentiation-order.maxima deleted file mode 100644 index 3d4af9a23d..0000000000 --- a/Task/Exponentiation-order/Maxima/exponentiation-order.maxima +++ /dev/null @@ -1,5 +0,0 @@ -5^3^2; -(5^3)^2; -5^(3^2); -(5**3)**2; -5^^3^^2; diff --git a/Task/Exponentiation-order/OCaml/exponentiation-order.ml b/Task/Exponentiation-order/OCaml/exponentiation-order.ocaml similarity index 100% rename from Task/Exponentiation-order/OCaml/exponentiation-order.ml rename to Task/Exponentiation-order/OCaml/exponentiation-order.ocaml diff --git a/Task/Exponentiation-order/PascalABC.NET/exponentiation-order.pas b/Task/Exponentiation-order/PascalABC.NET/exponentiation-order.pas deleted file mode 100644 index d38b6a0302..0000000000 --- a/Task/Exponentiation-order/PascalABC.NET/exponentiation-order.pas +++ /dev/null @@ -1,4 +0,0 @@ -## -println('5**3**2 =',5**3**2); -println('(5**3)**2 =',(5**3)**2); -println('5**(3**2) =',5**(3**2)); diff --git a/Task/Exponentiation-order/Phix/exponentiation-order.phix b/Task/Exponentiation-order/Phix/exponentiation-order.phix index a6f757e117..dfa7db2cb1 100644 --- a/Task/Exponentiation-order/Phix/exponentiation-order.phix +++ b/Task/Exponentiation-order/Phix/exponentiation-order.phix @@ -1,2 +1,4 @@ -?power(power(5,3),2) -?power(5,power(3,2)) +--> + ?power(power(5,3),2) + ?power(5,power(3,2)) + + for x=-5 to 5 by 10 do + for p=2 to 3 do + printf(1,"x = %2d, p = %d, power(-x,p) = %4d, -power(x,p) = %4d\n",{x,p,power(-x,p),-power(x,p)}) + end for + end for + + switch {condition1,condition2} do + case {true,true}: + case {true,false}: + case {false,true}: + case {false,false}: + end switch + + function if2(bool c1, bool c2) + return c1*10+c2 + end function -switch if2(condition1,condition2) do - case 11: - case 10: - case 01: - case 00: -end switch + switch if2(condition1,condition2) do + case 11: + case 10: + case 01: + case 00: + end switch + + enum BOTH = 0b11, FIRST = 0b10, SECOND = 0b01, NEITHER = 0b00 -function if2(bool c1, bool c2) - return c1*2+c2 -end function + function if2(bool c1, bool c2) + return c1*2+c2 + end function -integer r = if2(condition1,condition2) -if r=BOTH then -elsif r=FIRST then -elsif r=SECOND then -elsif r=NEITHER then -end if + integer r = if2(condition1,condition2) + if r=BOTH then + elsif r=FIRST then + elsif r=SECOND then + elsif r=NEITHER then + end if + + global constant T_if2 = 5200 tt_stringF("if2",T_if2) + global constant T_else1 = 5200 tt_stringF("else1",T_else1) + global constant T_else2 = 5200 tt_stringF("else2",T_else2) + + --constant T_endelseelsif = {T_end,T_else,T_elsif,T_case,T_default,T_fallthru,T_fallthrough} + constant T_endelseelsif = {T_end,T_else,T_else1,T_else2,T_elsif,T_case,T_default,T_fallthru,T_fallthrough} + + elsif ttidx=T_if2 then DoIf2() + + for N=10 to 20 do + printf(1,"%d is ",N) + if2 mod(N,2)=0, mod(N,3)=0 then + puts(1,"divisible by both two and three.\n") + else1 + puts(1,"divisible by two, but not by three.\n") + else2 + puts(1,"divisible by three, but not by two.\n") + else + puts(1,"neither divisible by two, nor by three.\n") + end if2 + end for + + with javascript_semantics + if platform()!=JS then free_console() end if + sequence primes = {2,3,5,7} + atom sieved = 10 -procedure add_block() - integer N = min((sieved-1)*sieved,400000) - sequence sieve = repeat(1,N) -- sieve[i] is really i+sieved - for i=2 to length(primes) do -- (evens filtered on output) - atom p = primes[i], p2 = p*p - if p2>sieved+N then exit end if - if p2procedure add_block() + integer N = min((sieved-1)*sieved,400000) + sequence sieve = repeat(1,N) -- sieve[i] is really i+sieved + for i=2 to length(primes) do -- (evens filtered on output) + atom p = primes[i], p2 = p*p + if p2>sieved+N then exit end if + if p2<sieved+1 then + p2 += ceil((sieved+1-p2)/p)*p + end if + p2 -= sieved + if and_bits(p2,1)=0 then p2 += p end if + -- if sieve[p2] then -- dang! + for k=p2 to N by p*2 do + sieve[k] = 0 + end for + -- end if + end for + for i=1 to N by 2 do + if sieve[i] then + primes &= i+sieved + end if + end for + sieved += N + end procedure -atom t0 = time() -while sieved<8000 do add_block() end while -printf(1,"The first 20 primes are: %v\n",{primes[1..20]}) -integer lo = abs(binary_search(100,primes)), - hi = abs(binary_search(150,primes))-1 -printf(1,"The primes between 100 and 150 are: %v\n",{primes[lo..hi]}) -lo = abs(binary_search(7700,primes)) -hi = abs(binary_search(8000,primes)) -printf(1,"There are %d primes between 7700 and 8000.\n",hi-lo) -for i=1 to iff(platform()=JS?7:8) do - integer k = power(10,i) - while length(primes)function is_prime2(integer n) + while sieved<n do + add_block() + end while + return binary_search(n,primes)>0 + end function + + atom t0 = time() + while length(primes)<20 do add_block() end while + printf(1,"The first 20 primes are: ") ?primes[1..20] + while sieved<150 do add_block() end while + sequence s = {} + for k=abs(binary_search(100,primes)) to length(primes) do + integer p = primes[k] + if p>150 then exit end if + s &= p + end for + printf(1,"The primes between 100 and 150 are: ") ?s + s = {} + for i=7700 to 8000 do + if is_prime2(i) then s&=i end if + end for + printf(1,"There are %d primes between 7700 and 8000.\n",length(s)) + for i=1 to iff(platform()=JS?7:8) do + integer k = power(10,i) + while length(primes)<k do + add_block() + end while + printf(1,"The %,dth prime is : %d\n",{k,primes[k]}) + end for + ?time()-t0 + if platform()!=JS then {} = wait_key() end if + + with javascript_semantics + atom t0 = time() + printf(1,"The first 20 primes are: %v\n",{get_primes(-20)}) + sequence s = get_primes_le(150)[length(get_primes_le(100))+1..$] + printf(1,"The primes between 100 and 150 are: %v\n",{s}) + integer n7700to8000 = length(get_primes_le(8000))-length(get_primes_le(7700)) + printf(1,"There are %d primes between 7700 and 8000.\n",n7700to8000) + for i=1 to iff(platform()=JS?7:8) do + integer k = power(10,i) + printf(1,"The %,dth prime is : %d\n",{k,get_prime(k)}) + end for + ?time()-t0 + if platform()!=JS then {} = wait_key() end if + + with javascript_semantics + constant inf = 1e300*1e300, -- (works on both 32 and 64 bit) + ninf = -inf, + nan = -(inf/inf), + nzero = -1/inf -- (not supported) -printf(1," inf: %f\n",{inf}) -printf(1," ninf: %f\n",{ninf}) -printf(1," nan: %f\n",{nan}) -printf(1,"*nzero: %f\n",{nzero}) -printf(1," inf+2: %f\n",{inf+2}) -printf(1," inf+ninf: %f\n",{inf+ninf}) -printf(1," 0*inf: %f\n",{0*inf}) -printf(1," nan+1: %f\n",{nan+1}) -printf(1," nan+nan: %f\n",{nan+nan}) -printf(1," inf>1e300: %d\n",{inf>1e300}) -printf(1," ninf<1e300: %d\n",{ninf<-1e300}) -printf(1,"*nan=nan: %d\n",{nan=nan}) -printf(1," nan=42: %d\n",{nan=42}) -printf(1,"*nan<0: %d\n",{nan<0}) -printf(1," nan>0: %d\n",{nan>0}) + printf(1," inf: %f\n",{inf}) + printf(1," ninf: %f\n",{ninf}) + printf(1," nan: %f\n",{nan}) + printf(1,"*nzero: %f\n",{nzero}) + printf(1," inf+2: %f\n",{inf+2}) + printf(1," inf+ninf: %f\n",{inf+ninf}) + printf(1," 0*inf: %f\n",{0*inf}) + printf(1," nan+1: %f\n",{nan+1}) + printf(1," nan+nan: %f\n",{nan+nan}) + printf(1," inf>1e300: %d\n",{inf>1e300}) + printf(1," ninf<1e300: %d\n",{ninf<-1e300}) + printf(1,"*nan=nan: %d\n",{nan=nan}) + printf(1," nan=42: %d\n",{nan=42}) + printf(1,"*nan<0: %d\n",{nan<0}) + printf(1," nan>0: %d\n",{nan>0}) + " + to_string(rotated, " ") << std::endl; - increment(factoradic); - } - std::cout << std::endl; - - // Part 2 - std::cout << "Generating the permutations of 11 digits:" << std::endl; - const uint32_t limit = factorial(11); - elements = convert_to_vector_of_integer("0.1.2.3.4.5.6.7.8.9.10"); - factoradic = convert_to_vector_of_integer("0.0.0.0.0.0.0.0.0.0"); - for ( uint32_t i = 0; i < limit; ++i ) { - std::vector rotated = permutation(elements, factoradic); - if ( i < 3 || i > limit - 4 ) { - std::cout << to_string(factoradic, ".") + " --> " + to_string(rotated, " ") - << std::endl; - } else if ( i == 3 ) { - std::cout << " [ ... ] " << std::endl; - } - increment(factoradic); - } - std::cout << "Number of permutations is 11! = " << limit << std::endl << std::endl; - - // Part 3 - std::vector codes = { "39.49.7.47.29.30.2.12.10.3.29.37.33.17.12.31.29.34.17.25.2.4.25.4.1.14.20.6.21.18.1.1.1.4.0.5.15.12.4.3.10.10.9.1.6.5.5.3.0.0.0", -"51.48.16.22.3.0.19.34.29.1.36.30.12.32.12.29.30.26.14.21.8.12.1.3.10.4.7.17.6.21.8.12.15.15.13.15.7.3.12.11.9.5.5.6.6.3.4.0.3.2.1" }; - - std::vector cards = { "A♠", "K♠", "Q♠", "J♠", "10♠", "9♠", "8♠", "7♠", "6♠", "5♠", "4♠", "3♠", "2♠", - "A♥", "K♥", "Q♥", "J♥", "10♥", "9♥", "8♥", "7♥", "6♥", "5♥", "4♥", "3♥", "2♥", - "A♦", "K♦", "Q♦", "J♦", "10♦", "9♦", "8♦", "7♦", "6♦", "5♦", "4♦", "3♦", "2♦", - "A♣", "K♣", "Q♣", "J♣", "10♣", "9♣", "8♣", "7♣", "6♣", "5♣", "4♣", "3♣", "2♣" - }; - - std::cout << "Original deck of cards:" << std::endl; - std::cout << to_string(cards, " ") << std::endl << std::endl; - std::cout << "Task shuffles:" << std::endl; - for ( const std::string& code : codes ) { - std::cout << code + " --> " << std::endl; - factoradic = convert_to_vector_of_integer(code); - std::cout << to_string(permutation(cards, factoradic), " ") - << std::endl << std::endl; - } - - std::cout << "Random shuffle:" << std::endl;; - std::random_device random; - std::mt19937 generator(random()); - - factoradic.clear(); - for ( uint32_t i = 0; i < cards.size() - 1; ++i ) { - std::uniform_int_distribution distribution(0, cards.size() - i - 1); - factoradic.emplace_back(distribution(generator)); - } - - std::cout << to_string(factoradic, ".") + " --> " << std::endl; - std::cout << to_string(permutation(cards, factoradic), " ") << std::endl; -} diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/FreeBASIC/factorial-base-numbers-indexing-permutations-of-a-collection.basic b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/FreeBASIC/factorial-base-numbers-indexing-permutations-of-a-collection.basic deleted file mode 100644 index abd85c0b29..0000000000 --- a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/FreeBASIC/factorial-base-numbers-indexing-permutations-of-a-collection.basic +++ /dev/null @@ -1,167 +0,0 @@ -Type Sequence - longi As Integer - dato(1000) As Integer -End Type - -Sub printSequence(s As Sequence) - Print " "; - For i As Integer = 1 To s.longi - Print Chr(8) & s.dato(i); - If i < s.longi Then Print "."; - Next i - Print -End Sub - -Function factorial(n As Integer) As Longint - If n <= 1 Then Return 1 - Return n * factorial(n - 1) -End Function - -Function tagset(n As Integer) As Sequence - Dim As Sequence result - result.longi = n - For i As Integer = 1 To n - result.dato(i) = i - Next i - Return result -End Function - -Sub showCards(s As Sequence) - Const cards = "AKQJT98765432" - Const suits = "SHDC" - - For i As Integer = 1 To s.longi - Dim As Integer c = s.dato(i) - 1 - Dim As String card = Mid(cards, (c Mod 13) + 1, 1) + Mid(suits, (c \ 13) + 1, 1) - Print card; Iif(((i Mod 13) = 0 Or i = s.longi), Chr(10), " "); - Next i - Print -End Sub - -Function fperm(fbn As Sequence, omega As Sequence) As Sequence - Dim As Integer i, g, tmp, j, m = 0 - Dim As Sequence result = omega - - For i = 1 To fbn.longi - g = fbn.dato(i) - If g > 0 Then - tmp = result.dato(m + g + 1) - For j = m + g + 1 To m + 2 Step -1 - result.dato(j) = result.dato(j - 1) - Next j - result.dato(m + 1) = tmp - End If - m += 1 - Next i - - result.longi = omega.longi - Return result -End Function - -Function factorialBaseNumbers(size As Integer, cntOnly As Integer) As Sequence - Dim As Sequence results - Dim As Integer res(1000) - Dim As Integer cnt, n, radix, k, i - - results.longi = 0 - cnt = 0 - n = 0 - Do - radix = 2 - k = n - For i = 1 To size - res(i) = 0 - Next i - - While k > 0 - If cntOnly = 0 Andalso radix <= size + 1 Then - res(size - radix + 2) = k Mod radix - End If - k \= radix - radix += 1 - Wend - - If radix > size + 2 Then Exit Do - - cnt += 1 - If cntOnly = 0 Then - results.longi += 1 - For i = 1 To size - results.dato((results.longi - 1) * size + i) = res(i) - Next i - End If - n += 1 - Loop - - If cntOnly Then - results.longi = 1 - results.dato(1) = cnt - End If - - Return results -End Function - -' Generate random factorial base number sequence -Function randFBN51() As Sequence - Dim As Sequence fbn51 - fbn51.longi = 51 - For i As Integer = 1 To 51 - fbn51.dato(i) = Int(Rnd * (52 - i)) + 1 - Next i - Return fbn51 -End Function - -' Main program -Randomize Timer -Dim As Integer i, j - -Dim As Sequence fbns = factorialBaseNumbers(3, 0) -Dim As Sequence omega -omega.longi = 4 -For i = 0 To 3 - omega.dato(i + 1) = i -Next i - -For i = 1 To fbns.longi - For j = 1 To 3 - Print fbns.dato((i-1)*3 + j) & "."; - Next j - Print Chr(8) & " ->"; - - Dim As Sequence tmp - tmp.longi = 3 - For j = 1 To 3 - tmp.dato(j) = fbns.dato((i-1)*3 + j) - Next j - - Dim As Sequence result = fperm(tmp, omega) - printSequence(result) -Next i - -Print -Dim As Sequence cnt = factorialBaseNumbers(10, 1) -Print "Permutations generated ="; cnt.dato(1) -Print " compared to 11! which ="; factorial(11) - -Print -Dim As Sequence fbn51s(3) - -' First predefined sequence -fbn51s(1).longi = 51 -Data 39,49,7,47,29,30,2,12,10,3,29,37,33,17,12,31,29,34,17,25,2,4,25,4,1,14,20,6,21,18,1,1,1,4,0,5,15,12,4,3,10,10,9,1,6,5,5,3,0,0,0 -For i = 1 To 51: Read fbn51s(1).dato(i): Next - -' Second predefined sequence -fbn51s(2).longi = 51 -Data 51,48,16,22,3,0,19,34,29,1,36,30,12,32,12,29,30,26,14,21,8,12,1,3,10,4,7,17,6,21,8,12,15,15,13,15,7,3,12,11,9,5,5,6,6,3,4,0,3,2,1 -For i = 1 To 51: Read fbn51s(2).dato(i): Next - -' Third random sequence -fbn51s(3) = randFBN51() - -' Show all card arrangements -For i = 1 To 3 - showCards(fperm(fbn51s(i), tagset(52))) -Next i - -Sleep diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java deleted file mode 100644 index 3f126f2202..0000000000 --- a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java +++ /dev/null @@ -1,110 +0,0 @@ -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; - -public final class FactorialBaseNumbersIndexingPermutations { - - public static void main(String[] args) { - // Part 1 - List elements = convertToListInteger("0.1.2.3"); - List factoradic = convertToListInteger("0.0.0"); - for ( int i = 0; i < factorial(4); i++ ) { - List rotated = permutation(elements, factoradic); - System.out.println(toString(factoradic, ".") + " --> " + toString(rotated, " ")); - increment(factoradic); - } - System.out.println(); - - // Part 2 - System.out.println("Generating the permutations of 11 digits:"); - final int limit = factorial(11); - elements = convertToListInteger("0.1.2.3.4.5.6.7.8.9.10"); - factoradic = convertToListInteger("0.0.0.0.0.0.0.0.0.0"); - for ( int i = 0; i < limit; i++ ) { - List rotated = permutation(elements, factoradic); - if ( i < 3 || i > limit - 4 ) { - System.out.println(toString(factoradic, ".") + " --> " + toString(rotated, " ")); - } else if ( i == 3 ) { - System.out.println(" [ ... ] "); - } - increment(factoradic); - } - System.out.println("Number of permutations is 11! = " + limit + System.lineSeparator()); - - // Part 3. - List codes = List.of( - "39.49.7.47.29.30.2.12.10.3.29.37.33.17.12.31.29.34.17.25.2.4.25.4.1.14" - + ".20.6.21.18.1.1.1.4.0.5.15.12.4.3.10.10.9.1.6.5.5.3.0.0.0", - "51.48.16.22.3.0.19.34.29.1.36.30.12.32.12.29.30.26.14.21.8.12.1.3.10.4" - + ".7.17.6.21.8.12.15.15.13.15.7.3.12.11.9.5.5.6.6.3.4.0.3.2.1" ); - - List cards = List.of( "A♠", "K♠", "Q♠", "J♠", "10♠", "9♠", "8♠", "7♠", "6♠", "5♠", "4♠", "3♠", "2♠", - "A♥", "K♥", "Q♥", "J♥", "10♥", "9♥", "8♥", "7♥", "6♥", "5♥", "4♥", "3♥", "2♥", - "A♦", "K♦", "Q♦", "J♦", "10♦", "9♦", "8♦", "7♦", "6♦", "5♦", "4♦", "3♦", "2♦", - "A♣", "K♣", "Q♣", "J♣", "10♣", "9♣", "8♣", "7♣", "6♣", "5♣", "4♣", "3♣", "2♣" ); - - System.out.println("Original deck of cards:"); - System.out.println(toString(cards, " ") + System.lineSeparator()); - System.out.println("Task shuffles:"); - for ( String code : codes ) { - System.out.println(code + " --> "); - factoradic = convertToListInteger(code); - System.out.println(toString(permutation(cards, factoradic), " ")); - System.out.println(); - } - - System.out.println("Random shuffle:"); - ThreadLocalRandom random = ThreadLocalRandom.current(); - factoradic.clear(); - for ( int i = 0; i < cards.size() - 1; i++ ) { - factoradic.add(random.nextInt(cards.size() - i)); - } - System.out.println(toString(factoradic, ".") + " --> "); - System.out.println(toString(permutation(cards, factoradic), " ")); - } - - private static List permutation(List elements, List factoradic) { - List copy = new ArrayList(elements); - int m = 0; - for ( int g : factoradic ) { - Collections.rotate(copy.subList(m, m + g + 1), 1); - m += 1; - } - return copy; - } - - private static void increment(List factoradic) { - int index = factoradic.size() - 1; - while ( index >= 0 && factoradic.get(index) == factoradic.size() - index ) { - factoradic.set(index, 0); - index -= 1; - } - if ( index >= 0 ) { - factoradic.set(index, factoradic.get(index) + 1); - } - } - - private static List convertToListInteger(String text) { - List result = new ArrayList(); - String[] numbers = text.split("\\."); - for ( String number : numbers ) { - result.add(Integer.valueOf(number)); - } - return result; - } - - private static int factorial(int n) { - int factorial = 1; - for ( int i = 2; i <= n; i++ ) { - factorial *= i; - } - return factorial; - } - - private static String toString(List factoradic, String delimiter) { - return factoradic.stream().map(String::valueOf).collect(Collectors.joining(delimiter)); - } - -} diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/JavaScript/factorial-base-numbers-indexing-permutations-of-a-collection.js b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/JavaScript/factorial-base-numbers-indexing-permutations-of-a-collection.js deleted file mode 100644 index 2b4f52172f..0000000000 --- a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/JavaScript/factorial-base-numbers-indexing-permutations-of-a-collection.js +++ /dev/null @@ -1,170 +0,0 @@ -// Helper function to convert values to strings -function stringify(text) { - return text; -} - -function stringifyNumber(number) { - return String(number); -} - -// Join array elements with delimiter -function toStringArray(factoradic, delimiter) { - let result = ""; - for (let i = 0; i < factoradic.length - 1; i++) { - result += stringifyNumber(factoradic[i]) + delimiter; - } - result += stringifyNumber(factoradic[factoradic.length - 1]); - return result; -} - -// Calculate factorial -function factorial(n) { - let result = 1; - for (let i = 2; i <= n; i++) { - result *= i; - } - return result; -} - -// Increment factoradic number -function increment(factoradic) { - let index = factoradic.length - 1; - while (index >= 0 && factoradic[index] === factoradic.length - index) { - factoradic[index] = 0; - index -= 1; - } - if (index >= 0) { - factoradic[index] += 1; - } -} - -// Split string by delimiter -function splitString(text, delimiter) { - const lines = []; - let start = 0; - let end = text.indexOf(delimiter); - - while (end !== -1) { - const line = text.substring(start, end); - if (line !== "") { - lines.push(line); - } - start = end + 1; - end = text.indexOf(delimiter, start); - } - - const lastLine = text.substring(start); - if (lastLine !== "") { - lines.push(lastLine); - } - - return lines; -} - -// Convert "a.b.c" format to array of integers -function convertToVectorOfInteger(text) { - const result = []; - const numbers = splitString(text, '.'); - for (const number of numbers) { - result.push(parseInt(number, 10)); - } - return result; -} - -// Generate permutation from elements and factoradic representation -function permutation(elements, factoradic) { - const result = [...elements]; - let m = 0; - - for (const g of factoradic) { - const element = result[m + g]; - result.splice(m + g, 1); - result.splice(m, 0, element); - m += 1; - } - - return result; -} - -// Main execution -function main() { - // Part 1 - console.log("Part 1: Permutations of 4 elements"); - console.log("=".repeat(50)); - - let elements = convertToVectorOfInteger("0.1.2.3"); - let factoradic = convertToVectorOfInteger("0.0.0"); - - for (let i = 0; i < factorial(4); i++) { - const rotated = permutation(elements, factoradic); - console.log(toStringArray(factoradic, '.') + " --> " + rotated.join(' ')); - increment(factoradic); - } - console.log(); - - // Part 2 - console.log("Part 2: Permutations of 11 digits"); - console.log("=".repeat(50)); - - const limit = factorial(11); - elements = convertToVectorOfInteger("0.1.2.3.4.5.6.7.8.9.10"); - factoradic = convertToVectorOfInteger("0.0.0.0.0.0.0.0.0.0"); - - for (let i = 0; i < limit; i++) { - const rotated = permutation(elements, factoradic); - if (i < 3 || i > limit - 4) { - console.log(toStringArray(factoradic, '.') + " --> " + rotated.join(' ')); - } else if (i === 3) { - console.log(" [ ... ] "); - } - increment(factoradic); - } - console.log("Number of permutations is 11! = " + limit); - console.log(); - - // Part 3 - console.log("Part 3: Card shuffling with factoradic representation"); - console.log("=".repeat(50)); - - const codes = [ - "39.49.7.47.29.30.2.12.10.3.29.37.33.17.12.31.29.34.17.25.2.4.25.4.1.14.20.6.21.18.1.1.1.4.0.5.15.12.4.3.10.10.9.1.6.5.5.3.0.0.0", - "51.48.16.22.3.0.19.34.29.1.36.30.12.32.12.29.30.26.14.21.8.12.1.3.10.4.7.17.6.21.8.12.15.15.13.15.7.3.12.11.9.5.5.6.6.3.4.0.3.2.1" - ]; - - const suits = ['♠', '♥', '♦', '♣']; - const ranks = ['A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2']; - - const cards = []; - for (const suit of suits) { - for (const rank of ranks) { - cards.push(rank + suit); - } - } - - console.log("Original deck of cards:"); - console.log(cards.join(' ')); - console.log(); - - console.log("Task shuffles:"); - for (const code of codes) { - console.log(code + " --> "); - factoradic = convertToVectorOfInteger(code); - const shuffled = permutation(cards, factoradic); - console.log(shuffled.join(' ')); - console.log(); - } - - console.log("Random shuffle:"); - factoradic = []; - for (let i = 0; i < cards.length - 1; i++) { - const randomIndex = Math.floor(Math.random() * (cards.length - i)); - factoradic.push(randomIndex); - } - - console.log(toStringArray(factoradic, '.') + " --> "); - const randomShuffled = permutation(cards, factoradic); - console.log(randomShuffled.join(' ')); -} - -// Run the program -main(); diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Julia/factorial-base-numbers-indexing-permutations-of-a-collection.jl b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Julia/factorial-base-numbers-indexing-permutations-of-a-collection.julia similarity index 100% rename from Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Julia/factorial-base-numbers-indexing-permutations-of-a-collection.jl rename to Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Julia/factorial-base-numbers-indexing-permutations-of-a-collection.julia diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Wren/factorial-base-numbers-indexing-permutations-of-a-collection.wren b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Wren/factorial-base-numbers-indexing-permutations-of-a-collection.wren index 395694ccdf..3b66e3b3b6 100644 --- a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Wren/factorial-base-numbers-indexing-permutations-of-a-collection.wren +++ b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Wren/factorial-base-numbers-indexing-permutations-of-a-collection.wren @@ -1,6 +1,6 @@ import "random" for Random -import "./math" for Int -import "./fmt" for Fmt +import "/math" for Int +import "/fmt" for Fmt var genFactBaseNums = Fn.new { |size, countOnly| var results = [] diff --git a/Task/Factorial-primes/ALGOL-68/factorial-primes.alg b/Task/Factorial-primes/ALGOL-68/factorial-primes.alg index 86395265f7..2cc56e0011 100644 --- a/Task/Factorial-primes/ALGOL-68/factorial-primes.alg +++ b/Task/Factorial-primes/ALGOL-68/factorial-primes.alg @@ -10,24 +10,27 @@ BEGIN # find some factorial primes - primes that are f - 1 or f + 1 # FOR i FROM 3 BY 2 TO SHORTEN ENTIER long sqrt(p) WHILE prime := p MOD i /= 0 DO SKIP OD; prime FI; -# end of code based on the primality by trial division task # +# end of code based on the primality by trial divisio task # + PROC show factorial prime = ( INT fp number, INT n, CHAR fp op, LONG INT fp )VOID: + print( ( whole( fp number, -2 ), ":", whole( n, -4 ) + , "! ", fp op, " 1 = ", whole( fp, 0 ) + , newline + ) + ); LONG INT f := 1; INT fp count := 0; FOR n WHILE fp count < 10 DO f *:= n; - CHAR fp op := "-"; - FOR offset FROM -1 BY 2 TO 1 DO - IF LONG INT fp = f + offset; - is prime( fp ) - THEN - print( ( whole( fp count +:= 1, -2 ), ":", whole( n, -4 ) - , "! ", fp op, " 1 = ", whole( fp, 0 ) - , newline - ) - ) - FI; - fp op := "+" - OD + IF LONG INT fp = f - 1; + is prime( fp ) + THEN + show factorial prime( fp count +:= 1, n, "-", fp ) + FI; + IF LONG INT fp = f + 1; + is prime( fp ) + THEN + show factorial prime( fp count +:= 1, n, "+", fp ) + FI OD END diff --git a/Task/Factorial-primes/ALGOL-W/factorial-primes.alg b/Task/Factorial-primes/ALGOL-W/factorial-primes.alg deleted file mode 100644 index d8a6380cc6..0000000000 --- a/Task/Factorial-primes/ALGOL-W/factorial-primes.alg +++ /dev/null @@ -1,75 +0,0 @@ -begin % find some factorial primes - primes that are f - 1 or f + 1 % - % for some factorial f % - - % returns true if p is prime, false otherwise % - logical procedure isPrime ( integer value p ) ; - if p <= 1 or p rem 2 = 0 then p = 2 - else begin - logical prime; - integer rootP, i; - prime := true; - i := 3; - rootP := entier( sqrt( p ) ); - while i <= rootP and prime do begin - prime := p rem i not = 0; - i := i + 2 - end; - prime - end isPrime ; - - % returns true if p is prime, false otherwise % - logical procedure isPrimeLongReal ( long real value p ) ; - if p <= MAXINTEGER then begin - % p is small enough to test using integer arithmetic % - isPrime( entier( p ) ) - end - else begin - % p is too large for integer primality testing % - logical prime; - integer rootP, i; - prime := true; - i := 2; - rootP := entier( longsqrt( p ) ); - while i <= rootP and prime do begin - long real pOverI; - pOverI := p / i; - prime := roundToReal( pOverI ) not = pOverI; - i := if i < 3 then 3 else i + 2 - end; - prime - end isPrime ; - - begin - long real f; - integer fpCount, n; - fpCount := 0; - n := 0; - f := 1; - while fpCount < 10 do begin - long real fp; - string(1) fpOp; - n := n + 1; - f := f * n; - fpOp := "-"; - for offset := -1 step 2 until 1 do begin - fp := f + offset; - if fp < MAXINTEGER then begin - if isPrime( entier( fp ) ) then begin - fpCount := fpCount + 1; - write( s_w := 0, i_w := 2, fpCount, ":" ); - writeon( s_w := 0, i_w := 4, n, "! ", fpOp, " 1 = " ); - writeon( s_w := 0, i_w := 1, entier( fp ) ) - end if_isPrime__entier__fp - end - else if isPrimeLongReal( fp ) then begin - fpCount := fpCount + 1; - write( s_w := 0, i_w := 2, fpCount, ":" ); - writeon( s_w := 0, i_w := 4, n, "! ", fpOp, " 1 = " ); - writeon( r_format := "A", r_w := 1, r_d := 0, fp ) - end if_isPrime__fp__isPrimeLongReal__fp ; - fpOp := "+" - end for_fp - end while_fpCount_lt_10 - end - -end. diff --git a/Task/Factorial-primes/AWK/factorial-primes.awk b/Task/Factorial-primes/AWK/factorial-primes.awk deleted file mode 100644 index b2cb4bb04a..0000000000 --- a/Task/Factorial-primes/AWK/factorial-primes.awk +++ /dev/null @@ -1,15 +0,0 @@ -function isprime(n, i) { - if(n==2)return 1 - if(n<2||n%2==0)return 0 - for(i=3;i*i<=n;i+=2) - if(n%i==0)return 0 - return 1 -} - -BEGIN { - for(x=i=1;z<10;i++){ - x*=i - if(isprime(x-1)){z++;print i"! - 1 = "x-1} - if(isprime(x+1)){z++;print i"! + 1 = "x+1} - } -} diff --git a/Task/Factorial-primes/Ada/factorial-primes.adb b/Task/Factorial-primes/Ada/factorial-primes.adb deleted file mode 100644 index f264eb9d50..0000000000 --- a/Task/Factorial-primes/Ada/factorial-primes.adb +++ /dev/null @@ -1,95 +0,0 @@ --- Rosetta Code Task written in Ada --- Factorial primes --- https://rosettacode.org/wiki/Factorial_primes --- August 2024, R. B. E. --- Using GNAT Big Integers, GNAT version 14.1, MacOS 14.6.1, M1 chip - -pragma Ada_2022; -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; -with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers; - -procedure Factorial_Primes is - - function Is_Prime (N : in Big_Integer) return Boolean is - Big_0 : Big_Natural := To_Big_Integer (0); - Big_2 : Big_Natural := To_Big_Integer (2); - Big_3 : Big_Natural := To_Big_Integer (3); - Big_Temp : Big_Natural := To_Big_Integer (5); - begin - if N < Big_2 then - return False; - end if; - if N mod Big_2 = Big_0 then - return N = Big_2; - end if; - if N mod Big_3 = Big_0 then - return N = Big_3; - end if; - while Big_Temp * Big_Temp <= N loop - if N mod Big_Temp = Big_0 then - return False; - end if; - Big_Temp := Big_Temp + Big_2; - if N mod Big_Temp = Big_0 then - return False; - end if; - Big_Temp := Big_Temp + 4; - end loop; - return True; - end Is_Prime; - - function Factorial (N : Positive) return Big_Integer is - type Factorial_Array is array (1..12) of Big_Integer; - First12_Facts : Factorial_Array; - Result : Big_Integer; - begin - First12_Facts (1) := To_Big_Integer (1); - for I in 2..12 loop - First12_Facts (I) := First12_Facts (I-1) * To_Big_Integer (I); - end loop; - if (N <= 12) then - return First12_Facts (N); - else - Result := First12_Facts (12); - for I in 13..N loop - Result := Result * To_Big_Integer (I); - end loop; - end if; - return Result; - end Factorial; - - Fact : Big_Integer; - Fact_Plus_One : Big_Integer; - Fact_Minus_One : Big_Integer; - Big_One : constant Big_Integer := To_Big_Integer (1); - I, Count : Natural := 0; - Limit : constant Positive := 10; - -begin - loop - I := I + 1; - Fact := Factorial (I); - if (is_Prime (Fact - Big_One)) then - Count := Count + 1; - Put (Count, 3); - Put (": "); - Put (I, 5); - Put ("! - 1 "); - Fact_Minus_One := Fact - Big_One; - Put (To_String (Arg => Fact_Minus_One, Width => 40)); - New_Line; - end if; - if (is_Prime (Fact + Big_One)) then - Count := Count + 1; - Put (Count, 3); - Put (": "); - Put (I, 5); - Put ("! + 1 "); - Fact_Plus_One := Fact + Big_One; - Put (To_String (Arg => Fact_Plus_One, Width => 40)); - New_Line; - end if; - exit when Count >= Limit; - end loop; -end Factorial_Primes; diff --git a/Task/Factorial-primes/Agena/factorial-primes.agena b/Task/Factorial-primes/Agena/factorial-primes.agena deleted file mode 100644 index 0a76370d5e..0000000000 --- a/Task/Factorial-primes/Agena/factorial-primes.agena +++ /dev/null @@ -1,17 +0,0 @@ -scope # find some factorial primes - primes that are f - 1 or f + 1 for some factorial f - - local f, fpCount, n := 1, 0, 1 - for n while fpCount < 10 do - f *:= n; - local fpOp := "-"; - for fp from f - 1 to f + 1 by 2 do - if numtheory.isprime( fp ) then - fpCount +:= 1; - # printing fp with %s as %d has trouble with 14! - 1 - printf( "%2d:%4d! %s 1 = %s\n", fpCount, n, fpOp, fp ) - fi; - fpOp := "+" - od - od - -end diff --git a/Task/Factorial-primes/C++/factorial-primes.cpp b/Task/Factorial-primes/C++/factorial-primes.cpp index 97ee8ec66d..5d7fc43aa3 100644 --- a/Task/Factorial-primes/C++/factorial-primes.cpp +++ b/Task/Factorial-primes/C++/factorial-primes.cpp @@ -5,11 +5,11 @@ using big_int = mpz_class; -std::string to_string(const big_int& num, size_t max_digits) { +std::string to_string(const big_int& num, size_t n) { std::string str = num.get_str(); size_t len = str.size(); - if (len > max_digits) { - str.replace(max_digits / 2, len - max_digits, "..."); + if (len > n) { + str = str.substr(0, n / 2) + "..." + str.substr(len - n / 2); str += " ("; str += std::to_string(len); str += " digits)"; diff --git a/Task/Factorial-primes/Common-Lisp/factorial-primes.lisp b/Task/Factorial-primes/Common-Lisp/factorial-primes.lisp deleted file mode 100644 index 0e28867922..0000000000 --- a/Task/Factorial-primes/Common-Lisp/factorial-primes.lisp +++ /dev/null @@ -1,27 +0,0 @@ -(defun factorial (x) - (if (= x 1) - x - (* x (factorial (- x 1))))) - -(defun is-factor (x y) - (zerop (mod x y))) - -(defun is-prime (n) - (cond ((< n 4) (or (= n 2) (= n 3))) - ((or (zerop (mod n 2)) (zerop (mod n 3))) nil) - (t (loop for i from 5 to (floor (sqrt n)) by 6 - never (or (is-factor n i) - (is-factor n (+ i 2))))))) - -(defun main (&optional (limit 10)) - (let ((n 0) - (f 0)) - (loop while (< n limit) - for i from 1 - do (setf f (factorial i)) - (when (is-prime (+ f 1)) - (incf n) - (format t "~2d: ~2d! + 1 = ~12d~%" n i (+ f 1))) - (when (is-prime (- f 1)) - (incf n) - (format t "~2d: ~2d! - 1 = ~12d~%" n i (- f 1)))))) diff --git a/Task/Factorial-primes/Craft-Basic/factorial-primes.basic b/Task/Factorial-primes/Craft-Basic/factorial-primes.basic deleted file mode 100644 index b846d3d748..0000000000 --- a/Task/Factorial-primes/Craft-Basic/factorial-primes.basic +++ /dev/null @@ -1,29 +0,0 @@ -define found = 0, fct = 0, i = 1 - -do - - if found < 10 then - - let fct = factorial(i) - - if prime(fct - 1) then - - let found = found + 1 - print found, ": ", i, "! - 1 = ", fct - 1 - - endif - - if prime(fct + 1) then - - let found = found + 1 - print found, ": ", i, "! + 1 = ", fct + 1 - - endif - - let i = i + 1 - - endif - - wait - -loop found < 10 diff --git a/Task/Factorial-primes/Delphi/factorial-primes.pas b/Task/Factorial-primes/Delphi/factorial-primes.delphi similarity index 100% rename from Task/Factorial-primes/Delphi/factorial-primes.pas rename to Task/Factorial-primes/Delphi/factorial-primes.delphi diff --git a/Task/Factorial-primes/EasyLang/factorial-primes.easy b/Task/Factorial-primes/EasyLang/factorial-primes.easy deleted file mode 100644 index fd62915528..0000000000 --- a/Task/Factorial-primes/EasyLang/factorial-primes.easy +++ /dev/null @@ -1,22 +0,0 @@ -func isprim num . - if num < 2 : return 0 - i = 2 - while i <= sqrt num - if num mod i = 0 : return 0 - i += 1 - . - return 1 -. -f = 1 -while count < 10 - n += 1 - f *= n - op$ = "-" - for fp in [ f - 1, f + 1 ] - if isprim fp = 1 - count += 1 - print n & "! " & op$ & " 1 = " & fp - . - op$ = "+" - . -. diff --git a/Task/Factorial-primes/Fennel/factorial-primes.fennel b/Task/Factorial-primes/Fennel/factorial-primes.fennel deleted file mode 100644 index 8151c241fb..0000000000 --- a/Task/Factorial-primes/Fennel/factorial-primes.fennel +++ /dev/null @@ -1,30 +0,0 @@ -(do ;;; find some factorial primes - primes that are f - 1 or f + 1 for some factorial f - - (fn is-prime [p] - (if (or (<= p 1) (= 0 (% p 2))) - (= p 2) - ;else - (do (var (prime i root-p) (values true 3 (math.floor (math.sqrt p)))) - (while (and (<= i root-p) prime) - (set (prime i) (values (not= 0 (% p i)) (+ i 1))) - ) - prime - ) - ) - ) - - (var (f fp-count n) (values 1 0 1)) - (while (< fp-count 10) - (set f (* f n)) - (var fp-op "-") - (for [fp (- f 1) (+ f 1) 2] - (when (is-prime fp) - (set fp-count (+ fp-count 1)) - (io.write (string.format "%2d:%4d! %s 1 = %d\n" fp-count n fp-op fp)) - ) - (set fp-op "+") - ) - (set n (+ n 1)) - ) - -) diff --git a/Task/Factorial-primes/Frink/factorial-primes.frink b/Task/Factorial-primes/Frink/factorial-primes.frink deleted file mode 100644 index e8941229fe..0000000000 --- a/Task/Factorial-primes/Frink/factorial-primes.frink +++ /dev/null @@ -1,36 +0,0 @@ -isFactorialPrime[x] := -{ - if isPrime[x!+1] - return +1 - if x>=2 and isPrime[x!-1] - return -1 - return 0 -} - -count = 0 -n = 1 -res = new array -do -{ - f = isFactorialPrime[n] - if f != 0 - { - count = count + 1 - line = ["$count:", "$n!", f<0 ? "-" : "+", 1, "="] - line.pushAll[formatFac[n!+f]] - res.push[line] - } - n = n + 1 -} until count == 30 - -println[formatTable[res, "right"]] - -formatFac[n] := -{ - s = toString[n] - len = length[s] - if len > 40 - return [left[s,20] + "..." + right[s,20], " ($len digits)"] - else - return [s] -} diff --git a/Task/Factorial-primes/Go/factorial-primes.go b/Task/Factorial-primes/Go/factorial-primes.go deleted file mode 100644 index a808dfb619..0000000000 --- a/Task/Factorial-primes/Go/factorial-primes.go +++ /dev/null @@ -1,59 +0,0 @@ -package main - -import ( - "fmt" - "math/big" -) - -func main() { - n, count := 0, 0 - - for count < 10 { - n++ - f := factorial(n) - - if isPrime(f.Sub(f, big.NewInt(1))) { - count++ - fmt.Printf("%2d: %2d! - 1 = %s\n", count, n, f.String()) - } - - if isPrime(f.Add(f, big.NewInt(2))) { - count++ - fmt.Printf("%2d: %2d! + 1 = %s\n", count, n, f.String()) - } - } -} - -func factorial(n int) *big.Int { - result := big.NewInt(1) - - for i := 2; i <= n; i++ { - result.Mul(result, big.NewInt(int64(i))) - } - - return result -} - -func isPrime(num *big.Int) bool { - if num.Cmp(big.NewInt(2)) < 0 { - return false - } - - if num.Cmp(big.NewInt(2)) == 0 { - return true - } - - if new(big.Int).Mod(num, big.NewInt(2)).Cmp(big.NewInt(0)) == 0 { - return false - } - - sqrt := new(big.Int).Sqrt(num) - - for i := big.NewInt(3); i.Cmp(sqrt) <= 0; i.Add(i, big.NewInt(2)) { - if new(big.Int).Mod(num, i).Cmp(big.NewInt(0)) == 0 { - return false - } - } - - return true -} diff --git a/Task/Factorial-primes/Haskell/factorial-primes.hs b/Task/Factorial-primes/Haskell/factorial-primes.hs deleted file mode 100644 index 9d2d00ea68..0000000000 --- a/Task/Factorial-primes/Haskell/factorial-primes.hs +++ /dev/null @@ -1,26 +0,0 @@ -isPrime :: Integer -> Bool -isPrime n - | n < 2 = False - | n == 2 = True - | otherwise = 0 == length [i | i <- [2..floor(sqrt (fromIntegral n))], n `mod` i == 0] - -data Op = SubtractOne | AddOne - deriving (Show) - -data Prime = Prime - { fact :: Integer, - prime :: Integer, - op :: Op -} deriving (Show) - -getFactorialPrimes :: Integer -> [Prime] -getFactorialPrimes n - | isPrime (f - 2) = Prime {fact = n, prime = f - 2, op = SubtractOne} : - (if isPrime f then [Prime {fact = n, prime = f, op = AddOne}] else []) - | otherwise = (if isPrime f then [Prime {fact = n, prime = f, op = AddOne}] else []) - where - factorial n = product[1..n] - f = factorial n + 1 - -factorialPrimes = concat $ map getFactorialPrimes [1..] -main = mapM_ print $ take 10 factorialPrimes diff --git a/Task/Factorial-primes/Julia/factorial-primes.jl b/Task/Factorial-primes/Julia/factorial-primes.julia similarity index 100% rename from Task/Factorial-primes/Julia/factorial-primes.jl rename to Task/Factorial-primes/Julia/factorial-primes.julia diff --git a/Task/Factorial-primes/Kotlin/factorial-primes.kts b/Task/Factorial-primes/Kotlin/factorial-primes.kts deleted file mode 100644 index 22db036df6..0000000000 --- a/Task/Factorial-primes/Kotlin/factorial-primes.kts +++ /dev/null @@ -1,43 +0,0 @@ -import java.math.BigInteger -import java.math.BigInteger.ONE - -enum class Difference(private val displayText: String) { - MINUS_ONE("- 1"), PLUS_ONE("+ 1"); - - override fun toString(): String { - return displayText - } -} - -fun main() { - var currentFactorial = ONE - var highestFactor = 1L - var found = 0 - - while(found < 30) { - if ((currentFactorial - ONE).isProbablePrime(25)) { - printlnFactorialPrime(currentFactorial - ONE, highestFactor, Difference.MINUS_ONE) - found++ - } - if ((currentFactorial + ONE).isProbablePrime(25)) { - printlnFactorialPrime(currentFactorial + ONE, highestFactor, Difference.PLUS_ONE) - found++ - } - - highestFactor++ - currentFactorial *= BigInteger.valueOf(highestFactor) - } -} - -fun printlnFactorialPrime(factorialPrime: BigInteger, base: Long, difference: Difference) = - println("${base}! $difference = ${factorialPrime.shortenIfNecessary()}") - -fun BigInteger.shortenIfNecessary(): String { - val digits = toString() - val length = digits.length - return if (length <= 40) { - digits - } else { - "${digits.take(20)}...${digits.takeLast(20)} ($length digits)" - } -} diff --git a/Task/Factorial-primes/Lua/factorial-primes.lua b/Task/Factorial-primes/Lua/factorial-primes.lua deleted file mode 100644 index 55c20a12e9..0000000000 --- a/Task/Factorial-primes/Lua/factorial-primes.lua +++ /dev/null @@ -1,29 +0,0 @@ -do -- find some factorial primes - primes that are f - 1 or f + 1 for some factorial f - - local function isPrime( p ) - if p <= 1 or p % 2 == 0 then - return p == 2 - else - local prime, i, rootP = true, 3, math.floor( math.sqrt( p ) ) - while i <= rootP and prime do - prime, i = p % i ~= 0, i + 1 - end - return prime - end - end - - local f, fpCount, n = 1, 0, 1 - while fpCount < 10 do - f = f * n - local fpOp = "-" - for fp = f - 1, f + 1, 2 do - if isPrime( fp ) then - fpCount = fpCount + 1 - io.write( string.format( "%2d:%4d! %s 1 = %d\n", fpCount, n, fpOp, fp ) ) - end - fpOp = "+" - end - n = n + 1 - end - -end diff --git a/Task/Factorial-primes/Mathematica/factorial-primes.math b/Task/Factorial-primes/Mathematica/factorial-primes.math deleted file mode 100644 index 75ebdcc718..0000000000 --- a/Task/Factorial-primes/Mathematica/factorial-primes.math +++ /dev/null @@ -1,15 +0,0 @@ -LimitedPrint[n_] := Module[{s = IntegerString[n], len}, - len = StringLength[s]; - If[len <= 40, s, StringJoin[StringTake[s, 20], "...", StringTake[s, -20], " (", ToString[len], " digits)"]] -] - -ShowFactorialPrimes[N_] := Module[{f}, - Do[ - f = Factorial[i]; - If[PrimeQ[f - 1], Print[IntegerString[i, 10, 3], "! - 1 -> ", LimitedPrint[f - 1]]]; - If[PrimeQ[f + 1], Print[IntegerString[i, 10, 3], "! + 1 -> ", LimitedPrint[f + 1]]], - {i, 1, N} - ] -] - -ShowFactorialPrimes[1000] diff --git a/Task/Factorial-primes/Maxima/factorial-primes.maxima b/Task/Factorial-primes/Maxima/factorial-primes.maxima deleted file mode 100644 index e78b212a99..0000000000 --- a/Task/Factorial-primes/Maxima/factorial-primes.maxima +++ /dev/null @@ -1,6 +0,0 @@ -block([i:1,count:0,result:[]], - while count<10 do (if primep(i!-1) or primep(i!+1) then (result:endcons(i,result),count:count+1),i:i+1), - result:map(lambda([x],[x,x!-1,x!+1]),result), - append(map(lambda([x],if primep(x[2]) then [x[1],x[2],"subtracted"]),result),map(lambda([x],if primep(x[3]) then [x[1],x[3],"added"]),result)), - unique(%%), - firstn(%%,10); diff --git a/Task/Factorial-primes/OCaml/factorial-primes.ml b/Task/Factorial-primes/OCaml/factorial-primes.ocaml similarity index 100% rename from Task/Factorial-primes/OCaml/factorial-primes.ml rename to Task/Factorial-primes/OCaml/factorial-primes.ocaml diff --git a/Task/Factorial-primes/PascalABC.NET/factorial-primes.pas b/Task/Factorial-primes/PascalABC.NET/factorial-primes.pas deleted file mode 100644 index 817ecf3506..0000000000 --- a/Task/Factorial-primes/PascalABC.NET/factorial-primes.pas +++ /dev/null @@ -1,42 +0,0 @@ -function IsPrime(n: int64): boolean; -begin - if (n = 2) or (n = 3) then Result := true - else if (n <= 1) or ((n mod 2) = 0) or ((n mod 3) = 0) then Result := false - else - begin - var i := 5; - Result := False; - while i <= trunc(sqrt(n)) do - begin - if ((n mod i) = 0) or ((n mod (i + 2)) = 0) then exit; - i += 6; - end; - Result := True; - end; -end; - -function Factorial(n: integer): int64; -begin - Result := 1; - for var i := 2 to n do Result *= i; -end; - -begin - var found := 0; - var i := 1; - while found < 10 do - begin - var fact := Factorial(i); - if IsPrime(fact - 1) then - begin - writeln(i:2, '! - 1 = ', fact - 1); - found += 1; - end; - if IsPrime(fact + 1) then - begin - writeln(i:2, '! + 1 = ', fact + 1); - found += 1; - end; - i += 1; - end; -end. diff --git a/Task/Factorial-primes/Pluto/factorial-primes.pluto b/Task/Factorial-primes/Pluto/factorial-primes.pluto deleted file mode 100644 index 4e6b707c4e..0000000000 --- a/Task/Factorial-primes/Pluto/factorial-primes.pluto +++ /dev/null @@ -1,20 +0,0 @@ -do -- find some factorial primes - primes that are f - 1 or f + 1 for some factorial f - - local fmt = require( "fmt" ) -- RC Pluto formatting library - local int = require( "int" ) -- RC Pluto integer library, inc. prime utilities - - local f, fpCount, n = 1, 0, 0 - while fpCount < 10 do - n += 1 - f *= n - local fpOp = "-" - for fp = f - 1, f + 1, 2 do - if int.isprime( fp ) then - fpCount += 1 - fmt.write( "%2d:%4d! %s 1 = %d\n", fpCount, n, fpOp, fp ) - end - fpOp = "+" - end - end - -end diff --git a/Task/Factorial-primes/PureBasic/factorial-primes.basic b/Task/Factorial-primes/PureBasic/factorial-primes.basic deleted file mode 100644 index 37ad8b8d2f..0000000000 --- a/Task/Factorial-primes/PureBasic/factorial-primes.basic +++ /dev/null @@ -1,24 +0,0 @@ -;XIncludeFile "isprime.pb" -;XIncludeFile "factorial.pb" - -If OpenConsole() - PrintN("First 10 factorial primes:") - Define found.i = 0, i,i = 1, fct.i - - While found < 10 - fct = factorial (i) - - If isprime(fct-1) - found + 1 - PrintN(RSet(Str(found),2) + ": " + RSet(Str(i),2) + "! - 1 = " + Str(fct-1)) - EndIf - If isprime(fct+1) - found + 1 - PrintN(RSet(Str(found),2) + ": " + RSet(Str(i),2) + "! + 1 = " + Str(fct+1)) - EndIf - i + 1 - Wend - - PrintN(#CRLF$ + "--- terminado, pulsa RETURN---"): Input() - CloseConsole() -EndIf diff --git a/Task/Factorial-primes/Quackery/factorial-primes.quackery b/Task/Factorial-primes/Quackery/factorial-primes.quackery deleted file mode 100644 index d746e3a6f0..0000000000 --- a/Task/Factorial-primes/Quackery/factorial-primes.quackery +++ /dev/null @@ -1,20 +0,0 @@ - [ dup 10 < if sp echo ] is recho ( n --> ) - - [] 0 - [ 1+ dup ! - dup dip - [ 1 - isprime if - [ tuck negate join swap ] ] - 1+ isprime if - [ tuck join swap ] - over size 9 > until ] - drop 10 split drop - witheach - [ i^ 1+ - recho say ": " - dup abs tuck recho - 0 < iff - [ say "! - 1 = " -1 ] - else - [ say "! + 1 = " 1 ] - swap ! + echo cr ] diff --git a/Task/Factorial-primes/R/factorial-primes.r b/Task/Factorial-primes/R/factorial-primes.r deleted file mode 100644 index 583498b194..0000000000 --- a/Task/Factorial-primes/R/factorial-primes.r +++ /dev/null @@ -1,29 +0,0 @@ -library(gmp) - -print_20digits <- function(z){ - s <- as.character(z) - if(nchar(s)>40){ - paste0(substring(s, 1, 20), "...", substring(s, nchar(s)-19, nchar(s))) - } - else return(s) -} - -count <- 0 -n <- 1 -while(count<33){ - plus <- factorialZ(n)+1 - minus <- factorialZ(n)-1 - if(isprime(plus)!=0){ - cat(n, "!+1 = ", print_20digits(plus), - " (", nchar(as.character(plus)), " digits)", - "\n", sep="") - count <- count+1 - } - if(isprime(minus)!=0){ - cat(n, "!-1 = ", print_20digits(minus), - " (", nchar(as.character(minus)), " digits)", - "\n", sep="") - count <- count+1 - } - n <- n+1 -} diff --git a/Task/Factorial-primes/Sidef/factorial-primes.sidef b/Task/Factorial-primes/Sidef/factorial-primes.sidef deleted file mode 100644 index 4ba2cf3cda..0000000000 --- a/Task/Factorial-primes/Sidef/factorial-primes.sidef +++ /dev/null @@ -1,14 +0,0 @@ -var factorial_primes = Enumerator({|f| - for k in (1..Inf) { - if (k!-1 -> is_prime) { f([k, -1]) } - if (k!+1 -> is_prime) { f([k, +1]) } - } -}) - -func abr(v) { - v.len <= 40 ? v : (v.to_s.first(20) + '..' + v.to_s.last(20) + " (#{v.len} digits)") -} - -factorial_primes.first(30).each_2d {|k,i| - printf("%3d! %s %d = %s\n", k, (i.sgn < 0 ? '-' : '+'), i.abs, abr(k! + i)) -} diff --git a/Task/Factorial-primes/Unicon/factorial-primes.unicon b/Task/Factorial-primes/Unicon/factorial-primes.unicon deleted file mode 100644 index 4de95546a3..0000000000 --- a/Task/Factorial-primes/Unicon/factorial-primes.unicon +++ /dev/null @@ -1,11 +0,0 @@ -link fastprime - -procedure main(A) - limit := \A[1] | 10 - every f := gfactorial(n := seq()) do { - if (x := (is_prime(y := f-1),n||"!-1")) then - (write(" (",x,",",y,")"), if 0 = (limit -:= 1) then break) - if (x := (is_prime(y := f+1),n||"!+1")) then - (write(" (",x,",",y,")"), if 0 = (limit -:= 1) then break) - } -end diff --git a/Task/Factorial/8th/factorial.8th b/Task/Factorial/8th/factorial.8th deleted file mode 100644 index d385be5c27..0000000000 --- a/Task/Factorial/8th/factorial.8th +++ /dev/null @@ -1,2 +0,0 @@ -: factorial \ n -- n! - 1 swap ' n:* 1 rot loop ; diff --git a/Task/Factorial/ALGOL-60/factorial.alg b/Task/Factorial/ALGOL-60/factorial.alg new file mode 100644 index 0000000000..6b44ce94eb --- /dev/null +++ b/Task/Factorial/ALGOL-60/factorial.alg @@ -0,0 +1,14 @@ +begin + comment factorial - algol 60; + integer procedure factorial(n); integer n; + begin + integer i,fact; + fact:=1; + for i:=2 step 1 until n do + fact:=fact*i; + factorial:=fact + end; + integer i; + for i:=1 step 1 until 10 do outinteger(1,factorial(i)); + outstring(1,"\n") +end diff --git a/Task/Factorial/ALGOL-68/factorial-1.alg b/Task/Factorial/ALGOL-68/factorial-1.alg new file mode 100644 index 0000000000..170a8c2633 --- /dev/null +++ b/Task/Factorial/ALGOL-68/factorial-1.alg @@ -0,0 +1,5 @@ +PROC factorial = (INT upb n)LONG LONG INT:( + LONG LONG INT z := 1; + FOR n TO upb n DO z *:= n OD; + z +); ~ diff --git a/Task/Factorial/ALGOL-68/factorial-2.alg b/Task/Factorial/ALGOL-68/factorial-2.alg new file mode 100644 index 0000000000..191fe07cfb --- /dev/null +++ b/Task/Factorial/ALGOL-68/factorial-2.alg @@ -0,0 +1,30 @@ +INT g = 7; +[]REAL p = []REAL(0.99999999999980993, 676.5203681218851, -1259.1392167224028, + 771.32342877765313, -176.61502916214059, 12.507343278686905, + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7)[@0]; + +PROC complex gamma = (COMPL in z)COMPL: ( + # Reflection formula # + COMPL z := in z; + IF re OF z < 0.5 THEN + pi / (complex sin(pi*z)*complex gamma(1-z)) + ELSE + z -:= 1; + COMPL x := p[0]; + FOR i TO g+1 DO x +:= p[i]/(z+i) OD; + COMPL t := z + g + 0.5; + complex sqrt(2*pi) * t**(z+0.5) * complex exp(-t) * x + FI +); + +OP ** = (COMPL z, p)COMPL: ( z=0|0|complex exp(complex ln(z)*p) ); +PROC factorial = (COMPL n)COMPL: complex gamma(n+1); + +FORMAT compl fmt = $g(-16, 8)"⊥"g(-10, 8)$; + +test:( + printf(($q"factorial(-0.5)**2="f(compl fmt)l$, factorial(-0.5)**2)); + FOR i TO 9 DO + printf(($q"factorial("d")="f(compl fmt)l$, i, factorial(i))) + OD +) diff --git a/Task/Factorial/ALGOL-68/factorial-3.alg b/Task/Factorial/ALGOL-68/factorial-3.alg new file mode 100644 index 0000000000..c9c3e54dd2 --- /dev/null +++ b/Task/Factorial/ALGOL-68/factorial-3.alg @@ -0,0 +1,7 @@ +PROC factorial = (INT n)LONG LONG INT: + CASE n+1 IN + 1,1,2,6,24,120,720 # a brief lookup # + OUT + n*factorial(n-1) + ESAC +; ~ diff --git a/Task/Factorial/ALGOL-W/factorial.alg b/Task/Factorial/ALGOL-W/factorial.alg new file mode 100644 index 0000000000..d52282365a --- /dev/null +++ b/Task/Factorial/ALGOL-W/factorial.alg @@ -0,0 +1,15 @@ +begin + % computes factorial n iteratively % + integer procedure factorial( integer value n ) ; + if n < 2 + then 1 + else begin + integer f; + f := 2; + for i := 3 until n do f := f * i; + f + end factorial ; + + for t := 0 until 10 do write( "factorial: ", t, factorial( t ) ); + +end. diff --git a/Task/Factorial/APL/factorial-4.apl b/Task/Factorial/APL/factorial-4.apl deleted file mode 100644 index 97b8778c57..0000000000 --- a/Task/Factorial/APL/factorial-4.apl +++ /dev/null @@ -1,3 +0,0 @@ - fac←{⍵>1 : ⍵×fac ⍵-1 ⋄ 1} - fac 5 -120 diff --git a/Task/Factorial/Acornsoft-Lisp/factorial-1.lisp b/Task/Factorial/Acornsoft-Lisp/factorial-1.lisp deleted file mode 100644 index e188cec74f..0000000000 --- a/Task/Factorial/Acornsoft-Lisp/factorial-1.lisp +++ /dev/null @@ -1,3 +0,0 @@ -(defun factorial (n) - (cond ((zerop n) 1) - (t (times n (factorial (sub1 n)))))) diff --git a/Task/Factorial/Acornsoft-Lisp/factorial-2.lisp b/Task/Factorial/Acornsoft-Lisp/factorial-2.lisp deleted file mode 100644 index 85bea1e0b4..0000000000 --- a/Task/Factorial/Acornsoft-Lisp/factorial-2.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(defun factorial (n (result . 1)) - (loop - (until (zerop n) result) - (setq result (times n result)) - (setq n (sub1 n)))) diff --git a/Task/Factorial/Ada/factorial-1.adb b/Task/Factorial/Ada/factorial-1.ada similarity index 100% rename from Task/Factorial/Ada/factorial-1.adb rename to Task/Factorial/Ada/factorial-1.ada diff --git a/Task/Factorial/Ada/factorial-2.adb b/Task/Factorial/Ada/factorial-2.ada similarity index 100% rename from Task/Factorial/Ada/factorial-2.adb rename to Task/Factorial/Ada/factorial-2.ada diff --git a/Task/Factorial/Ada/factorial-3.adb b/Task/Factorial/Ada/factorial-3.ada similarity index 100% rename from Task/Factorial/Ada/factorial-3.adb rename to Task/Factorial/Ada/factorial-3.ada diff --git a/Task/Factorial/Agena/factorial.agena b/Task/Factorial/Agena/factorial.agena deleted file mode 100644 index 8b050fee0e..0000000000 --- a/Task/Factorial/Agena/factorial.agena +++ /dev/null @@ -1,25 +0,0 @@ -scope # factorials using the arbitrary precision mapm library - - import mapm; # explicit import needed for: Linux, Mac OS X, Windows and Solaris - - mapm.xdigits( 100 ); # need to set the precision - 100 is enough for 60! - - # computes factorial n iteratively, using mapm - local constant factorial := proc( n :: number ) :: xnumber - if n < 2 then return mapm.xnumber( 1 ) - else - local f := mapm.xnumber( 2 ); - for i from 3 to n do f := f * i od; - return f - fi - end; - # returns a string representation of the integer portion of an xnumber - local constant asstring := proc( n :: xnumber ) :: string - local constant str := mapm.xtostring( n ); - local constant point := "." in str; - return if point <> null then str[ 1 to point - 1 ] else str fi; - end; - - for t from 0 to 9 do printf( "%2d! is %d\n", t, mapm.xtonumber( factorial( t ) ) ) od; - for t from 10 to 60 by 10 do printf( "%2d! is %s\n", t, asstring( factorial( t ) ) ) od; -end diff --git a/Task/Factorial/Apple/factorial-1.apple b/Task/Factorial/Apple/factorial-1.apple deleted file mode 100644 index a882f89b83..0000000000 --- a/Task/Factorial/Apple/factorial-1.apple +++ /dev/null @@ -1,2 +0,0 @@ - > [(*)/ₒ 1 (⍳ 1 x 1)] 7 -5040 diff --git a/Task/Factorial/Apple/factorial-2.apple b/Task/Factorial/Apple/factorial-2.apple deleted file mode 100644 index bf4bf79fa7..0000000000 --- a/Task/Factorial/Apple/factorial-2.apple +++ /dev/null @@ -1,16 +0,0 @@ - > :asm [(*)/ₒ 1 (⍳ 1 x 1)] - - mov x6, x0 - mov x0, #0x1 - mov x2, #0x1 - eor x1, x1, x1 - cmp x1, x6 - b.GE apple_1 -apple_0: - mul x0, x0, x2 - add x2, x2, #0x1 - add x1, x1, #0x1 - cmp x1, x6 - b.LT apple_0 -apple_1: - ret diff --git a/Task/Factorial/ArkScript/factorial.ark b/Task/Factorial/ArkScript/factorial.ark deleted file mode 100644 index 41607c70ad..0000000000 --- a/Task/Factorial/ArkScript/factorial.ark +++ /dev/null @@ -1,13 +0,0 @@ -(let factorial (fun (n) { - (mut result 1) - (mut i 2) - (while (< i n) { - (set result (* result i)) - (set i (+ 1 i)) }) - result })) - -(import std.List) - -(list:forEach - (list:iota 0 8) - (fun (n) (print n "\t" (factorial n)))) diff --git a/Task/Factorial/Arturo/factorial-1.arturo b/Task/Factorial/Arturo/factorial-1.arturo index 5adbf912c3..e61492a8b4 100644 --- a/Task/Factorial/Arturo/factorial-1.arturo +++ b/Task/Factorial/Arturo/factorial-1.arturo @@ -1,7 +1,4 @@ -factorial: function [n][ - switch n > 0 -> n * factorial n-1 - -> 1 +factorial: $[n][ + if? n>0 [n * factorial n-1] + else [1] ] - -loop 1..19 [x]-> - print ["Factorial of" x "=" factorial x] diff --git a/Task/Factorial/Arturo/factorial-2.arturo b/Task/Factorial/Arturo/factorial-2.arturo index 79b191bdb4..6e6d40e330 100644 --- a/Task/Factorial/Arturo/factorial-2.arturo +++ b/Task/Factorial/Arturo/factorial-2.arturo @@ -1,7 +1,3 @@ factorial: $[n][ fold.seed:1 1..n [a,b][a*b] ] - -loop 1..19 [x][ - print ["Factorial of" x "=" factorial x] -] diff --git a/Task/Factorial/Asymptote/factorial.asymptote b/Task/Factorial/Asymptote/factorial.asymptote deleted file mode 100644 index 4108263689..0000000000 --- a/Task/Factorial/Asymptote/factorial.asymptote +++ /dev/null @@ -1,10 +0,0 @@ -real factorial(int n) { - real f = 1; - for (int i = 2; i <= n; ++i) - f = f * i; - return f; -} - -write("The factorials for the first 5 positive integers are:"); -for (int j = 1; j <= 5; ++j) - write(string(j) + "! = " + string(factorial(j))); diff --git a/Task/Factorial/AutoIt/factorial-1.au3 b/Task/Factorial/AutoIt/factorial-1.autoit similarity index 100% rename from Task/Factorial/AutoIt/factorial-1.au3 rename to Task/Factorial/AutoIt/factorial-1.autoit diff --git a/Task/Factorial/AutoIt/factorial-2.au3 b/Task/Factorial/AutoIt/factorial-2.autoit similarity index 100% rename from Task/Factorial/AutoIt/factorial-2.au3 rename to Task/Factorial/AutoIt/factorial-2.autoit diff --git a/Task/Factorial/Bruijn/factorial.bruijn b/Task/Factorial/Bruijn/factorial.bruijn deleted file mode 100644 index 5fe7e558e6..0000000000 --- a/Task/Factorial/Bruijn/factorial.bruijn +++ /dev/null @@ -1,5 +0,0 @@ -:import std/Math . - -factorial [∏ (+1) → 0 | [0]] - -:test ((factorial (+10)) =? (+3628800)) ([[1]]) diff --git a/Task/Factorial/CBASIC/factorial.basic b/Task/Factorial/CBASIC/factorial.basic deleted file mode 100644 index 3ca40654ad..0000000000 --- a/Task/Factorial/CBASIC/factorial.basic +++ /dev/null @@ -1,19 +0,0 @@ -rem - return n! -def fn.factorial(n) - f = 1 - for i = 1 to n - f = f * i - next i - fn.factorial = f - return -fend - -print "Factorial Calculator" -print -print " n n!" -print "-------------------" -for k = 1 to 14 - print using "## ###,###,###,###"; k; fn.factorial(k) -next k - -end diff --git a/Task/Factorial/COBOL/factorial-1.cob b/Task/Factorial/COBOL/factorial-1.cobol similarity index 100% rename from Task/Factorial/COBOL/factorial-1.cob rename to Task/Factorial/COBOL/factorial-1.cobol diff --git a/Task/Factorial/COBOL/factorial-2.cob b/Task/Factorial/COBOL/factorial-2.cobol similarity index 100% rename from Task/Factorial/COBOL/factorial-2.cob rename to Task/Factorial/COBOL/factorial-2.cobol diff --git a/Task/Factorial/COBOL/factorial-3.cob b/Task/Factorial/COBOL/factorial-3.cobol similarity index 100% rename from Task/Factorial/COBOL/factorial-3.cob rename to Task/Factorial/COBOL/factorial-3.cobol diff --git a/Task/Factorial/COBOL/factorial-4.cob b/Task/Factorial/COBOL/factorial-4.cobol similarity index 100% rename from Task/Factorial/COBOL/factorial-4.cob rename to Task/Factorial/COBOL/factorial-4.cobol diff --git a/Task/Factorial/Chapel/factorial.chpl b/Task/Factorial/Chapel/factorial.chapel similarity index 100% rename from Task/Factorial/Chapel/factorial.chpl rename to Task/Factorial/Chapel/factorial.chapel diff --git a/Task/Factorial/Rocq/factorial.rocq b/Task/Factorial/Coq/factorial.coq similarity index 100% rename from Task/Factorial/Rocq/factorial.rocq rename to Task/Factorial/Coq/factorial.coq diff --git a/Task/Factorial/Crystal/factorial-1.cr b/Task/Factorial/Crystal/factorial-1.crystal similarity index 100% rename from Task/Factorial/Crystal/factorial-1.cr rename to Task/Factorial/Crystal/factorial-1.crystal diff --git a/Task/Factorial/Crystal/factorial-2.cr b/Task/Factorial/Crystal/factorial-2.crystal similarity index 100% rename from Task/Factorial/Crystal/factorial-2.cr rename to Task/Factorial/Crystal/factorial-2.crystal diff --git a/Task/Factorial/Delphi/factorial-1.pas b/Task/Factorial/Delphi/factorial-1.delphi similarity index 100% rename from Task/Factorial/Delphi/factorial-1.pas rename to Task/Factorial/Delphi/factorial-1.delphi diff --git a/Task/Factorial/Delphi/factorial-2.pas b/Task/Factorial/Delphi/factorial-2.delphi similarity index 100% rename from Task/Factorial/Delphi/factorial-2.pas rename to Task/Factorial/Delphi/factorial-2.delphi diff --git a/Task/Factorial/Delphi/factorial-3.pas b/Task/Factorial/Delphi/factorial-3.delphi similarity index 100% rename from Task/Factorial/Delphi/factorial-3.pas rename to Task/Factorial/Delphi/factorial-3.delphi diff --git a/Task/Factorial/DuckDB/factorial-1.duckdb b/Task/Factorial/DuckDB/factorial-1.duckdb deleted file mode 100644 index e4f4ecf769..0000000000 --- a/Task/Factorial/DuckDB/factorial-1.duckdb +++ /dev/null @@ -1,3 +0,0 @@ -create or replace function factorial(n) as ( - list_reduce( list_transform(range(1,n+1), x -> x::HUGEINT), (prod,n) -> prod * n) -); diff --git a/Task/Factorial/DuckDB/factorial-2.duckdb b/Task/Factorial/DuckDB/factorial-2.duckdb deleted file mode 100644 index 0ba68192de..0000000000 --- a/Task/Factorial/DuckDB/factorial-2.duckdb +++ /dev/null @@ -1,3 +0,0 @@ -create or replace function double_precision_factorial(n) as ( - list_product( range(1, n+1) ) -); diff --git a/Task/Factorial/DuckDB/factorial-3.duckdb b/Task/Factorial/DuckDB/factorial-3.duckdb deleted file mode 100644 index d3a13b50ff..0000000000 --- a/Task/Factorial/DuckDB/factorial-3.duckdb +++ /dev/null @@ -1,2 +0,0 @@ -select n, n!, factorial(n), double_precision_factorial(n) -from values (4), (30), (33) t(n); diff --git a/Task/Factorial/EasyLang/factorial.easy b/Task/Factorial/EasyLang/factorial.easy index 697c8807fd..986d3ce909 100644 --- a/Task/Factorial/EasyLang/factorial.easy +++ b/Task/Factorial/EasyLang/factorial.easy @@ -1,6 +1,8 @@ -func factorial n . - r = 1 - for i = 2 to n : r *= i - return r +proc factorial n . r . + r = 1 + for i = 2 to n + r *= i + . . -print factorial 7 +call factorial 7 r +print r diff --git a/Task/Factorial/Elixir/factorial.ex b/Task/Factorial/Elixir/factorial.elixir similarity index 100% rename from Task/Factorial/Elixir/factorial.ex rename to Task/Factorial/Elixir/factorial.elixir diff --git a/Task/Factorial/Emacs-Lisp/factorial-1.el b/Task/Factorial/Emacs-Lisp/factorial-1.l similarity index 100% rename from Task/Factorial/Emacs-Lisp/factorial-1.el rename to Task/Factorial/Emacs-Lisp/factorial-1.l diff --git a/Task/Factorial/Emacs-Lisp/factorial-2.el b/Task/Factorial/Emacs-Lisp/factorial-2.l similarity index 100% rename from Task/Factorial/Emacs-Lisp/factorial-2.el rename to Task/Factorial/Emacs-Lisp/factorial-2.l diff --git a/Task/Factorial/Emacs-Lisp/factorial-3.el b/Task/Factorial/Emacs-Lisp/factorial-3.l similarity index 100% rename from Task/Factorial/Emacs-Lisp/factorial-3.el rename to Task/Factorial/Emacs-Lisp/factorial-3.l diff --git a/Task/Factorial/Euphoria/factorial-1.eu b/Task/Factorial/Euphoria/factorial-1.euphoria similarity index 100% rename from Task/Factorial/Euphoria/factorial-1.eu rename to Task/Factorial/Euphoria/factorial-1.euphoria diff --git a/Task/Factorial/Euphoria/factorial-2.eu b/Task/Factorial/Euphoria/factorial-2.euphoria similarity index 100% rename from Task/Factorial/Euphoria/factorial-2.eu rename to Task/Factorial/Euphoria/factorial-2.euphoria diff --git a/Task/Factorial/Euphoria/factorial-3.eu b/Task/Factorial/Euphoria/factorial-3.euphoria similarity index 100% rename from Task/Factorial/Euphoria/factorial-3.eu rename to Task/Factorial/Euphoria/factorial-3.euphoria diff --git a/Task/Factorial/Euphoria/factorial-4.eu b/Task/Factorial/Euphoria/factorial-4.euphoria similarity index 100% rename from Task/Factorial/Euphoria/factorial-4.eu rename to Task/Factorial/Euphoria/factorial-4.euphoria diff --git a/Task/Factorial/Fennel/factorial.fennel b/Task/Factorial/Fennel/factorial.fennel deleted file mode 100644 index c9024229d5..0000000000 --- a/Task/Factorial/Fennel/factorial.fennel +++ /dev/null @@ -1,18 +0,0 @@ -(do - (fn factorial [n] ;;; iterative factorial - (if (< n 2) - 1 - ;else - (do (var f 2) - (for [i 3 n] - (set f (* f i)) - ) - f - ) - ) - ) - - (for [n 0 10] - (io.write (string.format "%2d! = %s\n" n (factorial n))) - ) -) diff --git a/Task/Factorial/Gleam/factorial-1.gleam b/Task/Factorial/Gleam/factorial-1.gleam deleted file mode 100644 index 6521eeb481..0000000000 --- a/Task/Factorial/Gleam/factorial-1.gleam +++ /dev/null @@ -1 +0,0 @@ -list.fold(int.range(1, n + 1, [], list.prepend), 1, int.multiply) diff --git a/Task/Factorial/Gleam/factorial-2.gleam b/Task/Factorial/Gleam/factorial-2.gleam deleted file mode 100644 index dbab0f45f6..0000000000 --- a/Task/Factorial/Gleam/factorial-2.gleam +++ /dev/null @@ -1,6 +0,0 @@ -pub fn fac(n: Int) -> Int { - case n { - 1 -> 1 - n -> n * fac(n - 1) - } -} diff --git a/Task/Factorial/Gleam/factorial-3.gleam b/Task/Factorial/Gleam/factorial-3.gleam deleted file mode 100644 index dbc03d5750..0000000000 --- a/Task/Factorial/Gleam/factorial-3.gleam +++ /dev/null @@ -1,10 +0,0 @@ -pub fn fac(n: Int) -> Int { - fac_helper(n, n - 1) -} - -fn fac_helper(n: Int, acc: Int) -> Int { - case n, acc { - n, 1 -> n - n, i -> fac_helper(n * i, i - 1) - } -} diff --git a/Task/Factorial/Haskell/factorial-10.hs b/Task/Factorial/Haskell/factorial-10.hs deleted file mode 100644 index d7507d16b3..0000000000 --- a/Task/Factorial/Haskell/factorial-10.hs +++ /dev/null @@ -1,8 +0,0 @@ --- product of [a,a+1..b] -productFromTo a b = - if a>b then 1 - else if a == b then a - else productFromTo a c * productFromTo (c+1) b - where c = (a+b) `div` 2 - -factorial = productFromTo 1 diff --git a/Task/Factorial/Haskell/factorial-5.hs b/Task/Factorial/Haskell/factorial-5.hs index f036c73a77..6b76b69b6e 100644 --- a/Task/Factorial/Haskell/factorial-5.hs +++ b/Task/Factorial/Haskell/factorial-5.hs @@ -1 +1,3 @@ -factorials = 1 : zipWith (*) factorials [1..] +factorial :: Integral -> Integral +factorial 0 = 1 +factorial n = n * factorial (n-1) diff --git a/Task/Factorial/Haskell/factorial-6.hs b/Task/Factorial/Haskell/factorial-6.hs index 655c366a44..baef906bf8 100644 --- a/Task/Factorial/Haskell/factorial-6.hs +++ b/Task/Factorial/Haskell/factorial-6.hs @@ -1,2 +1,5 @@ -factorials = go 1 1 where - go n fac = f : go (n+1) (n*fac) +fac n + | n >= 0 = go 1 n + | otherwise = error "Negative factorial!" + where go acc 0 = acc + go acc n = go (acc * n) (n - 1) diff --git a/Task/Factorial/Haskell/factorial-7.hs b/Task/Factorial/Haskell/factorial-7.hs index 6b76b69b6e..77d34e9b2e 100644 --- a/Task/Factorial/Haskell/factorial-7.hs +++ b/Task/Factorial/Haskell/factorial-7.hs @@ -1,3 +1,10 @@ -factorial :: Integral -> Integral -factorial 0 = 1 -factorial n = n * factorial (n-1) +{-# LANGUAGE PostfixOperators #-} + +(!) :: Integer -> Integer +(!) 0 = 1 +(!) n = n * (pred n !) + +main :: IO () +main = do + print (5 !) + print ((4 !) !) diff --git a/Task/Factorial/Haskell/factorial-8.hs b/Task/Factorial/Haskell/factorial-8.hs index baef906bf8..d7507d16b3 100644 --- a/Task/Factorial/Haskell/factorial-8.hs +++ b/Task/Factorial/Haskell/factorial-8.hs @@ -1,5 +1,8 @@ -fac n - | n >= 0 = go 1 n - | otherwise = error "Negative factorial!" - where go acc 0 = acc - go acc n = go (acc * n) (n - 1) +-- product of [a,a+1..b] +productFromTo a b = + if a>b then 1 + else if a == b then a + else productFromTo a c * productFromTo (c+1) b + where c = (a+b) `div` 2 + +factorial = productFromTo 1 diff --git a/Task/Factorial/Haskell/factorial-9.hs b/Task/Factorial/Haskell/factorial-9.hs deleted file mode 100644 index 77d34e9b2e..0000000000 --- a/Task/Factorial/Haskell/factorial-9.hs +++ /dev/null @@ -1,10 +0,0 @@ -{-# LANGUAGE PostfixOperators #-} - -(!) :: Integer -> Integer -(!) 0 = 1 -(!) n = n * (pred n !) - -main :: IO () -main = do - print (5 !) - print ((4 !) !) diff --git a/Task/Factorial/Haxe/factorial-1.hx b/Task/Factorial/Haxe/factorial-1.haxe similarity index 100% rename from Task/Factorial/Haxe/factorial-1.hx rename to Task/Factorial/Haxe/factorial-1.haxe diff --git a/Task/Factorial/Haxe/factorial-2.hx b/Task/Factorial/Haxe/factorial-2.haxe similarity index 100% rename from Task/Factorial/Haxe/factorial-2.hx rename to Task/Factorial/Haxe/factorial-2.haxe diff --git a/Task/Factorial/Haxe/factorial-3.hx b/Task/Factorial/Haxe/factorial-3.haxe similarity index 100% rename from Task/Factorial/Haxe/factorial-3.hx rename to Task/Factorial/Haxe/factorial-3.haxe diff --git a/Task/Factorial/Haxe/factorial-4.hx b/Task/Factorial/Haxe/factorial-4.haxe similarity index 100% rename from Task/Factorial/Haxe/factorial-4.hx rename to Task/Factorial/Haxe/factorial-4.haxe diff --git a/Task/Factorial/Haxe/factorial-5.hx b/Task/Factorial/Haxe/factorial-5.haxe similarity index 100% rename from Task/Factorial/Haxe/factorial-5.hx rename to Task/Factorial/Haxe/factorial-5.haxe diff --git a/Task/Factorial/Insitux/factorial-1.insitux b/Task/Factorial/Insitux/factorial-1.insitux deleted file mode 100644 index a2757e7f71..0000000000 --- a/Task/Factorial/Insitux/factorial-1.insitux +++ /dev/null @@ -1,2 +0,0 @@ -(function factorial n - (... *1 (range 2 (inc n)))) diff --git a/Task/Factorial/Insitux/factorial-2.insitux b/Task/Factorial/Insitux/factorial-2.insitux deleted file mode 100644 index 74910d9619..0000000000 --- a/Task/Factorial/Insitux/factorial-2.insitux +++ /dev/null @@ -1,4 +0,0 @@ -(function factorial x - (if (< x 2) - 1 - (*1 x (factorial (dec x))))) diff --git a/Task/Factorial/Java/factorial-4.java b/Task/Factorial/Java/factorial-4.java deleted file mode 100644 index 7194a10356..0000000000 --- a/Task/Factorial/Java/factorial-4.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.math.BigInteger; -import java.util.function.Function; -import java.util.stream.LongStream; -import java.util.stream.Stream; - -public final class Factorial { - - public static void main(String[] args) { - // Valid only for integer arguments 1, 2, ... , 20 - Function factorialPositive = n -> LongStream.rangeClosed(2, n).reduce(1, (a, b) -> a * b); - - // Valid for integer arguments <= 20 - Function factorial = n -> { - if ( n < 0 || n > 20 ) { - throw new AssertionError("Argument is out of range: " + n); - } - - return factorialPositive.apply(n); - }; - - // Return a BigInteger value - Function factorialBig = n -> Stream.iterate(BigInteger.ONE, i -> i.add(BigInteger.ONE)) - .limit(n) - .reduce(BigInteger.ONE, BigInteger::multiply); - } - -} diff --git a/Task/Factorial/Julia/factorial-1.jl b/Task/Factorial/Julia/factorial-1.julia similarity index 100% rename from Task/Factorial/Julia/factorial-1.jl rename to Task/Factorial/Julia/factorial-1.julia diff --git a/Task/Factorial/Julia/factorial-2.jl b/Task/Factorial/Julia/factorial-2.julia similarity index 100% rename from Task/Factorial/Julia/factorial-2.jl rename to Task/Factorial/Julia/factorial-2.julia diff --git a/Task/Factorial/Kotlin/factorial.kts b/Task/Factorial/Kotlin/factorial.kotlin similarity index 100% rename from Task/Factorial/Kotlin/factorial.kts rename to Task/Factorial/Kotlin/factorial.kotlin diff --git a/Task/Factorial/LDPL/factorial.ldpl b/Task/Factorial/LDPL/factorial.ldpl deleted file mode 100644 index e5e0354fc6..0000000000 --- a/Task/Factorial/LDPL/factorial.ldpl +++ /dev/null @@ -1,22 +0,0 @@ -data: -n is number - -procedure: -sub factorial - parameters: - n is number - result is number - local data: - i is number - m is number - procedure: - store 1 in result - in m solve n + 1 - for i from 1 to m step 1 do - multiply result by i in result - repeat -end sub -create statement "get factorial of $ in $" executing factorial - -get factorial of 5 in n -display n lf diff --git a/Task/Factorial/Langur/factorial-1.langur b/Task/Factorial/Langur/factorial-1.langur index 3149d6b778..bc9dffcb32 100644 --- a/Task/Factorial/Langur/factorial-1.langur +++ b/Task/Factorial/Langur/factorial-1.langur @@ -1,2 +1,2 @@ -val factorial = fn(n number) { fold(2 .. n, by=fn{*}) } -writeln factorial(7) +val .factorial = f fold(f .x x .y, pseries .n) +writeln .factorial(7) diff --git a/Task/Factorial/Langur/factorial-2.langur b/Task/Factorial/Langur/factorial-2.langur index 93fe1fe8d3..9c2085a654 100644 --- a/Task/Factorial/Langur/factorial-2.langur +++ b/Task/Factorial/Langur/factorial-2.langur @@ -1,2 +1,2 @@ -val factorial = fn(x number) { if(x < 2: 1; x * fn((x - 1))) } -writeln factorial(7) +val .factorial = f fold(f{x}, 2 .. .n) +writeln .factorial(7) diff --git a/Task/Factorial/Langur/factorial-3.langur b/Task/Factorial/Langur/factorial-3.langur index 934e4f08bd..eb03b40830 100644 --- a/Task/Factorial/Langur/factorial-3.langur +++ b/Task/Factorial/Langur/factorial-3.langur @@ -1,9 +1,2 @@ -val factorial = fn(i number) { - var answer = 1 - for x in 2 .. i { - answer *= x - } - answer -} - -writeln factorial(7) +val .factorial = f if(.x < 2: 1; .x x self(.x - 1)) +writeln .factorial(7) diff --git a/Task/Factorial/Langur/factorial-4.langur b/Task/Factorial/Langur/factorial-4.langur index a13962013b..584fd8692a 100644 --- a/Task/Factorial/Langur/factorial-4.langur +++ b/Task/Factorial/Langur/factorial-4.langur @@ -1,2 +1,8 @@ -val factorial = fn(n number) { for[=1] x in n { _for *= x } } -writeln factorial(7) +val .factorial = f(.i) { + var .answer = 1 + for .x in 2 .. .i { + .answer x= .x + } + .answer +} +writeln .factorial(7) diff --git a/Task/Factorial/Langur/factorial-5.langur b/Task/Factorial/Langur/factorial-5.langur new file mode 100644 index 0000000000..18af40dfb3 --- /dev/null +++ b/Task/Factorial/Langur/factorial-5.langur @@ -0,0 +1,2 @@ +val .factorial = f(.n) for[=1] .x in .n { _for x= .x } +writeln .factorial(7) diff --git a/Task/Factorial/M2000-Interpreter/factorial-2.m2000 b/Task/Factorial/M2000-Interpreter/factorial-2.m2000 deleted file mode 100644 index 43a5d9ca37..0000000000 --- a/Task/Factorial/M2000-Interpreter/factorial-2.m2000 +++ /dev/null @@ -1,24 +0,0 @@ -Cls , 0 ' 0 for non split display, eg 3 means we preserve the 3 top lines from scrolling/cla -Report { - Factorial Task - Definitions - • The factorial of 0 (zero) is defined as being 1 (unity). - • The Factorial Function of a positive integer, n, is defined as the product of the sequence: - n, n-1, n-2, ... 1 - -} -Cls, row ' now we preserve some lines (as row number return here) -Module CheckIt { - m=1u ' 1u is biginteger - k=width-tab - For i=1 to 1000 - if pos>tab then print - m*=i - Print @(0), format$("{0::-4} :", i); - Report str$(m), k - ' Report accumulate lines and stop at 3/4 of the screen (but not on printer) - ' so we can break this using this line: - while inkey$<>"": wait 1:end while: keyboard " " - Next i -} -Checkit diff --git a/Task/Factorial/M2000-Interpreter/factorial-1.m2000 b/Task/Factorial/M2000-Interpreter/factorial.m2000 similarity index 100% rename from Task/Factorial/M2000-Interpreter/factorial-1.m2000 rename to Task/Factorial/M2000-Interpreter/factorial.m2000 diff --git a/Task/Factorial/Mn/factorial.mn b/Task/Factorial/Mn/factorial.mn deleted file mode 100644 index 834200986a..0000000000 --- a/Task/Factorial/Mn/factorial.mn +++ /dev/null @@ -1,12 +0,0 @@ -( - (n) let - 1 (product) let - (n 1 >=) - ( - product n * (product) bind - n 1 - (n) bind - ) while - product -) (factorial) lambda - -5 factorial puts pop diff --git a/Task/Factorial/Nu/factorial.nu b/Task/Factorial/Nu/factorial.nu deleted file mode 100644 index 6250a46215..0000000000 --- a/Task/Factorial/Nu/factorial.nu +++ /dev/null @@ -1,3 +0,0 @@ -def 'math factorial' [] {[$in 1] | math max | 1..$in | math product} - -..10 | each {math factorial} diff --git a/Task/Factorial/OCaml/factorial-1.ml b/Task/Factorial/OCaml/factorial-1.ocaml similarity index 100% rename from Task/Factorial/OCaml/factorial-1.ml rename to Task/Factorial/OCaml/factorial-1.ocaml diff --git a/Task/Factorial/OCaml/factorial-2.ml b/Task/Factorial/OCaml/factorial-2.ocaml similarity index 100% rename from Task/Factorial/OCaml/factorial-2.ml rename to Task/Factorial/OCaml/factorial-2.ocaml diff --git a/Task/Factorial/OCaml/factorial-3.ml b/Task/Factorial/OCaml/factorial-3.ocaml similarity index 100% rename from Task/Factorial/OCaml/factorial-3.ml rename to Task/Factorial/OCaml/factorial-3.ocaml diff --git a/Task/Factorial/OCaml/factorial-4.ml b/Task/Factorial/OCaml/factorial-4.ocaml similarity index 100% rename from Task/Factorial/OCaml/factorial-4.ml rename to Task/Factorial/OCaml/factorial-4.ocaml diff --git a/Task/Factorial/Oberon-07/factorial.oberon b/Task/Factorial/Oberon-07/factorial.oberon deleted file mode 100644 index 8c8e1d89ca..0000000000 --- a/Task/Factorial/Oberon-07/factorial.oberon +++ /dev/null @@ -1,40 +0,0 @@ -MODULE Factorial; -IMPORT - Out; - -VAR - i: INTEGER; - - PROCEDURE Iterative(n: INTEGER): INTEGER; - VAR - i, r: INTEGER; - BEGIN - ASSERT(n >= 0); - r := 1; - FOR i := n TO 2 BY -1 DO - r := r * i - END; - RETURN r - END Iterative; - - PROCEDURE Recursive(n: INTEGER): INTEGER; - VAR - r: INTEGER; - BEGIN - ASSERT(n >= 0); - r := 1; - IF n > 1 THEN - r := n * Recursive(n - 1) - END; - RETURN r - END Recursive; - -BEGIN - FOR i := 0 TO 9 DO - Out.String("Iterative ");Out.Int(i,0);Out.String("! =");Out.Int(Iterative(i),8);Out.Ln; - END; - Out.Ln; - FOR i := 0 TO 9 DO - Out.String("Recursive ");Out.Int(i,0);Out.String("! =");Out.Int(Recursive(i),8);Out.Ln; - END -END Factorial. diff --git a/Task/Factorial/Pascal/factorial-2.pas b/Task/Factorial/Pascal/factorial-2.pas index 6b44f23124..991914c559 100644 --- a/Task/Factorial/Pascal/factorial-2.pas +++ b/Task/Factorial/Pascal/factorial-2.pas @@ -1,45 +1,32 @@ {$mode objFPC}{R+} -FUNCTION Fact(n: qword): qword; +FUNCTION Factorial ( n : qword ) : qword; -VAR - F: qword; + (*) + Update for version 3.2.0 + Factorial works until 20! , which is good enough for me for now + replace qword with dword and rax,rcx with eax, ecx for 32-bit + for Factorial until 12! + (*) -BEGIN - if n > 20 then - begin - WriteLn('This function is only accurate up to 20!'); - exit(0); - end; + VAR + + F: qword; + + BEGIN - asm - (*) Initialize result = 1 (0! = 1 case handled automatically) (*) + asm + + mov $1, %rax + mov n, %rcx + + .Lloop1: + imul %rcx, %rax + loopnz .Lloop1 + + mov %rax, F - mov $1, %rax (*) RAX = 1 (initial result) (*) - mov n, %rcx (*) RCX = input number (counter) (*) + end; - test %rcx, %rcx (*) Check if n=0 (*) - jz .Lstore_result (*) Skip loop if n=0 (*) - - .Lloop1: - imul %rcx, %rax (*) RAX = RAX * RCX (signed mul) (*) - dec %rcx (*) Decrement RCX (*) - jnz .Lloop1 (*) Loop while RCX != 0 (*) - - .Lstore_result: - mov %rax, F (*) Store result in F (*) - end ['rax', 'rcx']; (*) Tell compiler register change (*) - - Result := F; - -END; - - -var - N : integer = 20 ; - -begin - - writeln; - writeln( BasicFact(N)); - -end. (*) Function Fact (*) + Result := F ; + + END; diff --git a/Task/Factorial/Pascal/factorial-3.pas b/Task/Factorial/Pascal/factorial-3.pas index 137d0f6b28..64c4eabff6 100644 --- a/Task/Factorial/Pascal/factorial-3.pas +++ b/Task/Factorial/Pascal/factorial-3.pas @@ -1,33 +1,92 @@ -program GMPfact; +PROGRAM EXBigFac ; -{$mode objfpc} +{$IFDEF FPC} + {$mode objfpc}{$H+}{$J-}{R+} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} -uses +(*) - gmp - ; + Free Pascal Compiler version 3.2.0 [2020/06/14] for x86_64 + The free and readable alternative at C/C++ speeds + compiles natively to almost any platform, including raspberry PI * + Can run independently from DELPHI / Lazarus - function Factorial(n: qword): string; - var - ResultMPZ: mpz_t; - i: qword; - begin - mpz_init_set_ui(ResultMPZ, 1); - for i := 2 to n do - mpz_mul_ui(ResultMPZ, ResultMPZ, i); - Result := mpz_get_str(nil, 10, ResultMPZ); - mpz_clear(ResultMPZ); - end; + For debian Linux: apt -y install fpc + It contains a text IDE called fp -var - N : integer = 101 ; - Fact : string ; + https://www.freepascal.org/advantage.var -begin - Fact := Factorial(101); - writeln( N ,'! = ', Fact); -end. (*) GMPfact (*) +(*) +USES + + gmp; + + FUNCTION WriteBigNum ( c: pchar ) : ansistring ; + + CONST + + CrLf = #13 + #10 ; + + VAR + i: longint; + len: longint; + preview: integer; + ret: ansistring = ''; + threshold: integer; + + BEGIN + + len := length ( c ) ; + WriteLn ( 'Digits: ', len ) ; + threshold := 12 ; + preview := len div threshold ; + + IF ( len < 91 ) THEN + BEGIN + FOR i := 0 TO len DO + ret:= ret + c [ i ] ; + END + ELSE + BEGIN + FOR i := 0 TO preview DO + ret:= ret + c [ i ] ; + ret:= ret + '...' ; + FOR i := len - preview -1 TO len DO + ret:= ret + c [ i ] ; + END; + ret:= ret + CrLf ; + WriteBigNum := ret; + END; + + FUNCTION BigFactorial ( n : qword ) : ansistring ; + + (*) + See https://gmplib.org/#DOC + (*) + + VAR + S: mpz_t; + c: pchar; + + BEGIN + + mpz_init_set_ui ( S, 1 ) ; + mpz_fac_ui ( S, n ) ; + c := mpz_get_str ( NIL, 10, S ) ; + BigFactorial := WriteBigNum ( c ) ; + + END; + +BEGIN + + WriteLn ( BigFactorial ( 99 ) ) ; + +END. + Output: -101! = 9425947759838359420851623124482936749562312794702543768327889353416977599316221476503087861591808346911623490003549599583369706302603264000000000000000000000000 +Digits: 156 +93326215443944...00000000000000 diff --git a/Task/Factorial/PascalABC.NET/factorial.pas b/Task/Factorial/PascalABC.NET/factorial.pas deleted file mode 100644 index 87563d6ab2..0000000000 --- a/Task/Factorial/PascalABC.NET/factorial.pas +++ /dev/null @@ -1,19 +0,0 @@ -function FactIter(n: integer): BigInteger; -begin - Result := 1; - for var i:=2 to n do - Result *= i; -end; - -function FactRec(n: integer): BigInteger; -begin - if n = 0 then - Result := 1 - else Result := n * FactRec(n - 1); -end; - - -begin - for var i:=1 to 20 do - Println(i,FactRec(i),FactIter(i)); -end. diff --git a/Task/Factorial/Pluto/factorial.pluto b/Task/Factorial/Pluto/factorial.pluto deleted file mode 100644 index 3ed73ecb0e..0000000000 --- a/Task/Factorial/Pluto/factorial.pluto +++ /dev/null @@ -1,30 +0,0 @@ -local bigint = require "pluto:bigint" - -class Factorial - static function iterative(n) - local fact = bigint.new(1) - if n < 2 then return fact end - for i = 2, n do fact *= bigint.new(i) end - return fact - end - - static function recursive(n) - if n < 2 then return bigint.new(1) end - return bigint.new(n) * Factorial.recursive(n - 1) - end -end - -local function commatize(n) - local s = n:tostring() - local zero = bigint.new(0) - if n < zero then s = s:sub(2) end - for i = #s - 3, 1, -3 do - s = s:sub(1, i) .. "," .. s:sub(i + 1) - end - if n >= zero then return s end - return "-" .. s -end - -local n = 24 -print($"Factorial({n}) iterative -> {commatize(Factorial.iterative(n))}") -print($"Factorial({n}) recursive -> {commatize(Factorial.recursive(n))}") diff --git a/Task/Factorial/PowerShell/factorial-1.ps1 b/Task/Factorial/PowerShell/factorial-1.psh similarity index 100% rename from Task/Factorial/PowerShell/factorial-1.ps1 rename to Task/Factorial/PowerShell/factorial-1.psh diff --git a/Task/Factorial/PowerShell/factorial-2.ps1 b/Task/Factorial/PowerShell/factorial-2.psh similarity index 100% rename from Task/Factorial/PowerShell/factorial-2.ps1 rename to Task/Factorial/PowerShell/factorial-2.psh diff --git a/Task/Factorial/PowerShell/factorial-3.ps1 b/Task/Factorial/PowerShell/factorial-3.psh similarity index 100% rename from Task/Factorial/PowerShell/factorial-3.ps1 rename to Task/Factorial/PowerShell/factorial-3.psh diff --git a/Task/Factorial/R/factorial-4.r b/Task/Factorial/R/factorial-4.r deleted file mode 100644 index 3c651ae864..0000000000 --- a/Task/Factorial/R/factorial-4.r +++ /dev/null @@ -1 +0,0 @@ - fact_fp <- function(n) ifelse(!n, 1, Reduce(`*`, seq_len(n))) diff --git a/Task/Factorial/REBOL/factorial.rebol b/Task/Factorial/REBOL/factorial.rebol new file mode 100644 index 0000000000..b3ff15a290 --- /dev/null +++ b/Task/Factorial/REBOL/factorial.rebol @@ -0,0 +1,55 @@ +REBOL [ + Title: "Factorial" + URL: http://rosettacode.org/wiki/Factorial_function +] + +; Standard recursive implementation. + +factorial: func [n][ + either n > 1 [n * factorial n - 1] [1] +] + +; Iteration. + +ifactorial: func [n][ + f: 1 + for i 2 n 1 [f: f * i] + f +] + +; Automatic memoization. +; I'm just going to say up front that this is a stunt. However, you've +; got to admit it's pretty nifty. Note that the 'memo' function +; works with an unlimited number of arguments (although the expected +; gains decrease as the argument count increases). + +memo: func [ + "Defines memoizing function -- keeps arguments/results for later use." + args [block!] "Function arguments. Just specify variable names." + body [block!] "The body block of the function." + /local m-args m-r +][ + do compose/deep [ + func [ + (args) + /dump "Dump memory." + ][ + m-args: [] + if dump [return m-args] + + if m-r: select/only m-args reduce [(args)] [return m-r] + + m-r: do [(body)] + append m-args reduce [reduce [(args)] m-r] + m-r + ] + ] +] + +mfactorial: memo [n][ + either n > 1 [n * mfactorial n - 1] [1] +] + +; Test them on numbers zero to ten. + +for i 0 10 1 [print [i ":" factorial i ifactorial i mfactorial i]] diff --git a/Task/Factorial/REXX/factorial-1.rexx b/Task/Factorial/REXX/factorial-1.rexx index 4ab115dc32..b02528c706 100644 --- a/Task/Factorial/REXX/factorial-1.rexx +++ b/Task/Factorial/REXX/factorial-1.rexx @@ -1,4 +1,18 @@ -call time('r') -numeric digits 999999999 -a = 10/3 -say length(a) time('e') +/*REXX pgm computes & shows the factorial of a non─negative integer, and also its length*/ +numeric digits 100000 /*100k digits: handles N up to 25k.*/ +parse arg n /*obtain optional argument from the CL.*/ +if n='' then call er 'no argument specified.' +if arg()>1 | words(n)>1 then call er 'too many arguments specified.' +if \datatype(n,'N') then call er "argument isn't numeric: " n +if \datatype(n,'W') then call er "argument isn't a whole number: " n +if n<0 then call er "argument can't be negative: " n +!= 1 /*define the factorial product (so far)*/ + do j=2 to n; !=!*j /*compute the factorial the hard way. */ + end /*j*/ /* [↑] where da rubber meets da road. */ + +say n'! is ['length(!) "digits]:" /*display number of digits in factorial*/ +say /*add some whitespace to the output. */ +say ! /*display the factorial product──►term.*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +er: say; say '***error***'; say; say arg(1); say; exit 13 diff --git a/Task/Factorial/REXX/factorial-2.rexx b/Task/Factorial/REXX/factorial-2.rexx index 82133ca665..0ce1aa0e4d 100644 --- a/Task/Factorial/REXX/factorial-2.rexx +++ b/Task/Factorial/REXX/factorial-2.rexx @@ -1,68 +1,22 @@ --- 10 Mar 2026 -include Setting - -say 'Factorial' -say version -say -call First20 -call Imperative 10, '1 13 71 450 3249 25206 205022 1723508 14842907 130202808' -if pos('Regina',version) > 0 then - call Recursive 10, '1 13 71 450 3249 25206 205022' -else - call Recursive 10, '1 13 71 450 3249' -call Imperative 100000,'1 13 71 450 3249 25206' -call Timer -exit - -First20: -say 'First 20 FactorialS...' -numeric digits 30 -do n = 1 to 20 - say n'! =' Fact(n) -end -say -return - -Imperative: -Memo.='' -call Time('R') -arg d,p -numeric digits d -say 'Imperative in' d 'digits precision...' -do i = 1 to Words(p) - call Time('r'); f = Word(p,i); h = Fact(f) - parse var h 'E' e - if e = '' then - say Right(f'!',10) 'has exact' Right(Length(h),9) 'digits' '('Format(Time('e'),,3)'s)' - else - say Right(f'!',10) 'has about' Right(e+1,9) 'digits' '('Format(Time('e'),,3)'s)' -end -say -return - -Recursive: -Memo.='' -call Time('R') -arg d,p -numeric digits d -say 'Recursive in' d 'digits precision...' -do i = 1 to Words(p) - call Time('r'); f = Word(p,i); h = Recurs(f) - parse var h 'E' e - if e = '' then - say Right(f'!',10) 'has exact' Right(Length(h),9) 'digits' '('Format(Time('e'),,3)'s)' - else - say Right(f'!',10) 'has about' Right(e+1,9) 'digits' '('Format(Time('e'),,3)'s)' -end -say -return - -Recurs: -procedure -arg xx -if xx = 0 then - return 1 -else - return xx*Recurs(xx-1) - -include Math +/*REXX program computes the factorial of a non─negative integer, and it automatically */ +/*────────────────────── adjusts the number of decimal digits to accommodate the answer.*/ +numeric digits 99 /*99 digits initially, then expanded. */ +parse arg n /*obtain optional argument from the CL.*/ +if n='' then call er 'no argument specified' +if arg()>1 | words(n)>1 then call er 'too many arguments specified.' +if \datatype(n,'N') then call er "argument isn't numeric: " n +if \datatype(n,'W') then call er "argument isn't a whole number: " n +if n<0 then call er "argument can't be negative: " n +!= 1 /*define the factorial product (so far)*/ + do j=2 to n; !=!*j /*compute the factorial the hard way. */ + if pos(.,!)==0 then iterate /*is the ! in exponential notation? */ + parse var ! 'E' digs /*extract exponent of the factorial, */ + numeric digits digs + digs % 10 /* ··· and increase it by ten percent.*/ + end /*j*/ /* [↑] where da rubber meets da road. */ +!= !/1 /*normalize the factorial product. */ +say n'! is ['length(!) "digits]:" /*display number of digits in factorial*/ +say /*add some whitespace to the output. */ +say ! /*display the factorial product ──►term*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +er: say; say '***error!***'; say; say arg(1); say; exit 13 diff --git a/Task/Factorial/REXX/factorial-3.rexx b/Task/Factorial/REXX/factorial-3.rexx new file mode 100644 index 0000000000..f9f6da4455 --- /dev/null +++ b/Task/Factorial/REXX/factorial-3.rexx @@ -0,0 +1,27 @@ +/*REXX program computes & shows the factorial of an integer, striping trailing zeroes. */ +numeric digits 200 /*start with two hundred digits. */ +parse arg N . /*obtain an optional argument from CL. */ +if N=='' | N=="," then N= 0 /*Not specified? Then use the default.*/ +!= 1 /*define the factorial product so far. */ + do j=2 to N /*compute factorial the hard way. */ + old!= ! /*save old product in case of overflow.*/ + != ! * j /*multiple the old factorial with J. */ + if pos(.,!) \==0 then do /*is the ! in exponential notation?*/ + d= digits() /*D temporarily stores number digits.*/ + numeric digits d+d%10 /*add 10% to the decimal digits. */ + != old! * j /*re─calculate for the "lost" digits.*/ + end /*IFF ≡ if and only if. [↓] */ + parse var ! '' -1 _ /*obtain the right-most digit of ! */ + if _==0 then != strip(!, , 0) /*strip trailing zeroes IFF the ... */ + end /*j*/ /* [↑] ... right-most digit is zero. */ +z= 0 /*the number of trailing zeroes in ! */ + do v=5 by 0 while v<=N /*calculate number of trailing zeroes. */ + z= z + N % v /*bump Z if multiple power of five.*/ + v= v * 5 /*calculate the next power of five. */ + end /*v*/ /* [↑] we only advance V by ourself.*/ + /*stick a fork in it, we're all done. */ +!= ! || copies(0, z) /*add water to rehydrate the product. */ +if z==0 then z= 'no' /*use gooder English for the message. */ +say N'! is ['length(!) " digits with " z ' trailing zeroes]:' +say /*display blank line (for whitespace).*/ +say ! /*display the factorial product. */ diff --git a/Task/Factorial/RISC-V-Assembly/factorial.asm b/Task/Factorial/RISC-V-Assembly/factorial.asm deleted file mode 100644 index f3139a188e..0000000000 --- a/Task/Factorial/RISC-V-Assembly/factorial.asm +++ /dev/null @@ -1,131 +0,0 @@ -# riscv assembly raspberry pico2 rp2350 -# program factorial.s -# connexion putty com3 -/*********************************************/ -/* CONSTANTES */ -/********************************************/ -/* for this file see risc-v task include a file */ -.include "../../constantesRiscv.inc" - -/****************************************************/ -/* MACROS */ -/****************************************************/ -#.include "../ficmacrosriscv.inc" # for debugging only - -/*******************************************/ -/* INITIALED DATAS */ -/*******************************************/ -.data -szMessStart: .asciz "Program riscv start.\r\n" -szMessEnd: .asciz "\nProgram end OK.\r\n" -szCariageReturn: .asciz "\r\n" - -szMessLargeNumber: .asciz "Number N to large. \n" -szMessNegNumber: .asciz "Number N is negative. \n" - -szMessResult: .ascii "Resultat = " # message result - -.align 2 - - -/*******************************************/ -/* UNINITIALED DATA */ -/*******************************************/ -.bss -.align 2 -sConvArea: .skip 24 - -/********************************...-..--*****/ -/* SECTION CODE */ -/**********************************************/ -.text -.global main - -main: - call stdio_init_all # général init -1: # start loop connexion - li a0,0 # raz argument register - call tud_cdc_n_connected # waiting for USB connection - beqz a0,1b # return code = zero ? - - la a0,szMessStart # message address - call writeString # display message - - li a0,-10 - call factorial # - li a0,0 - call factorial # - li a0,10 - call factorial # - - la a0,szMessEnd - call writeString - call getchar -100: # final loop - j 100b -/**********************************************/ -/* compute factorial */ -/**********************************************/ -/* a0 value */ -factorial: # INFO: factorial - addi sp, sp, -4 # reserve stack - sw ra, 0(sp) - bltz a0,99f # is negative ? - li t0,1 - ble a0,t0,1f # is 0 or 1 - call computeFactorial - li t0,-1 # error overflow ? - beq a0,t0,98f -1: # display result - la a1,sConvArea - call conversion10 - la a0,szMessResult - call writeString - la a0,sConvArea - call writeString - la a0,szCariageReturn - call writeString - j 100f -98: - la a0,szMessLargeNumber - call writeString - j 100f -99: - la a0,szMessNegNumber - call writeString - j 100f -100: - lw ra, 0(sp) - addi sp, sp, 4 - ret -/**********************************************/ -/* compute factorial */ -/**********************************************/ -/* a0 value */ -computeFactorial: # INFO:computeFactorial - addi sp,sp, -8 # reserve stack - sw ra,0(sp) - sw s0,4(sp) - li t0,1 - beq a0,t0,100f # if n = 1 return - mv s0,a0 - addi a0,a0,-1 - call computeFactorial - li t0,-1 # error overflow ? - beq a0,t0,100f - mulh t0,a0,s0 # compute half high 32 bits - beqz t0,1f # is ok if result is zero - li a0,-1 # error overflow - j 100f -1: - mul a0,a0,s0 # multiplication -100: - lw ra,0(sp) - lw s0,4(sp) - addi sp,sp, 8 - ret -/************************************/ -/* file include Fonctions */ -/***********************************/ -/* for this file see risc-v task include a file */ -.include "../../includeFunctions.s" diff --git a/Task/Factorial/Rebol/factorial.rebol b/Task/Factorial/Rebol/factorial.rebol deleted file mode 100644 index feb9d5d6c4..0000000000 --- a/Task/Factorial/Rebol/factorial.rebol +++ /dev/null @@ -1,56 +0,0 @@ -Rebol [ - Title: "Factorial" - URL: http://rosettacode.org/wiki/Factorial_function -] - -;; Standard recursive implementation. -factorial: func [n][ - either n > 1 [n * factorial n - 1] [1] -] - -;; Iteration. -ifactorial: func [n][ - f: 1 - for i 2 n 1 [f: f * i] - f -] - -either system/version < 3.0.0 [ - ; Automatic memoization. - ; I'm just going to say up front that this is a stunt. However, you've - ; got to admit it's pretty nifty. Note that the 'memo' function - ; works with an unlimited number of arguments (although the expected - ; gains decrease as the argument count increases). - memo: func [ - "Defines memoizing function -- keeps arguments/results for later use." - args [block!] "Function arguments. Just specify variable names." - body [block!] "The body block of the function." - /local m-args m-r - ][ - do compose/deep [ - func [ - (args) - /dump "Dump memory." - ][ - m-args: [] - if dump [return m-args] - - if m-r: select/only m-args reduce [(args)] [return m-r] - - m-r: do [(body)] - append m-args reduce [reduce [(args)] m-r] - m-r - ] - ] - ] - - mfactorial: memo [n][ - either n > 1 [n * mfactorial n - 1] [1] - ] -][ - ;; Above hack is not supported in Rebol3 - mfactorial: func[i][none] -] - -;; Test them on numbers zero to ten. -for i 0 10 1 [print [i ":" factorial i ifactorial i mfactorial i]] diff --git a/Task/Factorial/Refal/factorial.refal b/Task/Factorial/Refal/factorial.refal deleted file mode 100644 index ab25f846e3..0000000000 --- a/Task/Factorial/Refal/factorial.refal +++ /dev/null @@ -1,14 +0,0 @@ -$ENTRY Go { - = ; -} - -Facts { - s.N s.Max, : '+' = ; - s.N s.Max = '! = ' > - s.Max>; -}; - -Fact { - 0 = 1; - s.N = <* s.N >>; -}; diff --git a/Task/Factorial/Retro/factorial.retro b/Task/Factorial/Retro/factorial.retro index 11cf76e297..fb56673ef4 100644 --- a/Task/Factorial/Retro/factorial.retro +++ b/Task/Factorial/Retro/factorial.retro @@ -1,8 +1,2 @@ -: - dup #1 -eq? 0; drop - dup n:dec * ; - -:factorial - dup n:zero? - [ n:inc ] - [ ] choose ; +: dup 1 = if; dup 1- * ; +: factorial dup 0 = [ 1+ ] [ ] if ; diff --git a/Task/Factorial/Rhombus/factorial-1.rhombus b/Task/Factorial/Rhombus/factorial-1.rhombus deleted file mode 100644 index 5042a49103..0000000000 --- a/Task/Factorial/Rhombus/factorial-1.rhombus +++ /dev/null @@ -1,5 +0,0 @@ -#lang rhombus/static - -fun factorial: -| factorial(0): 1 -| factorial(n): n * factorial(n - 1) diff --git a/Task/Factorial/Rhombus/factorial-2.rhombus b/Task/Factorial/Rhombus/factorial-2.rhombus deleted file mode 100644 index 95c17bc122..0000000000 --- a/Task/Factorial/Rhombus/factorial-2.rhombus +++ /dev/null @@ -1,7 +0,0 @@ -#lang rhombus/static - -fun factorial(n): - for values(a=1) (n in 1..=n): - a * n - -factorial(6) // output: 720 diff --git a/Task/Factorial/Rust/factorial.rs b/Task/Factorial/Rust/factorial.rust similarity index 100% rename from Task/Factorial/Rust/factorial.rs rename to Task/Factorial/Rust/factorial.rust diff --git a/Task/Factorial/S-BASIC/factorial-1.basic b/Task/Factorial/S-BASIC/factorial-1.basic deleted file mode 100644 index 3899ac1bd1..0000000000 --- a/Task/Factorial/S-BASIC/factorial-1.basic +++ /dev/null @@ -1,13 +0,0 @@ -function factorial(n=real.double)=real.double - if n = 0 then n = 1 else n = n * factorial(n-1) -end = n - -var i=integer -print "Factorial Calculator" -print " n n!" -print "----------------------" -for i=1 to 15 - print using "## #,###,###,###,###";i;factorial(i) -next i - -end diff --git a/Task/Factorial/S-BASIC/factorial-2.basic b/Task/Factorial/S-BASIC/factorial-2.basic deleted file mode 100644 index 91fbb1fce5..0000000000 --- a/Task/Factorial/S-BASIC/factorial-2.basic +++ /dev/null @@ -1,7 +0,0 @@ -function factorial(n=real.double)=real.double - var i, f = real.double - f = 1 - for i = 1 to n - f = f * i - next i -end = f diff --git a/Task/Factorial/SQL/factorial.sql b/Task/Factorial/SQL/factorial.sql deleted file mode 100644 index c0b412e4a3..0000000000 --- a/Task/Factorial/SQL/factorial.sql +++ /dev/null @@ -1,6 +0,0 @@ -WITH RECURSIVE f(a, b) AS ( - VALUES(1, 1) - UNION ALL - SELECT a * b, b + 1 FROM f WHERE b <= 9 -) -SELECT MAX(a) FROM f diff --git a/Task/Factorial/Scheme/factorial-1.scm b/Task/Factorial/Scheme/factorial-1.ss similarity index 100% rename from Task/Factorial/Scheme/factorial-1.scm rename to Task/Factorial/Scheme/factorial-1.ss diff --git a/Task/Factorial/Scheme/factorial-2.scm b/Task/Factorial/Scheme/factorial-2.ss similarity index 100% rename from Task/Factorial/Scheme/factorial-2.scm rename to Task/Factorial/Scheme/factorial-2.ss diff --git a/Task/Factorial/Scheme/factorial-3.scm b/Task/Factorial/Scheme/factorial-3.ss similarity index 100% rename from Task/Factorial/Scheme/factorial-3.scm rename to Task/Factorial/Scheme/factorial-3.ss diff --git a/Task/Factorial/Scheme/factorial-4.scm b/Task/Factorial/Scheme/factorial-4.scm deleted file mode 100644 index 1d26a067d8..0000000000 --- a/Task/Factorial/Scheme/factorial-4.scm +++ /dev/null @@ -1,24 +0,0 @@ -;Using a generator and a function that apply generated values to a function taking two arguments - -;A generator knows commands 'next? and 'next -(define (range a b) -(let ((k a)) -(lambda (msg) -(cond - ((eq? msg 'next?) (<= k b)) - ((eq? msg 'next) - (cond - ((<= k b) (set! k (+ k 1)) (- k 1)) - (else 'nothing-left))))))) - -;Similar to List.fold_left in OCaml, but uses a generator -(define (fold fun a gen) -(let aux ((a a)) - (if (gen 'next?) (aux (fun a (gen 'next))) a))) - -;Now the factorial function -(define (factorial n) (fold * 1 (range 1 n))) - -(factorial 8) - -;40320 diff --git a/Task/Factorial/Scheme/factorial-4.ss b/Task/Factorial/Scheme/factorial-4.ss new file mode 100644 index 0000000000..3e179ef9e9 --- /dev/null +++ b/Task/Factorial/Scheme/factorial-4.ss @@ -0,0 +1,23 @@ +;Using a generator and a function that apply generated values to a function taking two arguments + +;A generator knows commands 'next? and 'next +(define (range a b) +(let ((k a)) +(lambda (msg) +(cond + ((eq? msg 'next?) (<= k b)) + ((eq? msg 'next) + (cond + ((<= k b) (set! k (+ k 1)) (- k 1)) + (else 'nothing-left))))))) + +;Similar to List.fold_left in OCaml, but uses a generator +(define (fold fun a gen) +(let aux ((a a)) + (if (gen 'next?) (aux (fun a (gen 'next))) a))) + +;Now the factorial function +(define (factorial n) (fold * 1 (range 1 n))) + +(factorial 8) +;40320 diff --git a/Task/Factorial/Scheme/factorial-5.scm b/Task/Factorial/Scheme/factorial-5.scm deleted file mode 100644 index 513325a124..0000000000 --- a/Task/Factorial/Scheme/factorial-5.scm +++ /dev/null @@ -1,9 +0,0 @@ -(define (range n) - (let ((lst '())) - (do ((i 1 (+ i 1))) - ((= i (+ n 1))) - (set! lst (cons i lst))) - (reverse lst))) - -(define (fact n) - (apply * (range n))) diff --git a/Task/Factorial/Soda/factorial-2.soda b/Task/Factorial/Soda/factorial-2.soda index 91cb1f27fb..65bca7ad00 100644 --- a/Task/Factorial/Soda/factorial-2.soda +++ b/Task/Factorial/Soda/factorial-2.soda @@ -1,3 +1,4 @@ +@tailrec _tailrec_fact (n : Int) (accum : Int) : Int = if n < 2 then accum diff --git a/Task/Factorial/TAV/factorial.tav b/Task/Factorial/TAV/factorial.tav deleted file mode 100644 index ce55505a2d..0000000000 --- a/Task/Factorial/TAV/factorial.tav +++ /dev/null @@ -1,14 +0,0 @@ -factorial (n) iterative: - p =: 1 - ?# i =: from 2 upto n \ does nothing if n < 2 - p =* i - :> p -factorial (n) recursive: - ? n <= 1 - :> 1 - :> n * factorial recursive n-1 - \ test code - main(parms):+ - arg =: string parms[1] as integer else 100 - print factorial arg iterative - print factorial arg recursive diff --git a/Task/Factorial/Tailspin/factorial-2.tailspin b/Task/Factorial/Tailspin/factorial-2.tailspin index 09af3015fd..023c4b4738 100644 --- a/Task/Factorial/Tailspin/factorial-2.tailspin +++ b/Task/Factorial/Tailspin/factorial-2.tailspin @@ -1,6 +1,4 @@ -factorial templates - when <|0..> do - @ set 1; - 1..$ -> @ set $@ * $; - $@ ! +templates factorial + when <=0> do 1 ! + when <0..> $ * ($ - 1 -> factorial) ! end factorial diff --git a/Task/Factorial/Tailspin/factorial-3.tailspin b/Task/Factorial/Tailspin/factorial-3.tailspin deleted file mode 100644 index 023c4b4738..0000000000 --- a/Task/Factorial/Tailspin/factorial-3.tailspin +++ /dev/null @@ -1,4 +0,0 @@ -templates factorial - when <=0> do 1 ! - when <0..> $ * ($ - 1 -> factorial) ! -end factorial diff --git a/Task/Factorial/Tailspin/factorial-4.tailspin b/Task/Factorial/Tailspin/factorial-4.tailspin deleted file mode 100644 index 968ff78c33..0000000000 --- a/Task/Factorial/Tailspin/factorial-4.tailspin +++ /dev/null @@ -1,4 +0,0 @@ -factorial templates - when <|=0> do 1 ! - when <|0..> do $ * ($ - 1 -> #) ! -end factorial diff --git a/Task/Factorial/Tcl/factorial-1.tcl b/Task/Factorial/Tcl/factorial-1.tcl index a204184466..8220088fdf 100644 --- a/Task/Factorial/Tcl/factorial-1.tcl +++ b/Task/Factorial/Tcl/factorial-1.tcl @@ -1,12 +1,6 @@ -# tailcall optimization is standard in tcl8.6 -proc fact { n { result 1. } } { - if { $n <= 1 } { - return $result - } else { - tailcall fact [expr {$n-1}] [expr {$n*$result}] +proc ifact n { + for {set i $n; set sum 1} {$i >= 2} {incr i -1} { + set sum [expr {$sum * $i}] } + return $sum } - -set f [fact 10] - -puts $f diff --git a/Task/Factorial/Tcl/factorial-2.tcl b/Task/Factorial/Tcl/factorial-2.tcl index 8220088fdf..40cc360692 100644 --- a/Task/Factorial/Tcl/factorial-2.tcl +++ b/Task/Factorial/Tcl/factorial-2.tcl @@ -1,6 +1,3 @@ -proc ifact n { - for {set i $n; set sum 1} {$i >= 2} {incr i -1} { - set sum [expr {$sum * $i}] - } - return $sum +proc rfact n { + expr {$n < 2 ? 1 : $n * [rfact [incr n -1]]} } diff --git a/Task/Factorial/Tcl/factorial-3.tcl b/Task/Factorial/Tcl/factorial-3.tcl index 40cc360692..e25b3f18c7 100644 --- a/Task/Factorial/Tcl/factorial-3.tcl +++ b/Task/Factorial/Tcl/factorial-3.tcl @@ -1,3 +1 @@ -proc rfact n { - expr {$n < 2 ? 1 : $n * [rfact [incr n -1]]} -} +proc tcl::mathfunc::fact n {expr {$n < 2? 1: $n*fact($n-1)}} diff --git a/Task/Factorial/Tcl/factorial-4.tcl b/Task/Factorial/Tcl/factorial-4.tcl index e25b3f18c7..9a9a02de85 100644 --- a/Task/Factorial/Tcl/factorial-4.tcl +++ b/Task/Factorial/Tcl/factorial-4.tcl @@ -1 +1,17 @@ -proc tcl::mathfunc::fact n {expr {$n < 2? 1: $n*fact($n-1)}} +proc ifact_caching n { + global fact_cache + if { ! [info exists fact_cache]} { + set fact_cache {1 1} + } + if {$n < [llength $fact_cache]} { + return [lindex $fact_cache $n] + } + set i [expr {[llength $fact_cache] - 1}] + set sum [lindex $fact_cache $i] + while {$i < $n} { + incr i + set sum [expr {$sum * $i}] + lappend fact_cache $sum + } + return $sum +} diff --git a/Task/Factorial/Tcl/factorial-5.tcl b/Task/Factorial/Tcl/factorial-5.tcl index c8cb0123e7..ecdfbe5752 100644 --- a/Task/Factorial/Tcl/factorial-5.tcl +++ b/Task/Factorial/Tcl/factorial-5.tcl @@ -1,18 +1,11 @@ -proc ifact_caching n { - global fact_cache - tailcall fact [expr {$n-1}] [expr {$n*$result}] - if { ! [info exists fact_cache]} { - set fact_cache {1 1} - } - if {$n < [llength $fact_cache]} { - return [lindex $fact_cache $n] - } - set i [expr {[llength $fact_cache] - 1}] - set sum [lindex $fact_cache $i] - while {$i < $n} { - incr i - set sum [expr {$sum * $i}] - lappend fact_cache $sum - } - return $sum -} +puts [ifact 30] +puts [rfact 30] +puts [ifact_caching 30] + +set n 400 +set iterations 10000 +puts "calculate $n factorial $iterations times" +puts "ifact: [time {ifact $n} $iterations]" +puts "rfact: [time {rfact $n} $iterations]" +# for the caching proc, reset the cache between each iteration so as not to skew the results +puts "ifact_caching: [time {ifact_caching $n; unset -nocomplain fact_cache} $iterations]" diff --git a/Task/Factorial/Tcl/factorial-6.tcl b/Task/Factorial/Tcl/factorial-6.tcl index 9a3cf79548..46e5e0fcab 100644 --- a/Task/Factorial/Tcl/factorial-6.tcl +++ b/Task/Factorial/Tcl/factorial-6.tcl @@ -1,52 +1,5 @@ -# calls cmd with args -# retpeatedly in scope above -proc trampoline {cmd args} { +package require math::special - # thunk is {cmd {arg1 arg2 arg3 ...} } - set result [uplevel 1 [concat $cmd $args]] - - # split into vars - lassign $result type thunk - - # loop - while {$type eq "next"} { - set result [uplevel 1 $thunk] - lassign $result type thunk - } - - set final_value $thunk - - return $final_value +proc gfact n { + expr {round([::math::special::Gamma [expr {$n+1}]])} } - -# return { value final_value } -# or { next {cmd arg1 arg2} } -proc factorial_step {n result} { - - if {$n <= 1} { - set ret_value [list "value" $result] - } else { - - # n-1 - set next_n [expr {$n-1}] - - # (n-1) * fact(n) - set next_result [expr {$n * $result}] - - # {func arg1 arg2} - set next_thunk [list factorial_step $next_n $next_result] - - # Return the next step as a list - set ret_value [list "next" $next_thunk] - } - - return $ret_value -} - - -# The execution is wrapped by the trampoline -proc factorial {n} { - return [trampoline factorial_step $n 1] -} - -set f [factorial 100] diff --git a/Task/Factorial/Tcl/factorial-7.tcl b/Task/Factorial/Tcl/factorial-7.tcl deleted file mode 100644 index ecdfbe5752..0000000000 --- a/Task/Factorial/Tcl/factorial-7.tcl +++ /dev/null @@ -1,11 +0,0 @@ -puts [ifact 30] -puts [rfact 30] -puts [ifact_caching 30] - -set n 400 -set iterations 10000 -puts "calculate $n factorial $iterations times" -puts "ifact: [time {ifact $n} $iterations]" -puts "rfact: [time {rfact $n} $iterations]" -# for the caching proc, reset the cache between each iteration so as not to skew the results -puts "ifact_caching: [time {ifact_caching $n; unset -nocomplain fact_cache} $iterations]" diff --git a/Task/Factorial/Tcl/factorial-8.tcl b/Task/Factorial/Tcl/factorial-8.tcl deleted file mode 100644 index 46e5e0fcab..0000000000 --- a/Task/Factorial/Tcl/factorial-8.tcl +++ /dev/null @@ -1,5 +0,0 @@ -package require math::special - -proc gfact n { - expr {round([::math::special::Gamma [expr {$n+1}]])} -} diff --git a/Task/Factorial/Tiny-Craft-Basic/factorial.basic b/Task/Factorial/Tiny-Craft-Basic/factorial.basic new file mode 100644 index 0000000000..868e8fdb67 --- /dev/null +++ b/Task/Factorial/Tiny-Craft-Basic/factorial.basic @@ -0,0 +1,14 @@ +10 let f = 1 + +20 print "factorial" +30 input "enter an integer (1-34): ", n + +40 rem loop + + 60 let f = f * n + 70 let n = n - 1 + +80 if n > 0 then 40 + +90 print f +100 shell "pause" diff --git a/Task/Factorial/UNIX-Shell/factorial.sh b/Task/Factorial/UNIX-Shell/factorial.sh new file mode 100644 index 0000000000..f64f3b8b46 --- /dev/null +++ b/Task/Factorial/UNIX-Shell/factorial.sh @@ -0,0 +1,10 @@ +factorial() +{ + if [ $1 -le 1 ] + then + echo 1 + else + result=$(factorial $[$1-1]) + echo $((result*$1)) + fi +} diff --git a/Task/Factorial/Uiua/factorial.uiua b/Task/Factorial/Uiua/factorial.uiua deleted file mode 100644 index 7b2a3e07ea..0000000000 --- a/Task/Factorial/Uiua/factorial.uiua +++ /dev/null @@ -1 +0,0 @@ -Factorial = /×+1⇡ diff --git a/Task/Factorial/Uxntal/factorial.uxnatl b/Task/Factorial/Uxntal/factorial.uxnatl deleted file mode 100644 index f936013ac4..0000000000 --- a/Task/Factorial/Uxntal/factorial.uxnatl +++ /dev/null @@ -1,28 +0,0 @@ -%newline { [ LIT2 0a -Console/write ] DEO } - -|18 @Console/write - -|100 - -#0900 -&loop - DUP #00 SWP factorial print/dec newline - INC GTHk ?&loop -POP2 - -BRK - -@factorial ( n* -- n!* ) - ORAk ?{ POP2 #0001 JMP2r } - DUP2 #0001 SUB2 factorial MUL2 - JMP2r - -@print/dec ( short* -- ) - #000a SWP2 [ LITr ff ] - &get ( -- ) - SWP2k DIV2k MUL2 SUB2 STH - POP OVR2 DIV2 ORAk ?&get - POP2 POP2 - &put ( -- ) - STHr INCk ?{ POP JMP2r } - [ LIT "0 ] ADD .Console/write DEO !&put diff --git a/Task/Factorial/VBScript/factorial.vbs b/Task/Factorial/VBScript/factorial.vb similarity index 100% rename from Task/Factorial/VBScript/factorial.vbs rename to Task/Factorial/VBScript/factorial.vb diff --git a/Task/Factorial/VHDL/factorial.vhd b/Task/Factorial/VHDL/factorial.vhdl similarity index 100% rename from Task/Factorial/VHDL/factorial.vhd rename to Task/Factorial/VHDL/factorial.vhdl diff --git a/Task/Factorial/Vyxal/factorial-1.vyxal b/Task/Factorial/Vyxal/factorial-1.vyxal deleted file mode 100644 index 25e660494e..0000000000 --- a/Task/Factorial/Vyxal/factorial-1.vyxal +++ /dev/null @@ -1 +0,0 @@ -¡ diff --git a/Task/Factorial/Vyxal/factorial-2.vyxal b/Task/Factorial/Vyxal/factorial-2.vyxal deleted file mode 100644 index 954fe1858c..0000000000 --- a/Task/Factorial/Vyxal/factorial-2.vyxal +++ /dev/null @@ -1 +0,0 @@ -ɾƒ* diff --git a/Task/Factorial/Vyxal/factorial-3.vyxal b/Task/Factorial/Vyxal/factorial-3.vyxal deleted file mode 100644 index 601abd91b0..0000000000 --- a/Task/Factorial/Vyxal/factorial-3.vyxal +++ /dev/null @@ -1 +0,0 @@ -λ0=[1|‹x*]; diff --git a/Task/Factorial/Wren/factorial.wren b/Task/Factorial/Wren/factorial.wren index e954eb7b03..a534b7f4e0 100644 --- a/Task/Factorial/Wren/factorial.wren +++ b/Task/Factorial/Wren/factorial.wren @@ -1,5 +1,5 @@ -import "./fmt" for Fmt -import "./big" for BigInt +import "/fmt" for Fmt +import "/big" for BigInt class Factorial { static iterative(n) { diff --git a/Task/Factorial/YAMLScript/factorial.ys b/Task/Factorial/YAMLScript/factorial.ys deleted file mode 100644 index 29d50ba6fa..0000000000 --- a/Task/Factorial/YAMLScript/factorial.ys +++ /dev/null @@ -1,10 +0,0 @@ -!YS-v0 - -defn main(*ns): - each n ns: - say: "$n! -> $factorial(n)" - -defn factorial(x): - if x <= 2: - (x ||| 1) - (2 .. x).mul(*) diff --git a/Task/Factorial/Zig/factorial.zig b/Task/Factorial/Zig/factorial.zig index 8b39b0719a..c0a83517ca 100644 --- a/Task/Factorial/Zig/factorial.zig +++ b/Task/Factorial/Zig/factorial.zig @@ -1,27 +1,25 @@ +const stdout = @import("std").io.getStdOut().outStream(); + pub fn factorial(comptime Num: type, n: i8) ?Num { return if (@typeInfo(Num) != .Int) - @compileError("factorial called with non-integral type: " ++ @typeName(Num)) + @compileError("factorial called with num-integral type: " ++ @typeName(Num)) else if (n < 0) null else calc: { var i: i8 = 1; var fac: Num = 1; while (i <= n) : (i += 1) { - const tmp = @mulWithOverflow(fac, i); - if (tmp[1] != 0) - break :calc null; // overflow - fac = tmp[0]; + if (@mulWithOverflow(Num, fac, i, &fac)) + break :calc null; } else break :calc fac; }; } pub fn main() !void { - const stdout = @import("std").io.getStdOut().writer(); - - try stdout.print("-1! = {?}\n", .{factorial(i32, -1)}); - try stdout.print("0! = {?}\n", .{factorial(i32, 0)}); - try stdout.print("5! = {?}\n", .{factorial(i32, 5)}); - try stdout.print("33!(64 bit) = {?}\n", .{factorial(i64, 33)}); // not valid i64 factorial - try stdout.print("33! = {?}\n", .{factorial(i128, 33)}); // biggest i128 factorial possible - try stdout.print("34! = {?}\n", .{factorial(i128, 34)}); // will overflow + try stdout.print("-1! = {}\n", .{factorial(i32, -1)}); + try stdout.print("0! = {}\n", .{factorial(i32, 0)}); + try stdout.print("5! = {}\n", .{factorial(i32, 5)}); + try stdout.print("33!(64 bit) = {}\n", .{factorial(i64, 33)}); // not vailid i64 factorial + try stdout.print("33! = {}\n", .{factorial(i128, 33)}); // biggest facorial possible + try stdout.print("34! = {}\n", .{factorial(i128, 34)}); // will overflow } diff --git a/Task/Factorions/ALGOL-68/factorions.alg b/Task/Factorions/ALGOL-68/factorions.alg index bf43b1ebde..70b2f250e7 100644 --- a/Task/Factorions/ALGOL-68/factorions.alg +++ b/Task/Factorions/ALGOL-68/factorions.alg @@ -1,9 +1,9 @@ BEGIN # cache factorials from 0 to 11 # - [ 0 : 11 ]INT bfact; - bfact[0] := 1; + [ 0 : 11 ]INT fact; + fact[0] := 1; FOR n TO 11 DO - bfact[n] := bfact[n-1] * n + fact[n] := fact[n-1] * n OD; FOR b FROM 9 TO 12 DO print( ( "The factorions for base ", whole( b, 0 ), " are:", newline ) ); @@ -11,7 +11,7 @@ BEGIN INT sum := 0; INT j := i; WHILE j > 0 DO - sum +:= bfact[ j MOD b ]; + sum +:= fact[ j MOD b ]; j OVERAB b OD; IF sum = i THEN print( ( whole( i, 0 ), " " ) ) FI diff --git a/Task/Factorions/Ada/factorions.adb b/Task/Factorions/Ada/factorions.adb deleted file mode 100644 index a8d21fb554..0000000000 --- a/Task/Factorions/Ada/factorions.adb +++ /dev/null @@ -1,64 +0,0 @@ -with Ada.Text_IO; - -procedure Factorions is - subtype Factorial_Domain is Natural range 0 .. 11; - subtype Log_Base is Positive range 2 .. Positive'Last; - type Result_Table is array (Factorial_Domain) of Positive; - - Factorial : Result_Table; - Search_Limit : Positive := 1_500_000; - - procedure Precompute_Factorials is - begin - Factorial (0) := 1; - - for I in 1 .. Factorial'Last loop - Factorial (I) := I * Factorial (I - 1); - end loop; - end Precompute_Factorials; - - function Floor_Log (Number : Positive; Base : Log_Base) return Natural is - Remaining : Natural := Number; - Floor_Log : Natural := 0; - begin - while Remaining > Base loop - Remaining := Remaining / Base; - Floor_Log := Floor_Log + 1; - end loop; - - return Floor_Log; - end Floor_Log; - - function Digit (Number, Index : Natural; Base : Log_Base) return Natural is - begin - return (Number / (Base ** Index)) mod Base; - end Digit; - - function Is_Factorion (Number : Positive; Base : Log_Base) return Boolean is - Digit_Sum : Natural := 0; - begin - for I in 0 .. Floor_Log (Number, Base) loop - Digit_Sum := Digit_Sum + Factorial (Digit (Number, I, Base)); - end loop; - - return Digit_Sum = Number; - end Is_Factorion; - - procedure Show_Factorions (Base : Log_Base) is - begin - Ada.Text_IO.Put_Line ("Search Base " & Base'Image); - for I in 1 .. Search_Limit loop - if Is_Factorion (I, Base) then - Ada.Text_IO.Put_Line (I'Image); - end if; - end loop; - Ada.Text_IO.Put_Line ("Done Base " & Base'Image); - end Show_Factorions; - -begin - Precompute_Factorials; - Show_Factorions (9); - Show_Factorions (10); - Show_Factorions (11); - Show_Factorions (12); -end Factorions; diff --git a/Task/Factorions/Arturo/factorions.arturo b/Task/Factorions/Arturo/factorions.arturo index e31b208049..700ea04d67 100644 --- a/Task/Factorions/Arturo/factorions.arturo +++ b/Task/Factorions/Arturo/factorions.arturo @@ -1,9 +1,10 @@ factorials: [1 1 2 6 24 120 720 5040 40320 362880 3628800 39916800] factorion?: function [n, base][ - if throws? [ + try? [ n = sum map digits.base:base n 'x -> factorials\[x] - ][ + ] + else [ print ["n:" n "base:" base] false ] @@ -11,3 +12,4 @@ factorion?: function [n, base][ loop 9..12 'base -> print ["Base" base "factorions:" select 1..45000 'z -> factorion? z base] +] diff --git a/Task/Factorions/Delphi/factorions.pas b/Task/Factorions/Delphi/factorions.delphi similarity index 100% rename from Task/Factorions/Delphi/factorions.pas rename to Task/Factorions/Delphi/factorions.delphi diff --git a/Task/Factorions/EasyLang/factorions.easy b/Task/Factorions/EasyLang/factorions.easy deleted file mode 100644 index 014c445c4c..0000000000 --- a/Task/Factorions/EasyLang/factorions.easy +++ /dev/null @@ -1,20 +0,0 @@ -len fact[] 12 -# -fact[0] = 1 -for n = 1 to 11 - fact[n] = fact[n - 1] * n -. -for b = 9 to 12 - write "base " & b & " factorions:" - for i = 1 to 1500000 - 1 - sum = 0 - j = i - while j > 0 - d = j mod b - sum += fact[d] - j = j div b - . - if sum = i : write " " & i - . - print "" -. diff --git a/Task/Factorions/Fortran/factorions.f b/Task/Factorions/Fortran/factorions.f deleted file mode 100644 index a142cc2e4a..0000000000 --- a/Task/Factorions/Fortran/factorions.f +++ /dev/null @@ -1,52 +0,0 @@ -! Factorions -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.10 -! GNU gfortran (Ubuntu 15.2.0-4ubuntu4) 15.2.0 on Kubuntu 25.10 -! VSI Fortran x86-64 V8.7-001 on OpenVMS V9.2-3 -program Factorions -integer, parameter :: minBase=9, maxBase = 12 ! minumum and maximum base used in this little program -integer, parameter :: factLim=1499999 ! Maximum factorial Number for all bases that are used here -integer, dimension(0:maxBase-1) :: fact ! Stored factorials for numbers 0...12 - -integer :: ii, jj, base - -! Prepare cached factorial function -fact = 1 -do ii=1, maxBase-1 - do jj= 2, ii - fact(ii) = fact(ii) * jj - enddo -end do - -! -! Brute force: for all bases, for all numbers 1...max tes each number and print if its a factorion. -! -do base=minBase, maxBase - write (*, '("The factorions in base ", i0, " are:")') base - do ii=1, factLim - if (isFactorion (ii, base)) write (*, '(1x,i0)', advance='no') ii - enddo - write (*,'(/)') -end do - -contains - -! -! Separate digits d of number n in base b, sum up d!, and compare result with n. -! -function isFactorion (n,b) result (YN) -integer, intent (in) :: n, b -logical :: YN -integer :: dig, nn, facts_sum - -nn = N -facts_sum = 0 -do while (nn .ne. 0) - dig = mod (nn, b) - nn = nn / b - - facts_sum = facts_sum + fact(dig) -enddo -yn = facts_sum .eq. n - -end function isFactorion -end program Factorions diff --git a/Task/Factorions/JavaScript/factorions.js b/Task/Factorions/JavaScript/factorions.js deleted file mode 100644 index a9a3f2c3ae..0000000000 --- a/Task/Factorions/JavaScript/factorions.js +++ /dev/null @@ -1,25 +0,0 @@ -function factorial(n) { - if (n <= 1) { - return 1; - } - let a = [...Array(n + 1).keys()]; - a.shift(); - return a.reduce((x, y) => x * y); -} - -function fact_digsum(n, b) { - if (n > b - 1) { - return factorial(n % b) + fact_digsum(Math.floor(n / b), b); - } - return factorial(n); -} - -for (let i = 9; i <= 12; i++) { - console.log(`Factorions in base ${i}:`); - for (let j = 1; j < 1499999; j++) { - if (j == fact_digsum(j, i)) { - console.log(j); - } - } - console.log(); -} diff --git a/Task/Factorions/Jq/factorions.jq b/Task/Factorions/Jq/factorions.jq index 012ec312ee..84891c0781 100644 --- a/Task/Factorions/Jq/factorions.jq +++ b/Task/Factorions/Jq/factorions.jq @@ -29,7 +29,7 @@ def sufficient: .digits += 1 | .value *= $base ) ; -# Show the factorions for all bases from 2 through 12: +# Show the factorions for all based from 2 through 12: (range(2;10) | . as $base | sufficient.value as $max diff --git a/Task/Factorions/Julia/factorions.jl b/Task/Factorions/Julia/factorions.julia similarity index 100% rename from Task/Factorions/Julia/factorions.jl rename to Task/Factorions/Julia/factorions.julia diff --git a/Task/Factorions/OCaml/factorions.ml b/Task/Factorions/OCaml/factorions.ocaml similarity index 100% rename from Task/Factorions/OCaml/factorions.ml rename to Task/Factorions/OCaml/factorions.ocaml diff --git a/Task/Factorions/PascalABC.NET/factorions.pas b/Task/Factorions/PascalABC.NET/factorions.pas deleted file mode 100644 index ac69d82c56..0000000000 --- a/Task/Factorions/PascalABC.NET/factorions.pas +++ /dev/null @@ -1,22 +0,0 @@ -## -var fact := |1| * 12; -for var i := 1 to 11 do fact[i] := i * fact[i - 1]; - -for var b := 9 to 12 do -begin - write('The factorions for base ', b:2, ' are: '); - for var i := 1 to 1_500_000 do - begin - var fact_sum := 0; - var j := i; - while j > 0 do - begin - var d := j mod b; - fact_sum += fact[d]; - j := j div b; - end; - if fact_sum = i then - print(i) - end; - println; -end; diff --git a/Task/Factorions/Pluto/factorions.pluto b/Task/Factorions/Pluto/factorions.pluto deleted file mode 100644 index f95a296746..0000000000 --- a/Task/Factorions/Pluto/factorions.pluto +++ /dev/null @@ -1,18 +0,0 @@ --- Cache factorials from 0 to 11. -local fact = {[0] = 1} -for n = 1, 11 do fact[n] = fact[n - 1] * n end - -for b = 9, 12 do - print($"The factorions for base {b} are:") - for i = 1, 1_499_999 do - local sum = 0 - local j = i - while j > 0 do - local d = j % b - sum += fact[d] - j //= b - end - if sum == i then io.write($"{i} ") end - end - print("\n") -end diff --git a/Task/Factorions/R/factorions.r b/Task/Factorions/R/factorions.r deleted file mode 100644 index 9f1c569b7e..0000000000 --- a/Task/Factorions/R/factorions.r +++ /dev/null @@ -1,12 +0,0 @@ -fact_digsum <- function(n, b) { - if(n > b-1) { - factorial(n%%b)+fact_digsum(n%/%b, b) - } else factorial(n) -} - -for(i in 9:12) { - cat("\nFactorions in base ", i, ":\n", sep="") - for(j in 1:1499999) { - if(j == fact_digsum(j, i)) cat(j, "") - } -} diff --git a/Task/Factorions/VBScript/factorions.vbs b/Task/Factorions/VBScript/factorions.vb similarity index 100% rename from Task/Factorions/VBScript/factorions.vbs rename to Task/Factorions/VBScript/factorions.vb diff --git a/Task/Factorions/Vyxal/factorions.vyxal b/Task/Factorions/Vyxal/factorions.vyxal deleted file mode 100644 index bf2fb337c6..0000000000 --- a/Task/Factorions/Vyxal/factorions.vyxal +++ /dev/null @@ -1,7 +0,0 @@ -λ2|→B:←Bτƛ¡}∑$_-¬}£ # check whether factorion -⟨9|10|11|12⟩(`Base `₴n:₴\:,→b - 1500000 ( - n 1000 ≠[ - ←b n¥†[n,]] - ) -) diff --git a/Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.adb b/Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.ada similarity index 100% rename from Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.adb rename to Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.ada diff --git a/Task/Factors-of-a-Mersenne-number/Arturo/factors-of-a-mersenne-number.arturo b/Task/Factors-of-a-Mersenne-number/Arturo/factors-of-a-mersenne-number.arturo index ec0ce3744d..6542a31a61 100644 --- a/Task/Factors-of-a-Mersenne-number/Arturo/factors-of-a-mersenne-number.arturo +++ b/Task/Factors-of-a-Mersenne-number/Arturo/factors-of-a-mersenne-number.arturo @@ -5,16 +5,16 @@ mersenneFactors: function [q][ -> shl 'r 1 d: new 1 + 2 * q while [true][ - i: 1 + i: new 1 p: new r while [p <> 0][ - i: (i * i) % d + i: new (i * i) % d if p < 0 -> 'i * 2 if i > d -> 'i - d shl 'p 1 ] - switch i <> 1 -> 'd + 2 * q - -> break + if? i <> 1 -> 'd + 2 * q + else -> break ] print ["2 ^" q "- 1 = 0 ( mod" d ")"] ] diff --git a/Task/Factors-of-a-Mersenne-number/Crystal/factors-of-a-mersenne-number.cr b/Task/Factors-of-a-Mersenne-number/Crystal/factors-of-a-mersenne-number.crystal similarity index 100% rename from Task/Factors-of-a-Mersenne-number/Crystal/factors-of-a-mersenne-number.cr rename to Task/Factors-of-a-Mersenne-number/Crystal/factors-of-a-mersenne-number.crystal diff --git a/Task/Factors-of-a-Mersenne-number/EasyLang/factors-of-a-mersenne-number.easy b/Task/Factors-of-a-Mersenne-number/EasyLang/factors-of-a-mersenne-number.easy deleted file mode 100644 index 60690b52c1..0000000000 --- a/Task/Factors-of-a-Mersenne-number/EasyLang/factors-of-a-mersenne-number.easy +++ /dev/null @@ -1,32 +0,0 @@ -fastfunc isprim num . - i = 2 - while i <= sqrt num - if num mod i = 0 : return 0 - i += 1 - . - return 1 -. -func modpow p n . - square = 1 - p2 = pow 2 floor log n 2 - while p2 >= 1 - square *= square - if p >= p2 - p -= p2 - square *= 2 - . - p2 /= 2 - square = square mod n - . - return square -. -func mersenne_factor p . - repeat - k += 1 - q = 2 * k * p + 1 - m = q mod 8 - until (m = 1 or m = 7) and modpow p q = 1 and isprim q = 1 - . - return q -. -print mersenne_factor 929 diff --git a/Task/Factors-of-a-Mersenne-number/Elixir/factors-of-a-mersenne-number.ex b/Task/Factors-of-a-Mersenne-number/Elixir/factors-of-a-mersenne-number.elixir similarity index 100% rename from Task/Factors-of-a-Mersenne-number/Elixir/factors-of-a-mersenne-number.ex rename to Task/Factors-of-a-Mersenne-number/Elixir/factors-of-a-mersenne-number.elixir diff --git a/Task/Factors-of-a-Mersenne-number/FutureBasic/factors-of-a-mersenne-number.basic b/Task/Factors-of-a-Mersenne-number/FutureBasic/factors-of-a-mersenne-number.basic deleted file mode 100644 index 2552a45c70..0000000000 --- a/Task/Factors-of-a-Mersenne-number/FutureBasic/factors-of-a-mersenne-number.basic +++ /dev/null @@ -1,108 +0,0 @@ -// -// Factors of Mersenne number -// -// Using FutureBasic 7.0.36 -// October 2025, R.W. - -include "gmp.incl" - -_scanMax = 2000000 // max k scan set at 2 million - -// ------------------------------------------------------------ -// Exponent primality using GMP (mpz_probab_prime_p) -// Returns _true if p is (probably) prime; _false otherwise. - -local fn IsPrimeP_mpz( p as UInt32 ) as BOOL - mpz_t z - int res - if p < 2 then return _false - mpz_init( z ) - mpz_set_ui( z, p ) - // Miller–Rabin reps = 18 is sufficient - // res 0 = composite, 1 = probable, 2 = definite - res = fn mpz_probab_prime_p( z, 18 ) - mpz_clear( z ) - if res == 0 then return _false - // res 1 or 2 → treat as prime for gating -end fn = _True - -// ------------------------------------------------------------ -// Find first prime factor q of M_p = 2^p - 1 -// Scans q = 2 * k * p + 1 for k = 1..maxK. Returns 0 if none found. -// Precondition: caller ensures p is (probably) prime and p ≥ 2. -// -local fn FindMersenneFactor( p as UInt32, maxK as UInt64 ) as UInt64 - mpz_t qz, rz - UInt64 k, qCandidate - int isPrime - // Eliminate the obvious - if p < 2 then return 0 - if p == 2 then return 0 // M2 = 3 is prime - - mpz_init( qz ) - mpz_init( rz ) - k = 1 - while k <= maxK - // q = 2 * k * p + 1 (candidates with q ≡ 1 (mod 2p)) - qCandidate = (UInt64)2 * (UInt64)p * k + 1ULL - // primality screen for q - mpz_set_ui( qz, qCandidate ) - // Miller–Rabin reps = 18 is sufficient - isPrime = fn mpz_probab_prime_p( qz, 18 ) - if isPrime > 0 - // Test 2^p ≡ 1 (mod q) - mpz_set_ui( rz, 2 ) - mpz_powm_ui( rz, rz, p, qz ) - if fn mpz_cmp_ui( rz, 1 ) == 0 - mpz_clear( rz ) - mpz_clear( qz ) - return qCandidate - end if - end if - k = k + 1 - wend - mpz_clear( rz ) - mpz_clear( qz ) -end fn = 0 - -// ------------------------------------------------------------ -// M_p gating/message -// -local fn ReportMersenne( p as UInt32, maxK as UInt64 ) - UInt64 q - // Gate on exponent primality first - if fn IsPrimeP_mpz( p ) == _false - print @"M"; p; @" = 2^"; p; @" - 1 exponent is not prime" - exit fn - end if - // p is (probably) prime: try to find a factor of M_p - q = fn FindMersenneFactor( p, maxK ) - if q == 0 - // No factor found in scan range → either prime or factor > search bound - print @"M"; p; @" = 2^"; p; @" - 1 is prime (no factor found in range)" - else - print @"M"; p; @" = 2^"; p; @" - 1 is composite with factor "; q - end if -end fn - - -// Main - -window 1 - -UInt32 p -p = 929 // Rosetta Task requirement - -// start the clock -CFTimeInterval t -t = fn CACurrentMediaTime - -// note, if you need a range, just do a loop -// like: -// for p = 900 to 930 -fn ReportMersenne( p, _scanMax ) // 2 million k scans -// next p - -printf @"\nElapsed time: %.3f ms", (fn CACurrentMediaTime-t)*1000 - -HandleEvents diff --git a/Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq b/Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq deleted file mode 100644 index 2846586599..0000000000 --- a/Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq +++ /dev/null @@ -1,61 +0,0 @@ -# Generic filters: - -# Integer division (for gojq and jaq) -# If $j is 0, then an error condition is raised; -# otherwise, assuming infinite-precision integer arithmetic, -# if the input and $j are integers, then the result will be an integer. -def idivide($j): - (. % $j) as $mod - | (. - $mod) / $j | round; - -# Convert the input integer to a stream of 0s and 1s, least significant bit first -def bitwise: - recurse( if . >= 2 then idivide(2) else empty end) | . % 2; - -def is_prime: - . as $n - | if ($n < 2) then false - elif ($n % 2 == 0) then $n == 2 - elif ($n % 3 == 0) then $n == 3 - elif ($n % 5 == 0) then $n == 5 - elif ($n % 7 == 0) then $n == 7 - elif ($n % 11 == 0) then $n == 11 - elif ($n % 13 == 0) then $n == 13 - elif ($n % 17 == 0) then $n == 17 - elif ($n % 19 == 0) then $n == 19 - else sqrt as $s - | 23 - | until( . > $s or ($n % . == 0); . + 2) - | . > $s - end; - -### Factors of Mersene numbers - -def trialFactor($base; $exp; $mod): - [$exp | bitwise] as $bits - | ($bits|length) as $length - | reduce range( 0; $length) as $i (1; - (. * . * (if $bits[$length-$i-1] == 1 then $base else 1 end)) % $mod ) - | . == 1 ; - -def mersenneFactor($p): - ((pow(2;$p) - 1) | sqrt | floor) as $limit - | {k: 1} - | until ((2*.k*$p - 1) >= $limit or .emit; - (2*.k*$p + 1 ) as $q - | if ($q%8 == 1 or $q%8 == 7) and trialFactor(2; $p; $q) and ($q | is_prime) - then .emit = $q # q is a factor of 2^p - 1 - else .k += 1 - end) - | if .emit then .emit else null end; - -### Examples: - -def m: [3, 5, 11, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 929]; - -m[] -| mersenneFactor(.) as $f -| "2^\(.) - 1 is " + - if $f then "composite (factor \($f))" - else "prime" - end diff --git a/Task/Factors-of-a-Mersenne-number/Julia/factors-of-a-mersenne-number.jl b/Task/Factors-of-a-Mersenne-number/Julia/factors-of-a-mersenne-number.julia similarity index 100% rename from Task/Factors-of-a-Mersenne-number/Julia/factors-of-a-mersenne-number.jl rename to Task/Factors-of-a-Mersenne-number/Julia/factors-of-a-mersenne-number.julia diff --git a/Task/Factors-of-a-Mersenne-number/Kotlin/factors-of-a-mersenne-number.kts b/Task/Factors-of-a-Mersenne-number/Kotlin/factors-of-a-mersenne-number.kotlin similarity index 100% rename from Task/Factors-of-a-Mersenne-number/Kotlin/factors-of-a-mersenne-number.kts rename to Task/Factors-of-a-Mersenne-number/Kotlin/factors-of-a-mersenne-number.kotlin diff --git a/Task/Factors-of-a-Mersenne-number/M2000-Interpreter/factors-of-a-mersenne-number.m2000 b/Task/Factors-of-a-Mersenne-number/M2000-Interpreter/factors-of-a-mersenne-number.m2000 deleted file mode 100644 index 9387607154..0000000000 --- a/Task/Factors-of-a-Mersenne-number/M2000-Interpreter/factors-of-a-mersenne-number.m2000 +++ /dev/null @@ -1,39 +0,0 @@ -// 67 need a lot of time 45 minutes (2758716msec) where 71 need 3.1 second (3131msec) -Module Factors_of_a_Mersenne_number{ - Dim q() - // 67 need a lot of time 51 minutes (3082671msec) where 71 need 3.5 second (3505msec) - q()= (11, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 929) - profiler - long long j=0x8000_0000 - long long r, p, i - long d, dd - For k = 0 To len(q())-1 - If @isPrime(q(k)) Then - r=q(k):dd =2*r:d=dd+1 - while rd Then i-=d - Until p=0:If i=1 Then Exit Else d+=dd:i=1:p=r - Always - Print "2^"; q(k); @(6); " - 1 = 0 (mod "; d; ")" - Else - Print q(k); " is not prime" - End If - Print ceil(timecount):profiler - Next - - Function isPrime(n As long) - If n Mod 2 = 0 Then = n=2 : Exit Function - If n Mod 3 = 0 Then = n=3 : Exit Function - Local d As long = 5 - While d * d <= n - If n Mod d = 0 Then =False: exit function - d += 2 - If n Mod d = 0 Then = False: exit function - d += 4 - End While - =True - End Function -} -Factors_of_a_Mersenne_number diff --git a/Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number.parigp b/Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number-1.parigp similarity index 100% rename from Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number.parigp rename to Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number-1.parigp diff --git a/Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number-2.parigp b/Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number-2.parigp new file mode 100644 index 0000000000..a43166ed17 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/PARI-GP/factors-of-a-mersenne-number-2.parigp @@ -0,0 +1,20 @@ +TM(p) = local(status=1, i=1, len=0, S=0);{ +printp("Test TM \t..."); +S=2*p+1; +len = length(binary(p)); +B = Vecsmall(binary(p)); +q = B[i]*B[i]; +while( i<=len & status ==1, + if( B[i] != 0, + q = q*2; + ); + r = q%S; + q = r*r; + if( i == len & r == 1, + status = 0; + printp("Not Prime!"); + ); + i++; +); +return(status); +} diff --git a/Task/Factors-of-a-Mersenne-number/PascalABC.NET/factors-of-a-mersenne-number.pas b/Task/Factors-of-a-Mersenne-number/PascalABC.NET/factors-of-a-mersenne-number.pas deleted file mode 100644 index 32d45238dc..0000000000 --- a/Task/Factors-of-a-Mersenne-number/PascalABC.NET/factors-of-a-mersenne-number.pas +++ /dev/null @@ -1,36 +0,0 @@ -const - q = 929; - -function isPrime(a: integer): boolean; -begin - if a = 2 then - begin result := true; exit end; - if (a < 2) or (a mod 2 = 0) then - begin result := false; exit end; - for var i := 3 to sqrt(a).Floor step 2 do - if a mod i = 0 then - begin result := false; exit end; - result := true; -end; - -begin - if not isPrime(q) then exit; - var r := q; - while r > 0 do r := r shl 1; - var d := 2 * q + 1; - while true do - begin - var i := 1; - var p := r; - while p <> 0 do - begin - i := (i * i) mod d; - if p < 0 then i *= 2; - if i > d then i -= d; - p := p shl 1; - end; - if i <> 1 then d += 2 * q - else break - end; - write('2^', q, ' - 1 = 0 (mod ', d, ')'); -end. diff --git a/Task/Factors-of-a-Mersenne-number/Phix/factors-of-a-mersenne-number.phix b/Task/Factors-of-a-Mersenne-number/Phix/factors-of-a-mersenne-number.phix index 8185372101..641c6a8d2f 100644 --- a/Task/Factors-of-a-Mersenne-number/Phix/factors-of-a-mersenne-number.phix +++ b/Task/Factors-of-a-Mersenne-number/Phix/factors-of-a-mersenne-number.phix @@ -1,40 +1,39 @@ -with javascript_semantics -function modpow(atom x, n, m) - atom {i,y,z} = {n,1,x} - while i do - if odd(i) then - y = mod(y*z,m) - end if - z = mod(z*z,m) - i = floor(i/2) - end while - return y -end function +(phixonline)--> + with javascript_semantics + function modpow(atom x, atom n, atom m) + atom i = n, + y = 1, + z = x + while i do + if and_bits(i,1) then + y = mod(y*z,m) + end if + z = mod(z*z,m) + i = floor(i/2) + end while + return y + end function -function mersenne_factor(integer p) - if not is_prime(p) then return -1 end if - atom limit = sqrt(power(2,p))-1 - integer k = 1 - while 1 do - atom q = 2*p*k + 1 - if q>=limit then exit end if - if find(mod(q,8),{1,7}) - and is_prime(q,true) - and modpow(2,p,q)=1 then - return q - end if - k += 1 - end while - return 0 -end function + function mersenne_factor(integer p) + if not is_prime(p) then return -1 end if + atom limit = sqrt(power(2,p))-1 + integer k = 1 + while 1 do + atom q = 2*p*k + 1 + if q>=limit then exit end if + if find(mod(q,8),{1,7}) + and is_prime(q) + and modpow(2,p,q)=1 then + return q + end if + k += 1 + end while + return 0 + end function -constant tests = {2,3,4,5,7,11,13,17,19,23,29,31,37,41,43,47, - 53,59,67,71,73,79,83,929,937,941,953,967} -for t in tests do - integer r = mersenne_factor(t) - switch r - case 0: printf(1,"M%d is prime\n",{t}) - case -1: printf(1,"M%d is not prime\n",{t}) - else printf(1,"A factor of M%d is %d\n",{t,r}) - end switch -end for + sequence tests = {11, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 929, 937} + for i=1 to length(tests) do + integer ti = tests[i] + printf(1,"A factor of M%d is %d\n",{ti,mersenne_factor(ti)}) + end for + n n ) + [ [] swap - dup sqrt+ 0 = dip + dup isqrt 0 = dip [ times [ dup i^ 1+ /mod iff drop done rot join i^ 1+ join swap ] - drop - dup size 2 / split ] + drop + dup size 2 / split ] if [ -1 split drop ] swap join ] is factors ( n --> [ ) diff --git a/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx b/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx index 4e743184e1..7f2c60a2ca 100644 --- a/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx +++ b/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx @@ -1,32 +1,29 @@ -/* REXX *************************************************************** -* Program to calculate and show divisors of positive integer(s). -* 03.08.2012 Walter Pachl simplified the above somewhat -* in particular I see no benefit from divAdd procedure -* 04.08.2012 the reference to 'above' is no longer valid since that -* was meanwhile changed for the better. -* 04.08.2012 took over some improvements from new above -**********************************************************************/ -Parse arg low high . -Select - When low='' Then Parse Value '1 200' with low high - When high='' Then high=low - Otherwise Nop - End -do j=low to high - say ' n = ' right(j,6) " divisors = " divs(j) - end -exit - -divs: procedure; parse arg x - if x==1 then return 1 /*handle special case of 1 */ - Parse Value '1' x With lo hi /*initialize lists: lo=1 hi=x */ - odd=x//2 /* 1 if x is odd */ - Do j=2+odd By 1+odd While j*j=HI; sq.k= k*k /*memoization for squares.*/ + end /*k*/ + do n=LO to HI by inc; $= divs(n); #= words($) /*get list of divs; # divs*/ + if $==! then do; #= !; $= ' (infinite)'; end /*handle case for infinity*/ + p= @.#; if n<0 then if n\==-1 then p= @.. /* " " " negative*/ + if p==@.2 then pn= pn + 1 /*Prime? Then bump counter*/ + say center(n, w) center('['#"]", 9) "──► " p ' ' $ + end /*n*/ /* [↑] process a range of integers. */ +say +say right(pn, 20) ' primes were found.' /*display the number of primes found. */ +exit 0 /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +divs: procedure expose sq.; parse arg x 1 b; a=1 /*set X and B to the 1st argument. */ + if x<2 then do; x= abs(x); if x==1 then return 1; if x==0 then return '∞'; b=x + end + odd= x // 2 /* [↓] process EVEN or ODD ints. ___*/ + do j=2+odd by 1+odd while sq.j display factor - call displayresult -2: - addi s1,s1,1 # add 1 to loop counter - ble s1,s0,1b # <= number ? - -100: - lw ra, 0(sp) - lw s0, 4(sp) - addi sp, sp, 8 - ret - -/************************************/ -/* file include Fonctions */ -/***********************************/ -/* for this file see risc-v task include a file */ -.include "../../includeFunctions.s" diff --git a/Task/Factors-of-an-integer/Raku/factors-of-an-integer-2.raku b/Task/Factors-of-an-integer/Raku/factors-of-an-integer-2.raku deleted file mode 100644 index ae8b49d375..0000000000 --- a/Task/Factors-of-an-integer/Raku/factors-of-an-integer-2.raku +++ /dev/null @@ -1,5 +0,0 @@ -use Prime::Factor; - -put divisors :s, 2⁹⁹ + 1; - -say (now - INIT now).round(.001) ~' seconds'; diff --git a/Task/Factors-of-an-integer/Raku/factors-of-an-integer-1.raku b/Task/Factors-of-an-integer/Raku/factors-of-an-integer.raku similarity index 100% rename from Task/Factors-of-an-integer/Raku/factors-of-an-integer-1.raku rename to Task/Factors-of-an-integer/Raku/factors-of-an-integer.raku diff --git a/Task/Factors-of-an-integer/Rebol/factors-of-an-integer.rebol b/Task/Factors-of-an-integer/Rebol/factors-of-an-integer.rebol deleted file mode 100644 index 4d685b443d..0000000000 --- a/Task/Factors-of-an-integer/Rebol/factors-of-an-integer.rebol +++ /dev/null @@ -1,13 +0,0 @@ -factors: function [n [integer!]] [ - n: absolute n ;; work with a non-negative value for factorization - collect [ ;; build and return a block of factors - repeat i (sq: square-root n) - 1 [ ;; test divisors from 1 up to floor(sqrt(n)) - 1 - if n % i = 0 [ ;; if i divides n - keep i ;; keep the small factor i - keep n / i ;; and its complementary factor n/i - ] - ] - ;; If n is a perfect square, include the square root once (to avoid duplication) - if sq = sq: to integer! sq [keep sq] - ] -] diff --git a/Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal b/Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal deleted file mode 100644 index 86b75f81c5..0000000000 --- a/Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal +++ /dev/null @@ -1,13 +0,0 @@ -$ENTRY Go { - = >; -} - -Factors { - s.N = ; - (s.N s.D), >: '-' = ; - (s.N s.D), : { - (s.D) 0 = s.D; - (s.F) 0 = s.D )> s.F; - (s.X) s.Y = )>; - }; -}; diff --git a/Task/Factors-of-an-integer/Run-BASIC/factors-of-an-integer.basic b/Task/Factors-of-an-integer/Run-BASIC/factors-of-an-integer.basic index 201672eec7..9bf612184d 100644 --- a/Task/Factors-of-an-integer/Run-BASIC/factors-of-an-integer.basic +++ b/Task/Factors-of-an-integer/Run-BASIC/factors-of-an-integer.basic @@ -2,7 +2,7 @@ PRINT "Factors of 45 are ";factorlist$(45) PRINT "Factors of 12345 are "; factorlist$(12345) END -FUNCTION factorlist$(f) +function factorlist$(f) DIM L(100) FOR i = 1 TO SQR(f) IF (f MOD i) = 0 THEN @@ -15,18 +15,18 @@ FOR i = 1 TO SQR(f) END IF NEXT i s = 1 -WHILE s = 1 +while s = 1 s = 0 -FOR i = 0 TO c-1 - IF L(i) > L(i+1) AND L(i+1) <> 0 THEN +for i = 0 to c-1 + if L(i) > L(i+1) and L(i+1) <> 0 then t = L(i) L(i) = L(i+1) L(i+1) = t s = 1 - END IF -NEXT i -WEND + end if +next i +wend FOR i = 0 TO c-1 factorlist$ = factorlist$ + STR$(L(i)) + ", " NEXT -END FUNCTION +end function diff --git a/Task/Factors-of-an-integer/Rust/factors-of-an-integer-1.rs b/Task/Factors-of-an-integer/Rust/factors-of-an-integer-1.rust similarity index 100% rename from Task/Factors-of-an-integer/Rust/factors-of-an-integer-1.rs rename to Task/Factors-of-an-integer/Rust/factors-of-an-integer-1.rust diff --git a/Task/Factors-of-an-integer/Rust/factors-of-an-integer-2.rs b/Task/Factors-of-an-integer/Rust/factors-of-an-integer-2.rust similarity index 100% rename from Task/Factors-of-an-integer/Rust/factors-of-an-integer-2.rs rename to Task/Factors-of-an-integer/Rust/factors-of-an-integer-2.rust diff --git a/Task/Factors-of-an-integer/Scheme/factors-of-an-integer.scm b/Task/Factors-of-an-integer/Scheme/factors-of-an-integer.ss similarity index 100% rename from Task/Factors-of-an-integer/Scheme/factors-of-an-integer.scm rename to Task/Factors-of-an-integer/Scheme/factors-of-an-integer.ss diff --git a/Task/Factors-of-an-integer/Tailspin/factors-of-an-integer-2.tailspin b/Task/Factors-of-an-integer/Tailspin/factors-of-an-integer-2.tailspin deleted file mode 100644 index 2d4e649c6b..0000000000 --- a/Task/Factors-of-an-integer/Tailspin/factors-of-an-integer-2.tailspin +++ /dev/null @@ -1 +0,0 @@ -[1..351 -> if <|?(351 mod $ matches <|=0>)>] ! diff --git a/Task/Factors-of-an-integer/Tailspin/factors-of-an-integer-1.tailspin b/Task/Factors-of-an-integer/Tailspin/factors-of-an-integer.tailspin similarity index 100% rename from Task/Factors-of-an-integer/Tailspin/factors-of-an-integer-1.tailspin rename to Task/Factors-of-an-integer/Tailspin/factors-of-an-integer.tailspin diff --git a/Task/Factors-of-an-integer/True-BASIC/factors-of-an-integer.basic b/Task/Factors-of-an-integer/True-BASIC/factors-of-an-integer.basic index ed38bdaa61..a2f01a908b 100644 --- a/Task/Factors-of-an-integer/True-BASIC/factors-of-an-integer.basic +++ b/Task/Factors-of-an-integer/True-BASIC/factors-of-an-integer.basic @@ -1,16 +1,17 @@ -SUB printfactors(n) - IF n < 1 THEN EXIT SUB - PRINT n; "=>"; - FOR i = 1 TO n / 2 - IF REMAINDER(n, i) = 0 THEN PRINT i; - NEXT i - PRINT n -END SUB +sub printfactors(n) + if n < 1 then exit sub + print n; "=>"; + for i = 1 to n / 2 + if remainder(n, i) = 0 then print i; + next i + print n +end sub -CALL printfactors(11) -CALL printfactors(21) -CALL printfactors(32) -CALL printfactors(45) -CALL printfactors(67) -CALL printfactors(96) -END +call printfactors(11) +call printfactors(21) +call printfactors(32) +call printfactors(45) +call printfactors(67) +call printfactors(96) +print +end diff --git a/Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua b/Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua deleted file mode 100644 index 51d3ec2090..0000000000 --- a/Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua +++ /dev/null @@ -1,2 +0,0 @@ -Factors ← ◴⊂⟜(⇌÷)⊸(▽⤚≡(=0◿)⊙¤⊸(↘1⇡+1⌊√)) -⍚Factors {45 53 64} diff --git a/Task/Factors-of-an-integer/Wren/factors-of-an-integer.wren b/Task/Factors-of-an-integer/Wren/factors-of-an-integer.wren index cd182c9955..3cd92e5fb0 100644 --- a/Task/Factors-of-an-integer/Wren/factors-of-an-integer.wren +++ b/Task/Factors-of-an-integer/Wren/factors-of-an-integer.wren @@ -1,6 +1,6 @@ -import "./fmt" for Fmt -import "./math" for Int +import "/fmt" for Fmt +import "/math" for Int var a = [11, 21, 32, 45, 67, 96, 159, 723, 1024, 5673, 12345, 32767, 123459, 999997] System.print("The factors of the following numbers are:") -for (e in a) Fmt.print("$6d => $n", e, Int.divisors(e)) +for (e in a) System.print("%(Fmt.d(6, e)) => %(Int.divisors(e))") diff --git a/Task/Factors-of-an-integer/XBasic/factors-of-an-integer.basic b/Task/Factors-of-an-integer/XBasic/factors-of-an-integer.basic deleted file mode 100644 index c5f0f44b28..0000000000 --- a/Task/Factors-of-an-integer/XBasic/factors-of-an-integer.basic +++ /dev/null @@ -1,23 +0,0 @@ -PROGRAM "Factors of an integer" -VERSION "0.0000" - -DECLARE FUNCTION Entry () -DECLARE FUNCTION printFactors (n) - -FUNCTION Entry () - printFactors(11) - printFactors(21) - printFactors(32) - printFactors(45) - printFactors(67) - printFactors(96) -END FUNCTION - -FUNCTION printFactors (n) - PRINT n; " =>"; - FOR i = 1 TO n / 2 - IF n MOD i = 0 THEN PRINT i; " "; - NEXT i - PRINT n -END FUNCTION -END PROGRAM diff --git a/Task/Factors-of-an-integer/Yabasic/factors-of-an-integer.basic b/Task/Factors-of-an-integer/Yabasic/factors-of-an-integer.basic index 9205265807..6ac4c75cca 100644 --- a/Task/Factors-of-an-integer/Yabasic/factors-of-an-integer.basic +++ b/Task/Factors-of-an-integer/Yabasic/factors-of-an-integer.basic @@ -1,8 +1,8 @@ sub printFactors(n) - if n < 1 return 0 - print n, " =>"; + if n < 1 then return 0 : fi + print n, " =>", for i = 1 to n / 2 - if mod(n, i) = 0 print i, " "; + if mod(n, i) = 0 then print i, " "; : fi next i print n end sub diff --git a/Task/Factors-of-an-integer/Zig/factors-of-an-integer.zig b/Task/Factors-of-an-integer/Zig/factors-of-an-integer.zig deleted file mode 100644 index 7bd18ddab8..0000000000 --- a/Task/Factors-of-an-integer/Zig/factors-of-an-integer.zig +++ /dev/null @@ -1,43 +0,0 @@ -const std = @import("std"); - -fn generateFactors(n: i32, allocator: std.mem.Allocator) !std.ArrayList(i32) { - var factors = std.ArrayList(i32).init(allocator); - - try factors.append(1); - try factors.append(n); - - var i: i32 = 2; - while (i * i <= n) : (i += 1) { - if ( @mod(n, i) == 0) { - try factors.append(i); - if (i * i != n) { - try factors.append( @divFloor(n,i) ); - } - } - } - - std.sort.heap(i32, factors.items, {}, comptime std.sort.asc(i32)); - return factors; -} - -pub fn main() !void { - const sample_numbers = [_]i32{ 3135, 45, 60, 81 }; - - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - const allocator = gpa.allocator(); - defer _ = gpa.deinit(); - - const stdout = std.io.getStdOut().writer(); - - for (sample_numbers) |num| { - var factors = try generateFactors(num, allocator); - defer factors.deinit(); - - try stdout.print("Factors of {d:4} are: ", .{num}); - - for (factors.items) |factor| { - try stdout.print("{d} ", .{factor}); - } - try stdout.print("\n", .{}); - } -} diff --git a/Task/Fairshare-between-two-and-more/Arturo/fairshare-between-two-and-more.arturo b/Task/Fairshare-between-two-and-more/Arturo/fairshare-between-two-and-more.arturo index d71b5476a8..e0efa5d3c3 100644 --- a/Task/Fairshare-between-two-and-more/Arturo/fairshare-between-two-and-more.arturo +++ b/Task/Fairshare-between-two-and-more/Arturo/fairshare-between-two-and-more.arturo @@ -1,6 +1,6 @@ thueMorse: function [base, howmany][ i: 0 - result: [] + result: new [] while [howmany > size result][ 'result ++ (sum digits.base:base i) % base i: i + 1 diff --git a/Task/Fairshare-between-two-and-more/Bc/fairshare-between-two-and-more.bc b/Task/Fairshare-between-two-and-more/Bc/fairshare-between-two-and-more.bc deleted file mode 100644 index e0ae2efdb7..0000000000 --- a/Task/Fairshare-between-two-and-more/Bc/fairshare-between-two-and-more.bc +++ /dev/null @@ -1,21 +0,0 @@ -define fairshare(n, base) { - auto result - while (n>0) { - result += n % base - n /= base - } - return result % base -} - -define help(base) { - print base, ": " - for(i=0;i<25;i++) - print fairshare(i, base), " " - print "\n" -} - -{ q=help(2) - q=help(3) - q=help(5) - q=help(11) -} diff --git a/Task/Fairshare-between-two-and-more/C-sharp/fairshare-between-two-and-more.cs b/Task/Fairshare-between-two-and-more/C-sharp/fairshare-between-two-and-more.cs deleted file mode 100644 index faaea48c58..0000000000 --- a/Task/Fairshare-between-two-and-more/C-sharp/fairshare-between-two-and-more.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; - -class FairshareBetweenTwoAndMore -{ - static void Main(string[] args) - { - foreach (int baseValue in new List { 2, 3, 5, 11 }) - { - Console.WriteLine($"Base {baseValue} = {string.Join(", ", ThueMorseSequence(25, baseValue))}"); - } - } - - private static List ThueMorseSequence(int terms, int baseValue) - { - List sequence = new List(); - for (int i = 0; i < terms; i++) - { - int sum = 0; - int n = i; - while (n > 0) - { - // Compute the digit sum - sum += n % baseValue; - n /= baseValue; - } - // Compute the digit sum modulo baseValue. - sequence.Add(sum % baseValue); - } - return sequence; - } -} diff --git a/Task/Fairshare-between-two-and-more/Comal/fairshare-between-two-and-more.comal b/Task/Fairshare-between-two-and-more/Comal/fairshare-between-two-and-more.comal deleted file mode 100644 index 42ab541d88..0000000000 --- a/Task/Fairshare-between-two-and-more/Comal/fairshare-between-two-and-more.comal +++ /dev/null @@ -1,16 +0,0 @@ -0010 FUNC fair'share#(n#,base#) CLOSED -0020 sum#:=0 -0030 WHILE n#>0 DO sum#:+n# MOD base#;n#:=n# DIV base# -0040 RETURN sum# MOD base# -0050 ENDFUNC fair'share# -0060 // -0070 REPEAT -0080 READ base# -0090 ZONE 4 -0100 PRINT STR$(base#)+":", -0110 ZONE 3 -0120 FOR n#:=0 TO 24 DO PRINT fair'share#(n#,base#), -0130 PRINT -0140 UNTIL EOD -0150 END -0160 DATA 2,3,5,11 diff --git a/Task/Fairshare-between-two-and-more/Delphi/fairshare-between-two-and-more.pas b/Task/Fairshare-between-two-and-more/Delphi/fairshare-between-two-and-more.delphi similarity index 100% rename from Task/Fairshare-between-two-and-more/Delphi/fairshare-between-two-and-more.pas rename to Task/Fairshare-between-two-and-more/Delphi/fairshare-between-two-and-more.delphi diff --git a/Task/Fairshare-between-two-and-more/DuckDB/fairshare-between-two-and-more.duckdb b/Task/Fairshare-between-two-and-more/DuckDB/fairshare-between-two-and-more.duckdb deleted file mode 100644 index b7f902f67a..0000000000 --- a/Task/Fairshare-between-two-and-more/DuckDB/fairshare-between-two-and-more.duckdb +++ /dev/null @@ -1,42 +0,0 @@ -# Generate the "reverse array" representations of the decimal integer n in base b, -# where b > 1, i.e. the least significant digit is first. -# b and all components of the array are decimal integers. -create or replace function integer_to_base(n, base) as ( - WITH RECURSIVE cte AS ( - select (n % base) as digit, - (n // base) as k, - 0 as i - union all - select k % base as digit, - (k // base) as k, - i+1 as i - from cte - where k > 0 - ) - select array_agg(digit) from cte -); - -# Using the "reverse array" represententation of the integers up to mx in base b -# as above, generate a table with each row representing an integer. -# E.g. for binary: [0], [1], [0,1], [1,1] ... -# mx should be given as a decimal integer. -# Due to a bug in DuckDB the CTE name must be distinctive. -create or replace function integers_in_base(base, mx) as table ( - WITH RECURSIVE cte1 AS ( - select 0 as i, [0] as lst - union all - select i+1 as i, (integer_to_base(i+1, base)) as lst - from cte1 - where i < mx - ) - from cte1 -); - -create or replace function fairshare(base, numberOfTerms) as table ( - select (list_sum(lst) % base) as turn - from integers_in_base(base, numberOfTerms - 1) -); - -.print The first 25 terms of the fair share sequences: -select players, (select array_agg(turn) from fairshare(players, 25) ) as turns -from unnest( [2,3,5,11] ) as t(players); diff --git a/Task/Fairshare-between-two-and-more/EasyLang/fairshare-between-two-and-more.easy b/Task/Fairshare-between-two-and-more/EasyLang/fairshare-between-two-and-more.easy index 09372816ab..978264c4cb 100644 --- a/Task/Fairshare-between-two-and-more/EasyLang/fairshare-between-two-and-more.easy +++ b/Task/Fairshare-between-two-and-more/EasyLang/fairshare-between-two-and-more.easy @@ -1,19 +1,20 @@ -func fairshare ind base . +proc fairshare ind base . r . + r = 0 while ind > 0 - r += ind mod base + r = r + ind mod base ind = ind div base . r = r mod base - return r . -proc sequence n base . +proc sequence n base . . write base & ": " for ind range0 n - write (fairshare ind base) & " " + call fairshare ind base r + write r & " " . print "" . -sequence 25 2 -sequence 25 3 -sequence 25 5 -sequence 25 11 +call sequence 25 2 +call sequence 25 3 +call sequence 25 5 +call sequence 25 11 diff --git a/Task/Fairshare-between-two-and-more/Free-Pascal-Lazarus/fairshare-between-two-and-more.pas b/Task/Fairshare-between-two-and-more/Free-Pascal/fairshare-between-two-and-more.pas similarity index 100% rename from Task/Fairshare-between-two-and-more/Free-Pascal-Lazarus/fairshare-between-two-and-more.pas rename to Task/Fairshare-between-two-and-more/Free-Pascal/fairshare-between-two-and-more.pas diff --git a/Task/Fairshare-between-two-and-more/Julia/fairshare-between-two-and-more.jl b/Task/Fairshare-between-two-and-more/Julia/fairshare-between-two-and-more.julia similarity index 100% rename from Task/Fairshare-between-two-and-more/Julia/fairshare-between-two-and-more.jl rename to Task/Fairshare-between-two-and-more/Julia/fairshare-between-two-and-more.julia diff --git a/Task/Fairshare-between-two-and-more/Kotlin/fairshare-between-two-and-more.kts b/Task/Fairshare-between-two-and-more/Kotlin/fairshare-between-two-and-more.kotlin similarity index 100% rename from Task/Fairshare-between-two-and-more/Kotlin/fairshare-between-two-and-more.kts rename to Task/Fairshare-between-two-and-more/Kotlin/fairshare-between-two-and-more.kotlin diff --git a/Task/Fairshare-between-two-and-more/PL-I/fairshare-between-two-and-more.pli b/Task/Fairshare-between-two-and-more/PL-I/fairshare-between-two-and-more.pli deleted file mode 100644 index 01b1c2e9f6..0000000000 --- a/Task/Fairshare-between-two-and-more/PL-I/fairshare-between-two-and-more.pli +++ /dev/null @@ -1,19 +0,0 @@ -fairshareBetweenTwoAndMore: procedure options(main); - fairshare: procedure(nn, base) returns(fixed); - declare (n, nn, base, s) fixed; - s = 0; - do n=nn repeat(n/base) while(n>0); - s = s + mod(n, base); - end; - return(mod(s, base)); - end fairshare; - - declare bases(4) fixed static initial(2, 3, 5, 11); - declare (base, n) fixed; - do base=1 to 4; - put skip edit(bases(base), ': ') (F(2),A(2)); - do n=0 to 24; - put edit(fairshare(n, bases(base))) (F(3)); - end; - end; -end fairshareBetweenTwoAndMore; diff --git a/Task/Fairshare-between-two-and-more/PascalABC.NET/fairshare-between-two-and-more.pas b/Task/Fairshare-between-two-and-more/PascalABC.NET/fairshare-between-two-and-more.pas deleted file mode 100644 index d3d73e75cf..0000000000 --- a/Task/Fairshare-between-two-and-more/PascalABC.NET/fairshare-between-two-and-more.pas +++ /dev/null @@ -1,22 +0,0 @@ -function ThueMorseSequence(terms, baseValue: integer): list; -begin - result := new List; - for var i := 0 to terms - 1 do - begin - var sum := 0; - var n := i; - while (n > 0) do - begin - // Compute the digit sum - sum += n mod baseValue; - n := n div baseValue; - end; - // Compute the digit sum modulo baseValue. - result.Add(sum mod baseValue); - end; -end; - -begin - foreach var baseValue in |2, 3, 5, 11| do - println('Base', baseValue, '=', ThueMorseSequence(25, baseValue)); -end. diff --git a/Task/Fairshare-between-two-and-more/Phix/fairshare-between-two-and-more.phix b/Task/Fairshare-between-two-and-more/Phix/fairshare-between-two-and-more.phix index d2dc338dc3..8d6fdae63d 100644 --- a/Task/Fairshare-between-two-and-more/Phix/fairshare-between-two-and-more.phix +++ b/Task/Fairshare-between-two-and-more/Phix/fairshare-between-two-and-more.phix @@ -1,31 +1,20 @@ -with javascript_semantics -function fairshare(integer n, base) - sequence res = repeat(0,n) - for i=1 to n do - integer j = i-1, t = 0 - while j>0 do - t += rmdr(j,base) - j = floor(j/base) - end while - res[i] = rmdr(t,base) - end for - return {base,res} -end function +(phixonline)--> + function fairshare(integer n, base) + sequence res = repeat(0,n) + for i=1 to n do + integer j = i-1, + t = 0 + while j>0 do + t += remainder(j,base) + j = floor(j/base) + end while + res[i] = remainder(t,base) + end for + return {base,res} + end function -for t in {2,3,5,11} do - printf(1,"%2d : %v\n",fairshare(25,t)) -end for - -function turns(integer base) - sequence c = repeat(0,base) - for u in fairshare(50000,base)[2] do - c[u+1] += 1 - end for - if find(0,c) then return sprintf("only %d have a turn",sum(c)) end if - return join(unique(c)," or ",fmt:="%d") -end function - -printf(1,"\nHow many times does each get a turn in 50,000 iterations?\n") -for base in {191, 1377, 49999, 50000, 50001} do - printf(1," With %5d people: %s\n",{base,turns(base)}) -end for + constant tests = {2,3,5,11} + for i=1 to length(tests) do + printf(1,"%2d : %v\n", fairshare(25, tests[i])) + end for + + with javascript_semantics + -- demo\rosetta\Fermat.exw + include mpfr.e -procedure fermat(mpz res, integer n) - integer pn = power(2,n) - mpz_ui_pow_ui(res,2,pn) - mpz_add_si(res,res,1) -end procedure + procedure fermat(mpz res, integer n) + integer pn = power(2,n) + mpz_ui_pow_ui(res,2,pn) + mpz_add_si(res,res,1) + end procedure -mpz fn = mpz_init() -constant lim = iff(platform()=JS?18:29), -- (see note) - print_lim = iff(platform()=JS?16:20) -atom t -for i=0 to lim do - t = time() - fermat(fn,i) - string ts = elapsed(t,0.2," [%s]") - if i<=print_lim then - printf(1,"F%d = %s%s\n",{i,shorten(mpz_get_str(fn)),ts}) - else -- (since printing it takes too long...) - printf(1,"F%d has %,d digits%s\n",{i,mpz_sizeinbase(fn,10),ts}) - end if -end for + mpz fn = mpz_init() + constant lim = iff(platform()=JS?18:29), -- (see note) + print_lim = iff(platform()=JS?16:20) + for i=0 to lim do + fermat(fn,i) + if i<=print_lim then + printf(1,"F%d = %s\n",{i,shorten(mpz_get_str(fn))}) + else -- (since printing it takes too long...) + printf(1,"F%d has %,d digits\n",{i,mpz_sizeinbase(fn,10)}) + end if + end for -printf(1,"\n") -constant flimit = iff(platform()=JS?11:13) -for i=0 to flimit do - t = time() - fermat(fn,i) - sequence f = mpz_prime_factors(fn, 200000) - t = time()-t - string fs = "", - ts = elapsed(t,0.2," [%s]") - if length(f[$])=1 then -- (as per docs) - mpz_set_str(fn,f[$][1]) - if not mpz_prime(fn) then - if length(f)=1 then - fs = " (not prime)" - else - fs = " (last factor is not prime)" - end if - end if - f = deep_copy(f) - f[$][1] = shorten(f[$][1],ml:=15) - elsif length(f)=1 - and mpz_prime(fn) then - fs = " (prime)" - end if - fs = mpz_factorstring(f)&fs - printf(1,"Factors of F%d: %s%s\n",{i,fs,ts}) -end for + printf(1,"\n") + constant flimit = iff(platform()=JS?11:13) + for i=0 to flimit do + atom t = time() + fermat(fn,i) + sequence f = mpz_prime_factors(fn, 200000) + t = time()-t + string fs = "", + ts = elapsed(t) + if length(f[$])=1 then -- (as per docs) + mpz_set_str(fn,f[$][1]) + if not mpz_prime(fn) then + if length(f)=1 then + fs = " (not prime)" + else + fs = " (last factor is not prime)" + end if + end if + f = deep_copy(f) + f[$][1] = shorten(f[$][1]) + elsif length(f)=1 + and mpz_prime(fn) then + fs = " (prime)" + end if + fs = mpz_factorstring(f)&fs + printf(1,"Factors of F%d: %s [%s]\n",{i,fs,ts}) + end for + + with javascript_semantics + function nacci_noo(integer n, s, l) + if n<2 then return n+n*l end if + if n=2 then return 1 end if + atom res = nacci_noo(n-1,s,l) + for i=2 to min(s,n-1) do + res += nacci_noo(n-i,s,l) + end for + return res + end function -constant names = "lucas fibo tribo tetra penta hexa hepta octo nona deca" -sequence f = repeat(0,20) -for i,name in split(names) do - for j=1 to 20 do - f[j] = nacci_noo(j,i+(i=1),i=1) - end for - if name[$]!='s' then name&=`nacci` end if - printf(1,"%s: %s\n",{name,join(f,fmt:="%d")}) -end for + constant names = split("lucas fibo tribo tetra penta hexa hepta octo nona deca") + sequence f = repeat(0,10) + for i=1 to 4 do + for j=1 to 10 do + f[j] = nacci_noo(j,i+(i=1),i=1) + end for + printf(1,"%snacci: %v\n",{names[i],f}) + end for + + with javascript_semantics + constant extensions = lower({"zip","rar","7z","gz","archive","A##","tar.bz2"}) -global function get_known_extension(string filename) - for i,c in filename do - if c='.' then - string extension = lower(filename[i+1..$]) - if find(extension,extensions) then - return extension - end if - end if - end for - return "" -end function + global function get_known_extension(string filename) + for i=1 to length(filename) do + if filename[i]='.' then + string extension = lower(filename[i+1..$]) + if find(extension,extensions) then + return extension + end if + end if + end for + return "" + end function -constant tests = {"MyData.a##", - "MyData.tar.Gz", - "MyData.gzip", - "MyData.7z.backup", - "MyData...", - "MyData", - "MyData_v1.0.tar.bz2", - "MyData_v1.0.bz2"} + constant tests = {"MyData.a##", + "MyData.tar.Gz", + "MyData.gzip", + "MyData.7z.backup", + "MyData...", + "MyData", + "MyData_v1.0.tar.bz2", + "MyData_v1.0.bz2"} -for i,ti in tests do - string ext = get_known_extension(ti) - printf(1,"%-20s %-10s %t\n",{ti,ext,find(ext,extensions)!=0}) -end for + for i=1 to length(tests) do + string ti = tests[i], + ext = get_known_extension(ti) + printf(1,"%-20s %-10s %s\n",{ti,ext,{"true","false"}[2-(find(ext,extensions)!=0)]}) + end for + + with javascript_semantics + constant p0 = {0,0}, + p1 = {0,1}, + p2 = {3,1}, + triangle = {{3/2, 12/5}, {51/10, -31/10}, {-19/5, 1/2}} + function inside(sequence p) + return sort(convex_hull({p}&triangle))==sort(deep_copy(triangle)) + end function + printf(1,"Point %v is with triangle %v?:%t\n",{p0,triangle,inside(p0)}) + printf(1,"Point %v is with triangle %v?:%t\n",{p1,triangle,inside(p1)}) + printf(1,"Point %v is with triangle %v?:%t\n",{p2,triangle,inside(p2)}) + + with javascript_semantics + constant p0 = {0,0}, + p1 = {0,1}, + p2 = {3,1}, + triangle = {{3/2, 12/5}, {51/10, -31/10}, {-19/5, 1/2}} -function side(sequence p1, p2, p3) - -- which side of plane cut by line (p2, p3) is p1 on? - atom {x1, y1} = p1, - {x2, y2} = p2, - {x3, y3} = p3 - return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3) -end function + function side(sequence p1, p2, p3) + -- which side of plane cut by line (p2, p3) is p1 on? + atom {x1, y1} = p1, + {x2, y2} = p2, + {x3, y3} = p3 + return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3) + end function -function iswithin(sequence point, triangle) --- --- Determine if point is within triangle. --- If so, the point will be on the same side of each of the half planes --- defined by vectors p1p2, p2p3, and p3p1. side is positive if outside, --- negative if inside such a plane. All should be non-negative or all --- non-positive if the point is within the triangle. --- - sequence {pt1, pt2, pt3} = triangle - atom side12 = side(point, pt1, pt2), - side23 = side(point, pt2, pt3), - side31 = side(point, pt3, pt1) - bool all_non_neg = side12 >= 0 and side23 >= 0 and side31 >= 0, - all_non_pos = side12 <= 0 and side23 <= 0 and side31 <= 0 - return all_non_neg or all_non_pos -end function + function iswithin(sequence point, triangle) + -- + -- Determine if point is within triangle. + -- If so, the point will be on the same side of each of the half planes + -- defined by vectors p1p2, p2p3, and p3p1. side is positive if outside, + -- negative if inside such a plane. All should be non-negative or all + -- non-positive if the point is within the triangle. + -- + sequence {pt1, pt2, pt3} = triangle + atom side12 = side(point, pt1, pt2), + side23 = side(point, pt2, pt3), + side31 = side(point, pt3, pt1) + bool all_non_neg = side12 >= 0 and side23 >= 0 and side31 >= 0, + all_non_pos = side12 <= 0 and side23 <= 0 and side31 <= 0 + return all_non_neg or all_non_pos + end function -printf(1,"point %v is with triangle %v?:%t\n",{p0,triangle,iswithin(p0,triangle)}) -printf(1,"point %v is with triangle %v?:%t\n",{p1,triangle,iswithin(p1,triangle)}) -printf(1,"point %v is with triangle %v?:%t\n",{p2,triangle,iswithin(p2,triangle)}) + printf(1,"point %v is with triangle %v?:%t\n",{p0,triangle,iswithin(p0,triangle)}) + printf(1,"point %v is with triangle %v?:%t\n",{p1,triangle,iswithin(p1,triangle)}) + printf(1,"point %v is with triangle %v?:%t\n",{p2,triangle,iswithin(p2,triangle)}) + + atom t1 = time()+1 -integer depth = 0 + integer depth = 0 -procedure recurse() - if time()>t1 then - ?depth - t1 = time()+1 - end if - depth += 1 - -- only 1 of these will ever get called, of course... - recurse() - recurse() - recurse() -end procedure + procedure recurse() + if time()>t1 then + ?depth + t1 = time()+1 + end if + depth += 1 + -- only 1 of these will ever get called, of course... + recurse() + recurse() + recurse() + end procedure -recurse() + recurse() + + atom t1 = time()+1 -integer depth = 0, depth_blown = false, - limit = iff(platform()=JS?8e3:2e7) -string btd = "building" + integer depth = 0, depth_blown = false + string btd = "building" -procedure recurse() - if time()>t1 or depth>limit then - printf(1,"depth: %d (%s)\n",{depth,btd}) - if depth>limit then - depth_blown = true - btd = "tearing down" - end if - t1 = time()+1 - end if - if depth_blown then - depth -= 1 - else - depth += 1 - recurse() -- (build, aka +1 with progress) - recurse() -- (tear down, -1 with progress) - end if -end procedure + procedure recurse() + if time()>t1 then + printf(1,"depth: %d (%s)\n",{depth,btd}) + if depth>20_000_000 then + depth_blown = true + btd = "tearing down" + end if + t1 = time()+1 + end if + if depth_blown then + depth -= 1 + else + depth += 1 + recurse() -- (build, aka +1 with progress) + recurse() -- (tear down, -1 with progress) + end if + end procedure -recurse() + recurse() + + include timedate.e + + constant SUNDAY=7 + + procedure showlast(integer dow, integer doy, timedate td) + td = adjust_timedate(td,timedelta(days:=doy-1)) + integer {year,month,day} = td + while day_of_week(year,month,day)!=dow do day-=1 end while + printf(1,"%4d-%02d-%02d\n",{year,month,day}) + end procedure + + procedure last_day_of_month(integer year, integer dow) + integer doy + timedate first = {year,1,1,0,0,0,0,0} + -- start by finding the 1st of the next month, less 1 + for i=1 to 11 do + doy = day_of_year(year,i+1,1)-1 + showlast(dow,doy,first) + end for + -- do December separately, as 1st would be next year + doy = day_of_year(year,12,31) + showlast(dow,doy,first) + end procedure + last_day_of_month(2013,SUNDAY) + + with javascript_semantics + sequence mtable = {} -function multiplier(atom n1, atom n2) - mtable = append(mtable,{n1,n2}) - return length(mtable) -end function + function multiplier(atom n1, atom n2) + mtable = append(mtable,{n1,n2}) + return length(mtable) + end function -function call_multiplier(integer f, atom m) - atom {n1,n2} = mtable[f] - return n1*n2*m -end function + function call_multiplier(integer f, atom m) + atom {n1,n2} = mtable[f] + return n1*n2*m + end function -constant x = 2, - xi = 0.5, - y = 4, - yi = 0.25, - z = x + y, - zi = 1 / ( x + y ) + constant x = 2, + xi = 0.5, + y = 4, + yi = 0.25, + z = x + y, + zi = 1 / ( x + y ) -?call_multiplier(multiplier(x,xi),0.5) -?call_multiplier(multiplier(y,yi),0.5) -?call_multiplier(multiplier(z,zi),0.5) + ?call_multiplier(multiplier(x,xi),0.5) + ?call_multiplier(multiplier(y,yi),0.5) + ?call_multiplier(multiplier(z,zi),0.5) + + with javascript_semantics + sequence ctable = {} -function compose(integer f, g) - ctable = append(ctable,{f,g}) - integer cdx = length(ctable) - return cdx -end function + function compose(integer f, g) + ctable = append(ctable,{f,g}) + integer cdx = length(ctable) + return cdx + end function -function call_composite(integer cdx, atom x) - integer {f,g} = ctable[cdx] - return f(g(x)) -end function + function call_composite(integer cdx, atom x) + integer {f,g} = ctable[cdx] + return f(g(x)) + end function -function plus1(atom x) - return x+1 -end function + function plus1(atom x) + return x+1 + end function -function halve(atom x) - return x/2 -end function + function halve(atom x) + return x/2 + end function -constant m = compose(halve,plus1) + constant m = compose(halve,plus1) -?call_composite(m,1) -- displays 1 -?call_composite(m,4) -- displays 2.5 + ?call_composite(m,1) -- displays 1 + ?call_composite(m,4) -- displays 2.5 + n/d ) - [ 1 2 ] is xi ( --> n/d ) - [ 4 1 ] is y ( --> n/d ) - [ 1 4 ] is yi ( --> n/d ) - [ x y v+ ] is z ( n/d n/d --> n/d ) - [ x y v+ 1/v ] is zi ( n/d n/d --> n/d ) - - [ ' [ v* v* ] join join ] is multiplier ( x n/d --> [ ) - -' xi ' [ 1 2 ] multiplier dup echo x rot do say " applied to x gives: " vulgar$ echo$ cr -' yi ' [ 1 2 ] multiplier dup echo y rot do say " applied to y gives: " vulgar$ echo$ cr -' zi ' [ 1 2 ] multiplier dup echo z rot do say " applied to z gives: " vulgar$ echo$ cr diff --git a/Task/First-class-functions-Use-numbers-analogously/Rebol/first-class-functions-use-numbers-analogously.rebol b/Task/First-class-functions-Use-numbers-analogously/Rebol/first-class-functions-use-numbers-analogously.rebol deleted file mode 100644 index 717692aabd..0000000000 --- a/Task/First-class-functions-Use-numbers-analogously/Rebol/first-class-functions-use-numbers-analogously.rebol +++ /dev/null @@ -1,30 +0,0 @@ -Rebol [ - title: "Rosetta code: First-class functions/Use numbers analogously" - file: %First-class_functions-Use_numbers_analogously.r3 - url: https://rosettacode.org/wiki/First-class_functions/Use_numbers_analogously -] - -;; Numeric values and their inverses -x: 2.0 xi: 0.5 -y: 4.0 yi: 0.25 -z: x + y zi: 1 / (x + y) - -;; Returns a function that multiplies its argument a by n and m, -;; printing the expression before returning the result. -;; closure (vs func) ensures n and m are captured by value in the returned func. -multiplier: closure [n m] [ - func [a] [ - prin [a "*" n "*" m "= "] - a * n * m - ] -] -;; Parallel lists: each number paired with its inverse by position -num-list: reduce [x y z] ; [2.0 4.0 6.0] -num-list-inv: reduce [xi yi zi] ; [0.5 0.25 0.1666...] - -repeat key length? num-list [ - n: num-list/:key - ni: num-list-inv/:key - fun: multiplier ni n ;; build closure: a * ni * n = a * 1.0 (always) - print as-green fun 0.5 ;; call closure with 0.5; result should always be 0.5 -] diff --git a/Task/First-class-functions-Use-numbers-analogously/Rust/first-class-functions-use-numbers-analogously.rs b/Task/First-class-functions-Use-numbers-analogously/Rust/first-class-functions-use-numbers-analogously.rust similarity index 100% rename from Task/First-class-functions-Use-numbers-analogously/Rust/first-class-functions-use-numbers-analogously.rs rename to Task/First-class-functions-Use-numbers-analogously/Rust/first-class-functions-use-numbers-analogously.rust diff --git a/Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.scm b/Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.ss similarity index 100% rename from Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.scm rename to Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.ss diff --git a/Task/First-class-functions-Use-numbers-analogously/Wren/first-class-functions-use-numbers-analogously.wren b/Task/First-class-functions-Use-numbers-analogously/Wren/first-class-functions-use-numbers-analogously.wren index d8b6d872a3..50a2cf4730 100644 --- a/Task/First-class-functions-Use-numbers-analogously/Wren/first-class-functions-use-numbers-analogously.wren +++ b/Task/First-class-functions-Use-numbers-analogously/Wren/first-class-functions-use-numbers-analogously.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var multiplier = Fn.new { |n1, n2| Fn.new { |m| n1 * n2 * m } } diff --git a/Task/First-class-functions/Ada/first-class-functions.adb b/Task/First-class-functions/Ada/first-class-functions.ada similarity index 100% rename from Task/First-class-functions/Ada/first-class-functions.adb rename to Task/First-class-functions/Ada/first-class-functions.ada diff --git a/Task/First-class-functions/Crystal/first-class-functions-1.cr b/Task/First-class-functions/Crystal/first-class-functions-1.cr deleted file mode 100644 index 7d6593bb69..0000000000 --- a/Task/First-class-functions/Crystal/first-class-functions-1.cr +++ /dev/null @@ -1 +0,0 @@ -->Math.sin(Float64) diff --git a/Task/First-class-functions/Crystal/first-class-functions-2.cr b/Task/First-class-functions/Crystal/first-class-functions-2.cr deleted file mode 100644 index 3b82e7a930..0000000000 --- a/Task/First-class-functions/Crystal/first-class-functions-2.cr +++ /dev/null @@ -1 +0,0 @@ -->(n : Float64) { Math.sin(n) } diff --git a/Task/First-class-functions/Crystal/first-class-functions-3.cr b/Task/First-class-functions/Crystal/first-class-functions-3.cr deleted file mode 100644 index 8d6dfeceb0..0000000000 --- a/Task/First-class-functions/Crystal/first-class-functions-3.cr +++ /dev/null @@ -1,20 +0,0 @@ -def cube (n) - n*n*n -end - -add1 = ->(n : Float64) { n + 1 } -sub1 = ->(n : Float64) { n - 1 } - -a = [ ->Math.sin(Float64), ->Math.cos(Float64), ->cube(Float64), add1 ] -b = [ ->Math.asin(Float64), ->Math.acos(Float64), ->Math.cbrt(Float64), sub1 ] -s = [ "sin o asin", "cos o acos", "cube o cbrt", "add1 o sub1"] - -def compose (f, g) - ->(n : Float64) { f[ g[n] ] } -end - -composed = a.zip(b).map {|(f, g)| compose(f, g) } - -composed.each_with_index do |f, i| - puts "(#{s[i]})(0.5) = #{ f[0.5] }" -end diff --git a/Task/First-class-functions/Delphi/first-class-functions.pas b/Task/First-class-functions/Delphi/first-class-functions.delphi similarity index 100% rename from Task/First-class-functions/Delphi/first-class-functions.pas rename to Task/First-class-functions/Delphi/first-class-functions.delphi diff --git a/Task/First-class-functions/Elena/first-class-functions.elena b/Task/First-class-functions/Elena/first-class-functions.elena index 67f287ebe2..72cd37e51b 100644 --- a/Task/First-class-functions/Elena/first-class-functions.elena +++ b/Task/First-class-functions/Elena/first-class-functions.elena @@ -9,11 +9,11 @@ extension op = f(g(self)); } -public Program() +public program() { var fs := new object[]{ mssgconst sin[1], mssgconst cos[1], (x => power(x, 3.0r)) }; var gs := new object[]{ mssgconst arcsin[1], mssgconst arccos[1], (x => power(x, 1.0r / 3)) }; fs.zipBy(gs, (f,g => 0.5r.compose(f,g))) - .forEach(PrintingLn) + .forEach:printingLn } diff --git a/Task/First-class-functions/Elixir/first-class-functions.ex b/Task/First-class-functions/Elixir/first-class-functions.elixir similarity index 100% rename from Task/First-class-functions/Elixir/first-class-functions.ex rename to Task/First-class-functions/Elixir/first-class-functions.elixir diff --git a/Task/First-class-functions/Julia/first-class-functions.jl b/Task/First-class-functions/Julia/first-class-functions.julia similarity index 100% rename from Task/First-class-functions/Julia/first-class-functions.jl rename to Task/First-class-functions/Julia/first-class-functions.julia diff --git a/Task/First-class-functions/Kotlin/first-class-functions.kts b/Task/First-class-functions/Kotlin/first-class-functions.kotlin similarity index 100% rename from Task/First-class-functions/Kotlin/first-class-functions.kts rename to Task/First-class-functions/Kotlin/first-class-functions.kotlin diff --git a/Task/First-class-functions/Maxima/first-class-functions.maxima b/Task/First-class-functions/Maxima/first-class-functions.maxima index 5b2d1ff458..0f3b0ee18b 100644 --- a/Task/First-class-functions/Maxima/first-class-functions.maxima +++ b/Task/First-class-functions/Maxima/first-class-functions.maxima @@ -2,3 +2,4 @@ a: [sin, cos, lambda([x], x^3)]$ b: [asin, acos, lambda([x], x^(1/3))]$ compose(f, g) := buildq([f, g], lambda([x], f(g(x))))$ map(lambda([fun], fun(x)), map(compose, a, b)); +[x, x, x] diff --git a/Task/First-class-functions/OCaml/first-class-functions.ml b/Task/First-class-functions/OCaml/first-class-functions.ocaml similarity index 100% rename from Task/First-class-functions/OCaml/first-class-functions.ml rename to Task/First-class-functions/OCaml/first-class-functions.ocaml diff --git a/Task/First-class-functions/PascalABC.NET/first-class-functions.pas b/Task/First-class-functions/PascalABC.NET/first-class-functions.pas deleted file mode 100644 index 091decbbb2..0000000000 --- a/Task/First-class-functions/PascalABC.NET/first-class-functions.pas +++ /dev/null @@ -1,15 +0,0 @@ -function Cube(x: real) := x**3; -function CubeRoot(x: real) := x**(1/3); - -function Composition(f1,f2: T -> T): T -> T := x -> f1(f2(x)); - -begin - var A := Arr(Sin,Cos,Cube); - var B := Arr(ArcSin,ArcCos,CubeRoot); - for var i:=0 to A.Length-1 do - Println(Composition(A[i],B[i])(0.5)); - - // Build-in composition f1 * f2 - foreach var (f1,f2) in A.Zip(B) do - Println((f1 * f2)(0.5)); -end. diff --git a/Task/First-class-functions/Phix/first-class-functions.phix b/Task/First-class-functions/Phix/first-class-functions.phix index b422dc259e..6fe2a63ae3 100644 --- a/Task/First-class-functions/Phix/first-class-functions.phix +++ b/Task/First-class-functions/Phix/first-class-functions.phix @@ -1,25 +1,27 @@ -sequence ctable = {} +(phixonline)--> + sequence ctable = {} -function compose(integer f, g) - ctable = append(ctable,{f,g}) - integer cdx = length(ctable) - return cdx -end function + function compose(integer f, g) + ctable = append(ctable,{f,g}) + integer cdx = length(ctable) + return cdx + end function -function call_composite(integer cdx, atom x) - integer {f,g} = ctable[cdx] - return f(g(x)) -end function + function call_composite(integer cdx, atom x) + integer {f,g} = ctable[cdx] + return f(g(x)) + end function -function plus1(atom x) - return x+1 -end function + function plus1(atom x) + return x+1 + end function -function halve(atom x) - return x/2 -end function + function halve(atom x) + return x/2 + end function -constant m = compose(halve,plus1) + constant m = compose(halve,plus1) -?call_composite(m,1) -- displays 1 -?call_composite(m,4) -- displays 2.5 + ?call_composite(m,1) -- displays 1 + ?call_composite(m,4) -- displays 2.5 + b ) - - [ nextword - dup isfloat not if - [ $ '"f" needs to be followed by a number.' - message put bail ] - ' [ ' ] swap nested join - nested swap dip join ] builds f ( [ $ --> [ $ ) - - [ $ \ -import math -a = string_from_stack() -a = str(math.sin(float(a))) -string_to_stack(a) \ python ] is sin ( $ --> $ ) - - [ $ \ -import math -a = string_from_stack() -a = str(math.asin(float(a))) -string_to_stack(a) \ python ] is asin ( $ --> $ ) - - [ $ \ -import math -a = string_from_stack() -a = str(math.cos(float(a))) -string_to_stack(a) \ python ] is cos ( $ --> $ ) - - [ $ \ -import math -a = string_from_stack() -a = str(math.acos(float(a))) -string_to_stack(a) \ python ] is acos ( $ --> $ ) - - [ $ \ -a = string_from_stack() -b = string_from_stack() -c = str(float(b) * float(a)) -string_to_stack(c) \ python ] is f* ( $ $ --> $ ) - - [ $ \ -a = string_from_stack() -b = string_from_stack() -c = str(float(b) / float(a)) -string_to_stack(c) \ python ] is f/ ( $ $ --> $ ) - - [ $ \ -a = string_from_stack() -b = string_from_stack() -c = str(float(b) ** float(a)) -string_to_stack(c) \ python ] is f** ( $ $ --> $ ) diff --git a/Task/First-class-functions/Quackery/first-class-functions-2.quackery b/Task/First-class-functions/Quackery/first-class-functions-2.quackery deleted file mode 100644 index 338f0e1ae7..0000000000 --- a/Task/First-class-functions/Quackery/first-class-functions-2.quackery +++ /dev/null @@ -1,24 +0,0 @@ - [ dup dup f* f* ] is cubed ( $ --> $ ) - - [ f 1 f 3 f/ f** ] is cuberoot ( $ --> $ ) - - [ table sin cos cubed ] is A ( n --> [ ) - - [ table asin acos cuberoot ] is B ( n --> [ ) - - [ dip nested nested join ] is compose ( x x --> [ ) - - [ dup dip A B compose do ] is ->A->B-> ( f n --> f ) - - ' [ f 0.5 f 1.234567 ] - witheach - [ do 3 times - [ dup echo$ - say " -> " - i^ A echo - say " -> " - i^ B echo - say " -> " - dup i^ ->A->B-> echo$ - cr ] - drop cr ] diff --git a/Task/First-class-functions/Rebol/first-class-functions.rebol b/Task/First-class-functions/REBOL/first-class-functions.rebol similarity index 98% rename from Task/First-class-functions/Rebol/first-class-functions.rebol rename to Task/First-class-functions/REBOL/first-class-functions.rebol index 131a384d7a..41c1695b2b 100644 --- a/Task/First-class-functions/Rebol/first-class-functions.rebol +++ b/Task/First-class-functions/REBOL/first-class-functions.rebol @@ -1,4 +1,4 @@ -Rebol [ +REBOL [ Title: "First Class Functions" URL: http://rosettacode.org/wiki/First-class_functions ] diff --git a/Task/First-class-functions/Raku/first-class-functions-1.raku b/Task/First-class-functions/Raku/first-class-functions-1.raku index 613c01dcf1..df923bf8b3 100644 --- a/Task/First-class-functions/Raku/first-class-functions-1.raku +++ b/Task/First-class-functions/Raku/first-class-functions-1.raku @@ -1,3 +1,5 @@ +sub infix:<∘> (&𝑔, &𝑓) { -> \x { 𝑔 𝑓 x } } + my \𝐴 = &sin, &cos, { $_ ** <3/1> } my \𝐵 = &asin, &acos, { $_ ** <1/3> } diff --git a/Task/First-class-functions/Red/first-class-functions.red b/Task/First-class-functions/Red/first-class-functions.red deleted file mode 100644 index 4a0412bf0c..0000000000 --- a/Task/First-class-functions/Red/first-class-functions.red +++ /dev/null @@ -1,20 +0,0 @@ -Red [ "First-Class Functions - Hinjolicious" ] - -; sine and cosine are natives -cube: function [x][x * x * x] -cube-root: function [x][power x (1 / 3)] - -A: [sin cos cube] -B: [asin acos cube-root] - -; to show the codes -demo: function [s b] [print ["^/==" s "==^/"] print mold/only b do b] - -comp-func: function ['f 'g] [function [x] compose [(get f) (get g) x]] - -demo "Composing functions from List A and B and calling it" [ -repeat i 3 [ - f: comp-func A/:i B/:i - print f 0.5 -] -] diff --git a/Task/First-class-functions/Rust/first-class-functions.rs b/Task/First-class-functions/Rust/first-class-functions.rust similarity index 100% rename from Task/First-class-functions/Rust/first-class-functions.rs rename to Task/First-class-functions/Rust/first-class-functions.rust diff --git a/Task/First-class-functions/Scheme/first-class-functions.scm b/Task/First-class-functions/Scheme/first-class-functions.ss similarity index 100% rename from Task/First-class-functions/Scheme/first-class-functions.scm rename to Task/First-class-functions/Scheme/first-class-functions.ss diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/ALGOL-68/first-perfect-square-in-base-n-with-n-unique-digits.alg b/Task/First-perfect-square-in-base-n-with-n-unique-digits/ALGOL-68/first-perfect-square-in-base-n-with-n-unique-digits.alg index 540e9b67d6..4cd590746e 100644 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/ALGOL-68/first-perfect-square-in-base-n-with-n-unique-digits.alg +++ b/Task/First-perfect-square-in-base-n-with-n-unique-digits/ALGOL-68/first-perfect-square-in-base-n-with-n-unique-digits.alg @@ -25,7 +25,9 @@ BEGIN # find the first perfect square in base n with n unique digits n=1..16 # FOR b FROM 2 TO 16 DO all digits := all digits OR dmask[ b - 1 ]; LONG INT root := 1; - TO b - 1 DO root *:= b OD; + FOR i TO b - 1 DO + root *:= b + OD; root := ENTIER long sqrt( root ); BOOL found := FALSE; WHILE NOT found DO diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Delphi/first-perfect-square-in-base-n-with-n-unique-digits.pas b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Delphi/first-perfect-square-in-base-n-with-n-unique-digits.delphi similarity index 100% rename from Task/First-perfect-square-in-base-n-with-n-unique-digits/Delphi/first-perfect-square-in-base-n-with-n-unique-digits.pas rename to Task/First-perfect-square-in-base-n-with-n-unique-digits/Delphi/first-perfect-square-in-base-n-with-n-unique-digits.delphi diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/EasyLang/first-perfect-square-in-base-n-with-n-unique-digits.easy b/Task/First-perfect-square-in-base-n-with-n-unique-digits/EasyLang/first-perfect-square-in-base-n-with-n-unique-digits.easy deleted file mode 100644 index 21e3d1e191..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/EasyLang/first-perfect-square-in-base-n-with-n-unique-digits.easy +++ /dev/null @@ -1,28 +0,0 @@ -func$ itoa n b . - if n = 0 : return "" - d = n mod b + 48 - if d >= 58 : d += 7 - return itoa (n div b) b & strchar d -. -fastfunc unique s b . - len dig[] b + 1 - while s > 0 - dig[s mod b + 1] = 1 - s = s div b - . - for v in dig[] : cnt += v - return cnt -. -fastfunc find b . - n = floor pow b ((b - 1) / 2) + 1 - repeat - sq = n * n - until unique sq b = b - n += 1 - . - return n -. -for b = 2 to 14 - n = find b - print "Base " & b & ": " & itoa n b & "² = " & itoa (n * n) b -. diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Fortran/first-perfect-square-in-base-n-with-n-unique-digits.f b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Fortran/first-perfect-square-in-base-n-with-n-unique-digits.f deleted file mode 100644 index cc619f4a86..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Fortran/first-perfect-square-in-base-n-with-n-unique-digits.f +++ /dev/null @@ -1,100 +0,0 @@ -program perfect_squares - implicit none - integer :: base, i - integer(8) :: m, m_squared, base_power, start_m - character(len=:), allocatable :: m_str, square_str - logical :: found - - do base = 2, 16 - found = .false. - ! Calculate base^(base-1) for lower bound - base_power = 1_8 - do i = 1, base-1 - base_power = base_power * int(base, 8) - end do - ! Compute start_m as ceiling(sqrt(base_power)) - start_m = int(sqrt(real(base_power, kind=8)), kind=8) - if (start_m * start_m < base_power) start_m = start_m + 1_8 - ! Search until solution found (no upper limit) - do m = start_m, huge(1_8)-1 - m_squared = m * m - square_str = to_base(m_squared, base) - if (len(square_str) < base) cycle - if (is_valid_square(square_str, base)) then - m_str = to_base(m, base) - print "(A, I2, A, A,T25, A, A)", "Base ", base, " : Num ", trim(m_str), " Square ", trim(square_str) - found = .true. - exit - end if - end do - if (.not. found) print *, "No solution for base ", base - end do -contains -pure function to_base(n, base) result(str) - integer(8), intent(in) :: n - integer, intent(in) :: base - character(len=:), allocatable :: str - integer(8) :: tmp, bbase, rem - integer :: i, len - character(1) :: buffer(32) - character(1), parameter :: digits(16) = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'] - - tmp = n - bbase = base - i = 0 - buffer = ' ' ! Initialize buffer to blanks - - do while (tmp > 0) - rem = mod(tmp, bbase) - i = i + 1 - buffer(i) = digits(rem+1) - tmp = tmp / bbase - end do - - if (i == 0) then -! allocate(str(1)) - str(1:1) = '0' - return - end if - - allocate(character(i) :: str) - do len = 1, i - str(len:len) = buffer(i - len + 1) - end do -end function to_base - -pure function is_valid_square(str, base) result(ok) - character(len=*), intent(in) :: str - integer, intent(in) :: base - logical :: ok - integer :: i, digit, ascii, seen, mask - integer, parameter :: char_to_digit(48:70) = [ & - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, & ! '0'–'9' - ( -1, i = 58, 64 ), & ! ':'–'@' - 10, 11, 12, 13, 14, 15 ] ! 'A'–'F' - - if (len(str) < base) then - ok = .false. - return - end if - - seen = 0 - do i = 1, len(str) - ascii = iachar(str(i:i)) - if (ascii < 48 .or. ascii > 70) then - ok = .false. - return - end if - digit = char_to_digit(ascii) - if (digit < 0 .or. digit >= base) then - ok = .false. - return - end if - seen = ibset(seen, digit) - end do - - mask = ishft(1, base) - 1 - ok = (seen == mask) -end function is_valid_square - -end program perfect_squares diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/FreeBASIC/first-perfect-square-in-base-n-with-n-unique-digits.basic b/Task/First-perfect-square-in-base-n-with-n-unique-digits/FreeBASIC/first-perfect-square-in-base-n-with-n-unique-digits.basic deleted file mode 100644 index 91eb36ff0c..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/FreeBASIC/first-perfect-square-in-base-n-with-n-unique-digits.basic +++ /dev/null @@ -1,39 +0,0 @@ -#define floor(x) ((x*2.0-0.5) Shr 1) - -Dim Shared As Double n, base_ = 2. ' Base is a reserved word on FB - -Sub NumOut(n As Double) 'Display n in the specified base - Dim As Integer remainder = Fix(n Mod base_) - n = floor(n / base_) - If n <> 0. Then NumOut(n) - Print Chr(remainder + Iif(remainder <= 9, Asc("0"), Asc("A")-10)); -End Sub - -Function isPandigital(n As Double) As Boolean - Dim As Integer used, remainder - used = 0 - While n <> 0. - remainder = Fix(n Mod base_) - n = floor(n / base_) - used Or= 1 Shl remainder - Wend - Return used = (1 Shl Fix(base_)) - 1 -End Function - -Do - n = floor(Sqr(base_ ^ (base_-1.))) - Do - If isPandigital(n*n) Then - Print Using "Base ##: "; base_; - NumOut(n) - Print "^2 = "; - NumOut(n*n) - Print - Exit Do - End If - n += 1. - Loop - base_ += 1. -Loop Until base_ > 14. - -Sleep diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Julia/first-perfect-square-in-base-n-with-n-unique-digits.jl b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Julia/first-perfect-square-in-base-n-with-n-unique-digits.julia similarity index 100% rename from Task/First-perfect-square-in-base-n-with-n-unique-digits/Julia/first-perfect-square-in-base-n-with-n-unique-digits.jl rename to Task/First-perfect-square-in-base-n-with-n-unique-digits/Julia/first-perfect-square-in-base-n-with-n-unique-digits.julia diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Kotlin/first-perfect-square-in-base-n-with-n-unique-digits.kts b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Kotlin/first-perfect-square-in-base-n-with-n-unique-digits.kotlin similarity index 100% rename from Task/First-perfect-square-in-base-n-with-n-unique-digits/Kotlin/first-perfect-square-in-base-n-with-n-unique-digits.kts rename to Task/First-perfect-square-in-base-n-with-n-unique-digits/Kotlin/first-perfect-square-in-base-n-with-n-unique-digits.kotlin diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/PascalABC.NET/first-perfect-square-in-base-n-with-n-unique-digits.pas b/Task/First-perfect-square-in-base-n-with-n-unique-digits/PascalABC.NET/first-perfect-square-in-base-n-with-n-unique-digits.pas deleted file mode 100644 index 97a4a48928..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/PascalABC.NET/first-perfect-square-in-base-n-with-n-unique-digits.pas +++ /dev/null @@ -1,34 +0,0 @@ -uses School; - -const - valid_chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -function ToBase(number: int64; base: integer): string; -begin - var sb := new System.Text.StringBuilder(''); - while number > 0 do - begin - sb.Insert(0, valid_chars[integer(number mod base) + 1]); - number := number div base - end; - Result := if sb.Length = 0 then '0' - else sb.ToString -end; - -begin - var n: Int64 := 1; - for var base := 2 to 15 do - begin - while True do - begin - var nn: int64 := n * n; - var dd := ToBase(nn,base); - if (dd.Length >= base) and (dd.ToHashSet.Count = base) then - begin - Println($'{base,2} {ToBase(n,base),8}^2 = {ToBase(n*n,base)}'); - break; - end; - n += 1; - end; - end; -end. diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Pluto/first-perfect-square-in-base-n-with-n-unique-digits.pluto b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Pluto/first-perfect-square-in-base-n-with-n-unique-digits.pluto deleted file mode 100644 index 79bd463454..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Pluto/first-perfect-square-in-base-n-with-n-unique-digits.pluto +++ /dev/null @@ -1,99 +0,0 @@ -require "bignum" -require "table2" -local fmt = require "fmt" - -local maxbase = 21 -local minsq36 = "1023456789abcdefghijklmnopqrstuvwxyz" -local minsq36x = "10123456789abcdefghijklmnopqrstuvwxyz" -local zero = bigint.new(0) - -local function contains_all(sq, base) - local found = table.rep(maxbase, 0) - local le = #sq - local reps = 0 - for sq as r do - local d = r:byte() - 48 - if d > 38 then d -= 39 end - found[d + 1] += 1 - if found[d + 1] > 1 then - reps += 1 - if le - reps < base then return false end - end - end - return true -end - -local function sum_digits(n, base) - local sum = zero - while n > zero do - sum += n % base - n /= base - end - return sum -end - -local function digital_root(n, base) - while n > base - 1 do n = sum_digits(n, base) end - return bigint.toplain(n) -end - -local function min_start(base) - local ms = minsq36:sub(1, base) - local nn = bigint.frombase(ms, base) - local bdr = digital_root(nn, base) - local drs = {} - local ixs = {} - for n = 1, 2 * base - 1 do - nn = bigint.new(n * n) - local dr = digital_root(nn, base) - if dr == 0 then dr = n * n end - if dr == bdr then ixs:insert(n) end - if n < base and dr >= bdr then drs:insert(dr) end - end - local inc = 1 - if #ixs >= 2 and base != 3 then inc = ixs[2] - ixs[1] end - if #drs == 0 then return ms, inc, bdr end - local min = drs:min() - local rd = min - bdr - if rd == 0 then return ms, inc, bdr end - if rd == 1 then return minsq36x:sub(1, base + 1), 1, bdr end - local ins = minsq36[rd + 1] - return (minsq36:sub(1, rd) .. ins .. minsq36:sub(rd + 1)):sub(1, base + 1), inc, bdr -end - -local start = os.clock() -local n = 2 -local k = 1 -local base = 2 -while true do - if base == 2 or (n % base) != 0 then - local nb = bigint.new(n) - local sq = bigint.tobase(nb * nb, base) - if contains_all(sq:split(""), base) then - local ns = fmt.itoa(n, base) - local tt = os.clock() - start - fmt.print("Base %2d:%15s² = %-27s in %8.3fs", base, ns, sq, tt) - if base == maxbase then break end - base += 1 - local ms, inc, bdr = min_start(base) - k = inc - local nn = bigint.frombase(ms, base) - nb = bigint.sqrt(nn) - if nb < n + 1 then nb = bigint.new(n + 1) end - if k != 1 then - while true do - nn = nb * nb - local dr = digital_root(nn, base) - if dr == bdr then - n = bigint.toplain(nb) - k - break - end - nb += 1 - end - else - n = bigint.toplain(nb) - k - end - end - end - n += k -end diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Quackery/first-perfect-square-in-base-n-with-n-unique-digits.quackery b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Quackery/first-perfect-square-in-base-n-with-n-unique-digits.quackery deleted file mode 100644 index 2e62ca8c6d..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Quackery/first-perfect-square-in-base-n-with-n-unique-digits.quackery +++ /dev/null @@ -1,33 +0,0 @@ - [ dup 1 - [ 2dup > while - + 1 >> - 2dup / again ] - drop nip ] is sqrt ( n --> n ) - - [ base share bit 1 - - 0 rot - [ dup while - base share /mod bit - rot | swap again ] - drop = ] is pandigital ( n --> b ) - - [ base share - dup 2 - times - [ base share * - i^ 2 + + ] ] is firstpan ( --> n ) - - [ dup * ] is squared ( n --> n ) - - 11 times - [ i^ 2 + base put - firstpan sqrt from - [ index squared - pandigital if - [ index end ] ] - base share - say "Base " decimal echo - base release - say ": " dup echo - say "^" 2 echo say " = " - squared echo - cr base release ] diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua deleted file mode 100644 index e8e61cfe08..0000000000 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua +++ /dev/null @@ -1,11 +0,0 @@ -IsPan ← =⧻◴ # IsPan 3 [0 1 2] -> true -# Smallest pan number for given base -# will always be = [1 0 2 3 4...] in base n -MinPanBase ← ⌝⊥⊙⇌ ⟜(˜↙⊂1_0↘2⇡⊸+1) -# Take sqrt of the smallest pan number and inc until found. -MinPanSqrBase ← ⊙◌⍢(+1|¬IsPan ⇌⊥⊃⋅∘⊙∘˙×) ⌊√⊸MinPanBase -ShowMinPan ← ( - ⊃(⊙∘|⋅˙×|⇌⊥ ⊙˙×) ⟜MinPanSqrBase - &p $"Base _\t_\t_\t_\t" -) -⍜now (≡ShowMinPan ↘2⇡13) diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Wren/first-perfect-square-in-base-n-with-n-unique-digits.wren b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Wren/first-perfect-square-in-base-n-with-n-unique-digits.wren index 56a0a58e8d..02c6759dd3 100644 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Wren/first-perfect-square-in-base-n-with-n-unique-digits.wren +++ b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Wren/first-perfect-square-in-base-n-with-n-unique-digits.wren @@ -1,6 +1,6 @@ -import "./big" for BigInt -import "./math" for Nums -import "./fmt" for Conv, Fmt +import "/big" for BigInt +import "/math" for Nums +import "/fmt" for Conv, Fmt var maxBase = 21 var minSq36 = "1023456789abcdefghijklmnopqrstuvwxyz" diff --git a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/EasyLang/first-power-of-2-that-has-leading-decimal-digits-of-12.easy b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/EasyLang/first-power-of-2-that-has-leading-decimal-digits-of-12.easy deleted file mode 100644 index 246a21bb05..0000000000 --- a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/EasyLang/first-power-of-2-that-has-leading-decimal-digits-of-12.easy +++ /dev/null @@ -1,23 +0,0 @@ -fastfunc p l n . - log10_2 = log 2 10 - factor = 1 - loop = l - while loop > 10 - factor *= 10 - loop = loop div 10 - . - while n > 0 - test += 1 - val = floor (factor * pow 10 (test * log10_2 mod 1)) - if val = l : n -= 1 - . - return test -. -proc test l n . - print "p(" & l & ", " & n & ") = " & p l n -. -test 12 1 -test 12 2 -test 123 45 -test 123 12345 -test 123 678910 diff --git a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-1.jl b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-1.julia similarity index 100% rename from Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-1.jl rename to Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-1.julia diff --git a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-2.jl b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-2.julia similarity index 100% rename from Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-2.jl rename to Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Julia/first-power-of-2-that-has-leading-decimal-digits-of-12-2.julia diff --git a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Kotlin/first-power-of-2-that-has-leading-decimal-digits-of-12.kts b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Kotlin/first-power-of-2-that-has-leading-decimal-digits-of-12.kotlin similarity index 100% rename from Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Kotlin/first-power-of-2-that-has-leading-decimal-digits-of-12.kts rename to Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Kotlin/first-power-of-2-that-has-leading-decimal-digits-of-12.kotlin diff --git a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/PascalABC.NET/first-power-of-2-that-has-leading-decimal-digits-of-12.pas b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/PascalABC.NET/first-power-of-2-that-has-leading-decimal-digits-of-12.pas deleted file mode 100644 index 1c4d47c140..0000000000 --- a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/PascalABC.NET/first-power-of-2-that-has-leading-decimal-digits-of-12.pas +++ /dev/null @@ -1,24 +0,0 @@ -function p(L,n: integer): integer; -begin - var logof2 := log10(2); - var places := trunc(log10(L)); - var nfound := 0; - var i := 1; - while True do - begin - var a := i * logof2; - var b := trunc(power(10,a-trunc(a)+places)); - if L = b then - begin - nfound += 1; - if nfound = n then break - end; - i += 1; - end; - Result := i; -end; - -begin - foreach var (L,n) in Arr((12, 1), (12, 2), (123, 45), (123, 12345), (123, 678910)) do - Println($'p({n},{L}) = {p(n, L)}') -end. diff --git a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Phix/first-power-of-2-that-has-leading-decimal-digits-of-12.phix b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Phix/first-power-of-2-that-has-leading-decimal-digits-of-12.phix index 5c6d63b988..9d17028cd1 100644 --- a/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Phix/first-power-of-2-that-has-leading-decimal-digits-of-12.phix +++ b/Task/First-power-of-2-that-has-leading-decimal-digits-of-12/Phix/first-power-of-2-that-has-leading-decimal-digits-of-12.phix @@ -1,31 +1,33 @@ -with javascript_semantics -function p(integer L, n) - atom logof2 = log10(2) - integer places = trunc(log10(L)), - nfound = 0, i = 1 - while true do - atom a = i * logof2, - b = trunc(power(10,a-trunc(a)+places)) - if L == b then - nfound += 1 - if nfound == n then exit end if - end if - i += 1 - end while - return i -end function +(phixonline)--> + with javascript_semantics + function p(integer L, n) + atom logof2 = log10(2) + integer places = trunc(log10(L)), + nfound = 0, i = 1 + while true do + atom a = i * logof2, + b = trunc(power(10,a-trunc(a)+places)) + if L == b then + nfound += 1 + if nfound == n then exit end if + end if + i += 1 + end while + return i + end function -constant tests = {{12, 1}, {12, 2}, {123, 45}, {123, 12345}, {123, 678910}} -include ordinal.e -include mpfr.e -mpz z = mpz_init() -atom t0 = time() -for i=1 to length(tests)-(2*(platform()=JS)) do - integer {L,n} = tests[i], pln = p(L,n) - mpz_ui_pow_ui(z,2,pln) - integer digits = mpz_sizeinbase(z,10) - string st = iff(digits>2e6?sprintf("%,d digits",digits): - shorten(mpz_get_str(z),"digits",5)) - printf(1,"The %d%s power of 2 that starts with %d is %d [i.e. %s]\n",{n,ord(n),L,pln,st}) -end for -?elapsed(time()-t0) + constant tests = {{12, 1}, {12, 2}, {123, 45}, {123, 12345}, {123, 678910}} + include ordinal.e + include mpfr.e + mpz z = mpz_init() + atom t0 = time() + for i=1 to length(tests)-(2*(platform()=JS)) do + integer {L,n} = tests[i], pln = p(L,n) + mpz_ui_pow_ui(z,2,pln) + integer digits = mpz_sizeinbase(z,10) + string st = iff(digits>2e6?sprintf("%,d digits",digits): + shorten(mpz_get_str(z),"digits",5)) + printf(1,"The %d%s power of 2 that starts with %d is %d [i.e. %s]\n",{n,ord(n),L,pln,st}) + end for + ?elapsed(time()-t0) + + with javascript_semantics + sequence m31 = {"January",0,"March",0,"May",0,"July","August",0,"October",0,"December"} + integer y,m, + nmonths = 0 + string months + sequence res = {}, + none = {} -for y=1900 to 2100 do - months = "" - for m=1 to 12 do - if string(m31[m]) - and day_of_week(y,m,1,true)="Friday" then - if length(months)!=0 then months &= ", " end if - months &= m31[m] - nmonths += 1 - end if - end for - if length(months)=0 then - none = append(none,y) - else - res = append(res,sprintf("%d : %s\n",{y,months})) - end if -end for + for y=1900 to 2100 do + months = "" + for m=1 to 12 do + if string(m31[m]) + and day_of_week(y,m,1,true)="Friday" then + if length(months)!=0 then months &= ", " end if + months &= m31[m] + nmonths += 1 + end if + end for + if length(months)=0 then + none = append(none,y) + else + res = append(res,sprintf("%d : %s\n",{y,months})) + end if + end for -printf(1,"Found %d months with five full weekends\n",nmonths) -res[6..-6] = {" ...\n"} -puts(1,join(res,"")) -printf(1,"Found %d years with no month having 5 weekends:\n",{length(none)}) -none[6..-6] = {".."} -?none + printf(1,"Found %d months with five full weekends\n",nmonths) + res[6..-6] = {" ...\n"} + puts(1,join(res,"")) + printf(1,"Found %d years with no month having 5 weekends:\n",{length(none)}) + none[6..-6] = {".."} + ?none + ) + + say 'First 100 turns in the game of fizzbuzz:' cr cr + 100 fizzbuzz cr diff --git a/Task/FizzBuzz/Rebol/fizzbuzz-1.rebol b/Task/FizzBuzz/REBOL/fizzbuzz-1.rebol similarity index 98% rename from Task/FizzBuzz/Rebol/fizzbuzz-1.rebol rename to Task/FizzBuzz/REBOL/fizzbuzz-1.rebol index f238ac6bdc..8d859d274d 100644 --- a/Task/FizzBuzz/Rebol/fizzbuzz-1.rebol +++ b/Task/FizzBuzz/REBOL/fizzbuzz-1.rebol @@ -1,4 +1,4 @@ -Rebol [ +REBOL [ Title: "FizzBuzz" URL: http://rosettacode.org/wiki/FizzBuzz ] diff --git a/Task/FizzBuzz/Rebol/fizzbuzz-2.rebol b/Task/FizzBuzz/REBOL/fizzbuzz-2.rebol similarity index 100% rename from Task/FizzBuzz/Rebol/fizzbuzz-2.rebol rename to Task/FizzBuzz/REBOL/fizzbuzz-2.rebol diff --git a/Task/FizzBuzz/Rebol/fizzbuzz-3.rebol b/Task/FizzBuzz/REBOL/fizzbuzz-3.rebol similarity index 100% rename from Task/FizzBuzz/Rebol/fizzbuzz-3.rebol rename to Task/FizzBuzz/REBOL/fizzbuzz-3.rebol diff --git a/Task/FizzBuzz/Rebol/fizzbuzz-4.rebol b/Task/FizzBuzz/REBOL/fizzbuzz-4.rebol similarity index 100% rename from Task/FizzBuzz/Rebol/fizzbuzz-4.rebol rename to Task/FizzBuzz/REBOL/fizzbuzz-4.rebol diff --git a/Task/FizzBuzz/RISC-V-Assembly/fizzbuzz.asm b/Task/FizzBuzz/RISC-V-Assembly/fizzbuzz.asm deleted file mode 100644 index aa467e0000..0000000000 --- a/Task/FizzBuzz/RISC-V-Assembly/fizzbuzz.asm +++ /dev/null @@ -1,97 +0,0 @@ -# riscv assembly raspberry pico2 rp2350 -# program fizzbuzz.s -# connexion putty com3 -/*********************************************/ -/* CONSTANTES */ -/********************************************/ -/* for this file see risc-v task include a file */ -.include "../../../constantesRiscv.inc" -/****************************************************/ -/* MACROS */ -/****************************************************/ -#.include "../ficmacrosriscv.inc" # only for debugging -/*******************************************/ -/* INITIALED DATAS */ -/*******************************************/ -.data -szMessStart: .asciz "Program riscv start.\r\n" -szMessEndOk: .asciz "Program riscv end OK.\r\n" -szCariageReturn: .asciz "\r\n" -szMessFizz: .asciz " Fizz\n" -szMessBuzz: .asciz " Buzz\n" -szMessFizzBuzz: .asciz " FizzBuzz\n" - - -.align 2 -/*******************************************/ -/* UNINITIALED DATA */ -/*******************************************/ -.bss -sConvArea: .skip 24 - -.align 2 -/**********************************************/ -/* SECTION CODE */ -/**********************************************/ -.text -.global main - -main: - call stdio_init_all # général init -1: # start loop connexion - li a0,0 # raz argument register - call tud_cdc_n_connected # waiting for USB connection - beqz a0,1b # return code = zero ? yes -> loop - - la a0,szMessStart # message address - call writeString # display message - - li s0,0 # loop indice - li s1,3 # divisor 3 - li s2,5 # divisor 5 - li s3,15 # divisor 15 - li s4,100 -1: - remu t0,s0,s3 # / by 15 - bnez t0,2f - la s5,szMessFizzBuzz - j 4f -2: - remu t0,s0,s2 # / by 5 - bnez t0,3f - la s5,szMessBuzz - j 4f -3: - remu t0,s0,s1 # / by 3 - bnez t0,5f - la s5,szMessFizz - j 4f - -4: - mv a0,s0 - la a1,sConvArea - call conversion10 # conversion decimal - - la a0,sConvArea - call writeString - #la a0,szCariageReturn - #call writeString - mv a0,s5 - call writeString # display message -5: - addi s0,s0,1 - ble s0,s4,1b - - - - la a0,szMessEndOk # message address - call writeString # display message - call getchar -100: # final loop - j 100b - -/************************************/ -/* file include Fonctions */ -/***********************************/ -/* for this file see risc-v task include a file */ -.include "../../../includeFunctions.s" diff --git a/Task/FizzBuzz/Refal/fizzbuzz.refal b/Task/FizzBuzz/Refal/fizzbuzz.refal deleted file mode 100644 index 4dc835261a..0000000000 --- a/Task/FizzBuzz/Refal/fizzbuzz.refal +++ /dev/null @@ -1,16 +0,0 @@ -$ENTRY Go { - = ; -}; - -FizzBuzz { - 101 = ; - s.N = > - >; -}; - -Item { - s.N, : 0 = FizzBuzz; - s.N, : 0 = Buzz; - s.N, : 0 = Fizz; - s.N = s.N; -}; diff --git a/Task/FizzBuzz/Retro/fizzbuzz-1.retro b/Task/FizzBuzz/Retro/fizzbuzz-1.retro new file mode 100644 index 0000000000..beb6d646a4 --- /dev/null +++ b/Task/FizzBuzz/Retro/fizzbuzz-1.retro @@ -0,0 +1,8 @@ +: fizz? ( s-f ) 3 mod 0 = ; +: buzz? ( s-f ) 5 mod 0 = ; +: num? ( s-f ) dup fizz? swap buzz? or 0 = ; +: ?fizz ( s- ) fizz? [ "Fizz" puts ] ifTrue ; +: ?buzz ( s- ) buzz? [ "Buzz" puts ] ifTrue ; +: ?num ( s- ) num? &putn &drop if ; +: fizzbuzz ( s- ) dup ?fizz dup ?buzz dup ?num space ; +: all ( - ) 100 [ 1+ fizzbuzz ] iter ; diff --git a/Task/FizzBuzz/Retro/fizzbuzz-2.retro b/Task/FizzBuzz/Retro/fizzbuzz-2.retro new file mode 100644 index 0000000000..5912fde82c --- /dev/null +++ b/Task/FizzBuzz/Retro/fizzbuzz-2.retro @@ -0,0 +1,6 @@ +needs math' +: + [ 15 ^math'divisor? ] [ drop "FizzBuzz" puts ] when + [ 3 ^math'divisor? ] [ drop "Fizz" puts ] when + [ 5 ^math'divisor? ] [ drop "Buzz" puts ] when putn ; +: fizzbuzz cr 100 [ 1+ space ] iter ; diff --git a/Task/FizzBuzz/Retro/fizzbuzz.retro b/Task/FizzBuzz/Retro/fizzbuzz.retro deleted file mode 100644 index 0d0a9928be..0000000000 --- a/Task/FizzBuzz/Retro/fizzbuzz.retro +++ /dev/null @@ -1,26 +0,0 @@ -( empty string result to display result ) -~~~ - -'result var -' s:format !result - -'number var -#1 !number - -~~~ -( checks for empty string if result empty print number ) -( else append fizz for divisible by 3 and prepend buzz for divisible by 5) -( if; exists the word fizzbuzz immediately ) -~~~ - -:fizzbuzz (-) - @number #3 mod #0 eq? [ 'fizz @result s:append !result ] if - @number #5 mod #0 eq? [ 'buzz @result s:prepend !result ] if - ' @result s:eq? [ @number n:put nl ] if; - ' @result s:eq? not [ @result s:put nl ] if; - ; - -[ fizzbuzz 'result var - ' s:format !result @number #1 + !number @number #100 lteq? ] while - -~~~ diff --git a/Task/FizzBuzz/Rhombus/fizzbuzz.rhombus b/Task/FizzBuzz/Rhombus/fizzbuzz.rhombus deleted file mode 100644 index 83d4121639..0000000000 --- a/Task/FizzBuzz/Rhombus/fizzbuzz.rhombus +++ /dev/null @@ -1,8 +0,0 @@ -#lang rhombus/static - -for (i in 1..=100): - match math.gcd(i, 15) - | 15: println("fizzbuzz") - | 3: println("fizz") - | 5: println("buzz") - | _: println(i) diff --git a/Task/FizzBuzz/Rust/fizzbuzz-1.rs b/Task/FizzBuzz/Rust/fizzbuzz-1.rust similarity index 100% rename from Task/FizzBuzz/Rust/fizzbuzz-1.rs rename to Task/FizzBuzz/Rust/fizzbuzz-1.rust diff --git a/Task/FizzBuzz/Rust/fizzbuzz-2.rs b/Task/FizzBuzz/Rust/fizzbuzz-2.rust similarity index 100% rename from Task/FizzBuzz/Rust/fizzbuzz-2.rs rename to Task/FizzBuzz/Rust/fizzbuzz-2.rust diff --git a/Task/FizzBuzz/Rust/fizzbuzz-3.rs b/Task/FizzBuzz/Rust/fizzbuzz-3.rust similarity index 100% rename from Task/FizzBuzz/Rust/fizzbuzz-3.rs rename to Task/FizzBuzz/Rust/fizzbuzz-3.rust diff --git a/Task/FizzBuzz/Rust/fizzbuzz-4.rs b/Task/FizzBuzz/Rust/fizzbuzz-4.rust similarity index 100% rename from Task/FizzBuzz/Rust/fizzbuzz-4.rs rename to Task/FizzBuzz/Rust/fizzbuzz-4.rust diff --git a/Task/FizzBuzz/SETL/fizzbuzz.setl b/Task/FizzBuzz/SETL/fizzbuzz.setl deleted file mode 100644 index 58b8c0d94c..0000000000 --- a/Task/FizzBuzz/SETL/fizzbuzz.setl +++ /dev/null @@ -1,10 +0,0 @@ -program fizzbuzz; - loop for n in [1..100] do - print(fizzbuzz(n)); - end loop; - - proc fizzbuzz(n); - divs := [[3, "Fizz"], [5, "Buzz"]]; - return +/[w : [d,w] in divs | n mod d=0] ? str n; - end proc; -end program; diff --git a/Task/FizzBuzz/Scheme/fizzbuzz-1.scm b/Task/FizzBuzz/Scheme/fizzbuzz-1.ss similarity index 100% rename from Task/FizzBuzz/Scheme/fizzbuzz-1.scm rename to Task/FizzBuzz/Scheme/fizzbuzz-1.ss diff --git a/Task/FizzBuzz/Scheme/fizzbuzz-2.scm b/Task/FizzBuzz/Scheme/fizzbuzz-2.ss similarity index 100% rename from Task/FizzBuzz/Scheme/fizzbuzz-2.scm rename to Task/FizzBuzz/Scheme/fizzbuzz-2.ss diff --git a/Task/FizzBuzz/Scheme/fizzbuzz-3.scm b/Task/FizzBuzz/Scheme/fizzbuzz-3.ss similarity index 100% rename from Task/FizzBuzz/Scheme/fizzbuzz-3.scm rename to Task/FizzBuzz/Scheme/fizzbuzz-3.ss diff --git a/Task/FizzBuzz/SheerPower-4GL/fizzbuzz.4gl b/Task/FizzBuzz/SheerPower-4GL/fizzbuzz.4gl deleted file mode 100644 index 60a89eb1cb..0000000000 --- a/Task/FizzBuzz/SheerPower-4GL/fizzbuzz.4gl +++ /dev/null @@ -1,13 +0,0 @@ -declare integer i% - -for i% = 1 to 100 - if i% mod 15 = 0 then - print 'FizzBuzz' - elseif i% mod 3 = 0 then - print 'Fizz' - elseif i% mod 5 = 0 then - print 'Buzz' - else - print i% - end if -next i% diff --git a/Task/FizzBuzz/Sidef/fizzbuzz-1.sidef b/Task/FizzBuzz/Sidef/fizzbuzz-1.sidef index 6c866bf35c..e604d6c84d 100644 --- a/Task/FizzBuzz/Sidef/fizzbuzz-1.sidef +++ b/Task/FizzBuzz/Sidef/fizzbuzz-1.sidef @@ -6,4 +6,4 @@ } elsif (i %% 5) { say "Buzz" } else { say i } -} << 1..100 +} * 100 diff --git a/Task/FizzBuzz/Sidef/fizzbuzz-3.sidef b/Task/FizzBuzz/Sidef/fizzbuzz-3.sidef index 40a0a4819a..e106d952ba 100644 --- a/Task/FizzBuzz/Sidef/fizzbuzz-3.sidef +++ b/Task/FizzBuzz/Sidef/fizzbuzz-3.sidef @@ -1 +1 @@ -{>"#{[.%3]}#{[.%5]}"||_}<<1..100 +{|i|say "#{[i%3]}#{[i%5]}"||i}*100 diff --git a/Task/FizzBuzz/Smalltalk/fizzbuzz-4.st b/Task/FizzBuzz/Smalltalk/fizzbuzz-4.st index 67f72c15dd..12bbef1dcd 100644 --- a/Task/FizzBuzz/Smalltalk/fizzbuzz-4.st +++ b/Task/FizzBuzz/Smalltalk/fizzbuzz-4.st @@ -1,12 +1,10 @@ -0 to: 100 do: [ :i | - (i \\ 3 = 0 and: [ i \\ 5 = 0 ]) - ifTrue: [ Transcript show: 'FizzBuzz'; cr. ] - ifFalse: [ - (i \\ 3 = 0) - ifTrue: [ Transcript show: 'Fizz'; cr. ]. - (i \\ 5 = 0) - ifTrue: [ Transcript show: 'Buzz'; cr. ]. - ((i \\ 3 ~= 0) and: [ i \\ 5 ~= 0 ]) - ifTrue: [ Transcript show: i printString; cr. ]. - ]. -]. +1 to: 100 do: [:n | |r| + r := n rem: 15. + Transcript show: (r isZero + ifTrue:['fizzbuzz'] + ifFalse: [(#(3 6 9 12) includes: r) + ifTrue:['fizz'] + ifFalse:[((#(5 10) includes: r)) + ifTrue:['buzz'] + ifFalse:[n]]]); + cr]. diff --git a/Task/FizzBuzz/Smalltalk/fizzbuzz-5.st b/Task/FizzBuzz/Smalltalk/fizzbuzz-5.st index 12bbef1dcd..83e4ca616e 100644 --- a/Task/FizzBuzz/Smalltalk/fizzbuzz-5.st +++ b/Task/FizzBuzz/Smalltalk/fizzbuzz-5.st @@ -1,10 +1,5 @@ -1 to: 100 do: [:n | |r| - r := n rem: 15. - Transcript show: (r isZero - ifTrue:['fizzbuzz'] - ifFalse: [(#(3 6 9 12) includes: r) - ifTrue:['fizz'] - ifFalse:[((#(5 10) includes: r)) - ifTrue:['buzz'] - ifFalse:[n]]]); - cr]. +fbz := (1 to: 100) asOrderedCollection. + 3 to: 100 by: 3 do: [:i | fbz at: i put: 'Fizz']. + 5 to: 100 by: 5 do: [:i | fbz at: i put: 'Buzz']. +15 to: 100 by: 15 do: [:i | fbz at: i put: 'FizzBuzz']. +fbz do: [:i | Transcript show: i; cr]. diff --git a/Task/FizzBuzz/Smalltalk/fizzbuzz-6.st b/Task/FizzBuzz/Smalltalk/fizzbuzz-6.st index 83e4ca616e..a0c292e114 100644 --- a/Task/FizzBuzz/Smalltalk/fizzbuzz-6.st +++ b/Task/FizzBuzz/Smalltalk/fizzbuzz-6.st @@ -1,5 +1,5 @@ -fbz := (1 to: 100) asOrderedCollection. - 3 to: 100 by: 3 do: [:i | fbz at: i put: 'Fizz']. - 5 to: 100 by: 5 do: [:i | fbz at: i put: 'Buzz']. -15 to: 100 by: 15 do: [:i | fbz at: i put: 'FizzBuzz']. -fbz do: [:i | Transcript show: i; cr]. +1 to: 100 do: [:i | |fb s| + fb := {i isDivisibleBy: 3. i isDivisibleBy: 5. nil}. + fb at: 3 put: (fb first | fb second) not. + s := '<1?Fizz:><2?Buzz:><3?{1}:>' format: {i printString}. + Transcript show: (s expandMacrosWithArguments: fb); cr]. diff --git a/Task/FizzBuzz/Smalltalk/fizzbuzz-7.st b/Task/FizzBuzz/Smalltalk/fizzbuzz-7.st deleted file mode 100644 index a0c292e114..0000000000 --- a/Task/FizzBuzz/Smalltalk/fizzbuzz-7.st +++ /dev/null @@ -1,5 +0,0 @@ -1 to: 100 do: [:i | |fb s| - fb := {i isDivisibleBy: 3. i isDivisibleBy: 5. nil}. - fb at: 3 put: (fb first | fb second) not. - s := '<1?Fizz:><2?Buzz:><3?{1}:>' format: {i printString}. - Transcript show: (s expandMacrosWithArguments: fb); cr]. diff --git a/Task/FizzBuzz/Swift/fizzbuzz-3.swift b/Task/FizzBuzz/Swift/fizzbuzz-3.swift deleted file mode 100644 index d337cf2b97..0000000000 --- a/Task/FizzBuzz/Swift/fizzbuzz-3.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Foundation - -let formats: [String] = [ - "%d", - "%d", - "fizz", - "%d", - "buzz", - "fizz", - "%d", - "%d", - "fizz", - "buzz", - "%d", - "fizz", - "%d", - "%d", - "fizzbuzz", -] - -var count = 0 -var index = 0 -while count < 100 { - count += 1 - print(String(format: formats[index], count)) - index += 1 - index %= 15 -} diff --git a/Task/FizzBuzz/Tailspin/fizzbuzz-2.tailspin b/Task/FizzBuzz/Tailspin/fizzbuzz-2.tailspin deleted file mode 100644 index e808c59d20..0000000000 --- a/Task/FizzBuzz/Tailspin/fizzbuzz-2.tailspin +++ /dev/null @@ -1,15 +0,0 @@ -fizz templates - $ mod 3 -> # ! - when <|=0> do 'Fizz' ! -end fizz - -buzz templates - $ mod 5 -> # ! - when <|=0> do 'Buzz' ! -end buzz - -[ 1..100 -> '$->fizz;$->buzz;' ] -> $(.. as i; -> templates - when <|=''> do $i ! - otherwise $ ! -end)... -> '$; -' ! diff --git a/Task/FizzBuzz/Tailspin/fizzbuzz-1.tailspin b/Task/FizzBuzz/Tailspin/fizzbuzz.tailspin similarity index 100% rename from Task/FizzBuzz/Tailspin/fizzbuzz-1.tailspin rename to Task/FizzBuzz/Tailspin/fizzbuzz.tailspin diff --git a/Task/FizzBuzz/Uiua/fizzbuzz.uiua b/Task/FizzBuzz/Uiua/fizzbuzz.uiua deleted file mode 100644 index e6e42eafc6..0000000000 --- a/Task/FizzBuzz/Uiua/fizzbuzz.uiua +++ /dev/null @@ -1 +0,0 @@ -⨬(&p|&p"Fizz"|&p"Buzz"|&p"Fizzbuzz")°⋯⍉=0⊸⊞◿3_5+1⇡100 diff --git a/Task/FizzBuzz/Ursalang/fizzbuzz.ursa b/Task/FizzBuzz/Ursalang/fizzbuzz.ursa deleted file mode 100644 index 5dab217017..0000000000 --- a/Task/FizzBuzz/Ursalang/fizzbuzz.ursa +++ /dev/null @@ -1,9 +0,0 @@ -let write = process.stdout.write - -for i in range(100) { - let n = i + 1 - if (n % 3 == 0) {write("Fizz")} - if (n % 5 == 0) {write("Buzz")} - if (n % 3 != 0 and n % 5 != 0) {write(n.toString())} - write("\n") -} diff --git a/Task/FizzBuzz/VBScript/fizzbuzz-1.vbs b/Task/FizzBuzz/VBScript/fizzbuzz-1.vb similarity index 100% rename from Task/FizzBuzz/VBScript/fizzbuzz-1.vbs rename to Task/FizzBuzz/VBScript/fizzbuzz-1.vb diff --git a/Task/FizzBuzz/VBScript/fizzbuzz-2.vbs b/Task/FizzBuzz/VBScript/fizzbuzz-2.vb similarity index 100% rename from Task/FizzBuzz/VBScript/fizzbuzz-2.vbs rename to Task/FizzBuzz/VBScript/fizzbuzz-2.vb diff --git a/Task/FizzBuzz/VHDL/fizzbuzz.vhd b/Task/FizzBuzz/VHDL/fizzbuzz.vhdl similarity index 100% rename from Task/FizzBuzz/VHDL/fizzbuzz.vhd rename to Task/FizzBuzz/VHDL/fizzbuzz.vhdl diff --git a/Task/FizzBuzz/Vyxal/fizzbuzz.vyxal b/Task/FizzBuzz/Vyxal/fizzbuzz.vyxal deleted file mode 100644 index fe070a4b3c..0000000000 --- a/Task/FizzBuzz/Vyxal/fizzbuzz.vyxal +++ /dev/null @@ -1 +0,0 @@ -₁⟑₍₃₅kF½*∑∴, diff --git a/Task/FizzBuzz/YAMLScript/fizzbuzz-1.ys b/Task/FizzBuzz/YAMLScript/fizzbuzz-1.ys new file mode 100644 index 0000000000..0a0d3109b8 --- /dev/null +++ b/Task/FizzBuzz/YAMLScript/fizzbuzz-1.ys @@ -0,0 +1,9 @@ +map: +- (x): + - println: + - cond: [ + zero?(mod(x 15)), "FizzBuzz", + zero?(mod(x 5)), "Buzz", + zero?(mod(x 3)), "Fizz", + :else, x ] +- range(1, 101) diff --git a/Task/FizzBuzz/YAMLScript/fizzbuzz-2.ys b/Task/FizzBuzz/YAMLScript/fizzbuzz-2.ys new file mode 100644 index 0000000000..ca1788d8bf --- /dev/null +++ b/Task/FizzBuzz/YAMLScript/fizzbuzz-2.ys @@ -0,0 +1,9 @@ +loop [i 1]: +- println: + cond( + zero?(mod(i 15)) "FizzBuzz" + zero?(mod(i 5)) "Buzz" + zero?(mod(i 3)) "Fizz" + :else i) +- if (i < 100): + recur: inc(i) diff --git a/Task/FizzBuzz/YAMLScript/fizzbuzz-3.ys b/Task/FizzBuzz/YAMLScript/fizzbuzz-3.ys new file mode 100644 index 0000000000..d8a2fd9bf7 --- /dev/null +++ b/Task/FizzBuzz/YAMLScript/fizzbuzz-3.ys @@ -0,0 +1,9 @@ +map: +- (x): + - s =: + str: + - if (zero? mod(x 3)): "Fizz" + - if (zero? mod(x 5)): "Buzz" + - println: + if (empty? s): [x, s] +- range(1 101) diff --git a/Task/FizzBuzz/YAMLScript/fizzbuzz.ys b/Task/FizzBuzz/YAMLScript/fizzbuzz.ys deleted file mode 100644 index 1021f2a5f0..0000000000 --- a/Task/FizzBuzz/YAMLScript/fizzbuzz.ys +++ /dev/null @@ -1,7 +0,0 @@ -!YS-v0 - -defn main(n=100): - each x (1 .. n): !:say - or? _ x: - str ((x % 3).! &&& 'Fizz'): - ((x % 5).! &&& 'Buzz') diff --git a/Task/FizzBuzz/Zig/fizzbuzz.zig b/Task/FizzBuzz/Zig/fizzbuzz.zig index d69633205d..6630d76864 100644 --- a/Task/FizzBuzz/Zig/fizzbuzz.zig +++ b/Task/FizzBuzz/Zig/fizzbuzz.zig @@ -1,7 +1,7 @@ const print = @import("std").debug.print; pub fn main() void { - - for(1..101) |i| { + var i: usize = 1; + while (i <= 100) : (i += 1) { if (i % 3 == 0 and i % 5 == 0) { print("FizzBuzz\n", .{}); } else if (i % 3 == 0) { diff --git a/Task/Flatten-a-list/ALGOL-68/flatten-a-list-2.alg b/Task/Flatten-a-list/ALGOL-68/flatten-a-list-2.alg deleted file mode 100644 index b7302a8c5c..0000000000 --- a/Task/Flatten-a-list/ALGOL-68/flatten-a-list-2.alg +++ /dev/null @@ -1,31 +0,0 @@ -[][][][][][][][][]INT list1 = ((1), 2, ((3,4), 5), ((())), (((6))), 7, 8, () ); -FILE str file; -STRING str list; - -# write the list to a string # -associate( str file, str list ); -put( str file, ( list1 ) ); -close( str file ); - -# count the number of elements # -INT element count := 0; -associate( str file, str list ); -BOOL at end := FALSE; -on logical file end( str file, ( REF FILE f )BOOL: at end := TRUE ); -WHILE INT value := 0; - get( str file, value ); - NOT at end -DO - element count +:= 1 -OD; - -# read the elements into a "flattened list" # -[ 1 : element count ]INT values; -rewind( str file ); -at end := FALSE; -get( str file, ( values ) ); -close( str file ); - -# show the elements # -FOR i FROM LWB values TO UPB values DO print( ( " ", whole( values[ i ], 0 ) ) ) OD; -print( ( newline ) ) diff --git a/Task/Flatten-a-list/ALGOL-68/flatten-a-list-1.alg b/Task/Flatten-a-list/ALGOL-68/flatten-a-list.alg similarity index 100% rename from Task/Flatten-a-list/ALGOL-68/flatten-a-list-1.alg rename to Task/Flatten-a-list/ALGOL-68/flatten-a-list.alg diff --git a/Task/Flatten-a-list/Ada/flatten-a-list-1.adb b/Task/Flatten-a-list/Ada/flatten-a-list-1.ada similarity index 100% rename from Task/Flatten-a-list/Ada/flatten-a-list-1.adb rename to Task/Flatten-a-list/Ada/flatten-a-list-1.ada diff --git a/Task/Flatten-a-list/Ada/flatten-a-list-2.adb b/Task/Flatten-a-list/Ada/flatten-a-list-2.ada similarity index 100% rename from Task/Flatten-a-list/Ada/flatten-a-list-2.adb rename to Task/Flatten-a-list/Ada/flatten-a-list-2.ada diff --git a/Task/Flatten-a-list/Ada/flatten-a-list-3.adb b/Task/Flatten-a-list/Ada/flatten-a-list-3.ada similarity index 100% rename from Task/Flatten-a-list/Ada/flatten-a-list-3.adb rename to Task/Flatten-a-list/Ada/flatten-a-list-3.ada diff --git a/Task/Flatten-a-list/ArkScript/flatten-a-list.ark b/Task/Flatten-a-list/ArkScript/flatten-a-list.ark deleted file mode 100644 index 8d2eacae04..0000000000 --- a/Task/Flatten-a-list/ArkScript/flatten-a-list.ark +++ /dev/null @@ -1,13 +0,0 @@ -(import std.List :flatten :map) - -(let data [[1] 2 [[3 4] 5] [[[]]] [[[6]]] 7 8 []]) - -(let process (fun (lst) - (flatten - (map - lst - (fun (sub) - (if (= "List" (type sub)) - (process sub) - sub)))))) -(assert (= (process data) [1 2 3 4 5 6 7 8]) "list is flat") diff --git a/Task/Flatten-a-list/Batch-File/flatten-a-list.bat b/Task/Flatten-a-list/Batch-File/flatten-a-list.bat deleted file mode 100644 index ab535cc312..0000000000 --- a/Task/Flatten-a-list/Batch-File/flatten-a-list.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -setlocal -set /p list=||goto :eof -set "list=%list:[=%" -set "list=%list:]=%" -set newlist= -setlocal enabledelayedexpansion -for %%i in (%list%) do set "newlist=!newlist!, %%i" -echo:[%newlist:~2%] diff --git a/Task/Flatten-a-list/Crystal/flatten-a-list-1.cr b/Task/Flatten-a-list/Crystal/flatten-a-list-1.crystal similarity index 100% rename from Task/Flatten-a-list/Crystal/flatten-a-list-1.cr rename to Task/Flatten-a-list/Crystal/flatten-a-list-1.crystal diff --git a/Task/Flatten-a-list/Crystal/flatten-a-list-2.cr b/Task/Flatten-a-list/Crystal/flatten-a-list-2.crystal similarity index 100% rename from Task/Flatten-a-list/Crystal/flatten-a-list-2.cr rename to Task/Flatten-a-list/Crystal/flatten-a-list-2.crystal diff --git a/Task/Flatten-a-list/DuckDB/flatten-a-list.duckdb b/Task/Flatten-a-list/DuckDB/flatten-a-list.duckdb deleted file mode 100644 index 3c58b714cc..0000000000 --- a/Task/Flatten-a-list/DuckDB/flatten-a-list.duckdb +++ /dev/null @@ -1,9 +0,0 @@ -create or replace function flatten_tuple(tuple) as ( - with cte as - (select unnest( tuple, recursive:=true)), - rows as - (select list_transform( json_keys(j), k -> (j->>k)) as row_values - from (select cte::json j from cte) - limit 1) - select list_filter( (from rows), x -> x is not NULL) -); diff --git a/Task/Flatten-a-list/Elixir/flatten-a-list.ex b/Task/Flatten-a-list/Elixir/flatten-a-list.elixir similarity index 100% rename from Task/Flatten-a-list/Elixir/flatten-a-list.ex rename to Task/Flatten-a-list/Elixir/flatten-a-list.elixir diff --git a/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.el b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.el deleted file mode 100644 index 939c2dd810..0000000000 --- a/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.el +++ /dev/null @@ -1 +0,0 @@ -(flatten-tree mylist) diff --git a/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-1.el b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l similarity index 100% rename from Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-1.el rename to Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l diff --git a/Task/Flatten-a-list/Euphoria/flatten-a-list.eu b/Task/Flatten-a-list/Euphoria/flatten-a-list.euphoria similarity index 100% rename from Task/Flatten-a-list/Euphoria/flatten-a-list.eu rename to Task/Flatten-a-list/Euphoria/flatten-a-list.euphoria diff --git a/Task/Flatten-a-list/Insitux/flatten-a-list.insitux b/Task/Flatten-a-list/Insitux/flatten-a-list.insitux deleted file mode 100644 index 22daea6822..0000000000 --- a/Task/Flatten-a-list/Insitux/flatten-a-list.insitux +++ /dev/null @@ -1 +0,0 @@ -(flatten [[1] 2 [[3 4] 5] [[[]]] [[[6]]] 7 8 []]) diff --git a/Task/Flatten-a-list/Julia/flatten-a-list-1.jl b/Task/Flatten-a-list/Julia/flatten-a-list-1.julia similarity index 100% rename from Task/Flatten-a-list/Julia/flatten-a-list-1.jl rename to Task/Flatten-a-list/Julia/flatten-a-list-1.julia diff --git a/Task/Flatten-a-list/Julia/flatten-a-list-2.jl b/Task/Flatten-a-list/Julia/flatten-a-list-2.julia similarity index 100% rename from Task/Flatten-a-list/Julia/flatten-a-list-2.jl rename to Task/Flatten-a-list/Julia/flatten-a-list-2.julia diff --git a/Task/Flatten-a-list/Julia/flatten-a-list-3.jl b/Task/Flatten-a-list/Julia/flatten-a-list-3.julia similarity index 100% rename from Task/Flatten-a-list/Julia/flatten-a-list-3.jl rename to Task/Flatten-a-list/Julia/flatten-a-list-3.julia diff --git a/Task/Flatten-a-list/Julia/flatten-a-list-4.jl b/Task/Flatten-a-list/Julia/flatten-a-list-4.julia similarity index 100% rename from Task/Flatten-a-list/Julia/flatten-a-list-4.jl rename to Task/Flatten-a-list/Julia/flatten-a-list-4.julia diff --git a/Task/Flatten-a-list/Kotlin/flatten-a-list-1.kts b/Task/Flatten-a-list/Kotlin/flatten-a-list-1.kotlin similarity index 100% rename from Task/Flatten-a-list/Kotlin/flatten-a-list-1.kts rename to Task/Flatten-a-list/Kotlin/flatten-a-list-1.kotlin diff --git a/Task/Flatten-a-list/Kotlin/flatten-a-list-2.kts b/Task/Flatten-a-list/Kotlin/flatten-a-list-2.kotlin similarity index 100% rename from Task/Flatten-a-list/Kotlin/flatten-a-list-2.kts rename to Task/Flatten-a-list/Kotlin/flatten-a-list-2.kotlin diff --git a/Task/Flatten-a-list/OCaml/flatten-a-list-1.ml b/Task/Flatten-a-list/OCaml/flatten-a-list-1.ocaml similarity index 100% rename from Task/Flatten-a-list/OCaml/flatten-a-list-1.ml rename to Task/Flatten-a-list/OCaml/flatten-a-list-1.ocaml diff --git a/Task/Flatten-a-list/OCaml/flatten-a-list-2.ml b/Task/Flatten-a-list/OCaml/flatten-a-list-2.ocaml similarity index 100% rename from Task/Flatten-a-list/OCaml/flatten-a-list-2.ml rename to Task/Flatten-a-list/OCaml/flatten-a-list-2.ocaml diff --git a/Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas b/Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas deleted file mode 100644 index 4c3aff9618..0000000000 --- a/Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas +++ /dev/null @@ -1,16 +0,0 @@ -function Flatten(lst: List): List; -begin - Result := new List; - foreach var x in lst do - if x is List then - Result.Addrange(Flatten(x as List)) - else Result.Add(x) -end; - -function LstObj(params a: array of object): List := new List(a); - -begin - var lst := LstObj(1,LstObj(2, LstObj(3,4), LstObj(5,6)), LstObj(LstObj(7,8), 9)); - Println(lst); - Println(Flatten(lst)); -end. diff --git a/Task/Flatten-a-list/Phix/flatten-a-list.phix b/Task/Flatten-a-list/Phix/flatten-a-list.phix index 21e957b698..d3a391ec4f 100644 --- a/Task/Flatten-a-list/Phix/flatten-a-list.phix +++ b/Task/Flatten-a-list/Phix/flatten-a-list.phix @@ -1,3 +1 @@ -(phixonline)(not pygments)--> - ?flatten({{1},2,{{3,4},5},{{{}}},{{{6}}},7,8,{}}) - [ ) - - [ [] swap witheach [ not join ] ] is invert ( [ --> [ ) - - [ 2dup peek invert unrot poke ] is fliprow ( [ n --> [ ) - - [ dip transpose fliprow transpose ] is flipcolumn ( [ n --> [ ) - - [ dup - [ dup size dup * times - [ dup size random - 2 random iff - fliprow - else flipcolumn ] - 2dup != until ] - nip ] is mix ( [ --> [ ) - - [ say " " - dup size times - [ sp i^ char a + emit ] - witheach - [ cr sp i^ echo say ":" - witheach - [ sp echo ] ] ] is display ( [ --> ) - - [ cr $ "a..., or 0...: " - input $ "." join - trim 0 peek lower - 2dup char a rot over + - within iff - [ nip char a - - ' flipcolumn ] - done - 2dup char 0 rot over + - within iff - [ nip char 0 - - ' fliprow ] - done - drop again ] is getmove ( n --> n x ) - - [ 0 temp put - makeboard - dup mix - [ say "Moves: " - temp share echo cr - 1 temp tally - 2dup swap - say "Target" cr - display cr cr - say "Current" cr - display cr - dup size getmove do cr - 2dup = until ] - 2drop - temp take - say "Moves taken: " echo ] is flipbits ( n --> ) diff --git a/Task/Flipping-bits-game/R/flipping-bits-game.r b/Task/Flipping-bits-game/R/flipping-bits-game.r deleted file mode 100644 index bedaae8f59..0000000000 --- a/Task/Flipping-bits-game/R/flipping-bits-game.r +++ /dev/null @@ -1,59 +0,0 @@ -gen_board <- function(n) matrix(data=sample(c(0,1), n^2, replace=TRUE), - nrow=n, - ncol=n, - dimnames=list(1:n, letters[1:n])) - -fliprow <- function(mat, n){ - mat[n,] <- !mat[n,] - return(mat) -} - -flipcol <- function(mat, n){ - mat[,n] <- !mat[,n] - return(mat) -} - -bits_game <- function(){ - n <- as.numeric(readline(prompt="Input board size: ")) - board_final <- gen_board(n) - repeat{ - #Generate a list of between 10 and 15 random moves - num_moves <- sample(10:15, 1) - flip_args <- sample(1:n, num_moves, replace=TRUE) - flip_fns <- sample(list(fliprow, flipcol), num_moves, replace=TRUE) - gen_move <- function(k){ - function(mat) flip_fns[[k]](mat, flip_args[k]) - } - rand_moves <- sapply(1:num_moves, gen_move) - #Now apply them to the final board to generate the initial position - board_initial <- Reduce(function(x, f) f(x), rand_moves, init=board_final) - #Make sure initial and final positions aren't the same - if(!identical(board_initial, board_final)) break - } - #Time to start the game! - cat("\nYour starting position is:\n") - print(board_initial) - cat("\nYour target position is:\n") - print(board_final) - turns <- 1 - while(!identical(board_initial,board_final)){ - cat("\nTurn ", turns, ":\n", sep="") - move <- readline(prompt="Enter a row or column name to flip it: ") - if(move %in% 1:n){ - board_initial <- fliprow(board_initial, move) - cat("\nThe position is now:\n") - print(board_initial) - turns <- turns+1 - } - else if(move %in% letters[1:n]){ - board_initial <- flipcol(board_initial, which(letters==move)) - cat("\nThe position is now:\n") - print(board_initial) - turns <- turns+1 - } - else cat("\nThat's not a valid move. Try again!\n") - } - cat("\nWell done! You finished in", turns-1, "move(s).\n") -} - -bits_game() diff --git a/Task/Flipping-bits-game/Rust/flipping-bits-game.rs b/Task/Flipping-bits-game/Rust/flipping-bits-game.rust similarity index 100% rename from Task/Flipping-bits-game/Rust/flipping-bits-game.rs rename to Task/Flipping-bits-game/Rust/flipping-bits-game.rust diff --git a/Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua b/Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua deleted file mode 100644 index 4b550f5dcb..0000000000 --- a/Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua +++ /dev/null @@ -1,18 +0,0 @@ -# Could use `path`, but this is easily solved without it. -# ⊢path(⊂⊃(≡Fr|≡Fc)⇡Size¤|=0Dist|÷Size Dist) Shuffle T - -Size ← 8 -T ← ↯Size_Size 0 # Simple target setup. -Fr ← ⍜⊡¬⊙ # Flip a row. -Fc ← ⍜⊙⍉Fr # Flip a col. -Shuffle ← ⍥(⨬(Fr|Fc)<0.5⚂ ⌊×⚂Size)××2.Size # Apply random changes. -Dist ← /+/+⌵-T # Number of wrong cells. -⟜[∘]Shuffle T # Shuffle and start a copy for the output. -◌⍢( - ⊂⊃(≡Fr|≡Fc)⇡Size¤ # All neighbours. - ⊚=/↧.≡Dist. # Find min dist, get indices that give that. - ⊡⊢ # Pick first one. - ⊙⊂. # Save a copy of the new state. -| ≠0Dist # Repeat until found target. -) -⟜($"_ steps."⧻)⇌ diff --git a/Task/Flipping-bits-game/V-(Vlang)/flipping-bits-game.v b/Task/Flipping-bits-game/V-(Vlang)/flipping-bits-game.v deleted file mode 100644 index 5f31955f5d..0000000000 --- a/Task/Flipping-bits-game/V-(Vlang)/flipping-bits-game.v +++ /dev/null @@ -1,110 +0,0 @@ -import rand -import os - -const size = 3 - -struct Board { - mut: - target [][]int - board [][]int -} - -fn new_board() Board { - mut brd := Board{ - target: [][]int{len: size, init: []int{len: size}}, - board: [][]int{len: size, init: []int{len: size}}, - } - for ial in 0 .. size { - for jal in 0 .. size { - brd.target[ial][jal] = rand.intn(2) or {panic("No Random!")} - } - } - return brd -} - -fn (mut brd Board) flip_row(rir int) { - for cal in 0 .. size { - brd.board[rir][cal] = if brd.board[rir][cal] == 0 { 1 } else { 0 } - } -} - -fn (mut brd Board) flip_col(cir int) { - for ral in 0 .. size { - brd.board[ral][cir] = if brd.board[ral][cir] == 0 { 1 } else { 0 } - } -} - -fn (mut brd Board) init_board() { - for ial in 0 .. size { - for jal in 0 .. size { - brd.board[ial][jal] = brd.target[ial][jal] - } - } - for _ in 0 .. 9 { - rc := rand.intn(2) or {panic("No Random!")} - if rc == 0 { brd.flip_row(rand.intn(size) or {panic("No Random!")}) } - else { brd.flip_col(rand.intn(size) or {panic("No Random!")}) } - } -} - -fn print_board(label string, a [][]int) { - println("$label:") - println(" | a b c") - println("---------") - for ral in 0 .. size { - print("${ral + 1} |") - for cal in 0 .. size { - print(" ${a[ral][cal]}") - } - println("") - } - println("") -} - -fn (brd Board) game_over() bool { - for ral in 0 .. size { - for cal in 0 .. size { - if brd.board[ral][cal] != brd.target[ral][cal] { return false } - } - } - return true -} - -fn main() { - mut brd := new_board() - mut flips, mut nir := 0, -1 - mut is_row := true - // initialize board and ensure it differs from target - for { - brd.init_board() - if !brd.game_over() { break } - } - print_board("TARGET", brd.target) - print_board("OPENING BOARD", brd.board) - for { - is_row = true - nir = -1 - for nir == -1 { - input := os.input("Enter row number or column letter to be flipped: ").str() - if input.len == 0 { continue } - ch := input[0].ascii_str().to_lower() - if ch !in ["1", "2", "3", "a", "brd", "c"] { - println("Must be 1, 2, 3, a, brd or c") - continue - } - if ch in ["1", "2", "3"] { nir = int(ch[0]) - int(`1`) } - else { - is_row = false - nir = int(ch[0]) - int(`a`) - } - } - flips++ - if is_row { brd.flip_row(nir) } - else { brd.flip_col(nir) } - plural := if flips == 1 { "" } else { "S" } - print_board("\nBOARD AFTER $flips FLIP$plural", brd.board) - if brd.game_over() { break } - } - plural := if flips == 1 { "" } else { "s" } - println("You\'ve succeeded in $flips flip$plural") -} diff --git a/Task/Flipping-bits-game/Wren/flipping-bits-game.wren b/Task/Flipping-bits-game/Wren/flipping-bits-game.wren index ddcbaaf6d0..f17b9d0139 100644 --- a/Task/Flipping-bits-game/Wren/flipping-bits-game.wren +++ b/Task/Flipping-bits-game/Wren/flipping-bits-game.wren @@ -1,6 +1,6 @@ import "random" for Random -import "./ioutil" for Input -import "./str" for Str +import "/ioutil" for Input +import "/str" for Str var rand = Random.new() var target = List.filled(3, null) diff --git a/Task/Flow-control-structures/00-TASK.txt b/Task/Flow-control-structures/00-TASK.txt index e98a46bee8..914b6b9bdc 100644 --- a/Task/Flow-control-structures/00-TASK.txt +++ b/Task/Flow-control-structures/00-TASK.txt @@ -1,5 +1,4 @@ {{Control Structures}} -[[Category:Flow control]] ;Task: Document common flow-control structures. diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-1.adb b/Task/Flow-control-structures/Ada/flow-control-structures-1.ada similarity index 100% rename from Task/Flow-control-structures/Ada/flow-control-structures-1.adb rename to Task/Flow-control-structures/Ada/flow-control-structures-1.ada diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-2.ada b/Task/Flow-control-structures/Ada/flow-control-structures-2.ada new file mode 100644 index 0000000000..15f5e64b2f --- /dev/null +++ b/Task/Flow-control-structures/Ada/flow-control-structures-2.ada @@ -0,0 +1,8 @@ +Outer: + loop + -- do something + loop + -- do something else + exit Outer; -- exits both the inner and outer loops + end loop; + end loop; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-2.adb b/Task/Flow-control-structures/Ada/flow-control-structures-2.adb deleted file mode 100644 index b793ba8f93..0000000000 --- a/Task/Flow-control-structures/Ada/flow-control-structures-2.adb +++ /dev/null @@ -1,10 +0,0 @@ -Outer: -loop - -- do something - loop - if Finished then - exit Outer; -- exits both the inner and outer loops - end if; - -- do something else - end loop; -end loop Outer; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-5.adb b/Task/Flow-control-structures/Ada/flow-control-structures-3.ada similarity index 100% rename from Task/Flow-control-structures/Ada/flow-control-structures-5.adb rename to Task/Flow-control-structures/Ada/flow-control-structures-3.ada diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-3.adb b/Task/Flow-control-structures/Ada/flow-control-structures-3.adb deleted file mode 100644 index ed66f3714c..0000000000 --- a/Task/Flow-control-structures/Ada/flow-control-structures-3.adb +++ /dev/null @@ -1,8 +0,0 @@ -Outer: -loop - -- do something - loop - exit Outer when Finished; - -- do something else - end loop; -end loop Outer; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-4.adb b/Task/Flow-control-structures/Ada/flow-control-structures-4.adb deleted file mode 100644 index ef06de0b59..0000000000 --- a/Task/Flow-control-structures/Ada/flow-control-structures-4.adb +++ /dev/null @@ -1,8 +0,0 @@ -procedure Foo is -begin - -- do something - if Nothing_More_To_Do then - return; - end if; - -- do more -end Foo; diff --git a/Task/Flow-control-structures/COBOL/flow-control-structures-1.cob b/Task/Flow-control-structures/COBOL/flow-control-structures-1.cobol similarity index 100% rename from Task/Flow-control-structures/COBOL/flow-control-structures-1.cob rename to Task/Flow-control-structures/COBOL/flow-control-structures-1.cobol diff --git a/Task/Flow-control-structures/COBOL/flow-control-structures-2.cob b/Task/Flow-control-structures/COBOL/flow-control-structures-2.cobol similarity index 100% rename from Task/Flow-control-structures/COBOL/flow-control-structures-2.cob rename to Task/Flow-control-structures/COBOL/flow-control-structures-2.cobol diff --git a/Task/Flow-control-structures/COBOL/flow-control-structures-3.cob b/Task/Flow-control-structures/COBOL/flow-control-structures-3.cobol similarity index 100% rename from Task/Flow-control-structures/COBOL/flow-control-structures-3.cob rename to Task/Flow-control-structures/COBOL/flow-control-structures-3.cobol diff --git a/Task/Flow-control-structures/COBOL/flow-control-structures-4.cob b/Task/Flow-control-structures/COBOL/flow-control-structures-4.cobol similarity index 100% rename from Task/Flow-control-structures/COBOL/flow-control-structures-4.cob rename to Task/Flow-control-structures/COBOL/flow-control-structures-4.cobol diff --git a/Task/Flow-control-structures/COBOL/flow-control-structures-5.cob b/Task/Flow-control-structures/COBOL/flow-control-structures-5.cobol similarity index 100% rename from Task/Flow-control-structures/COBOL/flow-control-structures-5.cob rename to Task/Flow-control-structures/COBOL/flow-control-structures-5.cobol diff --git a/Task/Flow-control-structures/EasyLang/flow-control-structures.easy b/Task/Flow-control-structures/EasyLang/flow-control-structures.easy deleted file mode 100644 index ec5b67f41b..0000000000 --- a/Task/Flow-control-structures/EasyLang/flow-control-structures.easy +++ /dev/null @@ -1,9 +0,0 @@ -sum = 80036 -for i = 0 to 50 - for j = 0 to 50 - if i * i + j * j * j = sum - print i & "² + " & j & "³ = " & sum - break 2 - . - . -. diff --git a/Task/Flow-control-structures/FutureBasic/flow-control-structures.basic b/Task/Flow-control-structures/FutureBasic/flow-control-structures.basic deleted file mode 100644 index e1bdbc5e11..0000000000 --- a/Task/Flow-control-structures/FutureBasic/flow-control-structures.basic +++ /dev/null @@ -1,21 +0,0 @@ -override _allowSubroutines = _true -#build Optimization _buildOptimizationNone - -print "First line." -gosub "sub1" -print "Fifth line." - -HandleEvents - -"sub1" -print "Second line." -gosub "sub2" -print "Fourth line." -goto "skip" -print "we don't get here" -"skip" -return - -"sub2" -print "Third line." -return diff --git a/Task/Flow-control-structures/Julia/flow-control-structures.jl b/Task/Flow-control-structures/Julia/flow-control-structures.julia similarity index 100% rename from Task/Flow-control-structures/Julia/flow-control-structures.jl rename to Task/Flow-control-structures/Julia/flow-control-structures.julia diff --git a/Task/Flow-control-structures/Kotlin/flow-control-structures.kts b/Task/Flow-control-structures/Kotlin/flow-control-structures.kotlin similarity index 100% rename from Task/Flow-control-structures/Kotlin/flow-control-structures.kts rename to Task/Flow-control-structures/Kotlin/flow-control-structures.kotlin diff --git a/Task/Flow-control-structures/OCaml/flow-control-structures.ml b/Task/Flow-control-structures/OCaml/flow-control-structures.ocaml similarity index 100% rename from Task/Flow-control-structures/OCaml/flow-control-structures.ml rename to Task/Flow-control-structures/OCaml/flow-control-structures.ocaml diff --git a/Task/Flow-control-structures/Rebol/flow-control-structures.rebol b/Task/Flow-control-structures/REBOL/flow-control-structures.rebol similarity index 99% rename from Task/Flow-control-structures/Rebol/flow-control-structures.rebol rename to Task/Flow-control-structures/REBOL/flow-control-structures.rebol index 2530b2f609..27a2bbcf83 100644 --- a/Task/Flow-control-structures/Rebol/flow-control-structures.rebol +++ b/Task/Flow-control-structures/REBOL/flow-control-structures.rebol @@ -1,4 +1,4 @@ -Rebol [ +REBOL [ Title: "Flow Control" URL: http://rosettacode.org/wiki/Flow_Control_Structures ] diff --git a/Task/Flow-control-structures/Uxntal/flow-control-structures.uxnatl b/Task/Flow-control-structures/Uxntal/flow-control-structures.uxnatl deleted file mode 100644 index 7b135f37f9..0000000000 --- a/Task/Flow-control-structures/Uxntal/flow-control-structures.uxnatl +++ /dev/null @@ -1,24 +0,0 @@ -|18 @Console/write - -|100 - -example - -BRK - -@example ( x y -- ) - ;start print/str - !&world ( goto &world ) - ;never print/str - &world ( label &world ) - ;end !print/str - -@print/str ( str* -- ) - LDAk .Console/write DEO - INC2 LDAk ?&str - POP2 - JMP2r - -@start "Hello, 2000 -@never "Never 20 "printed. 0a00 -@end "World! 0a00 diff --git a/Task/Floyd-Warshall-algorithm/ALGOL-68/floyd-warshall-algorithm.alg b/Task/Floyd-Warshall-algorithm/ALGOL-68/floyd-warshall-algorithm.alg deleted file mode 100644 index 68ed0e7149..0000000000 --- a/Task/Floyd-Warshall-algorithm/ALGOL-68/floyd-warshall-algorithm.alg +++ /dev/null @@ -1,84 +0,0 @@ -BEGIN # Floyd-Warshall algorithm - translated from the Lua sample # - - OP FMT = ( REAL v )STRING: - BEGIN - STRING result := fixed( ABS v, 0, 15 ); - IF result[ LWB result ] = "." THEN "0" +=: result FI; - WHILE result[ UPB result ] = "0" DO result := result[ : UPB result - 1 ] OD; - IF result[ UPB result ] = "." THEN result := result[ : UPB result - 1 ] FI; - IF v < 0 THEN "-" ELSE " " FI + result - END # FMT # ; - - PROC print result = ( [,]REAL dist, [,]INT nxt )VOID: - BEGIN - print( ( "pair dist path", newline ) ); - FOR i FROM 1 LWB nxt TO 1 UPB nxt DO - FOR j FROM 2 LWB nxt TO 2 UPB nxt DO - IF i /= j THEN - INT u := i + 1; - INT v = j + 1; - print( ( whole( u, 0 ), " -> ", whole( v, 0 ), " " - , FMT dist[ i, j ], " ", whole( u, 0 ) - ) - ); - WHILE u := nxt[ u - 1, v - 1 ]; - print( ( " -> " + whole( u, 0 ) ) ); - u /= v - DO SKIP OD; - print( ( newline ) ) - FI - OD - OD - END # print result # ; - - PROC floyd warshall = ( [,]INT weights, INT num vertices )VOID: - BEGIN - - REAL infinite = max real; - - [ 0 : num vertices - 1, 0 : num vertices - 1 ]REAL dist; - FOR i FROM LWB dist TO 1 UPB dist DO - FOR j FROM 2 LWB dist TO 2 UPB dist DO - dist[ i, j ] := infinite - OD - OD; - - FOR i FROM 1 LWB weights TO 1 UPB weights DO - # the weights array is one based # - []INT w = weights[ i, : ]; - dist[ w[ 1 ] - 1, w[ 2 ] - 1 ] := w[ 3 ] - OD; - - [ 0 : num vertices - 1, 0 : num vertices - 1 ]INT nxt; - FOR i FROM LWB nxt TO 1 UPB nxt DO - FOR j FROM 2 LWB nxt TO 2 UPB nxt DO - nxt[ i, j ] := IF i /= j THEN j + 1 ELSE 0 FI - OD - OD; - - FOR k FROM 2 LWB dist TO 2 UPB dist DO - FOR i FROM 1 LWB dist TO 1 UPB dist DO - FOR j FROM 2 LWB dist TO 2 UPB dist DO - IF dist[ i, k ] /= infinite AND dist[ k, j ] /= infinite THEN - IF dist[ i, k ] + dist[ k, j ] < dist[ i, j ] THEN - dist[ i, j ] := dist[ i, k ] + dist[ k, j ]; - nxt[ i, j ] := nxt[ i, k ] - FI - FI - OD - OD - OD; - - print result( dist, nxt ) - END # floyd warshall # ; - BEGIN - [,]INT weights = ( ( 1, 3, -2 ) - , ( 2, 1, 4 ) - , ( 2, 3, 3 ) - , ( 3, 4, 2 ) - , ( 4, 2, -1 ) - ); - INT num vertices = 4; - floyd warshall( weights, num vertices ) - END -END diff --git a/Task/Floyd-Warshall-algorithm/Ada/floyd-warshall-algorithm.adb b/Task/Floyd-Warshall-algorithm/Ada/floyd-warshall-algorithm.ada similarity index 100% rename from Task/Floyd-Warshall-algorithm/Ada/floyd-warshall-algorithm.adb rename to Task/Floyd-Warshall-algorithm/Ada/floyd-warshall-algorithm.ada diff --git a/Task/Floyd-Warshall-algorithm/COBOL/floyd-warshall-algorithm.cob b/Task/Floyd-Warshall-algorithm/COBOL/floyd-warshall-algorithm.cob deleted file mode 100644 index 47f4420154..0000000000 --- a/Task/Floyd-Warshall-algorithm/COBOL/floyd-warshall-algorithm.cob +++ /dev/null @@ -1,183 +0,0 @@ -IDENTIFICATION DIVISION. - PROGRAM-ID. FLOYD-WARSHALL. - - DATA DIVISION. - WORKING-STORAGE SECTION. - - 01 WS-NUM-VERTICES PIC 9 VALUE 4. - 01 WS-NUM-WEIGHTS PIC 9 VALUE 5. - 01 WS-INFINITY PIC 9(7)V9(2) VALUE 9999999.99. - - 01 WS-WEIGHTS. - 05 WS-W OCCURS 5 TIMES. - 10 WS-FROM PIC 9. - 10 WS-TO PIC 9. - 10 WS-COST PIC S9(3) SIGN LEADING SEPARATE. - - 01 WS-DIST. - 05 WS-D OCCURS 4 TIMES. - 10 WS-D-COL OCCURS 4 TIMES. - 15 WS-DIST-VAL PIC S9(7)V9(2). - - 01 WS-NEXT. - 05 WS-N OCCURS 4 TIMES. - 10 WS-N-COL OCCURS 4 TIMES. - 15 WS-NEXT-VAL PIC 9. - - 01 WS-I PIC 9. - 01 WS-J PIC 9. - 01 WS-K PIC 9. - 01 WS-U PIC 9. - 01 WS-V PIC 9. - 01 WS-IDX PIC 9. - 01 WS-TEMP-SUM PIC S9(7)V9(2). - 01 WS-DIST-IJ PIC S9(7)V9(2). - 01 WS-DIST-IK PIC S9(7)V9(2). - 01 WS-DIST-KJ PIC S9(7)V9(2). - - *> Path and display working fields - 01 WS-PATH PIC X(200). - 01 WS-PATH-TEMP PIC X(200). - 01 WS-DIST-INT PIC S9(5). - 01 WS-DIST-EDIT PIC -(4)9. - 01 WS-DIST-TRIM PIC X(6). - 01 WS-OUTPUT-LINE PIC X(80). - 01 WS-NODE-CHAR PIC 9. - - PROCEDURE DIVISION. - MAIN-PARA. - MOVE 1 TO WS-FROM(1) - MOVE 3 TO WS-TO(1) - MOVE -2 TO WS-COST(1) - - MOVE 2 TO WS-FROM(2) - MOVE 1 TO WS-TO(2) - MOVE 4 TO WS-COST(2) - - MOVE 2 TO WS-FROM(3) - MOVE 3 TO WS-TO(3) - MOVE 3 TO WS-COST(3) - - MOVE 3 TO WS-FROM(4) - MOVE 4 TO WS-TO(4) - MOVE 2 TO WS-COST(4) - - MOVE 4 TO WS-FROM(5) - MOVE 2 TO WS-TO(5) - MOVE -1 TO WS-COST(5) - - PERFORM INIT-DIST - PERFORM INIT-NEXT - PERFORM FLOYD-WARSHALL - PERFORM PRINT-RESULT - STOP RUN. - - INIT-DIST. - PERFORM VARYING WS-I FROM 1 BY 1 - UNTIL WS-I > WS-NUM-VERTICES - PERFORM VARYING WS-J FROM 1 BY 1 - UNTIL WS-J > WS-NUM-VERTICES - MOVE WS-INFINITY TO WS-DIST-VAL(WS-I, WS-J) - END-PERFORM - END-PERFORM - PERFORM VARYING WS-IDX FROM 1 BY 1 - UNTIL WS-IDX > WS-NUM-WEIGHTS - MOVE WS-FROM(WS-IDX) TO WS-I - MOVE WS-TO(WS-IDX) TO WS-J - MOVE WS-COST(WS-IDX) TO WS-DIST-VAL(WS-I, WS-J) - END-PERFORM. - - INIT-NEXT. - PERFORM VARYING WS-I FROM 1 BY 1 - UNTIL WS-I > WS-NUM-VERTICES - PERFORM VARYING WS-J FROM 1 BY 1 - UNTIL WS-J > WS-NUM-VERTICES - IF WS-I NOT EQUAL WS-J - MOVE WS-J TO WS-NEXT-VAL(WS-I, WS-J) - ELSE - MOVE 0 TO WS-NEXT-VAL(WS-I, WS-J) - END-IF - END-PERFORM - END-PERFORM. - - FLOYD-WARSHALL. - PERFORM VARYING WS-K FROM 1 BY 1 - UNTIL WS-K > WS-NUM-VERTICES - PERFORM VARYING WS-I FROM 1 BY 1 - UNTIL WS-I > WS-NUM-VERTICES - PERFORM VARYING WS-J FROM 1 BY 1 - UNTIL WS-J > WS-NUM-VERTICES - MOVE WS-DIST-VAL(WS-I, WS-K) TO WS-DIST-IK - MOVE WS-DIST-VAL(WS-K, WS-J) TO WS-DIST-KJ - MOVE WS-DIST-VAL(WS-I, WS-J) TO WS-DIST-IJ - IF WS-DIST-IK < WS-INFINITY AND - WS-DIST-KJ < WS-INFINITY - COMPUTE WS-TEMP-SUM = - WS-DIST-IK + WS-DIST-KJ - IF WS-TEMP-SUM < WS-DIST-IJ - MOVE WS-TEMP-SUM - TO WS-DIST-VAL(WS-I, WS-J) - MOVE WS-NEXT-VAL(WS-I, WS-K) - TO WS-NEXT-VAL(WS-I, WS-J) - END-IF - END-IF - END-PERFORM - END-PERFORM - END-PERFORM. - - PRINT-RESULT. - DISPLAY "pair dist path" - PERFORM VARYING WS-I FROM 1 BY 1 - UNTIL WS-I > WS-NUM-VERTICES - PERFORM VARYING WS-J FROM 1 BY 1 - UNTIL WS-J > WS-NUM-VERTICES - IF WS-I NOT EQUAL WS-J - - *> Set up source and destination - MOVE WS-I TO WS-U - MOVE WS-J TO WS-V - - *> Seed path with just the source node - MOVE SPACES TO WS-PATH - MOVE WS-I TO WS-NODE-CHAR - MOVE WS-NODE-CHAR TO WS-PATH(1:1) - - *> Walk next-hop until we reach destination - PERFORM UNTIL WS-U = WS-V - MOVE WS-NEXT-VAL(WS-U, WS-V) TO WS-U - MOVE WS-U TO WS-NODE-CHAR - MOVE SPACES TO WS-PATH-TEMP - STRING - FUNCTION TRIM(WS-PATH TRAILING) - DELIMITED SIZE - " -> " DELIMITED SIZE - WS-NODE-CHAR DELIMITED SIZE - INTO WS-PATH-TEMP - MOVE WS-PATH-TEMP TO WS-PATH - END-PERFORM - - *> Format distance: move to integer then edit picture - *> to get clean signed number without leading zeros - COMPUTE WS-DIST-INT = - WS-DIST-VAL(WS-I, WS-J) - MOVE WS-DIST-INT TO WS-DIST-EDIT - MOVE FUNCTION TRIM(WS-DIST-EDIT LEADING) - TO WS-DIST-TRIM - - *> Assemble and print output line - MOVE SPACES TO WS-OUTPUT-LINE - STRING - WS-I DELIMITED SIZE - " -> " DELIMITED SIZE - WS-J DELIMITED SIZE - " " DELIMITED SIZE - FUNCTION TRIM(WS-DIST-TRIM LEADING) - DELIMITED SIZE - " " DELIMITED SIZE - FUNCTION TRIM(WS-PATH TRAILING) - DELIMITED SIZE - INTO WS-OUTPUT-LINE - DISPLAY FUNCTION TRIM(WS-OUTPUT-LINE TRAILING) - END-IF - END-PERFORM - END-PERFORM. diff --git a/Task/Floyd-Warshall-algorithm/Dart/floyd-warshall-algorithm.dart b/Task/Floyd-Warshall-algorithm/Dart/floyd-warshall-algorithm.dart deleted file mode 100644 index 287b9a495f..0000000000 --- a/Task/Floyd-Warshall-algorithm/Dart/floyd-warshall-algorithm.dart +++ /dev/null @@ -1,54 +0,0 @@ -void main() { - List> weights = [ - [1, 3, -2], - [2, 1, 4], - [2, 3, 3], - [3, 4, 2], - [4, 2, -1] - ]; - int numVertices = 4; - floydWarshall(weights, numVertices); -} - -void floydWarshall(List> weights, int numVertices) { - List> dist = List.generate( - numVertices, (_) => List.filled(numVertices, double.infinity)); - - for (var w in weights) { - dist[w[0] - 1][w[1] - 1] = w[2].toDouble(); - } - - List> next = List.generate( - numVertices, (i) => List.generate(numVertices, (j) => j != i ? j + 1 : 0)); - - for (int k = 0; k < numVertices; k++) { - for (int i = 0; i < numVertices; i++) { - for (int j = 0; j < numVertices; j++) { - if (dist[i][k] + dist[k][j] < dist[i][j]) { - dist[i][j] = dist[i][k] + dist[k][j]; - next[i][j] = next[i][k]; - } - } - } - } - - printResult(dist, next); -} - -void printResult(List> dist, List> next) { - print("pair dist path"); - for (int i = 0; i < next.length; i++) { - for (int j = 0; j < next.length; j++) { - if (i != j) { - int u = i + 1; - int v = j + 1; - String path = "$u -> $v ${dist[i][j].toInt()} $u"; - do { - u = next[u - 1][v - 1]; - path += " -> $u"; - } while (u != v); - print(path); - } - } - } -} diff --git a/Task/Floyd-Warshall-algorithm/EasyLang/floyd-warshall-algorithm.easy b/Task/Floyd-Warshall-algorithm/EasyLang/floyd-warshall-algorithm.easy deleted file mode 100644 index 4d4159674a..0000000000 --- a/Task/Floyd-Warshall-algorithm/EasyLang/floyd-warshall-algorithm.easy +++ /dev/null @@ -1,24 +0,0 @@ -proc floydwarshall w[][] n . - for i to n - con[][] &= [ ] - for j to n : con[i][] &= 1 / 0 - . - for i to len w[][] - con[w[i][1]][w[i][2]] = w[i][3] - . - for k to n - for i to n - for j to n - con[i][j] = lower con[i][j] (con[i][k] + con[k][j]) - . - . - . - for i to n - for j to n - if i <> j - print i & " -> " & j & " : " & con[i][j] - . - . - . -. -floydwarshall [ [ 1 3 -2 ] [ 2 1 4 ] [ 2 3 3 ] [ 3 4 2 ] [ 4 2 -1 ] ] 4 diff --git a/Task/Floyd-Warshall-algorithm/Elixir/floyd-warshall-algorithm.ex b/Task/Floyd-Warshall-algorithm/Elixir/floyd-warshall-algorithm.elixir similarity index 100% rename from Task/Floyd-Warshall-algorithm/Elixir/floyd-warshall-algorithm.ex rename to Task/Floyd-Warshall-algorithm/Elixir/floyd-warshall-algorithm.elixir diff --git a/Task/Floyd-Warshall-algorithm/Erlang/floyd-warshall-algorithm.erl b/Task/Floyd-Warshall-algorithm/Erlang/floyd-warshall-algorithm.erl deleted file mode 100644 index 9ff0e024e4..0000000000 --- a/Task/Floyd-Warshall-algorithm/Erlang/floyd-warshall-algorithm.erl +++ /dev/null @@ -1,54 +0,0 @@ --module(floyd_warshall). --export([main/2]). - - -main(N, Edge) -> - {Dist, Next} = setup(N, Edge), - {Dist2, Next2} = shortest_path(N, Dist, Next), - print(N, Dist2, Next2). - -setup(N, Edge) -> - Big = 1.0e300, - Dist = maps:from_list([{{I,J}, case I == J of true -> 0; false -> Big end} - || I <- lists:seq(1, N), J <- lists:seq(1, N)]), - Next = maps:from_list([{{I,J}, nil} - || I <- lists:seq(1, N), J <- lists:seq(1, N)]), - lists:foldl(fun({U, V, W}, {Dst, Nxt}) -> - {maps:put({U, V}, W, Dst), maps:put({U, V}, V, Nxt)} - end, {Dist, Next}, Edge). - -shortest_path(N, Dist, Next) -> - Combinations = [{K, I, J} || K <- lists:seq(1, N), - I <- lists:seq(1, N), - J <- lists:seq(1, N)], - lists:foldl(fun({K, I, J}, {Dst, Nxt}) -> - IJ_Dist = maps:get({I, J}, Dst), - IK_Dist = maps:get({I, K}, Dst), - KJ_Dist = maps:get({K, J}, Dst), - case IJ_Dist > IK_Dist + KJ_Dist of - true -> - NewDist = maps:put({I, J}, IK_Dist + KJ_Dist, Dst), - NewNext = maps:put({I, J}, maps:get({I, K}, Nxt), Nxt), - {NewDist, NewNext}; - false -> - {Dst, Nxt} - end - end, {Dist, Next}, Combinations). - -print(N, Dist, Next) -> - io:format("pair dist path~n"), - [io:format("~w -> ~w ~4w ~s~n", [I, J, maps:get({I, J}, Dist), path(Next, I, J)]) - || I <- lists:seq(1, N), J <- lists:seq(1, N), I =/= J]. - -path(Next, I, J) -> - PathList = path(Next, I, J, [I]), - string:join([integer_to_list(X) || X <- PathList], " -> "). - -path(_Next, I, I, List) -> - lists:reverse(List); -path(Next, I, J, List) -> - U = maps:get({I, J}, Next), - path(Next, U, J, [U | List]). - -% Usage example: -main(_) -> main(4, [{1, 3, -2}, {2, 1, 4}, {2, 3, 3}, {3, 4, 2}, {4, 2, -1}]). diff --git a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-2.j b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-2.j index 03dc67fc2d..e164599e6e 100644 --- a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-2.j +++ b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-2.j @@ -1 +1,12 @@ -floyd=: ]F..(]<.{"1+/{) i.@# +graph=: ".;._2]0 :0 + 0 _ _2 _ NB. 1->3 costs _2 + 4 0 3 _ NB. 2->1 costs 4; 2->3 costs 3 + _ _ 0 2 NB. 3->4 costs 2 + _ _1 _ 0 NB. 4->2 costs _1 +) + + floyd graph +0 _1 _2 0 +4 0 2 4 +5 1 0 2 +3 _1 1 0 diff --git a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-3.j b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-3.j index e164599e6e..a8d86325c7 100644 --- a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-3.j +++ b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-3.j @@ -1,12 +1,33 @@ -graph=: ".;._2]0 :0 - 0 _ _2 _ NB. 1->3 costs _2 - 4 0 3 _ NB. 2->1 costs 4; 2->3 costs 3 - _ _ 0 2 NB. 3->4 costs 2 - _ _1 _ 0 NB. 4->2 costs _1 +floydrecon=: verb define + n=. ($y)$_(I._=,y)},($$i.@#)y + for_j. i.#y do. + d=. y <. j ({"1 +/ {) y + b=. y~:d + y=. d + n=. (n*-.b)+b * j{"1 n + end. ) - floyd graph -0 _1 _2 0 -4 0 2 4 -5 1 0 2 -3 _1 1 0 +task=: verb define + dist=. floyd y + next=. floydrecon y + echo 'pair dist path' + for_i. i.#y do. + for_k. i.#y do. + ndx=. ndx{next do. + txt=. (":1+i),'->',(":1+k) + txt=. txt,_5{.":ndx{dist + txt=. txt,' ',":1+i + j=. i + while. j~:k do. + assert. j~:(',":1+j + end. + echo txt + end. + end. + end. + i.0 0 +) diff --git a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-4.j b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-4.j index a8d86325c7..2218e40e3a 100644 --- a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-4.j +++ b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-4.j @@ -1,33 +1,14 @@ -floydrecon=: verb define - n=. ($y)$_(I._=,y)},($$i.@#)y - for_j. i.#y do. - d=. y <. j ({"1 +/ {) y - b=. y~:d - y=. d - n=. (n*-.b)+b * j{"1 n - end. -) - -task=: verb define - dist=. floyd y - next=. floydrecon y - echo 'pair dist path' - for_i. i.#y do. - for_k. i.#y do. - ndx=. ndx{next do. - txt=. (":1+i),'->',(":1+k) - txt=. txt,_5{.":ndx{dist - txt=. txt,' ',":1+i - j=. i - while. j~:k do. - assert. j~:(',":1+j - end. - echo txt - end. - end. - end. - i.0 0 -) + task graph +pair dist path +1->2 _1 1->3->4->2 +1->3 _2 1->3 +1->4 0 1->3->4 +2->1 4 2->1 +2->3 2 2->1->3 +2->4 4 2->1->3->4 +3->1 5 3->4->2->1 +3->2 1 3->4->2 +3->4 2 3->4 +4->1 3 4->2->1 +4->2 _1 4->2 +4->3 1 4->2->1->3 diff --git a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-5.j b/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-5.j deleted file mode 100644 index 2218e40e3a..0000000000 --- a/Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-5.j +++ /dev/null @@ -1,14 +0,0 @@ - task graph -pair dist path -1->2 _1 1->3->4->2 -1->3 _2 1->3 -1->4 0 1->3->4 -2->1 4 2->1 -2->3 2 2->1->3 -2->4 4 2->1->3->4 -3->1 5 3->4->2->1 -3->2 1 3->4->2 -3->4 2 3->4 -4->1 3 4->2->1 -4->2 _1 4->2 -4->3 1 4->2->1->3 diff --git a/Task/Floyd-Warshall-algorithm/JavaScript/floyd-warshall-algorithm.js b/Task/Floyd-Warshall-algorithm/JavaScript/floyd-warshall-algorithm.js index e6c040e093..5509d0c1a8 100644 --- a/Task/Floyd-Warshall-algorithm/JavaScript/floyd-warshall-algorithm.js +++ b/Task/Floyd-Warshall-algorithm/JavaScript/floyd-warshall-algorithm.js @@ -1,49 +1,21 @@ -'use strict' -let numVertices = 4; -let weights = [ [ 1, 3, -2 ], [ 2, 1, 4 ], [ 2, 3, 3 ], [ 3, 4, 2 ], [ 4, 2, -1 ] ]; - -let graph = []; -for (let i = 0; i < numVertices; ++i) { +var graph = []; +for (i = 0; i < 10; ++i) { graph.push([]); - for (let j = 0; j < numVertices; ++j) + for (j = 0; j < 10; ++j) graph[i].push(i == j ? 0 : 9999999); } -for (let i = 0; i < weights.length; ++i) { - let w = weights[i]; - graph[w[0] - 1][w[1] - 1] = w[2]; +for (i = 1; i < 10; ++i) { + graph[0][i] = graph[i][0] = parseInt(Math.random() * 9 + 1); } -let nxt = []; -for (let i = 0; i < numVertices; ++i) { - nxt.push([]); - for (let j = 0; j < numVertices; ++j) - nxt[i].push(i == j ? 0 : j + 1); -} - -for (let k = 0; k < numVertices; ++k) { - for (let i = 0; i < numVertices; ++i) { - for (let j = 0; j < numVertices; ++j) { - if (graph[i][j] > graph[i][k] + graph[k][j]) { - graph[i][j] = graph[i][k] + graph[k][j]; - nxt[i][j] = nxt[i][k]; - } +for (k = 0; k < 10; ++k) { + for (i = 0; i < 10; ++i) { + for (j = 0; j < 10; ++j) { + if (graph[i][j] > graph[i][k] + graph[k][j]) + graph[i][j] = graph[i][k] + graph[k][j] } } } -console.log("pair dist path"); -for (let i = 0; i < numVertices; ++i) { - for (let j = 0; j < numVertices; ++j) { - if (i != j) { - let u = i + 1; - let v = j + 1; - let path = u + " -> " + v + " " + graph[i][j].toString().padStart(2) + " " + u; - do { - u = nxt[u - 1][v - 1]; - path = path + " -> " + u; - } while (u != v); - console.log(path) - } - } -} +console.log(graph); diff --git a/Task/Floyd-Warshall-algorithm/Julia/floyd-warshall-algorithm.jl b/Task/Floyd-Warshall-algorithm/Julia/floyd-warshall-algorithm.julia similarity index 100% rename from Task/Floyd-Warshall-algorithm/Julia/floyd-warshall-algorithm.jl rename to Task/Floyd-Warshall-algorithm/Julia/floyd-warshall-algorithm.julia diff --git a/Task/Floyd-Warshall-algorithm/Kotlin/floyd-warshall-algorithm.kts b/Task/Floyd-Warshall-algorithm/Kotlin/floyd-warshall-algorithm.kotlin similarity index 100% rename from Task/Floyd-Warshall-algorithm/Kotlin/floyd-warshall-algorithm.kts rename to Task/Floyd-Warshall-algorithm/Kotlin/floyd-warshall-algorithm.kotlin diff --git a/Task/Floyd-Warshall-algorithm/OCaml/floyd-warshall-algorithm.ml b/Task/Floyd-Warshall-algorithm/OCaml/floyd-warshall-algorithm.ocaml similarity index 100% rename from Task/Floyd-Warshall-algorithm/OCaml/floyd-warshall-algorithm.ml rename to Task/Floyd-Warshall-algorithm/OCaml/floyd-warshall-algorithm.ocaml diff --git a/Task/Floyd-Warshall-algorithm/Pluto/floyd-warshall-algorithm.pluto b/Task/Floyd-Warshall-algorithm/Pluto/floyd-warshall-algorithm.pluto deleted file mode 100644 index 8f3b213cd2..0000000000 --- a/Task/Floyd-Warshall-algorithm/Pluto/floyd-warshall-algorithm.pluto +++ /dev/null @@ -1,50 +0,0 @@ -require "table2" - -class floydWarshall - static function do_calcs(weights, nvertices) - local dist = {} - local next = {} - for i = 1, nvertices do - dist[i] = table.rep(nvertices, 1/0) - next[i] = table.rep(nvertices, 1) - for j = 1, nvertices do - if i != j then next[i][j] = j end - end - end - for weights as w do dist[w[1]][w[2]] = w[3] end - for k = 1, nvertices do - for i = 1, nvertices do - for j = 1, nvertices do - if (dist[i][k] + dist[k][j] < dist[i][j]) then - dist[i][j] = dist[i][k] + dist[k][j] - next[i][j] = next[i][k] - end - end - end - end - floydWarshall.print_result(dist, next) - end - - static function print_result(dist, next) - print("pair dist path") - for i = 1, #next do - for j = 1, #next do - if i != j then - local u = i - local v = j - local path = string.format("%d -> %d %2d %s", u, v, math.trunc(dist[i][j]), u) - while true do - u = next[u][v] - path ..= " -> " .. u - if u == v then break end - end - print(path) - end - end - end - end -end - -local weights = { {1, 3, -2}, {2, 1, 4}, {2, 3, 3}, {3, 4, 2}, {4, 2, -1} } -local nvertices = 4 -floydWarshall.do_calcs(weights, nvertices) diff --git a/Task/Floyd-Warshall-algorithm/R/floyd-warshall-algorithm.r b/Task/Floyd-Warshall-algorithm/R/floyd-warshall-algorithm.r deleted file mode 100644 index e65a241e61..0000000000 --- a/Task/Floyd-Warshall-algorithm/R/floyd-warshall-algorithm.r +++ /dev/null @@ -1,67 +0,0 @@ -floydWarshall <- function(weights, numVertices) { - # Initialize distance matrix with infinity - dist <- matrix(Inf, nrow = numVertices, ncol = numVertices) - - # Set diagonal elements to zero - diag(dist) <- 0 - - # Fill the distance matrix with the given weights - for (i in 1:nrow(weights)) { - dist[weights[i, 1], weights[i, 2]] <- weights[i, 3] - } - - # Initialize nextNode matrix - nextNode <- matrix(0, nrow = numVertices, ncol = numVertices) - for (i in 1:numVertices) { - for (j in 1:numVertices) { - if (i != j) { - nextNode[i, j] <- j - } - } - } - - # Floyd-Warshall algorithm - for (k in 1:numVertices) { - for (i in 1:numVertices) { - for (j in 1:numVertices) { - if (dist[i, k] + dist[k, j] < dist[i, j]) { - dist[i, j] <- dist[i, k] + dist[k, j] - nextNode[i, j] <- nextNode[i, k] - } - } - } - } - - printResult(dist, nextNode) -} - -printResult <- function(dist, nextNode) { - cat("pair dist path\n") - for (i in 1:nrow(nextNode)) { - for (j in 1:ncol(nextNode)) { - if (i != j) { - u <- i - v <- j - path <- sprintf("%d -> %d %2d %s", i, j, dist[i, j], i) - repeat { - u <- nextNode[u, v] - path <- paste(path, "->", u) - if (u == v) break - } - cat(path, "\n") - } - } - } -} - -# Example usage -weights <- matrix(c( - 1, 3, -2, - 2, 1, 4, - 2, 3, 3, - 3, 4, 2, - 4, 2, -1 -), ncol = 3, byrow = TRUE) - -numVertices <- 4 -floydWarshall(weights, numVertices) diff --git a/Task/Floyd-Warshall-algorithm/Rust/floyd-warshall-algorithm.rs b/Task/Floyd-Warshall-algorithm/Rust/floyd-warshall-algorithm.rust similarity index 100% rename from Task/Floyd-Warshall-algorithm/Rust/floyd-warshall-algorithm.rs rename to Task/Floyd-Warshall-algorithm/Rust/floyd-warshall-algorithm.rust diff --git a/Task/Floyd-Warshall-algorithm/Scala/floyd-warshall-algorithm.scala b/Task/Floyd-Warshall-algorithm/Scala/floyd-warshall-algorithm.scala deleted file mode 100644 index 250ce4faaa..0000000000 --- a/Task/Floyd-Warshall-algorithm/Scala/floyd-warshall-algorithm.scala +++ /dev/null @@ -1,50 +0,0 @@ -import java.lang.String.format; - -object FloydWarshall extends App { - - val weights = Array(Array(1, 3, -2), Array(2, 1, 4), Array(2, 3, 3), Array(3, 4, 2), Array(4, 2, -1)) - val numVertices = 4 - - floydWarshall(weights, numVertices) - - def floydWarshall(weights: Array[Array[Int]], numVertices: Int): Unit = { - - val dist = Array.fill(numVertices, numVertices)(Double.PositiveInfinity) - for (w <- weights) - dist(w(0) - 1)(w(1) - 1) = w(2) - - val next = Array.ofDim[Int](numVertices, numVertices) - for (i <- 0 until numVertices; j <- 0 until numVertices if i != j) - next(i)(j) = j + 1 - - for { - k <- 0 until numVertices - i <- 0 until numVertices - j <- 0 until numVertices - if dist(i)(k) + dist(k)(j) < dist(i)(j) - } { - dist(i)(j) = dist(i)(k) + dist(k)(j) - next(i)(j) = next(i)(k) - } - - printResult(dist, next) - } - - def printResult(dist: Array[Array[Double]], next: Array[Array[Int]]): Unit = { - println("pair dist path") - for { - i <- 0 until next.length - j <- 0 until next.length if i != j - } { - var u = i + 1 - val v = j + 1 - var path = format("%d -> %d %2d %s", u, v, - (dist(i)(j)).toInt, u); - while (u != v) { - u = next(u - 1)(v - 1) - path += s" -> $u" - } - println(path) - } - } -} diff --git a/Task/Floyd-Warshall-algorithm/Scheme/floyd-warshall-algorithm.scm b/Task/Floyd-Warshall-algorithm/Scheme/floyd-warshall-algorithm.ss similarity index 100% rename from Task/Floyd-Warshall-algorithm/Scheme/floyd-warshall-algorithm.scm rename to Task/Floyd-Warshall-algorithm/Scheme/floyd-warshall-algorithm.ss diff --git a/Task/Floyd-Warshall-algorithm/Swift/floyd-warshall-algorithm.swift b/Task/Floyd-Warshall-algorithm/Swift/floyd-warshall-algorithm.swift deleted file mode 100644 index f6f9661f35..0000000000 --- a/Task/Floyd-Warshall-algorithm/Swift/floyd-warshall-algorithm.swift +++ /dev/null @@ -1,51 +0,0 @@ -func floydWarshall(_ weights: [[Int]], _ numVertices: Int) { - var dist = Array(repeating: Array(repeating: Double.infinity, count: numVertices), count: numVertices) - var next = Array(repeating: Array(repeating: 0, count: numVertices), count: numVertices) - - for weight in weights { - dist[weight[0] - 1][weight[1] - 1] = Double(weight[2]) - } - - for i in 0.. %d %2d %d", U, V, Dist(I,J), U); - repeat U:= Next(U-1, V-1); - Print(" -> %d", U); - until U = V; - Print("\n"); - ]; - ]; - -[Dist:= Reserve(Verts*IntSize); -for I:= 0 to Verts-1 do - [Dist(I):= Reserve(Verts*IntSize); - for J:= 0 to Verts-1 do - Dist(I,J):= \Inf\10000; - ]; -for W:= 0 to Len-1 do - Dist(Weights(W,0)-1, Weights(W,1)-1):= Weights(W,2); -Next:= Reserve(Verts*IntSize); -for I:= 0 to Verts-1 do - [Next(I):= Reserve(Verts*IntSize); - for J:= 0 to Verts-1 do - Next(I,J):= if I=J then 0 else J+1; - ]; -for K:= 0 to Verts-1 do - for I:= 0 to Verts-1 do - for J:= 0 to Verts-1 do - if Dist(I,J) > Dist(I,K) + Dist(K,J) then - [Dist(I,J):= Dist(I,K) + Dist(K,J); - Next(I,J):= Next(I,K); - ]; -PrintResult; -]; - -int Weights; -[Weights:= [ [1, 3, -2], [2, 1, 4], [2, 3, 3], [3, 4, 2], [4, 2, -1] ]; -FloydWarshall(Weights, 5, 4); -] diff --git a/Task/Floyd-Warshall-algorithm/Zig/floyd-warshall-algorithm.zig b/Task/Floyd-Warshall-algorithm/Zig/floyd-warshall-algorithm.zig deleted file mode 100644 index fe8d6dd20d..0000000000 --- a/Task/Floyd-Warshall-algorithm/Zig/floyd-warshall-algorithm.zig +++ /dev/null @@ -1,99 +0,0 @@ -// floyd_warshall.zig -const std = @import("std"); - -const F64_INF = std.math.inf(f64); - -fn idx(i: usize, j: usize, n: usize) usize { - return i * n + j; -} - -fn printResult(dist: []const f64, next: []const usize, n: usize) void { - std.debug.print("(pair, dist, path)\n", .{}); - for (0..n) |i| { - for (0..n) |j| { - if (i == j) continue; - - const @"u0" = i + 1; - const v0 = j + 1; - - std.debug.print("({d} -> {d}, {d}, ", .{ - @"u0", v0, dist[idx(i, j, n)], - }); - - var u = @"u0"; - std.debug.print("{d}", .{u}); - while (u != v0) { - u = next[idx(u - 1, v0 - 1, n)]; - std.debug.print(" -> {d}", .{u}); - } - std.debug.print(")\n", .{}); - } - } -} - -fn solve( - allocator: std.mem.Allocator, - edges: []const [3]i64, // (u,v,w) 1‑based - n: usize, -) !void { - // Allocate matrices - var dist = try allocator.alloc(f64, n * n); - defer allocator.free(dist); - - var next_v = try allocator.alloc(usize, n * n); - defer allocator.free(next_v); - - // Initialise - for (dist)|*d| d.* = F64_INF; - for (next_v)|*x| x.* = 0; - - // Edge weights - for (edges) |e| { - const u = @as(usize, @intCast(e[0] - 1)); - const v = @as(usize, @intCast(e[1] - 1)); - dist[idx(u, v, n)] = @as(f64, @floatFromInt(e[2])); - } - - // Successor matrix - for (0..n) |i| { - for (0..n) |j| { - if (i != j) next_v[idx(i, j, n)] = j + 1; // 1‑based - } - } - - // Floyd–Warshall - for (0..n) |k| { - for (0..n) |i| { - for (0..n) |j| { - const dik = dist[idx(i, k, n)]; - const dkj = dist[idx(k, j, n)]; - if (std.math.isFinite(dik) and std.math.isFinite(dkj)) { - const alt = dik + dkj; - const pos = idx(i, j, n); - if (alt < dist[pos]) { - dist[pos] = alt; - next_v[pos] = next_v[idx(i, k, n)]; - } - } - } - } - } - - printResult(dist, next_v, n); -} - -pub fn main() !void { - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - defer _ = gpa.deinit(); - const alloc = gpa.allocator(); - - const edges = [_][3]i64{ - .{ 1, 3, -2 }, - .{ 2, 1, 4 }, - .{ 2, 3, 3 }, - .{ 3, 4, 2 }, - .{ 4, 2, -1 }, - }; - - try solve(alloc, edges[0..], 4); -} diff --git a/Task/Floyds-triangle/ABC/floyds-triangle.abc b/Task/Floyds-triangle/ABC/floyds-triangle.abc deleted file mode 100644 index 8d18d171cf..0000000000 --- a/Task/Floyds-triangle/ABC/floyds-triangle.abc +++ /dev/null @@ -1,18 +0,0 @@ -HOW TO RETURN width n: - SELECT: - n<10: RETURN 1 - ELSE: RETURN 1 + width floor (n/10) - -HOW TO DISPLAY A FLOYD TRIANGLE WITH lines LINES: - PUT lines * (lines+1)/2 IN maxno - PUT 1 IN n - FOR line IN {1..lines}: - FOR col IN {1..line}: - WRITE n >> (1 + width (maxno - lines + col)) - PUT n+1 IN n - WRITE / - -DISPLAY A FLOYD TRIANGLE WITH 5 LINES -WRITE / -DISPLAY A FLOYD TRIANGLE WITH 14 LINES -WRITE / diff --git a/Task/Floyds-triangle/ALGOL-68/floyds-triangle.alg b/Task/Floyds-triangle/ALGOL-68/floyds-triangle.alg index c3bd144573..3e06ecbe63 100644 --- a/Task/Floyds-triangle/ALGOL-68/floyds-triangle.alg +++ b/Task/Floyds-triangle/ALGOL-68/floyds-triangle.alg @@ -1,11 +1,7 @@ -# procedure to print a Floyd's Triangle with n lines # +# procedure to print a Floyd's Triangle with n lines # PROC floyds triangle = ( INT n )VOID: BEGIN - # the triangle should be left aligned with the individual numbers # - # right-aligned with only one space before the number in the final # - # row # - # calculate the number of the highest number that will be printed # # ( the sum of the integers 1, 2, ... n ) # INT max number = ( n * ( n + 1 ) ) OVER 2; @@ -28,6 +24,10 @@ BEGIN END; # floyds triangle # -floyds triangle( 5 ); -print( ( newline ) ); -floyds triangle( 14 ) +main: ( + + floyds triangle( 5 ); + print( ( newline ) ); + floyds triangle( 14 ) + +) diff --git a/Task/Floyds-triangle/APL/floyds-triangle-1.apl b/Task/Floyds-triangle/APL/floyds-triangle-1.apl deleted file mode 100644 index ff59b36c39..0000000000 --- a/Task/Floyds-triangle/APL/floyds-triangle-1.apl +++ /dev/null @@ -1,6 +0,0 @@ -floyd←{ - max←⍵×(⍵+1)÷2 - tri←↑(⍳max)⊂⍨(0,⍳max-1)∊+\0,⍳⍵ - wdt←⌈⍀⊖≢∘⍕¨tri - ↑,/wdt{' ',(-⍺××⍵)↑⍕⍵}¨tri -} diff --git a/Task/Floyds-triangle/APL/floyds-triangle-2.apl b/Task/Floyds-triangle/APL/floyds-triangle-2.apl deleted file mode 100644 index b847a54de1..0000000000 --- a/Task/Floyds-triangle/APL/floyds-triangle-2.apl +++ /dev/null @@ -1,21 +0,0 @@ - floyd 5 - 1 - 2 3 - 4 5 6 - 7 8 9 10 - 11 12 13 14 15 - floyd 14 - 1 - 2 3 - 4 5 6 - 7 8 9 10 - 11 12 13 14 15 - 16 17 18 19 20 21 - 22 23 24 25 26 27 28 - 29 30 31 32 33 34 35 36 - 37 38 39 40 41 42 43 44 45 - 46 47 48 49 50 51 52 53 54 55 - 56 57 58 59 60 61 62 63 64 65 66 - 67 68 69 70 71 72 73 74 75 76 77 78 - 79 80 81 82 83 84 85 86 87 88 89 90 91 - 92 93 94 95 96 97 98 99 100 101 102 103 104 105 diff --git a/Task/Floyds-triangle/Ada/floyds-triangle.adb b/Task/Floyds-triangle/Ada/floyds-triangle.ada similarity index 100% rename from Task/Floyds-triangle/Ada/floyds-triangle.adb rename to Task/Floyds-triangle/Ada/floyds-triangle.ada diff --git a/Task/Floyds-triangle/Ballerina/floyds-triangle.ballerina b/Task/Floyds-triangle/Ballerina/floyds-triangle.ballerina deleted file mode 100644 index 0a4976e6f9..0000000000 --- a/Task/Floyds-triangle/Ballerina/floyds-triangle.ballerina +++ /dev/null @@ -1,20 +0,0 @@ -import ballerina/io; - -function floyd(int n) { - int k = 1; - foreach int i in 1...n { - foreach int j in 1...i { - int p = j < 9 ? 3 : 4; - io:print(k.toString().padStart(p)); - k += 1; - } - io:println(); - } -} - -public function main() { - io:println("Floyd(5):"); - floyd(5); - io:println("\nFloyd(14):"); - floyd(14); -} diff --git a/Task/Floyds-triangle/COBOL/floyds-triangle.cob b/Task/Floyds-triangle/COBOL/floyds-triangle.cobol similarity index 100% rename from Task/Floyds-triangle/COBOL/floyds-triangle.cob rename to Task/Floyds-triangle/COBOL/floyds-triangle.cobol diff --git a/Task/Floyds-triangle/Delphi/floyds-triangle.pas b/Task/Floyds-triangle/Delphi/floyds-triangle.delphi similarity index 100% rename from Task/Floyds-triangle/Delphi/floyds-triangle.pas rename to Task/Floyds-triangle/Delphi/floyds-triangle.delphi diff --git a/Task/Floyds-triangle/Draco/floyds-triangle.draco b/Task/Floyds-triangle/Draco/floyds-triangle.draco deleted file mode 100644 index a517617453..0000000000 --- a/Task/Floyds-triangle/Draco/floyds-triangle.draco +++ /dev/null @@ -1,28 +0,0 @@ -proc width(word n) word: - word w; - w := 0; - while n>0 do - w := w + 1; - n := n / 10 - od; - w -corp - -proc floyd(word rows) void: - word n, row, col, maxno; - maxno := rows * (rows+1)/2; - n := 1; - for row from 1 upto rows do - for col from 1 upto row do - write(n : 1+width(maxno - rows + col)); - n := n+1 - od; - writeln() - od -corp - -proc main() void: - floyd(5); - writeln(); - floyd(14) -corp diff --git a/Task/Floyds-triangle/EasyLang/floyds-triangle.easy b/Task/Floyds-triangle/EasyLang/floyds-triangle.easy deleted file mode 100644 index d575e1535b..0000000000 --- a/Task/Floyds-triangle/EasyLang/floyds-triangle.easy +++ /dev/null @@ -1,24 +0,0 @@ -func ceil h . - f = floor h - if h <> f : f += 1 - return f -. -proc triangle n . - print n & " rows:" - row = 1 - while row <= n - printme += 1 - cols = ceil log (n * (n - 1) / 2 + nprinted + 2) 10 - numfmt cols 0 - write printme & " " - nprinted += 1 - if nprinted = row - print "" - row += 1 - nprinted = 0 - . - . - print "" -. -triangle 5 -triangle 14 diff --git a/Task/Floyds-triangle/Elixir/floyds-triangle.ex b/Task/Floyds-triangle/Elixir/floyds-triangle.elixir similarity index 100% rename from Task/Floyds-triangle/Elixir/floyds-triangle.ex rename to Task/Floyds-triangle/Elixir/floyds-triangle.elixir diff --git a/Task/Floyds-triangle/Frink/floyds-triangle.frink b/Task/Floyds-triangle/Frink/floyds-triangle.frink deleted file mode 100644 index d404e4fbdc..0000000000 --- a/Task/Floyds-triangle/Frink/floyds-triangle.frink +++ /dev/null @@ -1,16 +0,0 @@ -FloydsTriangle[rows] := -{ - result = new array - n = 1 - for r = 1 to rows - { - result.push[array[n to n+r-1]] - n = n + r - } - - return result -} - -println[formatTable[FloydsTriangle[5], "right"]] -println[] -println[formatTable[FloydsTriangle[14], "right"]] diff --git a/Task/Floyds-triangle/FutureBasic/floyds-triangle.basic b/Task/Floyds-triangle/FutureBasic/floyds-triangle.basic deleted file mode 100644 index cd7e9cb937..0000000000 --- a/Task/Floyds-triangle/FutureBasic/floyds-triangle.basic +++ /dev/null @@ -1,18 +0,0 @@ -void local fn FloydsTriangle( rows as int ) - int col, row, num = 1 - - printf @"%d rows:", rows - for row = 1 to rows - for col = 1 to row - printf @"%4d\b", num - num++ - next - print - next - print -end fn - -fn FloydsTriangle( 5 ) -fn FloydsTriangle( 14 ) - -HandleEvents diff --git a/Task/Floyds-triangle/Julia/floyds-triangle.jl b/Task/Floyds-triangle/Julia/floyds-triangle.julia similarity index 100% rename from Task/Floyds-triangle/Julia/floyds-triangle.jl rename to Task/Floyds-triangle/Julia/floyds-triangle.julia diff --git a/Task/Floyds-triangle/Kotlin/floyds-triangle.kts b/Task/Floyds-triangle/Kotlin/floyds-triangle.kotlin similarity index 100% rename from Task/Floyds-triangle/Kotlin/floyds-triangle.kts rename to Task/Floyds-triangle/Kotlin/floyds-triangle.kotlin diff --git a/Task/Floyds-triangle/Maxima/floyds-triangle.maxima b/Task/Floyds-triangle/Maxima/floyds-triangle.maxima deleted file mode 100644 index f1d435055e..0000000000 --- a/Task/Floyds-triangle/Maxima/floyds-triangle.maxima +++ /dev/null @@ -1,10 +0,0 @@ -floyd_t(m):=block( - t:m*(m+1)/2, - L1:makelist(makelist(k,k,1,t),j,0,m), - L2:makelist(rest(L1[i],((i-1)^2+(i-1))/2),i,1,m+1), - makelist(firstn(L2[i],i),i,1,m), - table_form(%%))$ - -/* Test cases */ -floyd_t(5); -floyd_t(14); diff --git a/Task/Floyds-triangle/Miranda/floyds-triangle.miranda b/Task/Floyds-triangle/Miranda/floyds-triangle.miranda deleted file mode 100644 index 9f93c14690..0000000000 --- a/Task/Floyds-triangle/Miranda/floyds-triangle.miranda +++ /dev/null @@ -1,27 +0,0 @@ -main :: [sys_message] -main = [Stdout (lay (map floyd [5, 14]))] - -floyd :: num->[char] -floyd n = lay (map fmt rws) - where rws = rows n - cws = map ((+1).width) (last rws) - fmt rw = concat (map (uncurry rjust) (zip2 cws rw)) - - -rows :: num->[[num]] -rows n = rows' [1..n] [1..] - where rows' [] ns = [] - rows' (l:ls) ns = row : rows' ls rest - where (row, rest) = split l ns - -split :: num->[*]->([*],[*]) -split n ls = (take n ls, drop n ls) - -rjust :: num->num->[char] -rjust w n = reverse (take w (reverse (show n) ++ repeat ' ')) - -width :: num->num -width = (#) . show - -uncurry :: (*->**->***)->(*,**)->*** -uncurry f (a,b) = f a b diff --git a/Task/Floyds-triangle/OCaml/floyds-triangle.ml b/Task/Floyds-triangle/OCaml/floyds-triangle.ocaml similarity index 100% rename from Task/Floyds-triangle/OCaml/floyds-triangle.ml rename to Task/Floyds-triangle/OCaml/floyds-triangle.ocaml diff --git a/Task/Floyds-triangle/Objeck/floyds-triangle.objeck b/Task/Floyds-triangle/Objeck/floyds-triangle.objeck deleted file mode 100644 index 567e784e01..0000000000 --- a/Task/Floyds-triangle/Objeck/floyds-triangle.objeck +++ /dev/null @@ -1,20 +0,0 @@ -class Floyds { - function : Main(args : String[]) ~ Nil { - PrintTriangle(5); - PrintTriangle(14); - } - - function : PrintTriangle(n : Int) ~ Nil { - "{$n} rows:"->PrintLine(); - - rowNum := 1; printMe := 1; numsPrinted := 0; - for(; rowNum <= n; printMe++;){ - "{$printMe}\t"->Print(); - - if(++numsPrinted = rowNum){ - ""->PrintLine(); - rowNum++; numsPrinted := 0; - } - } - } -} diff --git a/Task/Floyds-triangle/PL-M/floyds-triangle.plm b/Task/Floyds-triangle/PL-M/floyds-triangle.plm deleted file mode 100644 index 86f92c8938..0000000000 --- a/Task/Floyds-triangle/PL-M/floyds-triangle.plm +++ /dev/null @@ -1,49 +0,0 @@ -100H: -BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS; -EXIT: PROCEDURE; GO TO 0; END EXIT; -PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT; - - -PUT$NUM: PROCEDURE (N, WIDTH); - DECLARE S (6) BYTE INITIAL (' $'); - DECLARE N ADDRESS, (I, WIDTH) BYTE; - I = 5; -DIGIT: - S(I := I-1) = N MOD 10 + '0'; - IF (N := N/10) > 0 THEN GO TO DIGIT; - DO I=I-1 TO 0 BY -1; - S(I) = ' '; - END; - CALL PRINT(.S(6-WIDTH)); -END PUT$NUM; - -WIDTH: PROCEDURE (N) BYTE; - DECLARE (N, W) BYTE; - W = 1; - DO WHILE N>0; - N = N/10; - W = W+1; - END; - RETURN W; -END WIDTH; - -FLOYD: PROCEDURE (ROWS); - DECLARE (ROWS, ROW, COL) BYTE; - DECLARE (N, MAXNO) ADDRESS; - - MAXNO = ROWS * (ROWS+1)/2; - N = 1; - DO ROW = 1 TO ROWS; - DO COL = 1 TO ROW; - CALL PUT$NUM(N, 1 + WIDTH(MAXNO - ROWS + COL)); - N = N+1; - END; - CALL PRINT(.(13,10,'$')); - END; -END FLOYD; - -CALL FLOYD(5); -CALL PRINT(.(13,10,'$')); -CALL FLOYD(14); -CALL EXIT; -EOF diff --git a/Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas b/Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas deleted file mode 100644 index 4bdce7f681..0000000000 --- a/Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas +++ /dev/null @@ -1,19 +0,0 @@ -procedure FloydTriangle(rows: integer); -begin - var r := 1; - for var i:=1 to rows do - begin - for var j:=1 to i do - begin - Write(r: (j>8 ? 4 : 3)); - r += 1; - end; - Writeln - end; -end; - -begin - FloydTriangle(5); - Writeln; - FloydTriangle(14); -end. diff --git a/Task/Floyds-triangle/Phix/floyds-triangle.phix b/Task/Floyds-triangle/Phix/floyds-triangle.phix index 114ef290dc..590838b99c 100644 --- a/Task/Floyds-triangle/Phix/floyds-triangle.phix +++ b/Task/Floyds-triangle/Phix/floyds-triangle.phix @@ -1,18 +1,20 @@ -with javascript_semantics -procedure Floyds_triangle(integer n) - sequence widths = repeat(0,n) - integer k = (n * (n-1))/2 - for i=1 to n do - widths[i] = sprintf("%%%dd",length(sprintf("%d",i+k))+1) - end for - k = 1 - for i=1 to n do - for j=1 to i do - printf(1,widths[j],k) - k += 1 - end for - printf(1,"\n") - end for -end procedure -Floyds_triangle(5) -Floyds_triangle(14) +(phixonline)--> + with javascript_semantics + procedure Floyds_triangle(integer n) + sequence widths = repeat(0,n) + integer k = (n * (n-1))/2 + for i=1 to n do + widths[i] = sprintf("%%%dd",length(sprintf("%d",i+k))+1) + end for + k = 1 + for i=1 to n do + for j=1 to i do + printf(1,widths[j],k) + k += 1 + end for + printf(1,"\n") + end for + end procedure + Floyds_triangle(5) + Floyds_triangle(14) + + printf(1,"%09.3f\n",7.125) + b ) - - [ over 0 peek - char - = iff - [ dip [ behead drop ] - true unrot ] - else [ false unrot ] - over char . swap find - - char 0 swap of - swap join - swap iff char - - else space - swap join ] is left-pad ( $ n --> $ ) - - [ over char . has not if - [ dip [ char . join ] ] - over char . swap find - dip [ over size ] - 1+ - - - char 0 swap of - join ] is right-pad ( $ n --> $ ) - - [ dip left-pad right-pad ] is format ( $ n n --> $ ) - - ' [ $ "7.125" - $ "-7.125" - $ "0.125" - $ "-0.12" - $ "7.12" - $ "-7.12" - $ "0.12" - $ "-0.12" - $ "7" - $ "-7" - $ "0" ] - witheach - [ do 5 3 format echo$ cr ] diff --git a/Task/Formatted-numeric-output/Rebol/formatted-numeric-output.rebol b/Task/Formatted-numeric-output/REBOL/formatted-numeric-output.rebol similarity index 91% rename from Task/Formatted-numeric-output/Rebol/formatted-numeric-output.rebol rename to Task/Formatted-numeric-output/REBOL/formatted-numeric-output.rebol index 9e47fd18bb..141b175e64 100644 --- a/Task/Formatted-numeric-output/Rebol/formatted-numeric-output.rebol +++ b/Task/Formatted-numeric-output/REBOL/formatted-numeric-output.rebol @@ -1,9 +1,9 @@ -Rebol [ +REBOL [ Title: "Formatted Numeric Output" URL: http://rosettacode.org/wiki/Formatted_Numeric_Output ] -; Rebol has no built-in facilities for printing pictured output. +; REBOL has no built-in facilities for printing pictured output. ; However, it's not too hard to cook something up using the ; string manipulation facilities. diff --git a/Task/Formatted-numeric-output/Rust/formatted-numeric-output.rs b/Task/Formatted-numeric-output/Rust/formatted-numeric-output.rust similarity index 100% rename from Task/Formatted-numeric-output/Rust/formatted-numeric-output.rs rename to Task/Formatted-numeric-output/Rust/formatted-numeric-output.rust diff --git a/Task/Formatted-numeric-output/Scheme/formatted-numeric-output.scm b/Task/Formatted-numeric-output/Scheme/formatted-numeric-output.ss similarity index 100% rename from Task/Formatted-numeric-output/Scheme/formatted-numeric-output.scm rename to Task/Formatted-numeric-output/Scheme/formatted-numeric-output.ss diff --git a/Task/Formatted-numeric-output/TAV/formatted-numeric-output.tav b/Task/Formatted-numeric-output/TAV/formatted-numeric-output.tav deleted file mode 100644 index 2a96b778cc..0000000000 --- a/Task/Formatted-numeric-output/TAV/formatted-numeric-output.tav +++ /dev/null @@ -1,2 +0,0 @@ - print format '%09.3f;' 7.125 - print pad left 7.125 to 9 by '0' diff --git a/Task/Formatted-numeric-output/VBScript/formatted-numeric-output.vbs b/Task/Formatted-numeric-output/VBScript/formatted-numeric-output.vb similarity index 100% rename from Task/Formatted-numeric-output/VBScript/formatted-numeric-output.vbs rename to Task/Formatted-numeric-output/VBScript/formatted-numeric-output.vb diff --git a/Task/Formatted-numeric-output/Wren/formatted-numeric-output.wren b/Task/Formatted-numeric-output/Wren/formatted-numeric-output.wren index 6ce95585d6..ba19bf5ec9 100644 --- a/Task/Formatted-numeric-output/Wren/formatted-numeric-output.wren +++ b/Task/Formatted-numeric-output/Wren/formatted-numeric-output.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var n = 7.125 System.print(Fmt.rjust(9, n, "0")) diff --git a/Task/Fortunate-numbers/ALGOL-68/fortunate-numbers.alg b/Task/Fortunate-numbers/ALGOL-68/fortunate-numbers.alg deleted file mode 100644 index fb7e629305..0000000000 --- a/Task/Fortunate-numbers/ALGOL-68/fortunate-numbers.alg +++ /dev/null @@ -1,40 +0,0 @@ -BEGIN # find some Fortunate numbers m, m is smallest positive integer > 1 # - # where primorial(n) + m is prime for some n # - # as all primorials are even, m must be odd # - - PR precision 2000 PR # set the number of digits for LONG LONG INT # - PR read "primes.incl.a68" PR # include prime utilities # - INT max fortunate = 500; # largeest fortunate number we will consider # - []BOOL is prime = PRIMESIEVE 5 000; - [ 1 : max fortunate ]INT fortunate; FOR i TO max fortunate DO fortunate[ i ] := 0 OD; - INT primorial pos := 0; - LONG LONG INT primorial := 1; - INT prime pos := 0; - WHILE primorial pos < 100 DO - WHILE NOT is prime[ prime pos +:= 1 ] DO SKIP OD; - primorial pos +:= 1; - primorial *:= prime pos; - INT m := 3; - WHILE NOT is probably prime( primorial + m ) AND m <= max fortunate DO m +:= 2 OD; - IF m <= max fortunate THEN - IF fortunate[ m ] = 0 THEN fortunate[ m ] := primorial pos FI - FI - OD; - print( ( "The first 50 Fortunate numbers:", newline ) ); - INT f count := 0; - FOR f TO max fortunate WHILE f count < 50 DO - IF fortunate[ f ] /= 0 THEN - print( ( whole( f, -5 ) ) ); - IF ( f count +:= 1 ) MOD 10 = 0 THEN print( ( newline ) ) FI - FI - OD; - print( ( "The primorial associated with the first 50 Fortunate numbers:", newline ) ); - f count := 0; - FOR f TO max fortunate WHILE f count < 50 DO - IF fortunate[ f ] /= 0 THEN - print( ( whole( fortunate[ f ], -5 ) ) ); - IF ( f count +:= 1 ) MOD 10 = 0 THEN print( ( newline ) ) FI - FI - OD - -END diff --git a/Task/Fortunate-numbers/C++/fortunate-numbers.cpp b/Task/Fortunate-numbers/C++/fortunate-numbers.cpp deleted file mode 100644 index ed355c01af..0000000000 --- a/Task/Fortunate-numbers/C++/fortunate-numbers.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include -#include -#include - -std::vector prime_numbers(const int32_t& limit) { - const int32_t half_limit = ( limit % 2 == 0 ) ? limit / 2 : 1 + limit / 2; - std::vector composite(half_limit, false); - for ( int32_t i = 1, p = 3; i < half_limit; p += 2, ++i ) { - if ( ! composite[i] ) { - for ( int32_t a = i + p; a < half_limit; a += p ) { - composite[a] = true; - } - } - } - - std::vector primes{2}; - for ( int32_t i = 1, p = 3; i < half_limit; p += 2, ++i ) { - if ( ! composite[i] ) { - primes.push_back(p); - } - } - return primes; -} - -bool contains(const std::vector& list, const int32_t& n) { - return std::find(list.begin(), list.end(), n) != list.end(); -} - -int main() { - std::vector primes = prime_numbers(250'000'000); - std::set fortunates; - int32_t primorial = 1; - int32_t index = 0; - - while ( fortunates.size() < 8 ) { - primorial *= primes[index++]; - int32_t candidate = 3; - while ( ! contains(primes, primorial + candidate) ) { - candidate += 2; - } - fortunates.emplace(candidate); - } - - std::cout << "The first 8 distinct fortunate numbers are:" << std::endl; - for ( const int32_t& fortunate : fortunates ) { - std::cout << fortunate << " "; - } -} diff --git a/Task/Fortunate-numbers/C-sharp/fortunate-numbers.cs b/Task/Fortunate-numbers/C-sharp/fortunate-numbers.cs deleted file mode 100644 index 22f95c2071..0000000000 --- a/Task/Fortunate-numbers/C-sharp/fortunate-numbers.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Numerics; - -public class FortunateNumbers -{ - private const int CERTAINTY_LEVEL = 10; - - public static void Main(string[] args) - { - var primes = PrimeSieve(400); - SortedSet fortunates = new SortedSet(); - BigInteger primorial = BigInteger.One; - - foreach (var prime in primes) - { - primorial *= prime; - int candidate = 3; - while (!BigInteger.Add(primorial, candidate).IsProbablyPrime(CERTAINTY_LEVEL)) - { - candidate += 2; - } - fortunates.Add(candidate); - } - - Console.WriteLine("The first 50 distinct fortunate numbers are:"); - int count = 0; - foreach (var fortunate in fortunates) - { - if (count >= 50) break; - Console.Write($"{fortunate,4}{(count % 10 == 9 ? "\n" : "")}"); - count++; - } - } - - private static List PrimeSieve(int aNumber) - { - var sieve = new bool[aNumber + 1]; - var primes = new List(); - - for (int i = 2; i <= aNumber; i++) - { - if (!sieve[i]) - { - primes.Add(i); - for (int j = i * i; j <= aNumber && j > 0; j += i) - { - sieve[j] = true; - } - } - } - return primes; - } -} - -public static class BigIntegerExtensions -{ - private static Random random = new Random(); - - public static bool IsProbablyPrime(this BigInteger source, int certainty) - { - if (source == 2 || source == 3) - return true; - if (source < 2 || source % 2 == 0) - return false; - - BigInteger d = source - 1; - int s = 0; - - while (d % 2 == 0) - { - d /= 2; - s += 1; - } - - for (int i = 0; i < certainty; i++) - { - BigInteger a = RandomBigInteger(2, source - 2); - BigInteger x = BigInteger.ModPow(a, d, source); - if (x == 1 || x == source - 1) - continue; - - for (int r = 1; r < s; r++) - { - x = BigInteger.ModPow(x, 2, source); - if (x == 1) - return false; - if (x == source - 1) - break; - } - - if (x != source - 1) - return false; - } - - return true; - } - - private static BigInteger RandomBigInteger(BigInteger minValue, BigInteger maxValue) - { - if (minValue > maxValue) - throw new ArgumentException("minValue must be less than or equal to maxValue"); - - BigInteger range = maxValue - minValue + 1; - int length = range.ToByteArray().Length; - byte[] buffer = new byte[length]; - - BigInteger result; - do - { - random.NextBytes(buffer); - buffer[buffer.Length - 1] &= 0x7F; // Ensure non-negative - result = new BigInteger(buffer); - } while (result < minValue || result >= maxValue); - - return result; - } -} diff --git a/Task/Fortunate-numbers/EasyLang/fortunate-numbers.easy b/Task/Fortunate-numbers/EasyLang/fortunate-numbers.easy deleted file mode 100644 index dc96747c37..0000000000 --- a/Task/Fortunate-numbers/EasyLang/fortunate-numbers.easy +++ /dev/null @@ -1,43 +0,0 @@ -fastfunc isprim num . - i = 2 - while i <= sqrt num - if num mod i = 0 : return 0 - i += 1 - . - return 1 -. -fastfunc nextprim prim . - repeat - prim += 1 - until isprim prim = 1 - . - return prim -. -proc insert &d[] e . - for i = 1 to len d[] - if d[i] >= e - if d[i] = e : return - break 1 - . - . - d[] &= 0 - for i = len d[] downto i + 1 : d[i] = d[i - 1] - d[i] = e -. -proc fortunates . - maxint = pow 2 53 - primorial = 1 - prim = 2 - repeat - primorial *= prim - until primorial + 1000 >= maxint - prim = nextprim prim - j = 3 - while isprim (primorial + j) = 0 - j = j + 2 - . - insert fortuns[] j - . - for i to 8 : write fortuns[i] & " " -. -fortunates diff --git a/Task/Fortunate-numbers/Java/fortunate-numbers.java b/Task/Fortunate-numbers/Java/fortunate-numbers.java deleted file mode 100644 index e2c379d81e..0000000000 --- a/Task/Fortunate-numbers/Java/fortunate-numbers.java +++ /dev/null @@ -1,41 +0,0 @@ -import java.math.BigInteger; -import java.util.BitSet; -import java.util.NavigableSet; -import java.util.TreeSet; - -public final class FortunateNumbers { - - public static void main(String[] aArgs) { - BitSet primes = primeSieve(400); - NavigableSet fortunates = new TreeSet(); - BigInteger primorial = BigInteger.ONE; - - for ( int prime = 2; prime >= 0; prime = primes.nextSetBit(prime + 1) ) { - primorial = primorial.multiply(BigInteger.valueOf(prime)); - int candidate = 3; - while ( ! primorial.add(BigInteger.valueOf(candidate)).isProbablePrime(CERTAINTY_LEVEL) ) { - candidate += 2; - } - fortunates.add(candidate); - } - - System.out.println("The first 50 distinct fortunate numbers are:"); - for ( int i = 0; i < 50; i++ ) { - System.out.print(String.format("%4d%s", fortunates.pollFirst(), ( i % 10 == 9 ? "\n" : "" ))); - } - } - - private static BitSet primeSieve(int aNumber) { - BitSet sieve = new BitSet(aNumber + 1); - sieve.set(2, aNumber + 1); - for ( int i = 2; i <= Math.sqrt(aNumber); i = sieve.nextSetBit(i + 1) ) { - for ( int j = i * i; j <= aNumber; j = j + i ) { - sieve.clear(j); - } - } - return sieve; - } - - private static final int CERTAINTY_LEVEL = 10; - -} diff --git a/Task/Fortunate-numbers/Julia/fortunate-numbers.jl b/Task/Fortunate-numbers/Julia/fortunate-numbers.julia similarity index 100% rename from Task/Fortunate-numbers/Julia/fortunate-numbers.jl rename to Task/Fortunate-numbers/Julia/fortunate-numbers.julia diff --git a/Task/Fortunate-numbers/Phix/fortunate-numbers.phix b/Task/Fortunate-numbers/Phix/fortunate-numbers.phix index 0ac49b90d9..4caa77d229 100644 --- a/Task/Fortunate-numbers/Phix/fortunate-numbers.phix +++ b/Task/Fortunate-numbers/Phix/fortunate-numbers.phix @@ -1,18 +1,20 @@ -with javascript_semantics -include mpfr.e -mpz primorial = mpz_init(1), - pj = mpz_init() -sequence fortunates = {} -for p=1 to 75 do - mpz_mul_si(primorial,primorial,get_prime(p)) - integer j = 3 - mpz_add_si(pj,primorial,3) - while not mpz_prime(pj) do - mpz_add_si(pj,pj,2) - j = j + 2 - end while - fortunates &= j -end for -fortunates = unique(deep_copy(fortunates))[1..50] -fortunates = join_by(apply(true,sprintf,{{"%3d"},fortunates}),1,10) -printf(1,"The first 50 distinct fortunate numbers are:\n%s\n",{fortunates}) +(phixonline)--> + with javascript_semantics + include mpfr.e + mpz primorial = mpz_init(1), + pj = mpz_init() + sequence fortunates = {} + for p=1 to 75 do + mpz_mul_si(primorial,primorial,get_prime(p)) + integer j = 3 + mpz_add_si(pj,primorial,3) + while not mpz_prime(pj) do + mpz_add_si(pj,pj,2) + j = j + 2 + end while + fortunates &= j + end for + fortunates = unique(deep_copy(fortunates))[1..50] + fortunates = join_by(apply(true,sprintf,{{"%3d"},fortunates}),1,10) + printf(1,"The first 50 distinct fortunate numbers are:\n%s\n",{fortunates}) + + with javascript_semantics + function fwd_diff_n(sequence s, integer order) + assert(order<length(s)) + s = deep_copy(s) + for i=1 to order do + for j=1 to length(s)-1 do + s[j] = s[j+1]-s[j] + end for + s = s[1..-2] + end for + return s + end function -constant s = {90, 47, 58, 29, 22, 32, 55, 5, 55, 73} -for i=1 to 9 do - ?fwd_diff_n(s,i) -end for + constant s = {90, 47, 58, 29, 22, 32, 55, 5, 55, 73} + for i=1 to 9 do + ?fwd_diff_n(s,i) + end for + + with javascript_semantics + function xor_gate(bool a, bool b) + return (a and not b) or (not a and b) + end function -printf(1," inf: %f\n",{inf}) -printf(1," ninf: %f\n",{ninf}) -printf(1," nan: %f\n",{nan}) -printf(1,"*nzero: %f\n",{nzero}) -printf(1," inf+2: %f\n",{inf+2}) -printf(1," inf+ninf: %f\n",{inf+ninf}) -printf(1," 0*inf: %f\n",{0*inf}) -printf(1," nan+1: %f\n",{nan+1}) -printf(1," nan+nan: %f\n",{nan+nan}) -printf(1," inf>1e300: %d\n",{inf>1e300}) -printf(1," ninf<1e300: %d\n",{ninf<-1e300}) -printf(1,"*nan=nan: %d\n",{nan=nan}) -printf(1," nan=42: %d\n",{nan=42}) -printf(1,"*nan<0: %d\n",{nan<0}) -printf(1," nan>0: %d\n",{nan>0}) + function half_adder(bool a, bool b) + bool s = xor_gate(a,b), + c = a and b + return {s,c} + end function + + function full_adder(bool a, bool b, bool c) + bool {s1,c1} = half_adder(c,a), + {s2,c2} = half_adder(s1,b) + c = c1 or c2 + return {s2,c} + end function + + function four_bit_adder(bool a0, a1, a2, a3, b0, b1, b2, b3) + bool s0,s1,s2,s3,c + {s0,c} = full_adder(a0,b0,0) + {s1,c} = full_adder(a1,b1,c) + {s2,c} = full_adder(a2,b2,c) + {s3,c} = full_adder(a3,b3,c) + return {s3,s2,s1,s0,c} + end function + + procedure test(integer a, integer b) + bool {a0,a1,a2,a3} = int_to_bits(a,4), + {b0,b1,b2,b3} = int_to_bits(b,4), + {r3,r2,r1,r0,c} = four_bit_adder(a0,a1,a2,a3,b0,b1,b2,b3) + integer r = bits_to_int({r0,r1,r2,r3}) + string s = iff(c?sprintf(" [=%d+16]",r):"") + printf(1,"%04b + %04b = %04b %b (%d+%d=%d%s)\n",{a,b,r,c,a,b,c*16+r,s}) + end procedure + + test(0,0) + test(0,1) + test(0b1111,0b1111) + test(3,7) + test(11,8) + test(0b1100,0b1100) + test(0b1100,0b1101) + test(0b1100,0b1110) + test(0b1100,0b1111) + test(0b1101,0b0000) + test(0b1101,0b0001) + test(0b1101,0b0010) + test(0b1101,0b0011) + a^b ) - - [ 2dup and - dip xor ] is halfadder ( a b --> s c ) - - [ halfadder - dip halfadder or ] is fulladder ( a b c --> s c ) - - [ 4 pack reverse unpack - 4 times [ temp put ] - 4 pack reverse - 0 swap witheach - [ temp take fulladder ] - 5 pack reverse unpack ] is 4bitadder ( b3 b2 b1 b0 a3 a2 a1 a0 --> c s3 s2 s1 s0 ) - - say "1100 + 1100 = " - 1 1 0 0 1 1 0 0 4bitadder - 5 pack witheach echo - cr - say "1100 + 1101 = " - 1 1 0 0 1 1 0 1 4bitadder - 5 pack witheach echo - cr - say "1100 + 1110 = " - 1 1 0 0 1 1 1 0 4bitadder - 5 pack witheach echo - cr - say "1100 + 1111 = " - 1 1 0 0 1 1 1 1 4bitadder - 5 pack witheach echo - cr - say "1101 + 0000 = " - 1 1 0 1 0 0 0 0 4bitadder - 5 pack witheach echo - cr - say "1101 + 0001 = " - 1 1 0 1 0 0 0 1 4bitadder - 5 pack witheach echo - cr - say "1101 + 0010 = " - 1 1 0 1 0 0 1 0 4bitadder - 5 pack witheach echo - cr - say "1101 + 0011 = " - 1 1 0 1 0 0 1 1 4bitadder - 5 pack witheach echo - cr diff --git a/Task/Four-bit-adder/Rust/four-bit-adder.rs b/Task/Four-bit-adder/Rust/four-bit-adder.rust similarity index 100% rename from Task/Four-bit-adder/Rust/four-bit-adder.rs rename to Task/Four-bit-adder/Rust/four-bit-adder.rust diff --git a/Task/Four-bit-adder/Scheme/four-bit-adder.scm b/Task/Four-bit-adder/Scheme/four-bit-adder.ss similarity index 100% rename from Task/Four-bit-adder/Scheme/four-bit-adder.scm rename to Task/Four-bit-adder/Scheme/four-bit-adder.ss diff --git a/Task/Four-bit-adder/VHDL/four-bit-adder-1.vhd b/Task/Four-bit-adder/VHDL/four-bit-adder-1.vhdl similarity index 100% rename from Task/Four-bit-adder/VHDL/four-bit-adder-1.vhd rename to Task/Four-bit-adder/VHDL/four-bit-adder-1.vhdl diff --git a/Task/Four-bit-adder/VHDL/four-bit-adder-2.vhd b/Task/Four-bit-adder/VHDL/four-bit-adder-2.vhdl similarity index 100% rename from Task/Four-bit-adder/VHDL/four-bit-adder-2.vhd rename to Task/Four-bit-adder/VHDL/four-bit-adder-2.vhdl diff --git a/Task/Four-is-magic/ALGOL-68/four-is-magic.alg b/Task/Four-is-magic/ALGOL-68/four-is-magic.alg deleted file mode 100644 index acc82a0e68..0000000000 --- a/Task/Four-is-magic/ALGOL-68/four-is-magic.alg +++ /dev/null @@ -1,79 +0,0 @@ -BEGIN # construct number names from a number # - MODE NUMBER = LONG INT; # adjust to suit, must be at least 64 bits # - OP TOINT = ( NUMBER n )INT: SHORTEN n; # adjust to suit # - []STRING units - = ( "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" ); - []STRING teens - = ( "ten", "eleven", "twelve", "thirteen", "fourteen" - , "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" - ); - []STRING tens - = ( "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" ); - []STRING power suffix - = ( "thousand", "million", "billion", "trillion", "quadrillion", "quintillion" ); - # returns n converted to a number name, n must be in range 1-99 # - PROC two digits = ( INT n )STRING: - IF n < 10 - THEN units[ n ] - ELIF n < 20 - THEN teens[ n - 9 ] - ELIF INT last1 = n MOD 10; - last1 = 0 - THEN tens[ ( n OVER 10 ) - 1 ] - ELSE tens[ ( n OVER 10 ) - 1 ] + " " + units[ last1 ] - FI # two digits # ; - # returns n converted to a number name, n must be in range 1-999 # - PROC three digits = ( INT n )STRING: - IF n < 100 - THEN two digits( n ) - ELIF STRING hundreds = units[ n OVER 100 ] + " hundred"; - INT last2 = n MOD 100; - last2 = 0 - THEN hundreds - ELSE hundreds + " " + two digits( last2 ) - FI # three digits # ; - # returns the "name" of n # - OP NAME = ( NUMBER n )STRING: - IF n < 0 THEN "negative " + NAME - n - ELIF n = 0 THEN "zero" - ELSE # have a positive number to name # - NUMBER v := n; - STRING result := ""; - INT power pos := 0; - WHILE v /= 0 DO - IF INT v999 = TOINT ( v MOD 1000 ); - v999 /= 0 - THEN STRING component := three digits( v999 ); - IF power pos > 0 THEN - component +:= " " + power suffix[ power pos ] - FI; - IF result /= "" THEN component +:= " " FI; - component +=: result - FI; - power pos +:= 1; - v OVERAB 1000 - OD; - result - FI # NAME # ; - # returns the "x is y, y is z, ... four is magic" sequence derived from n # - OP MAGIC = ( NUMBER n )STRING: - BEGIN - NUMBER v := n; - STRING result := ""; - WHILE v /= 4 DO - IF result /= "" THEN result +:= ", " FI; - STRING v name = NAME v; - v := ( UPB v name - LWB v name ) + 1; - result +:= v name + " is " + NAME v - OD; - IF result /= "" THEN result +:= ", " FI; - result + "four is magic" - END # MAGIC # ; - # test cases # - []NUMBER t = ( 0, 1, 2, 3, 4, 5, 100, 101, 272, 1701, 1968, 4077, 90 210 - , - 100 001, 987 654, - NUMBER( 8 007 006 005 004 003 ) - ); - FOR n FROM LWB t TO UPB t DO - print( ( whole( t[ n ], -18 ), ": ", MAGIC t[ n ], newline ) ) - OD -END diff --git a/Task/Four-is-magic/Common-Lisp/four-is-magic.lisp b/Task/Four-is-magic/Common-Lisp/four-is-magic.lisp index 4f8ab2f47b..d8fa958084 100644 --- a/Task/Four-is-magic/Common-Lisp/four-is-magic.lisp +++ b/Task/Four-is-magic/Common-Lisp/four-is-magic.lisp @@ -5,6 +5,3 @@ while (/= n 4) do (format out "~A is ~R, " c (length c)) finally (format out "four is magic."))))) -(loop for n - in '( -1 0 1 2 3 4 5 6 7 8 9 11 21 1995 1000000 1234567890 1100100100100 ) - do (print (integer-to-text n))) diff --git a/Task/Four-is-magic/Crystal/four-is-magic.cr b/Task/Four-is-magic/Crystal/four-is-magic.cr deleted file mode 100644 index dc96957870..0000000000 --- a/Task/Four-is-magic/Crystal/four-is-magic.cr +++ /dev/null @@ -1,59 +0,0 @@ -struct Int - THOU_PREFIXES = %w(undec dec non oct sept sext quint quadr tr b m) - .map(&.+("illion")) + ["thousand", ""] - TENS = ["", ""] + %w(twen thir for fif six seven eigh nine).map &.+("ty") - ONES = [""] + %w(one two three four five six seven eight nine ten) + - %w(eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen) - def to_words - raise "Number to big to express in words" unless self.abs <= Int128::MAX - return "zero" if self == 0 - String.build do |s| - n = self - if n < 0 - s << "negative " - n = n.abs - end - ths = Array(Int128).new(THOU_PREFIXES.size, 0) - (0...ths.size).reverse_each do |idx| - n, ths[idx] = n.divmod(1000) - end - ths.zip(THOU_PREFIXES).each do |th, pref| - next if th == 0 - hundreds, rest = th.divmod 100 - s << ONES[hundreds] << " hundred " if hundreds > 0 - if rest < 20 - s << ONES[rest] << " " if rest > 0 - else - tens, ones = rest.divmod 10 - s << TENS[tens] - s << "-" << ONES[ones] if ones > 0 - s << " " - end - s << pref << " " if pref != "" - end - s.chomp! 32u8 - end - end -end - -def sequence (io, n) - words = n.to_words.capitalize - loop do - io << words << " is " - break if n == 4 - n = words.size - words = n.to_words - io << words << ", " - end - io << "magic." -end - -def sequence (n) - String.build do |s| - sequence s, n - end -end - -[0, 4, 6, 11, 13, 75, 337, -164, 9_876_543_209, Int128::MAX].each do |start| - puts "- " + sequence(start) -end diff --git a/Task/Four-is-magic/Delphi/four-is-magic.pas b/Task/Four-is-magic/Delphi/four-is-magic.delphi similarity index 100% rename from Task/Four-is-magic/Delphi/four-is-magic.pas rename to Task/Four-is-magic/Delphi/four-is-magic.delphi diff --git a/Task/Four-is-magic/EasyLang/four-is-magic.easy b/Task/Four-is-magic/EasyLang/four-is-magic.easy deleted file mode 100644 index c37be2eb43..0000000000 --- a/Task/Four-is-magic/EasyLang/four-is-magic.easy +++ /dev/null @@ -1,63 +0,0 @@ -small$[] = [ "zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" "nineteen" ] -tens$[] = [ "" "" "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety" ] -illions$[] = [ "" " thousand" " million" " billion" " trillion" " quadrillion" " quintillion" ] -func$ say n . - if n < 0 - t$ = "negative " - n = -n - . - if n < 20 - t$ &= small$[n + 1] - elif n < 100 - t$ &= tens$[n div 10 + 1] - s = n mod 10 - if s > 0 - t$ &= "-" & small$[s + 1] - . - elif n < 1000 - t$ &= small$[n div 100 + 1] & " hundred" - s = n mod 100 - if s > 0 - t$ &= " " & say s - . - else - i = 1 - while n > 0 - p = n mod 1000 - n = n div 1000 - if p > 0 - ix$ = say p & illions$[i] - if sx$ <> "" - ix$ &= " " & sx$ - . - sx$ = ix$ - . - i += 1 - . - t$ &= sx$ - . - return t$ -. -# -func$ toupper c$ . - c = strcode c$ - if c >= 97 and c <= 122 - c$ = strchar (c - 32) - . - return c$ -. -func$ four_is_magic n . - s$ = say n - s$ = toupper substr s$ 1 1 & substr s$ 2 99999 - t$ = s$ - while n <> 4 - n = len s$ - s$ = say n - t$ &= " is " & s$ & ", " & s$ - . - t$ &= " is magic." - return t$ -. -for n in [ 6 13 75 111 337 99999999 ] - print four_is_magic n -. diff --git a/Task/Four-is-magic/FutureBasic/four-is-magic.basic b/Task/Four-is-magic/FutureBasic/four-is-magic.basic deleted file mode 100644 index eb12b04ea0..0000000000 --- a/Task/Four-is-magic/FutureBasic/four-is-magic.basic +++ /dev/null @@ -1,31 +0,0 @@ -include "NSLog.incl" - -local fn FourIsMagic( number as CFNumberRef ) as CFStringRef - CFMutableStringRef result = fn MutableStringNew - NumberFormatterRef formatter = fn NumberFormatterWithStyle( NSNumberFormatterSpellOutStyle ) - NumberFormatterSetLocale( formatter, fn LocaleWithIdentifier( @"en_EN" ) ) - CFStringRef numberString = fn NumberFormatterStringFromNumber( formatter, number ) - MutableStringAppendString( result, fn StringCapitalizedString( numberString ) ) - - while ( fn StringIsEqual( numberString, @"four" ) == NO ) - numberString = fn NumberFormatterStringFromNumber( formatter, fn NumberWithInteger( len(numberString) ) ) - MutableStringAppendString( result, fn StringWithFormat( @" is %@, %@", numberString, numberString ) ) - wend - MutableStringAppendString( result, @" is magic." ) -end fn = result - -NSInteger i -CFNumberRef testInput -CFArrayRef testNumbers : testNumbers = @[@23, @1000000000, @20140, @100, @130, @151, @-7] - -NSLog( @"Outputs 0 through 9:\n" ) -for i = 0 to 9 - NSLog( @"%@", fn FourIsMagic( fn NumberWithInteger( i ) ) ) -next - -NSLog( @"\nOther number tests:\n" ) -for testInput in testNumbers - NSLog( @"%@", fn FourIsMagic( testInput ) ) -next - -HandleEvents diff --git a/Task/Four-is-magic/Julia/four-is-magic.jl b/Task/Four-is-magic/Julia/four-is-magic.julia similarity index 100% rename from Task/Four-is-magic/Julia/four-is-magic.jl rename to Task/Four-is-magic/Julia/four-is-magic.julia diff --git a/Task/Four-is-magic/Kotlin/four-is-magic.kts b/Task/Four-is-magic/Kotlin/four-is-magic.kotlin similarity index 100% rename from Task/Four-is-magic/Kotlin/four-is-magic.kts rename to Task/Four-is-magic/Kotlin/four-is-magic.kotlin diff --git a/Task/Four-is-magic/M2000-Interpreter/four-is-magic.m2000 b/Task/Four-is-magic/M2000-Interpreter/four-is-magic.m2000 deleted file mode 100644 index 08efda8634..0000000000 --- a/Task/Four-is-magic/M2000-Interpreter/four-is-magic.m2000 +++ /dev/null @@ -1,67 +0,0 @@ -module Four_is_magic { - numname=lambda ->{ - flush - data "", "one", "two", "three", "four" - data "five", "six", "seven", "eight", "nine", "ten" - data "eleven", "twelve", "thirteen", "fourteen", "fifteen" - data "sixteen", "seventeen","eighteen", "nineteen" - dim lows(), tens(), lev() - lows()=array([]) - data "", "", "twenty", "thirty", "forty","fifty", "sixty" - data "seventy", "eighty", "ninety" - tens()=array([]) - lev()=("", "thousand", "million", "billion") - =lambda lows(), tens(), lev() (n as long) -> { - if n=0 then ="zero": exit - long i, tr : boolean t : string ret, prefix - if n < 0 then prefix= "negative ": n-! else prefix="" - while n>0 {push n mod 1000: n|div 1000} - t=stack.size>1 - while not empty { - tripn="" : read tr : if tr=0 then continue - lt= tr mod 100 : h= tr div 100 - if lt<20 then - tripn+=lows(lt) - else - tripn=tens(lt div 10)+if$(lt mod 10 >0 ->"-"+lows(lt mod 10),"") - end if - if h>0 then tripn = lows(h)+" hundred " + tripn - if empty then if t and h = 0 then tripn = " and " + tripn - ret+=tripn+" "+lev(stack.size)+" " - } - =prefix+trim$(ret) - } - }() - TitleStr=lambda (s as string) ->{ - =ucase$(left$(s,1))+mid$(s, 2) - } - magic=lambda numname, TitleStr (n as integer)-> { - first$=numname(n) - count$=numname(len(first$)) - while first$<>"four" - data first$+" is "+count$ - swap first$, count$ - count$=numname(len(first$)) - end while - data "four is magic." - =TitleStr(array([])#str$(", ")) - } - document doc$ - for i=0 to 9 - doc$ = magic(i)+{ - } - next - doc$ = magic(23)+{ - } - doc$ = magic(130)+{ - } - doc$ = magic(151)+{ - } - doc$ = magic(-7)+{ - } - doc$ = magic(20140)+{ - } - report doc$ - clipboard doc$ -} -Four_is_magic diff --git a/Task/Four-is-magic/Phix/four-is-magic.phix b/Task/Four-is-magic/Phix/four-is-magic.phix index e826307ded..0fb9f78183 100644 --- a/Task/Four-is-magic/Phix/four-is-magic.phix +++ b/Task/Four-is-magic/Phix/four-is-magic.phix @@ -1,77 +1,80 @@ -with javascript_semantics -constant twenties = {"zero","one","two","three","four","five","six","seven","eight","nine","ten", - "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"}, - decades = {"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"} +(phixonline)--> + with javascript_semantics + --<adapted from demo\rosetta\number_names.exw, which alas outputs ",", "and", uses "minus" instead of "negative", etc...> + constant twenties = {"zero","one","two","three","four","five","six","seven","eight","nine","ten", + "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"}, + decades = {"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"} -function hundred(integer n) - if n<20 then - return twenties[mod(n,20)+1] - elsif mod(n,10)=0 then - return decades[mod(floor(n/10),10)-1] - end if - return decades[mod(floor(n/10),10)-1] & '-' & twenties[mod(n,10)+1] -end function + function hundred(integer n) + if n<20 then + return twenties[mod(n,20)+1] + elsif mod(n,10)=0 then + return decades[mod(floor(n/10),10)-1] + end if + return decades[mod(floor(n/10),10)-1] & '-' & twenties[mod(n,10)+1] + end function -function thousand(integer n) - if n<100 then - return hundred(n) - elsif mod(n,100)=0 then - return twenties[mod(floor(n/100),20)+1]&" hundred" - end if - return twenties[mod(floor(n/100),20)+1] & " hundred " & hundred(mod(n,100)) -end function + function thousand(integer n) + if n<100 then + return hundred(n) + elsif mod(n,100)=0 then + return twenties[mod(floor(n/100),20)+1]&" hundred" + end if + return twenties[mod(floor(n/100),20)+1] & " hundred " & hundred(mod(n,100)) + end function -constant orders = {{power(10,12),"trillion"}, - {power(10,9),"billion"}, - {power(10,6),"million"}, - {power(10,3),"thousand"}} + constant orders = {{power(10,12),"trillion"}, + {power(10,9),"billion"}, + {power(10,6),"million"}, + {power(10,3),"thousand"}} -function triplet(integer n) - string res = "" - for i=1 to length(orders) do - {atom order, string name} = orders[i] - atom high = floor(n/order), - low = mod(n,order) - if high!=0 then - res &= thousand(high)&' '&name - end if - n = low - if low=0 then exit end if - if length(res) and high!=0 then - res &= " " - end if - end for - if n!=0 or res="" then - res &= thousand(floor(n)) - end if - return res -end function + function triplet(integer n) + string res = "" + for i=1 to length(orders) do + {atom order, string name} = orders[i] + atom high = floor(n/order), + low = mod(n,order) + if high!=0 then + res &= thousand(high)&' '&name + end if + n = low + if low=0 then exit end if + if length(res) and high!=0 then + res &= " " + end if + end for + if n!=0 or res="" then + res &= thousand(floor(n)) + end if + return res + end function -function spell(integer n) - string res = "" - if n<0 then - res = "negative " - n = -n - end if - res &= triplet(n) - return res -end function --- + function spell(integer n) + string res = "" + if n<0 then + res = "negative " + n = -n + end if + res &= triplet(n) + return res + end function + --</adapted from number_names.exw> -function fourIsMagic(atom n) - string s = spell(n) - s[1] = upper(s[1]) - string t = s - while n!=4 do - n = length(s) - s = spell(n) - t &= " is " & s & ", " & s - end while - t &= " is magic.\n" - return t -end function + function fourIsMagic(atom n) + string s = spell(n) + s[1] = upper(s[1]) + string t = s + while n!=4 do + n = length(s) + s = spell(n) + t &= " is " & s & ", " & s + end while + t &= " is magic.\n" + return t + end function -constant tests = {-7, -1, 0, 1, 2, 3, 4, 23, 1e9, 20140, 100, 130, 151, 999999} -for i=1 to length(tests) do - puts(1,fourIsMagic(tests[i])) -end for + constant tests = {-7, -1, 0, 1, 2, 3, 4, 23, 1e9, 20140, 100, 130, 151, 999999} + for i=1 to length(tests) do + puts(1,fourIsMagic(tests[i])) + end for + %d/%d (removed %d)".fmt(xn,xd,yn,yd,k+1)); - } - } + foreach k in ([0..8]){ + yn,yd := rn[k],rd[k]; + if(yn!=0 and yd!=0 and + xn.toFloat()/xd.toFloat() == yn.toFloat()/yd.toFloat()){ + count+=1; + omitted[k]+=1; + if(count<=12) + println("%d/%d --> %d/%d (removed %d)".fmt(xn,xd,yn,yd,k+1)); + } + } } } println("%d-digit fractions found: %d, omitted %s\n" diff --git a/Task/Fractran/ALGOL-68/fractran.alg b/Task/Fractran/ALGOL-68/fractran.alg index 2908205a60..c1d894374e 100644 --- a/Task/Fractran/ALGOL-68/fractran.alg +++ b/Task/Fractran/ALGOL-68/fractran.alg @@ -1,6 +1,6 @@ # as the numbers required for finding the first 20 primes are quite large, # -# we use Algol 68G's LONG LONG INT with a precision of 200 digits # -PR precision 200 PR +# we use Algol 68G's LONG LONG INT with a precision of 100 digits # +PR precision 100 PR # mode to hold fractions # MODE FRACTION = STRUCT( INT numerator, INT denominator ); @@ -9,16 +9,16 @@ MODE FRACTION = STRUCT( INT numerator, INT denominator ); OP / = ( INT a, b )FRACTION: ( a, b ); # mode to define a FRACTRAN progam # -MODE FRACTRAN = STRUCT( [0]FRACTION data +MODE FRACTRAN = STRUCT( FLEX[0]FRACTION data , LONG LONG INT n , BOOL halted ); # prepares a FRACTRAN program for use - sets the initial value of n and halted to FALSE # PRIO STARTAT = 1; -OP STARTAT = ( REF FRACTRAN f, INT start p )REF FRACTRAN: +OP STARTAT = ( REF FRACTRAN f, INT start )REF FRACTRAN: BEGIN halted OF f := FALSE; - n OF f := start p; + n OF f := start; f END; @@ -39,39 +39,36 @@ OP NEXT = ( REF FRACTRAN f )LONG LONG INT: FI ; # generate and print the sequence of numbers from a FRACTRAN pogram # -PROC print fractran sequence = ( REF FRACTRAN f, INT start p, INT limit )VOID: +PROC print fractran sequence = ( REF FRACTRAN f, INT start, INT limit )VOID: BEGIN - VOID( f STARTAT start p ); - print( ( "0: ", whole( start p, 0 ) ) ); + VOID( f STARTAT start ); + print( ( "0: ", whole( start, 0 ) ) ); FOR i TO limit WHILE VOID( NEXT f ); NOT halted OF f DO - print( ( " ", whole( i, 0 ), ":", whole( n OF f, 0 ) ) ) + print( ( " " + whole( i, 0 ) + ": " + whole( n OF f, 0 ) ) ) OD; print( ( newline ) ) END ; # print the first 16 elements from the primes FRACTRAN program # -FRACTRAN pf := ( ( 17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17, 11/13 - , 13/11, 15/14, 15/2, 55/1 ), 0, FALSE ); +FRACTRAN pf := ( ( 17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1 ), 0, FALSE ); print fractran sequence( pf, 2, 15 ); # find some primes using the pf FRACTRAN progam - n is prime for the members in the sequence that are 2^n # -BEGIN - INT primes found := 0; - VOID( pf STARTAT 2 ); - INT pos := 0; - print( ( "seq position prime sequence value", newline ) ); - WHILE primes found < 20 AND NOT halted OF pf DO - LONG LONG INT value := NEXT pf; - INT power of 2 := 0; - pos +:= 1; - WHILE value MOD 2 = 0 AND value > 0 DO power of 2 PLUSAB 1; value OVERAB 2 OD; - IF value = 1 THEN - primes found +:= 1; - print( ( whole( pos, -12 ), " ", whole( power of 2, -6 ) ) ); - print( ( " (" + whole( n OF pf, 0 ), ")", newline ) ) - FI - OD -END +INT primes found := 0; +VOID( pf STARTAT 2 ); +INT pos := 0; +print( ( "seq position prime sequence value", newline ) ); +WHILE primes found < 20 AND NOT halted OF pf DO + LONG LONG INT value := NEXT pf; + INT power of 2 := 0; + pos +:= 1; + WHILE value MOD 2 = 0 AND value > 0 DO power of 2 PLUSAB 1; value OVERAB 2 OD; + IF value = 1 THEN + # found a prime # + primes found +:= 1; + print( ( whole( pos, -12 ) + " " + whole( power of 2, -6 ) + " (" + whole( n OF pf, 0 ) + ")", newline ) ) + FI +OD diff --git a/Task/Fractran/Ada/fractran.ada b/Task/Fractran/Ada/fractran.ada new file mode 100644 index 0000000000..90f1a8e4db --- /dev/null +++ b/Task/Fractran/Ada/fractran.ada @@ -0,0 +1,43 @@ +with Ada.Text_IO; + +procedure Fractan is + + type Fraction is record Nom: Natural; Denom: Positive; end record; + type Frac_Arr is array(Positive range <>) of Fraction; + + function "/" (N: Natural; D: Positive) return Fraction is + Frac: Fraction := (Nom => N, Denom => D); + begin + return Frac; + end "/"; + + procedure F(List: Frac_Arr; Start: Positive; Max_Steps: Natural) is + N: Positive := Start; + J: Positive; + begin + Ada.Text_IO.Put(" 0:" & Integer'Image(N) & " "); + for I in 1 .. Max_Steps loop + J := List'First; + loop + if N mod List(J).Denom = 0 then + N := (N/List(J).Denom) * List(J).Nom; + exit; -- found fraction + elsif J >= List'Last then + return; -- did try out all fractions + else + J := J + 1; -- try the next fraction + end if; + end loop; + Ada.Text_IO.Put(Integer'Image(I) & ":" & Integer'Image(N) & " "); + end loop; + end F; + +begin + -- F((2/3, 7/2, 1/5, 1/7, 1/9, 1/4, 1/8), 2, 100); + -- output would be "0: 2 1: 7 2: 1" and then terminate + + F((17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, + 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1), + 2, 15); + -- output is "0: 2 1: 15 2: 825 3: 725 ... 14: 132 15: 116" +end Fractan; diff --git a/Task/Fractran/Ada/fractran.adb b/Task/Fractran/Ada/fractran.adb deleted file mode 100644 index b80338cfca..0000000000 --- a/Task/Fractran/Ada/fractran.adb +++ /dev/null @@ -1,43 +0,0 @@ -with Ada.Text_IO; - -procedure Fractan is - - type Fraction is record Nom: Natural; Denom: Positive; end record; - type Frac_Arr is array(Positive range <>) of Fraction; - - function "/" (N: Natural; D: Positive) return Fraction is - Frac: Fraction := (Nom => N, Denom => D); - begin - return Frac; - end "/"; - - procedure F(List: Frac_Arr; Start: Positive; Max_Steps: Natural) is - N: Positive := Start; - J: Positive; - begin - Ada.Text_IO.Put(" 0:" & Integer'Image(N) & " "); - for I in 1 .. Max_Steps loop - J := List'First; - loop - if N mod List(J).Denom = 0 then - N := (N/List(J).Denom) * List(J).Nom; - exit; -- found fraction - elsif J >= List'Last then - return; -- did try out all fractions - else - J := J + 1; -- try the next fraction - end if; - end loop; - Ada.Text_IO.Put(Integer'Image(I) & ":" & Integer'Image(N) & " "); - end loop; - end F; - -begin - -- F((2/3, 7/2, 1/5, 1/7, 1/9, 1/4, 1/8), 2, 100); - -- output would be "0: 2 1: 7 2: 1" and then terminate - - F((17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, - 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1), - 2, 15); - -- output is "0: 2 1: 15 2: 825 3: 725 ... 14: 132 15: 116" -end Fractan; diff --git a/Task/Fractran/Batch-File/fractran.bat b/Task/Fractran/Batch-File/fractran.bat index 75fe098b0a..956eee44cc 100644 --- a/Task/Fractran/Batch-File/fractran.bat +++ b/Task/Fractran/Batch-File/fractran.bat @@ -1,41 +1,41 @@ @echo off setlocal enabledelayedexpansion - ::Set the inputs + ::Set the inputs set "code=17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1" set "n=2" - ::Basic validation of code + ::Basic validation of code for %%. in (!code!) do ( - echo.%%.|findstr /r /c:"^[0-9][0-9]*/[1-9][0-9]*$">nul||goto error_code + echo.%%.|findstr /r /c:"^[0-9][0-9]*/[1-9][0-9]*$">nul||goto error_code ) - ::Validate the input + ::Validate the input set /a "tst=1*!n!" 2>nul if !tst! lss 0 goto error_input if !tst! equ 0 (if not "!n!"=="0" (goto error_input)) - ::Set the limit outputs - set limit=20 + ::Set the limit outputs + set limit=20 - ::Execute the code + ::Execute the code echo.Input: -echo. !n! +echo. !n! echo.Output: for /l %%? in (1,1,!limit!) do ( - set shouldwehalt=1 - for %%A in (!code!) do ( - for /f "tokens=1,2 delims=/" %%B in ("%%A") do ( - set /a "tst=!n! %% %%C" - if !tst! equ 0 ( - if !shouldwehalt! equ 1 ( - set shouldwehalt=0 - set /a "n=n*%%B/%%C" - echo. !n! - ) - ) - ) - ) - if !shouldwehalt! equ 1 goto halt + set shouldwehalt=1 + for %%A in (!code!) do ( + for /f "tokens=1,2 delims=/" %%B in ("%%A") do ( + set /a "tst=!n! %% %%C" + if !tst! equ 0 ( + if !shouldwehalt! equ 1 ( + set shouldwehalt=0 + set /a "n=n*%%B/%%C" + echo. !n! + ) + ) + ) + ) + if !shouldwehalt! equ 1 goto halt ) :halt diff --git a/Task/Fractran/C++/fractran.cpp b/Task/Fractran/C++/fractran.cpp index a3d5f34195..0f68fa192b 100644 --- a/Task/Fractran/C++/fractran.cpp +++ b/Task/Fractran/C++/fractran.cpp @@ -16,44 +16,44 @@ public: copy( istream_iterator( iss ), istream_iterator(), back_inserter >( tmp ) ); string item; vector< pair > v; - pair a; - for( vector::iterator i = tmp.begin(); i != tmp.end(); i++ ) - { - string::size_type pos = ( *i ).find( '/', 0 ); - if( pos != std::string::npos ) - { - a = make_pair( atof( ( ( *i ).substr( 0, pos ) ).c_str() ), atof( ( ( *i ).substr( pos + 1 ) ).c_str() ) ); - v.push_back( a ); - } - } - - exec( &v ); + pair a; + for( vector::iterator i = tmp.begin(); i != tmp.end(); i++ ) + { + string::size_type pos = ( *i ).find( '/', 0 ); + if( pos != std::string::npos ) + { + a = make_pair( atof( ( ( *i ).substr( 0, pos ) ).c_str() ), atof( ( ( *i ).substr( pos + 1 ) ).c_str() ) ); + v.push_back( a ); + } + } + + exec( &v ); } private: void exec( vector< pair >* v ) { - int cnt = 0; - while( cnt < limit ) - { - cout << cnt << " : " << start << "\n"; - cnt++; - vector< pair >::iterator it = v->begin(); - bool found = false; float r; - while( it != v->end() ) - { - r = start * ( ( *it ).first / ( *it ).second ); - if( r == floor( r ) ) - { - found = true; - break; - } - ++it; - } + int cnt = 0; + while( cnt < limit ) + { + cout << cnt << " : " << start << "\n"; + cnt++; + vector< pair >::iterator it = v->begin(); + bool found = false; float r; + while( it != v->end() ) + { + r = start * ( ( *it ).first / ( *it ).second ); + if( r == floor( r ) ) + { + found = true; + break; + } + ++it; + } - if( found ) start = ( int )r; - else break; - } + if( found ) start = ( int )r; + else break; + } } int start, limit; }; diff --git a/Task/Fractran/C-sharp/fractran-1.cs b/Task/Fractran/C-sharp/fractran-1.cs deleted file mode 100644 index a1b546059d..0000000000 --- a/Task/Fractran/C-sharp/fractran-1.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace System.Numerics -{ - using Fractype = (BigInteger numerator, BigInteger denominator); - struct Quotient - { - private Fractype _frac; - public Fractype Fraction - { - get => _frac; - set => _frac = Reduce(value); - } - - public bool IsIntegral => _frac.denominator == 1; - - public Quotient(BigInteger num, BigInteger den) - { - Fraction = (num, den); - } - - public static BigInteger GCD(BigInteger a, BigInteger b) - { - return (b == 0) ? a : GCD(b, a % b); - } - - private static Fractype Reduce(Fractype f) - { - if (f.denominator == 0) - throw new DivideByZeroException(); - - BigInteger gcd = Quotient.GCD(f.numerator, f.denominator); - return (f.numerator / gcd, f.denominator / gcd); - } - - public static Quotient operator *(Quotient a, Quotient b) - => new Quotient(a._frac.numerator * b._frac.numerator, a._frac.denominator * b._frac.denominator); - - public static Quotient operator *(Quotient a, BigInteger n) - => new Quotient(a._frac.numerator * n, a._frac.denominator); - - public static explicit operator Quotient(Fractype t) => new Quotient(t.numerator, t.denominator); - } - - class FRACTRAN - { - private Quotient[] code; - public FRACTRAN(Fractype[] _code) - { - code = _code.Select(x => (Quotient) x).ToArray(); - } - - public (BigInteger value, bool success) Compute(BigInteger n) - { - for (int i = 0; i < code.Length; i++) - if ((code[i] * n).IsIntegral) - return ((code[i] * n).Fraction.numerator, true); - return (0, false); - } - } - - class Program - { - public static void Main(string[] args) - { - Fractype[] frac_code = args[0].Split(" ") - .Select(x => ((BigInteger)Int32.Parse(x.Split("/")[0]), (BigInteger)Int32.Parse(x.Split("/")[1].Trim(',')))).ToArray(); - BigInteger init = new BigInteger(Int32.Parse(args[1].Trim(','))); - int steps = Int32.Parse(args[2].Trim(',')); - - FRACTRAN FRACGAME = new FRACTRAN(frac_code); - - List sequence = new List(); - sequence.Add(init); - bool halt = false; - for (int i = 0; i < steps - 1; i++) - { - var k = FRACGAME.Compute(sequence[sequence.Count - 1]); - if (k.success) - sequence.Add(k.value); - else - { - halt = true; - break; - } - } - - for (int i = 0; i < sequence.Count; i++) - Console.WriteLine((i + 1).ToString() + ": " + sequence[i]); - if (halt) - Console.WriteLine("HALT"); - } - } -} diff --git a/Task/Fractran/C-sharp/fractran-2.cs b/Task/Fractran/C-sharp/fractran-2.cs deleted file mode 100644 index 14d41b2e3e..0000000000 --- a/Task/Fractran/C-sharp/fractran-2.cs +++ /dev/null @@ -1,54 +0,0 @@ - class Program - { - private static bool PowerOfTwo(BigInteger b) - { - while (b % 2 == 0) - b /= 2; - return b == 1; - } - - private static BigInteger BigLog2(BigInteger b) - { - BigInteger r = 0; - while (b > 1) - { - r++; - b /= 2; - } - return r; - } - - public static void Main(string[] args) - { - Fractype[] frac_code = args[0].Split(" ") - .Select(x => ((BigInteger)Int32.Parse(x.Split("/")[0]), (BigInteger)Int32.Parse(x.Split("/")[1].Trim(',')))).ToArray(); - BigInteger init = new BigInteger(Int32.Parse(args[1].Trim(','))); - int steps = Int32.Parse(args[2].Trim(',')); - - FRACTRAN FRACGAME = new FRACTRAN(frac_code); - - List sequence = new List(); - List primes = new List(); - sequence.Add(init); - bool halt = false; - while (primes.Count() < 20) - { - var k = FRACGAME.Compute(sequence[sequence.Count - 1]); - if (k.success) - sequence.Add(k.value); - else - { - halt = true; - break; - } - - if (PowerOfTwo(k.value)) - primes.Add(BigLog2(k.value)); - } - - for (int i = 0; i < primes.Count; i++) - Console.WriteLine((i + 1).ToString() + ": " + primes[i]); - if (halt) - Console.WriteLine("HALT"); - } - } diff --git a/Task/Fractran/C/fractran.c b/Task/Fractran/C/fractran.c index 1119b05a77..6931d47852 100644 --- a/Task/Fractran/C/fractran.c +++ b/Task/Fractran/C/fractran.c @@ -4,62 +4,62 @@ typedef struct frac_s *frac; struct frac_s { - int n, d; - frac next; + int n, d; + frac next; }; frac parse(char *s) { - int offset = 0; - struct frac_s h = {0}, *p = &h; + int offset = 0; + struct frac_s h = {0}, *p = &h; - while (2 == sscanf(s, "%d/%d%n", &h.n, &h.d, &offset)) { - s += offset; - p = p->next = malloc(sizeof *p); - *p = h; - p->next = 0; - } + while (2 == sscanf(s, "%d/%d%n", &h.n, &h.d, &offset)) { + s += offset; + p = p->next = malloc(sizeof *p); + *p = h; + p->next = 0; + } - return h.next; + return h.next; } int run(int v, char *s) { - frac n, p = parse(s); - mpz_t val; - mpz_init_set_ui(val, v); + frac n, p = parse(s); + mpz_t val; + mpz_init_set_ui(val, v); -loop: n = p; - if (mpz_popcount(val) == 1) - gmp_printf("\n[2^%d = %Zd]", mpz_scan1(val, 0), val); - else - gmp_printf(" %Zd", val); +loop: n = p; + if (mpz_popcount(val) == 1) + gmp_printf("\n[2^%d = %Zd]", mpz_scan1(val, 0), val); + else + gmp_printf(" %Zd", val); - for (n = p; n; n = n->next) { - // assuming the fractions are not reducible - if (!mpz_divisible_ui_p(val, n->d)) continue; + for (n = p; n; n = n->next) { + // assuming the fractions are not reducible + if (!mpz_divisible_ui_p(val, n->d)) continue; - mpz_divexact_ui(val, val, n->d); - mpz_mul_ui(val, val, n->n); - goto loop; - } + mpz_divexact_ui(val, val, n->d); + mpz_mul_ui(val, val, n->n); + goto loop; + } - gmp_printf("\nhalt: %Zd has no divisors\n", val); + gmp_printf("\nhalt: %Zd has no divisors\n", val); - mpz_clear(val); - while (p) { - n = p->next; - free(p); - p = n; - } + mpz_clear(val); + while (p) { + n = p->next; + free(p); + p = n; + } - return 0; + return 0; } int main(void) { - run(2, "17/91 78/85 19/51 23/38 29/33 77/29 95/23 " - "77/19 1/17 11/13 13/11 15/14 15/2 55/1"); + run(2, "17/91 78/85 19/51 23/38 29/33 77/29 95/23 " + "77/19 1/17 11/13 13/11 15/14 15/2 55/1"); - return 0; + return 0; } diff --git a/Task/Fractran/Delphi/fractran.pas b/Task/Fractran/Delphi/fractran.delphi similarity index 100% rename from Task/Fractran/Delphi/fractran.pas rename to Task/Fractran/Delphi/fractran.delphi diff --git a/Task/Fractran/EasyLang/fractran.easy b/Task/Fractran/EasyLang/fractran.easy deleted file mode 100644 index 1fed677ff9..0000000000 --- a/Task/Fractran/EasyLang/fractran.easy +++ /dev/null @@ -1,38 +0,0 @@ -func[] fractran prog$ val limit . - for s$ in strsplit prog$ " " : n[][] &= number strsplit s$ "/" - for n to limit - r[] &= val - for i to len n[][] - if val mod n[i][2] = 0 : break 1 - . - if i > len n[][] : break 1 - val = val / n[i][2] * n[i][1] - . - return r[] -. -p$ = "17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1" -print fractran p$ 2 15 -# -proc sort &d[] . - for i = 1 to len d[] - 1 - for j = i + 1 to len d[] - if d[j] < d[i] : swap d[j] d[i] - . - . -. -r[] = fractran p$ 2 1000 -sort r[] -i = 1 -prim = 2 -po = 4 -repeat - repeat - if i > len r[] : break 2 - until i > len r[] or r[i] >= po - i += 1 - . - until i > len r[] - if r[i] = po : write prim & " " - prim += 1 - po *= 2 -. diff --git a/Task/Fractran/Elixir/fractran.ex b/Task/Fractran/Elixir/fractran.elixir similarity index 100% rename from Task/Fractran/Elixir/fractran.ex rename to Task/Fractran/Elixir/fractran.elixir diff --git a/Task/Fractran/Fortran/fractran-2.f b/Task/Fractran/Fortran/fractran-2.f index 0422be02be..6a079ed26a 100644 --- a/Task/Fractran/Fortran/fractran-2.f +++ b/Task/Fractran/Fortran/fractran-2.f @@ -1,49 +1,49 @@ - INTEGER FUNCTION FRACTRAN(N,P,Q,M) !Notion devised by J. H. Conway. + INTEGER FUNCTION FRACTRAN(N,P,Q,M) !Notion devised by J. H. Conway. Careful: the rule is N*P/Q being integer. N*6/3 is integer always because this is N*2/1, but 3 may not divide N. Could check GCD(P,Q), dividing out the common denominator so MOD(N,Q) works. - INTEGER*8 N !The work variable. Modified! - INTEGER M !The number of fractions supplied. + INTEGER*8 N !The work variable. Modified! + INTEGER M !The number of fractions supplied. INTEGER P(M),Q(M)!The terms of the fractions. - INTEGER I !A stepper. - DO I = 1,M !Search the supplied fractions, P(i)/Q(i). - IF (MOD(N,Q(I)).EQ.0) THEN !Does the denominator divide N? - N = N/Q(I)*P(I) !Yes, compute N*P/Q but trying to dodge overflow. - FRACTRAN = I !Report the hit. - RETURN !Done! - END IF !Otherwise, - END DO !Try the next fraction in the order supplied. - FRACTRAN = 0 !No hit. - END FUNCTION FRACTRAN !That's it! Even so, "Turing complete"... + INTEGER I !A stepper. + DO I = 1,M !Search the supplied fractions, P(i)/Q(i). + IF (MOD(N,Q(I)).EQ.0) THEN !Does the denominator divide N? + N = N/Q(I)*P(I) !Yes, compute N*P/Q but trying to dodge overflow. + FRACTRAN = I !Report the hit. + RETURN !Done! + END IF !Otherwise, + END DO !Try the next fraction in the order supplied. + FRACTRAN = 0 !No hit. + END FUNCTION FRACTRAN !That's it! Even so, "Turing complete"... PROGRAM POKE - INTEGER FRACTRAN !Not the default type of function. - INTEGER P(66),Q(66) !Holds the fractions as P(i)/Q(i). - INTEGER*8 N !The working number. - INTEGER I,IT,L,M !Assistants. + INTEGER FRACTRAN !Not the default type of function. + INTEGER P(66),Q(66) !Holds the fractions as P(i)/Q(i). + INTEGER*8 N !The working number. + INTEGER I,IT,L,M !Assistants. - WRITE (6,1) !Announce. + WRITE (6,1) !Announce. 1 FORMAT ("Interpreter for J.H. Conway's FRACTRAN language.") Chew into an example programme. - OPEN (10,FILE = "Fractran.txt",STATUS="OLD",ACTION="READ") !Rather than compiled-in stuff. - READ (10,*) L !I need to know this without having to scan the input. - WRITE (6,2) L !Reveal in case of trouble. - 2 FORMAT (I0," fractions, as follow:") !Should the input evoke problems. - READ (10,*) (P(I),Q(I),I = 1,L) !Ask for the specified number of P,Q pairs. - WRITE (6,3) (P(I),Q(I),I = 1,L) !Show what turned up. - 3 FORMAT (24(I0,"/",I0:", ")) !As P(i)/Q(i) pairs. The colon means that there will be no trailing comma. - READ (10,*) N,M !The start value, and the step limit. - CLOSE (10) !Finished with input. - WRITE (6,4) N,M !Hopefully, all went well. + OPEN (10,FILE = "Fractran.txt",STATUS="OLD",ACTION="READ") !Rather than compiled-in stuff. + READ (10,*) L !I need to know this without having to scan the input. + WRITE (6,2) L !Reveal in case of trouble. + 2 FORMAT (I0," fractions, as follow:") !Should the input evoke problems. + READ (10,*) (P(I),Q(I),I = 1,L) !Ask for the specified number of P,Q pairs. + WRITE (6,3) (P(I),Q(I),I = 1,L) !Show what turned up. + 3 FORMAT (24(I0,"/",I0:", ")) !As P(i)/Q(i) pairs. The colon means that there will be no trailing comma. + READ (10,*) N,M !The start value, and the step limit. + CLOSE (10) !Finished with input. + WRITE (6,4) N,M !Hopefully, all went well. 4 FORMAT ("Start with N = ",I0,", step limit ",I0) Commence. - WRITE (6,10) 0,N !Splat a heading. - 10 FORMAT (/," Step #F: N",/,I6,4X,": ",I0) !Matched FORMAT 11. - DO I = 1,M !Here we go! - IT = FRACTRAN(N,P,Q,L) !Do it! - WRITE (6,11) I,IT,N !Show it! - 11 FORMAT (I6,I4,": ",I0) !N last, as it may be big. - IF (IT.LE.0) EXIT !No hit, so quit. - END DO !The next step. - END !Whee! + WRITE (6,10) 0,N !Splat a heading. + 10 FORMAT (/," Step #F: N",/,I6,4X,": ",I0) !Matched FORMAT 11. + DO I = 1,M !Here we go! + IT = FRACTRAN(N,P,Q,L) !Do it! + WRITE (6,11) I,IT,N !Show it! + 11 FORMAT (I6,I4,": ",I0) !N last, as it may be big. + IF (IT.LE.0) EXIT !No hit, so quit. + END DO !The next step. + END !Whee! diff --git a/Task/Fractran/Fortran/fractran-3.f b/Task/Fractran/Fortran/fractran-3.f index 8fdab8dd61..1a409a7c11 100644 --- a/Task/Fractran/Fortran/fractran-3.f +++ b/Task/Fractran/Fortran/fractran-3.f @@ -1,11 +1,11 @@ - DO I = 1,M !Here we go! - IT = FRACTRAN(N,P,Q,L) !Do it! - IF (POPCNT(N).EQ.1) WRITE (6,11) I,IT,N !Show it! - 11 FORMAT (I6,I4,": ",I0) !N last, as it may be big. - IF (IT.LE.0) EXIT !No hit, so quit. - IF (N.LE.0) THEN !Otherwise, worry about overflow. - WRITE (6,*) "Integer overflow!" !Justified. The test is not certain. - WRITE (6,11) I,IT,N !Alas, the step failed. - EXIT !Give in. - END IF !So much for overflow. - END DO !The next step. + DO I = 1,M !Here we go! + IT = FRACTRAN(N,P,Q,L) !Do it! + IF (POPCNT(N).EQ.1) WRITE (6,11) I,IT,N !Show it! + 11 FORMAT (I6,I4,": ",I0) !N last, as it may be big. + IF (IT.LE.0) EXIT !No hit, so quit. + IF (N.LE.0) THEN !Otherwise, worry about overflow. + WRITE (6,*) "Integer overflow!" !Justified. The test is not certain. + WRITE (6,11) I,IT,N !Alas, the step failed. + EXIT !Give in. + END IF !So much for overflow. + END DO !The next step. diff --git a/Task/Fractran/Fortran/fractran-4.f b/Task/Fractran/Fortran/fractran-4.f index 7e4093fbcd..367c6d7833 100644 --- a/Task/Fractran/Fortran/fractran-4.f +++ b/Task/Fractran/Fortran/fractran-4.f @@ -1,187 +1,187 @@ - MODULE CONWAYSIDEA !Notion devised by J. H. Conway. - USE PRIMEBAG !This is a common need. - INTEGER LASTP,ENUFF !Some size allowances. - PARAMETER (LASTP = 66, ENUFF = 66) !Should suffice for the example in mind. - INTEGER NPPOW(1:LASTP) !Represent N as a collection of powers of prime numbers. - TYPE FACTORED !But represent P and Q of freaction = P/Q - INTEGER PNUM(0:LASTP) !As a list of prime number indices with PNUM(0) the count. - INTEGER PPOW(LASTP) !And the powers. for the fingered primes. - END TYPE FACTORED !Rather than as a simple number multiplied out. - TYPE(FACTORED) FP(ENUFF),FQ(ENUFF) !Thus represent a factored fraction, P(i)/Q(i). - INTEGER PLIVE(ENUFF),NL !Helps subroutine SHOWN display NPPOW. - CONTAINS !Now for the details. - SUBROUTINE SHOWFACTORS(N) !First, to show an internal data structure. - TYPE(FACTORED) N !It is supplied as a list of prime factors. - INTEGER I !A stepper. - DO I = 1,N.PNUM(0) !Step along the list. - IF (I.GT.1) WRITE (MSG,"('x',$)") !Append a glyph for "multiply". - WRITE (MSG,"(I0,$)") PRIME(N.PNUM(I)) !The prime fingered in the list. - IF (N.PPOW(I).GT.1) WRITE (MSG,"('^',I0,$)") N.PPOW(I) !With an interesting power? - END DO !On to the next element in the list. - WRITE (MSG,1) N.PNUM(0) !End the line - 1 FORMAT (": Factor count ",I0) !With a count of prime factors. - END SUBROUTINE SHOWFACTORS !Hopefully, this will not be needed often. + MODULE CONWAYSIDEA !Notion devised by J. H. Conway. + USE PRIMEBAG !This is a common need. + INTEGER LASTP,ENUFF !Some size allowances. + PARAMETER (LASTP = 66, ENUFF = 66) !Should suffice for the example in mind. + INTEGER NPPOW(1:LASTP) !Represent N as a collection of powers of prime numbers. + TYPE FACTORED !But represent P and Q of freaction = P/Q + INTEGER PNUM(0:LASTP) !As a list of prime number indices with PNUM(0) the count. + INTEGER PPOW(LASTP) !And the powers. for the fingered primes. + END TYPE FACTORED !Rather than as a simple number multiplied out. + TYPE(FACTORED) FP(ENUFF),FQ(ENUFF) !Thus represent a factored fraction, P(i)/Q(i). + INTEGER PLIVE(ENUFF),NL !Helps subroutine SHOWN display NPPOW. + CONTAINS !Now for the details. + SUBROUTINE SHOWFACTORS(N) !First, to show an internal data structure. + TYPE(FACTORED) N !It is supplied as a list of prime factors. + INTEGER I !A stepper. + DO I = 1,N.PNUM(0) !Step along the list. + IF (I.GT.1) WRITE (MSG,"('x',$)") !Append a glyph for "multiply". + WRITE (MSG,"(I0,$)") PRIME(N.PNUM(I)) !The prime fingered in the list. + IF (N.PPOW(I).GT.1) WRITE (MSG,"('^',I0,$)") N.PPOW(I) !With an interesting power? + END DO !On to the next element in the list. + WRITE (MSG,1) N.PNUM(0) !End the line + 1 FORMAT (": Factor count ",I0) !With a count of prime factors. + END SUBROUTINE SHOWFACTORS !Hopefully, this will not be needed often. - TYPE(FACTORED) FUNCTION FACTOR(IT) !Into a list of primes and their powers. - INTEGER IT,N !The number and a copy to damage. - INTEGER P,POW !A stepper and a power. - INTEGER F,NF !A factor and a counter. - IF (IT.LE.0) STOP "Factor only positive numbers!" !Or else... - N = IT !A copy I can damage. - NF = 0 !No factors found. - P = 0 !Because no primes have been tried. - PP:DO WHILE (N.GT.1) !Step through the possibilities. - P = P + 1 !Another prime impends. - F = PRIME(P) !Grab a possible factor. - POW = 0 !It has no power yet. - FP:DO WHILE(MOD(N,F).EQ.0) !Well? - POW = POW + 1 !Count a factor.. - N = N/F !Reduce the number. - END DO FP !The P'th prime's power's produced. - IF (POW.GT.0) THEN !So, was it a factor? - IF (NF.GE.LASTP) THEN !Yes. Have I room in the list? - WRITE (MSG,1) IT,LASTP !Alas. + TYPE(FACTORED) FUNCTION FACTOR(IT) !Into a list of primes and their powers. + INTEGER IT,N !The number and a copy to damage. + INTEGER P,POW !A stepper and a power. + INTEGER F,NF !A factor and a counter. + IF (IT.LE.0) STOP "Factor only positive numbers!" !Or else... + N = IT !A copy I can damage. + NF = 0 !No factors found. + P = 0 !Because no primes have been tried. + PP:DO WHILE (N.GT.1) !Step through the possibilities. + P = P + 1 !Another prime impends. + F = PRIME(P) !Grab a possible factor. + POW = 0 !It has no power yet. + FP:DO WHILE(MOD(N,F).EQ.0) !Well? + POW = POW + 1 !Count a factor.. + N = N/F !Reduce the number. + END DO FP !The P'th prime's power's produced. + IF (POW.GT.0) THEN !So, was it a factor? + IF (NF.GE.LASTP) THEN !Yes. Have I room in the list? + WRITE (MSG,1) IT,LASTP !Alas. 1 FORMAT ("Factoring ",I0," but with provision for only ", 1 I0," prime factors!") - FACTOR.PNUM(0) = NF !Place the count so far, + FACTOR.PNUM(0) = NF !Place the count so far, CALL SHOWFACTORS(FACTOR)!So this can be invoked. - STOP "Not enough storage!" !Quite. - END IF !But normally, - NF = NF + 1 !Admit another factor. - FACTOR.PNUM(NF) = P !Identify the prime. NOT the prime itself. - FACTOR.PPOW(NF) = POW !Place its power. - END IF !So much for that factor. - END DO PP !Try another prime, if N > 1 still. - FACTOR.PNUM(0) = NF !Place the count. - END FUNCTION FACTOR !Thus, a list of primes and their powers. + STOP "Not enough storage!" !Quite. + END IF !But normally, + NF = NF + 1 !Admit another factor. + FACTOR.PNUM(NF) = P !Identify the prime. NOT the prime itself. + FACTOR.PPOW(NF) = POW !Place its power. + END IF !So much for that factor. + END DO PP !Try another prime, if N > 1 still. + FACTOR.PNUM(0) = NF !Place the count. + END FUNCTION FACTOR !Thus, a list of primes and their powers. - INTEGER FUNCTION GCD(I,J) !Greatest common divisor. - INTEGER I,J !Of these two integers. - INTEGER N,M,R !Workers. - N = MAX(I,J) !Since I don't want to damage I or J, - M = MIN(I,J) !These copies might as well be the right way around. - 1 R = MOD(N,M) !Divide N by M to get the remainder R. - IF (R.GT.0) THEN !Remainder zero? - N = M !No. Descend a level. - M = R !M-multiplicity has been removed from N. - IF (R .GT. 1) GO TO 1 !No point dividing by one. - END IF !If R = 0, M divides N. - GCD = M !There we are. - END FUNCTION GCD !Euclid lives on! + INTEGER FUNCTION GCD(I,J) !Greatest common divisor. + INTEGER I,J !Of these two integers. + INTEGER N,M,R !Workers. + N = MAX(I,J) !Since I don't want to damage I or J, + M = MIN(I,J) !These copies might as well be the right way around. + 1 R = MOD(N,M) !Divide N by M to get the remainder R. + IF (R.GT.0) THEN !Remainder zero? + N = M !No. Descend a level. + M = R !M-multiplicity has been removed from N. + IF (R .GT. 1) GO TO 1 !No point dividing by one. + END IF !If R = 0, M divides N. + GCD = M !There we are. + END FUNCTION GCD !Euclid lives on! - INTEGER FUNCTION FRACTRAN(L) !Applies Conway's idea to a list of fractions. + INTEGER FUNCTION FRACTRAN(L) !Applies Conway's idea to a list of fractions. Could abandon all parameters since global variables have the details... - INTEGER L !The last fraction to consider. - INTEGER I,NF !Assistants. - DO I = 1,L !Step through the fractions in the order they were given. - NF = FQ(I).PNUM(0) !How many factors are listed in FQ(I)? - IF (ALL(NPPOW(FQ(I).PNUM(1:NF)) !Can N (as NPPOW) be divided by Q (as FQ)? - 1 .GE. FQ(I).PPOW(1:NF))) THEN !By comparing the supplies of prime factors. - FRACTRAN = I !Yes! - NPPOW(FQ(I).PNUM(1:NF)) = NPPOW(FQ(I).PNUM(1:NF)) !Remove prime powers from N - 1 - FQ(I).PPOW(1:NF) !Corresponding to Q. - NF = FP(I).PNUM(0) !Add powers to N - NPPOW(FP(I).PNUM(1:NF)) = NPPOW(FP(I).PNUM(1:NF)) !Corresponding to P. - 1 + FP(I).PPOW(1:NF) !Thus, N = N/Q*P. - RETURN !That's all it takes! No multiplies nor divides! - END IF !So much for that fraction. - END DO !This relies on ALL(zero tests) yielding true, as when Q = 1. - FRACTRAN = 0 !No hit. - END FUNCTION FRACTRAN !No massive multi-precision arithmetic! + INTEGER L !The last fraction to consider. + INTEGER I,NF !Assistants. + DO I = 1,L !Step through the fractions in the order they were given. + NF = FQ(I).PNUM(0) !How many factors are listed in FQ(I)? + IF (ALL(NPPOW(FQ(I).PNUM(1:NF)) !Can N (as NPPOW) be divided by Q (as FQ)? + 1 .GE. FQ(I).PPOW(1:NF))) THEN !By comparing the supplies of prime factors. + FRACTRAN = I !Yes! + NPPOW(FQ(I).PNUM(1:NF)) = NPPOW(FQ(I).PNUM(1:NF)) !Remove prime powers from N + 1 - FQ(I).PPOW(1:NF) !Corresponding to Q. + NF = FP(I).PNUM(0) !Add powers to N + NPPOW(FP(I).PNUM(1:NF)) = NPPOW(FP(I).PNUM(1:NF)) !Corresponding to P. + 1 + FP(I).PPOW(1:NF) !Thus, N = N/Q*P. + RETURN !That's all it takes! No multiplies nor divides! + END IF !So much for that fraction. + END DO !This relies on ALL(zero tests) yielding true, as when Q = 1. + FRACTRAN = 0 !No hit. + END FUNCTION FRACTRAN !No massive multi-precision arithmetic! - SUBROUTINE SHOWN(S,F) !Service routine to show the state after a step is calculated. + SUBROUTINE SHOWN(S,F) !Service routine to show the state after a step is calculated. Could imaging a function I6FMT(23) that returns " 23" and " " for non-positive numbers. Can't do it, as if this were invoked via a WRITE statement, re-entrant use of WRITE usually fails. - INTEGER S,F !Step number, Fraction number. - INTEGER I !A stepper. - CHARACTER*(9+4+1 + NL*6) ALINE !A scratchpad matching FORMAT 103. - WRITE (ALINE,103) S,F,NPPOW(PLIVE(1:NL)) !Show it! - 103 FORMAT (I9,I4,":",I6) !As a sequence of powers of primes. - IF (F.LE.0) ALINE(10:13) = "" !Scrub when no fraction is fingered. - DO I = 1,NL !Step along the live primes. - IF (NPPOW(PLIVE(I)).GT.0) CYCLE !Ignoring the empowered ones. - ALINE(15 + (I - 1)*6:14 + I*6) = "" !Blank out zero powers. - END DO !On to the next. - WRITE (MSG,"(A)") ALINE !Reveal at last. - END SUBROUTINE SHOWN !A struggle. - END MODULE CONWAYSIDEA !Simple... + INTEGER S,F !Step number, Fraction number. + INTEGER I !A stepper. + CHARACTER*(9+4+1 + NL*6) ALINE !A scratchpad matching FORMAT 103. + WRITE (ALINE,103) S,F,NPPOW(PLIVE(1:NL)) !Show it! + 103 FORMAT (I9,I4,":",I6) !As a sequence of powers of primes. + IF (F.LE.0) ALINE(10:13) = "" !Scrub when no fraction is fingered. + DO I = 1,NL !Step along the live primes. + IF (NPPOW(PLIVE(I)).GT.0) CYCLE !Ignoring the empowered ones. + ALINE(15 + (I - 1)*6:14 + I*6) = "" !Blank out zero powers. + END DO !On to the next. + WRITE (MSG,"(A)") ALINE !Reveal at last. + END SUBROUTINE SHOWN !A struggle. + END MODULE CONWAYSIDEA !Simple... PROGRAM POKE - USE CONWAYSIDEA !But, where does he get his ideas from? - INTEGER P(ENUFF),Q(ENUFF) !Holds the fractions as P(i)/Q(i). - INTEGER N !The working number. - INTEGER LF !Last fraction given. - INTEGER LP !Last prime needed. - INTEGER MS !Maximum number of steps. - INTEGER I,IT !Assistants. - LOGICAL*1 PUSED(ENUFF) !Track the usage of prime numbers, + USE CONWAYSIDEA !But, where does he get his ideas from? + INTEGER P(ENUFF),Q(ENUFF) !Holds the fractions as P(i)/Q(i). + INTEGER N !The working number. + INTEGER LF !Last fraction given. + INTEGER LP !Last prime needed. + INTEGER MS !Maximum number of steps. + INTEGER I,IT !Assistants. + LOGICAL*1 PUSED(ENUFF) !Track the usage of prime numbers, - MSG = 6 !Standard output. - WRITE (6,1) !Announce. + MSG = 6 !Standard output. + WRITE (6,1) !Announce. 1 FORMAT ("Interpreter for J. H. Conway's FRACTRAN language.") Chew into an example programme. - 10 OPEN (10,FILE = "Fractran.txt",STATUS="OLD",ACTION="READ") !Rather than compiled-in stuff. - READ (10,*) LF !I need to know this without having to scan the input. - WRITE (MSG,11) LF !Reveal in case of trouble. - 11 FORMAT (I0," fractions, as follow:") !Should the input evoke problems. - READ (10,*) (P(I),Q(I),I = 1,LF) !Ask for the specified number of P,Q pairs. - WRITE (MSG,12) (P(I),Q(I),I = 1,LF) !Show what turned up. - 12 FORMAT (24(I0,"/",I0:", ")) !As P(i)/Q(i) pairs. The colon means that there will be no trailing comma. - READ (10,*) N,MS !The start value, and the step limit. - CLOSE (10) !Finished with input. - WRITE (MSG,13) N,MS !Hopefully, all went well. + 10 OPEN (10,FILE = "Fractran.txt",STATUS="OLD",ACTION="READ") !Rather than compiled-in stuff. + READ (10,*) LF !I need to know this without having to scan the input. + WRITE (MSG,11) LF !Reveal in case of trouble. + 11 FORMAT (I0," fractions, as follow:") !Should the input evoke problems. + READ (10,*) (P(I),Q(I),I = 1,LF) !Ask for the specified number of P,Q pairs. + WRITE (MSG,12) (P(I),Q(I),I = 1,LF) !Show what turned up. + 12 FORMAT (24(I0,"/",I0:", ")) !As P(i)/Q(i) pairs. The colon means that there will be no trailing comma. + READ (10,*) N,MS !The start value, and the step limit. + CLOSE (10) !Finished with input. + WRITE (MSG,13) N,MS !Hopefully, all went well. 13 FORMAT ("Start with N = ",I0,", step limit ",I0) - IF (.NOT.GRASPPRIMEBAG(66)) STOP "Gan't grab my file of primes!" !Attempt in hope. + IF (.NOT.GRASPPRIMEBAG(66)) STOP "Gan't grab my file of primes!" !Attempt in hope. Convert the starting number to a more convenient form, an array of powers of successive prime numbers. - 20 FP(1) = FACTOR(N) !Borrow one of the factor list variables. - NPPOW = 0 !Clear all prime factor counts. - DO I = 1,FP(1).PNUM(0) !Now find what they are. - NPPOW(FP(1).PNUM(I)) = FP(1).PPOW(I) !Convert from a variable-length list - END DO !To a fixed-length random-access array. - PUSED = NPPOW.GT.0 !Note which primes have been used. - LP = FP(1).PNUM(FP(1).PNUM(0)) !Recall the last prime required. More later. + 20 FP(1) = FACTOR(N) !Borrow one of the factor list variables. + NPPOW = 0 !Clear all prime factor counts. + DO I = 1,FP(1).PNUM(0) !Now find what they are. + NPPOW(FP(1).PNUM(I)) = FP(1).PPOW(I) !Convert from a variable-length list + END DO !To a fixed-length random-access array. + PUSED = NPPOW.GT.0 !Note which primes have been used. + LP = FP(1).PNUM(FP(1).PNUM(0)) !Recall the last prime required. More later. Convert the supplied P(i)/Q(i) fractions to lists of prime number factors and powers in FP(i) and FQ(i). - DO I = 1,LF !Step through the fractions. - IT = GCD(P(I),Q(I)) !Suspicion. - IF (IT.GT.1) THEN !Justified? - WRITE (MSG,21) I,P(I),Q(I),IT !Alas. Complain. The rule is N*(P/Q) being integer. + DO I = 1,LF !Step through the fractions. + IT = GCD(P(I),Q(I)) !Suspicion. + IF (IT.GT.1) THEN !Justified? + WRITE (MSG,21) I,P(I),Q(I),IT !Alas. Complain. The rule is N*(P/Q) being integer. 21 FORMAT ("Fraction ",I3,", ",I0,"/",I0,!N*6/3 is integer always because this is N*2/1, but 3 may not divide N. - 1 " has common factor ",I0,"!") !By removing IT, - P(I) = P(I)/IT !The test need merely check if N is divisible by Q. - Q(I) = Q(I)/IT !And, as N is factorised in NPPOW - END IF !And Q in FQ, subtractions of powers only is needed. - FP(I) = FACTOR(P(I)) !Righto, form the factor list for P. - PUSED(FP(I).PNUM(1:FP(I).PNUM(0))) = .TRUE. !Mark which primes it fingers. - LP = MAX(LP,FP(I).PNUM(FP(I).PNUM(0))) !One has no prime factors: PNUM(0) = 0. - FQ(I) = FACTOR(Q(I)) !And likewise for Q. - PUSED(FQ(I).PNUM(1:FQ(I).PNUM(0))) = .TRUE. !Some primes may be omitted. - LP = MAX(LP,FQ(I).PNUM(FQ(I).PNUM(0))) !If no prime factors, PNUM(0) fingers element zero, which is zero. - END DO !All this messing about saves on multiplication and division. + 1 " has common factor ",I0,"!") !By removing IT, + P(I) = P(I)/IT !The test need merely check if N is divisible by Q. + Q(I) = Q(I)/IT !And, as N is factorised in NPPOW + END IF !And Q in FQ, subtractions of powers only is needed. + FP(I) = FACTOR(P(I)) !Righto, form the factor list for P. + PUSED(FP(I).PNUM(1:FP(I).PNUM(0))) = .TRUE. !Mark which primes it fingers. + LP = MAX(LP,FP(I).PNUM(FP(I).PNUM(0))) !One has no prime factors: PNUM(0) = 0. + FQ(I) = FACTOR(Q(I)) !And likewise for Q. + PUSED(FQ(I).PNUM(1:FQ(I).PNUM(0))) = .TRUE. !Some primes may be omitted. + LP = MAX(LP,FQ(I).PNUM(FQ(I).PNUM(0))) !If no prime factors, PNUM(0) fingers element zero, which is zero. + END DO !All this messing about saves on multiplication and division. Check which primes are in use, preparing an index of live primes.. - NL = 0 !No live primes. - DO I = 1,LP !Check up to the last prime. - IF (PUSED(I)) THEN !This one used? - NL = NL + 1 !Yes. Another. - PLIVE(NL) = I !Fingered. - END IF !So much for that prime. - END DO !On to the next. - WRITE (MSG,22) NL,LP,PRIME(LP) !Remark on usage. - 22 FORMAT ("Require ",I0," primes only, up to Prime(",I0,") = ",I0) !Presume always more than one prime. + NL = 0 !No live primes. + DO I = 1,LP !Check up to the last prime. + IF (PUSED(I)) THEN !This one used? + NL = NL + 1 !Yes. Another. + PLIVE(NL) = I !Fingered. + END IF !So much for that prime. + END DO !On to the next. + WRITE (MSG,22) NL,LP,PRIME(LP) !Remark on usage. + 22 FORMAT ("Require ",I0," primes only, up to Prime(",I0,") = ",I0) !Presume always more than one prime. IF (LP.GT.LASTP) STOP "But, that's too many for array NPPOW!" Cast forth a heading. - 100 WRITE (MSG,101) (PRIME(PLIVE(I)), I = 1,NL) !Splat a heading. - 101 FORMAT (/,14X,"N as powers of prime factors",/, !The prime heading, - 1 5X,"Step F#:",I6) !With primes beneath. - CALL SHOWN(0,0) !Initial state of N as NPPOW. Step zero, no fraction. + 100 WRITE (MSG,101) (PRIME(PLIVE(I)), I = 1,NL) !Splat a heading. + 101 FORMAT (/,14X,"N as powers of prime factors",/, !The prime heading, + 1 5X,"Step F#:",I6) !With primes beneath. + CALL SHOWN(0,0) !Initial state of N as NPPOW. Step zero, no fraction. Commence! - DO I = 1,MS !Here we go! - IT = FRACTRAN(LF) !Do it! - CALL SHOWN(I,IT) !Show it! - IF (IT.LE.0) EXIT !Quit it? - END DO !The next step. + DO I = 1,MS !Here we go! + IT = FRACTRAN(LF) !Do it! + CALL SHOWN(I,IT) !Show it! + IF (IT.LE.0) EXIT !Quit it? + END DO !The next step. Complete! - END !Whee! + END !Whee! diff --git a/Task/Fractran/Fortran/fractran-5.f b/Task/Fractran/Fortran/fractran-5.f index 8bf75352db..65e4304ded 100644 --- a/Task/Fractran/Fortran/fractran-5.f +++ b/Task/Fractran/Fortran/fractran-5.f @@ -1,5 +1,5 @@ - DO I = 1,MS !Here we go! - IT = FRACTRAN(LF) !Do it! - IF (ALL(NPPOW(2:LP).EQ.0)) CALL SHOWN(I,IT) !Show it! - IF (IT.LE.0) EXIT !Quit it? - END DO !The next step. + DO I = 1,MS !Here we go! + IT = FRACTRAN(LF) !Do it! + IF (ALL(NPPOW(2:LP).EQ.0)) CALL SHOWN(I,IT) !Show it! + IF (IT.LE.0) EXIT !Quit it? + END DO !The next step. diff --git a/Task/Fractran/Julia/fractran.jl b/Task/Fractran/Julia/fractran.jl deleted file mode 100644 index 87f70c2989..0000000000 --- a/Task/Fractran/Julia/fractran.jl +++ /dev/null @@ -1,70 +0,0 @@ -using .Iterators, BenchmarkTools -using Primes: Factorization, factor - -# type alias for abbreviation -Factors = Factorization{Int} - -# iterable stuct with parametric type polymorphism -struct Fractran{T} - program::Vector{@NamedTuple{num::T, den::T}} - input::Int - - # inner constructor - function Fractran{T}(program::Vector{Rational{Int}}, input::Int) where T - c = Dict(BigInt => identity, Factors => factor)[T] - new{T}([(num = c(f.num), den = c(f.den)) for f ∈ program], input) - end -end - -# methods for Fractran with n::BigInt -Base.iterate(ft::Fractran{BigInt}, n = big(ft.input)) = - for f ∈ ft.program - if iszero(n % f.den) - n = n ÷ f.den * f.num - return n, n - end - end - -iters(ft::Fractran{BigInt}) = ft - -output(ft::Fractran{BigInt}) = (trailing_zeros(n) for n ∈ ft if ispow2(n)) - -# methods for Fractran with n::Factorization{Int} -Base.iterate(ft::Fractran{Factors}, n = factor(ft.input)) = - for f ∈ ft.program - if all(n[p] ≥ e for (p, e) ∈ f.den) - for (p, e) ∈ f.den n[p] -= e end - for (p, e) ∈ f.num n[p] += e end - return n, n - end - end - -iters(ft::Fractran{Factors}) = (prod(n) for n ∈ ft) - -output(ft::Fractran{Factors}) = (n[2] for n ∈ ft if - all((iszero(e) || (p == 2)) for (p, e) ∈ n)) - -# convenient Fractran scripting -macro ft_str(s::String) - eval(Meta.parse(replace("[$s]", "/" => "//"))) -end - -# instantiation of Fractran example generating prime numbers -primes(T) = Fractran{T}(ft"17/91, 78/85, 19/51, 23/38, 29/33, 77/29, - 95/23, 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1", 2) - -# Output including Benchmark -ilim = 20; plim = 45 - -function printout(T) - println("\n$ilim iterations and output of $plim prime numbers using ", T) - println(join(take(iters(primes(T)), ilim), ", "), "…") - join(stdout, take(output(primes(T)), plim), ", ") - print("…\nBenchmark: $plim primes in") -end - -printout(BigInt) -@btime collect(take(output(primes(BigInt)), plim)) - -printout(Factors) -@btime collect(take(output(primes(Factors)), plim)); diff --git a/Task/Fractran/Julia/fractran.julia b/Task/Fractran/Julia/fractran.julia new file mode 100644 index 0000000000..261db566c1 --- /dev/null +++ b/Task/Fractran/Julia/fractran.julia @@ -0,0 +1,37 @@ +# FRACTRAN interpreter implemented as an iterable struct + +using .Iterators: filter, map, take +import Base: iterate, show + +struct Fractran + rs::Vector{Rational{BigInt}} + i₀::BigInt +end + +iterate(f::Fractran, i = f.i₀) = + for r in f.rs + if iszero(i % r.den) # faster than isinteger(i*r) + i = i ÷ r.den * r.num + return (i, i) + end + end + +run(f::Fractran) = map(trailing_zeros, filter(ispow2, f)) + +show(io::IO, f::Fractran) = join(io, take(run(f), 30), ' ') + +macro code_str(s) + eval(Meta.parse("[" * replace(s, "/" => "//") * "]")) +end + +# Example FRACTRAN program generating primes +primes = Fractran(code"17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, + 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1", 2) + +# Output +println("First 25 iterations of FRACTRAN program 'primes':\n2 ", + join(take(primes, 25), ' ')) + +println("\nWatch the first 30 primes dropping out within seconds:") + +primes diff --git a/Task/Fractran/Kotlin/fractran.kts b/Task/Fractran/Kotlin/fractran.kotlin similarity index 100% rename from Task/Fractran/Kotlin/fractran.kts rename to Task/Fractran/Kotlin/fractran.kotlin diff --git a/Task/Fractran/Miranda/fractran.miranda b/Task/Fractran/Miranda/fractran.miranda deleted file mode 100644 index c1f844d524..0000000000 --- a/Task/Fractran/Miranda/fractran.miranda +++ /dev/null @@ -1,80 +0,0 @@ -main :: [sys_message] -main = [Stdout (lay [show (take 15 (run 2 primeprog)), - show (take 20 fracprimes)])] - -primeprog :: [(num,num)] -primeprog = fromjust (prog ("17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 " - ++ "1/17 11/13 13/11 15/14 15/2 55/1")) - -fracprimes :: [num] -fracprimes = [fromjust k | k<-map fracprime (run 2 primeprog); isjust k] - -fracprime :: num->maybe num -fracprime = f 0 - where f 1 1 = Nothing - f n 1 = Just n - f n x = Nothing, if x mod 2 ~= 0 - f n x = f (n+1) (x div 2), otherwise - -run :: num->[(num,num)]->[num] -run n prog = [n], if ~isjust n' - = n : run (fromjust n') prog, otherwise - where n' = step n prog - -step :: num->[(num,num)]->maybe num -step x [] = Nothing -step x ((n,d):xs) = Just (x*n div d), if x*n mod d = 0 - = step x xs, otherwise - -maybe * ::= Nothing | Just * - -isjust :: maybe *->bool -isjust (Just x) = True -isjust Nothing = False - -fromjust :: maybe *->* -fromjust (Just x) = x - -prog :: [char]->maybe [(num, num)] -prog xs = Just [], if trim xs = [] - = Nothing, if ~isjust fp \/ ~isjust rp - = Just (fr : fromjust rp), otherwise - where fp = frac xs - Just (fr, xs') = fp - rp = prog xs' - -frac :: [char]->maybe ((num,num), [char]) -frac xs = Nothing, if ~isjust np \/ ~isjust sl \/ ~isjust dp - = Just ((n, d), xs'''), otherwise - where np = numb xs - Just (n, xs') = np - sl = match '/' (trim xs') - Just xs'' = sl - dp = numb xs'' - Just (d, xs''') = dp - -numb :: [char]->maybe (num, [char]) -numb xs = Nothing, if n=[] - = Just (numval n, r), otherwise - where (n, r) = span "0123456789" (trim xs) - -match :: *->[*]->maybe [*] -match m [] = Nothing -match m (m:xs) = Just xs -match m (x:xs) = Nothing - -span :: [*]->[*]->([*],[*]) -span match [] = ([], []) -span match (x:xs) = ([], x:xs), if ~(x $in match) - = (x:r, xs'), otherwise - where (r, xs') = span match xs - -in :: *->[*]->bool -in x [] = False -in x (x:xs) = True -in x (y:xs) = x $in xs - -trim :: [char]->[char] -trim [] = [] -trim (c:xs) = trim xs, if c='\t' \/ c='\n' \/ c=' ' -trim (c:xs) = c:xs diff --git a/Task/Fractran/Nim/fractran-1.nim b/Task/Fractran/Nim/fractran-1.nim index 2dbc6b6ea7..232894e918 100644 --- a/Task/Fractran/Nim/fractran-1.nim +++ b/Task/Fractran/Nim/fractran-1.nim @@ -20,7 +20,7 @@ func toFractions(fractList: string): seq[Rat] = for f in fractList.split(): result.add(newRat(f)) -proc run(progStr: string; init: Natural; maxSteps: Natural = 0) = +proc run(progStr: string; init, maxSteps: Natural = 0) = ## Run the program described by string "progStr" with initial value "init", ## stopping after "maxSteps" (0 means for ever). ## Display the value after each step. @@ -39,7 +39,7 @@ iterator primes(n: Natural): int = for val in prog.values(2): if isZero(val and (val - 1)): # This is a power of two. - yield val.digits(2).int - 1 # Compute the exponent as number of binary digits minus one. + yield val.digits(2) - 1 # Compute the exponent as number of binary digits minus one. inc count if count == n: break diff --git a/Task/Fractran/OCaml/fractran.ml b/Task/Fractran/OCaml/fractran.ocaml similarity index 100% rename from Task/Fractran/OCaml/fractran.ml rename to Task/Fractran/OCaml/fractran.ocaml diff --git a/Task/Fractran/Odin/fractran.odin b/Task/Fractran/Odin/fractran.odin deleted file mode 100644 index 118e1b4333..0000000000 --- a/Task/Fractran/Odin/fractran.odin +++ /dev/null @@ -1,77 +0,0 @@ -package main - -import "core:fmt" -import "core:os" -import "core:strconv" -import "core:strings" -import "core:text/match" -import "core:math" - - -main :: proc() { - // fmt.println(os.args) - - n:int - number:int - number_conv:bool - fracts:[dynamic]int - defer delete(fracts) - - n,number_conv = strconv.parse_int(os.args[1]) - assert(number_conv, "Number must be given in first place!") - assert(len(os.args)>1,"no command line arguments given") - - data:="17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1" - - ss := strings.split(string(data), " ") - defer delete(ss) - - - a: [dynamic]string - dummy:[]string - defer delete(a) - defer delete(dummy) - - for i in ss{ - dummy =strings.split(i,"/") - for j in dummy{ - // fmt.println(j) - - append_elem(&a,j) - } - } - - for k in a{ - // fmt.println(k) - number,number_conv = strconv.parse_int(k) - assert(number_conv, "Number must be given in program") - append_elem(&fracts,number) - } - - - // fmt.println(len(fracts)) - cond:int - buf: [256]byte - bb:int - end:=0 - fmt.println(n) - frac: for j:=0;jnew($_), qw{ $|=1; MAIN: for( 1 .. 5000 ) { - print " " if $_ > 1; - my ($pow, $rest) = (0, $n->copy); - until( $rest->is_odd ) { - ++$pow; - $rest->bdiv(2); - } - if( $rest->is_one ) { - print "2**$pow"; - } else { - #print $n; - } - for my $f_i (@P) { - my $nf_i = $n * $f_i; - next unless $nf_i->is_int; - $n = $nf_i; - next MAIN; - } - last; + print " " if $_ > 1; + my ($pow, $rest) = (0, $n->copy); + until( $rest->is_odd ) { + ++$pow; + $rest->bdiv(2); + } + if( $rest->is_one ) { + print "2**$pow"; + } else { + #print $n; + } + for my $f_i (@P) { + my $nf_i = $n * $f_i; + next unless $nf_i->is_int; + $n = $nf_i; + next MAIN; + } + last; } print "\n"; diff --git a/Task/Fractran/R/fractran.r b/Task/Fractran/R/fractran.r deleted file mode 100644 index af0f56b3bf..0000000000 --- a/Task/Fractran/R/fractran.r +++ /dev/null @@ -1,25 +0,0 @@ -library(gmp) -library(stringr) - -fractran <- function(s, n, lim){ - P <- str_split_1(s, " ") |> str_split("/") - read_frac <- function(index) as.bigq(n=P[[index]][1], d=P[[index]][2]) - fracs <- sapply(seq_along(P), read_frac) - first_integer <- function(bigv, n){ - for(q in bigv){ - if(denominator(n*q)==1) return(q) - } - return(NA) - } - iters <- 0 - while(!is.na(first_integer(fracs, n))){ - n <- n*first_integer(fracs, n) - print(n, initLine=FALSE) - iters <- iters+1 - if(iters>=lim) break - } -} - -#Test input -fractran_primes <- "17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1" -fractran(fractran_primes, 2, 15) diff --git a/Task/Fractran/REXX/fractran-1.rexx b/Task/Fractran/REXX/fractran-1.rexx new file mode 100644 index 0000000000..8572c8bd0b --- /dev/null +++ b/Task/Fractran/REXX/fractran-1.rexx @@ -0,0 +1,28 @@ +/*REXX program runs FRACTRAN for a given set of fractions and from a specified N. */ +numeric digits 2000 /*be able to handle larger numbers. */ +parse arg N terms fracs /*obtain optional arguments from the CL*/ +if N=='' | N=="," then N= 2 /*Not specified? Then use the default.*/ +if terms=='' | terms=="," then terms= 100 /* " " " " " " */ +if fracs='' then fracs= "17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23,", + '77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1' + /* [↑] The default for the fractions. */ +f= space(fracs, 0) /*remove all blanks from the FRACS list*/ + do #=1 while f\==''; parse var f n.# "/" d.# ',' f + end /*#*/ /* [↑] parse all the fractions in list*/ +#= # - 1 /*the number of fractions just found. */ +say # 'fractions:' fracs /*display number and actual fractions. */ +say 'N is starting at ' N /*display the starting number N. */ +say terms ' terms are being shown:' /*display a kind of header/title. */ + + do j=1 for terms /*perform the DO loop for each term. */ + do k=1 for # /* " " " " " " fraction*/ + if N // d.k \== 0 then iterate /*Not an integer? Then ignore it. */ + cN= commas(N); L= length(cN) /*maybe insert commas into N; get len.*/ + say right('term' commas(j), 44) "──► " right(cN, max(15, L)) /*show Nth term & N*/ + N= N % d.k * n.k /*calculate next term (use %≡integer ÷)*/ + leave /*go start calculating the next term. */ + end /*k*/ /* [↑] if an integer, we found a new N*/ + end /*j*/ +exit 0 /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ? diff --git a/Task/Fractran/REXX/fractran-2.rexx b/Task/Fractran/REXX/fractran-2.rexx new file mode 100644 index 0000000000..a201c8471b --- /dev/null +++ b/Task/Fractran/REXX/fractran-2.rexx @@ -0,0 +1,39 @@ +/*REXX program runs FRACTRAN for a given set of fractions and from a specified N. */ +numeric digits 999; d= digits(); w= length(d) /*be able to handle gihugeic numbers. */ +parse arg N terms fracs /*obtain optional arguments from the CL*/ +if N=='' | N=="," then N= 2 /*Not specified? Then use the default.*/ +if terms=='' | terms=="," then terms= 100 /* " " " " " " */ +if fracs='' then fracs= "17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23,", + '77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1' + /* [↑] The default for the fractions. */ +f= space(fracs, 0) /*remove all blanks from the FRACS list*/ + do #=1 while f\==''; parse var f n.# "/" d.# ',' f + end /*#*/ /* [↑] parse all the fractions in list*/ +#= # - 1 /*adjust the number of fractions found.*/ +tell= terms>0 /*flag: show number or a power of 2.*/ +!.= 0; _= 1 /*the default value for powers of 2. */ +if \tell then do p=1 until length(_)>d; _= _ + _; !._= 1 + if p==1 then @._= left('', w + 9) "2**"left(p, w) ' ' + else @._= '(prime' right(p, w)") 2**"left(p, w) ' ' + end /*p*/ /* [↑] build powers of 2 tables. */ +L= length(N) /*length in decimal digits of integer N*/ +say # 'fractions:' fracs /*display number and actual fractions. */ +say 'N is starting at ' N /*display the starting number N. */ +if tell then say terms ' terms are being shown:' /*display header.*/ + else say 'only powers of two are being shown:' /* " " */ +@a= '(max digits used:' /*a literal used in the SAY below. */ + + do j=1 for abs(terms) /*perform DO loop once for each term. */ + do k=1 for # /* " " " " " " fraction*/ + if N // d.k \== 0 then iterate /*Not an integer? Then ignore it. */ + cN= commas(N); cj=commas(j) /*maybe insert commas into N. */ + if tell then say right('term' cj, 44) "──► " cN /*display Nth term and N.*/ + else if !.N then say right('term' cj,15) "──►" @.N @a right(L,w)") " cN + N= N % d.k * n.k /*calculate next term (use %≡integer ÷)*/ + L= max(L, length(N) ) /*the maximum number of decimal digits.*/ + leave /*go start calculating the next term. */ + end /*k*/ /* [↑] if an integer, we found a new N*/ + end /*j*/ +exit 0 /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ? diff --git a/Task/Fractran/REXX/fractran.rexx b/Task/Fractran/REXX/fractran.rexx deleted file mode 100644 index 1dd1d0179e..0000000000 --- a/Task/Fractran/REXX/fractran.rexx +++ /dev/null @@ -1,76 +0,0 @@ --- 23 Aug 2025 -include Setting - -say 'FRACTRAN' -say version -say -parse arg n','t -if n = '' then - n = 2 -if t = '' then - t = 100 -numeric digits 200 -call Fractions -call Task -call Powers -call Extra -exit - -Fractions: -call Time('r') -say 'Save fractions...' -l = '17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1' -n. = 0; d. = 0; w = Words(l) -do i = 1 to w - a = Word(l,i); parse var a n.i'/'d.i -end -say Format(Time('e'),,3) 'seconds'; say -return - -Task: -call Time('r') -say 'First' t 'terms of the sequence:' -do i = 2 to t - do j = 1 to w - if \ Integer(n/d.j) then - iterate - call CharOut ,Right(n,9) - if i//10 = 0 then - say - n = n%d.j*n.j - leave j - end -end -say Format(Time('e'),,3) 'seconds'; say -return - -Powers: -call Time('r') -say 'Flag powers of 2...' -p. = 0; e. = 0 -do i = 2 to 100 - a = 2**i; p.a = 1; e.a = i -end -say Format(Time('e'),,3) 'seconds'; say -return - -Extra: -call Time('r') -say 'Prime numbers:' -n = 2; p = 0 -do i = 2 to 1300000 - do j = 1 to w - if \ Integer(n/d.j) then - iterate j - if p.n then do - p = p+1 - say Right(p,2) ' Term' Right(i,7) Left('= 2^'e.n,7) 'Prime' Right(e.n,2) 'found' - end - n = n%d.j*n.j - leave j - end -end -say Format(Time('e'),,3) 'seconds'; say -return - -include Math diff --git a/Task/Fractran/Rebol/fractran.rebol b/Task/Fractran/Rebol/fractran.rebol deleted file mode 100644 index 33b17b69b8..0000000000 --- a/Task/Fractran/Rebol/fractran.rebol +++ /dev/null @@ -1,41 +0,0 @@ -Rebol [ - title: "Rosetta code: Fractran" - file: %Fractran.r3 - url: https://rosettacode.org/wiki/Fractran -] - -fractran: function/with [ - input [string! file! url!] - start [integer!] - terms [integer!] -][ - unless string? input [ input: read/string input ] - ;; --- parse fractions into [numerator denominator] pairs --- - fractions: parse input [collect [fraction some [separator fraction]]] - ;; --- interpreter loop --- - out: append copy [] n: start - while [terms > length? out] [ - forall fractions [ - frac: fractions/1 - if zero? mod n frac/y [ ;; fraction applies: n is divisible - n: n / frac/y * frac/x ;; advance: multiply n by fraction - append out to integer! n ;; keep the result - fractions: head fractions ;; restart from first fraction - break - ] - if tail? fractions [return out] ;; no fraction applied: halt - ] - ] - out -][ - digit: charset "0123456789" - fraction: [copy p [some digit] #"/" copy q [some digit] keep (as-pair to integer! p to integer! q)] - separator: [some #" "] -] - -print "First 100 terms of the sequence:" -out: fractran "17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1" 2 100 -forall out [ - prin pad out/1 9 - if zero? mod index? out 10 [print ""] -] diff --git a/Task/Fractran/Red/fractran.red b/Task/Fractran/Red/fractran.red index 44fb51eabe..a61ef88f55 100644 --- a/Task/Fractran/Red/fractran.red +++ b/Task/Fractran/Red/fractran.red @@ -5,20 +5,20 @@ if exists? inpf: to-file inp [inp: read inpf] digit: charset "0123456789" frac: [copy p [some digit] #"/" copy q [some digit] - keep (as-pair to-integer p to-integer q)] + keep (as-pair to-integer p to-integer q)] code: parse inp [collect [frac some [[some " "] frac]]] n: to-integer ask "please enter starting number n: " x: to-integer ask "please enter the number of terms, hit return for no limit: " l: length? code loop x [ - forall code [ - c: code/1 - if n % c/y = 0 [ - print n: n / c/y * c/x - code: head code - break - ] - if l = index? code [halt] - ] + forall code [ + c: code/1 + if n % c/y = 0 [ + print n: n / c/y * c/x + code: head code + break + ] + if l = index? code [halt] + ] ] diff --git a/Task/Fractran/Refal/fractran.refal b/Task/Fractran/Refal/fractran.refal deleted file mode 100644 index e66c789961..0000000000 --- a/Task/Fractran/Refal/fractran.refal +++ /dev/null @@ -1,78 +0,0 @@ -$ENTRY Go { - , >: e.Prog - = > - >; -}; - -PrimeProgram { - = '17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 ' - '1/17 11/13 13/11 15/14 15/2 55/1'; -}; - -FracPrimes { - 0 e.X = ; - s.I (e.N) e.P, - : Next e.N2, - : { - T s.N = s.N (e.N2) e.P>; - F = ; - }; -}; - -FracPrime { - (1) 1 = F; - (s.N) 1 = T s.N; - (s.N) e.X, : { - (e.X2) 0 = ) e.X2>; - e.Z = F; - }; - e.X = ; -}; - -FracRun { - 0 e.X = ; - s.I (e.N) e.P, : { - Halt = e.N; - Next e.N2 = e.N (e.N2) e.P>; - }; -}; - -FracStep { - (e.N) = Halt; - (e.N) ((e.Num) e.Denom) e.P, - ) e.Denom>: { - (e.N2) 0 = Next e.N2; - e.X = ; - }; -}; - -Prog { - e.X, : T (e.F) e.R = (e.F) ; - e.X = ; -}; - -Frac { - e.X, : T (e.N) e.X2, - : '/' e.X3, - : T (e.D) e.X4 = - T ((e.N) e.D) e.X4; - e.X = F e.X; -}; - -Num { - e.X, >: { - () e.R = F e.R; - (e.N) e.R = T () e.R; - }; -}; - -Span { - (e.M) (e.S) s.C e.X, e.S: e.1 s.C e.2 = ; - (e.M) (e.S) e.X = (e.M) e.X; - (e.S) e.X = ; -}; - -SkipWs { - s.C e.X, ' \n\t': e.1 s.C e.2 = ; - e.X = e.X; -}; diff --git a/Task/Fractran/Rust/fractran.rs b/Task/Fractran/Rust/fractran.rs deleted file mode 100644 index e73a574558..0000000000 --- a/Task/Fractran/Rust/fractran.rs +++ /dev/null @@ -1,75 +0,0 @@ -use std::io; - -struct Fractran { - start: i32, - limit: i32, -} - -impl Fractran { - fn new() -> Self { - Fractran { - start: 0, - limit: 0, - } - } - - fn run(&mut self, program: &str, start: i32, limit: i32) { - self.start = start; - self.limit = limit; - - // Parse the program string into fraction pairs - let fractions: Vec<(f64, f64)> = program - .split_whitespace() - .filter_map(|fraction_str| { - if let Some(pos) = fraction_str.find('/') { - let numerator = fraction_str[..pos].parse::().ok()?; - let denominator = fraction_str[pos + 1..].parse::().ok()?; - Some((numerator, denominator)) - } else { - None - } - }) - .collect(); - - self.exec(&fractions); - } - - fn exec(&mut self, fractions: &[(f64, f64)]) { - let mut count = 0; - - while count < self.limit { - println!("{} : {}", count, self.start); - count += 1; - - let mut found = false; - - for &(numerator, denominator) in fractions { - let result = self.start as f64 * (numerator / denominator); - - // Check if result is a whole number - if (result - result.floor()).abs() < f64::EPSILON { - self.start = result as i32; - found = true; - break; - } - } - - if !found { - break; - } - } - } -} - -fn main() { - let mut fractran = Fractran::new(); - fractran.run( - "17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1", - 2, - 15 - ); - - // Wait for user input (equivalent to cin.get()) - let mut input = String::new(); - io::stdin().read_line(&mut input).expect("Failed to read line"); -} diff --git a/Task/Fractran/SETL/fractran.setl b/Task/Fractran/SETL/fractran.setl deleted file mode 100644 index 05f2b18236..0000000000 --- a/Task/Fractran/SETL/fractran.setl +++ /dev/null @@ -1,52 +0,0 @@ -program fractran; - p := parse_fractran( - "17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 " + - "1/17 11/13 13/11 15/14 15/2 55/1" - ); - - print(frac_run_steps(p, 2, 15)); - print(frac_primes(p, 2, 20)); - - proc frac_primes(p, n, nprimes); - primes := []; - loop for i in [1..nprimes] do - loop until n bit_and (n-1) = 0 do - n := frac_step(p, n); - end loop; - primes with:= log n/log 2; - end loop; - return primes; - end proc; - - proc frac_run_steps(p, n, steps); - return [n] + [n := frac_step(p, n) : i in [2..steps]]; - end proc; - - proc frac_step(p, n); - if exists [num, denom] in p | n * num mod denom = 0 then - return n * num div denom; - end if; - return om; - end proc; - - proc rdws(rw s); - span(s, " \t\n"); - end proc; - - proc rdnum(rw s); - rdws(s); - return val span(s, "0123456789"); - end proc; - - proc rdfrac(rw s); - if (num := rdnum(s)) = om then return om; end if; - rdws(s); - if match(s, "/") = "" then return om; end if; - if (denom := rdnum(s)) = om then return om; end if; - return [num, denom]; - end proc; - - proc parse_fractran(s); - return [f := rdfrac(s) : until f=om]; - end proc; -end program; diff --git a/Task/Fractran/Scheme/fractran.scm b/Task/Fractran/Scheme/fractran.ss similarity index 100% rename from Task/Fractran/Scheme/fractran.scm rename to Task/Fractran/Scheme/fractran.ss diff --git a/Task/Fractran/TI-83-BASIC/fractran.basic b/Task/Fractran/TI-83-BASIC/fractran.basic index c501d5df6a..3c39e388a9 100644 --- a/Task/Fractran/TI-83-BASIC/fractran.basic +++ b/Task/Fractran/TI-83-BASIC/fractran.basic @@ -5,15 +5,15 @@ Dim(LA)->U T->Dim(LC) For(I,1,T) - 1->J: 1->F - While J<=U and F=1 - If remainder(N,LB(J))=0 - Then - Disp N - N->LC(I) - iPart(N/LB(J))*LA(J)->N - 0->F - End - J+1->J - End + 1->J: 1->F + While J<=U and F=1 + If remainder(N,LB(J))=0 + Then + Disp N + N->LC(I) + iPart(N/LB(J))*LA(J)->N + 0->F + End + J+1->J + End End diff --git a/Task/Fractran/Tcl/fractran-1.tcl b/Task/Fractran/Tcl/fractran-1.tcl index 6a0acc52ec..50932aaba5 100644 --- a/Task/Fractran/Tcl/fractran-1.tcl +++ b/Task/Fractran/Tcl/fractran-1.tcl @@ -3,42 +3,42 @@ package require Tcl 8.6 oo::class create Fractran { variable fracs nco constructor {fractions} { - set fracs {} - foreach frac $fractions { - if {[regexp {^(\d+)/(\d+),?$} $frac -> num denom]} { - lappend fracs $num $denom - } else { - return -code error "$frac is not a supported fraction" - } - } - if {![llength $fracs]} { - return -code error "need at least one fraction" - } + set fracs {} + foreach frac $fractions { + if {[regexp {^(\d+)/(\d+),?$} $frac -> num denom]} { + lappend fracs $num $denom + } else { + return -code error "$frac is not a supported fraction" + } + } + if {![llength $fracs]} { + return -code error "need at least one fraction" + } } method execute {n {steps 15}} { - set co [coroutine [incr nco] my Generate $n] - for {set i 0} {$i < $steps} {incr i} { - lappend result [$co] - } - catch {rename $co ""} - return $result + set co [coroutine [incr nco] my Generate $n] + for {set i 0} {$i < $steps} {incr i} { + lappend result [$co] + } + catch {rename $co ""} + return $result } method Step {n} { - foreach {num den} $fracs { - if {$n % $den} continue - return [expr {$n * $num / $den}] - } - return -code break + foreach {num den} $fracs { + if {$n % $den} continue + return [expr {$n * $num / $den}] + } + return -code break } method Generate {n} { - yield [info coroutine] - while 1 { - yield $n - set n [my Step $n] - } - return -code break + yield [info coroutine] + while 1 { + yield $n + set n [my Step $n] + } + return -code break } } diff --git a/Task/Fractran/Tcl/fractran-2.tcl b/Task/Fractran/Tcl/fractran-2.tcl index 21da1ffe97..a61af1865b 100644 --- a/Task/Fractran/Tcl/fractran-2.tcl +++ b/Task/Fractran/Tcl/fractran-2.tcl @@ -2,10 +2,10 @@ oo::objdefine $ft method pow2 {n} { set co [coroutine [incr nco] my Generate 2] set pows {} while {[llength $pows] < $n} { - set item [$co] - if {($item & ($item-1)) == 0} { - lappend pows $item - } + set item [$co] + if {($item & ($item-1)) == 0} { + lappend pows $item + } } return $pows } diff --git a/Task/Fractran/UNIX-Shell/fractran.sh b/Task/Fractran/UNIX-Shell/fractran.sh index bf28e57eb8..916bfce39b 100644 --- a/Task/Fractran/UNIX-Shell/fractran.sh +++ b/Task/Fractran/UNIX-Shell/fractran.sh @@ -10,10 +10,10 @@ t=0 n=72 echo "steps of computation" > steps.csv while [ $t -le 6 ]; do - if [ $(($n*${ns[$t]}%${ds[$t]})) -eq 0 ]; then - let "n=$(($n*${ns[$t]}/${ds[$t]}))" - let "t=0" - factor $n >> steps.csv - fi - let "t=$t+1" + if [ $(($n*${ns[$t]}%${ds[$t]})) -eq 0 ]; then + let "n=$(($n*${ns[$t]}/${ds[$t]}))" + let "t=0" + factor $n >> steps.csv + fi + let "t=$t+1" done diff --git a/Task/Fractran/Wren/fractran.wren b/Task/Fractran/Wren/fractran.wren index b719acd12d..1bcd949761 100644 --- a/Task/Fractran/Wren/fractran.wren +++ b/Task/Fractran/Wren/fractran.wren @@ -1,4 +1,4 @@ -import "./big" for BigInt, BigRat +import "/big" for BigInt, BigRat var isPowerOfTwo = Fn.new { |bi| bi & (bi - BigInt.one) == BigInt.zero } diff --git a/Task/Fractran/Zkl/fractran-1.zkl b/Task/Fractran/Zkl/fractran-1.zkl index ca49aa5d7d..ab1e3d8182 100644 --- a/Task/Fractran/Zkl/fractran-1.zkl +++ b/Task/Fractran/Zkl/fractran-1.zkl @@ -2,14 +2,14 @@ var fracs="17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17," "11/13, 13/11, 15/14, 15/2, 55/1"; fcn fractranW(n,fracsAsOneBigString){ //-->Walker (iterator) fracs:=(fracsAsOneBigString-" ").split(",").apply( - fcn(frac){ frac.split("/").apply("toInt") }); //( (n,d), (n,d), ...) + fcn(frac){ frac.split("/").apply("toInt") }); //( (n,d), (n,d), ...) Walker(fcn(rn,fracs){ n:=rn.value; foreach a,b in (fracs){ - if(n*a%b == 0){ - rn.set(n*a/b); - return(n); - } + if(n*a%b == 0){ + rn.set(n*a/b); + return(n); + } } }.fp(Ref(n),fracs)) } diff --git a/Task/Fractran/Zkl/fractran-3.zkl b/Task/Fractran/Zkl/fractran-3.zkl index 718365473b..00de8a061b 100644 --- a/Task/Fractran/Zkl/fractran-3.zkl +++ b/Task/Fractran/Zkl/fractran-3.zkl @@ -2,9 +2,9 @@ var [const] BN=Import("zklBigNum"); // libGMP fcn fractranPrimes{ foreach n,fr in ([1..].zip(fractranW(BN(2),fracs))){ if(fr.num1s==1){ - p:=(fr.toString(2) - "1").len(); // count zeros - if(p>1) - println("Prime %3d from the nth Fractran(%8d): %d".fmt(p,n,fr)); + p:=(fr.toString(2) - "1").len(); // count zeros + if(p>1) + println("Prime %3d from the nth Fractran(%8d): %d".fmt(p,n,fr)); } } } diff --git a/Task/French-Republican-calendar/C++/french-republican-calendar.cpp b/Task/French-Republican-calendar/C++/french-republican-calendar.cpp deleted file mode 100644 index ec13592d10..0000000000 --- a/Task/French-Republican-calendar/C++/french-republican-calendar.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -const std::vector MONTHS = { - "Vendemiaire", "Brumaire", "Frimaire", "Nivose", "Pluviose", "Ventose", "Germinal", - "Floreal", "Prairial", "Messidor", "Thermidor", "Fructidor", "Sansculottide" }; - -const std::vector SANSCULOTTIDES = { - "Fete de la vertu", "Fete du genie", "Fete du travail", - "Fete de l'opinion", "Fete des recompenses", "Fete de la Revolution" }; - -const std::vector GREGORIAN_MONTHS = { - "January", "February", "March", "April", "May", "June", "July", "August", - "September", "October", "November", "December" }; - -const std::chrono::year_month_day INTRODUCTION_DATE = - { std::chrono::year{1792}, std::chrono::month{9}, std::chrono::day{22} }; - -const std::chrono::year_month_day TERMINATION_DATE = - { std::chrono::year{1805}, std::chrono::month{12}, std::chrono::day{31} }; - -struct French_RC_Date { - uint32_t year, month, day; -}; - -std::vector split_string(const std::string& text, const char& delimiter) { - std::vector words; - std::istringstream stream(text); - std::string word; - while ( std::getline(stream, word, delimiter) ) { - words.emplace_back(word); - } - return words; -} - -uint32_t index_of(const std::vector& vec, const std::string& element) { - auto iter = std::find(vec.begin(), vec.end(), element); - return std::distance(vec.begin(), iter); -} - -uint32_t additional_days_for_year(const uint32_t& year) { - return ( year > 11 ) ? 3 : ( year > 7 ) ? 2 : ( year > 3 ) ? 1 : 0; -} - -std::string to_french_rc_date_string(French_RC_Date french_rc_date) { - if ( french_rc_date.month < 13 ) { - return std::to_string(french_rc_date.day) + " " + MONTHS[french_rc_date.month - 1] - + " " + std::to_string(french_rc_date.year); - } - return SANSCULOTTIDES[french_rc_date.day - 1] + " " + std::to_string(french_rc_date.year); -} - -std::string to_gregorian_date_string(std::chrono::year_month_day gregorian_date) { - const uint32_t year = static_cast(gregorian_date.year()); - const uint32_t month = static_cast(gregorian_date.month()); - const uint32_t day = static_cast(gregorian_date.day()); - const std::string month_string = GREGORIAN_MONTHS[month - 1]; - return std::to_string(day) + " " + month_string + " " + std::to_string(year); -} - -std::chrono::year_month_day parse_gregorian_date(const std::string& gregorian_string) { - std::vector splits = split_string(gregorian_string, ' '); - const uint32_t month = index_of(GREGORIAN_MONTHS, splits[1]) + 1; - return std::chrono::year_month_day{std::chrono::year{std::stoi(splits[2])}, - std::chrono::month{month}, std::chrono::day{static_cast(std::stoi(splits[0]))}}; -} - -French_RC_Date parse_french_rc_date(const std::string& french_rc_date) { - std::vector splits = split_string(french_rc_date, ' '); - if ( splits.size() == 3 ) { - const uint32_t year = std::stoi(splits[2]); - const uint32_t month = index_of(MONTHS, splits[1]) + 1; - const uint32_t day = std::stoi(splits[0]); - return French_RC_Date(year, month, day); - } - - std::string year_string = splits[splits.size() - 1]; - const uint32_t year = std::stoi(year_string); - std::string sansculottides_day = french_rc_date.substr(0, french_rc_date.size() - year_string.size() - 1); - const uint32_t day = index_of(SANSCULOTTIDES, sansculottides_day) + 1; - return French_RC_Date(year, 13, day); -} - -French_RC_Date to_french_rc_date(const std::chrono::year_month_day& gregorian_date) { - const int32_t days_before = - ( std::chrono::sys_days(TERMINATION_DATE) - std::chrono::sys_days(gregorian_date) ).count(); - const int32_t days_after = - ( std::chrono::sys_days(gregorian_date) - std::chrono::sys_days(INTRODUCTION_DATE) ).count(); - if ( days_after < 0 || days_before < 0 ) { - throw std::invalid_argument("French Republican Calendar date out of range."); - } - - uint32_t year = ( days_after + 366 ) / 365; - uint32_t days = ( days_after + 366 ) % 365 - additional_days_for_year(year); - if ( days == 0 ) { - year -= 1; - days += 366; - } - - if ( days < 361 ) { - return French_RC_Date(year, days / 30 + 1, days % 30); - } - return French_RC_Date(year, 13, days - 360); -} - -std::chrono::year_month_day to_gregorian_date(French_RC_Date french_rc_date) { - const uint32_t days = ( french_rc_date.year - 1 ) * 365 + additional_days_for_year(french_rc_date.year) - + ( french_rc_date.month - 1 ) * 30 + french_rc_date.day - 1; - return std::chrono::sys_days(INTRODUCTION_DATE) + std::chrono::days(days); -} - -int main() { - std::vector gregorian_strings = { - "22 September 1792", "20 May 1795", "15 July 1799", "23 September 1803", "31 December 1805" }; - - std::vector french_rc_strings = { }; - for ( const std::string& gregorian_string : gregorian_strings ) { - std::chrono::year_month_day gregorian_date = parse_gregorian_date(gregorian_string); - French_RC_Date french_rc_date = to_french_rc_date(gregorian_date); - const std::string french_rc_date_string = to_french_rc_date_string(french_rc_date); - french_rc_strings.emplace_back(french_rc_date_string); - std::cout << gregorian_string << " => " << french_rc_date_string << "\n"; - } - std::cout << "\n"; - - for ( const std::string& french_rc_string : french_rc_strings ) { - French_RC_Date french_rc_date = parse_french_rc_date(french_rc_string); - std::chrono::year_month_day gregorian_date = to_gregorian_date(french_rc_date); - const std::string gregorian_date_string = to_gregorian_date_string(gregorian_date); - std::cout << french_rc_string << " => " << gregorian_date_string << "\n"; - } -} diff --git a/Task/French-Republican-calendar/EasyLang/french-republican-calendar.easy b/Task/French-Republican-calendar/EasyLang/french-republican-calendar.easy deleted file mode 100644 index cd5d943873..0000000000 --- a/Task/French-Republican-calendar/EasyLang/french-republican-calendar.easy +++ /dev/null @@ -1,99 +0,0 @@ -func repLeap y . - return if (y + 1) mod 4 = 0 and ((y + 1) mod 100 <> 0 or (y + 1) mod 400 = 0) -. -func greLeap y . - return if y mod 4 = 0 and y mod 100 <> 0 or y mod 400 = 0 -. -gregmd[] = [ 31 28 31 30 31 30 31 31 30 31 30 31 ] -greg$[] = [ "January" "February" "March" "April" "May" "June" "July" "August" "September", "October" "November" "December" ] -repu$[] = [ "Vendémiaire" "Brumaire" "Frimaire" "Nivôse" "Pluviôse" "Ventôse" "Germinal" "Floréal" "Prairial" "Messidor" "Thermidor" "Fructidor" "Sansculottide" ] -sanscu$[] = [ "Fête de la vertu" "Fête du génie" "Fête du travail" "Fête de l'opinion" "Fête des récompenses" "Fête de la Révolution" ] -proc split s$ &d &m &y . - if substr s$ 1 4 = "Fête" - m = 13 - for d to len sanscu$[] - sc$ = sanscu$[d] - if substr s$ 1 len sc$ = sc$ - y = number substr s$ (len sc$ + 1) 99 - break 1 - . - . - else - h = strpos s$ " " - d = number substr s$ 1 h - my$ = substr s$ (h + 1) 99 - h = strpos my$ " " - m$ = substr my$ 1 (h - 1) - y = number substr my$ (h + 1) 99 - months$[] = greg$[] - if y < 1792 : months$[] = repu$[] - for m to 12 : if months$[m] = m$ : break 1 - . -. -func greToDay d m y . - if m < 3 - y -= 1 - m += 12 - . - return y * 36525 div 100 - y div 100 + y div 400 + 306 * (m + 1) div 10 + d - 654842 -. -func repToDay d m y . - if m = 13 - m -= 1 - d += 30 - . - d -= repLeap y - return 365 * y + (y + 1) div 4 - (y + 1) div 100 + (y + 1) div 400 + 30 * m + d - 395 -. -proc dayToGre day &d &m &y . - y = day * 100 div 36525 - d = day - y * 36525 div 100 + 21 - y += 1792 - d += y div 100 - y div 400 - 13 - m = 9 - while d > gregmd[m] - d -= gregmd[m] - m += 1 - if m = 13 - m = 1 - y += 1 - gregmd[2] = 28 + greLeap y - . - . -. -proc dayToRep day &d &m &y . - y = (day - 1) * 100 div 36525 - if repLeap y = 1 : y -= 1 - y += 1 - d = day - y * 36525 div 100 + 365 + y div 100 - y div 400 - m = 1 - sanscul = 5 + repLeap y - while d > 30 - d -= 30 - m += 1 - if m = 13 - if d > sanscul - d -= sanscul - m = 1 - y += 1 - sanscul = 5 + repLeap y - . - . - . -. -test$[] = [ "1 Vendémiaire 1" "1 Prairial 3" "27 Messidor 7" "Fête de la Révolution 11" "10 Nivôse 14" "22 September 1792" "20 May 1795" "15 July 1799" "23 September 1803" "31 December 1805" ] -for s$ in test$[] - write s$ & " => " - split s$ day, month, year - if year < 1792 - dayToGre (repToDay day month year) day month year - print day & " " & greg$[month] & " " & year - else - dayToRep (greToDay day month year) day month year - if month = 13 - print sanscu$[day] & " " & year - else - print day & " " & repu$[month] & " " & year - . - . -. diff --git a/Task/French-Republican-calendar/Fortran/french-republican-calendar.f b/Task/French-Republican-calendar/Fortran/french-republican-calendar.f deleted file mode 100644 index b5705acc4f..0000000000 --- a/Task/French-Republican-calendar/Fortran/french-republican-calendar.f +++ /dev/null @@ -1,338 +0,0 @@ -program calendar_converter - implicit none - - character(len=40) :: input_date,tstring - integer :: year, month, day, jd, i - logical :: is_gregorian -! - ! Test date arrays - character(len=*), parameter :: rep_dates(5) = [ & - '1 Vendemiaire 1 ', & - '1 Prairial 3 ', & - '27 Messidor 7 ', & - 'Fete de la Revolution 11 ', & - '10 Nivose 14 ' ] - - character(len=*), parameter :: greg_dates(5) = [ & - '22 September 1792 ', & - '20 May 1795 ', & - '15 July 1799 ', & - '23 September 1803 ', & - '31 December 1805 ' ] - do - print *, "Enter date (format examples):" - print *, "Gregorian: '20 May 1795' or Republican: '1 Prairial 3'" - print *, "Press Enter to exit" - read (*, '(a)') input_date - input_date = to_lower(input_date) - - if (len_trim(input_date) == 0) exit - - ! Try parsing as Gregorian first - if (parse_gregorian(input_date, year, month, day)) then - is_gregorian = .true. - else if (parse_republican(input_date, year, month, day)) then - is_gregorian = .false. - else - print *, "Invalid date format" - cycle - end if - - if (is_gregorian) then - jd = gregorian_to_jd(year, month, day) - call jd_to_republican(jd, year, month, day) - print *, "Republican date: ", republican_date_string(year, month, day) - else - jd = republican_to_jd(year, month, day) - call jd_to_gregorian(jd, year, month, day) - print *, "Gregorian date: ", gregorian_date_string(year, month, day) - end if - end do - - - ! Automatic conversions when exiting - print *, 'Converting predefined Republican dates:' - do i = 1, size(rep_dates) - tstring = to_lower(rep_dates(i)) - if (parse_republican(trim(tstring), year, month, day)) then - jd = republican_to_jd(year, month, day) - call jd_to_gregorian(jd, year, month, day) - print *, rep_dates(i), ' => ', gregorian_date_string(year, month, day) - end if - end do - - print '(/,a)','Converting predefined Gregorian dates:' - do i = 1, size(greg_dates) - tstring = to_lower(greg_dates(i)) - if (parse_gregorian(trim(tstring), year, month, day)) then - jd = gregorian_to_jd(year, month, day) - call jd_to_republican(jd, year, month, day) - print *, greg_dates(i), ' => ', republican_date_string(year, month, day) - end if - end do - -contains - - function parse_gregorian(str, y, m, d) result(success) - character(*), intent(in) :: str - integer, intent(out) :: y, m, d - logical :: success - character(len=3) :: mon - integer :: ios - - read(str, *, iostat=ios) d, mon, y - if (ios == 0) then - m = month_number(mon) - success = (m > 0) - else - success = .false. - end if - end function parse_gregorian - - function parse_republican(str, y, m, d) result(success) - character(*), intent(in) :: str - integer, intent(out) :: y, m, d - logical :: success - character(len=35) :: tokens(10) - integer :: num_tokens, i, ios - character(len=100) :: festival_name - - success = .false. - tokens = ' ' - call tokenize(str, tokens, num_tokens) - - if (num_tokens < 2) return - - if (.not. is_numeric(tokens(num_tokens))) return - read(tokens(num_tokens), *, iostat=ios) y - if (ios /= 0) return - - if (num_tokens == 3) then - if (.not. is_numeric(tokens(1))) return - read(tokens(1), *, iostat=ios) d - if (ios /= 0) return - - do m = 1, 12 - if (trim(tokens(2)) == republican_months(m)) then - success = .true. - return - end if - end do - else if (num_tokens >= 4) then - if (tokens(1) /= 'fete') return - - festival_name = tokens(1) - do i = 2, num_tokens-1 - festival_name = festival_name(1:len_trim(festival_name)) // ' ' // tokens(i) - end do - do i = 1, 6 - if (festival_name == sansculottides(i)) then - m = 13 - d = i - success = .true. - return - end if - end do - end if - end function parse_republican - - function to_lower(str) result(lower_str) - character(*), intent(in) :: str - character(len(str)) :: lower_str - integer :: i, c - lower_str = str - do i = 1, len(str) - c = iachar(str(i:i)) - if (c >= 65 .and. c <= 90) lower_str(i:i) = achar(c + 32) - end do - end function to_lower - - subroutine tokenize(input_string, tokens, num_tokens) - character(*), intent(in) :: input_string - character(*), intent(out) :: tokens(:) - integer, intent(out) :: num_tokens - integer :: i, start_idx, end_idx, str_len - character(len=len(input_string)) :: temp_str - - num_tokens = 0 - temp_str = adjustl(input_string) - str_len = len_trim(temp_str) - if (str_len == 0) return - - start_idx = 1 - do i = 1, str_len - if (scan(temp_str(i:i), " -/,.") > 0) then - end_idx = i - 1 - if (end_idx >= start_idx) then - num_tokens = num_tokens + 1 - if (num_tokens > size(tokens)) exit - tokens(num_tokens) = temp_str(start_idx:end_idx) - end if - start_idx = i + 1 - end if - end do - - if (start_idx <= str_len) then - num_tokens = num_tokens + 1 - if (num_tokens <= size(tokens)) then - tokens(num_tokens) = temp_str(start_idx:) - end if - end if - end subroutine tokenize - - function is_numeric(str) result(res) - character(*), intent(in) :: str - logical :: res - integer :: ios - integer :: dummy - read(str, *, iostat=ios) dummy - res = (ios == 0) - end function is_numeric - - function republican_months(m) result(namer) - integer, intent(in) :: m - character(len=12) :: namer - character(len=12), parameter :: names(13) = [character(len=12):: & - 'vendemiaire ', 'brumaire ', 'frimaire ', 'nivose ', & - 'pluviose ', 'ventose ', 'germinal ', 'floreal ', & - 'prairial ', 'messidor ', 'thermidor ', 'fructidor ', & - 'sansculott' ] - namer = names(m) - end function republican_months - - function sansculottides(d) result(name) - integer, intent(in) :: d - character(len=21) :: name - character(len=21), parameter :: names(6) = [ character(len=21)::& - 'fete de la vertu ', 'fete du genie ', & - 'fete du travail ', 'fete de l''opinion ', & - 'fete des recompenses', 'fete de la revolution' ] - name = names(d) - end function sansculottides - - function gregorian_date_string(y, m, d) result(str) - integer, intent(in) :: y, m, d - character(len=21) :: str - write(str, '(i0, 1x, a, 1x, i0)') d, trim(gregorian_months(m)), y - end function gregorian_date_string - - function republican_date_string(y, m, d) result(str) - integer, intent(in) :: y, m, d - character(len=30) :: str - character(len=30) :: holder - if (m == 13) then - holder = uppercasefirst(trim(sansculottides(d))) - write(str, '(a, 1x, i0)') trim(holder), y - else - holder = uppercasefirst(trim(republican_months(m))) - write(str, '(i0, 1x, a, 1x, i0)') d, trim(holder), y - end if - end function republican_date_string - - function month_number(mon) result(m) - character(*), intent(in) :: mon - integer :: m - character(len=3) :: months(12) = ['jan','feb','mar','apr','may','jun', & - 'jul','aug','sep','oct','nov','dec'] - do m = 1, 12 - if (months(m) == mon) return - end do - m = 0 - end function month_number - - function gregorian_months(m) result(name) - integer, intent(in) :: m - character(len=3) :: name - character(len=3) :: names(12) = ['Jan','Feb','Mar','Apr','May','Jun', & - 'Jul','Aug','Sep','Oct','Nov','Dec'] - name = names(m) - end function gregorian_months - - function republican_to_jd(year, month, day) result(jd) - integer, intent(in) :: year, month, day - integer :: jd - integer, parameter :: epoch_jd = 2375840 - integer :: total_days, leap_years, y - - if (month < 1 .or. month > 13) error stop "Invalid Republican month" - if (day < 1 .or. (month < 13 .and. day > 30)) error stop "Invalid Republican day" - if (month == 13 .and. day > 6) error stop "Invalid Sansculottides day" - - total_days = (year - 1) * 365 + (month - 1) * 30 + (day - 1) - leap_years = count([(is_republican_leap(y), y = 1, year-1)]) - total_days = total_days + leap_years - jd = epoch_jd + total_days - end function republican_to_jd - - integer function gregorian_to_jd(year, month, day) - integer, intent(in) :: year, month, day - integer :: a, y, m - a = (14 - month) / 12 - y = year + 4800 - a - m = month + 12*a - 3 - gregorian_to_jd = day + ((153*m + 2)/5) + 365*y + y/4 - y/100 + y/400 - 32045 - end function gregorian_to_jd - - pure logical function is_republican_leap(y) - integer, intent(in) :: y - integer, parameter :: historical_leaps(*) = [3, 7, 11, 15, 20] - is_republican_leap = any(historical_leaps == y) - end function is_republican_leap - - subroutine jd_to_gregorian(jd, year, month, day) - integer, intent(in) :: jd - integer, intent(out) :: year, month, day - integer :: a, b, c, d, e, m - a = jd + 32044 - b = (4*a + 3)/146097 - c = a - (146097*b)/4 - d = (4*c + 3)/1461 - e = c - (1461*d)/4 - m = (5*e + 2)/153 - day = int(e - (153*m + 2)/5 + 1) - month = int(m + 3 - 12*(m/10)) - year = int(100*b + d - 4800 + (m/10)) - end subroutine jd_to_gregorian - - subroutine jd_to_republican(jd, year, month, day) - integer, intent(out) :: year, month, day - integer, intent(in) :: jd - integer, parameter :: epoch_jd = 2375840 - integer :: days_since_epoch, y, leap_days, d - - days_since_epoch = jd - epoch_jd - if (days_since_epoch < 0) error stop "Date before Republican epoch" - - year = 1 + days_since_epoch / 365 - leap_days = count([(is_republican_leap(y), y = 1, year-1)]) - - d = days_since_epoch - (year-1)*365 - leap_days - if (d < 0) then - year = year - 1 - leap_days = count([(is_republican_leap(y), y = 1, year-1)]) - d = days_since_epoch - (year-1)*365 - leap_days - end if - - if (d < 360) then - month = d/30 + 1 - day = mod(d,30) + 1 - else - month = 13 - day = d - 359 - end if - end subroutine jd_to_republican - - function uppercasefirst(str) result(result_str) - character(len=*), intent(in) :: str - character(len=len(str)) :: result_str - integer :: c - result_str = str - if (len_trim(str) > 0) then - c = iachar(str(1:1)) - if (c >= iachar('a') .and. c <= iachar('z')) then - result_str(1:1) = achar(c - 32) - end if - end if - end function uppercasefirst - -end program calendar_converter diff --git a/Task/French-Republican-calendar/Java/french-republican-calendar.java b/Task/French-Republican-calendar/Java/french-republican-calendar.java deleted file mode 100644 index 64d0ca9aa4..0000000000 --- a/Task/French-Republican-calendar/Java/french-republican-calendar.java +++ /dev/null @@ -1,106 +0,0 @@ -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.List; - -public final class FrenchRepublicanCalendar { - - public static void main(String[] args) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy"); - - List gregorianStrings = List.of( - "22 September 1792", "20 May 1795", "15 July 1799", "23 September 1803", "31 December 1805" ); - - List frenchRCStrings = new ArrayList(); - for ( String gregorianString : gregorianStrings ) { - LocalDate gregorianDate = LocalDate.parse(gregorianString, formatter); - FrenchRCDate frenchRCDate = FrenchRCDate.toFrenchRCDate(gregorianDate); - frenchRCStrings.addLast(frenchRCDate.toString()); - System.out.println(gregorianString + " => " + frenchRCDate); - } - System.out.println(); - - for ( String frenchRCString : frenchRCStrings ) { - FrenchRCDate frenchRCDate = FrenchRCDate.parse(frenchRCString); - String gregorianDate = formatter.format(frenchRCDate.toGregorianDate()); - System.out.println(frenchRCString + " => " + gregorianDate); - } - } - -} - -final class FrenchRCDate { - - public FrenchRCDate(int aYear, int aMonth, int aDay) { - year = aYear; month = aMonth; day = aDay; - } - - public LocalDate toGregorianDate() { - final int days = ( year - 1 ) * 365 + additionalDaysForYear(year) + ( month - 1 ) * 30 + day - 1; - return INTRODUCTION_DATE.plusDays(days); - } - - public String toString() { - if ( month < 13 ) { - return day + " " + MONTHS.get(month - 1) + " " + year; - } - return SANSCULOTTIDES.get(day - 1) + " " + year; - } - - public static FrenchRCDate toFrenchRCDate(LocalDate gregorianDate) { - final int daysBefore = (int) ChronoUnit.DAYS.between(gregorianDate, TERMINATION_DATE); - final int daysAfter = (int) ChronoUnit.DAYS.between(INTRODUCTION_DATE, gregorianDate); - if ( daysAfter < 0 || daysBefore < 0 ) { - throw new IllegalArgumentException("French Republican Calendar date out of range."); - } - - int year = ( daysAfter + 366 ) / 365; - int days = ( daysAfter + 366 ) % 365 - additionalDaysForYear(year); - if ( days < 1 ) { - year -= 1; - days += 366; - } - - if ( days < 361 ) { - return new FrenchRCDate(year, days / 30 + 1, days % 30); - } - return new FrenchRCDate(year, 13, days - 360); - } - - public static FrenchRCDate parse(String frenchRCDate) { - String[] splits = frenchRCDate.split(" "); - if ( splits.length == 3 ) { - final int year = Integer.valueOf(splits[2]); - final int month = MONTHS.indexOf(splits[1]) + 1; - final int day = Integer.valueOf(splits[0]); - return new FrenchRCDate(year, month, day); - } - - String yearString = splits[splits.length - 1]; - final int year = Integer.valueOf(yearString); - String sansculottidesDay = frenchRCDate.substring(0, frenchRCDate.lastIndexOf(" ")); - final int day = SANSCULOTTIDES.indexOf(sansculottidesDay) + 1; - return new FrenchRCDate(year, 13, day); - } - - public static int additionalDaysForYear(int year) { - return ( year > 11 ) ? 3 : ( year > 7 ) ? 2 : ( year > 3 ) ? 1 : 0; - } - - public static final LocalDate INTRODUCTION_DATE = LocalDate.of(1792, 9, 22); - public static final LocalDate TERMINATION_DATE = LocalDate.of(1805, 12, 31); - - private int year, month, day; - - private static final List MONTHS = List.of( - "Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse", "Ventôse", "Germinal", - "Floréal", "Prairial", "Messidor", "Thermidor", "Fructidor", "Sansculottide" - ); - - private static final List SANSCULOTTIDES = List.of( - "Fête de la vertu", "Fête du génie", "Fête du travail", - "Fête de l'opinion", "Fête des récompenses", "Fête de la Révolution" - ); - -} diff --git a/Task/French-Republican-calendar/JavaScript/french-republican-calendar.js b/Task/French-Republican-calendar/JavaScript/french-republican-calendar.js deleted file mode 100644 index 5abfc4a5ff..0000000000 --- a/Task/French-Republican-calendar/JavaScript/french-republican-calendar.js +++ /dev/null @@ -1,130 +0,0 @@ -class FrenchRCDate { - constructor(year, month, day) { - this.year = year; - this.month = month; - this.day = day; - } - - static INTRODUCTION_DATE = new Date(Date.UTC(1792, 8, 22)); // Months are zero-indexed in JS - static TERMINATION_DATE = new Date(Date.UTC(1805, 11, 31)); - - static MONTHS = [ - "Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse", "Ventôse", - "Germinal", "Floréal", "Prairial", "Messidor", "Thermidor", "Fructidor" - ]; - - static SANSCULOTTIDES = [ - "Fête de la vertu", "Fête du génie", "Fête du travail", - "Fête de l'opinion", "Fête des récompenses", "Fête de la Révolution" - ]; - - toGregorianDate() { - const days = (this.year - 1) * 365 + FrenchRCDate.additionalDaysForYear(this.year) + - (this.month - 1) * 30 + this.day - 1; - - const gregorian = new Date(FrenchRCDate.INTRODUCTION_DATE); - gregorian.setUTCDate(gregorian.getUTCDate() + days); - return gregorian; - } - - toString() { - if (this.month < 13) { - return `${this.day} ${FrenchRCDate.MONTHS[this.month - 1]} ${this.year}`; - } else { - return `${FrenchRCDate.SANSCULOTTIDES[this.day - 1]} ${this.year}`; - } - } - - static additionalDaysForYear(year) { - return year > 11 ? 3 : year > 7 ? 2 : year > 3 ? 1 : 0; - } - - static toFrenchRCDate(gregorianDate) { - const daysAfter = Math.floor((gregorianDate - FrenchRCDate.INTRODUCTION_DATE) / (1000 * 60 * 60 * 24)); - const daysBefore = Math.floor((FrenchRCDate.TERMINATION_DATE - gregorianDate) / (1000 * 60 * 60 * 24)); - - if (daysAfter < 0 || daysBefore < 0) { - throw new Error("French Republican Calendar date out of range."); - } - - let year = Math.floor((daysAfter + 366) / 365); - let days = (daysAfter + 366) % 365 - FrenchRCDate.additionalDaysForYear(year); - - if (days < 1) { - year -= 1; - days += 366; - } - - if (days < 361) { - const month = Math.floor(days / 30) + 1; - const day = days % 30 || 30; - return new FrenchRCDate(year, month, day); - } else { - const day = days - 360; - return new FrenchRCDate(year, 13, day); - } - } - - static parse(frenchRCDateString) { - const parts = frenchRCDateString.trim().split(/\s+/); - if (parts.length === 3) { - const [dayStr, monthStr, yearStr] = parts; - const year = parseInt(yearStr, 10); - const month = FrenchRCDate.MONTHS.indexOf(monthStr) + 1; - const day = parseInt(dayStr, 10); - return new FrenchRCDate(year, month, day); - } else { - const yearStr = parts[parts.length - 1]; - const year = parseInt(yearStr, 10); - const sansculottideName = parts.slice(0, -1).join(" "); - const day = FrenchRCDate.SANSCULOTTIDES.indexOf(sansculottideName) + 1; - return new FrenchRCDate(year, 13, day); - } - } -} - -// Helper to format dates like "d MMMM yyyy" -function formatDate(date) { - const months = [ - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - ]; - const day = date.getUTCDate(); - const month = months[date.getUTCMonth()]; - const year = date.getUTCFullYear(); - return `${day} ${month} ${year}`; -} - -// Main logic -const gregorianStrings = [ - "22 September 1792", - "20 May 1795", - "15 July 1799", - "23 September 1803", - "31 December 1805" -]; - -const frenchRCStrings = []; - -for (const gregorianString of gregorianStrings) { - // Parse into JS Date object - const [day, month, year] = gregorianString.split(" "); - const monthIndex = [ - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - ].indexOf(month); - const gregorianDate = new Date(Date.UTC(parseInt(year), monthIndex, parseInt(day))); - - const frenchRCDate = FrenchRCDate.toFrenchRCDate(gregorianDate); - const frenchRCString = frenchRCDate.toString(); - frenchRCStrings.push(frenchRCString); - console.log(`${gregorianString} => ${frenchRCString}`); -} - -console.log(); - -for (const frenchRCString of frenchRCStrings) { - const frenchRCDate = FrenchRCDate.parse(frenchRCString); - const gregorianDate = frenchRCDate.toGregorianDate(); - console.log(`${frenchRCString} => ${formatDate(gregorianDate)}`); -} diff --git a/Task/French-Republican-calendar/Jq/french-republican-calendar.jq b/Task/French-Republican-calendar/Jq/french-republican-calendar.jq deleted file mode 100644 index dde45845bc..0000000000 --- a/Task/French-Republican-calendar/Jq/french-republican-calendar.jq +++ /dev/null @@ -1,149 +0,0 @@ -include "Date" {search: "."}; - -### Generic functions - -def assertEq($p;$q): - if $p == $q - then . - else debug("assertion violation: \($p) != \($q)") as $debug | . - end; - -def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; - -def trim: sub("^ *";"") | sub(" *$";""); - -# Input: string such as "12 Mar 2012" -# Output: Date -def parseDayMonthYear: - def months: - {Jan:1, Feb:2, Mar:3, Apr: 4, May: 5, Jun: 6, - Jul:7, Aug:8, Sep:9, Oct:10, Nov:11, Dec:12}; - capture("(?[0-9]+) *(?[A-Za-z]+) *(?[0-9]+)") - | .month |= months[ .[:3] ] - | map_values(tonumber) - | {year, month, day}; - -### French Republican Calendar (FRC) - -def introductionDate: Date(1792; 9; 22); - -# Use the 'continuous method' for years after 1805 -def isLeapYearFRC: - (. + 1) - | (. % 4 == 0) and ((. % 100 != 0) or (. % 400 == 0)); - -# If the numbers $year, $month, and $day specify a valid date -# in the French Republican Calendar, then emit {$year, $month, $day}; -# otherwise generate an informative error message. -def FrenchRCDate($year; $month; $day): - def err(msg): "Invalid date (\(msg)): FrenchRCDate(\($year); \($month); \($day))" | error; - if ($year <= 0 or $month < 1 or $month > 13) then err(if $year <= 0 then "year" else "month" end) end - | if $month < 13 - then if $day < 1 or $day > 30 then err("day") end - else ($year | isLeapYearFRC) as $leap - | if $leap and ($day < 1 or $day > 6) then err("invalid day in leap year") end - | if ($leap|not) and ($day < 1 or $day > 5) then err("invalid day in non-leap year") end - end - | {$year, $month, $day}; - -# for convenience we treat 'Sansculottide' as an extra month with 5 or 6 days -def months: - ["Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse", "Ventôse", "Germinal", - "Floréal", "Prairial", "Messidor", "Thermidor", "Fructidor", "Sansculottide"] ; - -def intercal: - ["Fête de la vertu", "Fête du génie", "Fête du travail", - "Fête de l'opinion", "Fête des récompenses", "Fête de la Révolution"]; - -# Input: a string specifying a FRC date -def parse: - . as $frcDate - | (trim|split(" ")) as $splits - | if $splits|length == 3 - then (months | index($splits[1]) + 1) as $month - | if $month < 1 or $month > 13 then "Invalid month." | error end - | ($splits[2]|tonumber) as $year - | if $year < 1 then "Invalid year." | error end - | (if ($month < 13) then 30 elif $year|isLeapYearFRC then 6 else 5 end) as $monthLength - | ($splits[0] | tonumber) as $day - | if $day < 1 or $day > $monthLength then "Invalid day." | error end - | FrenchRCDate($year; $month; $day) - - elif ($splits|length | IN(4,5)) - then $splits[-1] as $yearStr - | ($yearStr|tonumber) as $year - | if $year < 1 then "Invalid year." | error end - | ($frcDate | trim[0: -($yearStr|length + 1)] ) as $scDay - | (intercal | index($scDay) + 1) as $day - | (if $year | isLeapYearFRC then 6 else 5 end) as $maxDay - | if $day < 1 or $day > $maxDay then "Invalid day." | error end - | FrenchRCDate($year; 13; $day) - else "Invalid French Republican date." | error - end -; - -# Input: Date (Gregorian) -# Output: -def fromLocalDate: - # $start and $finish should be two Date objects - def daysFrom($start; $finish): - ($finish|daysBeforeDate) - ($start|daysBeforeDate); - - (daysFrom(introductionDate; .) + 1) as $daysDiff - | if ($daysDiff <= 0) then "Date can't be before 22 September 1792." | error end - | {year: 1, startDay: 1} - | until(.done; - (.startDay + (if .year|isLeapYearFRC then 365 else 364 end)) as $endDay - | if ($daysDiff >= .startDay and $daysDiff <= $endDay) then .done = true - else .year += 1 - | .startDay = $endDay + 1 - end ) - | ($daysDiff - .startDay) as $remDays - | (($remDays / 30)|floor) as $month - | ($remDays - $month * 30) as $day - | FrenchRCDate(.year; $month + 1; $day + 1) -; - -# Input: an FRC Date -def toString: - if .month < 13 then "\(.day) \(months[.month - 1]) \(.year)" - else "\(intercal[.day - 1]) \(.year)" - end; - -# Input: an FRC Date -def toLocalDate: - (reduce range(1; .year) as $i (0; . + (if $i|isLeapYearFRC then 366 else 365 end))) as $sumDays - | ((.month - 1) * 30 + .day - 1) as $dayInYear - | introductionDate | addDays($sumDays + $dayInYear) ; - - -### Examples - -def dates: [ - "22 September 1792", "20 May 1795", "15 July 1799", "23 September 1803", - "31 December 1805", "18 March 1871", "25 August 1944", "19 September 2016", - "22 September 2017", "28 September 2017" -]; - -def task: - def format: - "\(.day) \(monthNames[.month]) \(.year)"; - - dates as $dates - | reduce range(0; $dates|length) as $i ({}; - .date = $dates[$i] - | .thisDate = (.date|parseDayMonthYear) - | .frcd = (.thisDate|fromLocalDate) - | .frcDates[$i] = (.frcd|toString) - | .emit += "\(.date|lpad(26)) => \(.frcDates[$i])\n") - | .emit, - - # now process the other way around - range(0; $dates|length) as $i - | .frcDates[$i] as $frcDate - | ($frcDate|parse|toLocalDate|format) as $lds - | assertEq($dates[$i]; $lds) - | "\($frcDate|lpad(26)) => \($lds)" -; - -task diff --git a/Task/French-Republican-calendar/Julia/french-republican-calendar.jl b/Task/French-Republican-calendar/Julia/french-republican-calendar.julia similarity index 100% rename from Task/French-Republican-calendar/Julia/french-republican-calendar.jl rename to Task/French-Republican-calendar/Julia/french-republican-calendar.julia diff --git a/Task/French-Republican-calendar/Kotlin/french-republican-calendar.kts b/Task/French-Republican-calendar/Kotlin/french-republican-calendar.kotlin similarity index 100% rename from Task/French-Republican-calendar/Kotlin/french-republican-calendar.kts rename to Task/French-Republican-calendar/Kotlin/french-republican-calendar.kotlin diff --git a/Task/French-Republican-calendar/Rust/french-republican-calendar.rs b/Task/French-Republican-calendar/Rust/french-republican-calendar.rs deleted file mode 100644 index 873b6c090d..0000000000 --- a/Task/French-Republican-calendar/Rust/french-republican-calendar.rs +++ /dev/null @@ -1,177 +0,0 @@ -use chrono::{Datelike, Duration, NaiveDate}; - -const MONTHS: [&str; 13] = [ - "Vendemiaire", "Brumaire", "Frimaire", "Nivose", "Pluviose", "Ventose", "Germinal", - "Floreal", "Prairial", "Messidor", "Thermidor", "Fructidor", "Sansculottide", -]; - -const SANSCULOTTIDES: [&str; 6] = [ - "Fete de la vertu", "Fete du genie", "Fete du travail", - "Fete de l'opinion", "Fete des recompenses", "Fete de la Revolution", -]; - -const GREGORIAN_MONTHS: [&str; 12] = [ - "January", "February", "March", "April", "May", "June", "July", "August", - "September", "October", "November", "December", -]; - -const INTRODUCTION_DATE: NaiveDate = match NaiveDate::from_ymd_opt(1792, 9, 22) { - Some(date) => date, - None => panic!("Invalid introduction date"), -}; - -const TERMINATION_DATE: NaiveDate = match NaiveDate::from_ymd_opt(1805, 12, 31) { - Some(date) => date, - None => panic!("Invalid termination date"), -}; - -#[derive(Debug, Clone, Copy)] -struct FrenchRcDate { - year: u32, - month: u32, - day: u32, -} - -fn split_string(text: &str, delimiter: char) -> Vec<&str> { - text.split(delimiter).collect() -} - -fn index_of(vec: &[&str], element: &str) -> u32 { - vec.iter() - .position(|&x| x == element) - .map(|i| i as u32) - .unwrap_or_else(|| panic!("Element not found: {}", element)) -} - -fn additional_days_for_year(year: u32) -> u32 { - if year > 11 { - 3 - } else if year > 7 { - 2 - } else if year > 3 { - 1 - } else { - 0 - } -} - -fn to_french_rc_date_string(french_rc_date: FrenchRcDate) -> String { - if french_rc_date.month < 13 { - format!( - "{} {} {}", - french_rc_date.day, MONTHS[(french_rc_date.month - 1) as usize], french_rc_date.year - ) - } else { - format!( - "{} {}", - SANSCULOTTIDES[(french_rc_date.day - 1) as usize], french_rc_date.year - ) - } -} - -fn to_gregorian_date_string(gregorian_date: NaiveDate) -> String { - let year = gregorian_date.year(); - let month = gregorian_date.month() as usize; - let day = gregorian_date.day(); - let month_string = GREGORIAN_MONTHS[month - 1]; - format!("{} {} {}", day, month_string, year) -} - -fn parse_gregorian_date(gregorian_string: &str) -> NaiveDate { - let splits: Vec<&str> = split_string(gregorian_string, ' '); - let day: u32 = splits[0].parse().expect("Invalid day"); - let month = index_of(&GREGORIAN_MONTHS, splits[1]) + 1; - let year: i32 = splits[2].parse().expect("Invalid year"); - - NaiveDate::from_ymd_opt(year, month, day) - .unwrap_or_else(|| panic!("Invalid Gregorian date: {}", gregorian_string)) -} - -fn parse_french_rc_date(french_rc_date: &str) -> FrenchRcDate { - let splits: Vec<&str> = split_string(french_rc_date, ' '); - if splits.len() == 3 { - let day: u32 = splits[0].parse().expect("Invalid day"); - let month = index_of(&MONTHS, splits[1]) + 1; - let year: u32 = splits[2].parse().expect("Invalid year"); - FrenchRcDate { year, month, day } - } else { - let year_string = splits[splits.len() - 1]; - let year: u32 = year_string.parse().expect("Invalid year"); - let sansculottides_day = &french_rc_date[..french_rc_date.len() - year_string.len() - 1]; - let day = index_of(&SANSCULOTTIDES, sansculottides_day) + 1; - FrenchRcDate { - year, - month: 13, - day, - } - } -} - -fn to_french_rc_date(gregorian_date: NaiveDate) -> FrenchRcDate { - let days_after = (gregorian_date - INTRODUCTION_DATE).num_days(); - let days_before = (TERMINATION_DATE - gregorian_date).num_days(); - - if days_after < 0 || days_before < 0 { - panic!("French Republican Calendar date out of range."); - } - - let mut year = (days_after + 366) / 365; - let mut days = (days_after + 366) % 365 - additional_days_for_year(year as u32) as i64; - - if days == 0 { - year -= 1; - days += 366; - } - - if days < 361 { - FrenchRcDate { - year: year as u32, - month: (days / 30 + 1) as u32, - day: (days % 30) as u32, - } - } else { - FrenchRcDate { - year: year as u32, - month: 13, - day: (days - 360) as u32, - } - } -} - -fn to_gregorian_date(french_rc_date: FrenchRcDate) -> NaiveDate { - let days = (french_rc_date.year - 1) * 365 - + additional_days_for_year(french_rc_date.year) - + (french_rc_date.month - 1) * 30 - + french_rc_date.day - - 1; - INTRODUCTION_DATE + Duration::days(days as i64) -} - -fn main() { - let gregorian_strings = vec![ - "22 September 1792", - "20 May 1795", - "15 July 1799", - "23 September 1803", - "31 December 1805", - ]; - - let mut french_rc_strings = Vec::new(); - - for gregorian_string in &gregorian_strings { - let gregorian_date = parse_gregorian_date(gregorian_string); - let french_rc_date = to_french_rc_date(gregorian_date); - let french_rc_date_string = to_french_rc_date_string(french_rc_date); - french_rc_strings.push(french_rc_date_string.clone()); - println!("{} => {}", gregorian_string, french_rc_date_string); - } - - println!(); - - for french_rc_string in &french_rc_strings { - let french_rc_date = parse_french_rc_date(french_rc_string); - let gregorian_date = to_gregorian_date(french_rc_date); - let gregorian_date_string = to_gregorian_date_string(gregorian_date); - println!("{} => {}", french_rc_string, gregorian_date_string); - } -} diff --git a/Task/French-Republican-calendar/Scheme/french-republican-calendar.scm b/Task/French-Republican-calendar/Scheme/french-republican-calendar.scm deleted file mode 100644 index a60062f8fd..0000000000 --- a/Task/French-Republican-calendar/Scheme/french-republican-calendar.scm +++ /dev/null @@ -1,234 +0,0 @@ -; version 1 (11 Frimaire 234) -; inspired by BBC Basic -; see https://rosettacode.org/wiki/French_Republican_calendar - -(import (scheme base) (scheme char)) - -; ex: (date->jour-mois-annee '(2025 12 1)) -> 1 12 2025 -(define (date->jour-mois-annee date) - (values (list-ref date 2) (list-ref date 1) (list-ref date 0))) - -; ex: (jours-bissextiles 1900) -> 460 -(define (jours-bissextiles annee) - (- (+ (quotient annee 4) (quotient annee 400)) (quotient annee 100))) - -; ex: (bissextile? 1900) -> #f -(define (bissextile? annee) - (and (zero? (remainder annee 4)) - (or (zero? (remainder annee 400)) (positive? (remainder annee 100))))) - -; ex: (jour-bissextile 1900) -> 0 -(define (jour-bissextile annee) - (if (bissextile? annee) 1 0)) - -; ex: (gregorien->jours '(1792 9 22)) -> 1 -; ex: (gregorien->jours '(2025 12 1)) -> 85172 -(define (gregorien->jours date) - (let*-values (((jour mois annee) (date->jour-mois-annee date)) - ((mois annee) (if (< mois 3) - (values (+ mois 12) (- annee 1)) - (values mois annee)))) - (- (+ (* annee 365) - (jours-bissextiles annee) - (exact (floor (* 30.6 (+ mois 1)))) - jour) - 654842))) - -; ex: (republicain->jours '(1 1 1)) -> 1 -; ex: (republicain->jours '(2025 12 1)) -> 85172 -(define (republicain->jours date) - (let*-values (((jour mois annee) (date->jour-mois-annee date)) - ((mois jour) (if (= mois 13) - (values 12 (+ jour 30)) - (values mois jour)))) - (- (+ (* annee 365) - (* 30 mois) - (jours-bissextiles (+ annee 1)) - jour) - (jour-bissextile (+ annee 1)) - 395))) - -; ex: (jours->gregorien 1) -> (1792 9 22) -; ex: (jours->gregorien 85172) -> (2025 12 1) -(define (jours->gregorien jours) - (let* ((annee (exact (floor (/ jours 365.25)))) - (jour (+ (- jours (exact (floor (* annee 365.25)))) 21)) - (annee (+ annee 1792)) - (jour (- (+ jour (exact (quotient annee 100))) (exact (quotient annee 400)) 13))) - (let boucle ((jour jour)(mois 8)(annee annee)) - (let* ((duree-mois (vector-ref #(31 28 31 30 31 30 31 31 30 31 30 31) mois)) - (duree-mois (+ duree-mois (if (and (= mois 1) (bissextile? annee)) 1 0)))) - (if (<= jour duree-mois) - (list annee (+ mois 1) jour) - (let ((jour (- jour duree-mois)) - (mois (+ mois 1))) - (if (= mois 12) - (boucle jour 0 (+ annee 1)) - (boucle jour mois annee)))))))) - -; ex: (jours->republicain 1) -> (1 1 1) -; ex: (jours->republicain 85172) -> (234 3 11) -(define (jours->republicain jours) - (let* ((annee (exact (floor (/ jours 365.25)))) - (annee (- annee (jour-bissextile (+ annee 1)))) - (jour (- jours (exact (floor (* annee 365.25))))) - (annee (+ annee 1)) - (jour (- (+ jour (exact (quotient annee 100))) (exact (quotient annee 400))))) - (let boucle ((jour jour)(mois 1)(annee annee)) - (let ((duree-mois (if (< mois 13) 30 (+ 5 (jour-bissextile (+ annee 1)))))) - (if (<= jour duree-mois) - (list annee mois jour) - (let ((jour (- jour duree-mois)) - (mois (+ mois 1))) - (if (= mois 14) - (boucle jour 1 (+ annee 1)) - (boucle jour mois annee)))))))) - -; ex: (normalise-caractere #\E) -> #\e -; ex: (normalise-caractere #\ê) -> #\e -(define (normalise-caractere caractere) - (let* ((caractere (char-downcase caractere)) - (autre (assoc caractere '((#\é . #\e) (#\ê . #\e) (#\ô . #\o))))) - (if autre - (cdr autre) - caractere))) - -; ex: (normalise-texte "Ventôse") -> "ventose" -(define (normalise-texte texte) - (string-map normalise-caractere texte)) - -; ex: (normalise-texte '("Ventôse" "Germinal")) -> ("ventose" "germinal") -(define (normalise-liste liste) - (map normalise-texte liste)) - -(define mois-republicains '( - "Vendémiaire" "Brumaire" "Frimaire" "Nivôse" "Pluviôse" "Ventôse" - "Germinal" "Floréal" "Prairial" "Messidor" "Thermidor" "Fructidor" - "Sansculottide")) - -(define sansculottides '( - "Fête de la vertu" "Fête du génie" "Fête du travail" - "Fête de l'opinion" "Fête des récompenses" "Fête de la Révolution" )) - -(define mois-gregoriens '( - "January" "February" "March" "April" "May" "June" - "July" "August" "September" "October" "November" "December" )) - -(define mois-republicains-normal (normalise-liste mois-republicains)) - -(define sansculottides-normal (normalise-liste sansculottides)) - -(define mois-gregoriens-normal (normalise-liste mois-gregoriens)) - -; ex: (gregorien->texte '(2025 12 1)) -> "1 December 2025)" -(define (gregorien->texte date) - (string-append - (number->string (list-ref date 2)) - " " - (list-ref mois-gregoriens (- (list-ref date 1) 1)) - " " - (number->string (list-ref date 0)))) - -; ex: (republicain->texte '(2025 12 1)) -> "1 Fructidor 2025)" -; ex: (republicain->texte '(2025 13 1)) -> "Fête de la vertu 2025)" -(define (republicain->texte date) - (if (= (list-ref date 1) 13) - (string-append - (list-ref sansculottides (- (list-ref date 2) 1)) - " " - (number->string (list-ref date 0))) - (string-append - (number->string (list-ref date 2)) - " " - (list-ref mois-republicains (- (list-ref date 1) 1)) - " " - (number->string (list-ref date 0))))) - -; ex: (decompose "34 toto 78 zorro louarn 9") -> (9 "zorro louarn" 78 "toto" 34) -; ex: (decompose "10 Vendémiaire 1") -> (1 "Vendémiaire" 10) -(define (decompose texte) - (let ((texte (normalise-texte texte))) - (let boucle ((index 0)(resultat '())) - (if (>= index (string-length texte)) - resultat - (let ((caractere (string-ref texte index)) - (index (+ index 1))) - (cond - ((char-whitespace? caractere) - (boucle index resultat)) - ((char-numeric? caractere) - (let lit-nombre ((index index)(valeur (digit-value caractere))) - (let ((caractere (if (>= index (string-length texte)) - #\space - (string-ref texte index)))) - (if (char-numeric? caractere) - (lit-nombre (+ index 1) (+ (* 10 valeur) (digit-value caractere))) - (boucle index (cons valeur resultat)))))) - (else - (let lit-texte ((index index)(valeur (list caractere))) - (let ((caractere (if (>= index (string-length texte)) - #\0 - (string-ref texte index)))) - (if (char-numeric? caractere) - (let retire-espace ((valeur valeur)) - (if (char-whitespace? (car valeur)) - (retire-espace (cdr valeur)) - (boucle index (cons (list->string (reverse valeur)) resultat)))) - (lit-texte (+ index 1) (cons caractere valeur)))))))))))) - -; ex: (index-texte '("a" "b" "c") "b") -> 2 -; ex: (index-texte '("a" "b" "c") "x") -> #f -(define (index-texte liste texte) - (let ((tete (member texte liste))) - (and tete (+ 1 (- (length liste) (length tete)))))) - -; ex: (decode-date "22 September 1792") -> (gregorien 1792 9 22) -; ex: (decode-date "Fête de la Révolution 11") -> (republicain 11 13 6) -(define (decode-date texte) - (let ((decomposition (decompose texte))) - (case (length decomposition) - ((2) - (let* ((annee (list-ref decomposition 0)) - (fete (list-ref decomposition 1)) - (jour (index-texte sansculottides-normal fete))) - (and jour (number? annee) (list 'republicain annee 13 jour)))) - ((3) - (let* ((annee (list-ref decomposition 0)) - (mois (list-ref decomposition 1)) - (jour (list-ref decomposition 2)) - (mois-gregorien (index-texte mois-gregoriens-normal mois)) - (mois-republicain (index-texte mois-republicains-normal mois))) - (and (number? annee) (number? jour) - (or (and mois-gregorien (list 'gregorien annee mois-gregorien jour)) - (and mois-republicain (list 'republicain annee mois-republicain jour)))))) - (else - #f)))) - -; ex: (decode-date "22 September 1792") -> "1 Vendémiaire 1" -; ex: (decode-date "Fête de la Révolution 11") -> "23 September 1803" -(define (converti-date texte) - (let ((decodage (decode-date texte))) - (and decodage - (case (car decodage) - ((gregorien) - (republicain->texte (jours->republicain (gregorien->jours (cdr decodage))))) - ((republicain) - (gregorien->texte (jours->gregorien (republicain->jours (cdr decodage))))) - (else - #f))))) - -; validation -(for-each - (lambda (texte) - (display texte) - (display " = ") - (display (converti-date texte)) - (newline)) - '( - "1 Vendémiaire 1" "22 September 1792" - "1 Prairial 3" "20 May 1795" - "27 Messidor 7" "15 July 1799" - "Fête de la Révolution 11" "23 September 1803" - "10 Nivôse 14" "31 December 1805" - "11 Frimaire 234" "1 December 2025" - )) diff --git a/Task/French-Republican-calendar/Wren/french-republican-calendar.wren b/Task/French-Republican-calendar/Wren/french-republican-calendar.wren index 9c365d1f94..67c2ba5ccf 100644 --- a/Task/French-Republican-calendar/Wren/french-republican-calendar.wren +++ b/Task/French-Republican-calendar/Wren/french-republican-calendar.wren @@ -1,6 +1,6 @@ -import "./date" for Date -import "./seq" for Lst -import "./fmt" for Fmt +import "/date" for Date +import "/seq" for Lst +import "/fmt" for Fmt class FrenchRCDate { /* uses the 'continuous method' for years after 1805 */ diff --git a/Task/Function-composition/00-META.yaml b/Task/Function-composition/00-META.yaml index 483655d1d4..bd45864d57 100644 --- a/Task/Function-composition/00-META.yaml +++ b/Task/Function-composition/00-META.yaml @@ -1,2 +1,3 @@ --- from: http://rosettacode.org/wiki/Function_composition +note: Higher-order functions diff --git a/Task/Function-composition/00-TASK.txt b/Task/Function-composition/00-TASK.txt index 8b13789179..44f6ada3f0 100644 --- a/Task/Function-composition/00-TASK.txt +++ b/Task/Function-composition/00-TASK.txt @@ -1 +1,16 @@ +;Task: +Create a function, compose,   whose two arguments   ''f''   and   ''g'',   are both functions with one argument. + + +The result of compose is to be a function of one argument, (lets call the argument   ''x''),   which works like applying function   ''f''   to the result of applying function   ''g''   to   ''x''. + + +;Example: + compose(''f'', ''g'') (''x'') = ''f''(''g''(''x'')) + + +Reference: [[wp:Function composition (computer science)|Function composition]] + +Hint: In some languages, implementing compose correctly requires creating a [[wp:Closure (computer science)|closure]]. +

diff --git a/Task/Function-composition/Ada/function-composition-1.adb b/Task/Function-composition/Ada/function-composition-1.ada similarity index 100% rename from Task/Function-composition/Ada/function-composition-1.adb rename to Task/Function-composition/Ada/function-composition-1.ada diff --git a/Task/Function-composition/Ada/function-composition-2.adb b/Task/Function-composition/Ada/function-composition-2.ada similarity index 100% rename from Task/Function-composition/Ada/function-composition-2.adb rename to Task/Function-composition/Ada/function-composition-2.ada diff --git a/Task/Function-composition/Ada/function-composition-3.adb b/Task/Function-composition/Ada/function-composition-3.ada similarity index 100% rename from Task/Function-composition/Ada/function-composition-3.adb rename to Task/Function-composition/Ada/function-composition-3.ada diff --git a/Task/Function-composition/Amazing-Hopper/function-composition-1.hopper b/Task/Function-composition/Amazing-Hopper/function-composition-1.hopper deleted file mode 100644 index fa91f10a87..0000000000 --- a/Task/Function-composition/Amazing-Hopper/function-composition-1.hopper +++ /dev/null @@ -1,6 +0,0 @@ -#defn Compose(_FX_,_FY_) _FX_,_FY_ - -main: - 0.5,Compose(sin,arcsin) - "\n", print -{0}return diff --git a/Task/Function-composition/Amazing-Hopper/function-composition-2.hopper b/Task/Function-composition/Amazing-Hopper/function-composition-2.hopper deleted file mode 100644 index d8a0e6dfcd..0000000000 --- a/Task/Function-composition/Amazing-Hopper/function-composition-2.hopper +++ /dev/null @@ -1,8 +0,0 @@ -#define-a «(_X_) _X_ ) -#define Compose(_FX_,_FY_) _FC_(_FX_,_FY_, -#define _FC_(_X_,_Y_,*) *,_X_,_Y_ - -main: - Compose(sin,arcsin)«( 0.5) - "\n", print -{0}return diff --git a/Task/Function-composition/Amazing-Hopper/function-composition-3.hopper b/Task/Function-composition/Amazing-Hopper/function-composition-3.hopper deleted file mode 100644 index eeef30e4ea..0000000000 --- a/Task/Function-composition/Amazing-Hopper/function-composition-3.hopper +++ /dev/null @@ -1,8 +0,0 @@ -#define «(_X_) _X_ ) -#define Compose(_FX_,_FY_) _FC_(_FX_,_FY_, -#define _FC_(_X_,_Y_,*) *,_X_,_Y_ - -main: - Compose(sin,arcsin)«( 0.5, mul by '2' ) - "\n", print -{0}return diff --git a/Task/Function-composition/Bruijn/function-composition.bruijn b/Task/Function-composition/Bruijn/function-composition.bruijn deleted file mode 100644 index c6603e8e02..0000000000 --- a/Task/Function-composition/Bruijn/function-composition.bruijn +++ /dev/null @@ -1,21 +0,0 @@ -:import std/Number . - -# 1x composition, bluebird combinator -…∘… [[[2 (1 0)]]] - -:test (((inc ∘ (mul (+2))) (+3)) =? (+7)) ([[1]]) - -# 2x composition, blackbird combinator -…∘∘… [[[[3 (2 1 0)]]]] - -:test (((inc ∘∘ mul) (+2) (+3)) =? (+7)) ([[1]]) - -# 3x composition, bunting combinator -…∘∘∘… [[[[[4 (3 2 1 0)]]]]] - -:test (((inc ∘∘∘ (add ∘∘ mul)) (+1) (+2) (+4)) =? (+7)) ([[1]]) - -# reverse composition, queer bird combinator -…→… [[[1 (2 0)]]] - -:test ((((mul (+2)) → inc) (+3)) =? (+7)) ([[1]]) diff --git a/Task/Function-composition/Crystal/function-composition.cr b/Task/Function-composition/Crystal/function-composition.crystal similarity index 100% rename from Task/Function-composition/Crystal/function-composition.cr rename to Task/Function-composition/Crystal/function-composition.crystal diff --git a/Task/Function-composition/Delphi/function-composition.pas b/Task/Function-composition/Delphi/function-composition.delphi similarity index 100% rename from Task/Function-composition/Delphi/function-composition.pas rename to Task/Function-composition/Delphi/function-composition.delphi diff --git a/Task/Function-composition/Elena/function-composition.elena b/Task/Function-composition/Elena/function-composition.elena index e2bfe40d6c..54a79583c3 100644 --- a/Task/Function-composition/Elena/function-composition.elena +++ b/Task/Function-composition/Elena/function-composition.elena @@ -6,9 +6,9 @@ extension op : Func1 = (x => self(f(x))); } -public Program() +public program() { - var fg := (x => x + 1).compose::(x => x * x); + var fg := (x => x + 1).compose:(x => x * x); - Console.printLine(fg(3)) + console.printLine(fg(3)) } diff --git a/Task/Function-composition/Elixir/function-composition.ex b/Task/Function-composition/Elixir/function-composition.elixir similarity index 100% rename from Task/Function-composition/Elixir/function-composition.ex rename to Task/Function-composition/Elixir/function-composition.elixir diff --git a/Task/Function-composition/Emacs-Lisp/function-composition-1.el b/Task/Function-composition/Emacs-Lisp/function-composition-1.l similarity index 100% rename from Task/Function-composition/Emacs-Lisp/function-composition-1.el rename to Task/Function-composition/Emacs-Lisp/function-composition-1.l diff --git a/Task/Function-composition/Emacs-Lisp/function-composition-2.el b/Task/Function-composition/Emacs-Lisp/function-composition-2.l similarity index 100% rename from Task/Function-composition/Emacs-Lisp/function-composition-2.el rename to Task/Function-composition/Emacs-Lisp/function-composition-2.l diff --git a/Task/Function-composition/Emacs-Lisp/function-composition-3.el b/Task/Function-composition/Emacs-Lisp/function-composition-3.l similarity index 100% rename from Task/Function-composition/Emacs-Lisp/function-composition-3.el rename to Task/Function-composition/Emacs-Lisp/function-composition-3.l diff --git a/Task/Function-composition/FutureBasic/function-composition.basic b/Task/Function-composition/FutureBasic/function-composition.basic deleted file mode 100644 index 8df8fe887d..0000000000 --- a/Task/Function-composition/FutureBasic/function-composition.basic +++ /dev/null @@ -1,14 +0,0 @@ -double local fn FunctionF( x as double ) -end fn = x + 1.5 - -double local fn FunctionG( x as double ) -end fn = x * x - -double local fn Compose( f as ptr, g as ptr ) - double def fn ff(x1 as double) using f - double def fn fg(x2 as double) using g -end fn = fn ff(fn fg(2.5)) - -print fn Compose( @fn FunctionF, @fn FunctionG ) - -HandleEvents diff --git a/Task/Function-composition/Julia/function-composition-1.jl b/Task/Function-composition/Julia/function-composition-1.julia similarity index 100% rename from Task/Function-composition/Julia/function-composition-1.jl rename to Task/Function-composition/Julia/function-composition-1.julia diff --git a/Task/Function-composition/Julia/function-composition-2.jl b/Task/Function-composition/Julia/function-composition-2.julia similarity index 100% rename from Task/Function-composition/Julia/function-composition-2.jl rename to Task/Function-composition/Julia/function-composition-2.julia diff --git a/Task/Function-composition/Kotlin/function-composition.kts b/Task/Function-composition/Kotlin/function-composition.kotlin similarity index 100% rename from Task/Function-composition/Kotlin/function-composition.kts rename to Task/Function-composition/Kotlin/function-composition.kotlin diff --git a/Task/Function-composition/OCaml/function-composition-1.ml b/Task/Function-composition/OCaml/function-composition-1.ocaml similarity index 100% rename from Task/Function-composition/OCaml/function-composition-1.ml rename to Task/Function-composition/OCaml/function-composition-1.ocaml diff --git a/Task/Function-composition/OCaml/function-composition-2.ml b/Task/Function-composition/OCaml/function-composition-2.ocaml similarity index 100% rename from Task/Function-composition/OCaml/function-composition-2.ml rename to Task/Function-composition/OCaml/function-composition-2.ocaml diff --git a/Task/Function-composition/Odin/function-composition.odin b/Task/Function-composition/Odin/function-composition.odin deleted file mode 100644 index bda638fa4b..0000000000 --- a/Task/Function-composition/Odin/function-composition.odin +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import "core:fmt" -import "core:math" - -Compositor :: struct($ARG, $INTER, $RET: typeid) { - func1: #type proc "contextless" (_: ARG) -> INTER, - func2: #type proc "contextless" (_: INTER) -> RET, -} - -compose :: proc( - f: #type proc "contextless" (_: $INTER) -> $RET, - g: #type proc "contextless" (_: $ARG) -> INTER, -) -> Compositor(ARG, RET, INTER) { - return {g, f} -} - -call :: proc(c: Compositor($ARG, $INTER, $RET), arg: ARG) -> RET { - return c.func1(c.func2(arg)) -} - -main :: proc() { - comp := compose(math.sin_f64, math.asin_f64) // have to use specific functions. Odin's polymorphism doesn't play nice with procedure groups - fmt.println(call(comp, 0.5)) // prints 0.5 -} diff --git a/Task/Function-composition/PascalABC.NET/function-composition.pas b/Task/Function-composition/PascalABC.NET/function-composition.pas deleted file mode 100644 index 7072b96e99..0000000000 --- a/Task/Function-composition/PascalABC.NET/function-composition.pas +++ /dev/null @@ -1,5 +0,0 @@ -function Compose(f: T1 -> T2; g: T -> T1): T -> T2 := x -> f(g(x)); - -begin - Compose(Sin,ArcSin)(1.0).Print -end. diff --git a/Task/Function-composition/Pluto/function-composition.pluto b/Task/Function-composition/Pluto/function-composition.pluto deleted file mode 100644 index 6bbdea1daa..0000000000 --- a/Task/Function-composition/Pluto/function-composition.pluto +++ /dev/null @@ -1,7 +0,0 @@ -local function compose(f, g) return |x| -> f(g(x)) end - -local function double(x) return 2 * x end - -local function add_one(x) return x + 1 end - -print(compose(double, add_one)(3)) diff --git a/Task/Function-composition/PowerShell/function-composition-1.ps1 b/Task/Function-composition/PowerShell/function-composition-1.psh similarity index 100% rename from Task/Function-composition/PowerShell/function-composition-1.ps1 rename to Task/Function-composition/PowerShell/function-composition-1.psh diff --git a/Task/Function-composition/PowerShell/function-composition-2.ps1 b/Task/Function-composition/PowerShell/function-composition-2.psh similarity index 100% rename from Task/Function-composition/PowerShell/function-composition-2.ps1 rename to Task/Function-composition/PowerShell/function-composition-2.psh diff --git a/Task/Function-composition/Rebol/function-composition-1.rebol b/Task/Function-composition/REBOL/function-composition-1.rebol similarity index 78% rename from Task/Function-composition/Rebol/function-composition-1.rebol rename to Task/Function-composition/REBOL/function-composition-1.rebol index ef233a55ac..8f31baeb19 100644 --- a/Task/Function-composition/Rebol/function-composition-1.rebol +++ b/Task/Function-composition/REBOL/function-composition-1.rebol @@ -1,9 +1,9 @@ -Rebol [ +REBOL [ Title: "Functional Composition" URL: http://rosettacode.org/wiki/Functional_Composition ] -; "compose" means something else in Rebol, therefore I use a 'compose-functions name. +; "compose" means something else in REBOL, therefore I use a 'compose-functions name. compose-functions: func [ {compose the given functions F and G} diff --git a/Task/Function-composition/Rebol/function-composition-2.rebol b/Task/Function-composition/REBOL/function-composition-2.rebol similarity index 100% rename from Task/Function-composition/Rebol/function-composition-2.rebol rename to Task/Function-composition/REBOL/function-composition-2.rebol diff --git a/Task/Function-composition/REXX/function-composition.rexx b/Task/Function-composition/REXX/function-composition.rexx index ab3603d56d..5036f78de6 100644 --- a/Task/Function-composition/REXX/function-composition.rexx +++ b/Task/Function-composition/REXX/function-composition.rexx @@ -1,21 +1,3 @@ --- 12 Sep 2025 -include Setting +compose: procedure; parse arg f,g,x; interpret 'return' f"(" g'(' x "))" -say 'FUNCTION COMPOSITION' -say version -say -parse value 'Sin' 'ArcSin' 0.5 with ff gg xx -say 'Compose('ff','gg','xx')' '=' Compose(ff,gg,xx) ',' ff'('gg'('xx'))' '=' Sin(ArcSin(xx)) -parse value 'ArcSin' 'Sin' 0.5 with ff gg xx -say 'Compose('ff','gg','xx')' '=' Compose(ff,gg,xx) ',' ff'('gg'('xx'))' '=' ArcSin(Sin(xx)) -parse value 'Zeta' 'Gamma' 0.5 with ff gg xx -say 'Compose('ff','gg','xx')' '=' Compose(ff,gg,xx) ',' ff'('gg'('xx'))' '=' Zeta(Gamma(xx)) -exit - -Compose: -procedure expose Memo. -arg ff,gg,xx -interpret 'rr='ff'('gg'('xx'))' -return rr - -include Math +exit /*control should never gets here, but this was added just in case.*/ diff --git a/Task/Function-composition/Red/function-composition.red b/Task/Function-composition/Red/function-composition.red deleted file mode 100644 index 0f4331df21..0000000000 --- a/Task/Function-composition/Red/function-composition.red +++ /dev/null @@ -1,18 +0,0 @@ -Red [ "Compose Two or Any Number of Functions - Hinjolicious" ] - -; to show the codes -demo: function [s b] [print ["^/==" s "==^/"] print mold/only b do b] - -demo "Compose two functions" [ -comp-func: function ['f 'g] [function [x] compose [(get f) (get g) x]] -sin-cos: comp-func sin cos -print sin-cos 0.5 -] - -demo "Compose any number of functions" [ -comp-funcs: function [ff] [ - function [x] compose append collect [foreach e ff [keep (get e)]] 'x -] -log-sin-cos: comp-funcs [log-e sin cos] -print log-sin-cos 0.5 -] diff --git a/Task/Function-composition/Rust/function-composition-1.rs b/Task/Function-composition/Rust/function-composition-1.rust similarity index 100% rename from Task/Function-composition/Rust/function-composition-1.rs rename to Task/Function-composition/Rust/function-composition-1.rust diff --git a/Task/Function-composition/Rust/function-composition-2.rs b/Task/Function-composition/Rust/function-composition-2.rust similarity index 100% rename from Task/Function-composition/Rust/function-composition-2.rs rename to Task/Function-composition/Rust/function-composition-2.rust diff --git a/Task/Function-composition/Scheme/function-composition-1.scm b/Task/Function-composition/Scheme/function-composition-1.ss similarity index 100% rename from Task/Function-composition/Scheme/function-composition-1.scm rename to Task/Function-composition/Scheme/function-composition-1.ss diff --git a/Task/Function-composition/Scheme/function-composition-2.scm b/Task/Function-composition/Scheme/function-composition-2.ss similarity index 100% rename from Task/Function-composition/Scheme/function-composition-2.scm rename to Task/Function-composition/Scheme/function-composition-2.ss diff --git a/Task/Function-composition/Scheme/function-composition-3.scm b/Task/Function-composition/Scheme/function-composition-3.ss similarity index 100% rename from Task/Function-composition/Scheme/function-composition-3.scm rename to Task/Function-composition/Scheme/function-composition-3.ss diff --git a/Task/Function-composition/VBScript/function-composition-1.vbs b/Task/Function-composition/VBScript/function-composition-1.vb similarity index 100% rename from Task/Function-composition/VBScript/function-composition-1.vbs rename to Task/Function-composition/VBScript/function-composition-1.vb diff --git a/Task/Function-composition/VBScript/function-composition-2.vbs b/Task/Function-composition/VBScript/function-composition-2.vb similarity index 100% rename from Task/Function-composition/VBScript/function-composition-2.vbs rename to Task/Function-composition/VBScript/function-composition-2.vb diff --git a/Task/Function-definition/ANSI-BASIC/function-definition.basic b/Task/Function-definition/ANSI-BASIC/function-definition.basic deleted file mode 100644 index 9caf26d3c9..0000000000 --- a/Task/Function-definition/ANSI-BASIC/function-definition.basic +++ /dev/null @@ -1,13 +0,0 @@ -100 DEF Multiply(A, B) = A * B -110 DECLARE FUNCTION MultiplyI -120 DECLARE EXTERNAL FUNCTION MultiplyE -130 PRINT Multiply(3, 1.23456) -140 PRINT MultiplyI(3, 1.23456) -150 PRINT MultiplyE(3, 1.23456) -160 FUNCTION MultiplyI(X, Y) -170 LET MultiplyI = X * Y -180 END FUNCTION -190 END -200 EXTERNAL FUNCTION MultiplyE(A, B) -210 LET MultiplyE = A * B -220 END FUNCTION diff --git a/Task/Function-definition/Ada/function-definition-1.adb b/Task/Function-definition/Ada/function-definition-1.ada similarity index 100% rename from Task/Function-definition/Ada/function-definition-1.adb rename to Task/Function-definition/Ada/function-definition-1.ada diff --git a/Task/Function-definition/Ada/function-definition-2.adb b/Task/Function-definition/Ada/function-definition-2.ada similarity index 100% rename from Task/Function-definition/Ada/function-definition-2.adb rename to Task/Function-definition/Ada/function-definition-2.ada diff --git a/Task/Function-definition/Ada/function-definition-3.adb b/Task/Function-definition/Ada/function-definition-3.ada similarity index 100% rename from Task/Function-definition/Ada/function-definition-3.adb rename to Task/Function-definition/Ada/function-definition-3.ada diff --git a/Task/Function-definition/Ada/function-definition-4.adb b/Task/Function-definition/Ada/function-definition-4.ada similarity index 100% rename from Task/Function-definition/Ada/function-definition-4.adb rename to Task/Function-definition/Ada/function-definition-4.ada diff --git a/Task/Function-definition/Ada/function-definition-5.adb b/Task/Function-definition/Ada/function-definition-5.ada similarity index 100% rename from Task/Function-definition/Ada/function-definition-5.adb rename to Task/Function-definition/Ada/function-definition-5.ada diff --git a/Task/Function-definition/Ada/function-definition-6.adb b/Task/Function-definition/Ada/function-definition-6.ada similarity index 100% rename from Task/Function-definition/Ada/function-definition-6.adb rename to Task/Function-definition/Ada/function-definition-6.ada diff --git a/Task/Function-definition/Amazing-Hopper/function-definition.hopper b/Task/Function-definition/Amazing-Hopper/function-definition.hopper deleted file mode 100644 index fddd71f765..0000000000 --- a/Task/Function-definition/Amazing-Hopper/function-definition.hopper +++ /dev/null @@ -1,62 +0,0 @@ -/* this need data into stack */ -#context Multiplication - mul - Return \\ -#synon Multiplication *getproduct - -#context-free anothermul - /* #defn Args(*) #GENCODE $$$*$$$ #REVLIST=0,mov(#REVLIST);#ENDGEN, */ - Args 'a,b' - Return ( #(a*b) )\\ -#synon anothermul *getanotherproduct - -#include - -#prototype _multiply(_X_,_Y_) -#synon __multiply Multiply - -Main - /* "prototipos" of functions and procedures. - Solves internaly */ - Printnl ( Multiply ( 10, 4 ) ) - Printnl ( __multiply ( 10, 4 ) ) - - /* definición alternativa 1 */ - Printnl ( Set' 10,4 ', Gosub ' Multiply2 ') - - /* aseembler Hopper 1 */ - {10,4} jsub( Multiply3 ), {"\n"} print - - /* assembler Hopper 2 */ - {10,4} jsub( Multiply4 ), {"\n"} print - - /* context */ - Set '10,4', now get product, and print with newline - - /* context-free */ - Set '10,4', and get another product; then print with newline - -End - -.locals /* Subrutines */ - -_multiply(a,b) -Return ( Mul(a,b) ) - -/* Define is macro. Others macros: Function, Procedure: -#defn Define(_F_,*) _F_:,#GENCODE $$$*$$$ #REVLIST=0;mov(#REVLIST);#ENDGEN; -#defn Function(_F_,*) _F_:,#GENCODE $$$*$$$ #REVLIST=0;mov(#REVLIST);#ENDGEN; -#defn Procedure(_F_,*) _F_:,#GENCODE $$$*$$$ #REVLIST=0;mov(#REVLIST);#ENDGEN; -*/ -Define 'Multiply2, a,b' -Return ( Mul(a,b) ) - -Multiply3: - b=0, mov(b), a=0, mov(a) - {a,b}mul /* result into stack */ -Return - -Multiply4: - mul /* get values from stack, - and put result into stack */ -back /* Return */ diff --git a/Task/Function-definition/ArkScript/function-definition.ark b/Task/Function-definition/ArkScript/function-definition.ark deleted file mode 100644 index 2c796ab336..0000000000 --- a/Task/Function-definition/ArkScript/function-definition.ark +++ /dev/null @@ -1,2 +0,0 @@ -(let multiply (fun (a b) - (* a b))) diff --git a/Task/Function-definition/AutoIt/function-definition.au3 b/Task/Function-definition/AutoIt/function-definition.autoit similarity index 100% rename from Task/Function-definition/AutoIt/function-definition.au3 rename to Task/Function-definition/AutoIt/function-definition.autoit diff --git a/Task/Function-definition/QuickBASIC/function-definition.basic b/Task/Function-definition/BASIC/function-definition.basic similarity index 100% rename from Task/Function-definition/QuickBASIC/function-definition.basic rename to Task/Function-definition/BASIC/function-definition.basic diff --git a/Task/Function-definition/Ballerina/function-definition.ballerina b/Task/Function-definition/Ballerina/function-definition.ballerina deleted file mode 100644 index a3c79abc73..0000000000 --- a/Task/Function-definition/Ballerina/function-definition.ballerina +++ /dev/null @@ -1,9 +0,0 @@ -import ballerina/io; - -function multiply(int a, int b) returns int { - return a * b; -} - -public function main() { - io:println(multiply(4, 5)); -} diff --git a/Task/Function-definition/COBOL/function-definition-1.cob b/Task/Function-definition/COBOL/function-definition-1.cob deleted file mode 100644 index 36b6fec7b7..0000000000 --- a/Task/Function-definition/COBOL/function-definition-1.cob +++ /dev/null @@ -1,26 +0,0 @@ - IDENTIFICATION DIVISION. - PROGRAM-ID. myTest. - DATA DIVISION. - WORKING-STORAGE SECTION. - 01 x PICTURE IS 9(3) VALUE IS 3. - 01 y PICTURE IS 9(3) VALUE IS 2. - 01 z PICTURE IS 9(9). - PROCEDURE DIVISION. - CALL "myMultiply" USING - BY CONTENT x, BY CONTENT y, - BY REFERENCE z. - DISPLAY z. - STOP RUN. - END PROGRAM myTest. - - IDENTIFICATION DIVISION. - PROGRAM-ID. myMultiply. - DATA DIVISION. - LINKAGE SECTION. - 01 x PICTURE IS 9(3). - 01 y PICTURE IS 9(3). - 01 z PICTURE IS 9(9). - PROCEDURE DIVISION USING BY REFERENCE x, y, z. - MULTIPLY x BY y GIVING z. - EXIT PROGRAM. - END PROGRAM myMultiply. diff --git a/Task/Function-definition/COBOL/function-definition-1.cobol b/Task/Function-definition/COBOL/function-definition-1.cobol new file mode 100644 index 0000000000..7c00afbef6 --- /dev/null +++ b/Task/Function-definition/COBOL/function-definition-1.cobol @@ -0,0 +1,26 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. myTest. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 x PIC 9(3) VALUE 3. + 01 y PIC 9(3) VALUE 2. + 01 z PIC 9(9). + PROCEDURE DIVISION. + CALL "myMultiply" USING + BY CONTENT x, BY CONTENT y, + BY REFERENCE z. + DISPLAY z. + STOP RUN. + END PROGRAM myTest. + + IDENTIFICATION DIVISION. + PROGRAM-ID. myMultiply. + DATA DIVISION. + LINKAGE SECTION. + 01 x PIC 9(3). + 01 y PIC 9(3). + 01 z PIC 9(9). + PROCEDURE DIVISION USING x, y, z. + MULTIPLY x BY y GIVING z. + EXIT PROGRAM. + END PROGRAM myMultiply. diff --git a/Task/Function-definition/COBOL/function-definition-2.cob b/Task/Function-definition/COBOL/function-definition-2.cob deleted file mode 100644 index 45cb3574b1..0000000000 --- a/Task/Function-definition/COBOL/function-definition-2.cob +++ /dev/null @@ -1,26 +0,0 @@ - IDENTIFICATION DIVISION. - PROGRAM-ID. myTest. - ENVIRONMENT DIVISION. - CONFIGURATION SECTION. - REPOSITORY. - FUNCTION myMultiply. - DATA DIVISION. - WORKING-STORAGE SECTION. - 01 x PICTURE IS 9(3) VALUE IS 3. - 01 y PICTURE IS 9(3) VALUE IS 2. - PROCEDURE DIVISION. - DISPLAY myMultiply(x, y). - STOP RUN. - END PROGRAM myTest. - - IDENTIFICATION DIVISION. - FUNCTION-ID. myMultiply. - DATA DIVISION. - LINKAGE SECTION. - 01 x PICTURE IS 9(3). - 01 y PICTURE IS 9(3). - 01 z PICTURE IS 9(9). - PROCEDURE DIVISION USING x, y RETURNING z. - MULTIPLY x BY y GIVING z. - GOBACK. - END FUNCTION myMultiply. diff --git a/Task/Function-definition/COBOL/function-definition-2.cobol b/Task/Function-definition/COBOL/function-definition-2.cobol new file mode 100644 index 0000000000..6c12bbfc1a --- /dev/null +++ b/Task/Function-definition/COBOL/function-definition-2.cobol @@ -0,0 +1,26 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. myTest. + ENVIRONMENT DIVISION. + CONFIGURATION SECTION. + REPOSITORY. + FUNCTION myMultiply. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 x PIC 9(3) VALUE 3. + 01 y PIC 9(3) VALUE 2. + PROCEDURE DIVISION. + DISPLAY myMultiply(x, y). + STOP RUN. + END PROGRAM myTest. + + IDENTIFICATION DIVISION. + FUNCTION-ID. myMultiply. + DATA DIVISION. + LINKAGE SECTION. + 01 x PIC 9(3). + 01 y PIC 9(3). + 01 z pic 9(9). + PROCEDURE DIVISION USING x, y RETURNING z. + MULTIPLY x BY y GIVING z. + EXIT FUNCTION. + END FUNCTION myMultiply. diff --git a/Task/Function-definition/Chapel/function-definition-1.chpl b/Task/Function-definition/Chapel/function-definition-1.chpl deleted file mode 100644 index dce621a59f..0000000000 --- a/Task/Function-definition/Chapel/function-definition-1.chpl +++ /dev/null @@ -1,4 +0,0 @@ -proc multiply(a, b) -{ - return a * b; -} diff --git a/Task/Function-definition/Chapel/function-definition-2.chpl b/Task/Function-definition/Chapel/function-definition-2.chpl deleted file mode 100644 index cd4150861a..0000000000 --- a/Task/Function-definition/Chapel/function-definition-2.chpl +++ /dev/null @@ -1,4 +0,0 @@ -proc multiply(a : ?t ... 2) -{ - return a(0) * a(1) -} diff --git a/Task/Function-definition/Crystal/function-definition.cr b/Task/Function-definition/Crystal/function-definition.cr deleted file mode 100644 index 9a6b44e375..0000000000 --- a/Task/Function-definition/Crystal/function-definition.cr +++ /dev/null @@ -1,16 +0,0 @@ -def multiply (a, b) - a * b -end - -# with type restrictions: -def multiply (a : Int32, b : Int32) - print "(typed overload) " - a * b -end - -# proc (anonymous function) -m = ->(a : Int32, b : Int32) { a * b } - -p! multiply(2, 3), - multiply(2.0, 3.0), - m.call(2, 3) diff --git a/Task/Function-definition/Delphi/function-definition.pas b/Task/Function-definition/Delphi/function-definition.delphi similarity index 100% rename from Task/Function-definition/Delphi/function-definition.pas rename to Task/Function-definition/Delphi/function-definition.delphi diff --git a/Task/Function-definition/DuckDB/function-definition-1.duckdb b/Task/Function-definition/DuckDB/function-definition-1.duckdb deleted file mode 100644 index ce21102e19..0000000000 --- a/Task/Function-definition/DuckDB/function-definition-1.duckdb +++ /dev/null @@ -1 +0,0 @@ -create or replace function multiply(x,y) as x*y; diff --git a/Task/Function-definition/DuckDB/function-definition-2.duckdb b/Task/Function-definition/DuckDB/function-definition-2.duckdb deleted file mode 100644 index 3053825ed4..0000000000 --- a/Task/Function-definition/DuckDB/function-definition-2.duckdb +++ /dev/null @@ -1,10 +0,0 @@ -create or replace function power2(n) as ( - with recursive cte as ( - select 0 as i, 1::UHUGEINT as p - union all - select i+1 as i, p*2 as p - from cte - where i < n ) - select last(p order by i) - from cte -); diff --git a/Task/Function-definition/EasyLang/function-definition.easy b/Task/Function-definition/EasyLang/function-definition.easy index 3f70bb95f9..4c70f02eab 100644 --- a/Task/Function-definition/EasyLang/function-definition.easy +++ b/Task/Function-definition/EasyLang/function-definition.easy @@ -1,4 +1,5 @@ -func multiply a b . - return a * b +proc multiply a b . r . + r = a * b . -print multiply 7 5 +call multiply 7 5 res +print res diff --git a/Task/Function-definition/Elena/function-definition-2.elena b/Task/Function-definition/Elena/function-definition-2.elena index e80091723d..667f1dd0f2 100644 --- a/Task/Function-definition/Elena/function-definition-2.elena +++ b/Task/Function-definition/Elena/function-definition-2.elena @@ -1 +1 @@ -symbol f = (x,y => x * y); +symbol f := (x,y => x * y); diff --git a/Task/Function-definition/Elixir/function-definition.ex b/Task/Function-definition/Elixir/function-definition.elixir similarity index 100% rename from Task/Function-definition/Elixir/function-definition.ex rename to Task/Function-definition/Elixir/function-definition.elixir diff --git a/Task/Function-definition/Emacs-Lisp/function-definition-1.el b/Task/Function-definition/Emacs-Lisp/function-definition-1.l similarity index 100% rename from Task/Function-definition/Emacs-Lisp/function-definition-1.el rename to Task/Function-definition/Emacs-Lisp/function-definition-1.l diff --git a/Task/Function-definition/Emacs-Lisp/function-definition-2.el b/Task/Function-definition/Emacs-Lisp/function-definition-2.l similarity index 100% rename from Task/Function-definition/Emacs-Lisp/function-definition-2.el rename to Task/Function-definition/Emacs-Lisp/function-definition-2.l diff --git a/Task/Function-definition/Euphoria/function-definition-1.eu b/Task/Function-definition/Euphoria/function-definition-1.euphoria similarity index 100% rename from Task/Function-definition/Euphoria/function-definition-1.eu rename to Task/Function-definition/Euphoria/function-definition-1.euphoria diff --git a/Task/Function-definition/Euphoria/function-definition-2.eu b/Task/Function-definition/Euphoria/function-definition-2.euphoria similarity index 100% rename from Task/Function-definition/Euphoria/function-definition-2.eu rename to Task/Function-definition/Euphoria/function-definition-2.euphoria diff --git a/Task/Function-definition/Excel/function-definition.excel b/Task/Function-definition/Excel/function-definition.excel deleted file mode 100644 index 1b33fa780a..0000000000 --- a/Task/Function-definition/Excel/function-definition.excel +++ /dev/null @@ -1,4 +0,0 @@ -=LET( - MULTIPLY, LAMBDA(a, b, a * b), - ... - ) diff --git a/Task/Function-definition/Free-Pascal-Lazarus/function-definition.pas b/Task/Function-definition/Free-Pascal/function-definition.pas similarity index 100% rename from Task/Function-definition/Free-Pascal-Lazarus/function-definition.pas rename to Task/Function-definition/Free-Pascal/function-definition.pas diff --git a/Task/Function-definition/FutureBasic/function-definition-2.basic b/Task/Function-definition/FutureBasic/function-definition-2.basic deleted file mode 100644 index c6c813c61b..0000000000 --- a/Task/Function-definition/FutureBasic/function-definition-2.basic +++ /dev/null @@ -1,8 +0,0 @@ -window 1 - -long local fn multiply( a as long, b as long ) -end fn = a * b - -print fn multiply( 3, 9 ) - -HandleEvents diff --git a/Task/Function-definition/FutureBasic/function-definition-1.basic b/Task/Function-definition/FutureBasic/function-definition.basic similarity index 100% rename from Task/Function-definition/FutureBasic/function-definition-1.basic rename to Task/Function-definition/FutureBasic/function-definition.basic diff --git a/Task/Function-definition/Gleam/function-definition.gleam b/Task/Function-definition/Gleam/function-definition.gleam deleted file mode 100644 index 45be9f932e..0000000000 --- a/Task/Function-definition/Gleam/function-definition.gleam +++ /dev/null @@ -1,3 +0,0 @@ -fn multiply(x: Int, y: Int) -> Int { - x * y -} diff --git a/Task/Function-definition/Haxe/function-definition.hx b/Task/Function-definition/Haxe/function-definition.haxe similarity index 100% rename from Task/Function-definition/Haxe/function-definition.hx rename to Task/Function-definition/Haxe/function-definition.haxe diff --git a/Task/Function-definition/Java/function-definition-2.java b/Task/Function-definition/Java/function-definition-2.java deleted file mode 100644 index fb127fb080..0000000000 --- a/Task/Function-definition/Java/function-definition-2.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.util.function.BiFunction; -import java.util.function.DoubleUnaryOperator; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; - -public final class FunctionDefinition { - - public static void main(String[] args) { - System.out.println(size.apply("Rosetta")); - System.out.println(greeting.apply("Joe")); - System.out.println(half.applyAsDouble(7)); - System.out.println(lessThanTen.test(15)); - System.out.println(add.apply(2, 3)); - } - - private static Function size = s -> s.length(); - - private static UnaryOperator greeting = s -> "Hello " + s; - - private static DoubleUnaryOperator half = a -> a / 2; - - private static Predicate lessThanTen = a -> a < 10; - - private static BiFunction add = (a, b) -> a + b; - -} diff --git a/Task/Function-definition/Java/function-definition-1.java b/Task/Function-definition/Java/function-definition.java similarity index 100% rename from Task/Function-definition/Java/function-definition-1.java rename to Task/Function-definition/Java/function-definition.java diff --git a/Task/Function-definition/JavaScript/function-definition-6.js b/Task/Function-definition/JavaScript/function-definition-6.js index b32d13d81a..60d2fdb755 100644 --- a/Task/Function-definition/JavaScript/function-definition-6.js +++ b/Task/Function-definition/JavaScript/function-definition-6.js @@ -1,8 +1,2 @@ var multiply = (a, b) => a * b; var multiply = (a, b) => { return a * b }; - -// Or, `var` being long deprecated, and currying convenient, -// (particularly in use with the higher-order Array methods) - -const multiply = a => - b => a * b; diff --git a/Task/Function-definition/Julia/function-definition-1.jl b/Task/Function-definition/Julia/function-definition-1.julia similarity index 100% rename from Task/Function-definition/Julia/function-definition-1.jl rename to Task/Function-definition/Julia/function-definition-1.julia diff --git a/Task/Function-definition/Julia/function-definition-2.jl b/Task/Function-definition/Julia/function-definition-2.julia similarity index 100% rename from Task/Function-definition/Julia/function-definition-2.jl rename to Task/Function-definition/Julia/function-definition-2.julia diff --git a/Task/Function-definition/Julia/function-definition-3.jl b/Task/Function-definition/Julia/function-definition-3.julia similarity index 100% rename from Task/Function-definition/Julia/function-definition-3.jl rename to Task/Function-definition/Julia/function-definition-3.julia diff --git a/Task/Function-definition/Komodo/function-definition.komodo b/Task/Function-definition/Komodo/function-definition.komodo deleted file mode 100644 index 63404d357c..0000000000 --- a/Task/Function-definition/Komodo/function-definition.komodo +++ /dev/null @@ -1,5 +0,0 @@ -let prod(a, b) := a*b -let prodAnon := (a, b) -> a*b - -assert(prodAnon(2, 2) = ((a, b) -> a*b)(2, 2)) -assert(prod(2, 2) = prodAnon(2, 2)) diff --git a/Task/Function-definition/Kotlin/function-definition.kts b/Task/Function-definition/Kotlin/function-definition.kotlin similarity index 100% rename from Task/Function-definition/Kotlin/function-definition.kts rename to Task/Function-definition/Kotlin/function-definition.kotlin diff --git a/Task/Function-definition/LDPL/function-definition.ldpl b/Task/Function-definition/LDPL/function-definition.ldpl deleted file mode 100644 index 2c00e8327d..0000000000 --- a/Task/Function-definition/LDPL/function-definition.ldpl +++ /dev/null @@ -1,22 +0,0 @@ -data: -n is number - -procedure: -sub multiply - parameters: - x is number - y is number - result is number - procedure: - in result solve x * y -end sub - -# call the bare sub-procedure -call multiply with 3 4 n -display n lf - -# create a statement for it -create statement "multiply $ by $ in $" executing multiply - -multiply 3 by 4 in n -display n lf diff --git a/Task/Function-definition/LOLCODE/function-definition.lol b/Task/Function-definition/LOLCODE/function-definition.lol deleted file mode 100644 index 8d50259103..0000000000 --- a/Task/Function-definition/LOLCODE/function-definition.lol +++ /dev/null @@ -1,9 +0,0 @@ -HAI 1.3 - -HOW IZ I MULTIPLY YR X AN YR Y - FOUND YR PRODUKT OF X AN Y -IF U SAY SO - -VISIBLE I IZ MULTIPLY YR 2 AND YR 3 MKAY - -KTHXBYE diff --git a/Task/Function-definition/Langur/function-definition-1.langur b/Task/Function-definition/Langur/function-definition-1.langur index 0445f67e8d..3732180e63 100644 --- a/Task/Function-definition/Langur/function-definition-1.langur +++ b/Task/Function-definition/Langur/function-definition-1.langur @@ -1 +1,2 @@ -val multiply = fn(a, b) { a * b } +val .multiply = f(.x, .y) .x x .y +.multiply(3, 4) diff --git a/Task/Function-definition/Langur/function-definition-2.langur b/Task/Function-definition/Langur/function-definition-2.langur index 5878a47bf8..fbc6009c47 100644 --- a/Task/Function-definition/Langur/function-definition-2.langur +++ b/Task/Function-definition/Langur/function-definition-2.langur @@ -1 +1,2 @@ -val multiply = fn{*} +val .multiply = f .x x .y +.multiply(3, 4) diff --git a/Task/Function-definition/Langur/function-definition-3.langur b/Task/Function-definition/Langur/function-definition-3.langur index e8a58c5239..78648a1332 100644 --- a/Task/Function-definition/Langur/function-definition-3.langur +++ b/Task/Function-definition/Langur/function-definition-3.langur @@ -1 +1,2 @@ -val timestwo = fn{*2} +val .multiply = f{x} +.multiply(3, 4) diff --git a/Task/Function-definition/Langur/function-definition-4.langur b/Task/Function-definition/Langur/function-definition-4.langur index 64c16021ee..81288d6351 100644 --- a/Task/Function-definition/Langur/function-definition-4.langur +++ b/Task/Function-definition/Langur/function-definition-4.langur @@ -1 +1,2 @@ -val factorial = fn(x) { if(x < 2: 1; x * fn((x - 1))) } +val .times3 = f{x 3} +map .times3, [1, 2, 3] diff --git a/Task/Function-definition/OCaml/function-definition.ml b/Task/Function-definition/OCaml/function-definition.ocaml similarity index 100% rename from Task/Function-definition/OCaml/function-definition.ml rename to Task/Function-definition/OCaml/function-definition.ocaml diff --git a/Task/Function-definition/Oberon/function-definition.oberon b/Task/Function-definition/Oberon-2/function-definition.oberon similarity index 100% rename from Task/Function-definition/Oberon/function-definition.oberon rename to Task/Function-definition/Oberon-2/function-definition.oberon diff --git a/Task/Function-definition/PascalABC.NET/function-definition.pas b/Task/Function-definition/PascalABC.NET/function-definition.pas deleted file mode 100644 index 5cdaeef57d..0000000000 --- a/Task/Function-definition/PascalABC.NET/function-definition.pas +++ /dev/null @@ -1 +0,0 @@ -function multiply(a,b: real): real := a + b; diff --git a/Task/Function-definition/Pluto/function-definition.pluto b/Task/Function-definition/Pluto/function-definition.pluto deleted file mode 100644 index 442e6b756c..0000000000 --- a/Task/Function-definition/Pluto/function-definition.pluto +++ /dev/null @@ -1,5 +0,0 @@ -function multiply(a,b) - return a*b -end - -print(multiply(3,4)) diff --git a/Task/Function-definition/PowerShell/function-definition-1.ps1 b/Task/Function-definition/PowerShell/function-definition-1.psh similarity index 100% rename from Task/Function-definition/PowerShell/function-definition-1.ps1 rename to Task/Function-definition/PowerShell/function-definition-1.psh diff --git a/Task/Function-definition/PowerShell/function-definition-2.ps1 b/Task/Function-definition/PowerShell/function-definition-2.psh similarity index 100% rename from Task/Function-definition/PowerShell/function-definition-2.ps1 rename to Task/Function-definition/PowerShell/function-definition-2.psh diff --git a/Task/Function-definition/PowerShell/function-definition-3.ps1 b/Task/Function-definition/PowerShell/function-definition-3.psh similarity index 100% rename from Task/Function-definition/PowerShell/function-definition-3.ps1 rename to Task/Function-definition/PowerShell/function-definition-3.psh diff --git a/Task/Function-definition/PowerShell/function-definition-4.ps1 b/Task/Function-definition/PowerShell/function-definition-4.psh similarity index 100% rename from Task/Function-definition/PowerShell/function-definition-4.ps1 rename to Task/Function-definition/PowerShell/function-definition-4.psh diff --git a/Task/Function-definition/PowerShell/function-definition-5.ps1 b/Task/Function-definition/PowerShell/function-definition-5.psh similarity index 100% rename from Task/Function-definition/PowerShell/function-definition-5.ps1 rename to Task/Function-definition/PowerShell/function-definition-5.psh diff --git a/Task/Function-definition/Rebol/function-definition.rebol b/Task/Function-definition/REBOL/function-definition.rebol similarity index 100% rename from Task/Function-definition/Rebol/function-definition.rebol rename to Task/Function-definition/REBOL/function-definition.rebol diff --git a/Task/Function-definition/REXX/function-definition-1.rexx b/Task/Function-definition/REXX/function-definition-1.rexx new file mode 100644 index 0000000000..a476639d66 --- /dev/null +++ b/Task/Function-definition/REXX/function-definition-1.rexx @@ -0,0 +1 @@ +multiply: return arg(1) * arg(2) /*return the product of the two arguments.*/ diff --git a/Task/Function-definition/REXX/function-definition-2.rexx b/Task/Function-definition/REXX/function-definition-2.rexx new file mode 100644 index 0000000000..569b050f96 --- /dev/null +++ b/Task/Function-definition/REXX/function-definition-2.rexx @@ -0,0 +1 @@ +multiply: return arg(1) * arg(2) / 1 /*return with a normalized product of 2 args. */ diff --git a/Task/Function-definition/REXX/function-definition.rexx b/Task/Function-definition/REXX/function-definition.rexx deleted file mode 100644 index 1d6fc424e5..0000000000 --- a/Task/Function-definition/REXX/function-definition.rexx +++ /dev/null @@ -1,34 +0,0 @@ --- 11 Sep 2025 -include Setting - -say 'FUNCTION DEFINITION' -say version -say -xx=0; yy=0; rr=0 -say 'xx =' xx 'yy =' yy 'rr =' rr -say 'Multiply1(2,3)' '=' Multiply1(2,3) -say 'xx =' xx 'yy =' yy 'rr =' rr -say 'Multiply2(3,5)' '=' Multiply2(3,5) -say 'xx =' xx 'yy =' yy 'rr =' rr -xx=5; yy=7 -say 'xx =' xx 'yy =' yy 'rr =' rr -say 'Multiply3(5,7)' '=' Multiply3() -say 'xx =' xx 'yy =' yy 'rr =' rr -exit - -Multiply1: -procedure -arg xx,yy -rr=xx*yy -return rr - -Multiply2: -arg xx,yy -rr=xx*yy -return rr - -Multiply3: -rr=xx*yy -return rr - -include Math diff --git a/Task/Function-definition/Rust/function-definition.rs b/Task/Function-definition/Rust/function-definition.rust similarity index 100% rename from Task/Function-definition/Rust/function-definition.rs rename to Task/Function-definition/Rust/function-definition.rust diff --git a/Task/Function-definition/Rye/function-definition-1.rye b/Task/Function-definition/Rye/function-definition-1.rye deleted file mode 100644 index 944dd8c78b..0000000000 --- a/Task/Function-definition/Rye/function-definition-1.rye +++ /dev/null @@ -1 +0,0 @@ -multiply: fn { a b } { a * b } diff --git a/Task/Function-definition/Rye/function-definition-2.rye b/Task/Function-definition/Rye/function-definition-2.rye deleted file mode 100644 index 2f2cc5ea24..0000000000 --- a/Task/Function-definition/Rye/function-definition-2.rye +++ /dev/null @@ -1 +0,0 @@ -multiply: fn { a b } { * b } diff --git a/Task/Function-definition/Rye/function-definition-3.rye b/Task/Function-definition/Rye/function-definition-3.rye deleted file mode 100644 index ca8885cbcf..0000000000 --- a/Task/Function-definition/Rye/function-definition-3.rye +++ /dev/null @@ -1 +0,0 @@ -multiply: pfn { a b } { a * b } diff --git a/Task/Function-definition/SIL/function-definition.sil b/Task/Function-definition/SIL/function-definition.sil deleted file mode 100644 index 21bfbe3c19..0000000000 --- a/Task/Function-definition/SIL/function-definition.sil +++ /dev/null @@ -1,3 +0,0 @@ -funcmultiply -r = x * y -return diff --git a/Task/Function-definition/Scheme/function-definition-1.scm b/Task/Function-definition/Scheme/function-definition-1.ss similarity index 100% rename from Task/Function-definition/Scheme/function-definition-1.scm rename to Task/Function-definition/Scheme/function-definition-1.ss diff --git a/Task/Function-definition/Scheme/function-definition-2.scm b/Task/Function-definition/Scheme/function-definition-2.ss similarity index 100% rename from Task/Function-definition/Scheme/function-definition-2.scm rename to Task/Function-definition/Scheme/function-definition-2.ss diff --git a/Task/Function-definition/Tcl/function-definition-3.tcl b/Task/Function-definition/Tcl/function-definition-3.tcl deleted file mode 100644 index e2a1260e67..0000000000 --- a/Task/Function-definition/Tcl/function-definition-3.tcl +++ /dev/null @@ -1,13 +0,0 @@ -proc multiply { a b args } { - - set product 1 - - foreach m [list $a $b {*}$args] { - - set product [expr {$product * $m}] - } - - return $product -} - -puts stdout [multiply 3 4 7 9 -2 -5 ] diff --git a/Task/Function-definition/VBScript/function-definition-1.vbs b/Task/Function-definition/VBScript/function-definition-1.vb similarity index 100% rename from Task/Function-definition/VBScript/function-definition-1.vbs rename to Task/Function-definition/VBScript/function-definition-1.vb diff --git a/Task/Function-definition/VBScript/function-definition-2.vbs b/Task/Function-definition/VBScript/function-definition-2.vb similarity index 100% rename from Task/Function-definition/VBScript/function-definition-2.vbs rename to Task/Function-definition/VBScript/function-definition-2.vb diff --git a/Task/Function-definition/YAMLScript/function-definition.ys b/Task/Function-definition/YAMLScript/function-definition.ys deleted file mode 100644 index 7bab26ba31..0000000000 --- a/Task/Function-definition/YAMLScript/function-definition.ys +++ /dev/null @@ -1,15 +0,0 @@ -!YS-v0 - -# Main function definition with variable arguments: -defn main(*args): - say: "multiply($(args.join(', '))) - -> $multiply(args*)" - -# A multi-arity function definition: -defn multiply: - (): 1 - (x): x - (x y): x * y - (x y *more): - reduce multiply: - multiply(x y) more diff --git a/Task/Function-definition/Zig/function-definition.zig b/Task/Function-definition/Zig/function-definition.zig deleted file mode 100644 index 38dab3141a..0000000000 --- a/Task/Function-definition/Zig/function-definition.zig +++ /dev/null @@ -1,8 +0,0 @@ -fn multiply(x: i64, y: i64) i64 { - return x * y; -} - -//example call -const x: i64 = 4; -const y: i64 = 23; -_ = multipy(x, y); // --> 93 diff --git a/Task/Function-frequency/Arturo/function-frequency.arturo b/Task/Function-frequency/Arturo/function-frequency.arturo index 651ef9d353..ba1c035514 100644 --- a/Task/Function-frequency/Arturo/function-frequency.arturo +++ b/Task/Function-frequency/Arturo/function-frequency.arturo @@ -3,21 +3,23 @@ frequencies: #[] inspectBlock: function [blk][ loop blk 'item [ - when [ - word? item [ + case [] + when? [word? item][ sItem: to :string item if set? sItem -> if function? var sItem [ - switch key? frequencies sItem - -> set frequencies sItem (get frequencies sItem)+1 - -> set frequencies sItem 1 + if? key? frequencies sItem -> + set frequencies sItem (get frequencies sItem)+1 + else -> + set frequencies sItem 1 ] ] - or? block? item - inline? item -> + when? [or? block? item + inline? item] -> inspectBlock item - ] + + else [] ] ] diff --git a/Task/Function-frequency/FreeBASIC/function-frequency.basic b/Task/Function-frequency/FreeBASIC/function-frequency.basic deleted file mode 100644 index 70da46504e..0000000000 --- a/Task/Function-frequency/FreeBASIC/function-frequency.basic +++ /dev/null @@ -1,41 +0,0 @@ -Dim As String code, word, char -Dim As Integer i, j -Dim As String words() -Dim As Integer counts() - -Open "i:\your_file.bas" For Input As #1 -While Not Eof(1) - Line Input #1, code - For i = 1 To Len(code) - char = Lcase(Mid(code, i, 1)) - If char >= "a" And char <= "z" Then - word &= Mid(code, i, 1) - Elseif word <> "" Then - For j = 0 To Ubound(words) - If words(j) = word Then - counts(j) += 1 - Exit For - End If - Next - If j > Ubound(words) Then - Redim Preserve words(Ubound(words) + 1) - Redim Preserve counts(Ubound(counts) + 1) - words(Ubound(words)) = word - counts(Ubound(counts)) = 1 - End If - word = "" - End If - Next -Wend -Close #1 - -For i = 0 To 9 - Dim As Integer maxj = 0 - For j = 0 To Ubound(counts) - If counts(j) > counts(maxj) Then maxj = j - Next - Print words(maxj); " occurs"; counts(maxj); " times" - counts(maxj) = 0 -Next - -Sleep diff --git a/Task/Function-frequency/Julia/function-frequency.jl b/Task/Function-frequency/Julia/function-frequency.julia similarity index 100% rename from Task/Function-frequency/Julia/function-frequency.jl rename to Task/Function-frequency/Julia/function-frequency.julia diff --git a/Task/Function-frequency/REXX/function-frequency-3.rexx b/Task/Function-frequency/REXX/function-frequency-3.rexx deleted file mode 100644 index 05ffecf5c2..0000000000 --- a/Task/Function-frequency/REXX/function-frequency-3.rexx +++ /dev/null @@ -1,138 +0,0 @@ --- 21 Feb 2026 -include Setting -parse arg program - -say 'FUNCTION FREQUENCY' -say version -call ReadSource -call CleanSource -call CollectInvokes -call SortSt 'invo.' -call ReportInvokes -call Timer -exit - -ReadSource: --- Read all lines in a stem -if program='' then - program='FuncFreq.rex' -else - program=program'.rex' -say 'Invoke frequencies for program' program -say -call Stream program,'c','open read' -srce.=0; n=0 -do while Lines(program) - record=LineIn(program) - n=n+1; srce.n=record -end -srce.0=n -call Stream program,'c','close' -return - -CleanSource: --- Erase all characters that are (in this order): --- within a '' literal or a "" literal --- within a /*...*/ comment block --- after -- ... comment --- not allowed in names -cleanc=0 -p1=0; q1=0 -do i = 1 to srce.0 - cleanl=0 - s=srce.i; k=Length(s) - do j = 1 to k --- Substring for literals - p1=SubStr(s,j,1) --- Erase literal - if p1 = "'" | p1 = '"' then do - if cleanl then do - s=Overlay(' ',s,j) - if p1 = q1 then - cleanl=0 - end - else do - q1=p1; cleanl=1 - end - end - if cleanl then - s=Overlay(' ',s,j) - end j --- Substring for comments - p2=SubStr(s,j,2) --- Erase block /*...*/ comment - if p2 = '/*' then - cleanc=1 - else do - if p2 = '*/' then do - s=Overlay(' ',s,j,2) - cleanc=0 - end - end - if cleanc then do - s=Overlay(' ',s,j) - iterate j - end --- Erase -- ... comment - if p2 = '--' then do - s=Overlay(' ',s,j,k) - leave j - end --- Erase all characters not allowed in names - s=Translate(s,' ','+-*|<>,;=/\%)') - srce.i=s -end i -return - -CollectInvokes: --- Collect invocations 'Name()' or 'call Name' -invo.=0; v=0 -do i = 1 to srce.0 - s=srce.i --- Parse words - wrds.=0; n=0 - do until s = '' - n=n+1; parse var s wrds.n s - end --- Find invocations - wrds.0=n - do j = 1 to wrds.0 - w=wrds.j --- Call Name - if Upper(w) = 'CALL' then do - k=j+1; v=v+1; invo.v=wrds.k - end --- Name() - else do - p1=1; p2=Pos('(',w) - do while p2 > 0 - a=SubStr(w,p1,p2-p1) - if a <> '' then do - v=v+1; invo.v=SubStr(w,p1,p2-p1) - end - p1=p2+1; p2=Pos('(',w,p1) - end - end - end j -end i -invo.0=v -return - -ReportInvokes: --- Aggregate and report -p=invo.1; n=1 -do i = 2 to invo.0 - v = invo.i - if v = p then - n=n+1 - else do - say Right(n,3) p - p=v; n=1 - end -end i -say Right(n,3) p -say -return - --- SortSt; Timer -include Math diff --git a/Task/Function-frequency/Wren/function-frequency.wren b/Task/Function-frequency/Wren/function-frequency.wren index 2d2fcedef0..2216a94725 100644 --- a/Task/Function-frequency/Wren/function-frequency.wren +++ b/Task/Function-frequency/Wren/function-frequency.wren @@ -1,9 +1,9 @@ import "io" for File import "os" for Process -import "./pattern" for Pattern -import "./set" for Bag -import "./sort" for Sort -import "./fmt" for Fmt +import "/pattern" for Pattern +import "/set" for Bag +import "/sort" for Sort +import "/fmt" for Fmt var args = Process.arguments if (args.count != 1) { diff --git a/Task/Function-prototype/Ada/function-prototype-1.adb b/Task/Function-prototype/Ada/function-prototype-1.ada similarity index 100% rename from Task/Function-prototype/Ada/function-prototype-1.adb rename to Task/Function-prototype/Ada/function-prototype-1.ada diff --git a/Task/Function-prototype/Ada/function-prototype-2.adb b/Task/Function-prototype/Ada/function-prototype-2.ada similarity index 100% rename from Task/Function-prototype/Ada/function-prototype-2.adb rename to Task/Function-prototype/Ada/function-prototype-2.ada diff --git a/Task/Function-prototype/Ada/function-prototype-3.adb b/Task/Function-prototype/Ada/function-prototype-3.ada similarity index 100% rename from Task/Function-prototype/Ada/function-prototype-3.adb rename to Task/Function-prototype/Ada/function-prototype-3.ada diff --git a/Task/Function-prototype/Ada/function-prototype-4.adb b/Task/Function-prototype/Ada/function-prototype-4.ada similarity index 100% rename from Task/Function-prototype/Ada/function-prototype-4.adb rename to Task/Function-prototype/Ada/function-prototype-4.ada diff --git a/Task/Function-prototype/Ada/function-prototype-5.adb b/Task/Function-prototype/Ada/function-prototype-5.ada similarity index 100% rename from Task/Function-prototype/Ada/function-prototype-5.adb rename to Task/Function-prototype/Ada/function-prototype-5.ada diff --git a/Task/Function-prototype/COBOL/function-prototype.cob b/Task/Function-prototype/COBOL/function-prototype.cobol similarity index 100% rename from Task/Function-prototype/COBOL/function-prototype.cob rename to Task/Function-prototype/COBOL/function-prototype.cobol diff --git a/Task/Function-prototype/Delphi/function-prototype-1.pas b/Task/Function-prototype/Delphi/function-prototype-1.delphi similarity index 100% rename from Task/Function-prototype/Delphi/function-prototype-1.pas rename to Task/Function-prototype/Delphi/function-prototype-1.delphi diff --git a/Task/Function-prototype/Delphi/function-prototype-2.pas b/Task/Function-prototype/Delphi/function-prototype-2.delphi similarity index 100% rename from Task/Function-prototype/Delphi/function-prototype-2.pas rename to Task/Function-prototype/Delphi/function-prototype-2.delphi diff --git a/Task/Function-prototype/EasyLang/function-prototype.easy b/Task/Function-prototype/EasyLang/function-prototype.easy deleted file mode 100644 index d3292735cc..0000000000 --- a/Task/Function-prototype/EasyLang/function-prototype.easy +++ /dev/null @@ -1,31 +0,0 @@ -# No arguments -funcdecl f0 . -# -# Two arguments -procdecl f1 a s$ . -# -# Varargs are not available -# -# Two arguments (integer and string), pass by reference -procdecl f4 &a &s$ . -# -# Function returning an array -funcdecl[] f7 . -# -print f0 -# -# Each declared function must also be implemented -# -func f0 . - return 3 -. -proc f1 a s$ . - print s$ & a -. -proc f4 &a &s$ . - a = 7 - s$ = "hello" -. -func[] f7 . - return [ 1 2 3 ] -. diff --git a/Task/Function-prototype/FutureBasic/function-prototype.basic b/Task/Function-prototype/FutureBasic/function-prototype.basic deleted file mode 100644 index 9a96932ecb..0000000000 --- a/Task/Function-prototype/FutureBasic/function-prototype.basic +++ /dev/null @@ -1,4 +0,0 @@ -def fn NoArgs -def fn TwoArgs( a as long, b as long ) -def fn VarArgs( n as long, ... ) -long def fn Multiply( a as long, b as long ) // function returns a value diff --git a/Task/Function-prototype/Java/function-prototype.java b/Task/Function-prototype/Java/function-prototype.java deleted file mode 100644 index 5be1b82833..0000000000 --- a/Task/Function-prototype/Java/function-prototype.java +++ /dev/null @@ -1,55 +0,0 @@ -public final class FunctionPrototype { - - public static void main(String[] aArgs) { - Rectangle rectangle = new Rectangle(10.0, 20.0); - System.out.println("Area = " + rectangle.area()); - - Calculator calculator = new Calculator(); - System.out.println("Sum = " + calculator.sum(2, 2)); - calculator.version(); - } - - private static class Rectangle implements Shape { - - public Rectangle(double aWidth, double aLength) { - width = aWidth; length = aLength; - } - - @Override - public double area() { - return length * width; - } - - private final double width, length; - - } - - private static class Calculator extends Arithmetic { - - public Calculator() { - // Statements to create the graphical - // representation of the calculator - } - - @Override - public int sum(int aOne, int aTwo) { - return aOne + aTwo; - } - - @Override - public void version() { - System.out.println("0.0.1"); - } - - } - -} - -interface Shape { - public double area(); -} - -abstract class Arithmetic { - public abstract int sum(int aOne, int aTwo); - public abstract void version(); -} diff --git a/Task/Function-prototype/Julia/function-prototype-1.jl b/Task/Function-prototype/Julia/function-prototype-1.julia similarity index 100% rename from Task/Function-prototype/Julia/function-prototype-1.jl rename to Task/Function-prototype/Julia/function-prototype-1.julia diff --git a/Task/Function-prototype/Julia/function-prototype-2.jl b/Task/Function-prototype/Julia/function-prototype-2.julia similarity index 100% rename from Task/Function-prototype/Julia/function-prototype-2.jl rename to Task/Function-prototype/Julia/function-prototype-2.julia diff --git a/Task/Function-prototype/Kotlin/function-prototype.kts b/Task/Function-prototype/Kotlin/function-prototype.kotlin similarity index 100% rename from Task/Function-prototype/Kotlin/function-prototype.kts rename to Task/Function-prototype/Kotlin/function-prototype.kotlin diff --git a/Task/Function-prototype/OCaml/function-prototype.ml b/Task/Function-prototype/OCaml/function-prototype.ocaml similarity index 100% rename from Task/Function-prototype/OCaml/function-prototype.ml rename to Task/Function-prototype/OCaml/function-prototype.ocaml diff --git a/Task/Functional-coverage-tree/C++/functional-coverage-tree.cpp b/Task/Functional-coverage-tree/C++/functional-coverage-tree.cpp deleted file mode 100644 index 9397979952..0000000000 --- a/Task/Functional-coverage-tree/C++/functional-coverage-tree.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include -#include -#include -#include -#include -#include - -class FCNode { -public: - FCNode(const std::string& name, const uint32_t& weight, const double& coverage) - : name(name), weight(weight), coverage(coverage), parent(NULL) {} - - void add_children(const std::vector>& nodes) { - for ( const std::shared_ptr& node : nodes ) { - node->parent = this; - children.emplace_back(node); - update_coverage(); - } - } - - double get_coverage() { - return coverage; - } - - void set_coverage(const double& aCoverage) { - if ( coverage != aCoverage ) { - coverage = aCoverage; - if ( parent ) { - parent->update_coverage(); - } - } - } - - void display() { - display(0); - } - -private: - void update_coverage() { - double sum_weighted_coverage = 0.0; - uint32_t sum_weight = 0; - for ( const std::shared_ptr& node : children ) { - sum_weighted_coverage += node->weight * node->coverage; - sum_weight += node->weight; - } - - set_coverage(sum_weighted_coverage / sum_weight); - } - - void display(uint32_t level) { - const std::string initial = std::string(4 * level, ' ') + name; - const std::string padding = std::string(NAME_FIELD_WIDTH - initial.length(), ' '); - std::cout << initial + padding + "|"; - std::cout << " " << std::setw(3) << weight << " |"; - std::cout << " " << std::fixed << std::setprecision(6) << coverage << " |" << std::endl; - - for ( const std::shared_ptr& child : children ) { - child->display(level + 1); - } - } - - std::string name; - uint32_t weight; - double coverage; - FCNode* parent; - std::vector> children{ }; - - static constexpr uint32_t NAME_FIELD_WIDTH = 32; -}; - -int main() { - FCNode cleaning("Cleaning", 1, 0.0); - - std::vector> houses = { - std::make_shared("House_1", 40, 0.0), - std::make_shared("House_2", 60, 0.0) - }; - cleaning.add_children(houses); - - std::vector> house_1 = { - std::make_shared("Bedrooms", 1, 0.25), - std::make_shared("Bathrooms", 1, 0.0), - std::make_shared("Attic", 1, 0.75), - std::make_shared("Kitchen", 1, 0.1), - std::make_shared("Living_rooms", 1, 0.0), - std::make_shared("Basement", 1, 0.0), - std::make_shared("Garage", 1, 0.0), - std::make_shared("Garden",1, 0.8) - }; - houses[0]->add_children(house_1); - - std::vector> bathrooms_house_1 = { - std::make_shared("Bathroom_1", 1, 0.5), - std::make_shared("Bathroom_2", 1, 0.0), - std::make_shared("Outside_lavatory", 1, 1.0) - }; - house_1[1]->add_children(bathrooms_house_1); - - std::vector> living_rooms_house_1 = { - std::make_shared("lounge", 1, 0.0), - std::make_shared("Dining_room", 1, 0.0), - std::make_shared("Conservatory", 1, 0.0), - std::make_shared("Playroom", 1, 1.0) - }; - house_1[4]->add_children(living_rooms_house_1); - - std::vector> house_2 = { - std::make_shared("Upstairs", 1, 0.15), - std::make_shared("Ground_floor", 1, 0.316667), - std::make_shared("Basement", 1, 0.916667) - }; - houses[1]->add_children(house_2); - - std::vector> upstairs = { - std::make_shared("Bedrooms", 1, 0.0), - std::make_shared("Bathroom", 1, 0.0), - std::make_shared("Toilet", 1, 0.0), - std::make_shared("Attics", 1, 0.6) - }; - house_2[0]->add_children(upstairs); - - std::vector> ground_floor = { - std::make_shared("Kitchen", 1, 0.0), - std::make_shared("Living_rooms", 1, 0.0), - std::make_shared("Wet_room_&_toilet", 1, 0.0), - std::make_shared("Garage", 1, 0.0), - std::make_shared("Garden", 1, 0.9), - std::make_shared("Hot_tub_suite", 1, 1.0) - }; - house_2[1]->add_children(ground_floor); - - std::vector> basement = { - std::make_shared("Cellars", 1, 1.0), - std::make_shared("Wine_cellar", 1, 1.0), - std::make_shared("Cinema", 1, 0.75) - }; - house_2[2]->add_children(basement); - - std::vector> bedrooms = { - std::make_shared("Suite_1", 1, 0.0), - std::make_shared("Suite_2", 1, 0.0), - std::make_shared("Bedroom_3",1, 0.0), - std::make_shared("Bedroom_4",1, 0.0) - }; - upstairs[0]->add_children(bedrooms); - - std::vector> living_rooms_house_2 = { - std::make_shared("lounge", 1, 0.0), - std::make_shared("Dining_room", 1, 0.0), - std::make_shared("Conservatory", 1, 0.0), - std::make_shared("Playroom", 1, 0.0) - }; - ground_floor[1]->add_children(living_rooms_house_2); - - const double overall_coverage = cleaning.get_coverage(); - std::cout << "OVERALL COVERAGE = " << std::fixed << std::setprecision(6) - << overall_coverage << std::endl << std::endl; - std::cout << "NAME HIERARCHY | WEIGHT | COVERAGE |" << std::endl; - std::cout << "--------------------------------|--------|----------|" << std::endl; - cleaning.display(); - std::cout << std::endl; - - basement[2]->set_coverage(1.0); // Change House_2 Cinema node coverage to 1.0 - const double updated_coverage = cleaning.get_coverage(); - const double difference = updated_coverage - overall_coverage; - std::cout << "If the coverage of the House_2 Cinema node were increased " << std::endl; - std::cout << "from 0.75 to 1.0 the overall coverage would increase by "; - std::cout << std::fixed << std::setprecision(6) << difference << " to " << updated_coverage << std::endl; - basement[2]->set_coverage(0.75); // Restore to House_2 Cinema node coverage to its original value -} diff --git a/Task/Functional-coverage-tree/FreeBASIC/functional-coverage-tree.basic b/Task/Functional-coverage-tree/FreeBASIC/functional-coverage-tree.basic deleted file mode 100644 index 55d06e8f9a..0000000000 --- a/Task/Functional-coverage-tree/FreeBASIC/functional-coverage-tree.basic +++ /dev/null @@ -1,154 +0,0 @@ -Type FCNode - As String nombre - As Integer weight - As Double coverage - As FCNode Ptr children(Any) - As FCNode Ptr parent - Declare Constructor(nombre As String, weight As Integer, coverage As Double) - Declare Sub addChildren(nodes() As FCNode Ptr) - Declare Sub setCoverage(value As Double) - Declare Sub updateCoverage() - Declare Sub show(level As Integer) -End Type - -Constructor FCNode(nombre As String, weight As Integer, coverage As Double) - this.nombre = nombre - this.weight = weight - this.coverage = coverage - this.parent = 0 -End Constructor - -Sub FCNode.addChildren(nodes() As FCNode Ptr) - For i As Integer = 0 To Ubound(nodes) - nodes(i)->parent = @This - Redim Preserve this.children(Ubound(this.children) + 1) - this.children(Ubound(this.children)) = nodes(i) - Next - this.updateCoverage() -End Sub - -Sub FCNode.setCoverage(value As Double) - If this.coverage <> value Then - this.coverage = value - If this.parent <> 0 Then this.parent->updateCoverage() - End If -End Sub - -Sub FCNode.updateCoverage() - Dim As Double v1 = 0 - Dim As Integer v2 = 0 - For i As Integer = 0 To Ubound(this.children) - v1 += this.children(i)->weight * this.children(i)->coverage - v2 += this.children(i)->weight - Next - If v2 <> 0 Then this.setCoverage(v1 / v2) -End Sub - -Sub FCNode.show(level As Integer) - Dim As Integer indent, nl, i - - indent = level * 4 - nl = Len(this.nombre) + indent - Print Space(indent); this.nombre; Space(32 - nl); "|"; Using "#####"; this.weight; - Print Using " | #.###### |"; this.coverage - If Ubound(this.children) = -1 Then Return - For i = 0 To Ubound(this.children) - this.children(i)->show(level + 1) - Next -End Sub - -Function newFCN(nombre As String, weight As Integer, coverage As Double) As FCNode Ptr - Return New FCNode(nombre, weight, coverage) -End Function - -Dim houses(1) As FCNode Ptr -houses(0) = newFCN("house1", 40, 0) -houses(1) = newFCN("house2", 60, 0) - -Dim house1(7) As FCNode Ptr -house1(0) = newFCN("bedrooms", 1, 0.25) -house1(1) = newFCN("bathrooms", 1, 0) -house1(2) = newFCN("attic", 1, 0.75) -house1(3) = newFCN("kitchen", 1, 0.1) -house1(4) = newFCN("living_rooms", 1, 0) -house1(5) = newFCN("basement", 1, 0) -house1(6) = newFCN("garage", 1, 0) -house1(7) = newFCN("garden", 1, 0.8) - -Dim house2(2) As FCNode Ptr -house2(0) = newFCN("upstairs", 1, 0) -house2(1) = newFCN("groundfloor", 1, 0) -house2(2) = newFCN("basement", 1, 0) - -Dim h1Bathrooms(2) As FCNode Ptr -h1Bathrooms(0) = newFCN("bathroom1", 1, 0.5) -h1Bathrooms(1) = newFCN("bathroom2", 1, 0) -h1Bathrooms(2) = newFCN("outside_lavatory", 1, 1) - -Dim h1LivingRooms(3) As FCNode Ptr -h1LivingRooms(0) = newFCN("lounge", 1, 0) -h1LivingRooms(1) = newFCN("dining_room", 1, 0) -h1LivingRooms(2) = newFCN("conservatory", 1, 0) -h1LivingRooms(3) = newFCN("playroom", 1, 1) - -Dim h2Upstairs(3) As FCNode Ptr -h2Upstairs(0) = newFCN("bedrooms", 1, 0) -h2Upstairs(1) = newFCN("bathroom", 1, 0) -h2Upstairs(2) = newFCN("toilet", 1, 0) -h2Upstairs(3) = newFCN("attics", 1, 0.6) - -Dim h2Groundfloor(5) As FCNode Ptr -h2Groundfloor(0) = newFCN("kitchen", 1, 0) -h2Groundfloor(1) = newFCN("living_rooms", 1, 0) -h2Groundfloor(2) = newFCN("wet_room_&_toilet", 1, 0) -h2Groundfloor(3) = newFCN("garage", 1, 0) -h2Groundfloor(4) = newFCN("garden", 1, 0.9) -h2Groundfloor(5) = newFCN("hot_tub_suite", 1, 1) - -Dim h2Basement(2) As FCNode Ptr -h2Basement(0) = newFCN("cellars", 1, 1) -h2Basement(1) = newFCN("wine_cellar", 1, 1) -h2Basement(2) = newFCN("cinema", 1, 0.75) - -Dim h2UpstairsBedrooms(3) As FCNode Ptr -h2UpstairsBedrooms(0) = newFCN("suite_1", 1, 0) -h2UpstairsBedrooms(1) = newFCN("suite_2", 1, 0) -h2UpstairsBedrooms(2) = newFCN("bedroom_3", 1, 0) -h2UpstairsBedrooms(3) = newFCN("bedroom_4", 1, 0) - -Dim h2GroundfloorLivingRooms(3) As FCNode Ptr -h2GroundfloorLivingRooms(0) = newFCN("lounge", 1, 0) -h2GroundfloorLivingRooms(1) = newFCN("dining_room", 1, 0) -h2GroundfloorLivingRooms(2) = newFCN("conservatory", 1, 0) -h2GroundfloorLivingRooms(3) = newFCN("playroom", 1, 0) - -Dim cleaning As FCNode Ptr = newFCN("cleaning", 1, 0) - -house1(1)->addChildren(h1Bathrooms()) -house1(4)->addChildren(h1LivingRooms()) -houses(0)->addChildren(house1()) - -h2Upstairs(0)->addChildren(h2UpstairsBedrooms()) -house2(0)->addChildren(h2Upstairs()) -h2Groundfloor(1)->addChildren(h2GroundfloorLivingRooms()) -house2(1)->addChildren(h2Groundfloor()) -house2(2)->addChildren(h2Basement()) -houses(1)->addChildren(house2()) - -cleaning->addChildren(houses()) -Dim As Double topCoverage = cleaning->coverage -Print "TOP COVERAGE = "; -Print Using "########.######"; topCoverage -Print -Print "NAME HIERARCHY | WEIGHT | COVERAGE |" -cleaning->show(0) - -h2Basement(2)->setCoverage(1) ' change Cinema node coverage to 1 -Dim As Double diff = cleaning->coverage - topCoverage -Print -Print "If the coverage of the Cinema node were increased from 0.75 to 1" -Print "the top level coverage would increase by "; -Print Using "##.###### to ##.######"; diff; (topCoverage + diff) -h2Basement(2)->setCoverage(0.75) ' restore to original value if required - -Sleep diff --git a/Task/Functional-coverage-tree/Java/functional-coverage-tree.java b/Task/Functional-coverage-tree/Java/functional-coverage-tree.java index 703ad2b3f5..df0fd64987 100644 --- a/Task/Functional-coverage-tree/Java/functional-coverage-tree.java +++ b/Task/Functional-coverage-tree/Java/functional-coverage-tree.java @@ -1,4 +1,5 @@ import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public final class FunctionalCoverageTree { @@ -6,12 +7,12 @@ public final class FunctionalCoverageTree { public static void main(String[] aArgs) { FCNode cleaning = new FCNode("Cleaning", 1, 0.0); - List houses = List.of( + List houses = Arrays.asList( new FCNode("House_1", 40, 0.0), new FCNode("House_2", 60, 0.0) ); cleaning.addChildren(houses); - List house_1 = List.of( + List house_1 = Arrays.asList( new FCNode("Bedrooms", 1, 0.25), new FCNode("Bathrooms", 1, 0.0), new FCNode("Attic", 1, 0.75), @@ -22,33 +23,33 @@ public final class FunctionalCoverageTree { new FCNode("Garden",1, 0.8) ); houses.get(0).addChildren(house_1); - List bathrooms_house_1 = List.of( + List bathrooms_house_1 = Arrays.asList( new FCNode("Bathroom_1", 1, 0.5), new FCNode("Bathroom_2", 1, 0.0), new FCNode("Outside_lavatory", 1, 1.0) ); house_1.get(1).addChildren(bathrooms_house_1); - List living_rooms_house_1 = List.of( + List living_rooms_house_1 = Arrays.asList( new FCNode("lounge", 1, 0.0), new FCNode("Dining_room", 1, 0.0), new FCNode("Conservatory", 1, 0.0), new FCNode("Playroom", 1, 1.0) ); house_1.get(4).addChildren(living_rooms_house_1); - List house_2 = List.of( + List house_2 = Arrays.asList( new FCNode("Upstairs", 1, 0.15), new FCNode("Ground_floor", 1, 0.316667), new FCNode("Basement", 1, 0.916667)); houses.get(1).addChildren(house_2); - List upstairs = List.of( + List upstairs = Arrays.asList( new FCNode("Bedrooms", 1, 0.0), new FCNode("Bathroom", 1, 0.0), new FCNode("Toilet", 1, 0.0), new FCNode("Attics", 1, 0.6) ); house_2.get(0).addChildren(upstairs); - List ground_floor = List.of( + List ground_floor = Arrays.asList( new FCNode("Kitchen", 1, 0.0), new FCNode("Living_rooms", 1, 0.0), new FCNode("Wet_room_&_toilet", 1, 0.0), @@ -57,20 +58,20 @@ public final class FunctionalCoverageTree { new FCNode("Hot_tub_suite", 1, 1.0) ); house_2.get(1).addChildren(ground_floor); - List basement = List.of( + List basement = Arrays.asList( new FCNode("Cellars", 1, 1.0), new FCNode("Wine_cellar", 1, 1.0), new FCNode("Cinema", 1, 0.75) ); house_2.get(2).addChildren(basement); - List bedrooms = List.of( + List bedrooms = Arrays.asList( new FCNode("Suite_1", 1, 0.0), new FCNode("Suite_2", 1, 0.0), new FCNode("Bedroom_3",1, 0.0), new FCNode("Bedroom_4",1, 0.0) ); upstairs.get(0).addChildren(bedrooms); - List living_rooms_house_2 = List.of( + List living_rooms_house_2 = Arrays.asList( new FCNode("lounge", 1, 0.0), new FCNode("Dining_room", 1, 0.0), new FCNode("Conservatory", 1, 0.0), @@ -78,8 +79,7 @@ public final class FunctionalCoverageTree { ground_floor.get(1).addChildren(living_rooms_house_2); final double overallCoverage = cleaning.getCoverage(); - System.out.println("OVERALL COVERAGE = " + String.format("%.6f", overallCoverage)); - System.out.println(); + System.out.println("OVERALL COVERAGE = " + String.format("%.6f", overallCoverage) + System.lineSeparator()); System.out.println("NAME HIERARCHY | WEIGHT | COVERAGE |" ); System.out.println("--------------------------------|--------|----------|"); cleaning.display(); @@ -130,14 +130,14 @@ final class FCNode { } private void updateCoverage() { - double sumWeightedCoverage = 0.0; - int sumWeight = 0; + double value1 = 0.0; + int value2 = 0; for ( FCNode node : children ) { - sumWeightedCoverage += node.weight * node.coverage; - sumWeight += node.weight; + value1 += node.weight * node.coverage; + value2 += node.weight; } - setCoverage(sumWeightedCoverage / sumWeight); + setCoverage(value1 / value2); } private void display(int aLevel) { diff --git a/Task/Functional-coverage-tree/Julia/functional-coverage-tree.jl b/Task/Functional-coverage-tree/Julia/functional-coverage-tree.julia similarity index 100% rename from Task/Functional-coverage-tree/Julia/functional-coverage-tree.jl rename to Task/Functional-coverage-tree/Julia/functional-coverage-tree.julia diff --git a/Task/Functional-coverage-tree/Kotlin/functional-coverage-tree.kts b/Task/Functional-coverage-tree/Kotlin/functional-coverage-tree.kotlin similarity index 100% rename from Task/Functional-coverage-tree/Kotlin/functional-coverage-tree.kts rename to Task/Functional-coverage-tree/Kotlin/functional-coverage-tree.kotlin diff --git a/Task/Functional-coverage-tree/Phix/functional-coverage-tree.phix b/Task/Functional-coverage-tree/Phix/functional-coverage-tree.phix index da5f44351a..7f57dc15f2 100644 --- a/Task/Functional-coverage-tree/Phix/functional-coverage-tree.phix +++ b/Task/Functional-coverage-tree/Phix/functional-coverage-tree.phix @@ -1,108 +1,113 @@ --- demo\rosetta\Functional_coverage_tree.exw -with javascript_semantics -constant data = """ -NAME_HIERARCHY | WEIGHT | COVERAGE | -cleaning | | | - house1 |40 | | - bedrooms | |0.25 | - bathrooms | | | - bathroom1 | |0.5 | - bathroom2 | | | - outside_lavatory | |1 | - attic | |0.75 | - kitchen | |0.1 | - living_rooms | | | - lounge | | | - dining_room | | | - conservatory | | | - playroom | |1 | - basement | | | - garage | | | - garden | |0.8 | - house2 |60 | | - upstairs | | | - bedrooms | | | - suite_1 | | | - suite_2 | | | - bedroom_3 | | | - bedroom_4 | | | - bathroom | | | - toilet | | | - attics | |0.6 | - groundfloor | | | - kitchen | | | - living_rooms | | | - lounge | | | - dining_room | | | - conservatory | | | - playroom | | | - wet_room_&_toilet | | | - garage | | | - garden | |0.9 | - hot_tub_suite | |1 | - basement | | | - cellars | |1 | - wine_cellar | |1 | - cinema | |0.75 | -""" -sequence lines = split(data,"\n"), - pi = {}, -- indents (to locate parents) - pdx = {}, -- indexes for "" - children -string desc, weights, covers -integer parent, child -atom weight, coverage, childw = 0 -enum DESC, WEIGHT, COVERAGE, PARENT, CHILDREN, CHILDW -lines[DESC] &= " SHARE OF RESIDUE" -for i=2 to length(lines) do - -- decode text to useable data, link up parents & children - {desc,weights,covers} = split(lines[i],"|") - -- (nb this assumes /totally/ consistent indenting) - integer indent = length(desc)-length(trim_head(desc)), - k = find(indent,pi) - if k=0 then - pi = append(pi,indent) - pdx = append(pdx,0) - k = length(pi) - end if - pdx[k] = i - parent = 0 - if k>1 then - parent = pdx[k-1] --- lines[parent][CHILDREN] &= i - lines[parent][CHILDREN] = deep_copy(lines[parent][CHILDREN]) & i - end if - children = {} - weight = to_number(trim(weights),1) - coverage = to_number(trim(covers),0) - lines[i] = {desc, weight, coverage, parent, children, childw} -end for -for i=length(lines) to 2 by -1 do - -- calculate the parent coverages, and save child weight sums - children = lines[i][CHILDREN] - if length(children) then - coverage = 0 - childw = 0 - for c=1 to length(children) do - child = children[c] - atom w = lines[child][WEIGHT] - coverage += lines[child][COVERAGE]*w - childw += w - end for - lines[i][COVERAGE] = coverage/childw - lines[i][CHILDW] = childw -- (save for next loop) - end if -end for -for i=length(lines) to 2 by -1 do - -- calculate the share of residue, and format lines - child = i - {desc, weight, coverage, parent} = lines[i] - atom residue = 1-coverage - while parent do - residue *= lines[child][WEIGHT]/lines[parent][CHILDW] - {child, parent} = {parent, lines[parent][PARENT]} - end while - lines[i] = sprintf("%-32s| %6d | %-8g | %g",{desc,weight,coverage,residue}) -end for -puts(1,join(lines,"\n")&"\n") -{} = wait_key() +(phixonline)--> + -- + -- demo\rosetta\Functional_coverage_tree.exw + -- ========================================= + -- + with javascript_semantics + constant data = """ + NAME_HIERARCHY | WEIGHT | COVERAGE | + cleaning | | | + house1 |40 | | + bedrooms | |0.25 | + bathrooms | | | + bathroom1 | |0.5 | + bathroom2 | | | + outside_lavatory | |1 | + attic | |0.75 | + kitchen | |0.1 | + living_rooms | | | + lounge | | | + dining_room | | | + conservatory | | | + playroom | |1 | + basement | | | + garage | | | + garden | |0.8 | + house2 |60 | | + upstairs | | | + bedrooms | | | + suite_1 | | | + suite_2 | | | + bedroom_3 | | | + bedroom_4 | | | + bathroom | | | + toilet | | | + attics | |0.6 | + groundfloor | | | + kitchen | | | + living_rooms | | | + lounge | | | + dining_room | | | + conservatory | | | + playroom | | | + wet_room_&_toilet | | | + garage | | | + garden | |0.9 | + hot_tub_suite | |1 | + basement | | | + cellars | |1 | + wine_cellar | |1 | + cinema | |0.75 | + """ + sequence lines = split(data,"\n"), + pi = {}, -- indents (to locate parents) + pdx = {}, -- indexes for "" + children + string desc, weights, covers + integer parent, child + atom weight, coverage, childw = 0 + enum DESC, WEIGHT, COVERAGE, PARENT, CHILDREN, CHILDW + lines[1] &= " SHARE OF RESIDUE" + for i=2 to length(lines) do + -- decode text to useable data, link up parents & children + {desc,weights,covers} = split(lines[i],"|") + -- (nb this assumes /totally/ consistent indenting) + integer indent = length(desc)-length(trim_head(desc)), + k = find(indent,pi) + if k=0 then + pi = append(pi,indent) + pdx = append(pdx,0) + k = length(pi) + end if + pdx[k] = i + parent = 0 + if k>1 then + parent = pdx[k-1] + -- lines[parent][CHILDREN] &= i + lines[parent][CHILDREN] = deep_copy(lines[parent][CHILDREN]) & i + end if + children = {} + weight = to_number(trim(weights),1) + coverage = to_number(trim(covers),0) + lines[i] = {desc, weight, coverage, parent, children, childw} + end for + for i=length(lines) to 2 by -1 do + -- calculate the parent coverages, and save child weight sums + children = lines[i][CHILDREN] + if length(children) then + coverage = 0 + childw = 0 + for c=1 to length(children) do + child = children[c] + atom w = lines[child][WEIGHT] + coverage += lines[child][COVERAGE]*w + childw += w + end for + lines[i][COVERAGE] = coverage/childw + lines[i][CHILDW] = childw -- (save for next loop) + end if + end for + for i=length(lines) to 2 by -1 do + -- calculate the share of residue, and format lines + child = i + {desc, weight, coverage, parent} = lines[i] + atom residue = 1-coverage + while parent do + residue *= lines[child][WEIGHT]/lines[parent][CHILDW] + {child, parent} = {parent, lines[parent][PARENT]} + end while + lines[i] = sprintf("%-32s| %6d | %-8g | %g",{desc,weight,coverage,residue}) + end for + puts(1,join(lines,"\n")&"\n") + {} = wait_key() + diff --git a/Task/Fusc-sequence/Ada/fusc-sequence.adb b/Task/Fusc-sequence/Ada/fusc-sequence.ada similarity index 100% rename from Task/Fusc-sequence/Ada/fusc-sequence.adb rename to Task/Fusc-sequence/Ada/fusc-sequence.ada diff --git a/Task/Fusc-sequence/Arturo/fusc-sequence.arturo b/Task/Fusc-sequence/Arturo/fusc-sequence.arturo index 0355b9e3fa..9854dd9590 100644 --- a/Task/Fusc-sequence/Arturo/fusc-sequence.arturo +++ b/Task/Fusc-sequence/Arturo/fusc-sequence.arturo @@ -1,8 +1,8 @@ fusc: function [n][ - switch or? n=0 n=1 -> n - [ - switch 0=n%2 -> fusc n/2 - -> (fusc (n-1)/2) + fusc (n+1)/2 + if? or? n=0 n=1 -> n + else [ + if? 0=n%2 -> fusc n/2 + else -> (fusc (n-1)/2) + fusc (n+1)/2 ] ] diff --git a/Task/Fusc-sequence/BBC-BASIC/fusc-sequence.basic b/Task/Fusc-sequence/BBC-BASIC/fusc-sequence.basic deleted file mode 100644 index a7abddf247..0000000000 --- a/Task/Fusc-sequence/BBC-BASIC/fusc-sequence.basic +++ /dev/null @@ -1,22 +0,0 @@ - DIM Idx%(4) - L%=1 - F%=FNfusc(I%) - PRINT "First 61 numbers:" - WHILE L% < 5 - IF I% < 61 PRINT;F% ","; - I%+=1 - F%=FNfusc(I%) - IF LOGF% > L% Idx%(L%)=I% : L%+=1 - ENDIF - ENDWHILE - - PRINT CHR$127 ''"Number of digits in sequence increase at:" - FOR I%=0 TO L%-1 - PRINT ;Idx%(I%) ",";FNfusc(Idx%(I%)) - NEXT - END - - DEF FNfusc(n%) - IF n% < 2 THEN =n% - IF n% AND 1 THEN =FNfusc((n%-1)/2) + FNfusc((n%+1)/2) - =FNfusc(n%/2) diff --git a/Task/Fusc-sequence/COBOL/fusc-sequence.cob b/Task/Fusc-sequence/COBOL/fusc-sequence.cob deleted file mode 100644 index 79f12919f3..0000000000 --- a/Task/Fusc-sequence/COBOL/fusc-sequence.cob +++ /dev/null @@ -1,110 +0,0 @@ -IDENTIFICATION DIVISION. - PROGRAM-ID. FUSC-SEQUENCE. - - ENVIRONMENT DIVISION. - - DATA DIVISION. - WORKING-STORAGE SECTION. - - 01 FUSC-MAX PIC 9(8) COMP VALUE 2000. - 01 FUSC-TABLE. - 05 FUSC-VAL OCCURS 2000 TIMES - PIC 9(8) COMP. - - 01 WS-N PIC 9(8) COMP. - 01 WS-I PIC 9(2) COMP. - 01 WS-J PIC 9(8) COMP. - 01 WS-START PIC 9(8) COMP. - 01 WS-VAL PIC S9(8) COMP. - 01 WS-HALF PIC 9(8) COMP. - 01 WS-HALF-MINUS PIC 9(8) COMP. - 01 WS-HALF-PLUS PIC 9(8) COMP. - 01 WS-POWER PIC 9(8) COMP. - 01 WS-IDX PIC 9(8) COMP. - 01 WS-FOUND PIC X VALUE 'N'. - 01 WS-DISPLAY-IDX PIC Z(7)9. - 01 WS-DISPLAY-VAL PIC Z(7)9. - - PROCEDURE DIVISION. - - 000-MAIN SECTION. - MAIN-PARA. - PERFORM 100-INIT-FUSC - PERFORM 200-DISPLAY-FIRST-61 - PERFORM 300-DISPLAY-LENGTH-RECORDS - STOP RUN. - - *>---------------------------------------------------------------- - *> Initialize the FUSC array - *>---------------------------------------------------------------- - 100-INIT-FUSC SECTION. - MOVE 0 TO FUSC-VAL(1) - MOVE 1 TO FUSC-VAL(2) - PERFORM VARYING WS-N FROM 3 BY 1 - UNTIL WS-N > FUSC-MAX - EVALUATE TRUE - WHEN FUNCTION MOD(WS-N - 1, 2) = 0 - COMPUTE WS-HALF = (WS-N - 1) / 2 + 1 - MOVE FUSC-VAL(WS-HALF) TO FUSC-VAL(WS-N) - WHEN OTHER - COMPUTE WS-HALF-MINUS = - (WS-N - 2) / 2 + 1 - COMPUTE WS-HALF-PLUS = - WS-N / 2 + 1 - COMPUTE FUSC-VAL(WS-N) = - FUSC-VAL(WS-HALF-MINUS) + - FUSC-VAL(WS-HALF-PLUS) - END-EVALUATE - END-PERFORM. - - *>---------------------------------------------------------------- - *> Display first 61 fusc numbers (0-based index 0..60) - *>---------------------------------------------------------------- - 200-DISPLAY-FIRST-61 SECTION. - DISPLAY "Show the first 61 fusc numbers " - "(starting at zero) in a horizontal format" - PERFORM VARYING WS-N FROM 1 BY 1 - UNTIL WS-N > 61 - MOVE FUSC-VAL(WS-N) TO WS-DISPLAY-VAL - DISPLAY FUNCTION TRIM(WS-DISPLAY-VAL - LEADING) " " WITH NO ADVANCING - END-PERFORM - DISPLAY " ". - - *>---------------------------------------------------------------- - *> Display fusc numbers whose value first exceeds 10^i - *>---------------------------------------------------------------- - 300-DISPLAY-LENGTH-RECORDS SECTION. - DISPLAY " " - DISPLAY "Show the fusc number (and its index) whose " - "length is greater than any previous fusc number length." - MOVE 1 TO WS-START - PERFORM VARYING WS-I FROM 0 BY 1 - UNTIL WS-I > 5 - EVALUATE WS-I - WHEN 0 - MOVE -1 TO WS-VAL - WHEN OTHER - MOVE 1 TO WS-POWER - PERFORM VARYING WS-IDX FROM 1 BY 1 - UNTIL WS-IDX > WS-I - MULTIPLY 10 BY WS-POWER - END-PERFORM - MOVE WS-POWER TO WS-VAL - END-EVALUATE - MOVE 'N' TO WS-FOUND - PERFORM VARYING WS-J FROM WS-START BY 1 - UNTIL WS-J > FUSC-MAX OR WS-FOUND = 'Y' - IF FUSC-VAL(WS-J) > WS-VAL - COMPUTE WS-N = WS-J - 1 - MOVE WS-N TO WS-DISPLAY-IDX - MOVE FUSC-VAL(WS-J) TO WS-DISPLAY-VAL - DISPLAY "fusc[" - FUNCTION TRIM(WS-DISPLAY-IDX LEADING) - "] = " - FUNCTION TRIM(WS-DISPLAY-VAL LEADING) - MOVE WS-J TO WS-START - MOVE 'Y' TO WS-FOUND - END-IF - END-PERFORM - END-PERFORM. diff --git a/Task/Fusc-sequence/EasyLang/fusc-sequence.easy b/Task/Fusc-sequence/EasyLang/fusc-sequence.easy deleted file mode 100644 index 14197eec6a..0000000000 --- a/Task/Fusc-sequence/EasyLang/fusc-sequence.easy +++ /dev/null @@ -1,30 +0,0 @@ -FUSCMAX = 20000000 -len fusc[] FUSCMAX + 1 -# -fastproc fill . - fusc[1] = 1 - for n = 2 to FUSCMAX - if n mod 2 = 0 - fusc[n] = fusc[n / 2] - else - fusc[n] = fusc[(n - 1) / 2] + fusc[(n + 1) / 2] - . - . -. -fill -write "0 " -for n = 1 to 60 : write fusc[n] & " " -print "" -print "" -start = 1 -print "fusc[0] = 0" -for i = 1 to 5 - val = floor pow 10 i - for j = start to FUSCMAX - if fusc[j] > val - print "fusc[" & j & "] = " & fusc[j] - start = j - break 1 - . - . -. diff --git a/Task/Fusc-sequence/Fortran/fusc-sequence.f b/Task/Fusc-sequence/Fortran/fusc-sequence.f deleted file mode 100644 index 4d5c8c0f53..0000000000 --- a/Task/Fusc-sequence/Fortran/fusc-sequence.f +++ /dev/null @@ -1,185 +0,0 @@ -! -! Fusc sequence -! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 25.04 -! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 -! No Non-standard features used, should compile on any fairly recent Fortran. -! U.B., September 2025 - -program FuscNumbers - - implicit none - - integer, parameter :: kInt = 4 - integer, parameter :: maxdigs = 6 - integer, parameter :: strLen = 20 - - integer (kind=kInt), allocatable :: fuscMem(:) - - integer :: capacity, content ! usage of above container - - integer (kind=kInt) :: w,c,t - integer (kind=kINt) :: i, f - integer :: d=0, n=61, digs=1 - - character (len=strLen) :: sNum(2) ! for formatted output of integer numbers - - content = 0 - capacity = 1024 - call resize (fuscMem, capacity) - - call push (0) - call push (1) - - w = -1 - c = 0 - n = 61 - write ( *, '("First " , i0, " numbers in the fusc sequence:" )') n - - i = 0 - do while (i .lt. 61) - f = fusc(i) - if (mod (i, 20) .ne. 0) then - write (*, '(i2, x)', advance='no' ) f - else - write (*, '(i2,x)') f - endif - i = i + 1 - end do - - write (*, '(/"Fusc numbers with more digits than any previous (1 to 6 digits):")') - write (*, '( " Index Value")') - i = 0 - do while (digs <= maxdigs) - f = fusc (i) - if (f .ge. d) then - ! show all numbers with commas (if appropriate). - snum(1) = GroupedDigits(i, 10) - snum(2) = GroupedDigits(f,10) - if (digs .gt.1) then - write (*,'(i2, " digits: ", A10,x,A )' ) digs, snum(1), snum(2) - else - write (*,'(i2, " digit : ", A10,x,A )' ) digs, snum(1), snum(2) - endif - if (d .eq. 0) then - d = 10 - else - d = d * 10 - endif - digs = digs + 1 - if (digs .gt. 6) exit - end if - i = i + 1 - end do - - - contains - - function fusc (n) result (ret) - integer (kind=kint), intent(in) :: n - integer (kind=kInt) ret - - - if (n .lt. content) then - ret = fuscMem (1+n) - else - if (iand (n,1_kint) .eq. 0) then ! Even n has bit 0 = zero - ret = fuscMem(1+n/2) - call push (ret) ! Store for future use. - else ! Else its odd. - ret = fuscMem(1+(n-1)/2) + fuscMem(1+(n+2)/2) - call push (ret) - end if - end if - - end function fusc - - ! --------------------- - ! memoize another value - ! --------------------- - subroutine push (k) - integer (kind=kint), intent (in) :: k - - content = content+1 - - ! If we would exceed capacity of array 'Words', we need to increment capacity - if (content .gt. capacity) then - capacity = 2*capacity - call resize (fuscMem, capacity) - end if - fuscMem(content) = k - end subroutine push - - - ! ---------------------------------------------- - ! Increase allocated size of dynamic array 'var' - ! ---------------------------------------------- - subroutine resize(var, newSize) - integer (kind=kint), allocatable, intent(inout) :: var(:) ! The array to be increased - integer, intent(in) :: newSize ! The new size of var - integer (kind=kint), allocatable :: tmp(:) ! Temporary storage - integer :: oldSize ! Current array size - integer :: ii ! Loop index - - ! Copy allocated values to temporary, then allocate var with - ! new size and copy back saved values. - ! Could be done with move_alloc but this would not be portable to OpenVMS Fortran - - if (allocated(var)) then - oldSize = size(var) - else - oldSize = 0 - end if - - if (newSize .gt. oldSize) then ! only increment - if (oldSize .gt.0) then - allocate(tmp (oldSize)) - tmp(:oldSize) = var(:oldSize) - deallocate (var) - end if - allocate(var(newSize)) - if (allocated(tmp) .and. allocated (var) ) then - oldSize = min(size(tmp, 1), size(var, 1)) - var(:oldSize) = tmp(:oldSize) - deallocate (tmp) - end if - end if -end subroutine resize - - -! ---------------------------------------------------------------- - ! Fortran does not have a way to use locales for output. - ! Manual insert of separating commas such as 1,345,678 for 1345678 - ! ---------------------------------------------------------------- - function GroupedDigits (n, width) result (outStr) - integer(kind=kint), intent (in) :: n - integer :: width - character (len=width) :: outStr - character (len=2*strLen) :: workStr - integer :: ii, jj, cnt, trueLen - - - ! Write n into a string, then copy the digits to a second string, - ! inserting separater after every 3 digits. - write (workStr, '(i0)') n - ! Adjust left, then cutoff trailing blanks - workstr = adjustl (workstr) - trueLen = len_trim (workStr) - - outStr = ' ' - jj = width - cnt = 0 - do ii=trueLen, 1, -1 ! Copy backwards for correct grouping. - outStr (jj:jj) = workStr (ii:ii) - jj = jj -1 - cnt = cnt + 1 - ! Insert comma after 3 digits, but only if more digits follow. - if (mod (cnt, 3) .eq. 0 .and. ii .gt. 1 .and. workStr(ii-1:ii-1) .ne. ' ') then - outStr (jj:jj) = ',' - jj = jj - 1 - endif - end do - - end function GroupedDigits - - end program FuscNumbers diff --git a/Task/Fusc-sequence/FutureBasic/fusc-sequence.basic b/Task/Fusc-sequence/FutureBasic/fusc-sequence.basic deleted file mode 100644 index 4f848b700e..0000000000 --- a/Task/Fusc-sequence/FutureBasic/fusc-sequence.basic +++ /dev/null @@ -1,40 +0,0 @@ -_max = 20000000 - -begin globals -NSUInteger f(_max) -end globals - -void local fn Fusc - f(0) = 0 : f(1) = 1 - for NSUInteger n = 2 to _max - if ( n & 1 ) - f(n) = f((n - 1) / 2) + f((n + 1) / 2) - else - f(n) = f(n / 2) - end if - next -end fn - -void local fn DoIt - NSUInteger i, d = 0 - - fn Fusc - - for i = 0 to 60 - print f(i);" "; - if ( i == 32 ) then print - next - - print : print : print @" index\t\t value" - for i = 0 to _max - if ( f(i) >= d ) - printf @"%11lu\t\t%6lu",i,f(i) - if ( d == 0 ) then d = 1 - d *= 10 - end if - next -end fn - -fn DoIt - -HandleEvents diff --git a/Task/Fusc-sequence/Julia/fusc-sequence.jl b/Task/Fusc-sequence/Julia/fusc-sequence.julia similarity index 100% rename from Task/Fusc-sequence/Julia/fusc-sequence.jl rename to Task/Fusc-sequence/Julia/fusc-sequence.julia diff --git a/Task/Fusc-sequence/Kotlin/fusc-sequence.kts b/Task/Fusc-sequence/Kotlin/fusc-sequence.kotlin similarity index 100% rename from Task/Fusc-sequence/Kotlin/fusc-sequence.kts rename to Task/Fusc-sequence/Kotlin/fusc-sequence.kotlin diff --git a/Task/Fusc-sequence/OCaml/fusc-sequence.ml b/Task/Fusc-sequence/OCaml/fusc-sequence.ocaml similarity index 100% rename from Task/Fusc-sequence/OCaml/fusc-sequence.ml rename to Task/Fusc-sequence/OCaml/fusc-sequence.ocaml diff --git a/Task/Fusc-sequence/PascalABC.NET/fusc-sequence.pas b/Task/Fusc-sequence/PascalABC.NET/fusc-sequence.pas deleted file mode 100644 index 1379b95752..0000000000 --- a/Task/Fusc-sequence/PascalABC.NET/fusc-sequence.pas +++ /dev/null @@ -1,55 +0,0 @@ -const maxcalc = 100000000; - -var cache := new integer[maxcalc]; - -function Fusc(n: integer): integer; -begin - if (n = 0) or (n = 1) then - begin - Result := n; - exit - end; - if (n < maxcalc) and (cache[n] > 0) then - begin - Result := cache[n]; - exit; - end; - if n.IsEven then - Result := Fusc(n div 2) - else Result := Fusc((n-1) div 2) + Fusc((n+1) div 2); - if n < maxcalc then - cache[n] := Result -end; - -function Digits(n: integer): integer; -begin - Result := 0; - while n > 0 do - begin - Result += 1; - n := n div 10; - end; -end; - -begin - (0..60).Select(Fusc).Println; - var maxdigits := 1; - var num := 0; - var prevfun := 0; - for var i:=1 to integer.MaxValue - 1 do - begin - var fun := Fusc(i); - if fun > prevfun then - begin - var dig := Digits(fun); - if dig > maxdigits then - begin - maxdigits := dig; - Println(fun,i); - num +=1; - if num = 6 then exit; - end; - end; - prevfun := fun; - end; -end. diff --git a/Task/Fusc-sequence/Pluto/fusc-sequence.pluto b/Task/Fusc-sequence/Pluto/fusc-sequence.pluto deleted file mode 100644 index b05612a503..0000000000 --- a/Task/Fusc-sequence/Pluto/fusc-sequence.pluto +++ /dev/null @@ -1,27 +0,0 @@ -local fmt = require "fmt" - -print("The first 61 numbers in the fusc sequence are:") -local fusc = {0, 1} -local fusc2 = {{0, 0}} -local max_len = 1 -local n = 2 -while n < 20e6 do -- limit to indices under 20 million say - local f = (n % 2 == 0) ? fusc[n/2 + 1] : fusc[(n - 1)/2 + 1] + fusc[(n+1)/2 + 1] - fusc:insert(f) - local len = #tostring(f) - if len > max_len then - max_len = len - if n <= 60 then - fusc2:insert({n, f}) - else - fmt.print("%10s %s", fmt.int(n), fmt.int(f)) - end - end - if n == 60 then - for fusc as e do io.write($"{e} ") end - print("\n\nFirst terms longer than any previous ones for indices < 20,000,000:") - print(" Index Value") - for fusc2 as iv do fmt.print("%10d %d", iv[1], iv[2]) end - end - n += 1 -end diff --git a/Task/Fusc-sequence/Rust/fusc-sequence.rs b/Task/Fusc-sequence/Rust/fusc-sequence.rust similarity index 100% rename from Task/Fusc-sequence/Rust/fusc-sequence.rs rename to Task/Fusc-sequence/Rust/fusc-sequence.rust diff --git a/Task/Fusc-sequence/Wren/fusc-sequence.wren b/Task/Fusc-sequence/Wren/fusc-sequence.wren index 7941b2748a..c30b6e9219 100644 --- a/Task/Fusc-sequence/Wren/fusc-sequence.wren +++ b/Task/Fusc-sequence/Wren/fusc-sequence.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt System.print("The first 61 numbers in the fusc sequence are:") var fusc = [0, 1] diff --git a/Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.adb b/Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.ada similarity index 100% rename from Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.adb rename to Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.ada diff --git a/Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-1.pas b/Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-1.delphi similarity index 100% rename from Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-1.pas rename to Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-1.delphi diff --git a/Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-2.pas b/Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-2.delphi similarity index 100% rename from Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-2.pas rename to Task/GUI-Maximum-window-dimensions/Delphi/gui-maximum-window-dimensions-2.delphi diff --git a/Task/GUI-Maximum-window-dimensions/Julia/gui-maximum-window-dimensions.jl b/Task/GUI-Maximum-window-dimensions/Julia/gui-maximum-window-dimensions.julia similarity index 100% rename from Task/GUI-Maximum-window-dimensions/Julia/gui-maximum-window-dimensions.jl rename to Task/GUI-Maximum-window-dimensions/Julia/gui-maximum-window-dimensions.julia diff --git a/Task/GUI-Maximum-window-dimensions/Kotlin/gui-maximum-window-dimensions.kts b/Task/GUI-Maximum-window-dimensions/Kotlin/gui-maximum-window-dimensions.kotlin similarity index 100% rename from Task/GUI-Maximum-window-dimensions/Kotlin/gui-maximum-window-dimensions.kts rename to Task/GUI-Maximum-window-dimensions/Kotlin/gui-maximum-window-dimensions.kotlin diff --git a/Task/GUI-Maximum-window-dimensions/V-(Vlang)/gui-maximum-window-dimensions.v b/Task/GUI-Maximum-window-dimensions/V-(Vlang)/gui-maximum-window-dimensions.v index ff12bda7a8..0c36840074 100644 --- a/Task/GUI-Maximum-window-dimensions/V-(Vlang)/gui-maximum-window-dimensions.v +++ b/Task/GUI-Maximum-window-dimensions/V-(Vlang)/gui-maximum-window-dimensions.v @@ -2,7 +2,7 @@ import ui import gg import gx -@[heap] +[heap] struct App { mut: window &ui.Window = unsafe {nil} diff --git a/Task/GUI-component-interaction/Ada/gui-component-interaction.adb b/Task/GUI-component-interaction/Ada/gui-component-interaction.ada similarity index 100% rename from Task/GUI-component-interaction/Ada/gui-component-interaction.adb rename to Task/GUI-component-interaction/Ada/gui-component-interaction.ada diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-1.pas b/Task/GUI-component-interaction/Delphi/gui-component-interaction-1.delphi similarity index 100% rename from Task/GUI-component-interaction/Delphi/gui-component-interaction-1.pas rename to Task/GUI-component-interaction/Delphi/gui-component-interaction-1.delphi diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-2.pas b/Task/GUI-component-interaction/Delphi/gui-component-interaction-2.delphi similarity index 100% rename from Task/GUI-component-interaction/Delphi/gui-component-interaction-2.pas rename to Task/GUI-component-interaction/Delphi/gui-component-interaction-2.delphi diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-3.pas b/Task/GUI-component-interaction/Delphi/gui-component-interaction-3.delphi similarity index 100% rename from Task/GUI-component-interaction/Delphi/gui-component-interaction-3.pas rename to Task/GUI-component-interaction/Delphi/gui-component-interaction-3.delphi diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-4.pas b/Task/GUI-component-interaction/Delphi/gui-component-interaction-4.delphi similarity index 100% rename from Task/GUI-component-interaction/Delphi/gui-component-interaction-4.pas rename to Task/GUI-component-interaction/Delphi/gui-component-interaction-4.delphi diff --git a/Task/GUI-component-interaction/Elena/gui-component-interaction-1.elena b/Task/GUI-component-interaction/Elena/gui-component-interaction-1.elena new file mode 100644 index 0000000000..62382c02fc --- /dev/null +++ b/Task/GUI-component-interaction/Elena/gui-component-interaction-1.elena @@ -0,0 +1,57 @@ +import forms; +import extensions; + +public class MainWindow : SDIDialog +{ + Button btmIncrement; + Button btmRandom; + Edit txtNumber; + + constructor new() + <= new() + { + btmIncrement := Button.new(); + btmRandom := Button.new(); + txtNumber := Edit.new(); + + self + .appendControl:btmIncrement + .appendControl:btmRandom + .appendControl:txtNumber; + + self.Caption := "Rosseta Code"; + self.setRegion(100, 100, 160, 120); + + txtNumber.setRegion(7, 7, 140, 25); + txtNumber.Caption := "0"; + + btmIncrement.setRegion(7, 35, 140, 25); + btmIncrement.Caption := "Increment"; + btmIncrement.onClick := (args){ self.onButtonIncrementClick() }; + + btmRandom.setRegion(7, 65, 140, 25); + btmRandom.Caption := "Random"; + btmRandom.onClick := (args){ self.onButtonRandomClick() }; + } + + private onButtonIncrementClick() + { + var number := txtNumber.Value.toInt(); + + number := number + 1; + self.changeTextBoxValue(number) + } + + private onButtonRandomClick() + { + if(messageDialog.showQuestion("Inf", "Really reset to random value?")) + { + self.changeTextBoxValue(randomGenerator.eval(99999999)) + } + } + + private changeTextBoxValue(number) + { + txtNumber.Caption := number.toString() + } +} diff --git a/Task/GUI-component-interaction/Elena/gui-component-interaction-2.elena b/Task/GUI-component-interaction/Elena/gui-component-interaction-2.elena new file mode 100644 index 0000000000..60705accbe --- /dev/null +++ b/Task/GUI-component-interaction/Elena/gui-component-interaction-2.elena @@ -0,0 +1,8 @@ +
+ + + + +
diff --git a/Task/GUI-component-interaction/Elena/gui-component-interaction-3.elena b/Task/GUI-component-interaction/Elena/gui-component-interaction-3.elena new file mode 100644 index 0000000000..baba22a101 --- /dev/null +++ b/Task/GUI-component-interaction/Elena/gui-component-interaction-3.elena @@ -0,0 +1,44 @@ +import xforms; +import forms; +import extensions; + +public class MainWindow +{ + SDIForm form; + + Button btmIncrement; + Button btmRandom; + Edit txtNumber; + + constructor new() + { + form := xforms.executePath("main.xs", self); + + btmIncrement := form.Controls.btmIncrement; + btmRandom := form.Controls.btmRandom; + txtNumber := form.Controls.txtNumber; + } + + onButtonIncrementClick(sender) + { + var number := txtNumber.Value.toInt(); + + number := number + 1; + self.changeTextBoxValue(number) + } + + onButtonRandomClick(sender) + { + if(messageDialog.showQuestion("Inf", "Really reset to random value?")) + { + self.changeTextBoxValue(randomGenerator.eval(99999999)) + } + } + + private changeTextBoxValue(number) + { + txtNumber.Caption := number.toString() + } + + dispatch() => form; +} diff --git a/Task/GUI-component-interaction/Elena/gui-component-interaction.elena b/Task/GUI-component-interaction/Elena/gui-component-interaction.elena deleted file mode 100644 index 774cd067de..0000000000 --- a/Task/GUI-component-interaction/Elena/gui-component-interaction.elena +++ /dev/null @@ -1,57 +0,0 @@ -import forms; -import extensions; - -public class MainWindow : SDIDialog -{ - Button btmIncrement; - Button btmRandom; - Edit txtNumber; - - constructor new() - <= super new() - { - btmIncrement := Button.new(); - btmRandom := Button.new(); - txtNumber := Edit.new(); - - self - .appendControl(btmIncrement) - .appendControl(btmRandom) - .appendControl(txtNumber); - - self.Caption := "Rosseta Code"; - self.setRegion(100, 100, 180, 140); - - txtNumber.setRegion(20, 7, 140, 25); - txtNumber.Caption := "0"; - - btmIncrement.setRegion(20, 35, 140, 25); - btmIncrement.Caption := "Increment"; - btmIncrement.onClick := (args){ self.onButtonIncrementClick() }; - - btmRandom.setRegion(20, 65, 140, 25); - btmRandom.Caption := "Random"; - btmRandom.onClick := (args){ self.onButtonRandomClick() }; - } - - private onButtonIncrementClick() - { - var number := txtNumber.Value.toInt(); - - number := number + 1; - self.changeTextBoxValue(number) - } - - private onButtonRandomClick() - { - if(messageDialog.showQuestion("Inf", "Really reset to random value?")) - { - self.changeTextBoxValue(randomGenerator.nextInt(99999999)) - } - } - - private changeTextBoxValue(number) - { - txtNumber.Caption := number.toString() - } -} diff --git a/Task/GUI-component-interaction/Euphoria/gui-component-interaction.eu b/Task/GUI-component-interaction/Euphoria/gui-component-interaction.euphoria similarity index 100% rename from Task/GUI-component-interaction/Euphoria/gui-component-interaction.eu rename to Task/GUI-component-interaction/Euphoria/gui-component-interaction.euphoria diff --git a/Task/GUI-component-interaction/Forth/gui-component-interaction.fth b/Task/GUI-component-interaction/Forth/gui-component-interaction.fth deleted file mode 100644 index b25d56f2fa..0000000000 --- a/Task/GUI-component-interaction/Forth/gui-component-interaction.fth +++ /dev/null @@ -1,91 +0,0 @@ -\ The following is Forth code using iMops v2.23 -\ Tested on all MacOS from High Sierra to Sonoma -\ using Intel based systems. -\ This code can be used to create a stand-alone application - -: isdigit? ( char -- flag ) \ true if 0 thru 9, false otherwise - 48 58 within? ; - -: >uinteger { addr len \ dec accum -- n t | f } - len NIF exit THEN - 1 -> dec 0 -> accum - len 1+ 1 ?DO - addr len + i - c@ dup isdigit? - IF ( it's a digit 0 thru 9 ) - 48 - dec * accum + -> accum - dec 10 * -> dec - ELSE 2drop false unloop exit - THEN drop - LOOP accum true ; - -SYSCALL rand { -- int } - -:class TextView' super{ TextView } -:m put: ( addr len -- ) - 0 #ofChars: self SetSelect: self - insert: self ;m -;class - -Window+ w - View wview - Button incButton - 100 30 90 20 ( x0 y0 wid hi ) setFrame: incButton - Button randButton - 190 30 70 20 ( x0 y0 wid hi ) setFrame: randButton - TextView' val - 180 100 100 15 setFrame: val - FixedText valLabel - 110 98 80 18 setframe: valLabel - -Window+ okW - view okView - Button yesButton - 100 20 80 18 setframe: yesButton - Button cancelButton - 10 20 80 18 setframe: cancelButton - FixedText okText - 5 40 200 18 setframe: okText - -:noname - getText: val >uinteger - IF 1+ deciNumstr - ELSE " 0" - THEN put: val ; setAction: incButton - -:noname - show: okW ; setAction: randButton - -:noname - rand deciNumstr put: val - show: w ; setAction: yesButton - -:noname - getText: val >uinteger - NIF " 0" put: val - THEN show: w ; setAction: cancelButton - -: main - incButton addview: wview - randButton addview: wview - val addview: wview - valLabel addview: wview - " value:" SetText: valLabel - 300 30 430 230 put: frameRect - frameRect " GUI component interaction" docWindow - wview new: w show: w - " 0" put: val \ must be done after window is new: - " increment" setTitle: incButton - " random" setTitle: randButton - - yesButton addview: okView - cancelButton addview: okView - okText addview: okView - " Set value to random number?" SetText: okText - 310 40 200 60 put: frameRect - frameRect " " noCloseStyle - okView new: okW - " yes" setTitle: yesButton - " cancel" setTitle: cancelButton - ; - -main \ if creating installed app, startup word must be commented out diff --git a/Task/GUI-component-interaction/FuncSug/gui-component-interaction.funcsug b/Task/GUI-component-interaction/FuncSug/gui-component-interaction.funcsug deleted file mode 100644 index 07749f44b1..0000000000 --- a/Task/GUI-component-interaction/FuncSug/gui-component-interaction.funcsug +++ /dev/null @@ -1,26 +0,0 @@ -var numberInput := displayNewElementIn('', 'body', 'input', false) -numberInput.value := 0 -var incButton := displayNewElementIn('Increment', 'body', 'button', false) -var rndButton := displayNewElementIn('Random', 'body', 'button', false) - -parallel: - while true: - awaitDomeventBeep('change', numberInput) - if not (0+1*numberInput.value = 0+1*numberInput.value): - displayNewMessage('Invalid input !') - while true: - awaitClickBeep(incButton) - numberInput.value := 1*numberInput.value + 1 - while true: - awaitClickBeep(rndButton) - var msg := displayNewMessage('Are you sure?') - parallel(select 1) || - ||========= - awaitClickBeep('#yes') - ...-------- - numberInput.value := randomIntBetween(0, 5000) - ||========= - awaitClickBeep('#no') - ...-------- - displayNewMessage('No problem!') - removeElt(msg) diff --git a/Task/GUI-component-interaction/Julia/gui-component-interaction.jl b/Task/GUI-component-interaction/Julia/gui-component-interaction.julia similarity index 100% rename from Task/GUI-component-interaction/Julia/gui-component-interaction.jl rename to Task/GUI-component-interaction/Julia/gui-component-interaction.julia diff --git a/Task/GUI-component-interaction/Kotlin/gui-component-interaction.kts b/Task/GUI-component-interaction/Kotlin/gui-component-interaction.kotlin similarity index 100% rename from Task/GUI-component-interaction/Kotlin/gui-component-interaction.kts rename to Task/GUI-component-interaction/Kotlin/gui-component-interaction.kotlin diff --git a/Task/GUI-component-interaction/Lua/gui-component-interaction.lua b/Task/GUI-component-interaction/Lua/gui-component-interaction.lua deleted file mode 100644 index 531433f70a..0000000000 --- a/Task/GUI-component-interaction/Lua/gui-component-interaction.lua +++ /dev/null @@ -1,25 +0,0 @@ -local ui = require "ui" -math.randomseed(os.time()) - -local win = ui.Window("GUI component interaction", 320, 200) - -local entry = ui.Entry(win, 0, 124, 40) -entry.enabled = false - -ui.Button(win, "Increment", 105, 90).onClick = function (self) - entry.text = entry.text + 1 -end - -ui.Button(win, "Random", 110, 130).onClick = function (self) - if ui.confirm("Set the field to a random number?") == "yes" then - entry.text = math.random(100) - end - -end - -win:show() --- update the user interface until the user closes the Window -repeat - sleep(1) - ui.update() -until not win.visible diff --git a/Task/GUI-component-interaction/PowerShell/gui-component-interaction.ps1 b/Task/GUI-component-interaction/PowerShell/gui-component-interaction.psh similarity index 100% rename from Task/GUI-component-interaction/PowerShell/gui-component-interaction.ps1 rename to Task/GUI-component-interaction/PowerShell/gui-component-interaction.psh diff --git a/Task/GUI-component-interaction/Run-BASIC/gui-component-interaction-2.basic b/Task/GUI-component-interaction/Run-BASIC/gui-component-interaction-2.basic deleted file mode 100644 index 75fa105ed8..0000000000 --- a/Task/GUI-component-interaction/Run-BASIC/gui-component-interaction-2.basic +++ /dev/null @@ -1,32 +0,0 @@ -use eframe::egui; -use rand::Rng; - -fn main() -> Result<(), eframe::Error> { - let options = eframe::NativeOptions { - initial_window_size: Some(egui::vec2(214.0, 100.0)), - ..Default::default() - }; - - // Our application state: - let mut value = "0".to_owned(); - - eframe::run_simple_native("GUI component interaction", options, move |ctx, _frame| { - egui::CentralPanel::default().show(ctx, |ui| { - ui.horizontal(|ui| { - let name_label = ui.label("Value: "); - ui.text_edit_singleline(&mut value) - .labelled_by(name_label.id); - }); - ui.horizontal(|ui| { - if ui.button("Increment").clicked() { - if let Ok(v) = value.parse::() { - value = (v + 1).to_string() - } - } - if ui.button("Random").clicked() { - value = (rand::thread_rng().gen_range(1..=10000)).to_string(); - } - }); - }); - }) -} diff --git a/Task/GUI-component-interaction/Run-BASIC/gui-component-interaction-1.basic b/Task/GUI-component-interaction/Run-BASIC/gui-component-interaction.basic similarity index 100% rename from Task/GUI-component-interaction/Run-BASIC/gui-component-interaction-1.basic rename to Task/GUI-component-interaction/Run-BASIC/gui-component-interaction.basic diff --git a/Task/GUI-component-interaction/V-(Vlang)/gui-component-interaction.v b/Task/GUI-component-interaction/V-(Vlang)/gui-component-interaction.v index cf997efc44..430acc835a 100644 --- a/Task/GUI-component-interaction/V-(Vlang)/gui-component-interaction.v +++ b/Task/GUI-component-interaction/V-(Vlang)/gui-component-interaction.v @@ -7,7 +7,7 @@ const ( win_height = 40 ) -@[heap] +[heap] struct App { mut: window &ui.Window = unsafe {nil} diff --git a/Task/GUI-component-interaction/XPL0/gui-component-interaction.xpl0 b/Task/GUI-component-interaction/XPL0/gui-component-interaction.xpl0 deleted file mode 100644 index 86292ba117..0000000000 --- a/Task/GUI-component-interaction/XPL0/gui-component-interaction.xpl0 +++ /dev/null @@ -1,147 +0,0 @@ -\0123456789012345678901234567 template for display layout -\ Component interaction. X . main window -\ Value: 123456789_ . -\ [Increment] [Random] . -\ Confirm............... X . dialog pop-up -\ Set to a random value? -\ [ Yes ] [ No ] - -include xpllib; \for Ctrl key names, AtoI, ItoA and StrLen -def X0=22, Y0=10; \upper-left corner of main window's position -def X1=X0+21, Y1=Y0+5; \position of dialog pop-up (character cells) -int Mouse, Button, X, Y, Ch, I; \all variables are global for simplicity -def StrMax = 10; \max chars in String including underline -char String(StrMax); \Value string array -int StrInx; \index for character to be added to String - -proc ShowString; \Show Value String -[Attrib($F0); \set black on bright white -Cursor(13+X0, 2+Y0); \move to Value field position -for I:= 0 to StrInx-1 do ChOut(6, String(I)); -ChOut(6, ^_); \show cursor underline at end of String -for I:= StrInx+1 to StrMax-1 do ChOut(6, ^ ); \blank rest of line -]; - -func GetButton; \Return soft button number at mouse pointer -[Mouse:= GetMouse; -X:= Mouse(0)/8 - X0; \convert pixels to 8x16-pixel character cells -Y:= Mouse(1)/16 - Y0; -if X>=24 & X<=26 & Y=0 then return 0; \exit [X] -if X>= 3 & X<=13 & Y=4 then return 1; \Increment -if X>=17 & X<=24 & Y=4 then return 2; \Random -X:= Mouse(0)/8 - X1; \convert pixels to character cells for dialog -Y:= Mouse(1)/16 - Y1; -if X>=24 & X<=26 & Y=0 then return 3; \exit [X] -if X>= 3 & X<=11 & Y=4 then return 4; \Yes -if X>=16 & X<=24 & Y=4 then return 5; \No -return -1; \mouse is not on any soft button -]; - -proc DoDialog; \Do pop-up dialog for further information -[Attrib($70); \set black-on-gray color attribute -SetWind(0+X1, 0+Y1, 27+X1, 5+Y1, 0, \fill\true); \draw gray rectangle -Cursor(25+X1, 0+Y1); ChOut(6, ^X); \draw exit button -Cursor( 3+X1, 2+Y1); Text(6, "Set to a random value?"); -Attrib($80); \set black on dark gray for buttons -Cursor( 3+X1, 4+Y1); Text(6, " Yes "); -Cursor(16+X1, 4+Y1); Text(6, " No "); -Attrib($9F); \set bright white on light blue, for title bar -Cursor(0+X1, 0+Y1); Text(6, " Confirm "); -ShowMouse(true); \turn on mouse pointer -loop [MoveMouse; \make pointer track mouse movements - Mouse:= GetMouse; - if Mouse(2) then \a left or right mouse button is down - [Button:= GetButton; \get soft button at mouse pointer - while Mouse(2) do \wait for mouse button to be released - [MoveMouse; - Mouse:= GetMouse; - ]; - if Button = GetButton then \if down Button = release button - [if Button = 3 then InsertKey(Esc); \insert into keyboard buffer - if Button = 4 then InsertKey(^y); - if Button = 5 then InsertKey(^n); - ]; - ]; - if KeyHit then \key is hit or was inserted in KB buffer - [Ch:= ChIn(1); \get character from non-echoed keyboard - if Ch=^y or Ch=^Y then \set Value to random number - [I:= Ran(1_000_000_000); - ItoA(I, String); - StrInx:= StrLen(String); - quit; - ] - else if Ch=^n or Ch=^N or Ch=Esc then quit; - ]; - ]; \loop -]; - -proc DoMain; \Do main window interaction -[ShowMouse(true); \turn on mouse pointer -loop [MoveMouse; \make pointer track mouse movements - Mouse:= GetMouse; - if Mouse(2) then \a left or right mouse button is down - [Button:= GetButton; \get soft button at mouse pointer - while Mouse(2) do \wait for mouse button to be released - [MoveMouse; - Mouse:= GetMouse; - ]; - if Button = GetButton then \if down Button = release button - [if Button = 0 then InsertKey(Esc); \insert into keyboard buffer - if Button = 1 then InsertKey(^i); - if Button = 2 then InsertKey(^r); - ]; - ]; - if KeyHit then \key is hit or was inserted in KB buffer - [ShowMouse(false); \don't draw on top of mouse pointer - Ch:= ChIn(1); \get character from non-echoed keyboard - if Ch>=$30 & Ch<=$39 then \only allow numeric digits for Value - [if StrInx < StrMax-1 then \limit number of digits added - [String(StrInx):= Ch; - StrInx:= StrInx+1; - \handle leading zeros - convert number to its canonical form - String(StrInx):= 0; \append string terminator for AtoI - I:= AtoI(String); \convert numeric String to an integer - ItoA(I, String); \convert binary integer back to String - StrInx:= StrLen(String); \String could have gotten shorter - ]; - ] - else if Ch = BS then \(backspace) delete back a character - [if StrInx > 0 then StrInx:= StrInx-1] - else if Ch=^i or Ch=^I then \increment Value - [String(StrInx):= 0; \append terminator for AtoI - I:= AtoI(String); - ItoA(I+1, String); - StrInx:= StrLen(String); \String could have gotten longer - if StrInx > StrMax-1 then \roll all 9's to zero - [String(0):= ^0; StrInx:= 1]; - ] - else if Ch=^r or Ch=^R then \random Value - go do dialog pop-up - quit - else if Ch = Esc then - [SetVid(3); exit]; \restore normal text mode before exiting - ShowString; - ShowMouse(true); - ]; - ]; \loop -]; - -[SetVid($12); \set 640x480 graphics mode display -TrapC(true); \prevent Ctrl+C from aborting the program -String(0):= ^0; \initialize Value String to zero -StrInx:= 1; -loop [Attrib($70); \set black-on-gray color attribute - SetWind(0+X0, 0+Y0, 27+X0, 5+Y0, 0, \fill\true); \draw gray rectangle - Cursor(25+X0, 0+Y0); ChOut(6, ^X); \draw exit button - Cursor( 4+X0, 2+Y0); Text(6, "Value:"); - Attrib($80); \set black on dark gray for buttons - Cursor( 3+X0, 4+Y0); Text(6, " Increment "); - Cursor(17+X0, 4+Y0); Text(6, " Random "); - Attrib($9F); \set bright white on light blue for title bar - Cursor(0+X0, 0+Y0); Text(6, " Component interaction "); - ShowString; - DoMain; - DoDialog; - ShowMouse(false); \don't overwrite mouse pointer (with Clear) - Clear; \remove pop-up dialog - ]; \loop back to redraw main window -] diff --git a/Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.adb b/Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.ada similarity index 100% rename from Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.adb rename to Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.ada diff --git a/Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.pas b/Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.delphi similarity index 100% rename from Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.pas rename to Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.delphi diff --git a/Task/GUI-enabling-disabling-of-controls/FuncSug/gui-enabling-disabling-of-controls.funcsug b/Task/GUI-enabling-disabling-of-controls/FuncSug/gui-enabling-disabling-of-controls.funcsug deleted file mode 100644 index 469971e91b..0000000000 --- a/Task/GUI-enabling-disabling-of-controls/FuncSug/gui-enabling-disabling-of-controls.funcsug +++ /dev/null @@ -1,30 +0,0 @@ -var numberInput := displayNewElementIn('', 'body', 'input', false) -var decButton := displayNewElementIn('Decrement', 'body', 'button', false) -var incButton := displayNewElementIn('Increment', 'body', 'button', false) -numberInput.value := 0 -decButton.disabled := true -incButton.disabled := true - -while true: - parallel exitAfter 1 finished: - if numberInput.value = 0: - numberInput.disabled := false - awaitDomeventBeep('change', numberInput) - if not (0+1*numberInput.value = 0+1*numberInput.value): - displayNewMessage('It was an invalid input !') - numberInput.value := 0 - else: - numberInput.disabled := true - awaitForever() - - if numberInput.value > 0: - awaitClickBeep(decButton) - numberInput.value := 1*numberInput.value - 1 - else: - awaitForever() - - if numberInput.value < 10: - awaitClickBeep(incButton) - numberInput.value := 1*numberInput.value + 1 - else: - awaitForever() diff --git a/Task/GUI-enabling-disabling-of-controls/Julia/gui-enabling-disabling-of-controls.jl b/Task/GUI-enabling-disabling-of-controls/Julia/gui-enabling-disabling-of-controls.julia similarity index 100% rename from Task/GUI-enabling-disabling-of-controls/Julia/gui-enabling-disabling-of-controls.jl rename to Task/GUI-enabling-disabling-of-controls/Julia/gui-enabling-disabling-of-controls.julia diff --git a/Task/GUI-enabling-disabling-of-controls/Kotlin/gui-enabling-disabling-of-controls.kts b/Task/GUI-enabling-disabling-of-controls/Kotlin/gui-enabling-disabling-of-controls.kotlin similarity index 100% rename from Task/GUI-enabling-disabling-of-controls/Kotlin/gui-enabling-disabling-of-controls.kts rename to Task/GUI-enabling-disabling-of-controls/Kotlin/gui-enabling-disabling-of-controls.kotlin diff --git a/Task/GUI-enabling-disabling-of-controls/V-(Vlang)/gui-enabling-disabling-of-controls.v b/Task/GUI-enabling-disabling-of-controls/V-(Vlang)/gui-enabling-disabling-of-controls.v index d7e5a54f36..cd260a7e8b 100644 --- a/Task/GUI-enabling-disabling-of-controls/V-(Vlang)/gui-enabling-disabling-of-controls.v +++ b/Task/GUI-enabling-disabling-of-controls/V-(Vlang)/gui-enabling-disabling-of-controls.v @@ -6,7 +6,7 @@ const ( win_height = 40 ) -@[heap] +[heap] struct App { mut: window &ui.Window = unsafe {nil} diff --git a/Task/Galton-box-animation/EasyLang/galton-box-animation.easy b/Task/Galton-box-animation/EasyLang/galton-box-animation.easy deleted file mode 100644 index 0b63337aff..0000000000 --- a/Task/Galton-box-animation/EasyLang/galton-box-animation.easy +++ /dev/null @@ -1,69 +0,0 @@ -sysconf topleft -# -proc drawpins . - for i to 9 : for j to i - gcircle (15 - i) * 3 + j * 6 i * 6 + 2 0.7 - . -. -gcolor 555 -drawpins -gbackground -1 -# -len box[] 10 -len x[] 10 -len y[] 10 -# -proc showbox . - for i to 10 - x = i * 6 + 15 - for j to box[i] - gcircle x 100 - j * 4 + 2 2 - . - . -. -proc init . - for i to 10 - box[i] = 0 - x[i] = 0 - . -. -# -gcolor 543 -on timer - if busy = 0 and random 1 4 = 1 - busy = 1 - for i to 10 : if x[i] = 0 - x[i] = 48 - y[i] = 2 - break 1 - . - else - busy = 0 - . - gclear - showbox - for i to 10 : if x[i] > 0 - x = x[i] - if y[i] <= 56 - y[i] += 2 - if y[i] mod 6 = 2 - x += random 0 1 * 6 - 3 - x[i] = x - . - else - idx = (x - 15) / 6 - y[i] += 4 - if y[i] >= 96 - box[idx] * 4 - x[i] = 0 - box[idx] += 1 - if box[idx] > 10 - init - break 1 - . - . - . - gcircle x y[i] 2 - . - timer 0.1 -. -timer 0 diff --git a/Task/Galton-box-animation/FreeBASIC/galton-box-animation-1.basic b/Task/Galton-box-animation/FreeBASIC/galton-box-animation-1.basic deleted file mode 100644 index 8591593e80..0000000000 --- a/Task/Galton-box-animation/FreeBASIC/galton-box-animation-1.basic +++ /dev/null @@ -1,125 +0,0 @@ -Const boxW As Integer = 41 ' Galton box width -Const boxH As Integer = 37 ' Galton box height -Const pinsBaseW As Integer = 19 ' Pins triangle base -Const nMaxBalls As Integer = 55 ' Number of balls - -Const centerH As Integer = pinsBaseW + (boxW - pinsBaseW * 2 + 1) / 2 - 1 - -Const empty As String = " " -Const ball As String = "o" -Const wall As String = "|" -Const corner As String = "+" -Const floor As String = "-" -Const pin As String = "." - -Type Ball - x As Integer - y As Integer -End Type - -Dim Shared box(boxH - 1, boxW - 1) As String - -Sub initializeBox() - Dim As Integer r, c, nPins - ' Set ceiling and floor - box(0, 0) = corner - box(0, boxW - 1) = corner - For c = 1 To boxW - 2 - box(0, c) = floor - Next - For c = 0 To boxW - 1 - box(boxH - 1, c) = box(0, c) - Next - - ' Set walls - For r = 1 To boxH - 2 - box(r, 0) = wall - box(r, boxW - 1) = wall - Next - - ' Set rest to empty initially - For r = 1 To boxH - 2 - For c = 1 To boxW - 2 - box(r, c) = empty - Next - Next - - ' Set pins - For nPins = 1 To pinsBaseW - For c = 0 To nPins - 1 - box(boxH - 2 - nPins, centerH + 1 - nPins + c * 2) = pin - Next - Next -End Sub - -Sub drawBox() - Dim As Integer r, c - For r = boxH - 1 To 0 Step -1 - For c = 0 To boxW - 1 - Print box(r, c); - Next - Print - Next -End Sub - -Function newBall(x As Integer, y As Integer) As Ball - If box(y, x) <> empty Then - Print "Tried to create a new ball in a non-empty cell. Program terminated." - End - End If - Dim b As Ball - b.x = x - b.y = y - box(y, x) = ball - Return b -End Function - -Sub doStep(b As Ball) - If b.y <= 0 Then - Exit Sub ' Reached the bottom of the box - End If - Dim As String cell = box(b.y - 1, b.x) - Select Case cell - Case empty - box(b.y, b.x) = empty - b.y -= 1 - box(b.y, b.x) = ball - Case pin - box(b.y, b.x) = empty - b.y -= 1 - If box(b.y, b.x - 1) = empty And box(b.y, b.x + 1) = empty Then - b.x += Int(Rnd * 2) * 2 - 1 - box(b.y, b.x) = ball - Exit Sub - Elseif box(b.y, b.x - 1) = empty Then - b.x += 1 - Else - b.x -= 1 - End If - box(b.y, b.x) = ball - Case Else - ' It's frozen - it always piles on other balls - End Select -End Sub - -Dim As Ball balls() -Dim As Integer i, j, ballCount - -initializeBox() -For i = 0 To nMaxBalls + boxH - 1 - Print !"\nStep"; i; ":" - If i < nMaxBalls Then - ballCount += 1 - Redim Preserve balls(ballCount - 1) - balls(ballCount - 1) = newBall(centerH, boxH - 2) ' add ball - End If - drawBox() - - ' Next step for the simulation - ' Frozen balls are kept in balls array for simplicity - For j = 0 To ballCount - 1 - doStep(balls(j)) - Next -Next - -Sleep diff --git a/Task/Galton-box-animation/FreeBASIC/galton-box-animation-2.basic b/Task/Galton-box-animation/FreeBASIC/galton-box-animation-2.basic deleted file mode 100644 index 87ce17fba9..0000000000 --- a/Task/Galton-box-animation/FreeBASIC/galton-box-animation-2.basic +++ /dev/null @@ -1,110 +0,0 @@ -Const pegRadius As Integer = 4 -Const pegSize As Integer = pegRadius * 2 + 1 -Const pegSize2 As Integer = pegSize * 2 -Const delay As Integer = 1 -Dim Shared As Integer alto, ancho, histogramSize, ball - -Sub eventLoop() - Dim As String event - Do - event = Inkey - If event <> "" Then End - Loop Until event = "" -End Sub - -Sub animateActual(x1 As Single, y1 As Single, x2 As Single, y2 As Single, steps As Integer) - Dim As Single x, y, xstep, ystep, lastX, lastY - x = x1 - y = y1 - xstep = (x2 - x1) / steps - ystep = (y2 - y1) / steps - For i As Integer = 1 To steps - lastX = x - lastY = y - Circle (x, y), pegRadius, Rgb(255, 0, 0), , , , F - eventLoop() - Sleep delay - Circle (x, y), pegRadius, Rgb(235, 235, 235), , , , F - eventLoop() - x += xstep - y += ystep - Next -End Sub - -Function drawBall(xpos As Integer, ypos As Integer) As Boolean - Static As Integer ballcounts() - If xpos > Ubound(ballcounts) Then - Redim Preserve ballcounts(xpos) As Integer - End If - ballcounts(xpos) += 1 - animateActual(xpos, ypos, xpos, alto - ballcounts(xpos) * pegSize, 20) - Circle (xpos, alto - ballcounts(xpos) * pegSize), pegRadius, Rgb(255, 0, 0), , , , F - eventLoop() - Return Iif(ballcounts(xpos) <= histogramSize, True, False) -End Function - -Sub animate(x1 As Single, y1 As Single, x2 As Single, y2 As Single) - animateActual(x1, y1, x2, y1, 4) - animateActual(x2, y1, x2, y2, 10) -End Sub - -Function galton(pegRows As Integer) As Integer - Dim As Integer i, xpos, ypos, oldX, oldY - oldX = ancho / 2 - pegSize / 2 - xpos = oldX - oldY = pegSize * 3 - ypos = oldY - animateActual(oldX, 0, xpos, ypos, 10) - For i = 1 To pegRows - If Int(Rnd * 2) Then - xpos += pegSize - Else - xpos -= pegSize - End If - ypos += pegSize2 - animate(oldX, oldY, xpos, ypos) - oldX = xpos - oldY = ypos - Next - Return drawBall(xpos, ypos) -End Function - -Sub setupWindow(numRows As Integer, ballCount As Integer) - Dim As Integer i, j, xpos, ypos - ancho = (2 * numRows + 2) * pegSize + 50 - histogramSize = (ballCount + 2) / 3 - If histogramSize > 500 / pegSize Then histogramSize = 500 / pegSize - alto = ancho + histogramSize * pegSize + 50 - Screenres ancho, alto, 32 - Windowtitle "Galton box" - Line (0, 0) - Step(ancho, alto), Rgb(235, 235, 235), BF - For i = 1 To numRows - ypos = i * pegSize2 + pegSize * 2 - xpos = ancho / 2 - (i - 1) * pegSize - pegSize / 2 - For j = 1 To i - Circle (xpos, ypos), pegRadius, Rgb(0, 0, 139), , , , F - xpos += pegSize2 - Next - Next - For i As Integer = 1 To numRows - Line ((numRows - i + 1) * pegSize2 - pegSize / 2 + 24, alto - pegSize - histogramSize * pegSize) - Step(1, histogramSize * pegSize), Rgb(0, 0, 0) - Next -End Sub - -Dim pegRows As Integer = 10 -Dim ballCount As Integer -Do - Input "How many balls to drop? ", ballCount -Loop Until ballCount > 0 - -Randomize Timer -setupWindow(pegRows, ballCount) -eventLoop() -For ball = 1 To ballCount - If Not galton(pegRows) Then Exit For -Next - -Color Rgb(255, 0, 0), Rgb(235, 235, 235) -Print Spc(5); "Ended after "; Str(ball-1); " balls" - -Do: eventLoop(): Loop diff --git a/Task/Galton-box-animation/Julia/galton-box-animation.jl b/Task/Galton-box-animation/Julia/galton-box-animation.julia similarity index 100% rename from Task/Galton-box-animation/Julia/galton-box-animation.jl rename to Task/Galton-box-animation/Julia/galton-box-animation.julia diff --git a/Task/Galton-box-animation/Kotlin/galton-box-animation.kts b/Task/Galton-box-animation/Kotlin/galton-box-animation.kotlin similarity index 100% rename from Task/Galton-box-animation/Kotlin/galton-box-animation.kts rename to Task/Galton-box-animation/Kotlin/galton-box-animation.kotlin diff --git a/Task/Galton-box-animation/V-(Vlang)/galton-box-animation.v b/Task/Galton-box-animation/V-(Vlang)/galton-box-animation.v deleted file mode 100644 index 9ce6b7100e..0000000000 --- a/Task/Galton-box-animation/V-(Vlang)/galton-box-animation.v +++ /dev/null @@ -1,124 +0,0 @@ -import rand - -enum Cell { - empty - ball - wall - corner - floor - pin -} - -const cell_chars = { - Cell.empty: ` ` - Cell.ball: `o` - Cell.wall: `|` - Cell.corner: `+` - Cell.floor: `-` - Cell.pin: `.` -} - -struct Ball { - mut: - x int - y int - box &GaltonBox -} - -fn (mut b Ball) do_step() { - if b.y <= 0 { return } - cell := b.box.box[b.y - 1][b.x] - match cell { - .empty { - b.box.box[b.y][b.x] = .empty - b.y-- - b.box.box[b.y][b.x] = .ball - } - .pin { - b.box.box[b.y][b.x] = .empty - b.y-- - left_empty := b.box.box[b.y][b.x - 1] == .empty - right_empty := b.box.box[b.y][b.x + 1] == .empty - if left_empty && right_empty { - ran := rand.intn(2) or {0} - if ran == 0 { b.x-- } - else { b.x++ } - b.box.box[b.y][b.x] = .ball - return - } - else if left_empty { b.x-- } - else { b.x++ } - b.box.box[b.y][b.x] = .ball - } - else {} // do nothing - } -} - -struct GaltonBox { - box_w int = 41 - box_h int = 37 - pins_base_w int = 19 - n_max_balls int = 55 - center_h int - mut: - box [][]Cell - rand_seed int -} - -fn new_galton_box() &GaltonBox { - mut gb := &GaltonBox{ - center_h: 19 + (41 - 19 * 2 + 1) / 2 - 1 - } - gb.box = [][]Cell{len: gb.box_h, init: []Cell{len: gb.box_w, init: .empty}} - return gb -} - -fn (mut gb GaltonBox) initialize_box() { - gb.box[0][0] = .corner - gb.box[0][gb.box_w - 1] = .corner - for i := 1; i < gb.box_w - 1; i++ { - gb.box[0][i] = .floor - } - for i := 0; i < gb.box_w; i++ { - gb.box[gb.box_h - 1][i] = gb.box[0][i] - } - for r := 1; r < gb.box_h - 1; r++ { - gb.box[r][0] = .wall - gb.box[r][gb.box_w - 1] = .wall - } - for n_pins := 1; n_pins <= gb.pins_base_w; n_pins++ { - for pin := 0; pin < n_pins; pin++ { - gb.box[gb.box_h - 2 - n_pins][gb.center_h + 1 - n_pins + pin * 2] = .pin - } - } -} - -fn (gb &GaltonBox) draw_box() { - for row in gb.box.reverse() { - for cell in row { - print(cell_chars[cell]) - } - println("") - } -} - -fn main() { - mut balls := []Ball{} - mut gb := new_galton_box() - gb.initialize_box() - for i in 0 .. gb.n_max_balls + gb.box_h { - println("\nStep $i:") - if i < gb.n_max_balls { - balls << Ball{ - x: gb.center_h - y: gb.box_h - 2 - box: gb - } - gb.box[gb.box_h - 2][gb.center_h] = .ball - } - gb.draw_box() - for mut b in balls { - b.do_step() - } - } -} diff --git a/Task/Galton-box-animation/Wren/galton-box-animation.wren b/Task/Galton-box-animation/Wren/galton-box-animation.wren index ced4534f33..377d53bddf 100644 --- a/Task/Galton-box-animation/Wren/galton-box-animation.wren +++ b/Task/Galton-box-animation/Wren/galton-box-animation.wren @@ -1,5 +1,5 @@ import "random" for Random -import "./iterate" for Reversed +import "/iterate" for Reversed var boxW = 41 // Galton box width. var boxH = 37 // Galton box height. diff --git a/Task/Galton-box-animation/Zig/galton-box-animation.zig b/Task/Galton-box-animation/Zig/galton-box-animation.zig index e231702ade..24301bb178 100644 --- a/Task/Galton-box-animation/Zig/galton-box-animation.zig +++ b/Task/Galton-box-animation/Zig/galton-box-animation.zig @@ -17,7 +17,7 @@ fn boardSize(comptime peg_lines: u16) u16 { const BOARD_SIZE = boardSize(PEG_LINES); fn stepBoard(board: *[BOARD_SIZE]u1, count: *[PEG_LINES + 1]u8) void { - var prng = rand.DefaultPrng.init(@bitCast(time.timestamp())); + var prng = rand.DefaultPrng.init(@bitCast(u64, time.timestamp())); var p: u8 = 0; var sum: u16 = 0; diff --git a/Task/Gamma-function/Ada/gamma-function-1.adb b/Task/Gamma-function/Ada/gamma-function-1.ada similarity index 100% rename from Task/Gamma-function/Ada/gamma-function-1.adb rename to Task/Gamma-function/Ada/gamma-function-1.ada diff --git a/Task/Gamma-function/Ada/gamma-function-2.adb b/Task/Gamma-function/Ada/gamma-function-2.ada similarity index 100% rename from Task/Gamma-function/Ada/gamma-function-2.adb rename to Task/Gamma-function/Ada/gamma-function-2.ada diff --git a/Task/Gamma-function/Agena/gamma-function.agena b/Task/Gamma-function/Agena/gamma-function.agena deleted file mode 100644 index 16fc9718ce..0000000000 --- a/Task/Gamma-function/Agena/gamma-function.agena +++ /dev/null @@ -1,26 +0,0 @@ -# Gamma function - -proc ln_gamma(z :: number) :: number is - lz := reg(1.00000000019001, 76.1800917294715, -86.5053203294168, 24.0140982408309, -1.23173957245015, 0.0012086509738662, -0.000005395239385); - if z < 0.5 then - return ln(Pi / sin(Pi * z)) - ln_gamma(1.0 - z) - else - z -:= 1.0; - b := z + 5.5; - a := lz[1]; - for i from 2 to 7 do - a +:= lz[i] / (z + i - 1) - od; - return (ln(sqrt(2 * Pi)) + ln(a) - b) + ln(b) * (z + 0.5) - fi -end; - -proc gamma(z :: number) :: number is - return exp(ln_gamma(z)); -end; - -scope - for x from 0.1 to 2.05 by 0.1 do - printf("%3.1f\t%15.12f\n", x, gamma(x)) - od -epocs diff --git a/Task/Gamma-function/Arturo/gamma-function.arturo b/Task/Gamma-function/Arturo/gamma-function.arturo index e66f990867..4c0e16a2ef 100644 --- a/Task/Gamma-function/Arturo/gamma-function.arturo +++ b/Task/Gamma-function/Arturo/gamma-function.arturo @@ -20,17 +20,13 @@ ourGamma: function [x][ return result ] -print repeat "-" 100 - loop 1..10 'z [ v1: ourGamma z // 3 v2: gamma z // 3 print [ - pad (to :string z)++" =>" 6 + pad (to :string z)++" =>" 10 pad (to :string v1)++" ~" 30 pad (to :string v2)++" :" 30 pad (to :string v1-v2) 30 ] ] - -print repeat "-" 100 diff --git a/Task/Gamma-function/Crystal/gamma-function.cr b/Task/Gamma-function/Crystal/gamma-function.crystal similarity index 100% rename from Task/Gamma-function/Crystal/gamma-function.cr rename to Task/Gamma-function/Crystal/gamma-function.crystal diff --git a/Task/Gamma-function/Delphi/gamma-function.pas b/Task/Gamma-function/Delphi/gamma-function.delphi similarity index 100% rename from Task/Gamma-function/Delphi/gamma-function.pas rename to Task/Gamma-function/Delphi/gamma-function.delphi diff --git a/Task/Gamma-function/DuckDB/gamma-function.duckdb b/Task/Gamma-function/DuckDB/gamma-function.duckdb deleted file mode 100644 index 7bad150095..0000000000 --- a/Task/Gamma-function/DuckDB/gamma-function.duckdb +++ /dev/null @@ -1,30 +0,0 @@ -create or replace function gamma_taylor(x) as ( - select gamma - from ( select [ - 1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108, -0.04200263503409523553, - 0.16653861138229148950, -0.04219773455554433675, -0.00962197152787697356, 0.00721894324666309954, - -0.00116516759185906511, -0.00021524167411495097, 0.00012805028238811619, -0.00002013485478078824, - -0.00000125049348214267, 0.00000113302723198170, -0.00000020563384169776, 0.00000000611609510448, - 0.00000000500200764447, -0.00000000118127457049, 0.00000000010434267117, 0.00000000000778226344, - -0.00000000000369680562, 0.00000000000051003703, -0.00000000000002058326, -0.00000000000000534812, - 0.00000000000000122678, -0.00000000000000011813, 0.00000000000000000119, 0.00000000000000000141, - -0.00000000000000000023, 0.00000000000000000002 - ] as a, - length(a) as n, - (with recursive cte as ( - select 2 as an, a[n] as acc - union all - select an+1 as an, - (acc * (x-1)) + a[1 + n-an] as acc - from cte - where an <= n - ) - select 1 / last(acc order by an) from cte) as gamma - ) - limit 1 -); - -## Comparison -select x, gamma, taylor, 2 * @(gamma-taylor)/(gamma+taylor) as "%" -from (select x, gamma(x) as gamma, gamma_taylor(x) as taylor - from (select x/3 as x from range(1,11) t(x))) ; diff --git a/Task/Gamma-function/EMal/gamma-function.emal b/Task/Gamma-function/EMal/gamma-function.emal deleted file mode 100644 index b97e5e94c7..0000000000 --- a/Task/Gamma-function/EMal/gamma-function.emal +++ /dev/null @@ -1,19 +0,0 @@ -fun stirling ← 0.5 then gma(z) else pi / sin(pi * z) / gma(1.0 - z) - -fun main() - println("z\tLanczos\t\t\tStirling\t\tStirling2") - for(1, 20) fn(i) - val z = i.float64 / 10.0 - println(z.show(1) ++ "\t" ++ mirror(gamma-lanczos, z).show ++ "\t" ++ - mirror(gamma-stirling, z).show ++ "\t" ++ mirror(gamma-stirling2, z).show) - for(1, 7) fn(i) - val z = 10.0 * i.float64 - println(z.show ++ "\t" ++ gamma-lanczos(z).show ++ "\t" ++ - gamma-stirling(z).show ++ "\t" ++ gamma-stirling2(z).show) diff --git a/Task/Gamma-function/Kotlin/gamma-function.kts b/Task/Gamma-function/Kotlin/gamma-function.kotlin similarity index 100% rename from Task/Gamma-function/Kotlin/gamma-function.kts rename to Task/Gamma-function/Kotlin/gamma-function.kotlin diff --git a/Task/Gamma-function/Loglan82/gamma-function.loglan82 b/Task/Gamma-function/Loglan82/gamma-function.loglan82 deleted file mode 100644 index 27b4e2a096..0000000000 --- a/Task/Gamma-function/Loglan82/gamma-function.loglan82 +++ /dev/null @@ -1,53 +0,0 @@ -(* Gamma function *) -(* Lanczos approximation *) - -block -var - x: real; - - unit gamma: function (z: real): real; - const - pi = 3.14159265358979; - var - lz: arrayof real; - - unit ln_gamma: function (z: real): real; - (* Uses lz and pi *) - var - i: integer, - b, a: real; - begin - if z < 0.5 then - result := ln(pi / sin(pi * z)) - ln_gamma(1.0 - z) - else - z := z - 1.0; - b := z + 5.5; - a := lz(0); - for i:= 1 to 6 - do - a:= a + lz(i) / (z + i) - od; - result := (ln(sqrt(2.0 * pi)) + ln(a) - b) + ln(b) * (z + 0.5) - fi; - end ln_gamma; - - begin - array lz dim (0 : 6); - lz(0) := 1.00000000019001; - lz(1) := 76.1800917294715; - lz(2) := -86.5053203294168; - lz(3) := 24.0140982408309; - lz(4) := -1.23173957245015; - lz(5) := 1.2086509738662E-3; - lz(6) := -0.000005395239385; - result := exp(ln_gamma(z)) - end gamma; - -begin - x:= 0.1; - while x < 2.05 - do - writeln(x: 4: 1, " ", gamma(x): 15: 12); - x:= x + 0.1 - od; -end diff --git a/Task/Gamma-function/Modula-2/gamma-function.mod2 b/Task/Gamma-function/Modula-2/gamma-function.mod2 deleted file mode 100644 index 82195b4967..0000000000 --- a/Task/Gamma-function/Modula-2/gamma-function.mod2 +++ /dev/null @@ -1,55 +0,0 @@ -MODULE GammaFun; -(* Gamma function *) -(* Lanczos approximation *) -FROM LongMath IMPORT - exp, ln, pi, sin, sqrt; -FROM SLongIO IMPORT - WriteFixed; -FROM STextIO IMPORT - WriteLn, WriteString; - -VAR - X: LONGREAL; - -PROCEDURE Gamma(Z: LONGREAL): LONGREAL; -TYPE - LZArr = ARRAY [0 .. 6] OF LONGREAL; -VAR - LZ: LZArr; - - PROCEDURE LnGamma(Z: LONGREAL): LONGREAL; - (* Uses LZ *) - VAR - B, A: LONGREAL; - I: CARDINAL; - BEGIN - IF Z < 0.5 THEN - RETURN ln(pi / sin(pi * Z)) - LnGamma(1.0 - Z) - ELSE - Z:= Z - 1.0; - B:= Z + 5.5; - A:= LZ[0]; - FOR I:= 1 TO 6 DO - A:= A + LZ[I] / (Z + LFLOAT(I)) - END; - RETURN (ln(sqrt(2. * pi)) + ln(A) - B) + ln(B) * (Z + 0.5) - END; - END LnGamma; - -BEGIN - LZ:= LZArr{1.00000000019001, 76.1800917294715, -86.5053203294168, - 24.0140982408309, -1.23173957245015, 1.2086509738662E-3, - -0.000005395239385}; - RETURN exp(LnGamma(Z)) -END Gamma; - -BEGIN - X:= 0.1; - WHILE X < 2.05 DO - WriteFixed(X, 1, 4); - WriteString(" "); - WriteFixed(Gamma(X), 12, 15); - WriteLn; - X:= X + 0.1 - END; -END GammaFun. diff --git a/Task/Gamma-function/OCaml/gamma-function.ml b/Task/Gamma-function/OCaml/gamma-function.ocaml similarity index 100% rename from Task/Gamma-function/OCaml/gamma-function.ml rename to Task/Gamma-function/OCaml/gamma-function.ocaml diff --git a/Task/Gamma-function/PHP/gamma-function.php b/Task/Gamma-function/PHP/gamma-function.php deleted file mode 100644 index 22f01f3084..0000000000 --- a/Task/Gamma-function/PHP/gamma-function.php +++ /dev/null @@ -1,28 +0,0 @@ - diff --git a/Task/Gamma-function/Pascal-P/gamma-function.pas b/Task/Gamma-function/Pascal-P/gamma-function.pas deleted file mode 100644 index 06aaf5ff4c..0000000000 --- a/Task/Gamma-function/Pascal-P/gamma-function.pas +++ /dev/null @@ -1,48 +0,0 @@ -program gammafunction(output); -(* Gamma function *) - -const - pi = 3.1415926535897932384626433832795; - -var - x: real; - - function lngamma(z: real): real; - var - lz: array[0..6] of real; - a, b: real; - i: integer; - begin - lz[0] := 1.00000000019001; - lz[1] := 76.1800917294715; - lz[2] := -86.5053203294168; - lz[3] := 24.0140982408309; - lz[4] := -1.23173957245015; - lz[5] := 0.0012086509738662; - lz[6] := -0.000005395239385; - if (z < 0.5) then - lngamma := ln(pi / sin(pi * z)) - lngamma(1.0 - z) - else - begin - z := z - 1.0; - b := z + 5.5; - a := lz[0]; - for i := 1 to 6 do - a := a + lz[i] / (z + i); - lngamma := (ln(sqrt(2 * pi)) + ln(a) - b) + ln(b) * (z + 0.5); - end; - end; - - function gamma(z: real): real; - begin - gamma := exp(lngamma(z)); - end; - -begin - x := 0.1; - while x <= 2.05 do - begin - writeln(x, ' ', gamma(x)); - x := x + 0.1; - end; -end. diff --git a/Task/Gamma-function/Free-Pascal-Lazarus/gamma-function.pas b/Task/Gamma-function/Pascal/gamma-function.pas similarity index 100% rename from Task/Gamma-function/Free-Pascal-Lazarus/gamma-function.pas rename to Task/Gamma-function/Pascal/gamma-function.pas diff --git a/Task/Gamma-function/PascalABC.NET/gamma-function.pas b/Task/Gamma-function/PascalABC.NET/gamma-function.pas deleted file mode 100644 index 5c189dbe31..0000000000 --- a/Task/Gamma-function/PascalABC.NET/gamma-function.pas +++ /dev/null @@ -1,28 +0,0 @@ -const - g = 7; - p: array of real = - (0.99999999999980993, 676.5203681218851, -1259.1392167224028, - 771.32342877765313, -176.61502916214059, 12.507343278686905, - -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7); - -function Gamma(z: Complex): Complex; -begin - if (z.Real < 0.5) then - begin - result := pi / (Sin(pi * z) * Gamma(1 - z)); - exit; - end - else - begin - z -= 1; - var x: Complex := p[0]; - for var i := 1 to g + 1 do x += p[i] / (z + i); - var t := z + g + 0.5; - result := Sqrt(2 * pi) * (Power(t, z + 0.5)) * Exp(-t) * x; - end; -end; - -begin - writeln('z Lanczos'); - for var i := 1 to 10 do writeln(i / 3:6:4, gamma(i / 3):25); -end. diff --git a/Task/Gamma-function/Phix/gamma-function-1.phix b/Task/Gamma-function/Phix/gamma-function-1.phix index c4df9b0873..7a31179bd9 100644 --- a/Task/Gamma-function/Phix/gamma-function-1.phix +++ b/Task/Gamma-function/Phix/gamma-function-1.phix @@ -1,114 +1,116 @@ -with javascript_semantics -sequence c = repeat(0,12) -function spouge_gamma(atom z) - atom accm = c[1] - if accm=0 then - accm = sqrt(2*PI) - c[1] = accm - atom k1_factrl = 1 -- (k - 1)!*(-1)^k with 0!==1 - for k=2 to 12 do - c[k] = exp(13-k)*power(13-k,k-1.5)/k1_factrl - k1_factrl *= -(k-1) - end for - end if - for k=2 to 12 do - accm += c[k]/(z+k-1) - end for - accm *= exp(-(z+12))*power(z+12,z+0.5) -- Gamma(z+1) - return accm/z -end function +(phixonline)--> + with javascript_semantics + sequence c = repeat(0,12) + function spouge_gamma(atom z) + atom accm = c[1] + if accm=0 then + accm = sqrt(2*PI) + c[1] = accm + atom k1_factrl = 1 -- (k - 1)!*(-1)^k with 0!==1 + for k=2 to 12 do + c[k] = exp(13-k)*power(13-k,k-1.5)/k1_factrl + k1_factrl *= -(k-1) + end for + end if + for k=2 to 12 do + accm += c[k]/(z+k-1) + end for + accm *= exp(-(z+12))*power(z+12,z+0.5) -- Gamma(z+1) + return accm/z + end function -function taylor_gamma(atom x) --- (good for values between 0 and 1, apparently) - constant t = { 1.00000_00000_00000_00000, - 0.57721_56649_01532_86061, - -0.65587_80715_20253_88108, - -0.04200_26350_34095_23553, - 0.16653_86113_82291_48950, - -0.04219_77345_55544_33675, - -0.00962_19715_27876_97356, - 0.00721_89432_46663_09954, - -0.00116_51675_91859_06511, - -0.00021_52416_74114_95097, - 0.00012_80502_82388_11619, - -0.00002_01348_54780_78824, - -0.00000_12504_93482_14267, - 0.00000_11330_27231_98170, - -0.00000_02056_33841_69776, - 0.00000_00061_16095_10448, - 0.00000_00050_02007_64447, - -0.00000_00011_81274_57049, - 0.00000_00001_04342_67117, - 0.00000_00000_07782_26344, - -0.00000_00000_03696_80562, - 0.00000_00000_00510_03703, - -0.00000_00000_00020_58326, - -0.00000_00000_00005_34812, - 0.00000_00000_00001_22678, - -0.00000_00000_00000_11813, - 0.00000_00000_00000_00119, - 0.00000_00000_00000_00141, - -0.00000_00000_00000_00023, - 0.00000_00000_00000_00002 } - atom y = x-1, - s = t[$] - for n=length(t)-1 to 1 by -1 do - s = s*y + t[n] - end for - return 1/s -end function + function taylor_gamma(atom x) + -- (good for values between 0 and 1, apparently) + constant t = { 1.00000_00000_00000_00000, + 0.57721_56649_01532_86061, + -0.65587_80715_20253_88108, + -0.04200_26350_34095_23553, + 0.16653_86113_82291_48950, + -0.04219_77345_55544_33675, + -0.00962_19715_27876_97356, + 0.00721_89432_46663_09954, + -0.00116_51675_91859_06511, + -0.00021_52416_74114_95097, + 0.00012_80502_82388_11619, + -0.00002_01348_54780_78824, + -0.00000_12504_93482_14267, + 0.00000_11330_27231_98170, + -0.00000_02056_33841_69776, + 0.00000_00061_16095_10448, + 0.00000_00050_02007_64447, + -0.00000_00011_81274_57049, + 0.00000_00001_04342_67117, + 0.00000_00000_07782_26344, + -0.00000_00000_03696_80562, + 0.00000_00000_00510_03703, + -0.00000_00000_00020_58326, + -0.00000_00000_00005_34812, + 0.00000_00000_00001_22678, + -0.00000_00000_00000_11813, + 0.00000_00000_00000_00119, + 0.00000_00000_00000_00141, + -0.00000_00000_00000_00023, + 0.00000_00000_00000_00002 } + atom y = x-1, + s = t[$] + for n=length(t)-1 to 1 by -1 do + s = s*y + t[n] + end for + return 1/s + end function -function lanczos_gamma(atom z) - if z<0.5 then - return PI / (sin(PI*z)*lanczos_gamma(1-z)) - end if - -- use a lanczos approximation: - atom x = 0.99999999999980993, - t = z + 6.5; - sequence p = { 676.5203681218851, - -1259.1392167224028, - 771.32342877765313, - -176.61502916214059, - 12.507343278686905, - -0.13857109526572012, - 9.9843695780195716e-6, - 1.5056327351493116e-7 } - z -= 1 - for i=1 to length(p) do - x += p[i] / (z + i) - end for - return sqrt(2*PI) * power(t,z+0.5) * exp(-t) * x -end function + function lanczos_gamma(atom z) + if z<0.5 then + return PI / (sin(PI*z)*lanczos_gamma(1-z)) + end if + -- use a lanczos approximation: + atom x = 0.99999999999980993, + t = z + 6.5; + sequence p = { 676.5203681218851, + -1259.1392167224028, + 771.32342877765313, + -176.61502916214059, + 12.507343278686905, + -0.13857109526572012, + 9.9843695780195716e-6, + 1.5056327351493116e-7 } + z -= 1 + for i=1 to length(p) do + x += p[i] / (z + i) + end for + return sqrt(2*PI) * power(t,z+0.5) * exp(-t) * x + end function -constant sqPI = sqrt(PI) + constant sqPI = sqrt(PI) -procedure sq(sequence zm, string fmt="%19.16f") - atom {z, mul} = zm - atom e = sqPI/mul - sequence s = {spouge_gamma(z), - taylor_gamma(z), - lanczos_gamma(z)}, - error = sq_abs(sq_sub(s,e)) - string t = join(s,", ",fmt:=fmt)&", " - integer bdx = smallest(error,return_index:=true) - atom best = s[bdx], - p = s[bdx]*mul - for i=1 to length(s) do -- (potentially mark >1) - if s[i]=best then - t[i*22-2..i*22-1] = "*," - end if - end for - string es = sprintf(fmt,e) - printf(1,"%5g: %s %s, %19.16f\n",{z,t,es,p*p}) -end procedure + procedure sq(sequence zm, string fmt="%19.16f") + atom {z, mul} = zm + atom e = sqPI/mul + sequence s = {spouge_gamma(z), + taylor_gamma(z), + lanczos_gamma(z)}, + error = sq_abs(sq_sub(s,e)) + string t = join(s,", ",fmt:=fmt)&", " + integer bdx = smallest(error,return_index:=true) + atom best = s[bdx], + p = s[bdx]*mul + for i=1 to length(s) do -- (potentially mark >1) + if s[i]=best then + t[i*22-2..i*22-1] = "*," + end if + end for + string es = sprintf(fmt,e) + printf(1,"%5g: %s %s, %19.16f\n",{z,t,es,p*p}) + end procedure -printf(1," z ------ spouge ----- ----- taylor ------ ----- lanczos ----- ---- expected ----- %19.16f\n",PI) -papply({{-3/2,3/4},{-1/2,-1/2},{1/2,1},{1,sqPI},{3/2,2},{2,sqPI},{5/2,4/3},{3,sqPI/2},{7/2,8/15},{4,sqPI/6}},sq) -sq({0.001,sqPI/999.4237725},"%19.15f") -sq({0.01,sqPI/99.43258512},"%19.16f") -sq({0.1,sqPI/9.513507699},"%19.16f") -sq({10,sqPI/362880},"%19.12f") -sq({100,sqPI/9.332621544e155},"%19.13g") -if machine_bits()=64 then - sq({150,sqPI/3.808922638e260},"%19.13g") -- (fatal power overflow error on 32 bits) -end if + printf(1," z ------ spouge ----- ----- taylor ------ ----- lanczos ----- ---- expected ----- %19.16f\n",PI) + papply({{-3/2,3/4},{-1/2,-1/2},{1/2,1},{1,sqPI},{3/2,2},{2,sqPI},{5/2,4/3},{3,sqPI/2},{7/2,8/15},{4,sqPI/6}},sq) + sq({0.001,sqPI/999.4237725},"%19.15f") + sq({0.01,sqPI/99.43258512},"%19.16f") + sq({0.1,sqPI/9.513507699},"%19.16f") + sq({10,sqPI/362880},"%19.12f") + sq({100,sqPI/9.332621544e155},"%19.13g") + if machine_bits()=64 then + sq({150,sqPI/3.808922638e260},"%19.13g") -- (fatal power overflow error on 32 bits) + end if + + without javascript_semantics -- (no mpfr_exp(), mpfr_gamma() in pwa/p2js) + constant dp = 30 + string fmt = "%5s: %33s, %33s, %32s\n" + requires("1.0.2") -- (mpfr_get_fixed(maxlen), mpfr_gamma) + include mpfr.e + mpfr_set_default_precision(-87) -- 87 decimal places. + sequence mc = mpfr_inits(40) -function mpfr_spouge_gamma(mpfr z) - mpfr accm = mc[1] - if mpfr_cmp_si(accm,0)=0 then - -- mc[1] := sqrt(2*PI) - mpfr_const_pi(accm) - mpfr_mul_si(accm,accm,2) - mpfr_sqrt(accm,accm) - -- k1_factrl = (k - 1)!*(-1)^k with 0!==1 - mpfr k1_factrl = mpfr_init(1), - tmk = mpfr_init(), - p = mpfr_init() - for k=2 to length(mc) do - -- mc[k] = exp(13-k)*power(13-k,k-1.5)/k1_factrl - mpfr_set_si(tmk,length(mc)+1-k) - mpfr_exp(mc[k],tmk) - mpfr_set_d(p,k-1.5) - mpfr_pow(p,tmk,p) - mpfr_div(p,p,k1_factrl) - mpfr_mul(mc[k],mc[k],p) - -- k1_factrl *= -(k-1) - mpfr_mul_si(k1_factrl,k1_factrl,-(k-1)) - end for - end if - accm = mpfr_init_set(accm) - for k=2 to length(mc) do - -- accm += mc[k]/(z+k-1) - mpfr ck = mpfr_init_set(mc[k]), - zk = mpfr_init_set(z) - mpfr_add_si(zk,zk,k-1) - mpfr_div(ck,ck,zk) - mpfr_add(accm,accm,ck) - end for - -- atom zc = z+length(mc) - -- accm *= exp(-zc)*power(zc,z+0.5) -- Gamma(z+1) - mpfr p = mpfr_init_set(z), - ez = mpfr_init(), - zh = mpfr_init(0.5) - mpfr_add_si(p,p,length(mc)) - mpfr_neg(ez,p) - mpfr_exp(ez,ez) - mpfr_add(zh,zh,z) - mpfr_pow(p,p,zh) - mpfr_mul(accm,accm,ez) - mpfr_mul(accm,accm,p) - -- return accm/z - mpfr_div(accm,accm,z) - return accm -end function + function mpfr_spouge_gamma(mpfr z) + mpfr accm = mc[1] + if mpfr_cmp_si(accm,0)=0 then + -- mc[1] := sqrt(2*PI) + mpfr_const_pi(accm) + mpfr_mul_si(accm,accm,2) + mpfr_sqrt(accm,accm) + -- k1_factrl = (k - 1)!*(-1)^k with 0!==1 + mpfr k1_factrl = mpfr_init(1), + tmk = mpfr_init(), + p = mpfr_init() + for k=2 to length(mc) do + -- mc[k] = exp(13-k)*power(13-k,k-1.5)/k1_factrl + mpfr_set_si(tmk,length(mc)+1-k) + mpfr_exp(mc[k],tmk) + mpfr_set_d(p,k-1.5) + mpfr_pow(p,tmk,p) + mpfr_div(p,p,k1_factrl) + mpfr_mul(mc[k],mc[k],p) + -- k1_factrl *= -(k-1) + mpfr_mul_si(k1_factrl,k1_factrl,-(k-1)) + end for + end if + accm = mpfr_init_set(accm) + for k=2 to length(mc) do + -- accm += mc[k]/(z+k-1) + mpfr ck = mpfr_init_set(mc[k]), + zk = mpfr_init_set(z) + mpfr_add_si(zk,zk,k-1) + mpfr_div(ck,ck,zk) + mpfr_add(accm,accm,ck) + end for + -- atom zc = z+length(mc) + -- accm *= exp(-zc)*power(zc,z+0.5) -- Gamma(z+1) + mpfr p = mpfr_init_set(z), + ez = mpfr_init(), + zh = mpfr_init(0.5) + mpfr_add_si(p,p,length(mc)) + mpfr_neg(ez,p) + mpfr_exp(ez,ez) + mpfr_add(zh,zh,z) + mpfr_pow(p,p,zh) + mpfr_mul(accm,accm,ez) + mpfr_mul(accm,accm,p) + -- return accm/z + mpfr_div(accm,accm,z) + return accm + end function -constant mPI = mpfr_init(), - mqPI = mpfr_init() -mpfr_const_pi(mPI) -string pistr = mpfr_get_fixed(mPI,dp) -mpfr_sqrt(mqPI,mPI) + constant mPI = mpfr_init(), + mqPI = mpfr_init() + mpfr_const_pi(mPI) + string pistr = mpfr_get_fixed(mPI,dp) + mpfr_sqrt(mqPI,mPI) -function makempfr(object x) - mpfr res - if string(x) then - x = split(x,'/') - res = mpfr_init(x[1]) - mpfr_div_si(res,res,to_integer(x[2])) - elsif sequence(x) then - {mpfr x1, object x2} = x - res = mpfr_init_set(x1) - if string(x2) then - mpfr d = mpfr_init(x2) - mpfr_div(res,res,d) - else - mpfr_div_d(res,res,x2) - end if - else - res = mpfr_init(x) - end if - return res -end function + function makempfr(object x) + mpfr res + if string(x) then + x = split(x,'/') + res = mpfr_init(x[1]) + mpfr_div_si(res,res,to_integer(x[2])) + elsif sequence(x) then + {mpfr x1, object x2} = x + res = mpfr_init_set(x1) + if string(x2) then + mpfr d = mpfr_init(x2) + mpfr_div(res,res,d) + else + mpfr_div_d(res,res,x2) + end if + else + res = mpfr_init(x) + end if + return res + end function -procedure mq(sequence zm, integer d=dp) - mpfr {z, mul} = apply(zm,makempfr) - mpfr s = mpfr_spouge_gamma(z) - string t = mpfr_get_fixed(s,d,10,maxlen:=dp+2) - mpfr e = mpfr_init() - mpfr_gamma(e,z) - mpfr p = mpfr_init_set(s) - mpfr_mul(p,p,mul) - mpfr_mul(p,p,p) - string zs = mpfr_get_fixed(z,3), - es = mpfr_get_fixed(e,d,10,maxlen:=dp+2), - ps = mpfr_get_fixed(p,dp,10) - printf(1,fmt,{zs,t,es,ps}) -end procedure + procedure mq(sequence zm, integer d=dp) + mpfr {z, mul} = apply(zm,makempfr) + mpfr s = mpfr_spouge_gamma(z) + string t = mpfr_get_fixed(s,d,10,maxlen:=dp+2) + mpfr e = mpfr_init() + mpfr_gamma(e,z) + mpfr p = mpfr_init_set(s) + mpfr_mul(p,p,mul) + mpfr_mul(p,p,p) + string zs = mpfr_get_fixed(z,3), + es = mpfr_get_fixed(e,d,10,maxlen:=dp+2), + ps = mpfr_get_fixed(p,dp,10) + printf(1,fmt,{zs,t,es,ps}) + end procedure -printf(1," z %s %s %s\n",{pad(" spouge ",dp+2,"BOTH",'-'),pad(" expected ",dp+2,"BOTH",'-'),pistr}) -papply({{-1.5,0.75},{-0.5,-0.5},{0.5,1},{1,{mqPI,1}},{1.5,2},{2,{mqPI,1}},{2.5,"4/3"},{3,{mqPI,2}},{3.5,"8/15"},{4,{mqPI,6}}},mq) -mq({"1/1000",{mqPI,"999.4237724845954661149822012996"}},28) -mq({"1/100",{mqPI,"99.43258511915060371353298887051"}},29) -mq({"1/10",{mqPI,"9.513507698668731836292487177265"}},30) -mq({10,{mqPI,362880}},25) -mq({100,{mqPI,"9.332621544394415268169923885627e155"}},0) -mq({150,{mqPI,"3.80892263763056972698595524350735e260"}},0) + printf(1," z %s %s %s\n",{pad(" spouge ",dp+2,"BOTH",'-'),pad(" expected ",dp+2,"BOTH",'-'),pistr}) + papply({{-1.5,0.75},{-0.5,-0.5},{0.5,1},{1,{mqPI,1}},{1.5,2},{2,{mqPI,1}},{2.5,"4/3"},{3,{mqPI,2}},{3.5,"8/15"},{4,{mqPI,6}}},mq) + mq({"1/1000",{mqPI,"999.4237724845954661149822012996"}},28) + mq({"1/100",{mqPI,"99.43258511915060371353298887051"}},29) + mq({"1/10",{mqPI,"9.513507698668731836292487177265"}},30) + mq({10,{mqPI,362880}},25) + mq({100,{mqPI,"9.332621544394415268169923885627e155"}},0) + mq({150,{mqPI,"3.80892263763056972698595524350735e260"}},0) + + constant starts = {1e2, 1e6, 1e7, 1e9, 7123}, + counts = {30, 15, 15, 10, 25} + for i=1 to length(starts) do + integer count = counts[i], + j = starts[i], + pow = 100 + while j>=pow*10 do pow *= 10 end while + printf(1,"First %d gapful numbers starting at %,d: ", {count, j}) + while count do + integer fl = floor(j/pow)*10 + remainder(j,10) + if remainder(j,fl)==0 then + printf(1,"%d ", j) + count -= 1 + end if + j += 1 + if j>=10*pow then + pow *= 10 + end if + end while + printf(1,"\n") + end for + iterator +fcn gapfulW(start){ //--> iterator [start..].tweak( fcn(n){ if(n % (10*n.toString()[0] + n%10)) Void.Skip else n }) } diff --git a/Task/Gauss-Jordan-matrix-inversion/11l/gauss-jordan-matrix-inversion.11l b/Task/Gauss-Jordan-matrix-inversion/11l/gauss-jordan-matrix-inversion.11l index dd47e5cdf5..61eb3e830c 100644 --- a/Task/Gauss-Jordan-matrix-inversion/11l/gauss-jordan-matrix-inversion.11l +++ b/Task/Gauss-Jordan-matrix-inversion/11l/gauss-jordan-matrix-inversion.11l @@ -43,7 +43,7 @@ F inverse(mat) L(i) 0 .< mat.len L(j) 0 .< mat.len I augmat[i][j] != Float(i == j) - X.throw ValueError(‘matrix is singular’) + X ValueError(‘matrix is singular’) result[i][j] = augmat[i][mat.len + j] R result diff --git a/Task/Gauss-Jordan-matrix-inversion/ALGOL-68/gauss-jordan-matrix-inversion.alg b/Task/Gauss-Jordan-matrix-inversion/ALGOL-68/gauss-jordan-matrix-inversion.alg index 14b3603189..2b79d01805 100644 --- a/Task/Gauss-Jordan-matrix-inversion/ALGOL-68/gauss-jordan-matrix-inversion.alg +++ b/Task/Gauss-Jordan-matrix-inversion/ALGOL-68/gauss-jordan-matrix-inversion.alg @@ -43,17 +43,16 @@ BEGIN # Gauss-Jordan matrix inversion # OD END # show #; - BEGIN # test # - [ 1 : 4, 1 : 4 ]REAL a, b, c; - a := [,]REAL( ( 2, 1, 1, 4 ) - , ( 0, -1, 0, -1 ) - , ( 1, 0, -2, 4 ) - , ( 4, 1, 2, 2 ) - ); - show( "a", a ); - b := inverse( a ); - show( "b", b ); - c := inverse( b ); - show( "c", c ) - END + INT n = 4; + [ 1 : n, 1 : n ]REAL a, b, c; + a := [,]REAL( ( 2, 1, 1, 4 ) + , ( 0, -1, 0, -1 ) + , ( 1, 0, -2, 4 ) + , ( 4, 1, 2, 2 ) + ); + show( "a", a ); + b := inverse( a ); + show( "b", b ); + c := inverse( b ); + show( "c", c ) END diff --git a/Task/Gauss-Jordan-matrix-inversion/Agena/gauss-jordan-matrix-inversion.agena b/Task/Gauss-Jordan-matrix-inversion/Agena/gauss-jordan-matrix-inversion.agena deleted file mode 100644 index 34361a3d27..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/Agena/gauss-jordan-matrix-inversion.agena +++ /dev/null @@ -1,81 +0,0 @@ -scope # Gauss Jordan Matrix inversion - translation of the EasyLang sample - - local proc rref( m :: sequence ) - local nrow, ncol, lead := size m, size m[1], 1; - for r to nrow do - if lead > ncol then return fi; - local i := r; - while m[i][lead] = 0 do - i +:= 1; - if i > nrow then - i, lead := r, lead + 1 - if lead > ncol then return fi - fi - od; - m[i], m[r] := m[r], m[i]; - scope - local constant mrl := m[r][lead] - for k to ncol do m[r][k] /:= mrl od - end - for i to nrow do - if i <> r then - local constant mil := m[i][lead]; - for k to ncol do - m[i][k] -:= ( mil * m[r][k] ) - od - fi - od; - lead +:= 1 - od - end - local proc inverse( mat :: sequence ) :: sequence - local inv, mln, aug := seq(), size mat, seq(); - for i to mln do - if size mat[i] <> mln then - error( "not a square matrix" ) - fi; - aug[ size aug + 1 ] := seq(); - for j to mln do aug[i][j] := mat[i][j] od; - for j from mln + 1 to 2 * mln do aug[i][j] := 0 od; - aug[i][mln + i] := 1 - od; - rref( aug ); - for i to mln do - inv[ size inv + 1 ] := seq(); - for j from mln + 1 to 2 * mln do - inv[i][ size inv[i] + 1 ] := aug[i][j] - od - od; - return inv - end - local proc integerMatrix( m :: sequence ) :: boolean - for i to size m do - for j to size m[ i ] do - if entier m[ i ][ j ] <> m[ i ][ j ] then return false fi - od - od; - return true - end - local proc printMatrix( m :: sequence ) - local allInteger := integerMatrix( m ) - for i to size m do - printf( if i = 1 then "[ [" else " [" fi ); - for j to size m[ i ] do - printf( if allInteger then " %9d" else " %9.6f" fi, m[ i ][ j ] ) - od; - printf( " ]\n" ) - od; - printf( "]\n" ) - end - local proc testInverse( m :: sequence ) - printf( "Matrix:\n" ); - printMatrix( m ); - printf( "Inverse:\n" ); - printMatrix( inverse( m ) ); - printf( "\n" ) - end - - testInverse( seq( (/ 1, 2, 3 \), (/ 4, 1, 6 \), (/ 7, 8, 9 \) ) ); - testInverse( seq( (/ 2, -1, 0 \), (/ -1, 2, -1 \), (/ 0, -1, 2 \) ) ); - testInverse( seq( (/ -1, -2, 3, 2 \), (/ -4, -1, 6, 2 \), (/ 7, -8, 9, 1 \), (/ 1, -2, 1, 3 \) ) ) -end diff --git a/Task/Gauss-Jordan-matrix-inversion/EasyLang/gauss-jordan-matrix-inversion.easy b/Task/Gauss-Jordan-matrix-inversion/EasyLang/gauss-jordan-matrix-inversion.easy deleted file mode 100644 index 3027f65812..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/EasyLang/gauss-jordan-matrix-inversion.easy +++ /dev/null @@ -1,51 +0,0 @@ -proc rref &m[][] . - nrow = len m[][] - ncol = len m[1][] - lead = 1 - for r to nrow - if lead > ncol : return - i = r - while m[i][lead] = 0 - i += 1 - if i > nrow - i = r - lead += 1 - if lead > ncol : return - . - . - swap m[i][] m[r][] - m = m[r][lead] - for k to ncol : m[r][k] /= m - for i to nrow - if i <> r - m = m[i][lead] - for k to ncol : m[i][k] -= m * m[r][k] - . - . - lead += 1 - . -. -proc inverse &mat[][] &inv[][] . - inv[][] = [ ] - ln = len mat[][] - for i to ln - if len mat[i][] <> ln - # not a square matrix - return - . - aug[][] &= [ ] - len aug[i][] 2 * ln - for j to ln : aug[i][j] = mat[i][j] - aug[i][ln + i] = 1 - . - rref aug[][] - for i to ln - inv[][] &= [ ] - for j = ln + 1 to 2 * ln - inv[i][] &= aug[i][j] - . - . -. -test[][] = [ [ 1 2 3 ] [ 4 1 6 ] [ 7 8 9 ] ] -inverse test[][] inv[][] -print inv[][] diff --git a/Task/Gauss-Jordan-matrix-inversion/Free-Pascal-Lazarus/gauss-jordan-matrix-inversion.pas b/Task/Gauss-Jordan-matrix-inversion/Free-Pascal-Lazarus/gauss-jordan-matrix-inversion.pas deleted file mode 100644 index 59906999af..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/Free-Pascal-Lazarus/gauss-jordan-matrix-inversion.pas +++ /dev/null @@ -1,120 +0,0 @@ -program MatrixInverse; -{$mode ObjFPC}{$H+} - -const - MATRIX_1: array of array of Real = ((1, 2, 3), - (4, 1, 6), - (7, 8, 9)); - - MATRIX_2: array of array of Real = ((3.0, 1.0, 5.0, 9.0, 7.0), - (8.0, 2.0, 8.0, 0.0, 1.0), - (1.0, 7.0, 2.0, 0.0, 3.0), - (0.0, 1.0, 7.0, 0.0, 9.0), - (3.0, 5.0, 6.0, 1.0, 1.0)); - -type - Matrix = array of array of Real; - -function PopulateMatrix(A: Matrix; Order: Integer): Matrix; -var - i, j: Integer; -begin - SetLength(Result, Succ(Order), Succ(Order * 2)); - for i := 0 to Pred(Order) do - for j := 0 to Pred(Order) do - Result[i + 1, j + 1] := A[i, j]; -end; - -procedure PrintMatrix(const A: Matrix); -var - i, j, Order: Integer; -begin - Order := Length(A); - for i := 0 to Pred(Order) do - begin - for j := 0 to Pred(Order) do - Write(A[i, j]:8:4); - WriteLn; - end; - WriteLn; -end; - -procedure InterchangeRows(var A: Matrix; Order: Integer; Row1, Row2: Integer); -var - j: Integer; - temp: Real; -begin - for j := 1 to 2 * Order do - begin - temp := A[Row1, j]; - A[Row1, j] := A[Row2, j]; - A[Row2, j] := temp; - end; -end; - -procedure DivideRow(var A: Matrix; Order: Integer; Row: Integer; Divisor: Real); -var - j: Integer; -begin - for j := 1 to 2 * Order do - A[Row, j] := A[Row, j] / Divisor; -end; - -procedure SubtractRows(var A: Matrix; Order: Integer; Row1, Row2: Integer; Multiplier: Real); -var - j: Integer; -begin - for j := 1 to 2 * Order do - A[Row1, j] := A[Row1, j] - Multiplier * A[Row2, j]; -end; - -function GaussJordan(B: Matrix): Matrix; -var - i, j, Order: Integer; - Pivot, Multiplier: Real; - A: Matrix; -begin - Order := Length(B); - SetLength(Result, Order, Order); - A := PopulateMatrix(B, Order); - - // Create the augmented matrix - for i := 1 to Order do - for j := Order + 1 to 2 * Order do - if j = (i + Order) then - A[i, j] := 1; - - // Interchange rows if needed - for i := Order downto 2 do - if A[i - 1, 1] < A[i, 1] then - InterchangeRows(A, Order, i - 1, i); - - // Perform Gauss-Jordan elimination - for i := 1 to Order do - begin - Pivot := A[i, i]; - DivideRow(A, Order, i, Pivot); - for j := 1 to Order do - if j <> i then - begin - Multiplier := A[j, i]; - SubtractRows(A, Order, j, i, Multiplier); - end; - end; - - for i := 0 to Pred(Order) do - for j := 0 to Pred(Order) do - Result[i, j] := A[Succ(i), Succ(j) + Order]; -end; - -begin - writeln('== Original Matrix =='); - PrintMatrix(MATRIX_1); - writeln('== Inverse Matrix =='); - PrintMatrix(GaussJordan(MATRIX_1)); - - writeln('== Original Matrix =='); - PrintMatrix(MATRIX_2); - writeln('== Inverse Matrix =='); - PrintMatrix(GaussJordan(MATRIX_2)); -end. diff --git a/Task/Gauss-Jordan-matrix-inversion/JavaScript/gauss-jordan-matrix-inversion.js b/Task/Gauss-Jordan-matrix-inversion/JavaScript/gauss-jordan-matrix-inversion.js deleted file mode 100644 index 854bc332e7..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/JavaScript/gauss-jordan-matrix-inversion.js +++ /dev/null @@ -1,99 +0,0 @@ -// Vector and matrix types -// In JavaScript, we'll use arrays directly - -function printMatrix(matrix, title) { - console.log(title); - for (const row of matrix) { - console.log(row.map(x => x.toString().padStart(10)).join('')); - } -} - -function createIdentityMatrix(n) { - const result = Array(n).fill().map(() => Array(n).fill(0)); - for (let i = 0; i < n; i++) { - result[i][i] = 1; - } - return result; -} - -function inverse(matrix) { - const n = matrix.length; - - // Check if it's a square matrix - for (const row of matrix) { - if (row.length !== n) { - throw new Error("Not a square matrix"); - } - } - - // Create identity matrix for the result - const b = createIdentityMatrix(n); - - // Create a copy of the input matrix - const a = matrix.map(row => [...row]); - - for (let k = 0; k < n; k++) { - let iMax = 0; - let max = -1; - - for (let i = k; i < n; i++) { - const row = a[i]; - - // Compute scale factor s = max abs in row - let s = -1; - for (let j = k; j < n; j++) { - const x = Math.abs(row[j]); - if (x > s) { - s = x; - } - } - - if (s === 0) { - throw new Error("Irregular matrix"); - } - - // Scale the abs used to pick the pivot - const abs = Math.abs(row[k]) / s; - if (abs > max) { - iMax = i; - max = abs; - } - } - - // Swap rows if needed - if (k !== iMax) { - [a[k], a[iMax]] = [a[iMax], a[k]]; - [b[k], b[iMax]] = [b[iMax], b[k]]; - } - - const akk = a[k][k]; - - for (let j = 0; j < n; j++) { - a[k][j] /= akk; - b[k][j] /= akk; - } - - for (let i = 0; i < n; i++) { - if (i !== k) { - const aik = a[i][k]; - for (let j = 0; j < n; j++) { - a[i][j] -= a[k][j] * aik; - b[i][j] -= b[k][j] * aik; - } - } - } - } - - return b; -} - -function main() { - const a = [[1, 2, 3], [4, 1, 6], [7, 8, 9]]; - printMatrix(inverse(a), "Inverse of A is:\n"); - - const b = [[2, -1, 0], [-1, 2, -1], [0, -1, 2]]; - printMatrix(inverse(b), "Inverse of B is:\n"); -} - -// Run the main function -main(); diff --git a/Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-1.jl b/Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-1.julia similarity index 100% rename from Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-1.jl rename to Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-1.julia diff --git a/Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-2.jl b/Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-2.julia similarity index 100% rename from Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-2.jl rename to Task/Gauss-Jordan-matrix-inversion/Julia/gauss-jordan-matrix-inversion-2.julia diff --git a/Task/Gauss-Jordan-matrix-inversion/Kotlin/gauss-jordan-matrix-inversion.kts b/Task/Gauss-Jordan-matrix-inversion/Kotlin/gauss-jordan-matrix-inversion.kotlin similarity index 100% rename from Task/Gauss-Jordan-matrix-inversion/Kotlin/gauss-jordan-matrix-inversion.kts rename to Task/Gauss-Jordan-matrix-inversion/Kotlin/gauss-jordan-matrix-inversion.kotlin diff --git a/Task/Gauss-Jordan-matrix-inversion/Lua/gauss-jordan-matrix-inversion.lua b/Task/Gauss-Jordan-matrix-inversion/Lua/gauss-jordan-matrix-inversion.lua deleted file mode 100644 index 6eb7628293..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/Lua/gauss-jordan-matrix-inversion.lua +++ /dev/null @@ -1,81 +0,0 @@ -do -- Gauss Jordan Matrix inversion - translation of the EasyLang sample - - local function rref( m ) - local nrow, ncol, lead = # m, # m[1], 1 - for r = 1, nrow do - if lead > ncol then return end - local i = r - while m[i][lead] == 0 do - i = i + 1 - if i > nrow then - i, lead = r, lead + 1 - if lead > ncol then return end - end - end - m[i], m[r] = m[r], m[i] - do - local mrl = m[r][lead] - for k = 1, ncol do m[r][k] = m[r][k] / mrl end - end - for i = 1, nrow do - if i ~= r then - local mil = m[i][lead] - for k = 1, ncol do - m[i][k] = m[i][k] - ( mil * m[r][k] ) - end - end - end - lead = lead + 1 - end - end - local function inverse( mat ) - local inv, ln, aug = {}, # mat, {} - for i = 1, ln do - if # mat[i] ~= ln then - error( "not a square matrix" ) - end - aug[ # aug + 1 ] = {} - for j = 1, ln do aug[i][j] = mat[i][j] end - for j = ln + 1, 2 * ln do aug[i][j] = 0 end - aug[i][ln + i] = 1 - end - rref( aug ) - for i = 1, ln do - inv[ # inv + 1 ] = {} - for j = ln + 1, 2 * ln do - inv[i][ # inv[i] + 1 ] = aug[i][j] - end - end - return inv - end - local function integerMatrix( m ) - for i = 1, # m do - for j = 1, # m[ i ] do - if math.type( m[ i ][ j ] ) ~= "integer" then return false end - end - end - return true - end - local function printMatrix( m ) - local allInteger = integerMatrix( m ) - for i = 1, # m do - io.write( i == 1 and "[ [" or " [" ) - for j = 1, # m[ i ] do - io.write( string.format( ( allInteger and " %9d" or " %9.6f" ), m[ i ][ j ] ) ) - end - io.write( " ]\n" ) - end - io.write( "]\n" ) - end - local function testInverse( m ) - io.write( "Matrix:\n" ) - printMatrix( m ) - io.write( "Inverse:\n" ) - printMatrix( inverse( m ) ) - io.write( "\n" ) - end - - testInverse { { 1, 2, 3 }, { 4, 1, 6 }, { 7, 8, 9 } } - testInverse { { 2, -1, 0 }, {-1, 2, -1 }, { 0, -1, 2 } } - testInverse { { -1, -2, 3, 2 }, { -4, -1, 6, 2 }, { 7, -8, 9, 1 }, { 1, -2, 1, 3 } } -end diff --git a/Task/Gauss-Jordan-matrix-inversion/PascalABC.NET/gauss-jordan-matrix-inversion.pas b/Task/Gauss-Jordan-matrix-inversion/PascalABC.NET/gauss-jordan-matrix-inversion.pas deleted file mode 100644 index 3c25363004..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/PascalABC.NET/gauss-jordan-matrix-inversion.pas +++ /dev/null @@ -1,9 +0,0 @@ -uses NumLibABC; - -begin - var A := new Matrix(3,3,1,2,3,4,1,6,7,8,9); - 'Original:'.Println; - A.Println(10,5); - 'Inverse:'.Println; - A.Inv.Println(10,5); -end. diff --git a/Task/Gauss-Jordan-matrix-inversion/Perl/gauss-jordan-matrix-inversion.pl b/Task/Gauss-Jordan-matrix-inversion/Perl/gauss-jordan-matrix-inversion.pl index 2102119749..5fa185e871 100644 --- a/Task/Gauss-Jordan-matrix-inversion/Perl/gauss-jordan-matrix-inversion.pl +++ b/Task/Gauss-Jordan-matrix-inversion/Perl/gauss-jordan-matrix-inversion.pl @@ -61,5 +61,5 @@ for my $matrix (@tests) { my @gj = gauss_jordan_invert( @$matrix ); print "Gauss-Jordan Inverted Matrix:\n" . display(\@gj) . "\n"; my @rt = gauss_jordan_invert( @gj ); - print "After round-trip:\n" . display(\@rt) . "\n"; + print "After round-trip:\n" . display(\@rt) . "\n";} . "\n" } diff --git a/Task/Gauss-Jordan-matrix-inversion/Pluto/gauss-jordan-matrix-inversion.pluto b/Task/Gauss-Jordan-matrix-inversion/Pluto/gauss-jordan-matrix-inversion.pluto deleted file mode 100644 index 103fcf3988..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/Pluto/gauss-jordan-matrix-inversion.pluto +++ /dev/null @@ -1,25 +0,0 @@ -require "matrix" - -local arrays = { - { { 1, 2, 3 }, - { 4, 1, 6 }, - { 7, 8, 9 } }, - - { { 2, -1, 0 }, - {-1, 2, -1 }, - { 0, -1, 2 } }, - - { { -1, -2, 3, 2 }, - { -4, -1, 6, 2 }, - { 7, -8, 9, 1 }, - { 1, -2, 1, 3 } } -} - -for arrays as array do - print("Original:\n") - local m = matrix.from(array) - print(m) - print("\nInverse:\n") - print(m:inverse():format("%9.6f")) - print() -end diff --git a/Task/Gauss-Jordan-matrix-inversion/PowerShell/gauss-jordan-matrix-inversion.ps1 b/Task/Gauss-Jordan-matrix-inversion/PowerShell/gauss-jordan-matrix-inversion.psh similarity index 100% rename from Task/Gauss-Jordan-matrix-inversion/PowerShell/gauss-jordan-matrix-inversion.ps1 rename to Task/Gauss-Jordan-matrix-inversion/PowerShell/gauss-jordan-matrix-inversion.psh diff --git a/Task/Gauss-Jordan-matrix-inversion/R/gauss-jordan-matrix-inversion.r b/Task/Gauss-Jordan-matrix-inversion/R/gauss-jordan-matrix-inversion.r deleted file mode 100644 index 6f636d34ed..0000000000 --- a/Task/Gauss-Jordan-matrix-inversion/R/gauss-jordan-matrix-inversion.r +++ /dev/null @@ -1,91 +0,0 @@ -gaussjordan <- function(A) { - # Check if matrix is square - if (nrow(A) != ncol(A)) { - stop("A must be a square matrix") - } - - n <- nrow(A) - - # Create augmented matrix [A | I] - M <- cbind(matrix(as.numeric(A), nrow = n, ncol = n), diag(n)) - - tmp <- numeric(2 * n) - i <- 1 - - # Forward elimination - while (i <= n) { - # Check if pivot is approximately zero - if (abs(M[i, i]) < 1e-10) { - j <- i + 1 - # Find non-zero pivot - while (j <= n && abs(M[j, i]) < 1e-10) { - j <- j + 1 - } - if (j <= n) { - # Swap rows - tmp <- M[i, ] - M[i, ] <- M[j, ] - M[j, ] <- tmp - } else { - stop("Matrix is singular, cannot compute the inverse") - } - } - - # Eliminate below pivot - if (i < n) { - for (j in (i + 1):n) { - M[j, ] <- M[j, ] - (M[j, i] / M[i, i]) * M[i, ] - } - } - i <- i + 1 - } - - i <- n - - # Backward elimination - while (i >= 1) { - # Check if pivot is approximately zero - if (abs(M[i, i]) < 1e-10) { - j <- i - 1 - # Find non-zero pivot - while (j >= 1 && abs(M[j, i]) < 1e-10) { - j <- j - 1 - } - if (j >= 1) { - # Swap rows - tmp <- M[i, ] - M[i, ] <- M[j, ] - M[j, ] <- tmp - } else { - stop("Matrix is singular, cannot compute the inverse") - } - } - - # Eliminate above pivot - if (i > 1) { - for (j in (i - 1):1) { - M[j, ] <- M[j, ] - (M[j, i] / M[i, i]) * M[i, ] - } - } - i <- i - 1 - } - - # Normalize by diagonal elements - M <- M / diag(M) - - # Return the inverse (right half of augmented matrix) - return(M[, (n + 1):(2 * n)]) -} - -# Test examples -# Example 1: Create a test matrix -A <- matrix(c(4, 3, 2, 1), nrow = 2, ncol = 2) -print(gaussjordan(A)) -print(solve(A)) # R's built-in inverse function - -# Example 2: Random matrix test -set.seed(123) -A <- matrix(runif(100), nrow = 10, ncol = 10) -result <- gaussjordan(A) -expected <- solve(A) -print(all.equal(result, expected)) # Should return TRUE diff --git a/Task/Gauss-Jordan-matrix-inversion/REXX/gauss-jordan-matrix-inversion-2.rexx b/Task/Gauss-Jordan-matrix-inversion/REXX/gauss-jordan-matrix-inversion-2.rexx index 475332d230..f2202efef4 100644 --- a/Task/Gauss-Jordan-matrix-inversion/REXX/gauss-jordan-matrix-inversion-2.rexx +++ b/Task/Gauss-Jordan-matrix-inversion/REXX/gauss-jordan-matrix-inversion-2.rexx @@ -1,64 +1,35 @@ -/*REXX program performs a (square) matrix inversion using the Gauss-Jordan method. */ -data=8 3 7 5 9 12 10 11 6 2 4 13 14 15 16 17 /*the matrix element values. */ -Call build 4 /*assign data elements to the matrix. */ -Call show 'M','The matrix of order' n 'is:' /*display the (square) matrix. */ -Call aux /*define the auxiliary (identity) array*/ -Call invert /*invert the matrix, store result in X.*/ -Call show 'X','The inverted matrix is:' /*display inverted matrix. */ -Exit /*stick a fork in it, we're all done. */ -/*----------------------------------------------------------------------------------*/ -aux: - x.=0 - Do i=1 To n - x.i.i=1 - End - Return -/*----------------------------------------------------------------------------------*/ -build: /*set m.r.c from data */ - Arg n - k=0 - w=0 /*W: max width of a number*/ - Do r=1 To n /*loop over rows */ - Do c=1 To n /*loop over columns */ - k=k+1 - m.r.c=word(data,k) - w=max(w,length(m.r.c)) - End /*c*/ - End /*r*/ - Return -/*----------------------------------------------------------------------------------*/ -invert: - Do k=1 To n - t=m.k.k /*divide each matrix row by T */ - Do c=1 To n - m.k.c=m.k.c/t /*process row of original matrix.*/ - x.k.c=x.k.c/t /* ' ' ' auxiliary ' */ - End /*c*/ - Do r=1 To n - If r<>k Then Do /*skip if R is the same row as K.*/ - t=m.r.k - Do c=1 To n - m.r.c=m.r.c-t*m.k.c /*process row of original matrix.*/ - x.r.c=x.r.c-t*x.k.c /* ' ' ' auxiliary ' */ - End /*c*/ - End - End /*r*/ - End /*k*/ - Return -/*-----------------------------------------------------------------------------------*/ -show: - Parse Arg which,title - Say - Say title - f=4 /*F: fractional digits precision.*/ - Do r=1 To n - line='' - Do c=1 To n - If which=='M' Then - line=line right(m.r.c,w) - Else - line=line right(format(x.r.c,w,f),w+f+1) - End /*c*/ - Say line - End /*r*/ - Return +/*REXX program performs a (square) matrix inversion using the Gauss─Jordan method. */ +data= 8 3 7 5 9 12 10 11 6 2 4 13 14 15 16 17 /*the matrix element values. */ +call build 4 /*assign data elements to the matrix. */ +call show '@', 'The matrix of order ' n " is:" /*display the (square) matrix. */ +call aux /*define the auxiliary (identity) array*/ +call invert /*invert the matrix, store result in X.*/ +call show 'X', "The inverted matrix is:" /*display (inverted) auxiliary matrix. */ +exit 0 /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +aux: x.= 0; do i=1 for n; x.i.i= 1; end; return +/*──────────────────────────────────────────────────────────────────────────────────────*/ +build: arg n; #=0; w=0; do r=1 for n /*read a row of the matrix.*/ + do c=1 for n; #= # + 1 /* " " col " " " */ + @.r.c= word(data, #); w= max(w, length(@.r.c) ) + end /*c*/ /*W: max width of a number*/ + end /*r*/; return +/*──────────────────────────────────────────────────────────────────────────────────────*/ +invert: do k=1 for n; t= @.k.k /*divide each matrix row by T. */ + do c=1 for n; @.k.c= @.k.c / t /*process row of original matrix.*/ + x.k.c= x.k.c / t /* " " " auxiliary " */ + end /*c*/ + do r=1 for n; if r==k then iterate /*skip if R is the same row as K.*/ + t= @.r.k + do c=1 for n; @.r.c= @.r.c - t*@.k.c /*process row of original matrix.*/ + x.r.c= x.r.c - t*x.k.c /* " " " auxiliary " */ + end /*c*/ + end /*r*/ + end /*k*/; return +/*──────────────────────────────────────────────────────────────────────────────────────*/ +show: parse arg ?, title; say; say title; f= 4 /*F: fractional digits precision.*/ + do r=1 for n; _= + do c=1 for n; if ?=='@' then _= _ right( @.r.c, w) + else _= _ right(format(x.r.c, w, f), w + f + length(.)) + end /*c*/; say _ + end /*r*/; return diff --git a/Task/Gauss-Jordan-matrix-inversion/Rust/gauss-jordan-matrix-inversion.rs b/Task/Gauss-Jordan-matrix-inversion/Rust/gauss-jordan-matrix-inversion.rust similarity index 100% rename from Task/Gauss-Jordan-matrix-inversion/Rust/gauss-jordan-matrix-inversion.rs rename to Task/Gauss-Jordan-matrix-inversion/Rust/gauss-jordan-matrix-inversion.rust diff --git a/Task/Gauss-Jordan-matrix-inversion/VBScript/gauss-jordan-matrix-inversion.vbs b/Task/Gauss-Jordan-matrix-inversion/VBScript/gauss-jordan-matrix-inversion.vb similarity index 100% rename from Task/Gauss-Jordan-matrix-inversion/VBScript/gauss-jordan-matrix-inversion.vbs rename to Task/Gauss-Jordan-matrix-inversion/VBScript/gauss-jordan-matrix-inversion.vb diff --git a/Task/Gauss-Jordan-matrix-inversion/Wren/gauss-jordan-matrix-inversion.wren b/Task/Gauss-Jordan-matrix-inversion/Wren/gauss-jordan-matrix-inversion.wren index 17eee5a2d8..93e3476431 100644 --- a/Task/Gauss-Jordan-matrix-inversion/Wren/gauss-jordan-matrix-inversion.wren +++ b/Task/Gauss-Jordan-matrix-inversion/Wren/gauss-jordan-matrix-inversion.wren @@ -1,5 +1,5 @@ -import "./matrix" for Matrix -import "./fmt" for Fmt +import "/matrix" for Matrix +import "/fmt" for Fmt var arrays = [ [ [ 1, 2, 3], diff --git a/Task/Gaussian-elimination/Ada/gaussian-elimination.adb b/Task/Gaussian-elimination/Ada/gaussian-elimination.ada similarity index 100% rename from Task/Gaussian-elimination/Ada/gaussian-elimination.adb rename to Task/Gaussian-elimination/Ada/gaussian-elimination.ada diff --git a/Task/Gaussian-elimination/Delphi/gaussian-elimination.pas b/Task/Gaussian-elimination/Delphi/gaussian-elimination.delphi similarity index 100% rename from Task/Gaussian-elimination/Delphi/gaussian-elimination.pas rename to Task/Gaussian-elimination/Delphi/gaussian-elimination.delphi diff --git a/Task/Gaussian-elimination/EasyLang/gaussian-elimination.easy b/Task/Gaussian-elimination/EasyLang/gaussian-elimination.easy deleted file mode 100644 index 84676232a4..0000000000 --- a/Task/Gaussian-elimination/EasyLang/gaussian-elimination.easy +++ /dev/null @@ -1,45 +0,0 @@ -func[] gauss_elim a[][] b[] . - n = len a[][] - for i to n - maxr = i - maxv = abs a[i][i] - for j = i + 1 to n - if abs a[j][i] > maxv - maxr = j - maxv = abs a[j][i] - . - . - if maxr <> i - swap a[maxr][] a[i][] - swap b[maxr] b[i] - . - for j = i + 1 to n - fn = a[j][i] - fd = a[i][i] - for k = i to n - a[j][k] -= a[i][k] * fn / fd - . - b[j] -= b[i] * fn / fd - . - . - len x[] n - for i = n downto 1 - rhs = b[i] - for j = i + 1 to n - rhs -= a[i][j] * x[j] - . - x[i] = rhs / a[i][i] - . - return x[] -. -# --------------------- # -# 2x + 3y − z = 5 # -# x + y + z = 6 # -# -3x - 4y + 3z = -5 # -# # -# x = 5, y = -1, z = 2 # -# --------------------- # -# -a[][] = [ [ 2 3 -1 ] [ 1 1 1 ] [ -3 -4 3 ] ] -b[] = [ 5 6 -5 ] -print gauss_elim a[][] b[] diff --git a/Task/Gaussian-elimination/FutureBasic/gaussian-elimination.basic b/Task/Gaussian-elimination/FutureBasic/gaussian-elimination.basic deleted file mode 100644 index 10ac8ba5c8..0000000000 --- a/Task/Gaussian-elimination/FutureBasic/gaussian-elimination.basic +++ /dev/null @@ -1,106 +0,0 @@ -// -// Gaussian Elimination Estimate -// -// FutureBasic 7.0.34 August 2025 R.W -// -//-------------------------------------------------- -// -// Test data array. I wanted it to be base 1 and not zero -// hence the 99 which is just filler for the zeroeth element -// -double a(6,6) = ¬ -{99, 99, 99, 99, 99, 99, 99,¬ -99, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00,¬ -99, 1.00, 0.63, 0.39, 0.25, 0.16, 0.10,¬ -99, 1.00, 1.26, 1.58, 1.98, 2.49, 3.13,¬ -99, 1.00, 1.88, 3.55, 6.70, 12.62, 23.80,¬ -99, 1.00, 2.51, 6.32, 15.88, 39.90, 100.28,¬ -99, 1.00, 3.14, 9.87, 31.01, 97.41, 306.02 } - -double b(6) = ¬ -{99,-0.01, 0.61, 0.91, 0.99, 0.60, 0.02 } - -double x(6) -double ab(6) -double ans(6),r(6),bb(6,6), f -int c, d, g, p1, p2, z -// - -int row, col -int j, k, n = 6 -// -// Pivot n times -local fn pivot(num as int) - For p1 = num to n - 1 - For p2 = p1 + 1 To n - If abs(bb(p1,num)) < abs(bb(p2,num)) - Swap r(p1),r(p2) - For g = 1 To n - Swap bb(p1,g),bb(p2,g) - Next g - End If - Next p2 - Next p1 -end fn - -// The 'Gaussian' function takes two matrices, -// 'a' and 'b', with 'a' square, and it returns -// the determinant of 'a' and a matrix 'x' -// such that a * x = b. -// If 'b' is the identity, then 'x' = inverse of 'a' - -local fn Gaussian(matrix(6,6) as double, rhs(6) as double) - - // copy matrix - for c = 1 to n - r(c) = rhs(c) - for d = 1 to n - bb(c,d) = matrix(c,d) - next d - next c - - // pivot it (hey that's what the task requires - // don't ask me why. It doesn't - // improve accuracy with these numbers) - for k = 1 to n-1 - fn pivot(k) - for row = k to n-1 - if bb(row + 1, k) == 0 then exit for - f = bb(k, k) / bb(row+1, k) - r(row + 1) = r(row + 1) * f - r(k) - For g = 1 To n - bb((row + 1), g) = bb((row + 1), g) * f - bb(k,g) - Next g - Next row - Next k - - //back substitute - For z = n to 1 step -1 - ans(z) = r(z) / bb(z,z) - For j = n to z + 1 step -1 - ans(z) = ans(z) - (bb(z,j) * ans(j) / bb(z,z)) - Next j - Next z -end fn - -window 1,@"Gaussian Elimination" - -print "TEST DATA USED" -print " ax = transpose b" -print "[1.00 |0.00 |0.00 | 0.0000 | 0.00 | 0.00] [??] [-0.01]" -print "[1.00 |0.63 |0.39 | 0.2500 | 0.16 | 0.10] [??] [ 0.61]" -print "[1.00 |1.26 |1.58 | 1.9800 | 2.49 | 3.13] x [??] = [ 0.91]" -print "[1.00 |1.88 |3.55 | 6.7000 |12.62 | 23.80] [??] [ 0.99]" -print "[1.00 |2.51 |6.32 |15.8800 |39.90 |100.28] [??] [ 0.60]" -print "[1.00 |3.14 |9.87 |31.0100 |97.41 |306.02] [??] [ 0.02]" -print - -fn Gaussian(a(0,0),b(0)) - -print "Solution:" -print "---------" -for j = 1 to 6 - print using "###.################";ans(j) -next j - -HandleEvents diff --git a/Task/Gaussian-elimination/Julia/gaussian-elimination.jl b/Task/Gaussian-elimination/Julia/gaussian-elimination.julia similarity index 100% rename from Task/Gaussian-elimination/Julia/gaussian-elimination.jl rename to Task/Gaussian-elimination/Julia/gaussian-elimination.julia diff --git a/Task/Gaussian-elimination/Kotlin/gaussian-elimination.kts b/Task/Gaussian-elimination/Kotlin/gaussian-elimination.kotlin similarity index 100% rename from Task/Gaussian-elimination/Kotlin/gaussian-elimination.kts rename to Task/Gaussian-elimination/Kotlin/gaussian-elimination.kotlin diff --git a/Task/Gaussian-elimination/OCaml/gaussian-elimination-1.ml b/Task/Gaussian-elimination/OCaml/gaussian-elimination-1.ocaml similarity index 100% rename from Task/Gaussian-elimination/OCaml/gaussian-elimination-1.ml rename to Task/Gaussian-elimination/OCaml/gaussian-elimination-1.ocaml diff --git a/Task/Gaussian-elimination/OCaml/gaussian-elimination-2.ml b/Task/Gaussian-elimination/OCaml/gaussian-elimination-2.ocaml similarity index 100% rename from Task/Gaussian-elimination/OCaml/gaussian-elimination-2.ml rename to Task/Gaussian-elimination/OCaml/gaussian-elimination-2.ocaml diff --git a/Task/Gaussian-elimination/OCaml/gaussian-elimination-3.ml b/Task/Gaussian-elimination/OCaml/gaussian-elimination-3.ocaml similarity index 100% rename from Task/Gaussian-elimination/OCaml/gaussian-elimination-3.ml rename to Task/Gaussian-elimination/OCaml/gaussian-elimination-3.ocaml diff --git a/Task/Gaussian-elimination/OCaml/gaussian-elimination-4.ml b/Task/Gaussian-elimination/OCaml/gaussian-elimination-4.ocaml similarity index 100% rename from Task/Gaussian-elimination/OCaml/gaussian-elimination-4.ml rename to Task/Gaussian-elimination/OCaml/gaussian-elimination-4.ocaml diff --git a/Task/Gaussian-elimination/OCaml/gaussian-elimination-5.ml b/Task/Gaussian-elimination/OCaml/gaussian-elimination-5.ocaml similarity index 100% rename from Task/Gaussian-elimination/OCaml/gaussian-elimination-5.ml rename to Task/Gaussian-elimination/OCaml/gaussian-elimination-5.ocaml diff --git a/Task/Gaussian-elimination/OCaml/gaussian-elimination-6.ml b/Task/Gaussian-elimination/OCaml/gaussian-elimination-6.ocaml similarity index 100% rename from Task/Gaussian-elimination/OCaml/gaussian-elimination-6.ml rename to Task/Gaussian-elimination/OCaml/gaussian-elimination-6.ocaml diff --git a/Task/Gaussian-elimination/PascalABC.NET/gaussian-elimination.pas b/Task/Gaussian-elimination/PascalABC.NET/gaussian-elimination.pas deleted file mode 100644 index e6f257930e..0000000000 --- a/Task/Gaussian-elimination/PascalABC.NET/gaussian-elimination.pas +++ /dev/null @@ -1,16 +0,0 @@ -uses NumLibABC; - -begin - var A := new real[6, 6] ((1.00, 0.00, 0.00, 0.00, 0.00, 0.00), - (1.00, 0.63, 0.39, 0.25, 0.16, 0.10), - (1.00, 1.26, 1.58, 1.98, 2.49, 3.13), - (1.00, 1.88, 3.55, 6.70, 12.62, 23.80), - (1.00, 2.51, 6.32, 15.88, 39.90, 100.28), - (1.00, 3.14, 9.87, 31.01, 97.41, 306.02)); - - var b := new real[6] (-0.01, 0.61, 0.91, 0.99, 0.60, 0.02); - - var oL := new Decomp(A); - oL.Solve(b); - b.Println; -end. diff --git a/Task/Gaussian-elimination/PowerShell/gaussian-elimination-1.ps1 b/Task/Gaussian-elimination/PowerShell/gaussian-elimination-1.psh similarity index 100% rename from Task/Gaussian-elimination/PowerShell/gaussian-elimination-1.ps1 rename to Task/Gaussian-elimination/PowerShell/gaussian-elimination-1.psh diff --git a/Task/Gaussian-elimination/PowerShell/gaussian-elimination-2.ps1 b/Task/Gaussian-elimination/PowerShell/gaussian-elimination-2.psh similarity index 100% rename from Task/Gaussian-elimination/PowerShell/gaussian-elimination-2.ps1 rename to Task/Gaussian-elimination/PowerShell/gaussian-elimination-2.psh diff --git a/Task/Gaussian-elimination/Rust/gaussian-elimination.rs b/Task/Gaussian-elimination/Rust/gaussian-elimination.rust similarity index 100% rename from Task/Gaussian-elimination/Rust/gaussian-elimination.rs rename to Task/Gaussian-elimination/Rust/gaussian-elimination.rust diff --git a/Task/Gaussian-elimination/Scala/gaussian-elimination.scala b/Task/Gaussian-elimination/Scala/gaussian-elimination.scala deleted file mode 100644 index ed99dd1688..0000000000 --- a/Task/Gaussian-elimination/Scala/gaussian-elimination.scala +++ /dev/null @@ -1,99 +0,0 @@ -object GaussianElimination { - def solve(a: Array[Array[Double]], b: Array[Array[Double]]): Double = { - if (a == null || b == null || a.length == 0 || b.length == 0) { - throw new IllegalArgumentException("Invalid dimensions") - } - - val n = b.length - val p = b(0).length - - if (a.length != n || a(0).length != n) { - throw new IllegalArgumentException("Invalid dimensions") - } - - var det = 1.0 - - for (i <- 0 until n - 1) { - var k = i - - for (j <- i + 1 until n) { - if (Math.abs(a(j)(i)) > Math.abs(a(k)(i))) { - k = j - } - } - - if (k != i) { - det = -det - - for (j <- i until n) { - val s = a(i)(j) - a(i)(j) = a(k)(j) - a(k)(j) = s - } - - for (j <- 0 until p) { - val s = b(i)(j) - b(i)(j) = b(k)(j) - b(k)(j) = s - } - } - - for (j <- i + 1 until n) { - val s = a(j)(i) / a(i)(i) - - for (k <- i + 1 until n) { - a(j)(k) -= s * a(i)(k) - } - - for (k <- 0 until p) { - b(j)(k) -= s * b(i)(k) - } - } - } - - for (i <- n - 1 to 0 by -1) { - for (j <- i + 1 until n) { - val s = a(i)(j) - - for (k <- 0 until p) { - b(i)(k) -= s * b(j)(k) - } - } - - val s = a(i)(i) - det *= s - - for (k <- 0 until p) { - b(i)(k) /= s - } - } - - det - } - - def main(args: Array[String]): Unit = { - val a = Array( - Array(4.0, 1.0, 0.0, 0.0, 0.0), - Array(1.0, 4.0, 1.0, 0.0, 0.0), - Array(0.0, 1.0, 4.0, 1.0, 0.0), - Array(0.0, 0.0, 1.0, 4.0, 1.0), - Array(0.0, 0.0, 0.0, 1.0, 4.0) - ) - - val b = Array( - Array(1.0 / 2.0), - Array(2.0 / 3.0), - Array(3.0 / 4.0), - Array(4.0 / 5.0), - Array(5.0 / 6.0) - ) - - val x = Array(39.0 / 400.0, 11.0 / 100.0, 31.0 / 240.0, 37.0 / 300.0, 71.0 / 400.0) - - println("det: " + solve(a, b)) - - for (i <- 0 until 5) { - printf("%12.8f %12.4e\n", b(i)(0), b(i)(0) - x(i)) - } - } -} diff --git a/Task/Gaussian-elimination/VBScript/gaussian-elimination.vbs b/Task/Gaussian-elimination/VBScript/gaussian-elimination.vb similarity index 100% rename from Task/Gaussian-elimination/VBScript/gaussian-elimination.vbs rename to Task/Gaussian-elimination/VBScript/gaussian-elimination.vb diff --git a/Task/Gaussian-elimination/Wren/gaussian-elimination.wren b/Task/Gaussian-elimination/Wren/gaussian-elimination.wren index 2567f3a1de..171e9cf5cf 100644 --- a/Task/Gaussian-elimination/Wren/gaussian-elimination.wren +++ b/Task/Gaussian-elimination/Wren/gaussian-elimination.wren @@ -1,4 +1,4 @@ -import "./iterate" for Stepped +import "/iterate" for Stepped var ta = [ [1.00, 0.00, 0.00, 0.00, 0.00, 0.00], diff --git a/Task/Gaussian-elimination/XPL0/gaussian-elimination.xpl0 b/Task/Gaussian-elimination/XPL0/gaussian-elimination.xpl0 deleted file mode 100644 index d3f43119aa..0000000000 --- a/Task/Gaussian-elimination/XPL0/gaussian-elimination.xpl0 +++ /dev/null @@ -1,43 +0,0 @@ -proc Gauss(A, B, X, N); \Gaussian elimination returns [X] for [A]*[X] = [B] -real A, B, X; int N; \matrix, vector, output vector, number of rows -int Diag, MaxRow, Row, Col, I; -real Max, Temp; -[for Diag:= 0 to N-1 do \partial pivoting uses largest magnitude coefficient - [MaxRow:= Diag; \ to improve numerical stability - Max:= A(Diag, Diag); - for Row:= Diag+1 to N-1 do - [Temp:= abs(A(Row, Diag)); - if Temp > Max then - [MaxRow:= Row; Max:= Temp]; - ]; - Temp:= A(Diag); A(Diag):= A(MaxRow); A(MaxRow):= Temp; \swap rows - Temp:= B(Diag); B(Diag):= B(MaxRow); B(MaxRow):= Temp; - for Row:= Diag+1 to N-1 do - [Temp:= A(Row, Diag) / A(Diag, Diag); \divide by pivot element - for Col:= Diag+1 to N-1 do - A(Row, Col):= A(Row, Col) - Temp*A(Diag, Col); - A(Row, Diag):= 0.; - B(Row):= B(Row) - Temp*B(Diag); - ]; - ]; \reduced row echelon form -for Row:= N-1 downto 0 do \back substitution makes [X] - [Temp:= B(Row); - for I:= N-1 downto Row+1 do - Temp:= Temp - X(I)*A(Row, I); - X(Row):= Temp / A(Row, Row); - ]; -]; - -real A, B, X(6); -int I; -[A:= [ [1.00, 0.00, 0.00, 0.00, 0.00, 0.00], - [1.00, 0.63, 0.39, 0.25, 0.16, 0.10], - [1.00, 1.26, 1.58, 1.98, 2.49, 3.13], - [1.00, 1.88, 3.55, 6.70, 12.62, 23.80], - [1.00, 2.51, 6.32, 15.88, 39.90, 100.28], - [1.00, 3.14, 9.87, 31.01, 97.41, 306.02] ]; -B:= [-0.01, 0.61, 0.91, 0.99, 0.60, 0.02]; -Gauss(A, B, X, 6); -for I:= 0 to 6-1 do - [RlOut(0, X(I)); CrLf(0)]; -] diff --git a/Task/General-FizzBuzz/ALGOL-68/general-fizzbuzz.alg b/Task/General-FizzBuzz/ALGOL-68/general-fizzbuzz.alg index 046fa5220b..301d6ba2ca 100644 --- a/Task/General-FizzBuzz/ALGOL-68/general-fizzbuzz.alg +++ b/Task/General-FizzBuzz/ALGOL-68/general-fizzbuzz.alg @@ -1,25 +1,25 @@ BEGIN # generalised FizzBuzz # # prompts for an integer, reads it and returns it # - PROC read an integer = ( STRING prompt )INT: + PROC read integer = ( STRING prompt )INT: BEGIN print( ( prompt ) ); INT result; read( ( result, newline ) ); result - END; # read an integer # + END; # read integer # # prompts for a string, reads it and returns it # - PROC read a string = ( STRING prompt )STRING: + PROC read string = ( STRING prompt )STRING: BEGIN print( ( prompt ) ); STRING result; read( ( result, newline ) ); result - END; # read a string # + END; # read string # # mode to hold a factor and associated text # MODE FBFACTOR = STRUCT( INT factor, STRING text ); #===============================================================# - # quicksort routine for the factors # - # - from the Algol 68 task sample # + # quicksort routine for the factors, from the Algol 68 uicksort # + # task sample # #---------------------------------------------------------------# #--- Swap function ---# PROC swap = (REF[]FBFACTOR array, INT first, INT second) VOID: @@ -51,14 +51,14 @@ BEGIN # generalised FizzBuzz # OP > = ( FBFACTOR a, b )BOOL: factor OF a > factor OF b; #===============================================================# # get the maximum number to consider # - INT max number = read an integer( "Numbers required: " ); - # number of factors required # + INT max number = read integer( "Numbers reuired: " ); + # number of factors reuired # INT max factor = 3; # get the factors and associated words # [ max factor ]FBFACTOR factors; FOR i TO max factor DO - factor OF factors[ i ] := read an integer( "Factor " + whole( i, 0 ) + ": " ); - text OF factors [ i ] := read a string( "Text for " + whole( factor OF factors[ i ], 0 ) + ": " ) + factor OF factors[ i ] := read integer( "Factor " + whole( i, 0 ) + ": " ); + text OF factors [ i ] := read string( "Text for " + whole( factor OF factors[ i ], 0 ) + ": " ) OD; # sort the factors into order # quick( factors, 1, UPB factors ); diff --git a/Task/General-FizzBuzz/Ada/general-fizzbuzz.adb b/Task/General-FizzBuzz/Ada/general-fizzbuzz.ada similarity index 100% rename from Task/General-FizzBuzz/Ada/general-fizzbuzz.adb rename to Task/General-FizzBuzz/Ada/general-fizzbuzz.ada diff --git a/Task/General-FizzBuzz/Crystal/general-fizzbuzz.cr b/Task/General-FizzBuzz/Crystal/general-fizzbuzz.cr deleted file mode 100644 index 1af7cfbec8..0000000000 --- a/Task/General-FizzBuzz/Crystal/general-fizzbuzz.cr +++ /dev/null @@ -1,12 +0,0 @@ -def fizz_buzz_plus (factorwords, limit) - factorwords = factorwords.sort_by { |f, w| f } - (1..limit).each do |n| - shout = "" - factorwords.each do |factor, word| - shout += word if n % factor == 0 - end - puts (shout == "" ? n : shout) - end -end - -fizz_buzz_plus [{3, "Fizz"}, {5, "Buzz"}, {7, "Baxx"}], 20 diff --git a/Task/General-FizzBuzz/Crystal/general-fizzbuzz.crystal b/Task/General-FizzBuzz/Crystal/general-fizzbuzz.crystal new file mode 100644 index 0000000000..e74a7afc6f --- /dev/null +++ b/Task/General-FizzBuzz/Crystal/general-fizzbuzz.crystal @@ -0,0 +1,50 @@ +counter = 0 + +puts "Enter a maximum number:" +limit = gets + +puts "Enter the first integer for factoring:" +first_int = gets +puts "Enter the name of the first integer:" +first_int_name = gets + +puts "Enter the second integer for factoring:" +second_int = gets +puts "Enter the name of the second integer:" +second_int_name = gets + +puts "Enter the third integer for factoring:" +third_int = gets +puts "Enter the name of the third integer:" +third_int_name = gets + +if (limit && + first_int && + second_int && + third_int && + first_int_name && + second_int_name && + third_int_name) + limit = limit.chomp.to_i + first_int = first_int.chomp.to_i + second_int = second_int.chomp.to_i + third_int = third_int.chomp.to_i + while limit > counter + counter += 1 + if (counter % first_int) == 0 && (counter % second_int) == 0 && (counter % third_int) == 0 + puts first_int_name + second_int_name + third_int_name + elsif (counter % first_int) == 0 && (counter % second_int) == 0 + puts first_int_name + second_int_name + elsif (counter % first_int) == 0 + puts first_int_name + elsif (counter % second_int) == 0 + puts second_int_name + elsif (counter % third_int) == 0 + puts third_int_name + else + puts counter + end + end +else + exit +end diff --git a/Task/General-FizzBuzz/EasyLang/general-fizzbuzz.easy b/Task/General-FizzBuzz/EasyLang/general-fizzbuzz.easy deleted file mode 100644 index 5de17848ab..0000000000 --- a/Task/General-FizzBuzz/EasyLang/general-fizzbuzz.easy +++ /dev/null @@ -1,17 +0,0 @@ -max = 20 -words$[] = [ "Fizz" "Buzz" "Baxx" ] -keys[] = [ 3 5 7 ] -# -for n = 1 to max - prnt = 1 - for j = 1 to len keys[] - if n mod keys[j] = 0 - write words$[j] - prnt = 0 - . - . - if prnt = 1 - write n - . - print "" -. diff --git a/Task/General-FizzBuzz/Elixir/general-fizzbuzz.ex b/Task/General-FizzBuzz/Elixir/general-fizzbuzz.elixir similarity index 100% rename from Task/General-FizzBuzz/Elixir/general-fizzbuzz.ex rename to Task/General-FizzBuzz/Elixir/general-fizzbuzz.elixir diff --git a/Task/General-FizzBuzz/FutureBasic/general-fizzbuzz.basic b/Task/General-FizzBuzz/FutureBasic/general-fizzbuzz.basic deleted file mode 100644 index 01392f4c1c..0000000000 --- a/Task/General-FizzBuzz/FutureBasic/general-fizzbuzz.basic +++ /dev/null @@ -1,108 +0,0 @@ -include "NSLog.incl" - -_mfile = 1 -begin enum - _iNewGame - _ - _iClose -end enum -_mEdit = 2 - -_window = 1 -begin enum 1 - _maxNumLabel - _maxNumFld - _f1Label - _f1Fld - _wd1Label - _wd1Fld - _f2Label - _f2Fld - _wd2Label - _wd2Fld - _f3Label - _f3Fld - _wd3Label - _wd3Fld - _playBtn -end enum - -void local fn BuildMenu - menu _mFile,,, @"File" - menu _mFile, _iNewGame,, @"New Game" - menu _mFile, _iClose,, @"Close", @"w" - MenuItemSetAction( _mFile, _iClose, @"performClose:" ) - editmenu _mEdit -end fn - -void local fn BuildWindow - window _window, @"General FizzBuzz", (0,0,362,188), NSWindowStyleMaskTitled - - textlabel _maxNumLabel, @"Maximum number:", (18,150,116,16) - textfield _maxNumFld,, @"20", (140,147,202,21) - ControlSetFormat( _maxNumFld, @"0123456789", YES, 0, 0 ) - - textlabel _f1Label, @"Factor 1:", (18,121,58,16) - textfield _f1Fld,, @"3", (80,118,54,21) - ControlSetFormat( _f1Fld, @"0123456789", YES, 0, 0 ) - textlabel _wd1Label, @"Word 1:", (138,121,52,16) - textfield _wd1Fld,, @"Fizz", (196,118,146,21) - - textlabel _f2Label, @"Factor 2:", (18,92,58,16) - textfield _f2Fld,, @"5", (80,89,54,21) - ControlSetFormat( _f2Fld, @"0123456789", YES, 0, 0 ) - textlabel _wd2Label, @"Word 2:", (138,92,52,16) - textfield _wd2Fld,, @"Buzz", (196,89,146,21) - - textlabel _f3Label, @"Factor 3:", (18,63,58,16) - textfield _f3Fld,, @"7", (80,60,54,21) - ControlSetFormat( _f3Fld, @"0123456789", YES, 0, 0 ) - textlabel _wd3Label, @"Word 3:", (138,63,52,16) - textfield _wd3Fld,, @"Baxx", (196,60,146,21) - - button _playBtn,,, @"Play FizzBuzz", (122,13,118,32) - - WindowMakeFirstResponder( _window, _maxNumFld ) -end fn - -void local fn PlayFizzBuzz - long maxNum = intval(textfield(_maxNumFld)) - - long f1 = intval(textfield(_f1Fld)) - long f2 = intval(textfield(_f2Fld)) - long f3 = intval(textfield(_f3Fld)) - - CFStringRef f1Word = textfield(_wd1Fld) - CFStringRef f2Word = textfield(_wd2Fld) - CFStringRef f3Word = textfield(_wd3Fld) - CFStringRef string = NULL - - NSLogClear - - long i - for i = 1 to maxNum - string = @"" - if ( i mod f1 == 0 ) then string = f1Word - if ( i mod f2 == 0 ) then string = fn StringByAppendingString( string, f2Word ) - if ( i mod f3 == 0 ) then string = fn StringByAppendingString( string, f3Word ) - if ( len(string) == 0 ) then string = fn StringWithFormat( @"%ld", i ) - NSLog(@"%@",string) - next -end fn - - -void local fn DoDialog( ev as long, tag as long ) - select ( ev ) - case _btnClick - select ( tag ) - case _playBtn : fn PlayFizzBuzz - end select - end select -end fn - -fn BuildMenu -fn BuildWindow - -on dialog fn DoDialog - -HandleEvents diff --git a/Task/General-FizzBuzz/Icon/general-fizzbuzz.icon b/Task/General-FizzBuzz/Icon/general-fizzbuzz.icon deleted file mode 100644 index 8122a68d0c..0000000000 --- a/Task/General-FizzBuzz/Icon/general-fizzbuzz.icon +++ /dev/null @@ -1,16 +0,0 @@ -link factors - -procedure main(A) - /A := [20,3,"Fizz",5,"Buzz",7,"Baxx"] - mtable := table() - limit := get(A) - while *A > 0 do mtable[integer(get(A))] := get(A) - mlist := sort([: key(mtable) :]) - - every i := 1 to limit do write((""~== fizzbuzz(i,mlist,mtable))|i) -end - -procedure fizzbuzz(n,a,t) - every (s := "", n%(f := !a) = 0) do s ||:= t[f] - return s -end diff --git a/Task/General-FizzBuzz/Julia/general-fizzbuzz.jl b/Task/General-FizzBuzz/Julia/general-fizzbuzz.julia similarity index 100% rename from Task/General-FizzBuzz/Julia/general-fizzbuzz.jl rename to Task/General-FizzBuzz/Julia/general-fizzbuzz.julia diff --git a/Task/General-FizzBuzz/Kotlin/general-fizzbuzz.kts b/Task/General-FizzBuzz/Kotlin/general-fizzbuzz.kotlin similarity index 100% rename from Task/General-FizzBuzz/Kotlin/general-fizzbuzz.kts rename to Task/General-FizzBuzz/Kotlin/general-fizzbuzz.kotlin diff --git a/Task/General-FizzBuzz/Maxima/general-fizzbuzz.maxima b/Task/General-FizzBuzz/Maxima/general-fizzbuzz.maxima deleted file mode 100644 index 061ce84551..0000000000 --- a/Task/General-FizzBuzz/Maxima/general-fizzbuzz.maxima +++ /dev/null @@ -1,18 +0,0 @@ -srep(n, s) := block( - l: charlist(s), - lrep: map(lambda([c], smake(n, c)), l), - apply(sconcat, lrep) -)$ - -srep_zip(nums, strings) := block( - len: min(length(nums), length(strings)), - makelist(srep(nums[i], strings[i]), i, 1, len) -)$ - -genfizzbuzz(factors, words, n1, n2) := for i from n1 thru n2 do( - flags: map(lambda([k], charfun(mod(i, k)=0)), factors), - if member(1, flags) then sprint(apply(sconcat, srep_zip(flags, words))) else sprint(i), - if mod(i-n1+1, 10)=0 then newline() -)$ - -genfizzbuzz([3, 5, 7], ["Fizz", "Buzz", "Baxx"], 1, 105); diff --git a/Task/General-FizzBuzz/OCaml/general-fizzbuzz.ml b/Task/General-FizzBuzz/OCaml/general-fizzbuzz.ocaml similarity index 100% rename from Task/General-FizzBuzz/OCaml/general-fizzbuzz.ml rename to Task/General-FizzBuzz/OCaml/general-fizzbuzz.ocaml diff --git a/Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas b/Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas deleted file mode 100644 index dc3d777a26..0000000000 --- a/Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas +++ /dev/null @@ -1,14 +0,0 @@ -## -for var i:=1 to 20 do -begin - var s := ''; - if i mod 3 = 0 then - s += 'Fizz'; - if i mod 5 = 0 then - s += 'Buzz'; - if i mod 7 = 0 then - s += 'Baxx'; - if s = '' then - Println(i) - else Println(s); -end diff --git a/Task/General-FizzBuzz/Phix/general-fizzbuzz.phix b/Task/General-FizzBuzz/Phix/general-fizzbuzz.phix index 5eb2ca375f..5ac2a4ea5e 100644 --- a/Task/General-FizzBuzz/Phix/general-fizzbuzz.phix +++ b/Task/General-FizzBuzz/Phix/general-fizzbuzz.phix @@ -1,17 +1,17 @@ -with javascript_semantics - -procedure general_fizz_buzz(integer lim, sequence words, facts) - for i=1 to lim do - string word = "" - for j, f in facts do - if remainder(i,f)=0 then - word &= words[j] - end if - end for - if length(word)=0 then - word = sprintf("%d",i) - end if - printf(1,"%s\n",{word}) - end for -end procedure -general_fizz_buzz(20, {"Fizz","Buzz","Baxx"}, {3,5,7}) +--> + procedure general_fizz_buzz(integer lim, sequence words, facts) + for i=1 to lim do + string word = "" + for j=1 to length(facts) do + if remainder(i,facts[j])=0 then + word &= words[j] + end if + end for + if length(word)=0 then + word = sprintf("%d",i) + end if + printf(1,"%s\n",{word}) + end for + end procedure + general_fizz_buzz(20, {"Fizz","Buzz","Baxx"}, {3,5,7}) + $ ) - - 105 - ' [ [ $ "fizz" 3 ] - [ $ "baxx" 7 ] - [ $ "buzz" 5 ] ] generalfizzbuzz - nest$ 60 wrap$ cr diff --git a/Task/General-FizzBuzz/Refal/general-fizzbuzz.refal b/Task/General-FizzBuzz/Refal/general-fizzbuzz.refal deleted file mode 100644 index 7519a97553..0000000000 --- a/Task/General-FizzBuzz/Refal/general-fizzbuzz.refal +++ /dev/null @@ -1,54 +0,0 @@ -$ENTRY Go { - , >: s.Max - , : e.Factors - , : e.Nums - = ; -}; - -Fizz { - s.I e.Facs, : { - = >; - e.X = ; - }; -} - -Fac { - (s.Fac e.FacWord) s.I, : { - 0 = e.FacWord; - s.X = ; - }; -}; - -ReadFactors { - , : { - 0 = ; = ; - e.Line = () ; - }; -}; - -Line { - e.X, : (e.Num) e.Word = - ; -}; - -Split { - s.C e.X s.C e.Y = (e.X) e.Y; - s.C e.X = (e.X); -}; - -Trim { - s.C = ; - s.C s.C e.X = ; - s.C e.X s.C = ; - s.C s.I e.X = s.I ; -}; - -Iota { - s.End s.End = s.End; - s.Start s.End = s.Start s.End>; -}; - -Each { - s.F (e.Arg) = ; - s.F (e.Arg) t.I e.X = ; -}; diff --git a/Task/General-FizzBuzz/Rust/general-fizzbuzz-1.rs b/Task/General-FizzBuzz/Rust/general-fizzbuzz-1.rust similarity index 100% rename from Task/General-FizzBuzz/Rust/general-fizzbuzz-1.rs rename to Task/General-FizzBuzz/Rust/general-fizzbuzz-1.rust diff --git a/Task/General-FizzBuzz/Rust/general-fizzbuzz-2.rs b/Task/General-FizzBuzz/Rust/general-fizzbuzz-2.rust similarity index 100% rename from Task/General-FizzBuzz/Rust/general-fizzbuzz-2.rs rename to Task/General-FizzBuzz/Rust/general-fizzbuzz-2.rust diff --git a/Task/General-FizzBuzz/SETL/general-fizzbuzz.setl b/Task/General-FizzBuzz/SETL/general-fizzbuzz.setl deleted file mode 100644 index 4caf8b65f4..0000000000 --- a/Task/General-FizzBuzz/SETL/general-fizzbuzz.setl +++ /dev/null @@ -1,9 +0,0 @@ -program general_fizzbuzz; - fizzbuzz(20, {[3,"Fizz"], [5,"Buzz"], [7,"Baxx"]}); - - proc fizzbuzz(maxno, factors); - loop for i in [1..maxno] do - print(+/[word : word = factors(f) | i mod f=0] ? str i); - end loop; - end proc; -end program; diff --git a/Task/General-FizzBuzz/Tailspin/general-fizzbuzz-1.tailspin b/Task/General-FizzBuzz/Tailspin/general-fizzbuzz-1.tailspin deleted file mode 100644 index b69f11e901..0000000000 --- a/Task/General-FizzBuzz/Tailspin/general-fizzbuzz-1.tailspin +++ /dev/null @@ -1,16 +0,0 @@ -def input: {N: 110"1", words: [ { mod: 3"1", word: 'Fizz' }, { mod: 5"1", word: 'Buzz'}, {mod:7"1", word: 'Baxx'}]}; - -templates sayWords - def i: $; - templates maybeSay - def word: $.word; - $i mod $.mod -> \(<=0"1"> $word !\) ! - end maybeSay - '$input.words... -> maybeSay;' -> # - - when <=''> do $i ! - otherwise $ ! -end sayWords - -1"1"..$input.N -> sayWords -> '$; -' -> !OUT::write diff --git a/Task/General-FizzBuzz/Tailspin/general-fizzbuzz-2.tailspin b/Task/General-FizzBuzz/Tailspin/general-fizzbuzz-2.tailspin deleted file mode 100644 index d34c8fee9f..0000000000 --- a/Task/General-FizzBuzz/Tailspin/general-fizzbuzz-2.tailspin +++ /dev/null @@ -1,16 +0,0 @@ -input is {N: 110"1", words: [ { mod: 3"1", word: 'Fizz' }, { mod: 5"1", word: 'Buzz'}, {mod:7"1", word: 'Baxx'}]}; - -sayWords templates - i is $; - maybeSay templates - word is $(word:); - $i mod $(mod:) -> if <|=0"1"> -> $word ! - end maybeSay - '$input(words:)... -> maybeSay;' -> # ! - - when <|=''> do $i ! - otherwise $ ! -end sayWords - -1"1"..$input(N:) -> sayWords -> '$; -' ! diff --git a/Task/General-FizzBuzz/Tailspin/general-fizzbuzz.tailspin b/Task/General-FizzBuzz/Tailspin/general-fizzbuzz.tailspin new file mode 100644 index 0000000000..97e1bb007c --- /dev/null +++ b/Task/General-FizzBuzz/Tailspin/general-fizzbuzz.tailspin @@ -0,0 +1,13 @@ +def input: {N: 110"1", words: [ { mod: 3"1", word: 'Fizz' }, { mod: 5"1", word: 'Buzz'}, {mod:7"1", word: 'Baxx'}]}; + +templates sayWords + def i: $; + templates maybeSay + def word: $.word; + $i mod $.mod -> \(<=0"1"> $word !\) ! + end maybeSay + $input.words... -> maybeSay ! +end sayWords + +[ 1"1"..$input.N -> '$->sayWords;' ] -> \[i](<=''> $i ! <> $ !\) -> '$; +' -> !OUT::write diff --git a/Task/General-FizzBuzz/VBScript/general-fizzbuzz.vbs b/Task/General-FizzBuzz/VBScript/general-fizzbuzz.vb similarity index 100% rename from Task/General-FizzBuzz/VBScript/general-fizzbuzz.vbs rename to Task/General-FizzBuzz/VBScript/general-fizzbuzz.vb diff --git a/Task/General-FizzBuzz/Wren/general-fizzbuzz.wren b/Task/General-FizzBuzz/Wren/general-fizzbuzz.wren index 6acc353798..afb08348eb 100644 --- a/Task/General-FizzBuzz/Wren/general-fizzbuzz.wren +++ b/Task/General-FizzBuzz/Wren/general-fizzbuzz.wren @@ -1,5 +1,5 @@ import "io" for Stdin, Stdout -import "./sort" for Sort +import "/sort" for Sort var n diff --git a/Task/Generate-Chess960-starting-position/00-TASK.txt b/Task/Generate-Chess960-starting-position/00-TASK.txt index 5e682079f5..1721911501 100644 --- a/Task/Generate-Chess960-starting-position/00-TASK.txt +++ b/Task/Generate-Chess960-starting-position/00-TASK.txt @@ -11,6 +11,6 @@ With those constraints there are '''960''' possible starting positions, thus the ;Task: -The purpose of this task is to write a program that can randomly generate any one of the 960 Chess960 initial positions. You will show the result as the first rank displayed using either the [[wp:Chess symbols in Unicode|chess symbols in Unicode (♔♕♖♗♘)]], the letters '''K'''ing '''Q'''ueen '''R'''ook '''B'''ishop k'''N'''ight, or the corresponding letters in a language other than English. +The purpose of this task is to write a program that can randomly generate any one of the 960 Chess960 initial positions. You will show the result as the first rank displayed with [[wp:Chess symbols in Unicode|Chess symbols in Unicode: ♔♕♖♗♘]] or with the letters '''K'''ing '''Q'''ueen '''R'''ook '''B'''ishop k'''N'''ight.

diff --git a/Task/Generate-Chess960-starting-position/BBC-BASIC/generate-chess960-starting-position.basic b/Task/Generate-Chess960-starting-position/BBC-BASIC/generate-chess960-starting-position.basic deleted file mode 100644 index 517a7efb4b..0000000000 --- a/Task/Generate-Chess960-starting-position/BBC-BASIC/generate-chess960-starting-position.basic +++ /dev/null @@ -1,17 +0,0 @@ - VDU 23, 22, 240; 360; 8, 16, 16, 136 - *FONT Arial, 20 - FOR I% = 1 TO 10 - Rank1$ = "202" - FOR Piece = 1 TO 3 - P% = RND(LENRank1$ + 1) - Rank1$ = LEFT$(Rank1$, P% - 1) + MID$("144", Piece, 1) + MID$(Rank1$, P%) - NEXT - P% = RND(7) - Rank1$ = LEFT$(Rank1$, P% - 1) + "3" + MID$(Rank1$, P%) - IF P% > 5 P% += 1 ELSE P% += RND(4 - (P% >> 1)) * 2 - 1 - Rank1$ = LEFT$(Rank1$, P% - 1) + "3" + MID$(Rank1$, P%) - FOR Piece = 1 TO 8 - VDU &E2, &99, &94 + VALMID$(Rank1$, Piece, 1) - NEXT - PRINT - NEXT diff --git a/Task/Generate-Chess960-starting-position/C-sharp/generate-chess960-starting-position.cs b/Task/Generate-Chess960-starting-position/C-sharp/generate-chess960-starting-position.cs deleted file mode 100644 index 3925cf8ea6..0000000000 --- a/Task/Generate-Chess960-starting-position/C-sharp/generate-chess960-starting-position.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; - -class Program -{ - struct Symbols - { - public char K, Q, R, B, N; - - public Symbols(char k, char q, char r, char b, char n) - { - K = k; Q = q; R = r; B = b; N = n; - } - } - - private static Symbols A = new Symbols('K', 'Q', 'R', 'B', 'N'); - private static Symbols W = new Symbols('♔', '♕', '♖', '♗', '♘'); - private static Symbols B = new Symbols('♚', '♛', '♜', '♝', '♞'); - - private static string[] krn = new string[] - { - "nnrkr", "nrnkr", "nrknr", "nrkrn", - "rnnkr", "rnknr", "rnkrn", - "rknnr", "rknrn", - "rkrnn" - }; - - private static string Chess960(Symbols sym, int id) - { - char[] pos = new char[8]; - int q = id / 4, r = id % 4; - pos[r * 2 + 1] = sym.B; - r = q % 4; q /= 4; - pos[r * 2] = sym.B; - r = q % 6; q /= 6; - int placementIndex = 0; // Adjusted variable name to prevent conflict - for (int i = 0; ; i++) - { - if (pos[i] != '\0') continue; - if (r == 0) - { - pos[i] = sym.Q; - break; - } - r--; - } - while (pos[placementIndex] != '\0') placementIndex++; // Adjusted loop to prevent conflict - foreach (char f in krn[q]) - { - while (pos[placementIndex] != '\0') placementIndex++; - switch (f) - { - case 'k': - pos[placementIndex] = sym.K; - break; - case 'r': - pos[placementIndex] = sym.R; - break; - case 'n': - pos[placementIndex] = sym.N; - break; - } - } - return new string(pos); - } - - static void Main(string[] args) - { - Console.WriteLine(" ID Start position"); - foreach (int id in new int[] { 0, 518, 959 }) - { - Console.WriteLine($"{id,3} {Chess960(A, id)}"); - } - Console.WriteLine("\nRandom"); - Random rand = new Random(); - for (int i = 0; i < 5; i++) - { - Console.WriteLine(Chess960(W, rand.Next(960))); - } - } -} diff --git a/Task/Generate-Chess960-starting-position/Chipmunk-Basic/generate-chess960-starting-position.basic b/Task/Generate-Chess960-starting-position/Chipmunk-Basic/generate-chess960-starting-position.basic deleted file mode 100644 index 35d08c975c..0000000000 --- a/Task/Generate-Chess960-starting-position/Chipmunk-Basic/generate-chess960-starting-position.basic +++ /dev/null @@ -1,15 +0,0 @@ -100 randomize timer -110 for i = 1 to 10 -120 inicio$ = "RKR" -130 pieza$ = "QNN" -140 for n = 1 to len(pieza$) -150 posic = int(rnd(len(inicio$)+1))+1 -160 inicio$ = left$(inicio$,posic-1)+mid$(pieza$,n,1)+right$(inicio$,len(inicio$)-posic+1) -170 next n -180 posic = int(rnd(len(inicio$)+1))+1 -190 inicio$ = left$(inicio$,posic-1)+"B"+right$(inicio$,len(inicio$)-posic+1) -200 posic = posic+1+2*int(int(rnd(len(inicio$)-posic))/2) -210 inicio$ = left$(inicio$,posic-1)+"B"+right$(inicio$,len(inicio$)-posic+1) -220 print inicio$ -230 next i -240 end diff --git a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-1.d b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-1.d index adef3fcc8c..a0e9db973f 100644 --- a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-1.d +++ b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-1.d @@ -1,63 +1,13 @@ -import std.stdio; -import std.random; -import std.algorithm; -import std.range; - -string[] ch960startPos() { - string[] rank = new string[8]; - - auto d = (size_t num) => uniform(0, num); - - auto emptySquares = () { - return rank.enumerate - .filter!(t => t.value is null) - .map!(t => t.index) - .array(); - }; - - // Place one Bishop << on a black square - rank[d(4) * 2] = "♗"; - - // Place the other Bishop << on a white square - rank[d(4) * 2 + 1] = "♗"; - - // Place the Queen << - auto empty = emptySquares(); - rank[empty[d(empty.length)]] = "♕"; - - // Place one Knight << - empty = emptySquares(); - rank[empty[d(empty.length)]] = "♘"; - - // Place the second Knight << - empty = emptySquares(); - rank[empty[d(empty.length)]] = "♘"; - - // Remaining positions: place 2 Rooks << and 1 King << - empty = emptySquares(); - empty.sort(); // Sort positions for easier logic - - size_t kingPosIndex = d(empty.length); - size_t kingPos = empty[kingPosIndex]; - - auto left = empty[0 .. kingPosIndex]; - auto right = empty[kingPosIndex + 1 .. $]; - - if (left.empty || right.empty) { - // Invalid setup, retry - return ch960startPos(); - } - - size_t rook1 = left[d(left.length)]; - size_t rook2 = right[d(right.length)]; - - rank[rook1] = "♖"; - rank[kingPos] = "♔"; - rank[rook2] = "♖"; - - return rank; -} - void main() { - iota(10).each!(_ => writeln(ch960startPos().join(""))); + import std.stdio, std.range, std.algorithm, std.string, permutations2; + + const pieces = "KQRrBbNN"; + alias I = indexOf; + auto starts = pieces.dup.permutations.filter!(p => + I(p, 'B') % 2 != I(p, 'b') % 2 && // Bishop constraint. + // King constraint. + ((I(p, 'r') < I(p, 'K') && I(p, 'K') < I(p, 'R')) || + (I(p, 'R') < I(p, 'K') && I(p, 'K') < I(p, 'r')))) + .map!toUpper.array.sort().uniq; + writeln(starts.walkLength, "\n", starts.front); } diff --git a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-2.d b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-2.d index a349f282e0..420a99b0c8 100644 --- a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-2.d +++ b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-2.d @@ -1,25 +1,11 @@ -import std.stdio : writeln; -import std.random; -import std.array : join; -import std.string : indexOf, lastIndexOf; -import std.algorithm : nextPermutation; - void main() { - // The Pieces, no King at all but 3 Rooks! - auto pos = ["Q", "R", "R", "R", "B", "B", "N", "N"].randomShuffle; + import std.stdio, std.regex, std.range, std.algorithm, permutations2; - do { - auto candidate = pos.join(""); - - if (candidate.indexOf('B') % 2 != candidate.lastIndexOf('B') % 2) { - auto dupPos = pos.dup; - - // Promote middle Rook to King - dupPos[candidate[0..candidate.lastIndexOf('R')].lastIndexOf('R')] = "K"; - - dupPos.join("").writeln; // Output! - - return; - } - } while (pos.nextPermutation); + immutable pieces = "KQRRBBNN"; + immutable bish = r"B(|..|....|......)B"; + immutable king = r"R.*K.*R"; + auto starts3 = permutations(pieces.dup) + .filter!(p => p.match(bish) && p.match(king)) + .array.sort().uniq; + writeln(starts3.walkLength, "\n", starts3.front); } diff --git a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-3.d b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-3.d index a0e9db973f..5885e3bb3d 100644 --- a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-3.d +++ b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-3.d @@ -1,13 +1,13 @@ void main() { - import std.stdio, std.range, std.algorithm, std.string, permutations2; + import std.stdio, std.random, std.array, std.range; - const pieces = "KQRrBbNN"; - alias I = indexOf; - auto starts = pieces.dup.permutations.filter!(p => - I(p, 'B') % 2 != I(p, 'b') % 2 && // Bishop constraint. - // King constraint. - ((I(p, 'r') < I(p, 'K') && I(p, 'K') < I(p, 'R')) || - (I(p, 'R') < I(p, 'K') && I(p, 'K') < I(p, 'r')))) - .map!toUpper.array.sort().uniq; - writeln(starts.walkLength, "\n", starts.front); + // Subsequent order unchanged by insertions. + auto start = "RKR".dup; + foreach (immutable piece; "QNN") + start.insertInPlace(uniform(0, start.length), piece); + + immutable bishpos = uniform(0, start.length); + start.insertInPlace(bishpos, 'B'); + start.insertInPlace(iota(bishpos % 2, start.length, 2)[uniform(0,$)], 'B'); + start.writeln; } diff --git a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-4.d b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-4.d deleted file mode 100644 index 420a99b0c8..0000000000 --- a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-4.d +++ /dev/null @@ -1,11 +0,0 @@ -void main() { - import std.stdio, std.regex, std.range, std.algorithm, permutations2; - - immutable pieces = "KQRRBBNN"; - immutable bish = r"B(|..|....|......)B"; - immutable king = r"R.*K.*R"; - auto starts3 = permutations(pieces.dup) - .filter!(p => p.match(bish) && p.match(king)) - .array.sort().uniq; - writeln(starts3.walkLength, "\n", starts3.front); -} diff --git a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-5.d b/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-5.d deleted file mode 100644 index 5885e3bb3d..0000000000 --- a/Task/Generate-Chess960-starting-position/D/generate-chess960-starting-position-5.d +++ /dev/null @@ -1,13 +0,0 @@ -void main() { - import std.stdio, std.random, std.array, std.range; - - // Subsequent order unchanged by insertions. - auto start = "RKR".dup; - foreach (immutable piece; "QNN") - start.insertInPlace(uniform(0, start.length), piece); - - immutable bishpos = uniform(0, start.length); - start.insertInPlace(bishpos, 'B'); - start.insertInPlace(iota(bishpos % 2, start.length, 2)[uniform(0,$)], 'B'); - start.writeln; -} diff --git a/Task/Generate-Chess960-starting-position/Delphi/generate-chess960-starting-position.pas b/Task/Generate-Chess960-starting-position/Delphi/generate-chess960-starting-position.pas deleted file mode 100644 index 79f51aab19..0000000000 --- a/Task/Generate-Chess960-starting-position/Delphi/generate-chess960-starting-position.pas +++ /dev/null @@ -1,41 +0,0 @@ -program byconstruct; - -{$APPTYPE CONSOLE} - -uses - System.SysUtils, System.Math, Generics.Collections; - -var - start: TList; - piece: Char; - bishpos: Integer; - resultString: String; - -begin - Randomize; - - start := TList.Create; - - try - start.AddRange(['R', 'K', 'R']); // << - - for piece in ['Q', 'N', 'N'] do - start.Insert(Random(start.Count), piece); // << - - bishpos := Random(start.Count); - start.Insert(bishpos, 'B'); // << - - if bishpos mod 2 = 0 then - start.Insert(Random(start.Count div 2) * 2, 'B') // << - else - start.Insert(Random((start.Count - bishpos + 1) div 2) * 2 + bishpos, 'B'); // << - - // Convert TList to String - resultString := String.Create(start.ToArray); - - WriteLn(resultString); - - finally - start.Free; - end; -end. diff --git a/Task/Generate-Chess960-starting-position/EasyLang/generate-chess960-starting-position.easy b/Task/Generate-Chess960-starting-position/EasyLang/generate-chess960-starting-position.easy deleted file mode 100644 index 23cfd98d6c..0000000000 --- a/Task/Generate-Chess960-starting-position/EasyLang/generate-chess960-starting-position.easy +++ /dev/null @@ -1,21 +0,0 @@ -len t$[] 8 -proc randins c$ l r &pos . - repeat - pos = random l r - until t$[pos] = "" - . - t$[pos] = c$ -. -randins "K" 2 7 king -randins "R" 1 (king - 1) h -randins "R" (king + 1) 8 h -randins "B" 1 8 b1 -repeat - randins "B" 1 8 b2 - until (b2 - b1) mod 2 <> 0 - t$[b2] = "" -. -randins "Q" 1 8 b1 -randins "N" 1 8 b1 -randins "N" 1 8 b1 -print strjoin t$[] "" diff --git a/Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-1.ex b/Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-1.elixir similarity index 100% rename from Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-1.ex rename to Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-1.elixir diff --git a/Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-2.ex b/Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-2.elixir similarity index 100% rename from Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-2.ex rename to Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-2.elixir diff --git a/Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-3.ex b/Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-3.elixir similarity index 100% rename from Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-3.ex rename to Task/Generate-Chess960-starting-position/Elixir/generate-chess960-starting-position-3.elixir diff --git a/Task/Generate-Chess960-starting-position/FreeBASIC/generate-chess960-starting-position.basic b/Task/Generate-Chess960-starting-position/FreeBASIC/generate-chess960-starting-position.basic index ec27d49e50..4121b4fe91 100644 --- a/Task/Generate-Chess960-starting-position/FreeBASIC/generate-chess960-starting-position.basic +++ b/Task/Generate-Chess960-starting-position/FreeBASIC/generate-chess960-starting-position.basic @@ -9,12 +9,9 @@ For i As Byte = 1 To 10 Mid(pieza, n, 1) +_ Right(inicio, Len(inicio) - posic + 1) Next n - posic = Int(Rnd*(Len(inicio) + 1)) + 1 inicio = Left(inicio, posic-1) + "B" + Right(inicio, Len(inicio) - posic + 1) - - posic += 1 + 2 * (Int(Rnd*(Len(inicio) - posic)) \ 2) + posic = posic + 1 + 2 * Int(Int(Rnd*(Len(inicio) - posic)) / 2) inicio = Left(inicio, posic-1) + "B" + Right(inicio, Len(inicio) - posic + 1) - Print inicio Next i diff --git a/Task/Generate-Chess960-starting-position/Gambas/generate-chess960-starting-position.gambas b/Task/Generate-Chess960-starting-position/Gambas/generate-chess960-starting-position.gambas deleted file mode 100644 index bd592b61f9..0000000000 --- a/Task/Generate-Chess960-starting-position/Gambas/generate-chess960-starting-position.gambas +++ /dev/null @@ -1,21 +0,0 @@ -Public Sub Main() - - Randomize - - For i As Integer = 1 To 10 - Dim inicio As String = "RKR" - Dim pieza As String = "QNN" - Dim posic As Integer - - For n As Integer = 1 To Len(pieza) - posic = Int(Rnd * (Len(inicio) + 1)) + 1 - inicio = Left(inicio, posic - 1) & Mid(pieza, n, 1) & Right(inicio, Len(inicio) - posic + 1) - Next - posic = Int(Rnd * (Len(inicio) + 1)) + 1 - inicio = Left(inicio, posic - 1) & "B" & Right(inicio, Len(inicio) - posic + 1) - posic += 1 + 2 * Int(Int(Rnd * (Len(inicio) - posic)) / 2) - inicio = Left(inicio, posic - 1) & "B" & Right(inicio, Len(inicio) - posic + 1) - Print inicio - Next - -End diff --git a/Task/Generate-Chess960-starting-position/Julia/generate-chess960-starting-position.jl b/Task/Generate-Chess960-starting-position/Julia/generate-chess960-starting-position.julia similarity index 100% rename from Task/Generate-Chess960-starting-position/Julia/generate-chess960-starting-position.jl rename to Task/Generate-Chess960-starting-position/Julia/generate-chess960-starting-position.julia diff --git a/Task/Generate-Chess960-starting-position/Kotlin/generate-chess960-starting-position.kts b/Task/Generate-Chess960-starting-position/Kotlin/generate-chess960-starting-position.kotlin similarity index 100% rename from Task/Generate-Chess960-starting-position/Kotlin/generate-chess960-starting-position.kts rename to Task/Generate-Chess960-starting-position/Kotlin/generate-chess960-starting-position.kotlin diff --git a/Task/Generate-Chess960-starting-position/PascalABC.NET/generate-chess960-starting-position.pas b/Task/Generate-Chess960-starting-position/PascalABC.NET/generate-chess960-starting-position.pas deleted file mode 100644 index b45cbcaded..0000000000 --- a/Task/Generate-Chess960-starting-position/PascalABC.NET/generate-chess960-starting-position.pas +++ /dev/null @@ -1,15 +0,0 @@ -## -function random960: string; -begin - var start := 'RKR'; - - foreach var piece in 'QNN' do - Insert(piece, start, Random(start.length + 1) + 1); - - var bishpos := Random(start.length + 1) + 1; - Insert('B', start, bishpos); - Insert('B', start, Range(bishpos + 1, start.Length + 1, 2).ToArray.RandomElement); - result := start; -end; - -random960.Println; diff --git a/Task/Generate-Chess960-starting-position/PowerShell/generate-chess960-starting-position.ps1 b/Task/Generate-Chess960-starting-position/PowerShell/generate-chess960-starting-position.psh similarity index 100% rename from Task/Generate-Chess960-starting-position/PowerShell/generate-chess960-starting-position.ps1 rename to Task/Generate-Chess960-starting-position/PowerShell/generate-chess960-starting-position.psh diff --git a/Task/Generate-Chess960-starting-position/Prolog/generate-chess960-starting-position-1.pro b/Task/Generate-Chess960-starting-position/Prolog/generate-chess960-starting-position-1.pro deleted file mode 100644 index abfe908b60..0000000000 --- a/Task/Generate-Chess960-starting-position/Prolog/generate-chess960-starting-position-1.pro +++ /dev/null @@ -1,12 +0,0 @@ -check(Row) :- - nth1(King, Row, ♔), - nth1(Rook1, Row, ♖), - nth1(Rook2, Row, ♖), - nth1(Bishop1, Row, ♗), - nth1(Bishop2, Row, ♗), - Rook1 < King, King < Rook2, - (Bishop1 + Bishop2) mod 2 =:= 1. - -generate(Row) :- - random_permutation([♖,♘,♗,♕,♔,♗,♘,♖], Row), - check(Row) ; generate(Row). diff --git a/Task/Generate-Chess960-starting-position/Prolog/generate-chess960-starting-position-2.pro b/Task/Generate-Chess960-starting-position/Prolog/generate-chess960-starting-position-2.pro deleted file mode 100644 index c89dce15f8..0000000000 --- a/Task/Generate-Chess960-starting-position/Prolog/generate-chess960-starting-position-2.pro +++ /dev/null @@ -1,5 +0,0 @@ -?- generate(X). -X = [♘, ♗, ♖, ♕, ♘, ♔, ♗, ♖] ; -X = [♘, ♗, ♖, ♕, ♘, ♔, ♗, ♖] ; -X = [♘, ♖, ♘, ♕, ♔, ♖, ♗, ♗] ; -X = [♘, ♖, ♘, ♕, ♔, ♖, ♗, ♗] diff --git a/Task/Generate-Chess960-starting-position/PureBasic/generate-chess960-starting-position.basic b/Task/Generate-Chess960-starting-position/PureBasic/generate-chess960-starting-position.basic deleted file mode 100644 index 3a41d96d22..0000000000 --- a/Task/Generate-Chess960-starting-position/PureBasic/generate-chess960-starting-position.basic +++ /dev/null @@ -1,21 +0,0 @@ -OpenConsole() -RandomSeed(Date()) -For i = 1 To 10 - inicio.s = "RKR" - pieza.s = "QNN" - - For n = 1 To Len(pieza) - posic = Random(Len(inicio)) + 1 - inicio = Left(inicio, posic - 1) + Mid(pieza, n, 1) + Right(inicio, Len(inicio) - posic + 1) - Next n - - posic = Random(Len(inicio)) + 1 - inicio = Left(inicio, posic - 1) + "B" + Right(inicio, Len(inicio) - posic + 1) - posic + 1 + 2 * Int(Random(Len(inicio) - posic) / 2) - inicio = Left(inicio, posic - 1) + "B" + Right(inicio, Len(inicio) - posic + 1) - - PrintN(inicio) -Next i - -PrintN(#CRLF$ + "Press ENTER to exit"): Input() -CloseConsole() diff --git a/Task/Generate-Chess960-starting-position/QBasic/generate-chess960-starting-position.basic b/Task/Generate-Chess960-starting-position/QBasic/generate-chess960-starting-position.basic index aa667deeb1..004f9491ad 100644 --- a/Task/Generate-Chess960-starting-position/QBasic/generate-chess960-starting-position.basic +++ b/Task/Generate-Chess960-starting-position/QBasic/generate-chess960-starting-position.basic @@ -1,8 +1,9 @@ -RANDOMIZE TIMER ' DELETE for Run BASIC, Just Basic & Liberty BASIC +RANDOMIZE TIMER FOR i = 1 TO 10 inicio$ = "RKR" pieza$ = "QNN" + 'Dim posic FOR n = 1 TO LEN(pieza$) posic = INT(RND * (LEN(inicio$) + 1)) + 1 diff --git a/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-1.rs b/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-1.rust similarity index 100% rename from Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-1.rs rename to Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-1.rust diff --git a/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-2.rs b/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-2.rust similarity index 100% rename from Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-2.rs rename to Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-2.rust diff --git a/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-3.rs b/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-3.rs deleted file mode 100644 index fc4dda4049..0000000000 --- a/Task/Generate-Chess960-starting-position/Rust/generate-chess960-starting-position-3.rs +++ /dev/null @@ -1,36 +0,0 @@ -use rand::seq::SliceRandom; -use rand::rng; - -fn generate_chess960() -> String { - let mut rng = rng(); - - loop { - let mut pieces = vec!['♛', '♜', '♜', '♜', '♝', '♝', '♞', '♞']; - pieces.shuffle(&mut rng); - - let bishops: Vec = pieces.iter() - .enumerate() - .filter(|&(_, p)| *p == '♝') - .map(|(i, _)| i) - .collect(); - - if bishops.len() == 2 && bishops[0] % 2 != bishops[1] % 2 { - let mut rooks: Vec = pieces.iter() - .enumerate() - .filter(|&(_, p)| *p == '♜') - .map(|(i, _)| i) - .collect(); - - rooks.sort(); // Sort to locate the middle rook - let middle_rook = rooks[1]; // Promote the second rook to King - pieces[middle_rook] = '♚'; // Replace middle rook with King - - return pieces.iter().collect(); - } - } -} - -fn main() { - let position = generate_chess960(); - println!("Chess960 Position: {position}"); -} diff --git a/Task/Generate-Chess960-starting-position/Scheme/generate-chess960-starting-position.scm b/Task/Generate-Chess960-starting-position/Scheme/generate-chess960-starting-position.ss similarity index 100% rename from Task/Generate-Chess960-starting-position/Scheme/generate-chess960-starting-position.scm rename to Task/Generate-Chess960-starting-position/Scheme/generate-chess960-starting-position.ss diff --git a/Task/Generate-Chess960-starting-position/UNIX-Shell/generate-chess960-starting-position.sh b/Task/Generate-Chess960-starting-position/UNIX-Shell/generate-chess960-starting-position.sh deleted file mode 100644 index c669a5172f..0000000000 --- a/Task/Generate-Chess960-starting-position/UNIX-Shell/generate-chess960-starting-position.sh +++ /dev/null @@ -1,23 +0,0 @@ -declare -a pieces=(♖ ♖ ♖ ♕ ♗ ♗ ♘ ♘) -declare -i i pick index -declare -ai picking_history -declare attempt - -until [[ "$attempt" =~ ♗(..)*♗ ]] -do - attempt='' - picking_history=() - for _ in {1..8} - do - while ((picking_history[pick=RANDOM%8]++)) - do : - done - attempt+="${pieces[pick]}" - done -done -for i in {0..7} -do - if [[ "${attempt:i:1}" = ♖ ]] && ((index++)) - then echo "${attempt:0:i}♔${attempt:i+1}"; break; - fi -done diff --git a/Task/Generate-Chess960-starting-position/Wren/generate-chess960-starting-position.wren b/Task/Generate-Chess960-starting-position/Wren/generate-chess960-starting-position.wren index 9f422a956c..1a82f7ebd4 100644 --- a/Task/Generate-Chess960-starting-position/Wren/generate-chess960-starting-position.wren +++ b/Task/Generate-Chess960-starting-position/Wren/generate-chess960-starting-position.wren @@ -1,6 +1,6 @@ import "random" for Random -import "./dynamic" for Tuple -import "./fmt" for Fmt +import "/dynamic" for Tuple +import "/fmt" for Fmt var Symbols = Tuple.create("Symbols", ["k", "q", "r", "b", "n"]) diff --git a/Task/Generate-lower-case-ASCII-alphabet/ANSI-BASIC/generate-lower-case-ascii-alphabet.basic b/Task/Generate-lower-case-ASCII-alphabet/ANSI-BASIC/generate-lower-case-ascii-alphabet.basic deleted file mode 100644 index 900c1e6133..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/ANSI-BASIC/generate-lower-case-ascii-alphabet.basic +++ /dev/null @@ -1,6 +0,0 @@ -10 REM Generate lower case ASCII alphabet -20 FOR I = ORD("a") TO ORD("z") -30 PRINT CHR$(I); -40 NEXT I -50 PRINT -60 END diff --git a/Task/Generate-lower-case-ASCII-alphabet/ASIC/generate-lower-case-ascii-alphabet.asic b/Task/Generate-lower-case-ASCII-alphabet/ASIC/generate-lower-case-ascii-alphabet.asic deleted file mode 100644 index 966349483b..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/ASIC/generate-lower-case-ascii-alphabet.asic +++ /dev/null @@ -1,9 +0,0 @@ -REM Generate lower case ASCII alphabet -Asca = ASC("a") -Ascz = ASC("z") -FOR I = Asca TO Ascz - C$ = CHR$(I) - PRINT C$; -NEXT I -PRINT -END diff --git a/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-1.adb b/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-1.ada similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-1.adb rename to Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-1.ada diff --git a/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-2.adb b/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-2.ada similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-2.adb rename to Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-2.ada diff --git a/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-3.adb b/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-3.ada similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-3.adb rename to Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-3.ada diff --git a/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-4.adb b/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-4.adb deleted file mode 100644 index 49649e5209..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Ada/generate-lower-case-ascii-alphabet-4.adb +++ /dev/null @@ -1,34 +0,0 @@ --- Here is the fleshed-out code using the snippets from above --- Note that I could have enhanced the output by not displaying the last comma --- December 2024, R. B. E. - -with Ada.Text_IO; - -procedure Generate_Lower_Case_ASCII_Alphabet is - --- We start with a strong type definition: A character range that can only hold lower-case letters: - - type Lower_Case is new Character range 'a' .. 'z'; - --- Now we define an array type and initialize the Array A of that type with the 26 letters: - - type Arr_Type is array (Integer range <>) of Lower_Case; - A : Arr_Type (1 .. 26) := "abcdefghijklmnopqrstuvwxyz"; - --- Strong typing would catch two errors: (1) any upper-case letters or --- other symbols in the string assigned to A, and (2) too many or too --- few letters assigned to A. However, a letter might still appear --- twice (or more) in A, at the cost of one or more other --- letters. Array B is safe even against such errors: - - B : Arr_Type (1 .. 26); -begin - B(B'First) := 'a'; - for I in B'First .. B'Last-1 loop - B(I+1) := Lower_Case'Succ(B(I)); - end loop; -- now all the B(I) are different - for I in B'First .. B'Last loop - Ada.Text_IO.Put (B(I)'Image & ", "); - end loop; - Ada.Text_IO.New_Line; -end Generate_Lower_Case_ASCII_Alphabet; diff --git a/Task/Generate-lower-case-ASCII-alphabet/Agena/generate-lower-case-ascii-alphabet.agena b/Task/Generate-lower-case-ASCII-alphabet/Agena/generate-lower-case-ascii-alphabet.agena deleted file mode 100644 index c0fbbad6ef..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Agena/generate-lower-case-ascii-alphabet.agena +++ /dev/null @@ -1,7 +0,0 @@ -# Generate lower case ASCII alphabet -scope - for i from abs('a') to abs('z') do - printf("%c", i) - od - print() -end diff --git a/Task/Generate-lower-case-ASCII-alphabet/ArkScript/generate-lower-case-ascii-alphabet.ark b/Task/Generate-lower-case-ASCII-alphabet/ArkScript/generate-lower-case-ascii-alphabet.ark deleted file mode 100644 index d5b8ef6509..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/ArkScript/generate-lower-case-ascii-alphabet.ark +++ /dev/null @@ -1,9 +0,0 @@ -(import std.String) -(print string:asciiLowercase) - -(mut letters "") -(mut c (string:ord "a")) -(while (<= c (string:ord "z")) { - (set letters (+ letters (string:chr c))) - (set c (+ c 1)) }) -(print letters) diff --git a/Task/Generate-lower-case-ASCII-alphabet/AutoIt/generate-lower-case-ascii-alphabet.au3 b/Task/Generate-lower-case-ASCII-alphabet/AutoIt/generate-lower-case-ascii-alphabet.autoit similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/AutoIt/generate-lower-case-ascii-alphabet.au3 rename to Task/Generate-lower-case-ASCII-alphabet/AutoIt/generate-lower-case-ascii-alphabet.autoit diff --git a/Task/Generate-lower-case-ASCII-alphabet/COBOL/generate-lower-case-ascii-alphabet.cob b/Task/Generate-lower-case-ASCII-alphabet/COBOL/generate-lower-case-ascii-alphabet.cobol similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/COBOL/generate-lower-case-ascii-alphabet.cob rename to Task/Generate-lower-case-ASCII-alphabet/COBOL/generate-lower-case-ascii-alphabet.cobol diff --git a/Task/Generate-lower-case-ASCII-alphabet/Chipmunk-Basic/generate-lower-case-ascii-alphabet.basic b/Task/Generate-lower-case-ASCII-alphabet/Chipmunk-Basic/generate-lower-case-ascii-alphabet.basic deleted file mode 100644 index 3b798e77b9..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Chipmunk-Basic/generate-lower-case-ascii-alphabet.basic +++ /dev/null @@ -1,3 +0,0 @@ -10 for i = asc("a") to asc("z") -20 print chr$(i); -30 next i diff --git a/Task/Generate-lower-case-ASCII-alphabet/Crystal/generate-lower-case-ascii-alphabet.cr b/Task/Generate-lower-case-ASCII-alphabet/Crystal/generate-lower-case-ascii-alphabet.cr deleted file mode 100644 index 6cf0468c43..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Crystal/generate-lower-case-ascii-alphabet.cr +++ /dev/null @@ -1 +0,0 @@ -('a'..'z').to_a # => ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] diff --git a/Task/Generate-lower-case-ASCII-alphabet/Dart/generate-lower-case-ascii-alphabet.dart b/Task/Generate-lower-case-ASCII-alphabet/Dart/generate-lower-case-ascii-alphabet.dart deleted file mode 100644 index c9c95ce88e..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Dart/generate-lower-case-ascii-alphabet.dart +++ /dev/null @@ -1,5 +0,0 @@ -void main() { - List lower = - List.generate(26, (index) => String.fromCharCode(97 + index)); - print(lower); -} diff --git a/Task/Generate-lower-case-ASCII-alphabet/Delphi/generate-lower-case-ascii-alphabet.pas b/Task/Generate-lower-case-ASCII-alphabet/Delphi/generate-lower-case-ascii-alphabet.delphi similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Delphi/generate-lower-case-ascii-alphabet.pas rename to Task/Generate-lower-case-ASCII-alphabet/Delphi/generate-lower-case-ascii-alphabet.delphi diff --git a/Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-1.duckdb b/Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-1.duckdb deleted file mode 100644 index 1fa5db2488..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-1.duckdb +++ /dev/null @@ -1,2 +0,0 @@ -select array_agg(chr(ix::INT) order by ix) as lowercase -from unnest(range(ascii('a'), 1 + ascii('z'))) _(ix); diff --git a/Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-2.duckdb b/Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-2.duckdb deleted file mode 100644 index aab566589e..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-2.duckdb +++ /dev/null @@ -1 +0,0 @@ -select list_transform(generate_series(ascii('a'), ascii('z')), x -> chr(x::INT)) as lowercase; diff --git a/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet-1.easy b/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet-1.easy new file mode 100644 index 0000000000..94375ff0ed --- /dev/null +++ b/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet-1.easy @@ -0,0 +1,3 @@ +for i = 97 to 122 + alphabet$[] &= strchar i +. diff --git a/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet-2.easy b/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet-2.easy new file mode 100644 index 0000000000..cdeb8fe508 --- /dev/null +++ b/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet-2.easy @@ -0,0 +1,3 @@ +for i = 97 to 122 + alphabet$ &= strchar i +. diff --git a/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet.easy b/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet.easy deleted file mode 100644 index 0680e8a6d8..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/EasyLang/generate-lower-case-ascii-alphabet.easy +++ /dev/null @@ -1,10 +0,0 @@ -# Generated on an array -for i = 97 to 122 - alphabet$[] &= strchar i -. -print alphabet$[] -# Generated on a string -for i = 97 to 122 - alphabet$ &= strchar i -. -print alphabet$ diff --git a/Task/Generate-lower-case-ASCII-alphabet/Elena/generate-lower-case-ascii-alphabet.elena b/Task/Generate-lower-case-ASCII-alphabet/Elena/generate-lower-case-ascii-alphabet.elena index 9ad142cc45..5cb866a597 100644 --- a/Task/Generate-lower-case-ASCII-alphabet/Elena/generate-lower-case-ascii-alphabet.elena +++ b/Task/Generate-lower-case-ASCII-alphabet/Elena/generate-lower-case-ascii-alphabet.elena @@ -5,9 +5,9 @@ singleton Alphabet : Enumerable { Enumerator enumerator() = new Enumerator { - char? current; + char current; - get Value() = current; + get() = current; bool next() { @@ -36,7 +36,7 @@ singleton Alphabet : Enumerable }; } -public Program() +public program() { - Console.printLine(Alphabet) + console.printLine(Alphabet) } diff --git a/Task/Generate-lower-case-ASCII-alphabet/Elixir/generate-lower-case-ascii-alphabet.ex b/Task/Generate-lower-case-ASCII-alphabet/Elixir/generate-lower-case-ascii-alphabet.elixir similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Elixir/generate-lower-case-ascii-alphabet.ex rename to Task/Generate-lower-case-ASCII-alphabet/Elixir/generate-lower-case-ascii-alphabet.elixir diff --git a/Task/Generate-lower-case-ASCII-alphabet/Free-Pascal-Lazarus/generate-lower-case-ascii-alphabet.pas b/Task/Generate-lower-case-ASCII-alphabet/Free-Pascal/generate-lower-case-ascii-alphabet.pas similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Free-Pascal-Lazarus/generate-lower-case-ascii-alphabet.pas rename to Task/Generate-lower-case-ASCII-alphabet/Free-Pascal/generate-lower-case-ascii-alphabet.pas diff --git a/Task/Generate-lower-case-ASCII-alphabet/Insitux/generate-lower-case-ascii-alphabet.insitux b/Task/Generate-lower-case-ASCII-alphabet/Insitux/generate-lower-case-ascii-alphabet.insitux deleted file mode 100644 index aaabaf480b..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Insitux/generate-lower-case-ascii-alphabet.insitux +++ /dev/null @@ -1,4 +0,0 @@ -(-> (map char-code "az") - (adj _ inc) - (.. range) - (map char-code)) diff --git a/Task/Generate-lower-case-ASCII-alphabet/Julia/generate-lower-case-ascii-alphabet.jl b/Task/Generate-lower-case-ASCII-alphabet/Julia/generate-lower-case-ascii-alphabet.julia similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Julia/generate-lower-case-ascii-alphabet.jl rename to Task/Generate-lower-case-ASCII-alphabet/Julia/generate-lower-case-ascii-alphabet.julia diff --git a/Task/Generate-lower-case-ASCII-alphabet/Kotlin/generate-lower-case-ascii-alphabet.kts b/Task/Generate-lower-case-ASCII-alphabet/Kotlin/generate-lower-case-ascii-alphabet.kotlin similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Kotlin/generate-lower-case-ascii-alphabet.kts rename to Task/Generate-lower-case-ASCII-alphabet/Kotlin/generate-lower-case-ascii-alphabet.kotlin diff --git a/Task/Generate-lower-case-ASCII-alphabet/M2000-Interpreter/generate-lower-case-ascii-alphabet.m2000 b/Task/Generate-lower-case-ASCII-alphabet/M2000-Interpreter/generate-lower-case-ascii-alphabet.m2000 index d1934f96d8..fe1a6ae9a8 100644 --- a/Task/Generate-lower-case-ASCII-alphabet/M2000-Interpreter/generate-lower-case-ascii-alphabet.m2000 +++ b/Task/Generate-lower-case-ASCII-alphabet/M2000-Interpreter/generate-lower-case-ascii-alphabet.m2000 @@ -1,19 +1,9 @@ \\ old style Basic, including a Binary.Or() function Module OldStyle { 10 LET A$="" - 20 DEF FNUP$(I)=""""+CHR$(BINARY.OR(I, 32))+"""" - 30 FOR I=ASC("A") TO ASC("Y") - 40 LET A$= A$ + FNUP$(I, 32)+", " - 50 NEXT I - 60 LET A$ = A$+ FNUP$(I, 32) - 70 PRINT A$ + 20 FOR I=ASC("A") TO ASC("Z") + 30 LET A$=A$+CHR$(BINARY.OR(I, 32)) + 40 NEXT I + 50 PRINT A$ } CALL OldStyle - -Module new_style { - a=("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z") - map1= lambda ->{push binary.or(asc(letter$), 32)} - map2= lambda ->{push chr$(number)} - Print """"+a#map(map1, map2)#str$({", "})+"""" -} -new_style diff --git a/Task/Generate-lower-case-ASCII-alphabet/MSX-Basic/generate-lower-case-ascii-alphabet.basic b/Task/Generate-lower-case-ASCII-alphabet/MSX-Basic/generate-lower-case-ascii-alphabet.basic deleted file mode 100644 index 303fc9688c..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/MSX-Basic/generate-lower-case-ascii-alphabet.basic +++ /dev/null @@ -1,3 +0,0 @@ -10 FOR I = ASC("a") TO ASC("z") -20 PRINT CHR$(I); -30 NEXT I diff --git a/Task/Generate-lower-case-ASCII-alphabet/Modula-2/generate-lower-case-ascii-alphabet.mod2 b/Task/Generate-lower-case-ASCII-alphabet/Modula-2/generate-lower-case-ascii-alphabet.mod2 deleted file mode 100644 index f5baf60320..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Modula-2/generate-lower-case-ascii-alphabet.mod2 +++ /dev/null @@ -1,12 +0,0 @@ -MODULE GenerASCII; -(* Generate lower case ASCII alphabet *) -FROM STextIO IMPORT - WriteLn, WriteString; -VAR - C: CHAR; -BEGIN - FOR C := "a" TO "z" DO - WriteString(C) - END; - WriteLn -END GenerASCII. diff --git a/Task/Generate-lower-case-ASCII-alphabet/Nu/generate-lower-case-ascii-alphabet.nu b/Task/Generate-lower-case-ASCII-alphabet/Nu/generate-lower-case-ascii-alphabet.nu deleted file mode 100644 index 12911d52da..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Nu/generate-lower-case-ascii-alphabet.nu +++ /dev/null @@ -1 +0,0 @@ -seq char a z diff --git a/Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet-2.ml b/Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet-2.ml deleted file mode 100644 index 16c9e5ae0a..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet-2.ml +++ /dev/null @@ -1 +0,0 @@ -Array.init 26 (fun x -> char_of_int (x + int_of_char 'a')) diff --git a/Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet-1.ml b/Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet.ocaml similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet-1.ml rename to Task/Generate-lower-case-ASCII-alphabet/OCaml/generate-lower-case-ascii-alphabet.ocaml diff --git a/Task/Generate-lower-case-ASCII-alphabet/Objeck/generate-lower-case-ascii-alphabet.objeck b/Task/Generate-lower-case-ASCII-alphabet/Objeck/generate-lower-case-ascii-alphabet.objeck deleted file mode 100644 index dee3ea9202..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Objeck/generate-lower-case-ascii-alphabet.objeck +++ /dev/null @@ -1,7 +0,0 @@ -function : Main(args : String[]) ~ Nil { - buffer := ""; - for(i := 'a'; i <= 'z'; i += 1;) { - buffer += i->As(Char); - }; - buffer->PrintLine(); -} diff --git a/Task/Generate-lower-case-ASCII-alphabet/OxygenBasic/generate-lower-case-ascii-alphabet.basic b/Task/Generate-lower-case-ASCII-alphabet/OxygenBasic/generate-lower-case-ascii-alphabet.basic deleted file mode 100644 index 0b2526c385..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/OxygenBasic/generate-lower-case-ascii-alphabet.basic +++ /dev/null @@ -1,10 +0,0 @@ -uses console - -int i - -for i = asc("a") to asc("z") - print chr(i); -next i - -printl cr "Enter ..." -waitkey diff --git a/Task/Generate-lower-case-ASCII-alphabet/Pascal-P/generate-lower-case-ascii-alphabet.pas b/Task/Generate-lower-case-ASCII-alphabet/Pascal-P/generate-lower-case-ascii-alphabet.pas deleted file mode 100644 index 3c1f1a9575..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Pascal-P/generate-lower-case-ascii-alphabet.pas +++ /dev/null @@ -1,9 +0,0 @@ -program generascii; -(* Generate lower case ASCII alphabet *) -var - c: char; -begin - for c := 'a' to 'z' do - write(c); - writeln -end. diff --git a/Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas b/Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas deleted file mode 100644 index ab01a49532..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas +++ /dev/null @@ -1,5 +0,0 @@ -## -var a := Arr('a'..'z'); -a.Println; -var s := ('a'..'z').JoinToString(' ');; -s.Println diff --git a/Task/Generate-lower-case-ASCII-alphabet/Pluto/generate-lower-case-ascii-alphabet.pluto b/Task/Generate-lower-case-ASCII-alphabet/Pluto/generate-lower-case-ascii-alphabet.pluto deleted file mode 100644 index 13f79e979b..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Pluto/generate-lower-case-ascii-alphabet.pluto +++ /dev/null @@ -1,4 +0,0 @@ -alpha = range(97,122) - :reduce(|a,v|->a..string.char(v),"") - -print(alpha) diff --git a/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-1.ps1 b/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-1.psh similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-1.ps1 rename to Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-1.psh diff --git a/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-2.ps1 b/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-2.psh similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-2.ps1 rename to Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-2.psh diff --git a/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-3.ps1 b/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-3.psh similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-3.ps1 rename to Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-3.psh diff --git a/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-4.ps1 b/Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-4.psh similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-4.ps1 rename to Task/Generate-lower-case-ASCII-alphabet/PowerShell/generate-lower-case-ascii-alphabet-4.psh diff --git a/Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet-2.rs b/Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet-2.rs deleted file mode 100644 index e73620e114..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet-2.rs +++ /dev/null @@ -1 +0,0 @@ -'a'..='z' diff --git a/Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet-1.rs b/Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet.rust similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet-1.rs rename to Task/Generate-lower-case-ASCII-alphabet/Rust/generate-lower-case-ascii-alphabet.rust diff --git a/Task/Generate-lower-case-ASCII-alphabet/Scheme/generate-lower-case-ascii-alphabet.scm b/Task/Generate-lower-case-ASCII-alphabet/Scheme/generate-lower-case-ascii-alphabet.ss similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/Scheme/generate-lower-case-ascii-alphabet.scm rename to Task/Generate-lower-case-ASCII-alphabet/Scheme/generate-lower-case-ascii-alphabet.ss diff --git a/Task/Generate-lower-case-ASCII-alphabet/VBScript/generate-lower-case-ascii-alphabet.vbs b/Task/Generate-lower-case-ASCII-alphabet/VBScript/generate-lower-case-ascii-alphabet.vb similarity index 100% rename from Task/Generate-lower-case-ASCII-alphabet/VBScript/generate-lower-case-ascii-alphabet.vbs rename to Task/Generate-lower-case-ASCII-alphabet/VBScript/generate-lower-case-ascii-alphabet.vb diff --git a/Task/Generate-lower-case-ASCII-alphabet/X86-64-Assembly/generate-lower-case-ascii-alphabet-1.x86-64 b/Task/Generate-lower-case-ASCII-alphabet/X86-64-Assembly/generate-lower-case-ascii-alphabet-1.x86-64 deleted file mode 100644 index b684ad0215..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/X86-64-Assembly/generate-lower-case-ascii-alphabet-1.x86-64 +++ /dev/null @@ -1,30 +0,0 @@ -; compile with: -; nasm -f elf64 alpha.asm -o alpha.o -; ld -z noexecstack -no-pie -s alpha.o -o alpha - -global _start - -section .text -_start: - xor rax, rax - .loop: - mov dil, 'a' ;Our character - add dil, al ;add number in rax/al - mov byte[alphabet + rax], dil ;store character to memory - inc rax ;increment rax - cmp rax, 26 ;is rax less than 26? - jl .loop ;yes? jump to .loop - .print: - mov byte[alphabet + rax], 0x0a ;Make the last character an lf. - mov rax, 1 ;write to - mov rdi, 1 ;stdout - mov rsi, alphabet ;pointer to string - mov rdx, 27 ;the number of characters - syscall ;print it! - .exit: - mov rax, 60 ;exit - xor rdi, rdi ;exit code zero - syscall - -section .bss -alphabet: resb 27 diff --git a/Task/Generate-lower-case-ASCII-alphabet/X86-64-Assembly/generate-lower-case-ascii-alphabet-2.x86-64 b/Task/Generate-lower-case-ASCII-alphabet/X86-64-Assembly/generate-lower-case-ascii-alphabet-2.x86-64 deleted file mode 100644 index fd17eea75d..0000000000 --- a/Task/Generate-lower-case-ASCII-alphabet/X86-64-Assembly/generate-lower-case-ascii-alphabet-2.x86-64 +++ /dev/null @@ -1,26 +0,0 @@ -format ELF64 executable 3 -entry begin - -segment executable readable -begin: - mov rcx, 26 - mov rdi, alphabet - mov rax, 'a' - .loop0: - stosb - inc rax - loop .loop0 - mov byte[alphabet + 26], 0x0a - .print0: - mov rax, 1 - mov rdi, 1 - mov rsi, alphabet - mov rdx, 27 - syscall - .end: - mov rax, 60 - xor rdi, rdi - syscall - -segment readable writeable -alphabet: rb 27 diff --git a/Task/Generate-random-chess-position/11l/generate-random-chess-position.11l b/Task/Generate-random-chess-position/11l/generate-random-chess-position.11l index 4057f2ceee..8ccdb42c45 100644 --- a/Task/Generate-random-chess-position/11l/generate-random-chess-position.11l +++ b/Task/Generate-random-chess-position/11l/generate-random-chess-position.11l @@ -17,7 +17,7 @@ F pawn_on_promotion_square(pc, pr) R 0B F populate_board(&brd, wp, bp) - L(x) 0.<2 + L(x) 2 Int piece_amount [Char] pieces I x == 0 diff --git a/Task/Generate-random-chess-position/Crystal/generate-random-chess-position.cr b/Task/Generate-random-chess-position/Crystal/generate-random-chess-position.crystal similarity index 100% rename from Task/Generate-random-chess-position/Crystal/generate-random-chess-position.cr rename to Task/Generate-random-chess-position/Crystal/generate-random-chess-position.crystal diff --git a/Task/Generate-random-chess-position/Emacs-Lisp/generate-random-chess-position.el b/Task/Generate-random-chess-position/Emacs-Lisp/generate-random-chess-position.el deleted file mode 100644 index 72f1823100..0000000000 --- a/Task/Generate-random-chess-position/Emacs-Lisp/generate-random-chess-position.el +++ /dev/null @@ -1,2 +0,0 @@ -(require 'chess) -(chess-pos-to-fen (chess-fischer-random-position)) diff --git a/Task/Generate-random-chess-position/FutureBasic/generate-random-chess-position.basic b/Task/Generate-random-chess-position/FutureBasic/generate-random-chess-position.basic index 5c89119267..900804d30a 100644 --- a/Task/Generate-random-chess-position/FutureBasic/generate-random-chess-position.basic +++ b/Task/Generate-random-chess-position/FutureBasic/generate-random-chess-position.basic @@ -1,145 +1,117 @@ -_window = 1 -begin enum 1 - _view - _label -end enum +begin globals +short grid(8, 8) // 1-8 +end globals -void local fn BuildWindow - window _window, @"Generate random chess position", (0,0,360,400), NSWindowStyleMaskTitled - subclass view _view, (20,60,320,320) - textlabel _label,, (20,20,320,16) - ControlSetSize( _label, NSControlSizeSmall ) -end fn -void local fn ToFen - short ch, r, c, countEmpty = 0 - CFStringRef pieceStr = NULL, fen = @"" - long x = 0, y = 280 - - for r = 1 to 8 - for c = 1 to 8 - ch = mda(r,c) - select (ch) - case _"k" : pieceStr = @"♚" // Black King - case _"K" : pieceStr = @"♔" // White King - - case _"p" : pieceStr = @"♟" // Black Pawn - case _"P" : pieceStr = @"♙" // White Pawn - - case _"r" : pieceStr = @"♜" // Black Rook - case _"R" : pieceStr = @"♖" // White Rook - - case _"n" : pieceStr = @"♞" // Black Knight - case _"N" : pieceStr = @"♘" // White Knight - - case _"b" : pieceStr = @"♝" // Black Bishop - case _"B" : pieceStr = @"♗" // White Bishop - - case _"q" : pieceStr = @"♛" // Black Queen - case _"Q" : pieceStr = @"♕" // White Queen - end select - - if ( ch ) - x = (c-1) * 40 - y = 280 - ((r-1) * 40) - CFMutableAttributedStringRef aString = fn MutableAttributedStringWithString( pieceStr ) - MutableAttributedStringSetFontWithName( aString, @"Menlo", 36 ) - MutableAttributedStringSetAlignment( aString, NSTextAlignmentCenter ) - AttributedStringDrawInRect( aString, fn CGRectMake(x,y,40,40) ) - end if - - if ( ch == 0 ) - countEmpty++ - else - if ( countEmpty > 0 ) - fen = concat( fen, @(countEmpty) ) - - countEmpty = 0 - end if - fen = concat( fen, ucs(ch) ) - end if - next - - if ( countEmpty > 0 ) - fen = concat( fen, @(countEmpty) ) - countEmpty = 0 - end if - fen = concat( fen, @"/" ) - next - - fen = concat( fen, @" w - - 0 1" ) - textlabel _label, fen -end fn - -void local fn DrawBoard( tag as long ) - CGRect r = fn ViewBounds(tag) - BezierPathFillRect( r, fn ColorWhite ) - CGFloat x = 0, y = 0 - long i, j - for j = 1 to 8 - for i = 1 to 8 step 2 - BezierPathFillRect( fn CGRectMake( x, y, 40, 40 ), fn ColorLightGray ) - x += 80 - next - y += 40 - if ( j % 2 == 0 ) - x = 0 - else - x = 40 - end if - next - BezierPathStrokeRect( r, 3.0, fn ColorGray ) - fn ToFen -end fn - -void local fn PlaceKings +local fn PlaceKings short r1, r2, c1, c2 + while (YES) r1 = rnd(8) c1 = rnd(8) r2 = rnd(8) c2 = rnd(8) - if ( abs( r1 - r2 ) > 1 || abs( c1 - c2) > 1 ) - mda(r1,c2) = _"K" - mda(r2,c2) = _"k" - return + if ( abs( r1 - r2 ) > 1 or abs( c1 - c2) > 1 ) + grid(r1, c1) = asc("K") + grid(r2, c2) = asc("k") + exit fn end if wend end fn -void local fn PlacePieces( pieces as CFStringRef, isPawn as BOOL ) + +local fn PlacePieces( pieces$ as Str255, isPawn as BOOL ) short n, r, c, numToPlace - numToPlace = rnd( len(pieces) ) + + numToPlace = rnd( len$(pieces$) ) for n = 1 to numToPlace do r = rnd(8) c = rnd(8) - if ( isPawn == YES && fn StringIsEqual( mid(pieces,n-1,1), @"p" ) && r == 8 ) then return - if ( isPawn == YES && fn StringIsEqual( mid(pieces,n-1,1), @"P" ) && r == 1 ) then return - until !( ( mda(r,c) != 0 ) || ( isPawn && ( r == 8 || r == 1 ) ) ) - mda(r,c) = ucc( mid(pieces,n-1,1) ) + if isPawn == YES and mid$( pieces$, n, 1 ) == "p" and r = 8 then exit fn + if isPawn == YES and mid$( pieces$, n, 1 ) == "P" and r = 1 then exit fn + until not( ( grid(r, c) != 0 ) or ( isPawn and ( r == 8 or r == 1 ) ) ) + grid(r, c) = asc( mid$( pieces$, n, 1 ) ) next end fn -void local fn CreateFen - fn PlaceKings - fn PlacePieces( @"PPPPPPPP", YES ) - fn PlacePieces( @"pppppppp", YES ) - fn PlacePieces( @"RNBQBNR", NO ) - fn PlacePieces( @"rnbqbnr", NO ) + +local fn ToFen + Str255 fen$ + short ch, r, c, countEmpty = 0 + CFStringRef pieceStr + + for r = 1 to 8 + for c = 1 to 8 + ch = grid(r, c) + + select (ch) + + case 107 : pieceStr = @" ♚" // Black King + case 75 : pieceStr = @" ♔" // White King + + case 112 : pieceStr = @" ♟" // Black Pawn + case 80 : pieceStr = @" ♙" // White Pawn + + case 114 : pieceStr = @" ♜" // Black Rook + case 82 : pieceStr = @" ♖" // White Rook + + case 110 : pieceStr = @" ♞" // Black Knight + case 78 : pieceStr = @" ♘" // White Knight + + case 98 : pieceStr = @" ♝" // Black Bishop + case 66 : pieceStr = @" ♗" // White Bishop + + case 113 : pieceStr = @" ♛" // Black Queen + case 81 : pieceStr = @" ♕" // White Queen + + end select + + if ( ch ) + print pieceStr, + else + print @" .", + end if + if ( ch == 0 ) + countEmpty++ + else + if ( countEmpty > 0 ) + fen$ = fen$ + chr$(countEmpty + 48) + countEmpty = 0 + end if + fen$ = fen$ + chr$(ch) + end if + next + if ( countEmpty > 0 ) + fen$ = fen$ + chr$(countEmpty + 48) + countEmpty = 0 + end if + fen$ = fen$ + "/" + print + next + fen$ = fen$ + " w - - 0 1" + fen$ = mid$( fen$, 8, len$(fen$) ) + print + text @"Menlo", 14, fn ColorText, fn ColorClear, NSTextAlignmentLeft, 10 + print fen$ end fn -void local fn DoDialog( ev as long, tag as long ) - select ( ev ) - case _viewDrawRect : fn DrawBoard( tag ) - end select +local fn CreateFen + fn PlaceKings + fn PlacePieces( "PPPPPPPP", YES ) + fn PlacePieces( "pppppppp", YES ) + fn PlacePieces( "RNBQBNR", NO ) + fn PlacePieces( "rnbqbnr", NO ) + fn ToFen end fn + randomize -fn BuildWindow +window 1, @"Random Chess Position", ( 0, 0, 700, 400 ) + +text @"Menlo", 32, fn ColorText, fn ColorClear, NSTextAlignmentLeft, 10 + fn CreateFen -on dialog fn DoDialog - HandleEvents diff --git a/Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq b/Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq deleted file mode 100644 index 56cc2d10dd..0000000000 --- a/Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq +++ /dev/null @@ -1,94 +0,0 @@ -### Pseuo-random numbers - -# Output: a prn in range(0;$n) where $n is `.` -def prn: - if . == 1 then 0 - else . as $n - | ([1, (($n-1)|tostring|length)]|max) as $w - | [limit($w; inputs)] | join("") | tonumber - | if . < $n then . else ($n | prn) end - end; - -def sample: - if length == 0 # e.g. null or [] - then null - else .[length|prn] - end; - -def randFloat: - (1000|prn) / 1000; - -### Chess - -def isEmpty: . == "." or . == "•"; - -def grid: - [range(0;4) | (".","•") ] as $black - | [range(0;4) | ("•", ".")] as $white - | [range(0;4) | ($black, $white)] ; - -# input: {grid} -def placeKings: - .done = false - | until(.done; - [8 | prn, prn, prn, prn] as [$r1, $c1, $r2, $c2] - | if $r1 != $r2 and (($r1 - $r2)|length) > 1 and (($c1 - $c2)|length) > 1 - then .grid[$r1][$c1] = "K" - | .grid[$r2][$c2] = "k" - | .done = true - else . - end ) - | del(.done); - -# input: {grid} -def placePieces($pieces; $isPawn): - ($pieces|length|prn) as $numToPlace - | .n = -1 - | until(.n == $numToPlace; - .n += 1 - | .done = false - | until(.done; - .r = (8 | prn) - | .c = (8 | prn) - | if (.grid[.r][.c] | isEmpty) and (($isPawn and (.r == 7 or .r == 0))|not) - then .done = true - else . - end ) - | .grid[.r][.c] = $pieces[.n:.n+1] ) ; - -def toFen: - { grid, - fen: "", - countEmpty: 0 } - | reduce range (0;8) as $r (.; - reduce range(0;8) as $c (.; - .grid[$r][$c] as $ch - | .emit += " \($ch) " - | if ($ch | isEmpty) - then .countEmpty += 1 - else - if .countEmpty > 0 - then .fen += (.countEmpty|tostring) - | .countEmpty = 0 - end - | .fen += $ch - end ) - | if .countEmpty > 0 - then .fen += (.countEmpty|tostring) - | .countEmpty = 0 - end - | .fen += "/" - | .emit += "\n" ) - | .emit, - .fen + " w - - 0 1" ; - -def createFen: - {grid: grid} - | placeKings - | placePieces("PPPPPPPP"; true) - | placePieces("pppppppp"; true) - | placePieces("RNBQBNR"; false) - | placePieces("rnbqbnr"; false) - | toFen; - -createFen diff --git a/Task/Generate-random-chess-position/Julia/generate-random-chess-position-1.jl b/Task/Generate-random-chess-position/Julia/generate-random-chess-position-1.julia similarity index 100% rename from Task/Generate-random-chess-position/Julia/generate-random-chess-position-1.jl rename to Task/Generate-random-chess-position/Julia/generate-random-chess-position-1.julia diff --git a/Task/Generate-random-chess-position/Julia/generate-random-chess-position-2.jl b/Task/Generate-random-chess-position/Julia/generate-random-chess-position-2.julia similarity index 100% rename from Task/Generate-random-chess-position/Julia/generate-random-chess-position-2.jl rename to Task/Generate-random-chess-position/Julia/generate-random-chess-position-2.julia diff --git a/Task/Generate-random-chess-position/Kotlin/generate-random-chess-position.kts b/Task/Generate-random-chess-position/Kotlin/generate-random-chess-position.kotlin similarity index 100% rename from Task/Generate-random-chess-position/Kotlin/generate-random-chess-position.kts rename to Task/Generate-random-chess-position/Kotlin/generate-random-chess-position.kotlin diff --git a/Task/Generate-random-chess-position/Lua/generate-random-chess-position.lua b/Task/Generate-random-chess-position/Lua/generate-random-chess-position.lua deleted file mode 100644 index 34b1efa33e..0000000000 --- a/Task/Generate-random-chess-position/Lua/generate-random-chess-position.lua +++ /dev/null @@ -1,191 +0,0 @@ --- Seed the random number generator with the current system time -math.randomseed(os.time()) - --- Define a `Helper` table to store utility functions -local Helper = {} - --- Create a 1D table (array) filled with the same value ---- @param len number number of elements ---- @param val any value to fill each element with -function Helper.newFilledTable(len, val) - local t = {} - - for i = 1, len do - t[i] = val - end - - return t -end - --- Create a 2D table (rows x cols) initialized with a given value ----@param rows number number of rows ----@param cols number number of columns ----@param init any initial value for each cell -function Helper.new2D(rows, cols, init) - local b = {} - - for r = 1, rows do - b[r] = {} - for c = 1, cols do - b[r][c] = init - end - end - - return b -end - --- Compare two tables element by element for equality --- Works only for flat 1D arrays -function Helper.tablesEqual(tbl1, tbl2) - if #tbl1 ~= #tbl2 then - error("Tables must have equal length") - end - if #tbl1 == 0 and #tbl2 == 0 then - return true - end - - for i = 1, #tbl1 do - if tbl1[i] ~= tbl2[i] then - return false - end - end - return true -end - --- Initialise an 8x8 chess board (empty, filled with nils) -local board = Helper.new2D(8, 8, nil) - --- Place white and black kings randomly on the board --- Ensures: --- 1. They are not on the same square --- 2. They are not adjacent (Chebyshev distance > 1) -local function placeKings(board) - local attempts = 0 - - while true do - attempts = attempts + 1 - if attempts > 10000 then - error("Failed to place kings after many attempts") - end - - -- Random row and column for each king - local wr = math.random(1, 8) - local wc = math.random(1, 8) - local br = math.random(1, 8) - local bc = math.random(1, 8) - local skip1 = false - local skip2 = false - - -- Ensure kings are not on the same square - if wr == br and wc == bc then - skip1 = true - end - - if not skip1 then - -- Check Chebyshev distance (max of row/col difference) - local dr = math.abs(wr-br) - local dc = math.abs(wc-bc) - local chebyshev = (dr > dc) and dr or dc - - -- Skip if kings are adjacent - if chebyshev <= 1 then - skip2 = true - end - - -- Place kings if squares are empty and valid - if not skip2 then - if not board[wr][wc] and not board[br][bc] then - board[wr][wc] = "K" -- White king - board[br][bc] = "k" -- Black king - return - end - end - end - end -end - --- Populate the board with a given set of pieces ----@param board table board ----@param pieces string string of piece characters (e.g. "PPPPPPPP") ----@param isPawn boolean boolean, true if placing pawns (to avoid ranks 1 and 8) -local function populate(board, pieces, isPawn) - local piecesAmount = #pieces - - for i = 1, piecesAmount do - local pieceChar = pieces:sub(i, i) - local attempts = 0 - - while true do - attempts = attempts + 1 - if attempts > 5000 then - error("Failed to place piece "..pieceChar) - end - - -- Choose a random square - local r = math.random(1, 8) - local c = math.random(1, 8) - - if board[r][c] then - -- Skip if already occupied - else - -- Prevent pawns on promotion ranks (1 or 8) - if isPawn and (r == 1 or r == 8) then - else - board[r][c] = pieceChar - break - end - end - end - end -end - --- Convert the board into Forsyth-Edwards Notation (FEN) --- Only encodes piece placement and default values for side-to-move, castling, etc. -local function toFENFormat(board) - local result = "" - - -- Loop through ranks 8 to 1 (FEN goes top-down) - for r = 8, 1, -1 do - local emptyCount = 0 - - for c = 1, 8 do - local row = board[r] - local ch = row and row[c] - - if not ch then - -- Count consecutive empty squares - emptyCount = emptyCount + 1 - else - -- Insert number for empty squares, then piece - if emptyCount > 0 then - result = result .. tostring(emptyCount) - emptyCount = 0 - end - result = result .. tostring(ch) - end - end - - -- Handle trailing empty squares in row - if emptyCount > 0 then - result = result .. tostring(emptyCount) - end - - -- Add rank separator except for last row - if r > 1 then - result = result .. "/" - end - end - - -- Append default FEN suffix ("w - - 0 1") - return result .. " w - - 0 1" -end - --- Main function -- - -placeKings(board) -populate(board, "PPPPPPPP", true) -populate(board, "pppppppp", true) -populate(board, "RNBQBNR", false) -populate(board, "rnbqbnr", false) - -print(toFENFormat(board)) diff --git a/Task/Generate-random-chess-position/Rust/generate-random-chess-position.rs b/Task/Generate-random-chess-position/Rust/generate-random-chess-position.rust similarity index 100% rename from Task/Generate-random-chess-position/Rust/generate-random-chess-position.rs rename to Task/Generate-random-chess-position/Rust/generate-random-chess-position.rust diff --git a/Task/Generate-random-chess-position/V-(Vlang)/generate-random-chess-position.v b/Task/Generate-random-chess-position/V-(Vlang)/generate-random-chess-position.v deleted file mode 100644 index abf04e89b0..0000000000 --- a/Task/Generate-random-chess-position/V-(Vlang)/generate-random-chess-position.v +++ /dev/null @@ -1,79 +0,0 @@ -import rand -import math - -const nul = u8(0) - -struct Game { - mut: - grid [][]u8 = [][]u8{len: 8, init: []u8{len: 8, init: nul}} -} - -fn (mut gme Game) create_fen() string { - gme.place_kings() - gme.place_pieces("PPPPPPPP", true) - gme.place_pieces("pppppppp", true) - gme.place_pieces("RNBQBNR", false) - gme.place_pieces("rnbqbnr", false) - return gme.to_fen() -} - -fn (mut gme Game) place_kings() { - for { - r1 := rand.intn(8) or {0} - c1 := rand.intn(8) or {0} - r2 := rand.intn(8) or {0} - c2 := rand.intn(8) or {0} - if r1 != r2 && math.abs(r1 - r2) > 1 && math.abs(c1 - c2) > 1 { - gme.grid[r1][c1] = `K` - gme.grid[r2][c2] = `k` - return - } - } -} - -fn (mut gme Game) place_pieces(pieces string, is_pawn bool) { - num_to_place := rand.intn(pieces.len) or {0} - mut rir, mut cir := 0, 0 - for nal in 0 .. num_to_place { - rir = 0 - cir = 0 - for { - rir = rand.intn(8) or {0} - cir = rand.intn(8) or {0} - if gme.grid[rir][cir] == nul && !(is_pawn && (rir == 0 || rir == 7)) { break } - } - gme.grid[rir][cir] = pieces[nal] - } -} - -fn (gme Game) to_fen() string { - mut fen := "" - mut count_empty := 0 - for rir in 0 .. 8 { - for cir in 0 .. 8 { - ch := gme.grid[rir][cir] - print(if ch == nul { "." } else { ch.ascii_str() } + " ") - if ch == nul { count_empty++ } - else { - if count_empty > 0 { - fen += count_empty.str() - count_empty = 0 - } - fen += ch.ascii_str() - } - } - if count_empty > 0 { - fen += count_empty.str() - count_empty = 0 - } - fen += "/" - println("") - } - fen += " w - - 0 1" - return fen -} - -fn main() { - mut game := Game{} - println(game.create_fen()) -} diff --git a/Task/Generate-random-chess-position/Wren/generate-random-chess-position.wren b/Task/Generate-random-chess-position/Wren/generate-random-chess-position.wren index d81ee05b17..94b7db5e77 100644 --- a/Task/Generate-random-chess-position/Wren/generate-random-chess-position.wren +++ b/Task/Generate-random-chess-position/Wren/generate-random-chess-position.wren @@ -1,5 +1,5 @@ import "random" for Random -import "./fmt" for Fmt +import "/fmt" for Fmt var rand = Random.new() diff --git a/Task/Generator-Exponential/Ada/generator-exponential-1.adb b/Task/Generator-Exponential/Ada/generator-exponential-1.ada similarity index 100% rename from Task/Generator-Exponential/Ada/generator-exponential-1.adb rename to Task/Generator-Exponential/Ada/generator-exponential-1.ada diff --git a/Task/Generator-Exponential/Ada/generator-exponential-2.adb b/Task/Generator-Exponential/Ada/generator-exponential-2.ada similarity index 100% rename from Task/Generator-Exponential/Ada/generator-exponential-2.adb rename to Task/Generator-Exponential/Ada/generator-exponential-2.ada diff --git a/Task/Generator-Exponential/Ada/generator-exponential-3.adb b/Task/Generator-Exponential/Ada/generator-exponential-3.ada similarity index 100% rename from Task/Generator-Exponential/Ada/generator-exponential-3.adb rename to Task/Generator-Exponential/Ada/generator-exponential-3.ada diff --git a/Task/Generator-Exponential/Ada/generator-exponential-4.adb b/Task/Generator-Exponential/Ada/generator-exponential-4.ada similarity index 100% rename from Task/Generator-Exponential/Ada/generator-exponential-4.adb rename to Task/Generator-Exponential/Ada/generator-exponential-4.ada diff --git a/Task/Generator-Exponential/Ada/generator-exponential-5.adb b/Task/Generator-Exponential/Ada/generator-exponential-5.ada similarity index 100% rename from Task/Generator-Exponential/Ada/generator-exponential-5.adb rename to Task/Generator-Exponential/Ada/generator-exponential-5.ada diff --git a/Task/Generator-Exponential/Crystal/generator-exponential.cr b/Task/Generator-Exponential/Crystal/generator-exponential.cr deleted file mode 100644 index 4c83a5799f..0000000000 --- a/Task/Generator-Exponential/Crystal/generator-exponential.cr +++ /dev/null @@ -1,20 +0,0 @@ -require "big" - -def powers (power) - (0.to_big_i..).each.map {|n| n ** power } -end - -def filtered (iter1, iter2) - next_skipped = iter2.next - iter1.reject { |n| - while (ns = next_skipped) && ns.is_a?(Number) && n > ns - next_skipped = iter2.next - end - n == next_skipped - } -end - -squares = powers 2 -cubes = powers 3 - -p filtered(squares, cubes).skip(20).first(10).to_a diff --git a/Task/Generator-Exponential/Delphi/generator-exponential.pas b/Task/Generator-Exponential/Delphi/generator-exponential.delphi similarity index 100% rename from Task/Generator-Exponential/Delphi/generator-exponential.pas rename to Task/Generator-Exponential/Delphi/generator-exponential.delphi diff --git a/Task/Generator-Exponential/Elixir/generator-exponential.ex b/Task/Generator-Exponential/Elixir/generator-exponential.elixir similarity index 100% rename from Task/Generator-Exponential/Elixir/generator-exponential.ex rename to Task/Generator-Exponential/Elixir/generator-exponential.elixir diff --git a/Task/Generator-Exponential/Emacs-Lisp/generator-exponential.el b/Task/Generator-Exponential/Emacs-Lisp/generator-exponential.l similarity index 100% rename from Task/Generator-Exponential/Emacs-Lisp/generator-exponential.el rename to Task/Generator-Exponential/Emacs-Lisp/generator-exponential.l diff --git a/Task/Generator-Exponential/Icon/generator-exponential-2.icon b/Task/Generator-Exponential/Icon/generator-exponential-2.icon deleted file mode 100644 index 75b6573b1b..0000000000 --- a/Task/Generator-Exponential/Icon/generator-exponential-2.icon +++ /dev/null @@ -1,9 +0,0 @@ -procedure noncubesquares() #: filter for squares that aren't cubes - cu := create mthpower(3) - c := @cu - every s := mthpower(2) do{ - if s > c then c := @cu - if s == c then next - suspend s - } -end diff --git a/Task/Generator-Exponential/Icon/generator-exponential-1.icon b/Task/Generator-Exponential/Icon/generator-exponential.icon similarity index 100% rename from Task/Generator-Exponential/Icon/generator-exponential-1.icon rename to Task/Generator-Exponential/Icon/generator-exponential.icon diff --git a/Task/Generator-Exponential/Julia/generator-exponential.jl b/Task/Generator-Exponential/Julia/generator-exponential.julia similarity index 100% rename from Task/Generator-Exponential/Julia/generator-exponential.jl rename to Task/Generator-Exponential/Julia/generator-exponential.julia diff --git a/Task/Generator-Exponential/Kotlin/generator-exponential.kts b/Task/Generator-Exponential/Kotlin/generator-exponential.kotlin similarity index 100% rename from Task/Generator-Exponential/Kotlin/generator-exponential.kts rename to Task/Generator-Exponential/Kotlin/generator-exponential.kotlin diff --git a/Task/Generator-Exponential/OCaml/generator-exponential.ml b/Task/Generator-Exponential/OCaml/generator-exponential.ocaml similarity index 100% rename from Task/Generator-Exponential/OCaml/generator-exponential.ml rename to Task/Generator-Exponential/OCaml/generator-exponential.ocaml diff --git a/Task/Generator-Exponential/PascalABC.NET/generator-exponential.pas b/Task/Generator-Exponential/PascalABC.NET/generator-exponential.pas deleted file mode 100644 index 845617ebf1..0000000000 --- a/Task/Generator-Exponential/PascalABC.NET/generator-exponential.pas +++ /dev/null @@ -1,6 +0,0 @@ -## -var ms: integer -> sequence of BigInteger := m -> 0.Step.Select(i -> BigInteger(i)**m); -var squares := ms(2); -var cubes := ms(3); -var filtered := squares.Where(square -> cubes.First(cube -> cube >= square) <> square); -filtered.Skip(20).Take(10).Println; diff --git a/Task/Generator-Exponential/Phix/generator-exponential.phix b/Task/Generator-Exponential/Phix/generator-exponential.phix index a0131eca25..b57c7cae54 100644 --- a/Task/Generator-Exponential/Phix/generator-exponential.phix +++ b/Task/Generator-Exponential/Phix/generator-exponential.phix @@ -1,40 +1,47 @@ --- demo\rosetta\Generator_Exponential.exw -without js -- tasks +(notonline)--> + -- + -- demo\rosetta\Generator_Exponential.exw + -- ====================================== + -- + without js -- tasks + bool terminate = false -atom res -bool terminate = false + atom res -procedure powers(integer p) - integer i = 0 - while not terminate do - res = power(i,p) - task_suspend(task_self()) - task_yield() - i += 1 - end while -end procedure + procedure powers(integer p) + integer i=0 + while not terminate do + res = power(i,p) + task_suspend(task_self()) + task_yield() + i += 1 + end while + end procedure -constant squares = task_create(powers,{2}), - cubes = task_create(powers,{3}) + constant squares = task_create(powers,{2}), + cubes = task_create(powers,{3}) -atom square, cube -task_schedule(cubes,1) -task_yield() -cube = res -sequence snq = {} -for i=1 to 30 do - do - task_schedule(squares,1) - task_yield() - square = res - while cube20 then snq &= square end if -end for -?snq -terminate = 1 -wait_key() + atom square, cube + task_schedule(cubes,1) + task_yield() + cube = res + for i=1 to 30 do + while 1 do + task_schedule(squares,1) + task_yield() + square = res + while cube<square do + task_schedule(cubes,1) + task_yield() + cube = res + end while + if square!=cube then exit end if + end while + if i>20 then + ?square + end if + end for + + terminate = 1 + {} = wait_key() + Get the size of the Main Screen. <--- - CGRect mainScreenFrame = fn ScreenMainFrame - float msh = mainScreenFrame.size.height - CGRect r = fn CGRectMake( 0, 0, 600, int(msh) - 110) - - window 1, @"Go Fish", r - windowcenter(1) - WindowSetBackgroundColor(1,fn ColorBlack) - -end fn - -//--- Start --- - -fn BuildWindow - -fn Intro - -fn InitCards - -str255 AddTheS -bool RequestCard = _false -short v = 0 -short po = 0 -boolean ShowHand = _false -str255 WantsCard - -"Main" - -ShowHand = _false - -str255 RequestedCard - -While ShowHand = _false - text ,,fn colorGreen - Print Chr$(10) + "Points >> "; - text ,,fn colorYellow - print YourName + ": "; - text ,,fn colorGreen - print Points(0); - text ,,fn colorOrange - print " CPU: "; - text ,,fn colorGreen - print Points(1) - text ,,fn colorWhite - Print Chr$(10) + " " + str$(RemainingCards) + " remaining cards" - text ,,fn colorWhite - - - /* - // Uncomment this to see the CPUs cards For testing - Print Chr$(10) + "CPU Cards: "; - For i = 1 To 13 - if Computer(i) <> 0 - For j = 1 To Computer(i) - if Mid$(cards,i,1) = "0" - Print @"10"; " "; - else - Print Mid$(cards,i,1); " "; - end if - Next j - End If - Next i - Print - fn PrintViewScrollToBottom( fn WindowPrintView(1)) - */ - - - Print Chr$(10) + "Your Cards: "; - For i = 1 To 13 - if play(i) <> 0 - For j = 1 To play(i) - if Mid$(cards,i,1) = "0" - Print @"10"; " "; - else - Print Mid$(cards,i,1); " "; - end if - Next j - End If - Next i - Print - fn PrintViewScrollToBottom( fn WindowPrintView(1)) - - RequestCard = _false - - While RequestCard = _false - if fn CheckForEndGame = _True then cls:fn InitCards:goto "Loop" - - Someone = YourName - - CFStringRef UserInput = 0 - "InputCard" - UserInput = input % (20, fn WhatCardInputHeight),@"What card do you want? " - if ( UserInput == NULL ) then "InputCard" // Rich added this 5/1/24 - fn CFStringGetPascalString (UserInput, @RequestedCard, 256, _kCFStringEncodingMacRoman) - if RequestedCard = "10" then RequestedCard = "0"// card zero is a 10 - text ,,fn ColorYellow - Print - - WantsCard = RequestedCard - - if WantsCard = "j" || WantsCard = "J" then WantsCard = "Jack" - if WantsCard = "q" || WantsCard = "Q" then WantsCard = "Queen" - if WantsCard = "k" || WantsCard = "K" then WantsCard = "King" - if WantsCard = "a" || WantsCard = "A" then WantsCard = "Ace" - if WantsCard = "0" then WantsCard = "10" - - print "-------------------------------------" - print - str255 AorAn - AorAn = "a" - if WantsCard = "Ace" then AorAn = "an" - print YourName + " asked For " + AorAn + " " + WantsCard - print - text ,,fn ColorWhite - - fn PrintViewScrollToBottom( fn WindowPrintView(1)) - - if RequestedCard = "X" || RequestedCard = "x" then fn QuitOrResumeAlert(@"EXIT") - - If RequestedCard <> "" Then CardNumber = Instr$(1,cards, Ucase$(RequestedCard)): RequestCard = _true - - If CardNumber = 0 - text,,fn ColorRed - Print "Sorry, that is not a valid card.": RequestCard = _false - print - fn PrintViewScrollToBottom( fn WindowPrintView(1)) - Else if play(CardNumber) = 0 Then text ,,fn colorRed: Print "You don//t have that card!": text ,,fn colorRed: RequestCard = _false - fn PrintViewScrollToBottom( fn WindowPrintView(1)) - text,,fn ColorWhite - - End If - - Wend - - guess(CardNumber) = 1 - - If Computer(CardNumber) = 0 - Print Someone + ","; - text ,,fn colorRed - Print " Go fish!" - text ,,fn colorWhite - Print Someone + " got a";: fn youGoFishing - print - fn CheckForCompletedBook - ShowHand = _true - Else - v = Computer(CardNumber) - Computer(CardNumber) = 0 - play(CardNumber) += v - if v > 1 then AddTheS = "s" else AddTheS = "" - Print Someone + " got" + str$(v) + " card" + AddTheS - fn CheckForCompletedBook - fn PrintViewScrollToBottom( fn WindowPrintView(1)) - ShowHand = _false - End If - -Wend - - - -Someone = "CPU" -For i = 1 To 13 - asked(i) = 0 -Next i - -bool CPUsTurn = _false - -While CPUsTurn = _false - if fn CheckForEndGame = _True then cls:fn InitCards:goto "Loop" - - po = 0 - For i = 1 To 13 - If (Computer(i) > 0) && (guess(i) > 0) Then poss(i) = 1: po += 1 - Next i - - short whilecounter - WhileCounter = 0 - - - If po = 0 - // this k is the go fish card. - - k = rnd(12) +1 - while Computer(k) = 0 || asked(k) - whilecounter ++ - k = rnd(12) +1 - if WhileCounter > 100 then k = 0: exit while //5/5/24 Rich added this to prevent hangs - wend - - Else - - k = rnd(12) + 1 - while poss(k) = 0 - k = rnd(12) + 1 - if WhileCounter > 100 then k = 0: exit while //5/5/24 Rich added this to prevent hangs - wend - - guess(k) = 0 - asked(k) = 1 - - end if - - - if k = 0 then "Loop" //5/5/24 Rich added this to prevent hangs - - WantsCard = fn CheckForFaceCard(k) - - if WantsCard = "j" || WantsCard = "J" then WantsCard = "Jack" - if WantsCard = "q" || WantsCard = "Q" then WantsCard = "Queen" - if WantsCard = "k" || WantsCard = "K" then WantsCard = "King" - if WantsCard = "a" || WantsCard = "A" then WantsCard = "Ace" - if WantsCard = "0" then WantsCard = "10" - - text ,,fn ColorOrange - - print "-------------------------------------" - - - - Print:Print Someone + " wants your " + wantsCard + "'s." - print - - text ,,fn ColorWhite - - asked(k) = 1 - - - If play(k) = 0 - Print Someone + ", "; - text ,,fn colorRed: Print "go fish!" - text ,,fn colorWhite:Print Someone + " got";: fn cpuGoFishing - - fn CheckCPUForCompletedBook - CPUsTurn = _true - - Else - - v = play(k) - play(k) = 0 - Computer(k) += v - if v > 1 then AddTheS = "s" else AddTheS = "" - Print Someone + " got" + str$(v) + " card" + AddTheS - fn CheckCPUForCompletedBook - CPUsTurn = _false - End If - - -Wend - -"Loop" -goto "Main" - -handleevents diff --git a/Task/Go-Fish/Rebol/go-fish.rebol b/Task/Go-Fish/Rebol/go-fish.rebol deleted file mode 100644 index c310b23444..0000000000 --- a/Task/Go-Fish/Rebol/go-fish.rebol +++ /dev/null @@ -1,217 +0,0 @@ -Rebol [ - title: "Rosetta code: Go Fish" - file: %Go_fish.r3 - url: https://rosettacode.org/wiki/Go_Fish -] - -go-fish-game: function/with [ - "Play a game of Go Fish" -][ - deck: fisher-yates-shuffle copy ordered-deck - clear ai-hand clear ai-book-list clear ai-guess - clear my-hand clear my-book-list - ai-books: my-books: 0 - deal-cards/ai 9 ai-hand - deal-cards 9 my-hand - message: clear "" - draw-screen - while [ai-books + my-books < 13][ - computer-turn - if ai-books + my-books < 13 [player-turn] - ] - clear-screen - draw-screen - print "" - print as-yellow "GAME OVER" - print ["^/Computer books:" as-red pad ai-books -3 - "^/Player books:" as-green pad my-books -3] -][ - ;; Build deck - ordered-deck: [] - foreach r ranks: "A23456789TJQK" [ - foreach s "♣♦♥♠" [ - append ordered-deck ajoin [r s] - ] - ] - ;; Charsets used to filter key inputs - player-card-keys: charset join ranks "x" - player-yes-no: charset "ynx" - - ;; Game states - ai-hand: [] ai-book-list: [] ai-guess: [] - my-hand: [] my-book-list: [] - deck: [] - ai-books: my-books: 0 - - - message: "" - - ;; Shuffle function - fisher-yates-shuffle: func [list [block!] /local len j] [ - len: length? list - repeat i len [ - j: i + random (len - i) - swap at list i at list j - ] - list - ] - ;; Cards sorting - rank-modifiers: #[ - #"A" 130 #"K" 120 #"Q" 110 #"J" 100 #"T" 90 - #"9" 80 #"8" 70 #"7" 60 #"6" 50 #"5" 40 - #"4" 30 #"3" 20 #"2" 10 - ] - card-rank: func [card] [rank-modifiers/(card/1)] - sort-hand: func [hand] [ - sort/compare hand func [a b] [ - (card-rank a) < (card-rank b) - ] - ] - ;; Screen output - clear-screen: does [prin "^[[2J^[[H"] - draw-screen: does [ - clear-screen - ;; title bar - print as-yellow "==================================" - print as-yellow " G O F I S H " - print as-yellow "==================================" - print "" - ;; deck count - print ajoin [as-cyan " Deck: " length? deck " cards remaining"] - print "" - ;; books lines - print ajoin [as-red " Computer books: " pad ai-books -2 " [ " ai-book-list " ]"] - print ajoin [as-green " Your books: " pad my-books -2 " [ " my-book-list " ]"] - print as-yellow "----------------------------------" - print "" - ;; my hand - print [as-cyan "Your hand:" as-yellow sort-hand my-hand] - print "" - ;; last message - unless empty? message [ print message ] - print as-yellow "----------------------------------" - ] - status: func[txt][ - if block? txt [txt: ajoin txt] - append append message txt LF - ] - ;; Game functions - deal-cards: function [num hand /ai] [ - new: take/part deck num - unless ai [ - status ["You draw new card" if num > 1 ["s"] ": " new] - ] - append hand new - ] - find-in: func [hand kind [char!]] [ - forall hand [ - if hand/1/1 = kind [return kind] - ] - none - ] - guess-from: function [hand guessed] [ - kind: first random/only exclude hand guessed - append guessed kind - kind - ] - check-for-books: func [hand /ai /local kind n count] [ - if empty? hand [exit] - sort hand - kind: hand/1/1 n: count: 0 - while [not tail? hand][ - either kind = hand/1/1 [ - n: n + 1 - if n = 4 [ - remove/part next hand -4 - ++ count - append either ai [ai-book-list][my-book-list] kind - if tail? hand [break] - kind: hand/1/1 n: 0 - continue - ] - ][ - kind: hand/1/1 - n: 1 - ] - ++ hand - ] - either ai [ - ai-books: ai-books + count - ][ my-books: my-books + count] - if count > 0 [ - status ["New " as-green count " book" if count > 1 "s" " collected!"] - ] - count - ] - transfer-cards: func [ - ;; Move all cards of a given rank from src to trg - src [block!] trg [block!] kind [char!] - ][ - while [not tail? src] [ - either kind = src/1/1 [append trg take src][++ src] - ] - ] - computer-turn: func [/local kind a] [ - forever [ - if empty? ai-hand [ - if empty? deck [exit] - deal-cards/ai 3 ai-hand - ] - ai-guess: unique ai-guess - kind: guess-from ai-hand ai-guess - draw-screen - print as-red { -------------------^/ - COMPUTER TURN -^/ -------------------} - clear message - prin ajoin [" Do you have any " as-green kind "s? "] - a: wait-for-key/only player-yes-no - if any [none? a a = #"x"][ halt ] - either a = #"y" [ - transfer-cards my-hand ai-hand kind - status ["Computer took your " as-green kind "s!"] - check-for-books/ai ai-hand - draw-screen - ][ - status ["Go Fish! Computer draws a card."] - deal-cards/ai 1 ai-hand - check-for-books/ai ai-hand - draw-screen - exit - ] - ] - ] - - player-turn: func [/local kind n] [ - forever [ - if empty? my-hand [ - if empty? deck [exit] - deal-cards 3 my-hand - ] - draw-screen - print as-green { -------------------^/ - PLAYER TURN -^/ -------------------} - clear message - prin " Your guess: " - kind: wait-for-key/only player-card-keys - if any [none? kind kind = #"x"][ halt ] - kind: uppercase kind - unless find-in my-hand kind [ - status as-red "You must hold that rank to ask for it!" - draw-screen - exit - ] - either find-in ai-hand kind [ - transfer-cards ai-hand my-hand kind - status ["You took the computer's " as-green kind "s!"] - check-for-books my-hand - draw-screen - ][ - status ["Computer don't have any " as-green kind "s!"] - deal-cards 1 my-hand - check-for-books my-hand - draw-screen - exit - ] - ] - ] -] -;--- Main --- -go-fish-game diff --git a/Task/Goldbachs-comet/Agena/goldbachs-comet.agena b/Task/Goldbachs-comet/Agena/goldbachs-comet.agena deleted file mode 100644 index 5e498f40b6..0000000000 --- a/Task/Goldbachs-comet/Agena/goldbachs-comet.agena +++ /dev/null @@ -1,22 +0,0 @@ -scope # Goldbach's comet, translation of Pluto - - local proc goldbach( n :: number ) :: number - local count := 0; - for i to n \ 2 do - if numtheory.isprime( i ) and numtheory.isprime( n - i ) then - count +:= 1 - fi - od - return count - end; - - print( "The first 100 G numbers:" ) - print( join( foreach( 1, 100, << n -> strings.format( "%2d" & if n mod 10 = 0 then "\n" else " " fi - , goldbach( 2 + n * 2 ) - ) - >> - ) - ) - ); - printf( "G(1000000) = %.0f\n", goldbach( 1_000_000 ) ) -end diff --git a/Task/Goldbachs-comet/Arturo/goldbachs-comet.arturo b/Task/Goldbachs-comet/Arturo/goldbachs-comet.arturo index e7bfa7ec91..5930a6e9da 100644 --- a/Task/Goldbachs-comet/Arturo/goldbachs-comet.arturo +++ b/Task/Goldbachs-comet/Arturo/goldbachs-comet.arturo @@ -13,4 +13,6 @@ print ["\nG(1000000) =" G 1000000] csv: join.with:",\n" map select 4..2000 => even? 'x -> ~"|x|, |G x|" -csv >> "comet.csv" +; write the CSV data to a file which we can then visualize +; via our preferred spreadsheet app +write "comet.csv" csv diff --git a/Task/Goldbachs-comet/BASIC256/goldbachs-comet.basic b/Task/Goldbachs-comet/BASIC256/goldbachs-comet.basic deleted file mode 100644 index 153f24f02b..0000000000 --- a/Task/Goldbachs-comet/BASIC256/goldbachs-comet.basic +++ /dev/null @@ -1,30 +0,0 @@ -#arraybase 1 -print "The first 100 G numbers are:" - -col = 1 -for n = 4 to 202 step 2 - print rjust(string(g(n)), 4); - if col mod 10 = 0 then print - col += 1 -next n - -print : print "G(1000000) = "; g(1000000) -end - -function isPrime(v) - if v <= 1 then return False - for i = 2 to int(sqrt(v)) - if v mod i = 0 then return False - next i - return True -end function - -function g(n) - cont = 0 - if n mod 2 = 0 then - for i = 2 to (1/2) * n - if isPrime(i) = 1 and isPrime(n - i) = 1 then cont += 1 - next i - end if - return cont -end function diff --git a/Task/Goldbachs-comet/Delphi/goldbachs-comet.pas b/Task/Goldbachs-comet/Delphi/goldbachs-comet.delphi similarity index 100% rename from Task/Goldbachs-comet/Delphi/goldbachs-comet.pas rename to Task/Goldbachs-comet/Delphi/goldbachs-comet.delphi diff --git a/Task/Goldbachs-comet/EasyLang/goldbachs-comet.easy b/Task/Goldbachs-comet/EasyLang/goldbachs-comet.easy index 1a4a2b23d6..84f3ef12ba 100644 --- a/Task/Goldbachs-comet/EasyLang/goldbachs-comet.easy +++ b/Task/Goldbachs-comet/EasyLang/goldbachs-comet.easy @@ -1,22 +1,40 @@ -func isprim n . - if n mod 2 = 0 and n > 2 : return 0 - i = 3 - sq = sqrt n - while i <= sq - if n mod i = 0 : return 0 - i += 2 +proc isprime n . r . + r = 1 + if n <= 1 + r = 0 + break 1 . - return 1 -. -func goldbach n . - for i = 2 to n div 2 - if isprim i = 1 : cnt += isprim (n - i) + if n mod 2 = 0 + if n = 2 + break 1 + . + r = 0 + break 1 + . + for i = 3 step 2 to sqrt n + if n mod i = 0 + r = 0 + break 2 + . . - return cnt . -numfmt 3 0 +proc goldbach n . cnt . + cnt = 0 + for i = 1 to n div 2 + call isprime i r + if r = 1 + call isprime n - i r + cnt += r + . + . +. +numfmt 0 3 for n = 4 step 2 to 202 - write goldbach n - if n mod 20 = 2 : print "" + call goldbach n r + write r + if n mod 20 = 2 + print "" + . . -print goldbach 1000000 +call goldbach 1000000 r +print r diff --git a/Task/Goldbachs-comet/Fennel/goldbachs-comet.fennel b/Task/Goldbachs-comet/Fennel/goldbachs-comet.fennel deleted file mode 100644 index 0fbbb9715e..0000000000 --- a/Task/Goldbachs-comet/Fennel/goldbachs-comet.fennel +++ /dev/null @@ -1,49 +0,0 @@ -(do ;;; Goldbach's comet - translated from the Lua sample - - (fn range [from to] ; generate a table containing the integers [from .. to] - (local t {}) - (for [i from to] - (tset t i i) - ) - t - ) - - (fn is-prime [p] - (if (or (<= p 1) (= 0 (% p 2))) - (= p 2) - ;else - (do (var (prime i root-p) (values true 3 (math.floor (math.sqrt p)))) - (while (and (<= i root-p) prime) - (set (prime i) (values (not= 0 (% p i)) (+ i 1))) - ) - prime - ) - ) - ) - - (fn goldbach [n] - (var count 0) - (for [i 1 (math.floor (/ n 2))] - (when (and (is-prime i) (is-prime (- n i))) - (set count (+ count 1)) - ) - ) - count - ) - - (print "The first 100 G numbers:") - (print (table.concat (icollect [_ v (ipairs (range 1 100))] - (string.format (.. "%2d" (if (= 0 (% v 10)) - "\n" - ;else - " " - ) - ) - (goldbach (+ 2 (* v 2))) - ) - ) - "" - ) - ) - (print (.. "G(1000000) = " (goldbach 1_000_000))) -) diff --git a/Task/Goldbachs-comet/FreeBASIC/goldbachs-comet.basic b/Task/Goldbachs-comet/FreeBASIC/goldbachs-comet-1.basic similarity index 100% rename from Task/Goldbachs-comet/FreeBASIC/goldbachs-comet.basic rename to Task/Goldbachs-comet/FreeBASIC/goldbachs-comet-1.basic diff --git a/Task/Goldbachs-comet/FreeBASIC/goldbachs-comet-2.basic b/Task/Goldbachs-comet/FreeBASIC/goldbachs-comet-2.basic new file mode 100644 index 0000000000..6a74789be6 --- /dev/null +++ b/Task/Goldbachs-comet/FreeBASIC/goldbachs-comet-2.basic @@ -0,0 +1,47 @@ +OPTION STRICT: OPTION DEFINT +VAR MAX_G = 4000, MAX_P = 1000000 +VAR ROOT_MAX_P = FLOOR(SQR(MAX_P)) +VAR HALF_MAX_G = MAX_G DIV 2 +VAR G[MAX_G + 1], P[MAX_P + 1] +VAR I, J +CLS: GCLS +P[0] = FALSE: P[1] = 0: P[2] = TRUE +FOR I = 4 TO MAX_P STEP 2 P[I] = FALSE: NEXT +FOR I = 3 TO MAX_P STEP 2 P[I] = TRUE: NEXT +FOR I = 3 TO ROOT_MAX_P STEP 2 + IF P[I] THEN + FOR J = I * I TO MAX_P STEP I + P[J] = FALSE + NEXT + ENDIF +NEXT +FOR I = 1 TO MAX_G G[I] = 0: NEXT +G[4] = 1 ' 4 is the only sum of 2 even primes +FOR I = 3 TO HALF_MAX_G STEP 2 + IF P[I] THEN + INC G[I + 1] + FOR J = I + 2 TO MAX_G - 1 + IF P[J] THEN + INC G[I + 1] + ENDIF + NEXT + ENDIF +NEXT +VAR C = 0 +FOR I = 4 TO 202 STEP 2 + PRINT FORMAT$("%3D", G[I]), + INC C + IF C == 10 THEN PRINT: C = 0: ENDIF +NEXT +VAR GM = 0 +FOR I = 3 TO MAX_P DIV 2 STEP 2 + IF P[I] THEN + IF P[MAX_P - I] THEN INC GM: ENDIF + ENDIF +NEXT +PRINT FORMAT$("G(%D): ", MAX_P); GM +FOR I = 2 TO MAX_G - 10 STEP 10 + FOR J = 1 TO I + 8 STEP 2 + GPSET I DIV 10, 240-G[J],RGB(255,255,255) + NEXT +NEXT diff --git a/Task/Goldbachs-comet/Gambas/goldbachs-comet-1.gambas b/Task/Goldbachs-comet/Gambas/goldbachs-comet-1.gambas deleted file mode 100644 index f3e283e96a..0000000000 --- a/Task/Goldbachs-comet/Gambas/goldbachs-comet-1.gambas +++ /dev/null @@ -1,28 +0,0 @@ -Use "isprime.bas" - -Public Sub Main() - - Print "The first 100 G numbers are:" - - Dim n As Integer, col As Integer = 1 - For n = 4 To 202 Step 2 - Print Format$(Str(g(n)), "####"); - If col Mod 10 = 0 Then Print - col += 1 - Next - - Print "\nG(1.000.000) = "; g(1000000) - -End - -Function g(n As Integer) As Integer - - Dim i As Integer, count As Integer = 0 - If n Mod 2 = 0 Then - For i = 2 To n \ 2 '(1/2) * n - If isPrime(i) And isPrime(n - i) Then count += 1 - Next - End If - Return count - -End Function diff --git a/Task/Goldbachs-comet/Gambas/goldbachs-comet-2.gambas b/Task/Goldbachs-comet/Gambas/goldbachs-comet-2.gambas deleted file mode 100644 index 827e0b16a0..0000000000 --- a/Task/Goldbachs-comet/Gambas/goldbachs-comet-2.gambas +++ /dev/null @@ -1,47 +0,0 @@ -OPTION STRICT: OPTION DEFINT -VAR MAX_G = 4000, MAX_P = 1000000 -VAR ROOT_MAX_P = FLOOR(SQR(MAX_P)) -VAR HALF_MAX_G = MAX_G DIV 2 -VAR G[MAX_G + 1], P[MAX_P + 1] -VAR I, J -CLS: GCLS -P[0] = FALSE: P[1] = 0: P[2] = TRUE -FOR I = 4 TO MAX_P STEP 2 P[I] = FALSE: NEXT -FOR I = 3 TO MAX_P STEP 2 P[I] = TRUE: NEXT -FOR I = 3 TO ROOT_MAX_P STEP 2 - IF P[I] THEN - FOR J = I * I TO MAX_P STEP I - P[J] = FALSE - NEXT - ENDIF -NEXT -FOR I = 1 TO MAX_G G[I] = 0: NEXT -G[4] = 1 ' 4 is the only sum of 2 even primes -FOR I = 3 TO HALF_MAX_G STEP 2 - IF P[I] THEN - INC G[I + I] - FOR J = I + 2 TO MAX_G - I - IF P[J] THEN - INC G[I + J] - ENDIF - NEXT - ENDIF -NEXT -VAR C = 0 -FOR I = 4 TO 202 STEP 2 - PRINT FORMAT$("%3D", G[I]), - INC C - IF C == 10 THEN PRINT: C = 0: ENDIF -NEXT -VAR GM = 0 -FOR I = 3 TO MAX_P DIV 2 STEP 2 - IF P[I] THEN - IF P[MAX_P - I] THEN INC GM: ENDIF - ENDIF -NEXT -PRINT FORMAT$("G(%D): ", MAX_P); GM -FOR I = 2 TO MAX_G - 10 STEP 10 - FOR J = I TO I + 8 STEP 2 - GPSET I DIV 10, 240-G[J],RGB(255,255,255) - NEXT -NEXT diff --git a/Task/Goldbachs-comet/Go/goldbachs-comet.go b/Task/Goldbachs-comet/Go/goldbachs-comet.go deleted file mode 100644 index 4c8b45dc6c..0000000000 --- a/Task/Goldbachs-comet/Go/goldbachs-comet.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "fmt" - "math" -) - -var primes []bool - -func initialisePrimes(limit int) { - primes = make([]bool, limit) - for i := 2; i < limit; i++ { - primes[i] = true - } - - sqrtLimit := int(math.Sqrt(float64(limit))) - for n := 2; n < sqrtLimit; n++ { - if primes[n] { - for k := n * n; k < limit; k += n { - primes[k] = false - } - } - } -} - -func goldbachFunction(number int) (int, error) { - if number <= 2 || number%2 == 1 { - return 0, fmt.Errorf("argument must be even and greater than 2: %d", number) - } - - result := 0 - for i := 1; i <= number/2; i++ { - if primes[i] && primes[number-i] { - result++ - } - } - return result, nil -} - -func main() { - initialisePrimes(2000000) - - fmt.Println("The first 100 Goldbach numbers:") - for n := 2; n < 102; n++ { - value, err := goldbachFunction(2 * n) - if err != nil { - fmt.Printf("Error: %v\n", err) - continue - } - fmt.Printf("%3d", value) - if n%10 == 1 { - fmt.Println() - } - } - - fmt.Println("\nThe 1,000,000th Goldbach number =", func() string { - value, err := goldbachFunction(1000000) - if err != nil { - return fmt.Sprintf("Error: %v", err) - } - return fmt.Sprintf("%d", value) - }()) -} diff --git a/Task/Goldbachs-comet/Java/goldbachs-comet.java b/Task/Goldbachs-comet/Java/goldbachs-comet.java deleted file mode 100644 index 7826587d18..0000000000 --- a/Task/Goldbachs-comet/Java/goldbachs-comet.java +++ /dev/null @@ -1,76 +0,0 @@ -import java.awt.Color; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.List; - -import javax.imageio.ImageIO; - -public final class GoldbachsComet { - - public static void main(String[] aArgs) { - initialisePrimes(2_000_000); - - System.out.println("The first 100 Goldbach numbers:"); - for ( int n = 2; n < 102; n++ ) { - System.out.print(String.format("%3d%s", goldbachFunction(2 * n), ( n % 10 == 1 ? "\n" : "" ))); - } - - System.out.println(); - System.out.println("The 1,000,000th Goldbach number = " + goldbachFunction(1_000_000)); - - createImage(); - } - - private static void createImage() { - final int width = 1040; - final int height = 860; - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - Graphics graphics = image.getGraphics(); - graphics.setColor(Color.WHITE); - graphics.fillRect(0, 0, width, height); - - List colours = List.of( Color.BLUE, Color.GREEN, Color.RED ); - for ( int n = 2; n < 2002; n++ ) { - graphics.setColor(colours.get(n % 3)); - graphics.fillOval(n / 2, height - 5 * goldbachFunction(2 * n), 10, 10); - } - - try { - ImageIO.write(image, "png", new File("GoldbachsCometJava.png")); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - - private static int goldbachFunction(int aNumber) { - if ( aNumber <= 2 || aNumber % 2 == 1 ) { - throw new AssertionError("Argument must be even and greater than 2: " + aNumber); - } - - int result = 0; - for ( int i = 1; i <= aNumber / 2; i++ ) { - if ( primes[i] && primes[aNumber - i] ) { - result += 1; - } - } - return result; - } - - private static void initialisePrimes(int aLimit) { - primes = new boolean[aLimit]; - for ( int i = 2; i < aLimit; i++ ) { - primes[i] = true; - } - - for ( int n = 2; n < Math.sqrt(aLimit); n++ ) { - for ( int k = n * n; k < aLimit; k += n ) { - primes[k] = false; - } - } - } - - private static boolean[] primes; - -} diff --git a/Task/Goldbachs-comet/Julia/goldbachs-comet.jl b/Task/Goldbachs-comet/Julia/goldbachs-comet.julia similarity index 100% rename from Task/Goldbachs-comet/Julia/goldbachs-comet.jl rename to Task/Goldbachs-comet/Julia/goldbachs-comet.julia diff --git a/Task/Goldbachs-comet/Lua/goldbachs-comet.lua b/Task/Goldbachs-comet/Lua/goldbachs-comet.lua index 41e61a815e..85a60e5015 100644 --- a/Task/Goldbachs-comet/Lua/goldbachs-comet.lua +++ b/Task/Goldbachs-comet/Lua/goldbachs-comet.lua @@ -1,6 +1,7 @@ function T(t) return setmetatable(t, {__index=table}) end table.range = function(t,n) local s=T{} for i=1,n do s[i]=i end return s end table.map = function(t,f) local s=T{} for i=1,#t do s[i]=f(t[i]) end return s end +table.batch = function(t,n,f) for i=1,#t,n do local s=T{} for j=1,n do s[j]=t[i+j-1] end f(s) end return t end function isprime(n) if n < 2 then return false end @@ -23,7 +24,6 @@ function goldbach(n) end print("The first 100 G numbers:") -print(T{}:range(100) - :map(function(n) return string.format("%2d"..(n % 10 == 0 and "\n" or " "),goldbach(2+n*2)) end) - :concat("")) +g = T{}:range(100):map(function(n) return goldbach(2+n*2) end) +g:map(function(n) return string.format("%2d ",n) end):batch(10,function(t) print(t:concat()) end) print("G(1000000) = "..goldbach(1000000)) diff --git a/Task/Goldbachs-comet/PascalABC.NET/goldbachs-comet.pas b/Task/Goldbachs-comet/PascalABC.NET/goldbachs-comet.pas deleted file mode 100644 index 234717b9bc..0000000000 --- a/Task/Goldbachs-comet/PascalABC.NET/goldbachs-comet.pas +++ /dev/null @@ -1,36 +0,0 @@ -uses GraphWPF; - -const colpick = (Colors.Red, Colors.Green, Colors.Blue); - -function IsPrime(x: longword): boolean; -begin - var i := 2; - while (i * i <= x) and (x mod i <> 0) do - i += 1; - Result := i * i > x; -end; - -function g(n: integer): integer; -begin - assert((n > 2) and (n mod 2 = 0), '“n” must be even and greater than 2.'); - for var i := 2 to (n div 2) do - if isPrime(i) and isPrime(n - i) then - result += 1; -end; - -begin - println('First 100 G numbers:'); - foreach var n in (2..101) index i do - begin - write(g( 2 * n):3); - if (i + 1) mod 10 = 0 then writeln; - end; - println; - println('G(1_000_000) =', g(1_000_000)); - - setMathematicCoords(0, 4000, 0, false); - foreach var x in range(4, 4002, 2) do - begin - fillcircle(x, g(x)*15, 10, colpick[(x div 2) mod 3]); - end; -end. diff --git a/Task/Goldbachs-comet/Pluto/goldbachs-comet-1.pluto b/Task/Goldbachs-comet/Pluto/goldbachs-comet-1.pluto deleted file mode 100644 index 8d53f40164..0000000000 --- a/Task/Goldbachs-comet/Pluto/goldbachs-comet-1.pluto +++ /dev/null @@ -1,23 +0,0 @@ -do -- Goldbach's comet, translation of Lua - - local int = require( "int" ) -- RC Pluto integer library, inc. prime utilities - - local function goldbach( n : number ) : number - local count = 0 - for i = 1, n // 2 do - if int.isprime( i ) and int.isprime( n - i ) then - ++ count - end - end - return count - end - - print( "The first 100 G numbers:" ) - print( range( 100 ):map( | n | -> string.format( "%2d"..if n % 10 == 0 then "\n" else " " end - , goldbach( 2 + n * 2 ) - ) - ) - :concat( "" ) - ) - print( $"G(1000000) = { goldbach( 1_000_000 ) }" ) -end diff --git a/Task/Goldbachs-comet/Pluto/goldbachs-comet-2.pluto b/Task/Goldbachs-comet/Pluto/goldbachs-comet-2.pluto deleted file mode 100644 index 8f93744a60..0000000000 --- a/Task/Goldbachs-comet/Pluto/goldbachs-comet-2.pluto +++ /dev/null @@ -1,69 +0,0 @@ -do -- create a bitmap of Goldbach's Comet - - local int = require( "int" ) -- RC Pluto integer library, inc. prime utilities - require( "bitmap" ) -- RC bitmap library - - local bmp = bitmap.of( 400, 240, color.black, "Goldbachs_comet_Pluto" ) - - local maxG , maxP = 4000, 1_000_000 - local rootMaxP , halfMaxG = math.floor( math.sqrt( maxP ) ), maxG // 2 - - local prime = int.arecomps( maxP ):map( | v | -> not v ) -- sieve the primes to maxP - - local G = {} -- construct a table of G numbers - for i = 1, maxG do G[ i ] = 0 end - G[ 4 ] = 1 -- 4 is the only sum of 2 even primes - for i = 3, halfMaxG, 2 do - if prime[ i ] then - G[ i + i ] += 1 - for j = i + 2, maxG - i do - if prime[ j ] then - G[ i + j ] += 1 - end - end - end - end - -- print the first few G numbers to the bitmap - 8x8 charaxters - local c, tx, ty = 0, 2, 2 - for i = 4, 202, 2 do - c += 1 - bmp:text( string.format( "%3d", G[ i ] ), tx, ty, color.white, 1 ) - if c % 10 != 0 then - tx += 24 - else - tx, ty = 2, ty + 10 - end - end - local Gm = 0 - for i = 3, maxP // 2, 2 do - if prime[ i ] then - if prime[ maxP - i ] then Gm += 1 end - end - end - -- print G(1_000_000) to the bitmap - bmp:text( string.format( "G(%d): %d", maxP, Gm ), 2, ty + 10, color.white, 1 ) - for i = 2, maxG - 10, 10 do - local maxY = 0 - local x = i // 10 - for j = i, i + 8, 2 do - if G[ j ] > 0 then - local y = 240 - G[ j ] - bmp:set( x, y, switch bmp:get( x, y ) do - case color.black -> color.orange - case color.orange -> color.yellow - default -> color.white - end - ) - if y > maxY then maxY = y end - end - end - -- we're going to save it as a png, so convert from BGR to RGb - for j = 1, maxY do - local bgr = bmp:get( x, j ) - if bgr != color.black then - bmp:set( x, j, bmp.flipColor( bgr ) ) - end - end - end - bmp:view( true ) -end diff --git a/Task/Goldbachs-comet/REXX/goldbachs-comet.rexx b/Task/Goldbachs-comet/REXX/goldbachs-comet.rexx deleted file mode 100644 index 4d7666fda3..0000000000 --- a/Task/Goldbachs-comet/REXX/goldbachs-comet.rexx +++ /dev/null @@ -1,58 +0,0 @@ --- 23 Aug 2025 -include Setting - -say 'GOLDBACH''S COMET' -say version -say -numeric digits 7 -call GetPrimes -call ShowFirst100 -call ShowMillion -exit - -GetPrimes: -procedure expose prim. flag. -call Time('r') -say 'Collect Primes up to 1000000...' -call Primes(1e6) -say Time('e')/1 'seconds' -say -return - -ShowFirst100: -procedure expose prim. flag. -call Time('r') -say 'First 100 values...' -do i = 4 by 2 to 202 - call Charout ,Right(Goldbach(i),3) - if i//20 = 2 then - say -end -say Time('e')/1 'seconds' -say -return - -ShowMillion: -procedure expose prim. flag. -call Time('r') -say 'g(1000000)...' -say Goldbach(1e6) -say Time('e')/1 'seconds' -say -return - -Goldbach: -procedure expose prim. flag. -arg x -y = 0 -do i = 2 to x%2 - if flag.i then do - j = x-i - if flag.j then do - y = y+1 - end - end -end -return y/1 - -include Math diff --git a/Task/Goldbachs-comet/Rust/goldbachs-comet.rs b/Task/Goldbachs-comet/Rust/goldbachs-comet.rust similarity index 100% rename from Task/Goldbachs-comet/Rust/goldbachs-comet.rs rename to Task/Goldbachs-comet/Rust/goldbachs-comet.rust diff --git a/Task/Goldbachs-comet/Yabasic/goldbachs-comet-1.basic b/Task/Goldbachs-comet/Yabasic/goldbachs-comet-1.basic deleted file mode 100644 index effc0a4409..0000000000 --- a/Task/Goldbachs-comet/Yabasic/goldbachs-comet-1.basic +++ /dev/null @@ -1,23 +0,0 @@ -import isprime - -print "The first 100 G numbers are:" - -col = 1 -for n = 4 to 202 step 2 - print g(n) using ("####"); - if mod(col, 10) = 0 print - col = col + 1 -next n - -print "\nG(1000000) = ", g(1000000) -end - -sub g(n) - count = 0 - if mod(n, 2) = 0 then - for i = 2 to (1/2) * n - if isPrime(i) and isPrime(n - i) count = count + 1 - next i - fi - return count -end sub diff --git a/Task/Goldbachs-comet/Yabasic/goldbachs-comet-2.basic b/Task/Goldbachs-comet/Yabasic/goldbachs-comet-2.basic deleted file mode 100644 index 64f65b0ac9..0000000000 --- a/Task/Goldbachs-comet/Yabasic/goldbachs-comet-2.basic +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include -#include - -std::vector primes; - -void initialise_primes(const int32_t& limit) { - primes.resize(limit); - for ( int32_t i = 2; i < limit; ++i ) { - primes[i] = true; - } - - for ( int32_t n = 2; n < sqrt(limit); ++n ) { - for ( int32_t k = n * n; k < limit; k += n ) { - primes[k] = false; - } - } -} - -int32_t goldbach_function(const int32_t& number) { - if ( number <= 2 || number % 2 == 1 ) { - throw std::invalid_argument("Argument must be even and greater than 2: " + std::to_string(number)); - } - - int32_t result = 0; - for ( int32_t i = 1; i <= number / 2; ++i ) { - if ( primes[i] && primes[number - i] ) { - result++; - } - } - return result; -} - -int main() { - initialise_primes(2'000'000); - - std::cout << "The first 100 Goldbach numbers:" << std::endl; - for ( int32_t n = 2; n < 102; ++n ) { - std::cout << std::setw(3) << goldbach_function(2 * n) << ( n % 10 == 1 ? "\n" : "" ); - } - - std::cout << "\n" << "The 1,000,000th Goldbach number = " << goldbach_function(1'000'000) << std::endl; -} diff --git a/Task/Golden-ratio-Convergence/Ada/golden-ratio-convergence.adb b/Task/Golden-ratio-Convergence/Ada/golden-ratio-convergence.ada similarity index 100% rename from Task/Golden-ratio-Convergence/Ada/golden-ratio-convergence.adb rename to Task/Golden-ratio-Convergence/Ada/golden-ratio-convergence.ada diff --git a/Task/Golden-ratio-Convergence/C-sharp/golden-ratio-convergence.cs b/Task/Golden-ratio-Convergence/C-sharp/golden-ratio-convergence.cs deleted file mode 100644 index b3bfccf9c2..0000000000 --- a/Task/Golden-ratio-Convergence/C-sharp/golden-ratio-convergence.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -public class GoldenRatio { - static void Iterate() { - double oldPhi = 1.0, phi = 1.0, limit = 1e-5; - int iters = 0; - while (true) { - phi = 1.0 + 1.0 / oldPhi; - iters++; - if (Math.Abs(phi - oldPhi) <= limit) break; - oldPhi = phi; - } - Console.WriteLine($"Final value of phi : {phi:0.00000000000000}"); - double actualPhi = (1.0 + Math.Sqrt(5.0)) / 2.0; - Console.WriteLine($"Number of iterations : {iters}"); - Console.WriteLine($"Error (approx) : {phi - actualPhi:0.00000000000000}"); - } - - public static void Main(string[] args) { - Iterate(); - } -} diff --git a/Task/Golden-ratio-Convergence/COBOL/golden-ratio-convergence.cob b/Task/Golden-ratio-Convergence/COBOL/golden-ratio-convergence.cobol similarity index 100% rename from Task/Golden-ratio-Convergence/COBOL/golden-ratio-convergence.cob rename to Task/Golden-ratio-Convergence/COBOL/golden-ratio-convergence.cobol diff --git a/Task/Golden-ratio-Convergence/DuckDB/golden-ratio-convergence.duckdb b/Task/Golden-ratio-Convergence/DuckDB/golden-ratio-convergence.duckdb deleted file mode 100644 index 0e9e393bfe..0000000000 --- a/Task/Golden-ratio-Convergence/DuckDB/golden-ratio-convergence.duckdb +++ /dev/null @@ -1,24 +0,0 @@ -set variable phi = (1 + sqrt(5)) / 2; - -# Output: one row (iterations, phi) -# This should work even with epsilon = 0 -create or replace function compute_phi(epsilon) as table ( - with recursive cte as ( - select 2.0::DOUBLE as oldPhi, 1::DOUBLE as phi, 0 as iterations - union all - select phi as oldPhi, - 1 + (1 / phi) as phi, - iterations + 1 as iterations - from cte - where @(phi - oldPhi) > epsilon - ) - select last(iterations order by iterations) as iterations, - last(phi order by iterations) as phi - from cte -); - -select epsilon, - iterations, - phi as "final value", - @(phi - getvariable('phi')) as "approximate absolute error" - from (select unnest([1e-5, 0]) as epsilon), compute_phi(epsilon); diff --git a/Task/Golden-ratio-Convergence/EasyLang/golden-ratio-convergence.easy b/Task/Golden-ratio-Convergence/EasyLang/golden-ratio-convergence.easy index c5d55953a8..66bf65792e 100644 --- a/Task/Golden-ratio-Convergence/EasyLang/golden-ratio-convergence.easy +++ b/Task/Golden-ratio-Convergence/EasyLang/golden-ratio-convergence.easy @@ -5,7 +5,7 @@ repeat phi0 = phi iter += 1 . -numfmt 0 10 +numfmt 10 0 print "Iterations: " & iter print "Result: " & phi print "Error: " & phi - (1 + sqrt 5) / 2 diff --git a/Task/Golden-ratio-Convergence/F-Sharp/golden-ratio-convergence.fs b/Task/Golden-ratio-Convergence/F-Sharp/golden-ratio-convergence.fs deleted file mode 100644 index 7c4f5f161d..0000000000 --- a/Task/Golden-ratio-Convergence/F-Sharp/golden-ratio-convergence.fs +++ /dev/null @@ -1,4 +0,0 @@ -// Golden ratio/Convergence. Nigel Galloway: March 8th., 2024 -let ϕ=let aπ()=fun()->1M in cf2S(aπ())(aπ()) -let (_,n),g=let mutable l=1 in (ϕ|>Seq.pairwise|>Seq.skipWhile(fun(n,g)->l<-l+1;abs(n-g)>1e-5M)|>Seq.head,l) -printfn "Value of ϕ is %1.14f after %d iterations error with respect to (1+√5)/2 is %1.14f" n g (abs(n-(decimal(1.0+(sqrt 5.0))/2M))) diff --git a/Task/Golden-ratio-Convergence/FutureBasic/golden-ratio-convergence.basic b/Task/Golden-ratio-Convergence/FutureBasic/golden-ratio-convergence.basic deleted file mode 100644 index 250ef6e2b2..0000000000 --- a/Task/Golden-ratio-Convergence/FutureBasic/golden-ratio-convergence.basic +++ /dev/null @@ -1,21 +0,0 @@ -include "NSLog.incl" - -void local fn Iterate - double oldPhi = 1.0, phi = 1.0, limit = 1e-5 - int iters = 0 - while (YES) - phi = 1.0 + 1.0 / oldPhi - iters++ - if ( abs( phi - oldPhi ) <= limit ) then break - oldPhi = phi - wend - NSLog( @"Final value of phi: %16.14f", phi ) - double actualPhi = ( 1.0 + fn sqrt(5.0) ) / 2.0 - NSLog( @"Actual value of phi: %16.14f", actualPhi ) - NSLog( @"Error (approx): %16.14f", phi - actualPhi ) - NSLog( @"Number of iterations: %d", iters ) -end fn - -fn Iterate - -HandleEvents diff --git a/Task/Golden-ratio-Convergence/Julia/golden-ratio-convergence.jl b/Task/Golden-ratio-Convergence/Julia/golden-ratio-convergence.julia similarity index 100% rename from Task/Golden-ratio-Convergence/Julia/golden-ratio-convergence.jl rename to Task/Golden-ratio-Convergence/Julia/golden-ratio-convergence.julia diff --git a/Task/Golden-ratio-Convergence/Lua/golden-ratio-convergence.lua b/Task/Golden-ratio-Convergence/Lua/golden-ratio-convergence.lua deleted file mode 100644 index 6d87e32847..0000000000 --- a/Task/Golden-ratio-Convergence/Lua/golden-ratio-convergence.lua +++ /dev/null @@ -1,7 +0,0 @@ -local phi, phi0, expected, iters = 1, 0, (1 + math.sqrt(5)) / 2, 0 -repeat - phi0, phi = phi, 1 + 1 / phi - iters = iters + 1 -until math.abs(phi0 - phi) < 1e-5 -io.write( "after ", iters, " iterations, phi = ", phi ) -io.write( ", expected value: ", expected, ", diff: ", math.abs( expected - phi ), "\n" ) diff --git a/Task/Golden-ratio-Convergence/Oberon/golden-ratio-convergence.oberon b/Task/Golden-ratio-Convergence/Oberon/golden-ratio-convergence.oberon deleted file mode 100644 index 041dac37f4..0000000000 --- a/Task/Golden-ratio-Convergence/Oberon/golden-ratio-convergence.oberon +++ /dev/null @@ -1,24 +0,0 @@ -MODULE GoldenRatioCnv; (* calculate the Golden Ratio and show the number of iterations required *) - IMPORT Math, Out; - - VAR count : INTEGER; - phi0, phi1, diff : REAL; - -BEGIN - - count := 0; - phi0 := 1.0; - diff := 1.0E20; - - WHILE 1.0E-5 < diff DO - phi1 := 1.0 + ( 1.0 / phi0 ); - diff := ABS( phi1 - phi0 ); - phi0 := phi1; - INC( count ) - END; - - Out.String( "Result:" );Out.Real( phi0, 10 ); - Out.String( " after " );Out.Int( count, 0 );Out.String( " iterations" );Out.Ln; - Out.String( "The error is approximately " );Out.Real( phi0 - ( 0.5 * ( 1.0 + Math.sqrt( 5.0 ) ) ), 10 );Out.Ln - -END GoldenRatioCnv. diff --git a/Task/Golden-ratio-Convergence/Odin/golden-ratio-convergence.odin b/Task/Golden-ratio-Convergence/Odin/golden-ratio-convergence.odin deleted file mode 100644 index 4704230834..0000000000 --- a/Task/Golden-ratio-Convergence/Odin/golden-ratio-convergence.odin +++ /dev/null @@ -1,26 +0,0 @@ -package golden -import "core:fmt" -import "core:math" -/* main block */ -main :: proc() { - iterate() -} -/* definitions */ -iterate :: proc() { - count := 0 - phi0: f64 = 1.0 - difference: f64 = 1.0 - phi1: f64 - fmt.println("\nGolden ratio/Convergence") - fmt.println("-----------------------------------------") - for 1.0e-5 < difference { - phi1 = 1.0 + (1.0 / phi0) - difference = abs(phi1 - phi0) - phi0 = phi1 - count += 1 - fmt.printf("Iteration %2d : Estimate : %.8f\n", count, phi1) - } - fmt.println("-----------------------------------------") - fmt.printf("Result: %.8f after %d iterations", phi1, count) - fmt.printf("\nThe error is approximately %.10f\n", (phi1 - (0.5 * (1.0 + math.sqrt_f64(5.0))))) -} diff --git a/Task/Golden-ratio-Convergence/Onyx-(wasm)/golden-ratio-convergence.onyx b/Task/Golden-ratio-Convergence/Onyx-(wasm)/golden-ratio-convergence.onyx deleted file mode 100644 index 81df1f1637..0000000000 --- a/Task/Golden-ratio-Convergence/Onyx-(wasm)/golden-ratio-convergence.onyx +++ /dev/null @@ -1,26 +0,0 @@ -package main -use core {*} -use core.math{abs} -use core.intrinsics.wasm{sqrt_f64} -main :: () { - iterate(); -} -iterate :: () { - count := 0; - phi0: f64 = 1.0; - difference: f64 = 1.0; - phi1: f64; - println("\nGolden ratio/Convergence"); - println("-----------------------------------------"); - while 0.00001 < difference { - phi1 = 1.0 + (1.0 / phi0); - difference = abs(phi1 - phi0); - phi0 = phi1; - count += 1; - printf("Iteration {} : Estimate : {.8}\n", count, phi1); - } - println("-----------------------------------------"); - printf("Result: {} after {} iterations", phi1, count); - printf("\nThe error is approximately {.8}\n", (phi1 - (0.5 * (1.0 + sqrt_f64(5.0))))); - println("\n"); -} diff --git a/Task/Golden-ratio-Convergence/PascalABC.NET/golden-ratio-convergence.pas b/Task/Golden-ratio-Convergence/PascalABC.NET/golden-ratio-convergence.pas deleted file mode 100644 index ab76ee0240..0000000000 --- a/Task/Golden-ratio-Convergence/PascalABC.NET/golden-ratio-convergence.pas +++ /dev/null @@ -1,17 +0,0 @@ -begin - var phi := 1.0; - var phiprev := 0.0; - var n := 0; - var err := 0.0; - while True do - begin - n += 1; - phi := 1 + 1/phi; - err := Abs(phi - phiprev); - if err <= 1e-5 then - break; - phiprev := phi; - end; - Println($'Result = {phi} after {n} iterations'); - Println($'The error is approximately = {phi - (1+sqrt(5)) / 2}'); -end. diff --git a/Task/Golden-ratio-Convergence/Phix/golden-ratio-convergence.phix b/Task/Golden-ratio-Convergence/Phix/golden-ratio-convergence.phix index 4ec55e1c3f..48bad6392b 100644 --- a/Task/Golden-ratio-Convergence/Phix/golden-ratio-convergence.phix +++ b/Task/Golden-ratio-Convergence/Phix/golden-ratio-convergence.phix @@ -1,9 +1,11 @@ -with javascript_semantics -atom Phi = 1, iter = 0 -do - atom Pi = Phi - Phi = 1+1/Phi - iter += 1 -until abs(Phi-Pi)<1e-5 -printf(1,"Result: %.14f after %d iterations\n",{Phi,iter}) -printf(1,"Error: %.14f\n",{Phi-(1+sqrt(5))/2}) +(phixonline)--> + with javascript_semantics + atom Phi = 1, iter = 0 + do + atom Pi = Phi + Phi = 1+1/Phi + iter += 1 + until abs(Phi-Pi)<1e-5 + printf(1,"Result: %.14f after %d iterations\n",{Phi,iter}) + printf(1,"Error: %.14f\n",{Phi-(1+sqrt(5))/2}) + "; i; print Bin(i,5); " --> "; diff --git a/Task/Gray-code/Frink/gray-code.frink b/Task/Gray-code/Frink/gray-code.frink index 2d456adfa7..a145daca00 100644 --- a/Task/Gray-code/Frink/gray-code.frink +++ b/Task/Gray-code/Frink/gray-code.frink @@ -2,7 +2,5 @@ for i=0 to 31 { gray = binaryToGray[i] back = grayToBinary[gray] - println[pad[i->binary] + "\t" + pad[gray->binary] + "\t" + pad[back->binary]] + println[(i->binary) + "\t" + (gray->binary) + "\t" + (back->binary)] } - -pad[x] := padLeft[x,5,"0"] diff --git a/Task/Gray-code/FutureBasic/gray-code.basic b/Task/Gray-code/FutureBasic/gray-code.basic deleted file mode 100644 index 9bb50c362a..0000000000 --- a/Task/Gray-code/FutureBasic/gray-code.basic +++ /dev/null @@ -1,31 +0,0 @@ -// Gray Code -//https://rosettacode.org/wiki/Gray_code - -local fn gray2bin(g As uint32) As uint32 - uint32 b = g - While g - g = g >> 1 - b = b Xor g - Wend - Return b -End fn = b - -local fn bin2gray(b As uint32) As uint32 -End fn = b Xor (b >> 1) - -// ------=< MAIN >=------ - -uint32 i -Print " DEC Binary Gray GrayToBinary" - -For i = 0 To 31 - print str$(i) + " "; - if i < 10 then print " "; - print " " + right$(bin$(i),5); - print " -->"; - print " " + right$(bin$(fn bin2gray(i)),5); - print " -->"; - print " " + right$(bin$(fn gray2bin(fn bin2gray(i))),5) -Next - -handleevents diff --git a/Task/Gray-code/Jq/gray-code.jq b/Task/Gray-code/Jq/gray-code.jq deleted file mode 100644 index cb4f7ad97c..0000000000 --- a/Task/Gray-code/Jq/gray-code.jq +++ /dev/null @@ -1,38 +0,0 @@ -def encode: - def flip: if . == 1 then 0 else 1 end; - . as $b - | reduce range(1; length) as $i ($b; - if $b[$i-1] == 1 then .[$i] |= flip - else . - end ) ; - -def decode: - def xor($a;$b): ($a + $b) % 2; - . as $g - | reduce range(1; length) as $i (.[:1]; - .[$i] = xor($g[$i]; .[$i-1]) ) ; - - -# input: a non-negative integer -# output: a binary array, least-significant bit first -def to_binary: - if . == 0 then [0] - else [recurse( if . == 0 then empty else ./2 | floor end ) % 2] - | .[:-1] # remove the uninteresting 0 - end ; - -def lpad($len; $fill): - tostring - | ($len - length) as $l - | if $l <= 0 then . - else ($fill * $l)[:$l] + . - end; - -def pp: map(tostring) | join("") | lpad(5; "0"); - -### The task -"decimal binary gray roundtrip", -(range(0; 32) as $i - | ($i | to_binary | reverse) as $b - | ($b|encode) as $g - | " \($i|lpad(2;" ")) \($b|pp) \($g|pp) \($g|decode == $b)" ) diff --git a/Task/Gray-code/Julia/gray-code.jl b/Task/Gray-code/Julia/gray-code.julia similarity index 100% rename from Task/Gray-code/Julia/gray-code.jl rename to Task/Gray-code/Julia/gray-code.julia diff --git a/Task/Gray-code/Kotlin/gray-code.kts b/Task/Gray-code/Kotlin/gray-code.kotlin similarity index 100% rename from Task/Gray-code/Kotlin/gray-code.kts rename to Task/Gray-code/Kotlin/gray-code.kotlin diff --git a/Task/Gray-code/Liberty-BASIC/gray-code.basic b/Task/Gray-code/Liberty-BASIC/gray-code.basic index 44f2129ea9..14888831e6 100644 --- a/Task/Gray-code/Liberty-BASIC/gray-code.basic +++ b/Task/Gray-code/Liberty-BASIC/gray-code.basic @@ -7,6 +7,7 @@ B$ =Gray2Bin$( G$) print B$; " in pure binary." next r + end function Bin2Gray$( bin$) ' Given a binary number as a string, returns Gray code as a string. diff --git a/Task/Gray-code/Modula-2/gray-code.mod2 b/Task/Gray-code/Modula-2/gray-code.mod2 deleted file mode 100644 index 135aaa93e7..0000000000 --- a/Task/Gray-code/Modula-2/gray-code.mod2 +++ /dev/null @@ -1,57 +0,0 @@ -MODULE GrayCode; - -FROM STextIO IMPORT - WriteString, WriteLn; -FROM SWholeIO IMPORT - WriteInt; -FROM Conversions IMPORT - LongBaseToStr; -FROM FormatString IMPORT - FormatString; (* for justifying *) - -VAR - I, G, D: CARDINAL; - Ok: BOOLEAN; - BinS, OutBinS: ARRAY[0 .. 5] OF CHAR; - -PROCEDURE Encode(V: CARDINAL): CARDINAL; -BEGIN - RETURN V BXOR (V SHR 1) -END Encode; - -PROCEDURE Decode(V: CARDINAL): CARDINAL; -VAR - Result: CARDINAL; -BEGIN - Result := 0; - WHILE V > 0 DO - Result := Result BXOR V; - V := V SHR 1 - END; - RETURN Result -END Decode; - -BEGIN - WriteString("decimal binary gray decoded"); - WriteLn; - FOR I := 0 TO 31 DO - G := Encode(I); - D := Decode(G); - WriteInt(I, 4); - WriteString(" "); - Ok := LongBaseToStr(I, 2, BinS); - Ok := FormatString("%'05s", OutBinS, BinS); - (* Padded with 0; width: 5; type: string *) - WriteString(OutBinS); - WriteString(" "); - Ok := LongBaseToStr(G, 2, BinS); - Ok := FormatString("%'05s", OutBinS, BinS); - WriteString(OutBinS); - WriteString(" "); - Ok := LongBaseToStr(D, 2, BinS); - Ok := FormatString("%'05s", OutBinS, BinS); - WriteString(OutBinS); - WriteInt(D, 4); - WriteLn; - END -END GrayCode. diff --git a/Task/Gray-code/OCaml/gray-code.ml b/Task/Gray-code/OCaml/gray-code.ocaml similarity index 100% rename from Task/Gray-code/OCaml/gray-code.ml rename to Task/Gray-code/OCaml/gray-code.ocaml diff --git a/Task/Gray-code/PascalABC.NET/gray-code.pas b/Task/Gray-code/PascalABC.NET/gray-code.pas deleted file mode 100644 index e7f7d37b51..0000000000 --- a/Task/Gray-code/PascalABC.NET/gray-code.pas +++ /dev/null @@ -1,18 +0,0 @@ -uses School; - -function GrayEncode(n: longword): longword := n xor (n shr 1); - -function GrayDecode(n: longword): longword; -begin - Result := 0; - while n > 0 do - begin - Result := Result xor n; - n := n shr 1; - end; -end; - -begin - for var i := 0 to 31 do - Writeln($'{i,-7} {Bin(i),-7} {Bin(grayEncode(i)),-7} {grayDecode(grayEncode(i)),-7}'); -end. diff --git a/Task/Gray-code/Pluto/gray-code.pluto b/Task/Gray-code/Pluto/gray-code.pluto deleted file mode 100644 index cf0cab4ce4..0000000000 --- a/Task/Gray-code/Pluto/gray-code.pluto +++ /dev/null @@ -1,19 +0,0 @@ -local fmt = require "fmt" - -local function to_gray(n) return n ~ (n >> 1) end - -local function from_gray(g) - local b = 0 - while g != 0 do - b ~= g - g >>= 1 - end - return b -end - -print("decimal binary gray decoded") -for b = 0, 31 do - fmt.write(" %2d %05d", b, fmt.bin(b)) - local g = to_gray(b) - fmt.print(" %05d %05d", fmt.bin(g), fmt.bin(from_gray(g))) -end diff --git a/Task/Gray-code/PowerShell/gray-code.ps1 b/Task/Gray-code/PowerShell/gray-code.ps1 deleted file mode 100644 index 0becbcb13c..0000000000 --- a/Task/Gray-code/PowerShell/gray-code.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -# Gray code - -function Encode { - [OutputType([uint32])] - param([uint32]$V) - - return $V -bxor ($V -shr 1) -} - -function Decode { - [OutputType([uint32])] - param([uint32]$V) - - [uint32]$result = 0 - while ($V -gt 0) { - $result = $result -bxor $V - $V = $V -shr 1 - } - return $result -} - -Write-Output "decimal binary gray decoded" -foreach ($i in 0..31) { - [uint32]$g = Encode($i) - [uint32]$d = Decode($g) - [string]$out = @() - $out += "{0, 4} " -f $i - $binS = ([convert]::ToString($i, 2)).PadLeft(5, "0") - $out += "$binS " - $binS = ([convert]::ToString($g, 2)).PadLeft(5, "0") - $out += "$binS " - $binS = ([convert]::ToString($d, 2)).PadLeft(5, "0") - $out += "$binS{0, 4}" -f $d - Write-Output $out -} diff --git a/Task/Gray-code/Rust/gray-code.rs b/Task/Gray-code/Rust/gray-code.rust similarity index 100% rename from Task/Gray-code/Rust/gray-code.rs rename to Task/Gray-code/Rust/gray-code.rust diff --git a/Task/Gray-code/SETL/gray-code.setl b/Task/Gray-code/SETL/gray-code.setl deleted file mode 100644 index e5d368056b..0000000000 --- a/Task/Gray-code/SETL/gray-code.setl +++ /dev/null @@ -1,29 +0,0 @@ -program gray_code; - loop for n in [0..31] do - print( - lpad(str n, 2) + ": " + - lpad(bits n, 5) + " => " + - lpad(bits(g := gray_encode(n)), 5) + " => " + - lpad(bits(d := gray_decode(g)), 5) + ": " + - lpad(str d, 2) - ); - end loop; - - proc gray_encode(n); - return n bit_xor (n div 2); - end proc; - - proc gray_decode(n); - loop - init r := 0; - step n div:= 2; - until n=0 do r bit_xor:= n; - end loop; - return r; - end proc; - - op bits(n); - b := '' +/ [[str (n mod 2), n div:=2](1) : until n=0]; - return reverse(b); - end op; -end program; diff --git a/Task/Gray-code/VBScript/gray-code.vbs b/Task/Gray-code/VBScript/gray-code.vb similarity index 100% rename from Task/Gray-code/VBScript/gray-code.vbs rename to Task/Gray-code/VBScript/gray-code.vb diff --git a/Task/Gray-code/VHDL/gray-code-1.vhd b/Task/Gray-code/VHDL/gray-code-1.vhdl similarity index 100% rename from Task/Gray-code/VHDL/gray-code-1.vhd rename to Task/Gray-code/VHDL/gray-code-1.vhdl diff --git a/Task/Gray-code/VHDL/gray-code-2.vhd b/Task/Gray-code/VHDL/gray-code-2.vhdl similarity index 100% rename from Task/Gray-code/VHDL/gray-code-2.vhd rename to Task/Gray-code/VHDL/gray-code-2.vhdl diff --git a/Task/Gray-code/Wren/gray-code.wren b/Task/Gray-code/Wren/gray-code.wren index 8d50662588..1774f73d3e 100644 --- a/Task/Gray-code/Wren/gray-code.wren +++ b/Task/Gray-code/Wren/gray-code.wren @@ -1,4 +1,4 @@ -import "./fmt" for Fmt +import "/fmt" for Fmt var toGray = Fn.new { |n| n ^ (n>>1) } diff --git a/Task/Gray-code/Zig/gray-code.zig b/Task/Gray-code/Zig/gray-code.zig deleted file mode 100644 index 93a671caa5..0000000000 --- a/Task/Gray-code/Zig/gray-code.zig +++ /dev/null @@ -1,64 +0,0 @@ -const std = @import("std"); - -fn grayEncode(b: u32) u32 { - return b ^ (b >> 1); -} - -fn grayDecode(g: u32) u32 { - var result = g; - var bit: u32 = 1 << 31; - while (bit > 1) { - if (result & bit != 0) result ^= bit >> 1; - bit >>= 1; - } - return result; -} - -fn toBinary(value: u32, buffer: []u8) []const u8 { - if (value == 0) return "0"; - - var temp = value; - var highest_bit: u5 = 0; - // Find the highest bit set - while (temp != 0) : (temp >>= 1) { - highest_bit += 1; - } - - // Fill buffer from right to left - var i: usize = highest_bit; - temp = value; - while (i > 0) { - i -= 1; - buffer[i] = if (temp & 1 == 1) '1' else '0'; - temp >>= 1; - } - - // Find first '1' - for (buffer[0..highest_bit], 0..) |c, index| { - if (c == '1') { - return buffer[index..highest_bit]; - } - } - - return "0"; // Fallback -} - -pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - try stdout.print("Number\tBinary\tGray\tDecoded\n", .{}); - - // Pre-allocate a buffer big enough for 32-bit numbers - var binary_buffer: [32]u8 = undefined; - var gray_buffer: [32]u8 = undefined; - - for (0..32) |n| { - const n_u32: u32 = @intCast(n); - const g = grayEncode(n_u32); - std.debug.assert(grayDecode(g) == n_u32); - - const binary = toBinary(n_u32, &binary_buffer); - const grayBinary = toBinary(g, &gray_buffer); - - try stdout.print("{d}\t{s}\t{s}\t{d}\n", .{ n, binary, grayBinary, g }); - } -} diff --git a/Task/Grayscale-image/11l/grayscale-image.11l b/Task/Grayscale-image/11l/grayscale-image.11l index 3f4f195f10..2d3c981e9e 100644 --- a/Task/Grayscale-image/11l/grayscale-image.11l +++ b/Task/Grayscale-image/11l/grayscale-image.11l @@ -1,4 +1,13 @@ -T Colour = BVec3 +T Colour + Byte r, g, b + + F (r, g, b) + .r = r + .g = g + .b = b + + F ==(other) + R .r == other.r & .g == other.g & .b == other.b V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Grayscale-image/Ada/grayscale-image-1.adb b/Task/Grayscale-image/Ada/grayscale-image-1.ada similarity index 100% rename from Task/Grayscale-image/Ada/grayscale-image-1.adb rename to Task/Grayscale-image/Ada/grayscale-image-1.ada diff --git a/Task/Grayscale-image/Ada/grayscale-image-2.adb b/Task/Grayscale-image/Ada/grayscale-image-2.ada similarity index 100% rename from Task/Grayscale-image/Ada/grayscale-image-2.adb rename to Task/Grayscale-image/Ada/grayscale-image-2.ada diff --git a/Task/Grayscale-image/Ada/grayscale-image-3.adb b/Task/Grayscale-image/Ada/grayscale-image-3.ada similarity index 100% rename from Task/Grayscale-image/Ada/grayscale-image-3.adb rename to Task/Grayscale-image/Ada/grayscale-image-3.ada diff --git a/Task/Grayscale-image/Crystal/grayscale-image.cr b/Task/Grayscale-image/Crystal/grayscale-image.crystal similarity index 100% rename from Task/Grayscale-image/Crystal/grayscale-image.cr rename to Task/Grayscale-image/Crystal/grayscale-image.crystal diff --git a/Task/Grayscale-image/Euphoria/grayscale-image.eu b/Task/Grayscale-image/Euphoria/grayscale-image.euphoria similarity index 100% rename from Task/Grayscale-image/Euphoria/grayscale-image.eu rename to Task/Grayscale-image/Euphoria/grayscale-image.euphoria diff --git a/Task/Grayscale-image/Julia/grayscale-image-1.jl b/Task/Grayscale-image/Julia/grayscale-image-1.julia similarity index 100% rename from Task/Grayscale-image/Julia/grayscale-image-1.jl rename to Task/Grayscale-image/Julia/grayscale-image-1.julia diff --git a/Task/Grayscale-image/Julia/grayscale-image-2.jl b/Task/Grayscale-image/Julia/grayscale-image-2.julia similarity index 100% rename from Task/Grayscale-image/Julia/grayscale-image-2.jl rename to Task/Grayscale-image/Julia/grayscale-image-2.julia diff --git a/Task/Grayscale-image/Kotlin/grayscale-image.kts b/Task/Grayscale-image/Kotlin/grayscale-image.kotlin similarity index 100% rename from Task/Grayscale-image/Kotlin/grayscale-image.kts rename to Task/Grayscale-image/Kotlin/grayscale-image.kotlin diff --git a/Task/Grayscale-image/M2000-Interpreter/grayscale-image.m2000 b/Task/Grayscale-image/M2000-Interpreter/grayscale-image.m2000 index ed33411db2..229762871a 100644 --- a/Task/Grayscale-image/M2000-Interpreter/grayscale-image.m2000 +++ b/Task/Grayscale-image/M2000-Interpreter/grayscale-image.m2000 @@ -1,202 +1,201 @@ Module P6P5 { - Class Bitmap { - { // from version 14 - Var x As long, y As long, Import As boolean, P5 As boolean - If match("NN") Then - Read x, y - Else.if Match("N") Then - Read f As long - buffer whitespace As Byte - if not Eof(f) Then - get #f, whitespace :P6$=eval$(whitespace) - get #f, whitespace : P6$+=eval$(whitespace) - boolean getW=true, getH=true, getV=true - long v - P5=p6$=str$("P5") - If p6$=str$("P6") or P5 Then - do - get #f, whitespace - if Eval$(whitespace)=str$("#") Then - do - get #f, whitespace - until eval(whitespace)=10 - Else - select case eval(whitespace) - case 32, 9, 13, 10 - { - if getW and x<>0 Then - getW=false - Else.if getH and y<>0 Then - getH=false - Else.if getV and v<>0 Then - getV=false - End If - } - case 48 To 57 - { - if getW Then - x*=10 - x+=eval(whitespace, 0)-48 - Else.if getH Then - y*=10 - y+=eval(whitespace, 0)-48 - Else.if getV Then - v*=10 - v+=eval(whitespace, 0)-48 - End If - } - End Select - End If - iF eof(f) Then Error "Not a ppm file" - until getV=false - Else - Error "Not a P6 ppm or P5 ppm file" - End If - Import=True - End if - Else - Error "No proper arguments" - End If - if x<1 or y<1 Then Error "Wrong dimensions" - Buffer Clear Pad1 As Byte*3 - structure rgb { - red As Byte - green As Byte - blue As Byte - } - m=len(rgb)*x mod 4 - if m>0 Then m=4-m ' add some bytes To raster line - m+=len(rgb) *x - Structure rasterline { - { - pad As Byte*m - } - hline As rgb*x - } - Structure Raster { - magic As integer*4 - w As integer*4 - h As integer*4 - { - linesB As Byte*len(rasterline)*y - } - lines As rasterline*y - } - Buffer Clear Image1 As Raster - Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2) - if not Import Then Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y)) - Buffer Clear Pad As Byte*4 - aLines=Len(Raster)-Len(Rasterline)-Raster("linesB") - blines=-Len(Rasterline) - if Import Then - x0=x-1 : where=0 - Buffer Pad1 As Byte*3 - Buffer Pad2 As Byte - local rasterline=x*3 - m=rasterline mod 4 : if m<>0 Then rasterline+=4-m - For y1=y-1 To 0 - where=rasterline*y1 - For x1=0 To x0 - if p5 Then - Get #f, Pad2: m=eval(Pad2,0) : Return pad1, 0:=m, 1:=m, 2:=m - Else - Get #f, Pad1 : Push Eval(pad1, 2) : Return pad1, 2:=Eval(pad1, 0), 0:=Number - End if - Image1|linesB[where]=Pad1[0, 3] : where+=3 - Next - Next - End if - } - SetPixel=Lambda Image1, Pad, aLines, blines (x, y, c) ->{ - if c>0 Then c=color(c) - c-! - Return Pad, 0:=c As long - Push pad[2] : pad[2]=pad[0]: pad[0]=Number - Image1|linesB[alines+3*x+blines*y]=Pad[0, 3] - } - GetPixel=Lambda Image1,aLines, blines, Pad1 (x,y) ->{ - Pad1[0]=Image1|linesB[alines+3*x+blines*y, 3] - =color(Pad1[2], Pad1[1],Pad1[0]) - } - GetPixelGray=Lambda Image1,aLines, blines, Pad1 (x,y) ->{ - Pad1[0]=Image1|linesB[alines+3*x+blines*y, 3] - grayval=round(0.2126*Pad1[2] + 0.7152*Pad1[1] + 0.0722*Pad1[0], 0) - =color(grayval,grayval,grayval) - } - Image$=Lambda$ Image1, Raster ->Eval$(Image1, 0, Len(Raster)) - Copy=Lambda Image1 (image$) -> { - if left$(image$,12)=Image1[0, 24] Then - Return Image1, 0:=Image$ - Else - Error "Can't Copy Image" - End if - } - ToFile=Lambda Image1, x, y (f) -> { - Print #f, "P6";chr$(10);"# Created using M2000 Interpreter";chr$(10); - Print #f, x;" ";y;" 255";chr$(10); - x2=x-1 : where=0 : rasterline=x*3 - m=rasterline mod 4 : if m<>0 Then rasterline+=4-m - Buffer pad As Byte*3 - For y1=y-1 To 0 - where=rasterline*y1 - For x1=0 To x2 - pad[0]=image1|linesB[where, 3] - Push pad[2] : pad[2]=pad[0]: pad[0]=Number - Put #f, pad : where+=3 - Next - Next - } - ToFileGray=Lambda Image1, x, y (f) -> { - Print #f, "P5";chr$(10);"# Created using M2000 Interpreter";chr$(10); - Print #f, x;" ";y;" 255";chr$(10); - x2=x-1 : where=0 : rasterline=x*3 - m=rasterline mod 4 : if m<>0 Then rasterline+=4-m - Buffer pad As Byte*3 - Buffer bytepad As Byte - const R=0.2126, G=0.7152, B=0.0722 - For y1=y-1 To 0 - where=rasterline*y1 - For x1=0 To x2 - Return pad, 0:=eval$(image1, 0!linesB!where, 3) - Return bytepad, 0:=round(R*Eval(pad, 2) + G*Eval(pad, 1) + B*Eval(pad, 0), 0) - Put #f, bytepad : where+=3 - Next - Next - } - } - Cls 5,0 - A=Bitmap(15,10) - B=Bitmap(15,10) - c1=color(100, 200, 255) - c2=color(180, 250, 128) - For i=0 To 8 - Call A.SetPixel(i, i, c1) - Call A.SetPixel(9, i,c2) - Next - Call A.SetPixel(i,i,c1) - // make a new one GrayScale (but 24bit) As B - For i=0 To 14 { For J=0 To 9 {Call B.SetPixel(i, j, A.GetPixelGray(i,j))}} - // place image A at 200 pixel from left margin, 100 pixel from top margin - Copy 200*twipsX, 100*twipsY use A.Image$(), 0, 800 ' zoom 800%, angle 0 - // place image B at 400 pixel from left margin, 100 pixel from top margin - Copy 400*twipsX, 100*twipsY use B.Image$(), 0, 800 ' zoom 800% - Try { - Open "P6example.ppm" For Output As #f - Call A.Tofile(f) - Close #f - Open "P5example.ppm" For Output As #f - Call A.TofileGray(f) - Close #f - Open "P5example.ppm" For Input As #f - C=Bitmap(f) - close #f - Copy 600*twipsX, 100*twipsY use C.Image$(), 0, 800 ' zoom 800% - Open "P6example.ppm" For Input As #f - C=Bitmap(f) - close #f - // use of Top clause To make the border color transparent at rotation - Copy 800*twipsX, 100*twipsY top C.Image$(), 30, 800 ' zoom 800%, angle 30 degree - } - Print "Done" + Function Bitmap { + def x as long, y as long, Import as boolean, P5 as boolean + If match("NN") then { + Read x, y + } else.if Match("N") Then { + \\ is a file? + Read f as long + buffer whitespace as byte + if not Eof(f) then { + get #f, whitespace :P6$=eval$(whitespace) + get #f, whitespace : P6$+=eval$(whitespace) + def boolean getW=true, getH=true, getV=true + def long v + \\ str$("P6") has 2 bytes. "P6" has 4 bytes + P5=p6$=str$("P5") + If p6$=str$("P6") or P5 Then { + do { + get #f, whitespace + if Eval$(whitespace)=str$("#") then { + do {get #f, whitespace} until eval(whitespace)=10 + } else { + select case eval(whitespace) + case 32, 9, 13, 10 + { if getW and x<>0 then { + getW=false + } else.if getH and y<>0 then { + getH=false + } else.if getV and v<>0 then { + getV=false + } + } + case 48 to 57 + {if getW then { + x*=10 + x+=eval(whitespace, 0)-48 + } else.if getH then { + y*=10 + y+=eval(whitespace, 0)-48 + } else.if getV then { + v*=10 + v+=eval(whitespace, 0)-48 + } + } + End Select + } + iF eof(f) then Error "Not a ppm file" + } until getV=false + } else Error "Not a P6 ppm or P5 ppm file" + Import=True + } + } else Error "No proper arguments" + if x<1 or y<1 then Error "Wrong dimensions" + structure rgb { + red as byte + green as byte + blue as byte + } + m=len(rgb)*x mod 4 + if m>0 then m=4-m ' add some bytes to raster line + m+=len(rgb) *x + Structure rasterline { + { + pad as byte*m + } + hline as rgb*x + } + Structure Raster { + magic as integer*4 + w as integer*4 + h as integer*4 + { + linesB as byte*len(rasterline)*y + } + lines as rasterline*y + } + Buffer Clear Image1 as Raster + Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2) + if not Import then Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y)) + Buffer Clear Pad as Byte*4 + SetPixel=Lambda Image1, Pad,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{ + where=alines+3*x+blines*y + if c>0 then c=color(c) + c-! + Return Pad, 0:=c as long + Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte + } + GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{ + where=alines+3*x+blines*y + =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte)) + } + GetPixelGray=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{ + where=alines+3*x+blines*y + grayval=round(0.2126*Eval(image1, where+2 as byte) + 0.7152*Eval(image1, where+1 as byte) + 0.0722*Eval(image1, where as byte), 0) + =color(grayval,grayval,grayval) + } + StrDib$=Lambda$ Image1, Raster -> { + =Eval$(Image1, 0, Len(Raster)) + } + CopyImage=Lambda Image1 (image$) -> { + if left$(image$,12)=Eval$(Image1, 0, 24 ) Then { + Return Image1, 0:=Image$ + } Else Error "Can't Copy Image" + } + Export2File=Lambda Image1, x, y (f) -> { + Print #f, "P6";chr$(10);"# Created using M2000 Interpreter";chr$(10); + Print #f, x;" ";y;" 255";chr$(10); + x2=x-1 : where=0 : rasterline=x*3 + m=rasterline mod 4 : if m<>0 then rasterline+=4-m + Buffer pad as byte*3 + For y1=y-1 to 0 { + where=rasterline*y1 + For x1=0 to x2 { + Return pad, 0:=eval$(image1, 0!linesB!where, 3) + Push Eval(pad, 2) : Return pad, 2:=Eval(pad, 0), 0:=Number + Put #f, pad : where+=3 + } + } + } + Export2FileGray=Lambda Image1, x, y (f) -> { + Print #f, "P5";chr$(10);"# Created using M2000 Interpreter";chr$(10); + Print #f, x;" ";y;" 255";chr$(10); + x2=x-1 : where=0 : rasterline=x*3 + m=rasterline mod 4 : if m<>0 then rasterline+=4-m + Buffer pad as byte*3 + Buffer bytepad as byte + const R=0.2126, G=0.7152, B=0.0722 + For y1=y-1 to 0 { + where=rasterline*y1 + For x1=0 to x2 { + Return pad, 0:=eval$(image1, 0!linesB!where, 3) + Return bytepad, 0:=round(R*Eval(pad, 2) + G*Eval(pad, 1) + B*Eval(pad, 0), 0) + Put #f, bytepad : where+=3 + } + } + } + if Import then { + x0=x-1 : where=0 + Buffer Pad1 as byte*3 + Buffer Pad2 as byte + local rasterline=x*3 + m=rasterline mod 4 : if m<>0 then rasterline+=4-m + For y1=y-1 to 0 { + where=rasterline*y1 + For x1=0 to x0 { + if p5 then + Get #f, Pad2: m=eval(Pad2,0) : Return pad1, 0:=m, 1:=m, 2:=m + else + Get #f, Pad1 : Push Eval(pad1, 2) : Return pad1, 2:=Eval(pad1, 0), 0:=Number + End if + Return Image1, 0!linesB!where:=Eval$(Pad1) : where+=3 + } + } + } + Group Bitmap { + SetPixel=SetPixel + GetPixel=GetPixel + Image$=StrDib$ + Copy=CopyImage + ToFile=Export2File + ToFileGray=Export2FileGray + GetPixelGray=GetPixelGray + } + =Bitmap + } + Cls 5,0 + A=Bitmap(15,10) + B=Bitmap(15,10) + c1=color(100, 200, 255) + c2=color(180, 250, 128) + For i=0 to 8 + Call A.SetPixel(i, i, c1) + Call A.SetPixel(9, i,c2) + Next + Call A.SetPixel(i,i,c1) + // make a new one GrayScale (but 24bit) as B + For i=0 to 14 { For J=0 to 9 {Call B.SetPixel(i, j, A.GetPixelGray(i,j))}} + // place image A at 200 pixel from left margin, 100 pixel from top margin + Copy 200*twipsX, 100*twipsY use A.Image$(), 0, 400 ' zoom 400%, angle 0 + // place image B at 400 pixel from left margin, 100 pixel from top margin + Copy 400*twipsX, 100*twipsY use B.Image$(), 0, 400 ' zoom 400% + Try { + Open "P6example.ppm" For Output as #f + Call A.Tofile(f) + Close #f + Open "P5example.ppm" For Output as #f + Call A.TofileGray(f) + Close #f + Open "P5example.ppm" For Input as #f + C=Bitmap(f) + close #f + Copy 600*twipsX, 100*twipsY use C.Image$(), 0, 400 ' zoom 400% + Open "P6example.ppm" For Input as #f + C=Bitmap(f) + close #f + // use of Top clause to make the border color transparent at rotation + Copy 800*twipsX, 100*twipsY top C.Image$(), 30, 400 ' zoom 400%, angle 30 degree + } + Print "Done" } P6P5 diff --git a/Task/Grayscale-image/MiniScript/grayscale-image.mini b/Task/Grayscale-image/MiniScript/grayscale-image.mini deleted file mode 100644 index 062d6fb5d8..0000000000 --- a/Task/Grayscale-image/MiniScript/grayscale-image.mini +++ /dev/null @@ -1,34 +0,0 @@ -greyedColor = function(colr) - clist = color.toList(colr) - lum = [0.2126, 0.7152, 0.0722] - - red = clist[0] * lum[0] - green = clist[1] * lum[1] - blue = clist[2] * lum[2] - grey = red + green + blue - return color.fromList([grey, grey, grey, clist[3]]) -end function - -toGreyScale = function(img) - greyImg = Image.create(img.width, img.height) - for x in range(0, img.width - 1) - for y in range(0, img.height - 1) - greyed = greyedColor(img.pixel(x, y)) - greyImg.setPixel x, y, greyed - end for - end for - return greyImg -end function - -clear - -// The turtle and color wheel images are included with MiniMicro -turtle = file.loadImage("/sys/pics/animals/turtle.png") -greyTurtle = toGreyScale(turtle) -gfx.drawImage turtle, 0, 0 -gfx.drawImage greyTurtle, turtle.width, 0 - -colorWheel = file.loadImage("/sys/pics/ColorWheel.png") -greyWheel = toGreyScale(colorWheel) -gfx.drawImage colorWheel, 0, 320 -gfx.drawImage greyWheel, greyWheel.width, 320 diff --git a/Task/Grayscale-image/OCaml/grayscale-image-1.ml b/Task/Grayscale-image/OCaml/grayscale-image-1.ocaml similarity index 100% rename from Task/Grayscale-image/OCaml/grayscale-image-1.ml rename to Task/Grayscale-image/OCaml/grayscale-image-1.ocaml diff --git a/Task/Grayscale-image/OCaml/grayscale-image-2.ml b/Task/Grayscale-image/OCaml/grayscale-image-2.ocaml similarity index 100% rename from Task/Grayscale-image/OCaml/grayscale-image-2.ml rename to Task/Grayscale-image/OCaml/grayscale-image-2.ocaml diff --git a/Task/Grayscale-image/OCaml/grayscale-image-3.ml b/Task/Grayscale-image/OCaml/grayscale-image-3.ocaml similarity index 100% rename from Task/Grayscale-image/OCaml/grayscale-image-3.ml rename to Task/Grayscale-image/OCaml/grayscale-image-3.ocaml diff --git a/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg b/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg index 1f11565746..2e357e0524 100644 --- a/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg +++ b/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg @@ -1,24 +1,17 @@ -BEGIN - PROC gcd = (INT m, n) INT: ( - IF INT a = ABS m, b = ABS n; - a = 0 - THEN - b - ELIF b = 0 THEN - a - ELIF a > b THEN - gcd(b, a MOD b) - ELSE - gcd(a, b MOD a) - FI - ); - test:( - FOR a FROM 33 BY -33 TO -33 DO - FOR b FROM 77 BY -77 TO -77 DO - print(("The gcd of ", whole(a,-6)," and ", whole(b,-6)," is ", whole(gcd(a,b),-6),newline)) - OD - OD; - INT c = 49865, d = 69811; - print(("The gcd of ", whole(c,-6)," and ", whole(d,-6)," is ", whole(gcd(c,d),-6),newline)) - ) -END +PROC gcd = (INT a, b) INT: ( + IF a = 0 THEN + b + ELIF b = 0 THEN + a + ELIF a > b THEN + gcd(b, a MOD b) + ELSE + gcd(a, b MOD a) + FI +); +test:( + INT a = 33, b = 77; + printf(($x"The gcd of"g" and "g" is "gl$,a,b,gcd(a,b))); + INT c = 49865, d = 69811; + printf(($x"The gcd of"g" and "g" is "gl$,c,d,gcd(c,d))) +) diff --git a/Task/Greatest-common-divisor/Ada/greatest-common-divisor.adb b/Task/Greatest-common-divisor/Ada/greatest-common-divisor.ada similarity index 100% rename from Task/Greatest-common-divisor/Ada/greatest-common-divisor.adb rename to Task/Greatest-common-divisor/Ada/greatest-common-divisor.ada diff --git a/Task/Greatest-common-divisor/AutoIt/greatest-common-divisor.au3 b/Task/Greatest-common-divisor/AutoIt/greatest-common-divisor.autoit similarity index 100% rename from Task/Greatest-common-divisor/AutoIt/greatest-common-divisor.au3 rename to Task/Greatest-common-divisor/AutoIt/greatest-common-divisor.autoit diff --git a/Task/Greatest-common-divisor/Ballerina/greatest-common-divisor.ballerina b/Task/Greatest-common-divisor/Ballerina/greatest-common-divisor.ballerina deleted file mode 100644 index e203dc5ef4..0000000000 --- a/Task/Greatest-common-divisor/Ballerina/greatest-common-divisor.ballerina +++ /dev/null @@ -1,21 +0,0 @@ -import ballerina/io; - -function gcd(int u, int v) returns int { - int _u = u; - int _v = v; - while _v != 0 { - [_u, _v] = [_v, _u % _v]; - } - return _u.abs(); -} - -public function main() { - io:println(gcd(0, 0)); - io:println(gcd(0, 10)); - io:println(gcd(0, -10)); - io:println(gcd(9, 6)); - io:println(gcd(6, 9)); - io:println(gcd(-6, 9)); - io:println(gcd(8, 45)); - io:println(gcd(40902, 24140)); -} diff --git a/Task/Greatest-common-divisor/Bruijn/greatest-common-divisor.bruijn b/Task/Greatest-common-divisor/Bruijn/greatest-common-divisor.bruijn deleted file mode 100644 index 37bbb66bb1..0000000000 --- a/Task/Greatest-common-divisor/Bruijn/greatest-common-divisor.bruijn +++ /dev/null @@ -1,8 +0,0 @@ -:import std/Combinator . -:import std/Number . - -gcd y [[[=?0 1 (2 0 (1 % 0))]]] - -:test ((gcd (+2) (+4)) =? (+2)) ([[1]]) -:test ((gcd (+10) (+5)) =? (+5)) ([[1]]) -:test ((gcd (+3) (+8)) =? (+1)) ([[1]]) diff --git a/Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cob b/Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cobol similarity index 100% rename from Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cob rename to Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cobol diff --git a/Task/Greatest-common-divisor/Chipmunk-Basic/greatest-common-divisor.basic b/Task/Greatest-common-divisor/Chipmunk-Basic/greatest-common-divisor.basic deleted file mode 100644 index b633cc3739..0000000000 --- a/Task/Greatest-common-divisor/Chipmunk-Basic/greatest-common-divisor.basic +++ /dev/null @@ -1,15 +0,0 @@ -100 cls -110 a = 40902 -120 b = 24140 -130 print : print "GCD(";a;", ";b;") = ";gcdi(a,b) -140 print : print "GCD(";a;", 111) = ";gcdi(a,111) -170 end - -190 sub gcdi(x,y) -200 while y -210 t = y -220 y = x mod y -230 x = t -240 wend -250 gcdi = x -260 end sub diff --git a/Task/Greatest-common-divisor/Crystal/greatest-common-divisor.cr b/Task/Greatest-common-divisor/Crystal/greatest-common-divisor.cr deleted file mode 100644 index f4717cf74a..0000000000 --- a/Task/Greatest-common-divisor/Crystal/greatest-common-divisor.cr +++ /dev/null @@ -1 +0,0 @@ -2345.gcd 5432 #=> 7 diff --git a/Task/Greatest-common-divisor/Dt/greatest-common-divisor.dt b/Task/Greatest-common-divisor/Dt/greatest-common-divisor.dt deleted file mode 100644 index 52034fc15d..0000000000 --- a/Task/Greatest-common-divisor/Dt/greatest-common-divisor.dt +++ /dev/null @@ -1 +0,0 @@ -[[a b]: a [b a b % gcd] b do?] \gcd def diff --git a/Task/Greatest-common-divisor/DuckDB/greatest-common-divisor.duckdb b/Task/Greatest-common-divisor/DuckDB/greatest-common-divisor.duckdb deleted file mode 100644 index 9114ccd611..0000000000 --- a/Task/Greatest-common-divisor/DuckDB/greatest-common-divisor.duckdb +++ /dev/null @@ -1,12 +0,0 @@ -create or replace function mygcd(a0, b0) as ( - with recursive cte as ( - select a0 as a, b0 as b - union all - select b as a, mod(a,b) as b - from cte - where b != 0 - ) - select last(a) - from cte - where b=0 -); diff --git a/Task/Greatest-common-divisor/EMal/greatest-common-divisor.emal b/Task/Greatest-common-divisor/EMal/greatest-common-divisor.emal deleted file mode 100644 index bbb6e1a9ab..0000000000 --- a/Task/Greatest-common-divisor/EMal/greatest-common-divisor.emal +++ /dev/null @@ -1,14 +0,0 @@ -fun gcd ← int by int a, int b - while b ≠ 0 - int t ← b - b ← a % b - a ← t - end - return abs(a) -end -writeLine(gcd(0, 0)) -writeLine(gcd(0, -10)) -writeLine(gcd(-6, 9)) -writeLine(gcd(40902, 24140)) -writeLine(gcd(9360, 12240)) -writeLine(gcd(123456789, 987654321)) diff --git a/Task/Greatest-common-divisor/EasyLang/greatest-common-divisor.easy b/Task/Greatest-common-divisor/EasyLang/greatest-common-divisor.easy index b66fa24d09..56852717f9 100644 --- a/Task/Greatest-common-divisor/EasyLang/greatest-common-divisor.easy +++ b/Task/Greatest-common-divisor/EasyLang/greatest-common-divisor.easy @@ -1,8 +1,10 @@ -func gcd a b . - while b <> 0 - swap a b - b = b mod a - . - return a +proc gcd a b . res . + while b <> 0 + h = b + b = a mod b + a = h + . + res = a . -print gcd 120 35 +call gcd 120 35 r +print r diff --git a/Task/Greatest-common-divisor/Elena/greatest-common-divisor.elena b/Task/Greatest-common-divisor/Elena/greatest-common-divisor.elena index 07bf136003..8d3b778db8 100644 --- a/Task/Greatest-common-divisor/Elena/greatest-common-divisor.elena +++ b/Task/Greatest-common-divisor/Elena/greatest-common-divisor.elena @@ -17,10 +17,10 @@ gcd(a,b) printGCD(a,b) { - Console.printLineFormatted("GCD of {0} and {1} is {2}", a, b, gcd(a,b)) + console.printLineFormatted("GCD of {0} and {1} is {2}", a, b, gcd(a,b)) } -public Program() +public program() { printGCD(1,1); printGCD(1,10); diff --git a/Task/Greatest-common-divisor/Elixir/greatest-common-divisor.ex b/Task/Greatest-common-divisor/Elixir/greatest-common-divisor.elixir similarity index 100% rename from Task/Greatest-common-divisor/Elixir/greatest-common-divisor.ex rename to Task/Greatest-common-divisor/Elixir/greatest-common-divisor.elixir diff --git a/Task/Greatest-common-divisor/Elm/greatest-common-divisor.elm b/Task/Greatest-common-divisor/Elm/greatest-common-divisor.elm deleted file mode 100644 index 600d41fbf4..0000000000 --- a/Task/Greatest-common-divisor/Elm/greatest-common-divisor.elm +++ /dev/null @@ -1,37 +0,0 @@ -import Html exposing (Html, div, h1, p, text) -import Html.Attributes exposing (style) - - --- Test cases - -nr1 : Int -nr1 = - 2 * 3 * 5 * 7 * 11 - - -nr2 : Int -nr2 = - 7 * 11 * 13 * 17 * 23 - - -main : Html msg -main = - div [ style "margin" "5%", style "font-size" "1.5em", style "color" "blue" ] - [ h1 [ style "font-size" "1.5em" ] [ text "GCD Calculator" ] - , text - ("number a = " - ++ String.fromInt nr1 - ++ ", number b = " - ++ String.fromInt nr2 - ) - , p [] [ text ("GCD = " ++ String.fromInt (gcd nr1 nr2)) ] - ] - - -gcd : Int -> Int -> Int -gcd anr bnr = - if bnr /= 0 then - gcd bnr (modBy bnr anr) - - else - abs anr diff --git a/Task/Greatest-common-divisor/Emacs-Lisp/greatest-common-divisor.el b/Task/Greatest-common-divisor/Emacs-Lisp/greatest-common-divisor.l similarity index 100% rename from Task/Greatest-common-divisor/Emacs-Lisp/greatest-common-divisor.el rename to Task/Greatest-common-divisor/Emacs-Lisp/greatest-common-divisor.l diff --git a/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.eu b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.euphoria similarity index 100% rename from Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.eu rename to Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.euphoria diff --git a/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.eu b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.euphoria similarity index 100% rename from Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.eu rename to Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.euphoria diff --git a/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.eu b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.euphoria similarity index 100% rename from Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.eu rename to Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.euphoria diff --git a/Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor-2.fs b/Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor-2.fs deleted file mode 100644 index 121ed1a89b..0000000000 --- a/Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor-2.fs +++ /dev/null @@ -1,5 +0,0 @@ -// GCD method attributed to Dijkstra. Nigel Galloway: February 7th., 2026. -let rec gcd n=function g when n=g->n - |g when ngcd (g-n) n - |g->gcd g (n-g) -printfn "%d, %d, %d" (gcd 23 13) (gcd 600 400) (gcd 0 0) diff --git a/Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor-1.fs b/Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor.fs similarity index 100% rename from Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor-1.fs rename to Task/Greatest-common-divisor/F-Sharp/greatest-common-divisor.fs diff --git a/Task/Greatest-common-divisor/FutureBasic/greatest-common-divisor.basic b/Task/Greatest-common-divisor/FutureBasic/greatest-common-divisor.basic index 5ec8eb36e6..8b50cf0c2e 100644 --- a/Task/Greatest-common-divisor/FutureBasic/greatest-common-divisor.basic +++ b/Task/Greatest-common-divisor/FutureBasic/greatest-common-divisor.basic @@ -1,56 +1,15 @@ -begin enum 1 // Object tags - _fldA - _ansA - _fldB - _ansB - _rand -end enum +window 1, @"Greatest Common Divisor", (0,0,480,270) -void local fn BuildMacInterface //15-line GUI - window 1, @"Greatest Common Divisor", ( 0, 0, 380, 130 ), NSWindowStyleMaskTitled + NSWindowStyleMaskClosable - textfield _fldA,,, ( 20, 89, 156, 21 ) - ControlSetAlignment( _fldA, NSTextAlignmentRight ) - ControlSetFormat( _fldA, @"0123456789", Yes, 18, 0 ) - textfield _fldB,,, ( 20, 57, 156, 24 ) - ControlSetAlignment( _fldB, NSTextAlignmentRight ) - ControlSetFormat( _fldB, @"0123456789", Yes, 18, 0 ) - textlabel _ansA, @"= ", ( 182, 91, 185, 16 ) - textlabel _ansB, @"= ", ( 182, 62, 185, 16 ) - button _rand,,,@"Random demo", ( 129, 13, 122, 32 ) - menu 1,,, @"File" : menu 1,0,, @"Close", @"w" : MenuItemSetAction(1,0,@"performClose:") - editmenu 2 - WindowMakeFirstResponder( 1, _fldA ) -end fn +local fn gcd( a as short, b as short ) as short + short result -local fn GCD( a as long, b as long ) as long //the requested function - while b - long c = a mod b - a = b : b = c - wend -end fn = a + if ( b != 0 ) + result = fn gcd( b, a mod b) + else + result = abs(a) + end if +end fn = result -void local fn DoDialog( ev as Long, tag as long ) //This makes it interactive - long a, b, c - select ev - case _textFieldDidchange //Find GCD of edit fields' contents - a = fn ControlIntegerValue( _fldA ) - b = fn ControlIntegerValue( _fldB ) - if a + b == 0 then textlabel _ansA, @"= 0" : textlabel _ansB, @"= 0" : exit fn - c = fn GCD( a, b ) - textlabel _ansA, fn stringwithformat(@"= %ld x %ld", c, a / c ) - textlabel _ansB, fn stringwithformat(@"= %ld x %ld", c, b / c ) - case _btnclick //Fill edit fields with random content, then process - select tag - case _rand - c = rnd(65536) - textfield _fldA,,str( c * rnd(65536) ) - textfield _fldB,,str( c * rnd(65536) ) - fn DoDialog( _textFieldDidchange, 0 ) - end select - case _windowWillClose : end - end select -end fn +print fn gcd( 6, 9 ) -fn BuildMacInterface -on dialog fn doDialog -handleevents +HandleEvents diff --git a/Task/Greatest-common-divisor/Gleam/greatest-common-divisor.gleam b/Task/Greatest-common-divisor/Gleam/greatest-common-divisor.gleam deleted file mode 100644 index f5187521b9..0000000000 --- a/Task/Greatest-common-divisor/Gleam/greatest-common-divisor.gleam +++ /dev/null @@ -1,19 +0,0 @@ -import gleam/int -import gleam/io - -pub fn main() { - gcd(40_902, 24_140) - |> int.to_string - |> io.println -} - -pub fn gcd(a, b) { - gcd_loop(int.absolute_value(a), int.absolute_value(b)) -} - -fn gcd_loop(a, b) { - case b { - 0 -> a - _ -> gcd_loop(b, a % b) - } -} diff --git a/Task/Greatest-common-divisor/Hoon/greatest-common-divisor.hoon b/Task/Greatest-common-divisor/Hoon/greatest-common-divisor.hoon deleted file mode 100644 index effc940b78..0000000000 --- a/Task/Greatest-common-divisor/Hoon/greatest-common-divisor.hoon +++ /dev/null @@ -1,9 +0,0 @@ -:: -:: Greatest common divisor (gcd), Euclid's algorithm. -:: -|= [a=@ud b=@ud] -^- @ud -?> (gth b 0) -?: =((mod a b) 0) - b -$(a b, b (mod a b)) diff --git a/Task/Greatest-common-divisor/J/greatest-common-divisor-3.j b/Task/Greatest-common-divisor/J/greatest-common-divisor-3.j index f34b6cd4f7..a4531536ed 100644 --- a/Task/Greatest-common-divisor/J/greatest-common-divisor-3.j +++ b/Task/Greatest-common-divisor/J/greatest-common-divisor-3.j @@ -1 +1 @@ -gcd=: (| $: [)^:(0<[)&| +gcd=: (| gcd [)^:(0<[)&| diff --git a/Task/Greatest-common-divisor/Julia/greatest-common-divisor.jl b/Task/Greatest-common-divisor/Julia/greatest-common-divisor.julia similarity index 100% rename from Task/Greatest-common-divisor/Julia/greatest-common-divisor.jl rename to Task/Greatest-common-divisor/Julia/greatest-common-divisor.julia diff --git a/Task/Greatest-common-divisor/Kotlin/greatest-common-divisor.kts b/Task/Greatest-common-divisor/Kotlin/greatest-common-divisor.kotlin similarity index 100% rename from Task/Greatest-common-divisor/Kotlin/greatest-common-divisor.kts rename to Task/Greatest-common-divisor/Kotlin/greatest-common-divisor.kotlin diff --git a/Task/Greatest-common-divisor/LOLCODE/greatest-common-divisor.lol b/Task/Greatest-common-divisor/LOLCODE/greatest-common-divisor.lol index b261e752da..655b749ee7 100644 --- a/Task/Greatest-common-divisor/LOLCODE/greatest-common-divisor.lol +++ b/Task/Greatest-common-divisor/LOLCODE/greatest-common-divisor.lol @@ -1,32 +1,36 @@ HAI 1.3 -HOW IZ I gcd YR a AN YR b BTW ITERATIF GCD - a R BIGGR OF a AN PRODUKT OF a AN -1 BTW absolute value of a - b R BIGGR OF b AN PRODUKT OF b AN -1 BTW absolute value of b - BOTH SAEM a AN b, O RLY? - YA RLY - FOUND YR a - MEBBE BOTH SAEM a AN 0, - FOUND YR b - MEBBE BOTH SAEM b AN 0, - FOUND YR a - NO WAI - BOTH SAEM b AN BIGGR OF a AN b, O RLY? BTW make sure a is the larger of (a, b) - YA RLY - I HAS A temp ITZ a - a R b - b R temp - OIC - IM IN YR loop - I HAS A temp ITZ b - b R MOD OF a AN b - a R temp - BOTH SAEM b AN 0, O RLY? - YA RLY - FOUND YR a - OIC - IM OUTTA YR loop - OIC +HOW IZ I gcd YR a AN YR b + a R BIGGR OF a AN PRODUKT OF a AN -1 BTW absolute value of a + b R BIGGR OF b AN PRODUKT OF b AN -1 BTW absolute value of b + BOTH SAEM a AN b, O RLY? + YA RLY + FOUND YR a + OIC + BOTH SAEM a AN 0, O RLY? + YA RLY + FOUND YR b + OIC + BOTH SAEM b AN 0, O RLY? + YA RLY + FOUND YR a + OIC + BOTH SAEM b AN BIGGR OF a AN b, O RLY? BTW make sure a is the larger of (a, b) + YA RLY + I HAS A temp ITZ a + a R b + b R temp + OIC + + IM IN YR loop + I HAS A temp ITZ b + b R MOD OF a AN b + a R temp + BOTH SAEM b AN 0, O RLY? + YA RLY + FOUND YR a + OIC + IM OUTTA YR loop IF U SAY SO VISIBLE I IZ gcd YR 40902 AN YR 24140 MKAY diff --git a/Task/Greatest-common-divisor/Nu/greatest-common-divisor.nu b/Task/Greatest-common-divisor/Nu/greatest-common-divisor.nu deleted file mode 100644 index d2e0ca06ca..0000000000 --- a/Task/Greatest-common-divisor/Nu/greatest-common-divisor.nu +++ /dev/null @@ -1,8 +0,0 @@ -def 'math gcd' [] { - reduce {|x gcd| - generate { match $in { [$a 0] => {out: $a} [$a $b] => {next: [$b ($a mod $b)]} } } [$x $gcd] - | first - } -} - -[63 18 45] | math gcd diff --git a/Task/Greatest-common-divisor/OCaml/greatest-common-divisor-1.ml b/Task/Greatest-common-divisor/OCaml/greatest-common-divisor-1.ocaml similarity index 100% rename from Task/Greatest-common-divisor/OCaml/greatest-common-divisor-1.ml rename to Task/Greatest-common-divisor/OCaml/greatest-common-divisor-1.ocaml diff --git a/Task/Greatest-common-divisor/OCaml/greatest-common-divisor-2.ml b/Task/Greatest-common-divisor/OCaml/greatest-common-divisor-2.ocaml similarity index 100% rename from Task/Greatest-common-divisor/OCaml/greatest-common-divisor-2.ml rename to Task/Greatest-common-divisor/OCaml/greatest-common-divisor-2.ocaml diff --git a/Task/Greatest-common-divisor/Oberon-2/greatest-common-divisor.oberon b/Task/Greatest-common-divisor/Oberon-2/greatest-common-divisor.oberon new file mode 100644 index 0000000000..e81af17de6 --- /dev/null +++ b/Task/Greatest-common-divisor/Oberon-2/greatest-common-divisor.oberon @@ -0,0 +1,22 @@ +MODULE GCD; +(* Greatest Common Divisor *) +IMPORT + Out; + + PROCEDURE Gcd(a,b: LONGINT):LONGINT; + VAR + r: LONGINT; + BEGIN + LOOP + r := a MOD b; + IF r = 0 THEN RETURN b END; + a := b;b := r + END + END Gcd; +BEGIN + Out.String("GCD of 12 and 8 : ");Out.LongInt(Gcd(12,8),4);Out.Ln; + Out.String("GCD of 100 and 5 : ");Out.LongInt(Gcd(100,5),4);Out.Ln; + Out.String("GCD of 7 and 23 : ");Out.LongInt(Gcd(7,23),4);Out.Ln; + Out.String("GCD of 24 and -112 : ");Out.LongInt(Gcd(12,8),4);Out.Ln; + Out.String("GCD of 40902 and 24140 : ");Out.LongInt(Gcd(40902,24140),4);Out.Ln +END GCD. diff --git a/Task/Greatest-common-divisor/Pascal/greatest-common-divisor.pas b/Task/Greatest-common-divisor/Pascal/greatest-common-divisor.pas deleted file mode 100644 index 3766737710..0000000000 --- a/Task/Greatest-common-divisor/Pascal/greatest-common-divisor.pas +++ /dev/null @@ -1,17 +0,0 @@ -program GCF (INPUT, OUTPUT); - var - a,b,c:integer; - begin - writeln('Enter 1st number'); - read(a); - writeln('Enter 2nd number'); - read(b); - while (a*b<>0) - do - begin - c:=a; - a:=b mod a; - b:=c; - end; - writeln('GCF :=', a+b ); - end. diff --git a/Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas b/Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas deleted file mode 100644 index 7457c48563..0000000000 --- a/Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas +++ /dev/null @@ -1,18 +0,0 @@ -function GCD(a,b: integer): integer; -begin - while b > 0 do - (a,b) := (b,a mod b); - Result := a; -end; - -function GCDRec(a,b: integer): integer; -begin - if b = 0 then - Result := a - else Result := GCDRec(b, a mod b); -end; - -begin - Println(GCD(72,30),GCDRec(72,30)); - Println(GCD(49865, 69811),GCDRec(49865, 69811)); -end. diff --git a/Task/Greatest-common-divisor/Pluto/greatest-common-divisor.pluto b/Task/Greatest-common-divisor/Pluto/greatest-common-divisor.pluto deleted file mode 100644 index 9ead7fee31..0000000000 --- a/Task/Greatest-common-divisor/Pluto/greatest-common-divisor.pluto +++ /dev/null @@ -1,8 +0,0 @@ -function gcd(a,b) - while b~=0 do - a,b=b,a%b - end - return a -end - -print(gcd(56,98)) diff --git a/Task/Greatest-common-divisor/PowerPC-Assembly/greatest-common-divisor.ppc b/Task/Greatest-common-divisor/PowerPC-Assembly/greatest-common-divisor.ppc deleted file mode 100644 index 536b6851ed..0000000000 --- a/Task/Greatest-common-divisor/PowerPC-Assembly/greatest-common-divisor.ppc +++ /dev/null @@ -1,123 +0,0 @@ -#include -_gcd_string: - .ascii "gcd(" - _gcd_string_len = . - _gcd_string -_gcd_close_string: - .ascii ") = " - _gcd_close_string_len = . - _gcd_close_string - - .equiv STDIN, 0 - .equiv STDOUT, 1 - - .align 4 - .section ".text" - .global _start - .section ".opd","aw" - .align 3 -_start: - .quad ._start,.TOC.@tocbase,0 - .previous - .global ._start -._start: - li r30, 1071 - li r31, 1029 - # move the loaded values into the argument registers - mr r3, r30 - mr r4, r31 - bl gcd - # save the result for printing later - mr r29, r3 - addis r4, r2, _gcd_string@toc@ha - addi r4, r4, _gcd_string@toc@l - li r5, _gcd_string_len - bl print_string - mr r3, r30 - bl print_integer - li r3, ',' - bl print_char - mr r3, r31 - bl print_integer - addis r4, r2, _gcd_close_string@toc@ha - addi r4, r4, _gcd_close_string@toc@l - li r5, _gcd_close_string_len - bl print_string - mr r3, r29 - bl print_integer - li r3, '\n' - bl print_char - li r0,SYS_exit # syscall number (sys_exit) - li r3,0 # first argument: exit code - sc # call kernel - -gcd: - cmpd r3, r4 - bge _gcd - mr r5, r3 - mr r3, r4 - mr r4, r5 -_gcd: - cmpdi r4, 0 - beqlr - mr r5, r3 - mr r3, r4 - modud r4, r5, r4 - b _gcd - -# r4 is the address of the string -# r5 is the length of the string -print_string: - li r0, SYS_write - li r3, STDOUT - sc - blr - -print_char: - mr r4, r3 - li r0, SYS_write - li r3, STDOUT - stb r4, -1(sp) - addi r4, sp, -1 - li r5, 1 - sc - blr - -print_integer: - # r3 is the integer to print - # r4 is the working register - # r5 holds the current address to write to the string - # r6 is 10 for division operations - # r7 is working storage - mr r5, sp - li r6, 10 - neg r4, r3 - cmpdi r3, 0 - bne 1f - li r7, '0' - stbu r7, -1(r5) - b 3f -1: - isellt r4, r4, r3 # r4 = abs(r3) -1: - modsd r7, r4, r6 - divd r4, r4, r6 - addi r7, r7, '0' - stbu r7, -1(r5) - cmpdi r4, 0 - beq 1f - b 1b - -1: - cmpdi r3, 0 - blt 2f -3: - mr r4, r5 - subf r5, r5, sp - mflr r14 - bl print_string - mtlr r14 - blr - -2: - li r7, '-' - stbu r7, -1(r5) - b 3b diff --git a/Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-1.ps1 b/Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-1.psh similarity index 100% rename from Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-1.ps1 rename to Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-1.psh diff --git a/Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-2.ps1 b/Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-2.psh similarity index 100% rename from Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-2.ps1 rename to Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-2.psh diff --git a/Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-3.ps1 b/Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-3.psh similarity index 100% rename from Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-3.ps1 rename to Task/Greatest-common-divisor/PowerShell/greatest-common-divisor-3.psh diff --git a/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor-1.basic b/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor-1.basic new file mode 100644 index 0000000000..5c5743f69d --- /dev/null +++ b/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor-1.basic @@ -0,0 +1,9 @@ +Procedure GCD(x, y) + Protected r + While y <> 0 + r = x % y + x = y + y = r + Wend + ProcedureReturn y +EndProcedure diff --git a/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor-2.basic b/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor-2.basic new file mode 100644 index 0000000000..053fe34a33 --- /dev/null +++ b/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor-2.basic @@ -0,0 +1,8 @@ +Procedure GCD(x, y) + Protected r + r = x % y + If (r > 0) + y = GCD(y, r) + EndIf + ProcedureReturn y +EndProcedure diff --git a/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor.basic b/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor.basic deleted file mode 100644 index b29a94857f..0000000000 --- a/Task/Greatest-common-divisor/PureBasic/greatest-common-divisor.basic +++ /dev/null @@ -1,16 +0,0 @@ -Import "" ;msvcrt.lib - AbsI(Quad.q) As "_abs64" - AbsL(Long.l) As "labs" -EndImport -Procedure.i GCD(u.i, v.i) - Protected.i t - While v <> 0 - t = v - v = u % v - u = t - Wend - ProcedureReturn AbsI(u) ; Avoid float conversion with Abs(u). -EndProcedure -Debug GCD(18, 12) ; 6 -Debug GCD(1071, 1029) ; 21 -Debug GCD(3528, -3780) ; 252 diff --git a/Task/Greatest-common-divisor/Rebol/greatest-common-divisor.rebol b/Task/Greatest-common-divisor/REBOL/greatest-common-divisor.rebol similarity index 100% rename from Task/Greatest-common-divisor/Rebol/greatest-common-divisor.rebol rename to Task/Greatest-common-divisor/REBOL/greatest-common-divisor.rebol diff --git a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-3.raku b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-3.raku index e3ead41f57..f46e0769f4 100644 --- a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-3.raku +++ b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-3.raku @@ -1 +1 @@ -{ $^b ?? &?BLOCK( $^b, $^a % $^b ) !! $^a } +my &gcd = { ($^a.abs, $^b.abs, * % * ... 0)[*-2] } diff --git a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-4.raku b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-4.raku index f46e0769f4..7d7fe222da 100644 --- a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-4.raku +++ b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-4.raku @@ -1 +1 @@ -my &gcd = { ($^a.abs, $^b.abs, * % * ... 0)[*-2] } +my $gcd = $a gcd $b; diff --git a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-5.raku b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-5.raku index 7d7fe222da..cd9880fbea 100644 --- a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-5.raku +++ b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-5.raku @@ -1 +1,4 @@ -my $gcd = $a gcd $b; +[gcd] @list; # reduce with gcd +@alist Zgcd @blist; # lazy zip with gcd +@alist Xgcd @blist; # lazy cross with gcd +@alist »gcd« @blist; # parallel gcd diff --git a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-6.raku b/Task/Greatest-common-divisor/Raku/greatest-common-divisor-6.raku deleted file mode 100644 index cd9880fbea..0000000000 --- a/Task/Greatest-common-divisor/Raku/greatest-common-divisor-6.raku +++ /dev/null @@ -1,4 +0,0 @@ -[gcd] @list; # reduce with gcd -@alist Zgcd @blist; # lazy zip with gcd -@alist Xgcd @blist; # lazy cross with gcd -@alist »gcd« @blist; # parallel gcd diff --git a/Task/Greatest-common-divisor/Refal/greatest-common-divisor.refal b/Task/Greatest-common-divisor/Refal/greatest-common-divisor.refal deleted file mode 100644 index 91066da551..0000000000 --- a/Task/Greatest-common-divisor/Refal/greatest-common-divisor.refal +++ /dev/null @@ -1,8 +0,0 @@ -$ENTRY Go { - = >; -}; - -Gcd { - s.M 0 = s.M; - s.M s.N = >; -}; diff --git a/Task/Greatest-common-divisor/Rust/greatest-common-divisor-1.rs b/Task/Greatest-common-divisor/Rust/greatest-common-divisor-1.rust similarity index 100% rename from Task/Greatest-common-divisor/Rust/greatest-common-divisor-1.rs rename to Task/Greatest-common-divisor/Rust/greatest-common-divisor-1.rust diff --git a/Task/Greatest-common-divisor/Rust/greatest-common-divisor-2.rs b/Task/Greatest-common-divisor/Rust/greatest-common-divisor-2.rust similarity index 100% rename from Task/Greatest-common-divisor/Rust/greatest-common-divisor-2.rs rename to Task/Greatest-common-divisor/Rust/greatest-common-divisor-2.rust diff --git a/Task/Greatest-common-divisor/Rust/greatest-common-divisor-3.rs b/Task/Greatest-common-divisor/Rust/greatest-common-divisor-3.rust similarity index 100% rename from Task/Greatest-common-divisor/Rust/greatest-common-divisor-3.rs rename to Task/Greatest-common-divisor/Rust/greatest-common-divisor-3.rust diff --git a/Task/Greatest-common-divisor/Rust/greatest-common-divisor-4.rs b/Task/Greatest-common-divisor/Rust/greatest-common-divisor-4.rust similarity index 100% rename from Task/Greatest-common-divisor/Rust/greatest-common-divisor-4.rs rename to Task/Greatest-common-divisor/Rust/greatest-common-divisor-4.rust diff --git a/Task/Greatest-common-divisor/Rust/greatest-common-divisor-5.rs b/Task/Greatest-common-divisor/Rust/greatest-common-divisor-5.rust similarity index 100% rename from Task/Greatest-common-divisor/Rust/greatest-common-divisor-5.rs rename to Task/Greatest-common-divisor/Rust/greatest-common-divisor-5.rust diff --git a/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.scm b/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.ss similarity index 100% rename from Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.scm rename to Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.ss diff --git a/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.scm b/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.ss similarity index 100% rename from Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.scm rename to Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.ss diff --git a/Task/Greatest-common-divisor/Swift/greatest-common-divisor.swift b/Task/Greatest-common-divisor/Swift/greatest-common-divisor.swift index 339eb14c44..6061407791 100644 --- a/Task/Greatest-common-divisor/Swift/greatest-common-divisor.swift +++ b/Task/Greatest-common-divisor/Swift/greatest-common-divisor.swift @@ -1,9 +1,8 @@ // Iterative -func gcd(a: Int, b: Int) -> Int { +func gcd(var a: Int, var b: Int) -> Int { - var a = abs(a) - var b = abs(b) + a = abs(a); b = abs(b) if (b > a) { swap(&a, &b) } @@ -14,10 +13,9 @@ func gcd(a: Int, b: Int) -> Int { // Recursive -func gcdr (a: Int, b: Int) -> Int { +func gcdr (var a: Int, var b: Int) -> Int { - var a = abs(a) - var b = abs(b) + a = abs(a); b = abs(b) if (b > a) { swap(&a, &b) } diff --git a/Task/Greatest-common-divisor/Uiua/greatest-common-divisor.uiua b/Task/Greatest-common-divisor/Uiua/greatest-common-divisor.uiua deleted file mode 100644 index cffa04c401..0000000000 --- a/Task/Greatest-common-divisor/Uiua/greatest-common-divisor.uiua +++ /dev/null @@ -1 +0,0 @@ -⊙◌⍢(⤙˜◿|◡⋅>₀) diff --git a/Task/Greatest-common-divisor/VBScript/greatest-common-divisor.vbs b/Task/Greatest-common-divisor/VBScript/greatest-common-divisor.vb similarity index 100% rename from Task/Greatest-common-divisor/VBScript/greatest-common-divisor.vbs rename to Task/Greatest-common-divisor/VBScript/greatest-common-divisor.vb diff --git a/Task/Greatest-common-divisor/YAMLScript/greatest-common-divisor.ys b/Task/Greatest-common-divisor/YAMLScript/greatest-common-divisor.ys deleted file mode 100644 index b77cb8bd55..0000000000 --- a/Task/Greatest-common-divisor/YAMLScript/greatest-common-divisor.ys +++ /dev/null @@ -1,9 +0,0 @@ -!YS-v0 - -defn main(a=42 b=63): - say: "gcd($a $b) -> $gcd(a b)" - -defn gcd(a b): - if b > 0: - recur b: a % b - else: a diff --git a/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg b/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg index fa4c980bbe..15570e56dd 100644 --- a/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg +++ b/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg @@ -1,7 +1,12 @@ -BEGIN -MODE FLT = REAL; # substitute any array type with ">" defined # +# substitute any array type with a scalar element # +MODE FLT = REAL; -PROC max = ([]FLT item, PROC VOID raise empty array)FLT: +# create an exception for the case of an empty array # +PROC raise empty array = VOID:( + GO TO except empty array +); + +PROC max = ([]FLT item)FLT: BEGIN IF LWB item > UPB item THEN raise empty array; SKIP @@ -17,11 +22,9 @@ BEGIN FI END # max #; -#test#( +test:( []FLT buf = (-275.0, -111.19, 0.0, -1234568.0, pi, -pi); - # handle an exception for the case of an empty array # - PROC have empty array = VOID:print(("empty array", newline)); - - print((max(buf,have empty array),new line)) + print((max(buf),new line)) EXIT + except empty array: + SKIP ) -END diff --git a/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.adb b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.ada similarity index 100% rename from Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.adb rename to Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.ada diff --git a/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.adb b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.ada similarity index 100% rename from Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.adb rename to Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.ada diff --git a/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.adb b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.ada similarity index 100% rename from Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.adb rename to Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.ada diff --git a/Task/Greatest-element-of-a-list/ArkScript/greatest-element-of-a-list.ark b/Task/Greatest-element-of-a-list/ArkScript/greatest-element-of-a-list.ark deleted file mode 100644 index 9a3429517e..0000000000 --- a/Task/Greatest-element-of-a-list/ArkScript/greatest-element-of-a-list.ark +++ /dev/null @@ -1,11 +0,0 @@ -(let max (fun (L) { - (mut index 0) - (mut output nil) - - (while (< index (len L)) { - (if (or (nil? output) (> (@ L index) output)) - (set output (@ L index))) - (set index (+ 1 index)) }) - output })) - -(print (max [1 2 3 0 -5 42 0 1])) diff --git a/Task/Greatest-element-of-a-list/Ballerina/greatest-element-of-a-list.ballerina b/Task/Greatest-element-of-a-list/Ballerina/greatest-element-of-a-list.ballerina deleted file mode 100644 index bdfeabbf46..0000000000 --- a/Task/Greatest-element-of-a-list/Ballerina/greatest-element-of-a-list.ballerina +++ /dev/null @@ -1,11 +0,0 @@ -import ballerina/io; - -function max(float[] a) returns float { - return float:max(...a); -} - -public function main() { - float[] a = [1.0, 2.3, 1.1, 5.0, - 3.0, 2.8, 2.01, 3.14159]; - io:println(max(a)); -} diff --git a/Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-1.cob b/Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-1.cobol similarity index 100% rename from Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-1.cob rename to Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-1.cobol diff --git a/Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-2.cob b/Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-2.cobol similarity index 100% rename from Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-2.cob rename to Task/Greatest-element-of-a-list/COBOL/greatest-element-of-a-list-2.cobol diff --git a/Task/Greatest-element-of-a-list/Crystal/greatest-element-of-a-list.cr b/Task/Greatest-element-of-a-list/Crystal/greatest-element-of-a-list.crystal similarity index 100% rename from Task/Greatest-element-of-a-list/Crystal/greatest-element-of-a-list.cr rename to Task/Greatest-element-of-a-list/Crystal/greatest-element-of-a-list.crystal diff --git a/Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.pas b/Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.delphi similarity index 100% rename from Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.pas rename to Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.delphi diff --git a/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-1.duckdb b/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-1.duckdb deleted file mode 100644 index 4128a2435f..0000000000 --- a/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-1.duckdb +++ /dev/null @@ -1 +0,0 @@ -select list_max( [1.0, 2.0, 3.14] ) as max; diff --git a/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-2.duckdb b/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-2.duckdb deleted file mode 100644 index cef71412c4..0000000000 --- a/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-2.duckdb +++ /dev/null @@ -1 +0,0 @@ -select list_max( [ ['a']::JSON, [{'a':0}]::JSON ] ) as max; diff --git a/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-3.duckdb b/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-3.duckdb deleted file mode 100644 index d018f76d12..0000000000 --- a/Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-3.duckdb +++ /dev/null @@ -1,4 +0,0 @@ -create or replace function max_list(l) as ( - list_reduce(l, (acc, x) -> greatest(acc,x)) -); -select max_list( [ ['b']::JSON, ['a']::JSON ]); diff --git a/Task/Greatest-element-of-a-list/EasyLang/greatest-element-of-a-list.easy b/Task/Greatest-element-of-a-list/EasyLang/greatest-element-of-a-list.easy index 3f347d9e3d..d65b41b634 100644 --- a/Task/Greatest-element-of-a-list/EasyLang/greatest-element-of-a-list.easy +++ b/Task/Greatest-element-of-a-list/EasyLang/greatest-element-of-a-list.easy @@ -1,3 +1,5 @@ a[] = [ 2 9 4 3 8 5 ] -for e in a[] : max = higher e max +for e in a[] + max = higher e max +. print max diff --git a/Task/Greatest-element-of-a-list/Elena/greatest-element-of-a-list.elena b/Task/Greatest-element-of-a-list/Elena/greatest-element-of-a-list.elena index 2572fdf43b..ac93225e37 100644 --- a/Task/Greatest-element-of-a-list/Elena/greatest-element-of-a-list.elena +++ b/Task/Greatest-element-of-a-list/Elena/greatest-element-of-a-list.elena @@ -9,7 +9,7 @@ extension op object maximal := nil; while (en.next()) { - var item := *en; + var item := en.get(); if (nil == maximal) { maximal := item @@ -24,7 +24,7 @@ extension op } } -public Program() +public program() { console.printLine(new int[]{1,2,3,4,20,10,9,8}.Maximal) } diff --git a/Task/Greatest-element-of-a-list/Elixir/greatest-element-of-a-list.ex b/Task/Greatest-element-of-a-list/Elixir/greatest-element-of-a-list.elixir similarity index 100% rename from Task/Greatest-element-of-a-list/Elixir/greatest-element-of-a-list.ex rename to Task/Greatest-element-of-a-list/Elixir/greatest-element-of-a-list.elixir diff --git a/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.el b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.l similarity index 100% rename from Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.el rename to Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.l diff --git a/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.el b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.l similarity index 100% rename from Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.el rename to Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.l diff --git a/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-3.el b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-3.l similarity index 100% rename from Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-3.el rename to Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-3.l diff --git a/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-4.el b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-4.l similarity index 100% rename from Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-4.el rename to Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-4.l diff --git a/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.eu b/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.euphoria similarity index 100% rename from Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.eu rename to Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.euphoria diff --git a/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.eu b/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.euphoria similarity index 100% rename from Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.eu rename to Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.euphoria diff --git a/Task/Greatest-element-of-a-list/Gleam/greatest-element-of-a-list-1.gleam b/Task/Greatest-element-of-a-list/Gleam/greatest-element-of-a-list-1.gleam deleted file mode 100644 index 26e97484fa..0000000000 --- a/Task/Greatest-element-of-a-list/Gleam/greatest-element-of-a-list-1.gleam +++ /dev/null @@ -1,8 +0,0 @@ -import gleam/int -import gleam/list - -pub fn main() { - [1, 99, 136, 4, 3, 22, 111] - |> list.max(int.compare) - |> echo -} diff --git a/Task/Greatest-element-of-a-list/Gleam/greatest-element-of-a-list-2.gleam b/Task/Greatest-element-of-a-list/Gleam/greatest-element-of-a-list-2.gleam deleted file mode 100644 index 24bda4cd6a..0000000000 --- a/Task/Greatest-element-of-a-list/Gleam/greatest-element-of-a-list-2.gleam +++ /dev/null @@ -1,20 +0,0 @@ -pub fn max( - over list: List(a), - with compare: fn(a, a) -> Order, -) -> Result(a, Nil) { - case list { - [] -> Error(Nil) - [first, ..rest] -> Ok(max_loop(rest, compare, first)) - } -} - -fn max_loop(list, compare, max) { - case list { - [] -> max - [first, ..rest] -> - case compare(first, max) { - order.Gt -> max_loop(rest, compare, first) - order.Lt | order.Eq -> max_loop(rest, compare, max) - } - } -} diff --git a/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list-2.icon b/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list-2.icon deleted file mode 100644 index c9268e3bf2..0000000000 --- a/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list-2.icon +++ /dev/null @@ -1,3 +0,0 @@ -(max 1 2 3 4) -;or -(... max [1 2 3 4]) diff --git a/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list-1.icon b/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list.icon similarity index 100% rename from Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list-1.icon rename to Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list.icon diff --git a/Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.jl b/Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.julia similarity index 100% rename from Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.jl rename to Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.julia diff --git a/Task/Greatest-element-of-a-list/Komodo/greatest-element-of-a-list.komodo b/Task/Greatest-element-of-a-list/Komodo/greatest-element-of-a-list.komodo deleted file mode 100644 index 8ecd71f500..0000000000 --- a/Task/Greatest-element-of-a-list/Komodo/greatest-element-of-a-list.komodo +++ /dev/null @@ -1,8 +0,0 @@ -let max([first|tail]) := max(first, tail) -let max(curMax, []) := curMax -let max(curMax, [first|tail]) := max( - if curMax > first then curMax else first, - tail, -) - -assert(max([3, 5, 7, 2, 4, 8, -1]) = 8) diff --git a/Task/Greatest-element-of-a-list/Kotlin/greatest-element-of-a-list.kts b/Task/Greatest-element-of-a-list/Kotlin/greatest-element-of-a-list.kotlin similarity index 100% rename from Task/Greatest-element-of-a-list/Kotlin/greatest-element-of-a-list.kts rename to Task/Greatest-element-of-a-list/Kotlin/greatest-element-of-a-list.kotlin diff --git a/Task/Greatest-element-of-a-list/LDPL/greatest-element-of-a-list.ldpl b/Task/Greatest-element-of-a-list/LDPL/greatest-element-of-a-list.ldpl deleted file mode 100644 index fc74137c3f..0000000000 --- a/Task/Greatest-element-of-a-list/LDPL/greatest-element-of-a-list.ldpl +++ /dev/null @@ -1,33 +0,0 @@ -data: -values is number list -n is number - -procedure: -sub max - parameters: - x is number list - result is number - local data: - i is number - procedure: - store x:0 in result - for each i in values do - if i is greater than result then - store i in result - end if - repeat -end sub -create statement "get maximum of list $ in $" executing max - -# Now let's use the sub-procedure. -push 1 to values -push 11 to values -push 5 to values -push 33 to values -push 99 to values -push 13 to values -push 37 to values -push 50 to values - -get maximum of list values in n -display "The maximum is " n lf diff --git a/Task/Greatest-element-of-a-list/MSX-Basic/greatest-element-of-a-list.basic b/Task/Greatest-element-of-a-list/MSX-Basic/greatest-element-of-a-list.basic deleted file mode 100644 index 84c5b041f4..0000000000 --- a/Task/Greatest-element-of-a-list/MSX-Basic/greatest-element-of-a-list.basic +++ /dev/null @@ -1,12 +0,0 @@ -10 INPUT "How many items"; N% -20 DIM ARR(N%) -30 FOR I% = 0 TO N% - 1 -40 PRINT "Value of item #"; I% -50 INPUT ARR(I%) -60 NEXT I% -70 CHAMP = ARR(0) : INDEX = 0 -80 FOR I% = 1 TO N% - 1 -90 IF ARR(I%) > CHAMP THEN CHAMP = ARR(I%): INDEX = I% -100 NEXT I% -110 PRINT "The maximum value was "; CHAMP; " at index "; INDEX; "." -120 END diff --git a/Task/Greatest-element-of-a-list/Minimal-BASIC/greatest-element-of-a-list.basic b/Task/Greatest-element-of-a-list/Minimal-BASIC/greatest-element-of-a-list.basic deleted file mode 100644 index 8d69818dad..0000000000 --- a/Task/Greatest-element-of-a-list/Minimal-BASIC/greatest-element-of-a-list.basic +++ /dev/null @@ -1,17 +0,0 @@ -10 PRINT "HOW MANY ITEMS? " -20 INPUT N -30 FOR J = 0 TO N-1 -40 PRINT "VALUE OF ITEM #";J -50 INPUT T -60 LET A(J) = T -70 NEXT J -80 LET C = A(0) -90 LET I = 0 -100 FOR J = 1 TO N-1 -110 IF A(J) > C THEN 130 -120 GOTO 150 -130 LET C = A(J) -140 LET I = J -150 NEXT J -160 PRINT "THE MAXIMUM VALUE WAS ";C;" AT INDEX ";I;"." -170 END diff --git a/Task/Greatest-element-of-a-list/Nu/greatest-element-of-a-list.nu b/Task/Greatest-element-of-a-list/Nu/greatest-element-of-a-list.nu deleted file mode 100644 index 82d037d42d..0000000000 --- a/Task/Greatest-element-of-a-list/Nu/greatest-element-of-a-list.nu +++ /dev/null @@ -1 +0,0 @@ -[1 5 3 11 7] | math max diff --git a/Task/Greatest-element-of-a-list/OCaml/greatest-element-of-a-list.ml b/Task/Greatest-element-of-a-list/OCaml/greatest-element-of-a-list.ocaml similarity index 100% rename from Task/Greatest-element-of-a-list/OCaml/greatest-element-of-a-list.ml rename to Task/Greatest-element-of-a-list/OCaml/greatest-element-of-a-list.ocaml diff --git a/Task/Greatest-element-of-a-list/Oberon/greatest-element-of-a-list-1.oberon b/Task/Greatest-element-of-a-list/Oberon-2/greatest-element-of-a-list-1.oberon similarity index 100% rename from Task/Greatest-element-of-a-list/Oberon/greatest-element-of-a-list-1.oberon rename to Task/Greatest-element-of-a-list/Oberon-2/greatest-element-of-a-list-1.oberon diff --git a/Task/Greatest-element-of-a-list/Oberon/greatest-element-of-a-list-2.oberon b/Task/Greatest-element-of-a-list/Oberon-2/greatest-element-of-a-list-2.oberon similarity index 100% rename from Task/Greatest-element-of-a-list/Oberon/greatest-element-of-a-list-2.oberon rename to Task/Greatest-element-of-a-list/Oberon-2/greatest-element-of-a-list-2.oberon diff --git a/Task/Greatest-element-of-a-list/PascalABC.NET/greatest-element-of-a-list.pas b/Task/Greatest-element-of-a-list/PascalABC.NET/greatest-element-of-a-list.pas deleted file mode 100644 index c2ed38704b..0000000000 --- a/Task/Greatest-element-of-a-list/PascalABC.NET/greatest-element-of-a-list.pas +++ /dev/null @@ -1,3 +0,0 @@ -## -var values := Lst(1,7,4,6,3,5,2,6); -values.Max.Print; diff --git a/Task/Greatest-element-of-a-list/Pluto/greatest-element-of-a-list.pluto b/Task/Greatest-element-of-a-list/Pluto/greatest-element-of-a-list.pluto deleted file mode 100644 index 794b3bbaf6..0000000000 --- a/Task/Greatest-element-of-a-list/Pluto/greatest-element-of-a-list.pluto +++ /dev/null @@ -1,2 +0,0 @@ -local list = {42, 7, -5, 11.7, 58, 22.31, 59, -18} -print(list:max()) diff --git a/Task/Greatest-element-of-a-list/PowerShell/greatest-element-of-a-list.ps1 b/Task/Greatest-element-of-a-list/PowerShell/greatest-element-of-a-list.psh similarity index 100% rename from Task/Greatest-element-of-a-list/PowerShell/greatest-element-of-a-list.ps1 rename to Task/Greatest-element-of-a-list/PowerShell/greatest-element-of-a-list.psh diff --git a/Task/Greatest-element-of-a-list/Quite-BASIC/greatest-element-of-a-list.basic b/Task/Greatest-element-of-a-list/Quite-BASIC/greatest-element-of-a-list.basic deleted file mode 100644 index d38bd0b389..0000000000 --- a/Task/Greatest-element-of-a-list/Quite-BASIC/greatest-element-of-a-list.basic +++ /dev/null @@ -1,14 +0,0 @@ -10 INPUT "How many items? "; n -20 ARRAY a -30 FOR j = 0 TO n-1 -40 PRINT "Value of item #"; j -50 INPUT ""; t -60 LET a(j) = t -70 NEXT j -80 LET c = a(0) -90 LET i = 0 -100 FOR j = 1 TO n-1 -110 IF a(j) > c THEN LET c = a(j) : LET i = j -120 NEXT j -130 PRINT "The maximum value was "; c; " at index "; i; "." -140 END diff --git a/Task/Greatest-element-of-a-list/REBOL/greatest-element-of-a-list.rebol b/Task/Greatest-element-of-a-list/REBOL/greatest-element-of-a-list.rebol new file mode 100644 index 0000000000..952008c20e --- /dev/null +++ b/Task/Greatest-element-of-a-list/REBOL/greatest-element-of-a-list.rebol @@ -0,0 +1,14 @@ +REBOL [ + Title: "Maximum Value" + URL: http://rosettacode.org/wiki/Maximum_Value +] + +max: func [ + "Find maximum value in a list." + values [series!] "List of values." +] [ + first maximum-of values +] + +print ["Max of" mold d: [5 4 3 2 1] "is" max d] +print ["Max of" mold d: [-5 -4 -3 -2 -1] "is" max d] diff --git a/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-1.rebol b/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-1.rebol deleted file mode 100644 index 8adb252ada..0000000000 --- a/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-1.rebol +++ /dev/null @@ -1,14 +0,0 @@ -Rebol [ - Title: "Maximum Value" - URL: http://rosettacode.org/wiki/Maximum_Value -] - -max: func [ - "Find maximum value in a list." - values [series!] "List of values." -] [ - first maximum-of values -] - -print ["Max of" mold d: [5 4 3 2 1] "is" max d] -print ["Max of" mold d: [-5 -4 -3 -2 -1] "is" max d] diff --git a/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-2.rebol b/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-2.rebol deleted file mode 100644 index 1fc5e0cfa9..0000000000 --- a/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-2.rebol +++ /dev/null @@ -1,2 +0,0 @@ -print last sort [1 2 3 5 4] -;== 5 diff --git a/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-3.rebol b/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-3.rebol deleted file mode 100644 index 3fcee66127..0000000000 --- a/Task/Greatest-element-of-a-list/Rebol/greatest-element-of-a-list-3.rebol +++ /dev/null @@ -1,9 +0,0 @@ -vect: #(i16! [1 2 9 2 4]) -vect/maximum -;== 9 -query vect 'max -;== 9 -query vect [maximum minimum] -;== [maximum: 9 minimum: 1] -query vect [:maximum :minimum] -;== [9 1] diff --git a/Task/Greatest-element-of-a-list/Rust/greatest-element-of-a-list.rs b/Task/Greatest-element-of-a-list/Rust/greatest-element-of-a-list.rust similarity index 100% rename from Task/Greatest-element-of-a-list/Rust/greatest-element-of-a-list.rs rename to Task/Greatest-element-of-a-list/Rust/greatest-element-of-a-list.rust diff --git a/Task/Greatest-element-of-a-list/Rye/greatest-element-of-a-list.rye b/Task/Greatest-element-of-a-list/Rye/greatest-element-of-a-list.rye deleted file mode 100644 index aa0ce27a2a..0000000000 --- a/Task/Greatest-element-of-a-list/Rye/greatest-element-of-a-list.rye +++ /dev/null @@ -1 +0,0 @@ -print max { 3 22 4 9 10 } diff --git a/Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.scm b/Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.ss similarity index 100% rename from Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.scm rename to Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.ss diff --git a/Task/Greatest-element-of-a-list/TAV/greatest-element-of-a-list.tav b/Task/Greatest-element-of-a-list/TAV/greatest-element-of-a-list.tav deleted file mode 100644 index dedbbf5933..0000000000 --- a/Task/Greatest-element-of-a-list/TAV/greatest-element-of-a-list.tav +++ /dev/null @@ -1,4 +0,0 @@ -main (parms):+ - ? parms.Count < 2 - parms =: 5, 2, 7, 11, 4, 99, 33 - print maximum of parms diff --git a/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-3.tailspin b/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-3.tailspin index c1cd1001c7..e62dae2ed6 100644 --- a/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-3.tailspin +++ b/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-3.tailspin @@ -1,7 +1,2 @@ -[1, 5, 20, 3, 9, 7] -> \(@: $(1); - $(2..last)... -> # - $@ ! - - when <$@..> do @: $; -\) -> !OUT::write +[1, 5, 20, 3, 9, 7] -> \(@: $(1); $(2..last)... -> # $@ ! when <$@..> do @: $;\) -> !OUT::write // outputs 20 diff --git a/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-4.tailspin b/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-4.tailspin index 92a2a4b411..a330ba807a 100644 --- a/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-4.tailspin +++ b/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-4.tailspin @@ -1,8 +1,8 @@ -[1, 5, 20, 3, 9, 7] -> templates - @ set $(1); - $(2..)... -> !# - $@ ! +templates max + @: $(1); + $(2..last)... -> \(<$@max..> @max: $;\) -> !VOID + $@! +end max - when <|$@..> do @ set $; -end ! --- outputs 20 +[1, 5, 20, 3, 9, 7] -> max -> !OUT::write +// outputs 20 diff --git a/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-5.tailspin b/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-5.tailspin deleted file mode 100644 index a330ba807a..0000000000 --- a/Task/Greatest-element-of-a-list/Tailspin/greatest-element-of-a-list-5.tailspin +++ /dev/null @@ -1,8 +0,0 @@ -templates max - @: $(1); - $(2..last)... -> \(<$@max..> @max: $;\) -> !VOID - $@! -end max - -[1, 5, 20, 3, 9, 7] -> max -> !OUT::write -// outputs 20 diff --git a/Task/Greatest-element-of-a-list/True-BASIC/greatest-element-of-a-list.basic b/Task/Greatest-element-of-a-list/True-BASIC/greatest-element-of-a-list.basic deleted file mode 100644 index cf549f2611..0000000000 --- a/Task/Greatest-element-of-a-list/True-BASIC/greatest-element-of-a-list.basic +++ /dev/null @@ -1,16 +0,0 @@ -OPTION BASE 0 - -DIM vals(4) -LET vals(1) = 70.5 -LET vals(2) = 23.67 -LET vals(3) = 150.2 -LET vals(4) = 145 - -FUNCTION findmax - FOR x = 1 TO UBOUND(vals) - IF vals(x) > vals(x-1) THEN LET findmax = vals(x) - NEXT x -END FUNCTION - -PRINT findmax -END diff --git a/Task/Greatest-element-of-a-list/VBScript/greatest-element-of-a-list.vbs b/Task/Greatest-element-of-a-list/VBScript/greatest-element-of-a-list.vb similarity index 100% rename from Task/Greatest-element-of-a-list/VBScript/greatest-element-of-a-list.vbs rename to Task/Greatest-element-of-a-list/VBScript/greatest-element-of-a-list.vb diff --git a/Task/Greatest-element-of-a-list/Zig/greatest-element-of-a-list.zig b/Task/Greatest-element-of-a-list/Zig/greatest-element-of-a-list.zig index ea8499a79c..7dad1f9dc4 100644 --- a/Task/Greatest-element-of-a-list/Zig/greatest-element-of-a-list.zig +++ b/Task/Greatest-element-of-a-list/Zig/greatest-element-of-a-list.zig @@ -1,8 +1,7 @@ -/// Asserts that `input` is not empty (len >= 1). -pub fn max(comptime T: type, input: []const T) T { - var max_elem: T = input[0]; - for (input[1..]) |elem| { - max_elem = @max(max_elem, elem); - } - return max_elem; +fn max( a: []const f32) f32{ + var output = a[0]; + for(a)|num|{ + output = @max(output, num); + } +return output; } diff --git a/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg b/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg index e720ed2065..71d6e84d21 100644 --- a/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg +++ b/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg @@ -1,3 +1,4 @@ +main: ( []INT a = (-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1); @@ -22,7 +23,7 @@ OD; FOR i FROM begin max TO end max DO - print((" ",whole(a[i],0))) + print(a[i]) OD ) diff --git a/Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.adb b/Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.ada similarity index 100% rename from Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.adb rename to Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.ada diff --git a/Task/Greatest-subsequential-sum/Arturo/greatest-subsequential-sum.arturo b/Task/Greatest-subsequential-sum/Arturo/greatest-subsequential-sum.arturo index 59676b248e..a1470d3426 100644 --- a/Task/Greatest-subsequential-sum/Arturo/greatest-subsequential-sum.arturo +++ b/Task/Greatest-subsequential-sum/Arturo/greatest-subsequential-sum.arturo @@ -17,8 +17,8 @@ subarraySum: function [arr][ lst: i ] ] - switch lst > fst -> return @[mx, slice arr fst lst] - -> return [0, []] + if? lst > fst -> return @[mx, slice arr fst lst] + else -> return [0, []] ] sequences: @[ diff --git a/Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.au3 b/Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.autoit similarity index 100% rename from Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.au3 rename to Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.autoit diff --git a/Task/Greatest-subsequential-sum/Ballerina/greatest-subsequential-sum.ballerina b/Task/Greatest-subsequential-sum/Ballerina/greatest-subsequential-sum.ballerina deleted file mode 100644 index 3ee409c7ea..0000000000 --- a/Task/Greatest-subsequential-sum/Ballerina/greatest-subsequential-sum.ballerina +++ /dev/null @@ -1,42 +0,0 @@ -import ballerina/io; - -function gss(int[] s) returns [int[], int] { - int best = 0; - int strt = 0; - int end = 0; - int sum = 0; - int sumStart = 0; - foreach var [i, x] in s.enumerate() { - sum += x; - if sum > best { - best = sum; - strt = sumStart; - end = i + 1; - } else if sum < 0 { - sum = 0; - sumStart = i + 1; - } - } - return [s.slice(strt, end), best]; -} - -function A(any[] a) returns string { - return re `,`.replaceAll(a.toString(), ", "); -} - -public function main() { - var tests = [ - [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1], - [-1, 1, 2, -5, -6], - [], - [-1, -2, -1] - ]; - foreach var test in tests { - io:println("Input: ", A(test)); - var res = gss(test); - var subSeq = res[0]; - int sum = res[1]; - io:println("Sub seq: ", A(subSeq)); - io:println("Sum: ", sum, "\n"); - } -} diff --git a/Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-1.cr b/Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-1.crystal similarity index 100% rename from Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-1.cr rename to Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-1.crystal diff --git a/Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-2.cr b/Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-2.crystal similarity index 100% rename from Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-2.cr rename to Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-2.crystal diff --git a/Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-3.cr b/Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-3.crystal similarity index 100% rename from Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-3.cr rename to Task/Greatest-subsequential-sum/Crystal/greatest-subsequential-sum-3.crystal diff --git a/Task/Greatest-subsequential-sum/DuckDB/greatest-subsequential-sum.duckdb b/Task/Greatest-subsequential-sum/DuckDB/greatest-subsequential-sum.duckdb deleted file mode 100644 index b989bd5e2b..0000000000 --- a/Task/Greatest-subsequential-sum/DuckDB/greatest-subsequential-sum.duckdb +++ /dev/null @@ -1,32 +0,0 @@ -create or replace function list_find_last_nonnegative(lst) as ( - select first(i) - from range(length(lst), 0, -1) t(i) - where lst[i] > 0 -); - -# Return the tuple (start, end, subtotal) for the subsequence lst[start:end] -# having a maximal subtotal for the given value of `start`. -# Initial negative numbers are ignored. -# It is assumed that the caller has taken care of trailing negative numbers. -create or replace function max_initial_subsequential_sum(lst, start) as ( - select max_by( (start,i,total), total) - from ( SELECT i, list_sum(lst[start:i]) as total - FROM range(start, length(lst)+1) t(i) - WHERE lst[start] >= 0 ) -); - -# If the list is empty or if the items are all negative, return [] -create or replace function subsequence_with_maximal_sum(lst) as ( - with cte as (select list_find_last_nonnegative(lst) as len) - select coalesce(max_by( lst[ mis[1]: mis[2]], mis[3] ), []) - from ( SELECT max_initial_subsequential_sum(lst,start) as mis - FROM (select unnest(range(1, 1 + len)) as start from cte) ) -); - -# Examples -select s, subsequence_with_maximal_sum(s) as subseq -from values - ([1,2,3,-1, 10]), - ([-1,2,3,-1, 10]), - ([-1,-2]), - ([]) as t(s); diff --git a/Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy b/Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy deleted file mode 100644 index 90385e92e1..0000000000 --- a/Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy +++ /dev/null @@ -1,21 +0,0 @@ -proc max_subseq &seq[] &start &stop &maxsum . - maxsum = 0 - i = 1 - start = 1 - stop = 0 - for j to len seq[] - sum += seq[j] - if sum < 0 - i = j + 1 - sum = 0 - elif sum > maxsum - start = i - stop = j - maxsum = sum - . - . -. -a[] = [ -1 -2 3 5 6 -2 -1 4 -4 2 -1 ] -max_subseq a[] a b sum -print "Max sum = " & sum -for i = a to b : write a[i] & " " diff --git a/Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-1.ex b/Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-1.elixir similarity index 100% rename from Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-1.ex rename to Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-1.elixir diff --git a/Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-2.ex b/Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-2.elixir similarity index 100% rename from Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-2.ex rename to Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-2.elixir diff --git a/Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-3.ex b/Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-3.elixir similarity index 100% rename from Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-3.ex rename to Task/Greatest-subsequential-sum/Elixir/greatest-subsequential-sum-3.elixir diff --git a/Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.eu b/Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.euphoria similarity index 100% rename from Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.eu rename to Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.euphoria diff --git a/Task/Greatest-subsequential-sum/FutureBasic/greatest-subsequential-sum.basic b/Task/Greatest-subsequential-sum/FutureBasic/greatest-subsequential-sum.basic deleted file mode 100644 index 836a0f87a4..0000000000 --- a/Task/Greatest-subsequential-sum/FutureBasic/greatest-subsequential-sum.basic +++ /dev/null @@ -1,64 +0,0 @@ -_rndlen = 01 //BOOL: is sequence length random or fixed -_maxlen = 14 //Length of each/longest sequence -_maxVal = 20 //Largest number (pos or neg) in sequence -_repeat = 25 //Number of sequences to evaluate - -void local fn maxSubSequence - int i, j, seq(_maxlen), ndx(_maxlen + 1),sum(_maxlen) - int grp, maxSum, maxNdx, maxEnd, tot, iterations = _repeat - - while iterations - iterations-- - - // Create random sequence - int count = (_rndlen) ? rnd(_maxlen) : _maxlen - for i = 1 to count - seq(i) = rnd(_maxVal * 2 + 1) - _maxVal - 1 - next - - // Determine maximum sub-sequence - bool isNeg = yes : grp = 0 : sum(0) = 0 : ndx(0) = 0 - maxSum = 0 : maxNdx = 0 : maxEnd = 0 - - for i = 1 to count // Merge array into groups of like signs - if (seq(i) < 0) <> isNeg // If change of sign... - grp ++ // Start new group - isNeg = yes - isNeg - ndx(grp) = i - sum(grp) = 0 - end if - sum(grp) += seq(i) - next - ndx(grp + 1) = 0 - - for i = 1 to grp step 2 // Determine max sub-sequence - j = i : tot = sum(j) - do - if tot > maxSum - maxSum = tot - maxNdx = ndx(i) - maxEnd = ndx(j + 1) - end if - j += 2 : tot += sum(j - 1) + sum(j) // add next neg & pos groups - until j > grp - next - - // Print result - print @" Sum = "; maxSum, " {"; - for i = 1 to count - if i == maxNdx then text ,,, _zCyan - if i == maxEnd then text ,,, fn ColorClear - print " "; seq(i); " "; - next - text ,,, fn ColorClear - print "}" - - wend -end fn - -window 1, @"Maximum subsequence" -CFTimeInterval t : t = fn CACurrentMediaTime -fn maxSubSequence -printf @"\n %d random sequences created, solved, and printed in %.3f sec.",_repeat,1*(fn CACurrentMediaTime - t) - -handleevents diff --git a/Task/Greatest-subsequential-sum/Julia/greatest-subsequential-sum.jl b/Task/Greatest-subsequential-sum/Julia/greatest-subsequential-sum.julia similarity index 100% rename from Task/Greatest-subsequential-sum/Julia/greatest-subsequential-sum.jl rename to Task/Greatest-subsequential-sum/Julia/greatest-subsequential-sum.julia diff --git a/Task/Greatest-subsequential-sum/Kotlin/greatest-subsequential-sum.kts b/Task/Greatest-subsequential-sum/Kotlin/greatest-subsequential-sum.kotlin similarity index 100% rename from Task/Greatest-subsequential-sum/Kotlin/greatest-subsequential-sum.kts rename to Task/Greatest-subsequential-sum/Kotlin/greatest-subsequential-sum.kotlin diff --git a/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua b/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua index cbf5481d51..23551e0e51 100644 --- a/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua +++ b/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua @@ -8,25 +8,7 @@ function maxsub(ary, idx) end local v = maxsub(ary, idx + 1) if maxsum < sumt(v, 1, #v) then return v end - local ret, allNegative = {}, true - for i = idx, last do - ret[#ret+1] = ary[i] - if ret[#ret] >= 0 then allNegative = false end - end - return allNegative and {} or ret + local ret = {} + for i = idx, last do ret[#ret+1] = ary[i] end + return ret end - -local function test(s) - local msub = maxsub(s) - print("["..table.concat(s, " ").."] -> ["..table.concat(msub, " ").."] sum: "..sumt(msub, 1, #msub)) -end - --- test cases from 11l -test {-1, 2, -1} -test {-1, 2, -1, 3, -1} -test {-1, 1, 2, -5, -6} -test {-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1} - --- additional test cases -test {-1, -2, -1} -test {} diff --git a/Task/Greatest-subsequential-sum/M2000-Interpreter/greatest-subsequential-sum-1.m2000 b/Task/Greatest-subsequential-sum/M2000-Interpreter/greatest-subsequential-sum-1.m2000 deleted file mode 100644 index 1eb7221eed..0000000000 --- a/Task/Greatest-subsequential-sum/M2000-Interpreter/greatest-subsequential-sum-1.m2000 +++ /dev/null @@ -1,26 +0,0 @@ -module Greatest_subsequential_sum { - showGSS=lambda (a)->{ - function Greatest_subsequential_sum(a as array){ - s=a#sum() - =a - p=len(a)-1 - if p<0 then exit - for i=0 to p - for j=i to p - k= a#slice(i, j) - m=k#sum() - if m>s then =k: s=m - next - next - } - = "("+a#str$(",")+") -> ("+ Greatest_subsequential_sum(a)#str$(",")+")" - } - open "out.txt" for output as#f - print #f, showGSS((-1 , 2 , -1)) - print #f, showGSS((-1, 2, -1, 3, -1)) - print #f, showGSS((-1, 1, 2, -5, -6)) - print #f, showGSS((-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1)) - close #f - win notepad, dir$+"out.txt" -} -Greatest_subsequential_sum diff --git a/Task/Greatest-subsequential-sum/M2000-Interpreter/greatest-subsequential-sum-2.m2000 b/Task/Greatest-subsequential-sum/M2000-Interpreter/greatest-subsequential-sum-2.m2000 deleted file mode 100644 index a16c08d534..0000000000 --- a/Task/Greatest-subsequential-sum/M2000-Interpreter/greatest-subsequential-sum-2.m2000 +++ /dev/null @@ -1,36 +0,0 @@ -module Greatest_subsequential_sum (filename) { - showGSS=lambda (a)->{ - function Greatest_subsequential_sum(a as array){ - var best = 0 - var start = 0 - var end = 0 - var sum = 0 - var sumStart = 0 - var i = 0 - s=each(a) - while s { - sum +=array(s) - if (sum > best) then { - best = sum - start = sumStart - end = i + 1 - } else.if (sum < 0) then { - sum = 0 - sumStart = i + 1 - } - i++ - } - =a#slice(start, end-1) - } - = "("+a#str$(",")+") -> ("+ Greatest_subsequential_sum(a)#str$(",")+")" - } - open filename for output as#f - print #f, showGSS((-1 , 2 , -1)) - print #f, showGSS((-1, 2, -1, 3, -1)) - print #f, showGSS((-1, 1, 2, -5, -6)) - print #f, showGSS((-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1)) - close #f - if filename<>"" then win notepad, dir$+filename -} -Greatest_subsequential_sum "" ' to screen -Greatest_subsequential_sum "out.txt" diff --git a/Task/Greatest-subsequential-sum/OCaml/greatest-subsequential-sum.ml b/Task/Greatest-subsequential-sum/OCaml/greatest-subsequential-sum.ocaml similarity index 100% rename from Task/Greatest-subsequential-sum/OCaml/greatest-subsequential-sum.ml rename to Task/Greatest-subsequential-sum/OCaml/greatest-subsequential-sum.ocaml diff --git a/Task/Greatest-subsequential-sum/Oberon/greatest-subsequential-sum.oberon b/Task/Greatest-subsequential-sum/Oberon-2/greatest-subsequential-sum.oberon similarity index 100% rename from Task/Greatest-subsequential-sum/Oberon/greatest-subsequential-sum.oberon rename to Task/Greatest-subsequential-sum/Oberon-2/greatest-subsequential-sum.oberon diff --git a/Task/Greatest-subsequential-sum/PascalABC.NET/greatest-subsequential-sum.pas b/Task/Greatest-subsequential-sum/PascalABC.NET/greatest-subsequential-sum.pas deleted file mode 100644 index 0f5860e32e..0000000000 --- a/Task/Greatest-subsequential-sum/PascalABC.NET/greatest-subsequential-sum.pas +++ /dev/null @@ -1,28 +0,0 @@ -function MaxSumSeq(a: array of integer): (integer,integer,integer); -begin - var (maxSum,thisSum) := (0,0); - var (f,t) := (0,-1); - var k := 0; - for var j:=0 to a.Length-1 do - begin - thisSum += a[j]; - if thisSum < 0 then - begin - k := j + 1; - thisSum := 0; - end - else if thisSum > maxSum then - begin - maxSum := thisSum; - f := k; - t := j - end; - end; - Result := (f,t,maxSum); -end; - -begin - var a := Arr(-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1); - var (f,t,max) := MaxSumSeq(a); - Print('Subsequence with max sum:', a[f:t+1], 'It''s sum:', max); -end. diff --git a/Task/Greatest-subsequential-sum/Phix/greatest-subsequential-sum.phix b/Task/Greatest-subsequential-sum/Phix/greatest-subsequential-sum.phix index 8229d70663..98711bab7a 100644 --- a/Task/Greatest-subsequential-sum/Phix/greatest-subsequential-sum.phix +++ b/Task/Greatest-subsequential-sum/Phix/greatest-subsequential-sum.phix @@ -1,17 +1,19 @@ -with javascript_semantics -function maxSubseq(sequence s) - integer maxsum = 0, first = 1, last = 0 - for i=1 to length(s) do - integer sumsij = 0 - for j=i to length(s) do - sumsij += s[j] - if sumsij>maxsum then - {maxsum,first,last} = {sumsij,i,j} - end if - end for - end for - return s[first..last] -end function -? maxSubseq({-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1}) -? maxSubseq({}) -? maxSubseq({-1, -5, -3}) +(phixonline)--> + with javascript_semantics + function maxSubseq(sequence s) + integer maxsum = 0, first = 1, last = 0 + for i=1 to length(s) do + integer sumsij = 0 + for j=i to length(s) do + sumsij += s[j] + if sumsij>maxsum then + {maxsum,first,last} = {sumsij,i,j} + end if + end for + end for + return s[first..last] + end function + ? maxSubseq({-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1}) + ? maxSubseq({}) + ? maxSubseq({-1, -5, -3}) + s ) - [ stack ] is maxsum ( --> s ) - - [ [] maxseq put - 0 maxsum put - dup dup size times - [ [] 0 rot - witheach - [ rot over join - unrot + - dup maxsum share > - if - [ dup maxsum replace - over maxseq replace ] ] - 2drop behead drop dup ] - 2drop - maxsum take - maxseq take ] is maxsubseqsum ( [ --> n [ ) - - - ' [ [ 1 2 3 4 5 -8 -9 -20 40 25 -5 ] - [ -1 -2 3 5 6 -2 -1 4 -4 2 -1 ] - [ -1 -2 -3 -4 -5 ] - [ ] ] - witheach - [ dup - say "Sequence: " echo cr - maxsubseqsum - say "Subsequence: " echo cr - say "Sum: " echo cr - cr ] diff --git a/Task/Greatest-subsequential-sum/Rust/greatest-subsequential-sum.rs b/Task/Greatest-subsequential-sum/Rust/greatest-subsequential-sum.rust similarity index 100% rename from Task/Greatest-subsequential-sum/Rust/greatest-subsequential-sum.rs rename to Task/Greatest-subsequential-sum/Rust/greatest-subsequential-sum.rust diff --git a/Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.scm b/Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.ss similarity index 100% rename from Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.scm rename to Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.ss diff --git a/Task/Greatest-subsequential-sum/Sidef/greatest-subsequential-sum.sidef b/Task/Greatest-subsequential-sum/Sidef/greatest-subsequential-sum.sidef index 5b7d6e7a88..b77d67e5c2 100644 --- a/Task/Greatest-subsequential-sum/Sidef/greatest-subsequential-sum.sidef +++ b/Task/Greatest-subsequential-sum/Sidef/greatest-subsequential-sum.sidef @@ -1,19 +1,19 @@ func maxsubseq(*a) { - var (start, end, sum, maxsum) = (-1, -1, 0, 0) + var (start, end, sum, maxsum) = (-1, -1, 0, 0); a.each_kv { |i, x| - sum += x + sum += x; if (maxsum < sum) { - maxsum = sum - end = i + maxsum = sum; + end = i; } elsif (sum < 0) { - sum = 0 - start = i + sum = 0; + start = i; } - } - a.slice(start+1).first(end-start) + }; + a.ft(start+1, end); } -  -say maxsubseq(-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1) -say maxsubseq(-2, -2, -1, 3, 5, 6, -1, 4, -4, 2, -1) -say maxsubseq(-2, -2, -1, -3, -5, -6, -1, -4, -4, -2, -1) + +say maxsubseq(-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1); +say maxsubseq(-2, -2, -1, 3, 5, 6, -1, 4, -4, 2, -1); +say maxsubseq(-2, -2, -1, -3, -5, -6, -1, -4, -4, -2, -1); diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/00-TASK.txt b/Task/Greedy-algorithm-for-Egyptian-fractions/00-TASK.txt index 438c913d3d..7319ffb5ae 100644 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/00-TASK.txt +++ b/Task/Greedy-algorithm-for-Egyptian-fractions/00-TASK.txt @@ -38,6 +38,5 @@ For improper fractions, the integer part of any improper fraction should be firs ;Also see: *   Wolfram MathWorld™ entry: [http://mathworld.wolfram.com/EgyptianFraction.html Egyptian fraction] -*   Numberphile YouTube video: [https://youtu.be/aVUUbNbQkbQ Egyptian Fractions and the Greedy Algorithm]

diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/ALGOL-68/greedy-algorithm-for-egyptian-fractions.alg b/Task/Greedy-algorithm-for-Egyptian-fractions/ALGOL-68/greedy-algorithm-for-egyptian-fractions.alg index 0d7c9e866c..653de829fb 100644 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/ALGOL-68/greedy-algorithm-for-egyptian-fractions.alg +++ b/Task/Greedy-algorithm-for-Egyptian-fractions/ALGOL-68/greedy-algorithm-for-egyptian-fractions.alg @@ -1,4 +1,4 @@ -BEGIN # compute some Egyptian fractions # +BEGIN # compute some Egytian fractions # PR precision 2000 PR # set the number of digits for LONG LONG INT # PROC gcd = ( LONG LONG INT a, b )LONG LONG INT: IF b = 0 THEN @@ -14,7 +14,7 @@ BEGIN # compute some Egyptian fractions # MODE LISTOFRATIONAL = STRUCT( RATIONAL element, REF LISTOFRATIONAL next ); REF LISTOFRATIONAL nil list of rational = NIL; OP TOSTRING = ( INT a )STRING: whole( a, 0 ); -CO OP TOSTRING = ( LONG INT a )STRING: whole( a, 0 ); # not needed for the task # CO + OP TOSTRING = ( LONG INT a )STRING: whole( a, 0 ); OP TOSTRING = ( LONG LONG INT a )STRING: whole( a, 0 ); OP TOSTRING = ( RATIONAL a )STRING: IF den OF a = 1 @@ -49,12 +49,12 @@ CO OP TOSTRING = ( LONG INT a )STRING: whole( a, 0 ); # not needed for t ELSE REF LISTOFRATIONAL result := nil list of rational; REF LISTOFRATIONAL end result := nil list of rational; - PROC add = ( RATIONAL rn )VOID: + PROC add = ( RATIONAL r )VOID: IF end result IS nil list of rational THEN - result := HEAP LISTOFRATIONAL := ( rn, nil list of rational ); + result := HEAP LISTOFRATIONAL := ( r, nil list of rational ); end result := result ELSE - next OF end result := HEAP LISTOFRATIONAL := ( rn, nil list of rational ); + next OF end result := HEAP LISTOFRATIONAL := ( r, nil list of rational ); end result := next OF end result FI ; # add # IF num OF r > den OF r THEN diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/C++/greedy-algorithm-for-egyptian-fractions.cpp b/Task/Greedy-algorithm-for-Egyptian-fractions/C++/greedy-algorithm-for-egyptian-fractions.cpp index 2d67979bc3..392b4dbc74 100644 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/C++/greedy-algorithm-for-egyptian-fractions.cpp +++ b/Task/Greedy-algorithm-for-Egyptian-fractions/C++/greedy-algorithm-for-egyptian-fractions.cpp @@ -1,20 +1,21 @@ -#include #include #include -#include -#include #include +#include +#include +#include typedef boost::multiprecision::cpp_int integer; struct fraction { - fraction(const integer& n, const integer& d) - : numerator(n), denominator(d) {} + fraction(const integer& n, const integer& d) : numerator(n), denominator(d) {} integer numerator; integer denominator; }; -integer mod(const integer& x, const integer& y) { return ((x % y) + y) % y; } +integer mod(const integer& x, const integer& y) { + return ((x % y) + y) % y; +} size_t count_digits(const integer& i) { std::ostringstream os; @@ -27,8 +28,9 @@ std::string to_string(const integer& i) { std::ostringstream os; os << i; std::string s = os.str(); - if (s.length() > max_digits) - s.replace(max_digits / 2, s.length() - max_digits, "..."); + if (s.length() > max_digits) { + s = s.substr(0, max_digits/2) + "..." + s.substr(s.length()-max_digits/2); + } return s; } @@ -40,7 +42,7 @@ void egyptian(const fraction& f, std::vector& result) { result.clear(); integer x = f.numerator, y = f.denominator; while (x > 0) { - integer z = (y + x - 1) / x; + integer z = (y + x - 1)/x; result.emplace_back(1, z); x = mod(-y, x); y = y * z; @@ -61,7 +63,7 @@ void print_egyptian(const fraction& f) { std::cout << "Egyptian fraction for " << f << ": "; integer x = f.numerator, y = f.denominator; if (x > y) { - std::cout << "[" << x / y << "] "; + std::cout << "[" << x/y << "] "; x = x % y; } std::vector result; @@ -94,15 +96,11 @@ void show_max_terms_and_max_denominator(const integer& limit) { } } } - std::cout - << "Proper fractions with most terms and largest denominator, limit = " - << limit << ":\n\n"; - std::cout << "Most terms (" << max_terms - << "): " << max_terms_fraction.value() << " = "; + std::cout << "Proper fractions with most terms and largest denominator, limit = " << limit << ":\n\n"; + std::cout << "Most terms (" << max_terms << "): " << max_terms_fraction.value() << " = "; print_egyptian(max_terms_result); - std::cout << "\nLargest denominator (" - << count_digits(max_denominator_result.back().denominator) - << " digits): " << max_denominator_fraction.value() << " = "; + std::cout << "\nLargest denominator (" << count_digits(max_denominator_result.back().denominator) + << " digits): " << max_denominator_fraction.value() << " = "; print_egyptian(max_denominator_result); } diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/Fortran/greedy-algorithm-for-egyptian-fractions.f b/Task/Greedy-algorithm-for-Egyptian-fractions/Fortran/greedy-algorithm-for-egyptian-fractions.f deleted file mode 100644 index 5c2a7c47df..0000000000 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/Fortran/greedy-algorithm-for-egyptian-fractions.f +++ /dev/null @@ -1,342 +0,0 @@ -program egyptian_fractions - implicit none - - integer, parameter :: base = 1000000000 - integer, parameter :: max_dig = 800 - integer, parameter :: max_terms = 2000 - - type big_int - integer :: len = 0 - integer :: d(max_dig) = 0 ! least significant digit first - end type big_int - - type(big_int) :: terms(max_terms) - integer :: nterms - - type(big_int) :: max_terms_terms(max_terms) - integer :: max_terms_n = 0 - integer :: max_terms_a, max_terms_b - - type(big_int) :: max_denom_terms(max_terms) - integer :: max_denom_n = 0 - integer :: max_denom_a, max_denom_b - type(big_int) :: max_denom_val - - integer :: a, b, int_part, frac_num - - ! ------------------------------------------------------------------ - ! Required examples - ! ------------------------------------------------------------------ - call compute_egyptian(43, 48, terms, nterms) - write(*, '(A)', advance='no') "43/48 = " - call print_egyptian(0, terms, nterms) - write(*, *) - - call compute_egyptian(5, 121, terms, nterms) - write(*, '(A)', advance='no') "5/121 = " - call print_egyptian(0, terms, nterms) - write(*, *) - - int_part = 2014 / 59 - frac_num = 2014 - int_part * 59 - call compute_egyptian(frac_num, 59, terms, nterms) - write(*, '(A)', advance='no') "2014/59 = " - call print_egyptian(int_part, terms, nterms) - write(*, '(/)') - - ! ------------------------------------------------------------------ - ! Proper fractions with 1- or 2-digit a,b - ! ------------------------------------------------------------------ - call big_from_int(max_denom_val, 0) - - do a = 1, 99 - do b = a + 1, 99 - call compute_egyptian(a, b, terms, nterms) - - if (nterms > max_terms_n) then - max_terms_n = nterms - max_terms_a = a - max_terms_b = b - max_terms_terms(1:nterms) = terms(1:nterms) - end if - - if (nterms > 0) then - if (big_compare(terms(nterms), max_denom_val) > 0) then - max_denom_val = terms(nterms) - max_denom_n = nterms - max_denom_a = a - max_denom_b = b - max_denom_terms(1:nterms) = terms(1:nterms) - end if - end if - end do - end do - - write(*, '(A,I0,A,I0,A,I0,A)', advance='no') & - "Largest number of terms (1-99): ", max_terms_n, " terms => ", max_terms_a, "/", max_terms_b, " = " - call print_egyptian(0, max_terms_terms, max_terms_n) - write(*, '(/)') - - write(*, '(A)', advance='no') "Largest denominator (1-99): " - call print_big(max_denom_val) - write(*, '(A,I0,A,I0,A)', advance='no') " => ", max_denom_a, "/", max_denom_b, " = " - call print_egyptian(0, max_denom_terms, max_denom_n) - write(*, *) - write(*, *) - - ! ------------------------------------------------------------------ - ! Extra credit: 1- to 3-digit a,b - ! ------------------------------------------------------------------ - max_terms_n = 0 - call big_from_int(max_denom_val, 0) - max_denom_n = 0 - - do a = 1, 999 - do b = a + 1, 999 - call compute_egyptian(a, b, terms, nterms) - - if (nterms > max_terms_n) then - max_terms_n = nterms - max_terms_a = a - max_terms_b = b - max_terms_terms(1:nterms) = terms(1:nterms) - end if - - if (nterms > 0) then - if (big_compare(terms(nterms), max_denom_val) > 0) then - max_denom_val = terms(nterms) - max_denom_n = nterms - max_denom_a = a - max_denom_b = b - max_denom_terms(1:nterms) = terms(1:nterms) - end if - end if - end do - end do - - write(*, '(A,I0,A,I0,A,I0,A)', advance='no') & - "Largest number of terms (1-999): ", max_terms_n, " terms => ", max_terms_a, "/", max_terms_b, " = " - call print_egyptian(0, max_terms_terms, max_terms_n) - write(*, *) - - write(*, '(A)', advance='no') "Largest denominator (1-999): " - call print_big(max_denom_val) - write(*, '(A,I0,A,I0,A)', advance='no') " => ", max_denom_a, "/", max_denom_b, " = " - call print_egyptian(0, max_denom_terms, max_denom_n) - write(*, *) - -contains - - subroutine compute_egyptian(num0, den0, terms_out, nterms_out) - integer, intent(in) :: num0, den0 - type(big_int), intent(out) :: terms_out(:) - integer, intent(out) :: nterms_out - - type(big_int) :: den_big, d_big, temp - integer :: num, mod_val, new_num - - nterms_out = 0 - if (num0 <= 0 .or. den0 <= 0) return - - num = num0 - call big_from_int(den_big, den0) - - do while (num > 0) - temp = den_big - call big_add_small(temp, num - 1) - call big_div_small(temp, num, d_big) - - nterms_out = nterms_out + 1 - if (nterms_out > size(terms_out)) stop 'Too many terms - increase MAX_TERMS' - - terms_out(nterms_out) = d_big - - mod_val = big_mod_small(den_big, num) - if (mod_val == 0) then - new_num = 0 - else - new_num = num - mod_val - end if - - call big_mul(den_big, d_big, temp) - den_big = temp - - num = new_num - end do - end subroutine compute_egyptian - - subroutine big_from_int(b, i) - type(big_int), intent(out) :: b - integer, intent(in) :: i - b%len = 0 - b%d = 0 - if (i == 0) return - b%len = 1 - b%d(1) = i - end subroutine big_from_int - - subroutine big_add_small(b, s) - type(big_int), intent(inout) :: b - integer, intent(in) :: s - integer(kind=8) :: carry, tmp - integer :: i - - if (s == 0) return - carry = s - i = 1 - do while (carry > 0) - if (i > b%len) then - if (i > max_dig) stop 'Overflow in big_add_small' - b%len = i - b%d(i) = 0 - end if - tmp = int(b%d(i), 8) + carry - b%d(i) = mod(tmp, int(base, 8)) - carry = tmp / int(base, 8) - i = i + 1 - end do - end subroutine big_add_small - - subroutine big_mul(a, b, res) - type(big_int), intent(in) :: a, b - type(big_int), intent(out) :: res - integer(kind=8) :: tmp, carry - integer :: i, j, k - - res%d = 0 - res%len = 0 - if (a%len == 0 .or. b%len == 0) return - - do i = 1, a%len - carry = 0 - do j = 1, b%len - k = i + j - 1 - tmp = int(a%d(i), 8) * int(b%d(j), 8) + int(res%d(k), 8) + carry - res%d(k) = mod(tmp, int(base, 8)) - carry = tmp / int(base, 8) - end do - k = i + b%len - do while (carry > 0) - if (k > max_dig) stop 'Overflow in big_mul' - tmp = int(res%d(k), 8) + carry - res%d(k) = mod(tmp, int(base, 8)) - carry = tmp / int(base, 8) - k = k + 1 - end do - end do - - res%len = a%len + b%len + 1 - do while (res%len > 0 .and. res%d(res%len) == 0) - res%len = res%len - 1 - end do - end subroutine big_mul - - integer function big_mod_small(b, s) - type(big_int), intent(in) :: b - integer, intent(in) :: s - integer(kind=8) :: rem - integer :: i - - rem = 0 - do i = b%len, 1, -1 - rem = mod(rem * int(base, 8) + b%d(i), int(s, 8)) - end do - big_mod_small = int(rem) - end function big_mod_small - - subroutine big_div_small(b, s, q) - type(big_int), intent(in) :: b - integer, intent(in) :: s - type(big_int), intent(out) :: q - integer(kind=8) :: tmp, carry - integer :: i - - q%d = 0 - q%len = b%len - carry = 0 - do i = b%len, 1, -1 - tmp = carry * int(base, 8) + b%d(i) - q%d(i) = tmp / s - carry = mod(tmp, int(s, 8)) - end do - do while (q%len > 0 .and. q%d(q%len) == 0) - q%len = q%len - 1 - end do - end subroutine big_div_small - - integer function big_compare(a, b) - type(big_int), intent(in) :: a, b - integer :: i - - if (a%len > b%len) then - big_compare = 1 - else if (a%len < b%len) then - big_compare = -1 - else if (a%len == 0) then - big_compare = 0 - else - do i = a%len, 1, -1 - if (a%d(i) > b%d(i)) then - big_compare = 1 - return - else if (a%d(i) < b%d(i)) then - big_compare = -1 - return - end if - end do - big_compare = 0 - end if - end function big_compare - - subroutine print_big(b) - type(big_int), intent(in) :: b - character(20) :: buf - character(len=max_dig) :: pooka - character(len=8) :: front, back - integer :: i - pooka = '' - if (b%len == 0) then - write(*, '(A)', advance='no') "0" - return - end if - write(buf, '(I0)') b%d(b%len) -! write(*, '(A)', advance='no') trim(buf) - pooka = trim(adjustl(buf)) - do i = b%len - 1, 1, -1 - write(buf, '(I9.9)') b%d(i) - ! write(*,'(A)',advance='no') trim(adjustl(buf)) - pooka = trim(pooka) // trim(adjustl(buf)) - end do - i = len_trim(pooka) - if (i > 19)then - front = pooka(1:8) - back = pooka(i - 8:) - pooka = front // '....' // back - end if - write(*, '(A)', advance='no') trim(adjustl(pooka)) - end subroutine print_big - - subroutine print_egyptian(int_part, terms_in, n_in) - integer, intent(in) :: int_part, n_in - type(big_int), intent(in) :: terms_in(:) - integer :: i - logical :: need_plus - - need_plus = .false. - if (int_part > 0) then - write(*, '(A,I0,A)', advance='no') "[", int_part, "]" - if (n_in > 0) then - write(*, '(A)', advance='no') " + " - need_plus = .false. - end if - end if - - do i = 1, n_in - if (need_plus) write(*, '(A)', advance='no') " + " - write(*, '(A)', advance='no') "1/" - call print_big(terms_in(i)) - need_plus = .true. - end do - end subroutine print_egyptian - -end program egyptian_fractions diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/FutureBasic/greedy-algorithm-for-egyptian-fractions.basic b/Task/Greedy-algorithm-for-Egyptian-fractions/FutureBasic/greedy-algorithm-for-egyptian-fractions.basic deleted file mode 100644 index 2841366b89..0000000000 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/FutureBasic/greedy-algorithm-for-egyptian-fractions.basic +++ /dev/null @@ -1,304 +0,0 @@ -include "gmp.incl" - -// -------------------------------------------- -// -// Egyptian Fractions with GMP -// Using FutureBasic 7.0.35, October 2025, R.W -// -// -------------------------------------------- - -_kBitsPrecision = 256 // precission bits requested -STRSetLeadingSpace(_False) // no space on positive STR - -// ------------------------------------------ -// Simple string-returning Egyptian expansion -// ------------------------------------------ -local fn egyptian_Fraction( num as Int, denom as Int ) as CFStringRef - CFStringRef result - mpz_t n, d, t - - fn mpz_init2( n, _kBitsPrecision ) - fn mpz_init2( d, _kBitsPrecision ) - fn mpz_init2( t, _kBitsPrecision ) - - // n := num, d := denom - fn mpz_set_si( n, num ) - fn mpz_set_si( d, denom ) - - result = @"" - while fn mpz_cmp_si( n, 0 ) != 0 - // t = ceil(d/n) - fn mpz_cdiv_q( t, d, n ) - - // append "1/t" - if fn CFStringGetLength( result ) == 0 - result = concat( @"1/", fn mpz_cf2( t ) ) - else - result = concat( result, @" + 1/", fn mpz_cf2( t ) ) - end if - - // n,d <- (n*t - d, d*t) - fn mpz_mul( n, n, t ) // n = n * t - fn mpz_sub( n, n, d ) // n = n - d - fn mpz_mul( d, d, t ) // d = d * t - - // reduce if n != 0 - if fn mpz_cmp_si( n, 0 ) != 0 - mpz_t g - fn mpz_init2( g, _kBitsPrecision ) - fn mpz_gcd( g, n, d ) - if fn mpz_cmp_si( g, 1 ) != 0 - fn mpz_divexact( n, n, g ) - fn mpz_divexact( d, d, g ) - end if - fn mpz_clear( g ) - end if - wend - - fn mpz_clears( t, d, n, NULL ) -end fn = result - -// ------------------------------------------ -// Helper: -// gcd for Ints (used to skip duplicate fractions -// only consider reduced n/d) -local fn GCD_Int( a as Int, b as Int ) as Int - Int x, y, t - x = (a < 0) ? -a : a - y = (b < 0) ? -b : b - while y != 0 - t = x MOD y - x = y - y = t - wend -end fn = x - -// Helper: number of base-10 digits for positive Int (r>=1) -local fn NumDigits10( r as Int ) as Int - Int n, t - if r <= 0 - n = 1 - else - n = 0 - t = r - while t > 0 - t = t / 10 - n = n + 1 - wend - end if -end fn = n - -// Helper: Append item to list (empty list -> item) -local fn CSVAppend( list as CFStringRef, item as CFStringRef ) as CFStringRef - if list == _nil then return item - if fn CFStringGetLength( list ) == 0 then return item -end fn = concat( list, @", ", item ) - -// ------------------------------------------ -// EgyptianStats — greedy via GMP, returns: -// outStr : "1/x + 1/y + ..." -// outCount: #terms -// outLast : last unit term "1/z" -// outLastDenDigits: digits in z -// ------------------------------------------ -local fn EgyptianStats( n as Int, d as Int, ¬ - outStr as ^CFStringRef, ¬ - outCount as ^Int, ¬ - outLast as ^CFStringRef, ¬ - outLastDenDigits as ^Int ) - mpz_t a, b, t, tmp, g - CFMutableStringRef m - CFStringRef unit - Int count, firstTerm - CFIndex lenLast - - m = fn CFStringCreateMutable( _kCFAllocatorDefault, 0 ) - count = 0 - firstTerm = 1 - *outLast = @"" - - fn mpz_init2( a, _kBitsPrecision ) - fn mpz_init2( b, _kBitsPrecision ) - fn mpz_init2( t, _kBitsPrecision ) - fn mpz_init2( tmp, _kBitsPrecision ) - fn mpz_init2( g, _kBitsPrecision ) - - fn mpz_set_si( a, n ) // a = numerator - fn mpz_set_si( b, d ) // b = denominator - - while fn mpz_cmp_si( a, 0 ) != 0 - // t = ceil(b/a) - fn mpz_cdiv_q( t, b, a ) - - // Current unit term "1/t" - unit = concat( @"1/", fn mpz_cf2( t ) ) - if firstTerm - fn CFStringAppend( m, unit ) - firstTerm = 0 - else - fn CFStringAppend( m, @" + " ) - fn CFStringAppend( m, unit ) - end if - *outLast = unit - count = count + 1 - - // a = a*t - b ; b = b*t - fn mpz_mul( tmp, a, t ) - fn mpz_sub( a, tmp, b ) - fn mpz_mul( b, b, t ) - - if fn mpz_cmp_si( a, 0 ) != 0 - fn mpz_gcd( g, a, b ) - if fn mpz_cmp_si( g, 1 ) != 0 - fn mpz_divexact( a, a, g ) - fn mpz_divexact( b, b, g ) - end if - end if - wend - - *outStr = fn CFStringCreateCopy( _kCFAllocatorDefault, m ) - lenLast = fn CFStringGetLength( *outLast ) - if lenLast >= 3 - *outLastDenDigits = lenLast - 2 // strip leading "1/" - else - *outLastDenDigits = 0 - end if - *outCount = count - - fn mpz_clears( g, tmp, t, b, a, _nil ) -end fn - -// ------------------------------------------ -// Display the fraction chain [xx] if whole # -// ------------------------------------------ -void local fn efrac( num as Int, denom as Int ) - CFStringRef fraction, e, prefix - Int whole - fraction = @"": e = @"": prefix = @"" - fraction = concat( str(num),@"/", str(denom), @" -> " ) - if num >= denom - whole = FIX( num / denom ) - num = num - whole * denom - prefix = concat(@"[",str(whole),@"] + ") - end if - e = concat( fn egyptian_Fraction( num, denom )) - print @ fraction, prefix; e -end fn - - -// Rosetta task did not specify that we can use ellipsis -// but I figured it's unnecessary to list all the digits -// if it's more than 200 digits, instead we abbreviate it - -// Abbreviate denominator of a last unit term "1/XXXXXXXX" -// Returns "first10...last10" (or full if <= 200 chars) - -local fn AbbrevLastDen( lastTerm as CFStringRef ) as CFStringRef - CFStringRef outStr, denStr, a, b - CFIndex slashPos1, denLen - outStr = @"" - if lastTerm == _nil then return outStr - slashPos1 = instr( 0, lastTerm, @"/" ) - if slashPos1 == 0 then return outStr - // get the string from the slash back - denStr = mid( lastTerm, slashPos1+1 ) - denLen = fn CFStringGetLength( denStr ) - if denLen <= 200 then return denStr - a = left( denStr, 10 ) - b = mid( denStr, denLen - 10 ) - outStr = concat( a, @"...", b ) -end fn = outStr - - -// ------------------------------------------ -// Main -// ------------------------------------------ -window 1, @"Greedy Egyptian Fraction", (0,0,610,400) -print @ -print @"Egyptian fraction for:" -print @ - -// Rosetta Stone Task requirements 1 - -fn efrac( 43, 48 ) -fn efrac( 5, 121 ) -fn efrac( 2014, 59 ) - -// start the clock -CFTimeInterval t -t = fn CACurrentMediaTime - -// --------------------------------------------------- -// Rosetta Stone task 2 -// -// Do the Fibonacci's Greedy algorithm for Egyptian -// fractions expansion for proper fraction n/d with -// 1 <= n < d <= r+1, compute -// its Egyptian expansion, and report: -// - Largest number of terms (maxt) -// - Largest size (digits) of the final denominator -// --------------------------------------------------- -Int r -for r = 98 to 998 step 900 // do this iteration twice - Int n, d - Int nterms, lastDenDigits - Int maxTerms, maxDenDigits - CFStringRef termsStr, lastTerm, termLabel - CFStringRef maxTermsList, maxDenTermList, maxDenAbbrev - Int digitsR - - maxTerms = 0 : maxDenDigits = 0 - maxTermsList = @"": maxDenTermList = @"": maxDenAbbrev = @"" - - for n = 1 to r - for d = n + 1 to r + 1 - // Only reduced fractions - if fn GCD_Int( n, d ) == 1 //dupes skipped - termLabel = fn CFStringCreateWithFormat( _kCFAllocatorDefault, 0, @"%d/%d", n, d ) - - fn EgyptianStats( n, d, @termsStr, @nterms, @lastTerm, @lastDenDigits ) - - // Track largest number of terms - if nterms > maxTerms - maxTerms = nterms - maxTermsList = termLabel - else - if nterms == maxTerms - maxTermsList = fn CSVAppend( maxTermsList, termLabel ) - end if - end if - - // Track largest last-denominator digit length - if lastDenDigits > maxDenDigits - maxDenDigits = lastDenDigits - maxDenTermList = termLabel - maxDenAbbrev = fn AbbrevLastDen( lastTerm ) - else - if lastDenDigits == maxDenDigits - maxDenTermList = fn CSVAppend( maxDenTermList, termLabel ) - end if - end if - end if - next d - next n - - // Rosetta Stone Task 3 (extra credit) - - digitsR = fn NumDigits10( r ) - print - print @"For proper fractions with 1 to "; digitsR; @" digits:" - print @"Largest number of terms is "; maxTerms; @" for "; maxTermsList - print @"Largest size for denominator is for "; maxDenTermList; " with ";maxDenDigits; @" digits: " - - if maxDenDigits > 200 - print @ "("; maxDenAbbrev;")" - else - print @ maxDenAbbrev - end if -next r - -printf @"\nElapsed time: %.3f secs", (fn CACurrentMediaTime-t) - -handleEvents - -// diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/JavaScript/greedy-algorithm-for-egyptian-fractions.js b/Task/Greedy-algorithm-for-Egyptian-fractions/JavaScript/greedy-algorithm-for-egyptian-fractions.js deleted file mode 100644 index 7c80a0f77e..0000000000 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/JavaScript/greedy-algorithm-for-egyptian-fractions.js +++ /dev/null @@ -1,222 +0,0 @@ -// Egyptian Fractions implementation in JavaScript -// Using BigInt for arbitrary precision integers - -function gcd(a, b) { - if (b === 0n) { - return a; - } - return gcd(b, a % b); -} - -class Frac { - constructor(n, d) { - // Handle different input types (number or BigInt) - const num = typeof n === 'number' ? BigInt(n) : n; - const denom = typeof d === 'number' ? BigInt(d) : d; - - if (denom === 0n) { - throw new Error("Parameter d may not be zero."); - } - - let nn = num; - let dd = denom; - - if (nn === 0n) { - dd = 1n; - } else if (dd < 0n) { - nn = -nn; - dd = -dd; - } - - const g = gcd(nn < 0n ? -nn : nn, dd).valueOf(); - - if (g > 0n) { - nn = nn / g; - dd = dd / g; - } - - this.num = nn; - this.denom = dd; - } - - plus(rhs) { - return new Frac( - this.num * rhs.denom + this.denom * rhs.num, - this.denom * rhs.denom - ); - } - - unaryMinus() { - return new Frac(-this.num, this.denom); - } - - minus(rhs) { - return this.plus(rhs.unaryMinus()); - } - - compareTo(rhs) { - // We'll compare by cross multiplication to avoid floating point issues - const leftSide = this.num * rhs.denom; - const rightSide = rhs.num * this.denom; - - if (leftSide < rightSide) return -1; - if (leftSide > rightSide) return 1; - return 0; - } - - equals(obj) { - if (!(obj instanceof Frac)) { - return false; - } - return this.compareTo(obj) === 0; - } - - toString() { - if (this.denom === 1n) { - return this.num.toString(); - } - return `${this.num}/${this.denom}`; - } - - toNumber() { - // Convert fraction to a regular number (potentially with loss of precision) - return Number(this.num) / Number(this.denom); - } - - toEgyptian() { - if (this.num === 0n) { - return [this]; - } - - const fracs = []; - - if ((this.num < 0n ? -this.num : this.num) >= (this.denom < 0n ? -this.denom : this.denom)) { - // Handle improper fractions - const div = new Frac(this.num / this.denom, 1n); - const rem = this.minus(div); - fracs.push(div); - this._toEgyptian(rem.num, rem.denom, fracs); - } else { - this._toEgyptian(this.num, this.denom, fracs); - } - - return fracs; - } - - _toEgyptian(n, d, fracs) { - if (n === 0n) { - return; - } - - // Calculate ceiling of d/n - let div = d / n; - if (d % n !== 0n) { - div = div + 1n; - } - - fracs.push(new Frac(1n, div)); - - // Calculate next fraction's numerator and denominator - let n3 = -(d % n); - if (n3 < 0n) { - n3 = n3 + n; - } - - const d3 = d * div; - const f = new Frac(n3, d3); - - if (f.num === 1n) { - fracs.push(f); - return; - } - - this._toEgyptian(f.num, f.denom, fracs); - } -} - -// Main function -function main() { - const fracs = [ - new Frac(43, 48), - new Frac(5, 121), - new Frac(2014, 59) - ]; - - for (const frac of fracs) { - const list = frac.toEgyptian(); - const first = list[0]; - - if (first.denom === 1n) { - process.stdout.write(`${frac} -> [${first}] + `); - } else { - process.stdout.write(`${frac} -> ${first}`); - } - - for (let i = 1; i < list.length; ++i) { - process.stdout.write(` + ${list[i]}`); - } - - console.log(); - } - - for (const r of [98, 998]) { - if (r === 98) { - console.log("\nFor proper fractions with 1 or 2 digits:"); - } else { - console.log("\nFor proper fractions with 1, 2 or 3 digits:"); - } - - let maxSize = 0; - let maxSizeFracs = []; - let maxDen = 0n; - let maxDenFracs = []; - - // Create sieve array - const sieve = Array(r + 1).fill().map(() => Array(r + 2).fill(false)); - - for (let i = 1; i < r; ++i) { - for (let j = i + 1; j < r + 1; ++j) { - if (sieve[i][j]) continue; - - const f = new Frac(i, j); - const list = f.toEgyptian(); - const listSize = list.length; - - if (listSize > maxSize) { - maxSize = listSize; - maxSizeFracs = [f]; - } else if (listSize === maxSize) { - maxSizeFracs.push(f); - } - - const listDen = list[list.length - 1].denom; - - if (listDen > maxDen) { - maxDen = listDen; - maxDenFracs = [f]; - } else if (listDen === maxDen) { - maxDenFracs.push(f); - } - - if (i < r / 2) { - let k = 2; - while (true) { - if (j * k > r + 1) break; - sieve[i * k][j * k] = true; - k++; - } - } - } - } - - console.log(` largest number of items = ${maxSize}`); - console.log(`fraction(s) with this number : ${maxSizeFracs}`); - - const md = maxDen.toString(); - console.log(` largest denominator = ${md.length} digits, ${md.substring(0, 20)}...${md.substring(md.length - 20)}`); - console.log(`fraction(s) with this denominator : ${maxDenFracs}`); - } -} - -// Run the main function -main(); diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/Julia/greedy-algorithm-for-egyptian-fractions.jl b/Task/Greedy-algorithm-for-Egyptian-fractions/Julia/greedy-algorithm-for-egyptian-fractions.jl deleted file mode 100644 index aae2cd6384..0000000000 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/Julia/greedy-algorithm-for-egyptian-fractions.jl +++ /dev/null @@ -1,69 +0,0 @@ -struct EgyptianFraction{T<:Integer} <: Real - int::T - frac::NTuple{N,Rational{T}} where N -end -EgyptianFraction{V}(r::Rational{T}) where {T, V} = convert(EgyptianFraction{V}, r) -EgyptianFraction(r::Rational{T}) where T = convert(EgyptianFraction{T}, r) -EgyptianFraction(r::Rational) = convert(EgyptianFraction, r) - -Base.Rational(ef::EgyptianFraction{T}) where T = convert(Rational{T}, ef) -Base.show(io::IO, ef::EgyptianFraction) = println(io, "[", ef.int, "] ", join(ef.frac, " + ")) -Base.length(ef::EgyptianFraction) = !iszero(ef.int) + length(ef.frac) -function Base.convert(::Type{EgyptianFraction{T}}, fr::Rational) where T - fr, int::T = modf(fr) - fractions = Rational{T}[] - x::T, y::T = numerator(fr), denominator(fr) - iszero(x) && return EgyptianFraction{T}(int, (x // y,)) - while x != one(x) - push!(fractions, one(T) // cld(y, x)) - x, y = mod1(-y, x), y * cld(y, x) - d = gcd(x, y) - x ÷= d - y ÷= d - end - push!(fractions, x // y) - return EgyptianFraction{T}(int, tuple(fractions...)) -end -Base.convert(::Type{EgyptianFraction}, fr::Rational{T}) where T = convert(EgyptianFraction{T}, fr) -Base.convert(::Type{EgyptianFraction{T}}, fr::EgyptianFraction) where T = EgyptianFraction{T}(convert(T, fr.int), convert.(Rational{T}, fr.frac)) -Base.convert(::Type{Rational{T}}, fr::EgyptianFraction{V}) where {T, V} = T(fr.int) + sum(convert.(Rational{T}, fr.frac)) - -@show EgyptianFraction(43 // 48) -@show EgyptianFraction{BigInt}(5 // 121) -@show EgyptianFraction(2014 // 59) - -function task(fractions::AbstractVector) - fracs = convert(Vector{EgyptianFraction{BigInt}}, fractions) - local frlenmax::EgyptianFraction{BigInt} - local lenmax = 0 - local frdenmax::EgyptianFraction{BigInt} - local denmax = 0 - for f in fracs - if length(f) ≥ lenmax - lenmax = length(f) - frlenmax = f - end - if denominator(last(f.frac)) ≥ denmax - denmax = denominator(last(f.frac)) - frdenmax = f - end - end - return frlenmax, lenmax, frdenmax, denmax -end - -fr = collect((x // y) for x in 1:100 for y in 1:100 if x != y) |> unique -frlenmax, lenmax, frdenmax, denmax = task(fr) -println("Longest fraction, with length $lenmax: \n", Rational(frlenmax), "\n = ", frlenmax) -println("Fraction with greatest denominator\n(that is $denmax):\n", Rational(frdenmax), "\n = ", frdenmax) - -println("\n# For 1 digit-integers:") -fr = collect((x // y) for x in 1:10 for y in 1:10 if x != y) |> unique -frlenmax, lenmax, frdenmax, denmax = task(fr) -println("Longest fraction, with length $lenmax: \n", Rational(frlenmax), "\n = ", frlenmax) -println("Fraction with greatest denominator\n(that is $denmax):\n", Rational(frdenmax), "\n = ", frdenmax) - -println("# For 3 digit-integers:") -fr = collect((x // y) for x in 1:1000 for y in 1:1000 if x != y) |> unique -frlenmax, lenmax, frdenmax, denmax = task(fr) -println("Longest fraction, with length $lenmax: \n", Rational(frlenmax), "\n = ", frlenmax) -println("Fraction with greatest denominator\n(that is $denmax):\n", Rational(frdenmax), "\n = ", frdenmax) diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/Julia/greedy-algorithm-for-egyptian-fractions.julia b/Task/Greedy-algorithm-for-Egyptian-fractions/Julia/greedy-algorithm-for-egyptian-fractions.julia new file mode 100644 index 0000000000..24ff1c4277 --- /dev/null +++ b/Task/Greedy-algorithm-for-Egyptian-fractions/Julia/greedy-algorithm-for-egyptian-fractions.julia @@ -0,0 +1,66 @@ +struct EgyptianFraction{T<:Integer} <: Real + int::T + frac::NTuple{N,Rational{T}} where N +end + +Base.show(io::IO, ef::EgyptianFraction) = println(io, "[", ef.int, "] ", join(ef.frac, " + ")) +Base.length(ef::EgyptianFraction) = !iszero(ef.int) + length(ef.frac) +function Base.convert(::Type{EgyptianFraction{T}}, fr::Rational) where T + fr, int::T = modf(fr) + fractions = Vector{Rational{T}}(0) + x::T, y::T = numerator(fr), denominator(fr) + iszero(x) && return EgyptianFraction{T}(int, (x // y,)) + while x != one(x) + push!(fractions, one(T) // cld(y, x)) + x, y = mod1(-y, x), y * cld(y, x) + d = gcd(x, y) + x ÷= d + y ÷= d + end + push!(fractions, x // y) + return EgyptianFraction{T}(int, tuple(fractions...)) +end +Base.convert(::Type{EgyptianFraction}, fr::Rational{T}) where T = convert(EgyptianFraction{T}, fr) +Base.convert(::Type{EgyptianFraction{T}}, fr::EgyptianFraction) where T = EgyptianFraction{T}(convert(T, fr.int), convert.(Rational{T}, fr.frac)) +Base.convert(::Type{Rational{T}}, fr::EgyptianFraction) where T = T(fr.int) + sum(convert.(Rational{T}, fr.frac)) +Base.convert(::Type{Rational}, fr::EgyptianFraction{T}) where T = convert(Rational{T}, fr) + +@show EgyptianFraction(43 // 48) +@show EgyptianFraction{BigInt}(5 // 121) +@show EgyptianFraction(2014 // 59) + +function task(fractions::AbstractVector) + fracs = convert(Vector{EgyptianFraction{BigInt}}, fractions) + local frlenmax::EgyptianFraction{BigInt} + local lenmax = 0 + local frdenmax::EgyptianFraction{BigInt} + local denmax = 0 + for f in fracs + if length(f) ≥ lenmax + lenmax = length(f) + frlenmax = f + end + if denominator(last(f.frac)) ≥ denmax + denmax = denominator(last(f.frac)) + frdenmax = f + end + end + return frlenmax, lenmax, frdenmax, denmax +end + +fr = collect((x // y) for x in 1:100 for y in 1:100 if x != y) |> unique +frlenmax, lenmax, frdenmax, denmax = task(fr) +println("Longest fraction, with length $lenmax: \n", Rational(frlenmax), "\n = ", frlenmax) +println("Fraction with greatest denominator\n(that is $denmax):\n", Rational(frdenmax), "\n = ", frdenmax) + +println("\n# For 1 digit-integers:") +fr = collect((x // y) for x in 1:10 for y in 1:10 if x != y) |> unique +frlenmax, lenmax, frdenmax, denmax = task(fr) +println("Longest fraction, with length $lenmax: \n", Rational(frlenmax), "\n = ", frlenmax) +println("Fraction with greatest denominator\n(that is $denmax):\n", Rational(frdenmax), "\n = ", frdenmax) + +println("# For 3 digit-integers:") +fr = collect((x // y) for x in 1:1000 for y in 1:1000 if x != y) |> unique +frlenmax, lenmax, frdenmax, denmax = task(fr) +println("Longest fraction, with length $lenmax: \n", Rational(frlenmax), "\n = ", frlenmax) +println("Fraction with greatest denominator\n(that is $denmax):\n", Rational(frdenmax), "\n = ", frdenmax) diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/Kotlin/greedy-algorithm-for-egyptian-fractions.kts b/Task/Greedy-algorithm-for-Egyptian-fractions/Kotlin/greedy-algorithm-for-egyptian-fractions.kotlin similarity index 100% rename from Task/Greedy-algorithm-for-Egyptian-fractions/Kotlin/greedy-algorithm-for-egyptian-fractions.kts rename to Task/Greedy-algorithm-for-Egyptian-fractions/Kotlin/greedy-algorithm-for-egyptian-fractions.kotlin diff --git a/Task/Greedy-algorithm-for-Egyptian-fractions/Phix/greedy-algorithm-for-egyptian-fractions.phix b/Task/Greedy-algorithm-for-Egyptian-fractions/Phix/greedy-algorithm-for-egyptian-fractions.phix index d4f24ce4f4..5695fb8f26 100644 --- a/Task/Greedy-algorithm-for-Egyptian-fractions/Phix/greedy-algorithm-for-egyptian-fractions.phix +++ b/Task/Greedy-algorithm-for-Egyptian-fractions/Phix/greedy-algorithm-for-egyptian-fractions.phix @@ -1,78 +1,80 @@ -with javascript_semantics -include mpfr.e -function egyptian(integer num, denom) - mpz n = mpz_init(num), - d = mpz_init(denom), - t = mpz_init() - sequence result = {} - while mpz_cmp_si(n,0)!=0 do - mpz_cdiv_q(t, d, n) - result = append(result,"1/"&mpz_get_str(t)) - mpz_neg(d,d) - mpz_mod(n,d,n) - mpz_neg(d,d) - mpz_mul(d,d,t) - end while - {n,d} = mpz_free({n,d}) - return result -end function +(phixonline)--> + with javascript_semantics + include mpfr.e + function egyptian(integer num, denom) + mpz n = mpz_init(num), + d = mpz_init(denom), + t = mpz_init() + sequence result = {} + while mpz_cmp_si(n,0)!=0 do + mpz_cdiv_q(t, d, n) + result = append(result,"1/"&mpz_get_str(t)) + mpz_neg(d,d) + mpz_mod(n,d,n) + mpz_neg(d,d) + mpz_mul(d,d,t) + end while + {n,d} = mpz_free({n,d}) + return result + end function -procedure efrac(integer num, denom) - string fraction = sprintf("%d/%d",{num,denom}), - prefix = "" - if num>=denom then - integer whole = floor(num/denom) - num -= whole*denom - prefix = sprintf("[%d] + ",whole) - end if - string e = join(egyptian(num, denom)," + ") - printf(1,"%s -> %s%s\n",{fraction,prefix,e}) -end procedure + procedure efrac(integer num, denom) + string fraction = sprintf("%d/%d",{num,denom}), + prefix = "" + if num>=denom then + integer whole = floor(num/denom) + num -= whole*denom + prefix = sprintf("[%d] + ",whole) + end if + string e = join(egyptian(num, denom)," + ") + printf(1,"%s -> %s%s\n",{fraction,prefix,e}) + end procedure -efrac(43,48) -efrac(5,121) -efrac(2014,59) + efrac(43,48) + efrac(5,121) + efrac(2014,59) -integer maxt = 0, - maxd = 0 -string maxts = "", - maxds = "", - maxda = "" + integer maxt = 0, + maxd = 0 + string maxts = "", + maxds = "", + maxda = "" -for r=98 to 998 by 900 do -- (iterates just twice!) - sequence sieve = repeat(repeat(false,r+1),r) -- to eliminate duplicates - for n=1 to r do - for d=n+1 to r+1 do - if sieve[n][d]=false then - string term = sprintf("%d/%d",{n,d}) - sequence terms = egyptian(n,d) - integer nterms = length(terms) - if nterms>maxt then - maxt = nterms - maxts = term - elsif nterms=maxt then - maxts &= ", " & term - end if - integer mlen = length(terms[$])-2 - if mlen>maxd then - maxd = mlen - maxds = term - maxda = terms[$] - elsif mlen=maxd then - maxds &= ", " & term - end if - if n r+1 then exit end if - sieve[n*k][d*k] = true - end for - end if - end if - end for - end for - printf(1,"\nfor proper fractions with 1 to %d digits\n",{length(sprint(r))}) - printf(1,"Largest number of terms is %d for %s\n",{maxt,maxts}) - maxda = maxda[3..$] -- (strip the "1/") - maxda[6..-6]="..." -- (show only first/last 5 digits) - printf(1,"Largest size for denominator is %d digits (%s) for %s\n",{maxd,maxda,maxds}) -end for + for r=98 to 998 by 900 do -- (iterates just twice!) + sequence sieve = repeat(repeat(false,r+1),r) -- to eliminate duplicates + for n=1 to r do + for d=n+1 to r+1 do + if sieve[n][d]=false then + string term = sprintf("%d/%d",{n,d}) + sequence terms = egyptian(n,d) + integer nterms = length(terms) + if nterms>maxt then + maxt = nterms + maxts = term + elsif nterms=maxt then + maxts &= ", " & term + end if + integer mlen = length(terms[$])-2 + if mlen>maxd then + maxd = mlen + maxds = term + maxda = terms[$] + elsif mlen=maxd then + maxds &= ", " & term + end if + if n<r/2 then + for k=2 to 9999 do + if d*k > r+1 then exit end if + sieve[n*k][d*k] = true + end for + end if + end if + end for + end for + printf(1,"\nfor proper fractions with 1 to %d digits\n",{length(sprint(r))}) + printf(1,"Largest number of terms is %d for %s\n",{maxt,maxts}) + maxda = maxda[3..$] -- (strip the "1/") + maxda[6..-6]="..." -- (show only first/last 5 digits) + printf(1,"Largest size for denominator is %d digits (%s) for %s\n",{maxd,maxda,maxds}) + end for + OpenSSL Stuffs <-- -extern BIO_new_ssl_connect -extern BIO_ctrl -extern BIO_write -extern BIO_read -extern BIO_free_all -extern TLS_client_method -extern SSL_CTX_new -extern SSL_CTX_free -extern SSL_CTX_set_verify -extern SSL_CTX_set_default_verify_paths -extern SSL_ctrl - -%define BIO_C_SET_CONNECT 100 -%define BIO_C_DO_STATE 101 -%define BIO_C_GET_SSL 110 -%define SSL_CTRL_SET_TLSHOST 55 -%define SSL_VERIFY_PEER 1 - -section .text - global xrequest - xrequest: - prolog 6*8 - %define _req_host rbp-1*8 - %define _req_pack rbp-2*8 - %define _req_buff rbp-3*8 - %define _req_ssl rbp-4*8 - %define _req_ctx rbp-5*8 - %define _req_bio rbp-6*8 - - mov rax, rdi - mov qword [_req_host], rax - mov rax, rsi - mov qword [_req_pack], rax - mov rax, rdx - mov qword [_req_buff], rax - xcall TLS_client_method - mov rdi, rax - xcall SSL_CTX_new - test rax, rax - jz __req_err_ctx - mov qword [_req_ctx], rax - mov rdi, qword [_req_ctx] - xcall SSL_CTX_set_default_verify_paths - test eax, eax - jz __req_err_verify - mov rdx, 0 - mov rsi, SSL_VERIFY_PEER - mov rdi, qword [_req_ctx] - xcall SSL_CTX_set_verify - ;;-->> Create Bio chain - mov rdi, qword [_req_ctx] - xcall BIO_new_ssl_connect - test rax, rax - jz __req_err_bio - mov qword [_req_bio], rax - ;;-->> Get SSL object - lea rcx, [_req_ssl] - mov rdx, 0 - mov rsi, BIO_C_GET_SSL - mov rdi, qword [_req_bio] - xcall BIO_ctrl - - ;; -->> Set the SNI hostname. - mov rdi, qword [_req_host] - xcall strdup - mov rdx, rax ; rdx now holds the copy - push rdx ; Push pointer to stack - mov rdi, rdx - mov rsi, ':' - xcall strchr - test rax, rax - jz __req_sni_set - mov byte [rax], 0 ; Null-terminate at colon - __req_sni_set: - mov rdi, qword [_req_ssl] - mov rsi, SSL_CTRL_SET_TLSHOST - mov rdx, 0 - mov rcx, [rsp] - xcall SSL_ctrl - pop rdi - xcall free - ;; -->>Set Hostname (BIO expects "host:port") - mov rdi, qword [_req_bio] - mov rsi, BIO_C_SET_CONNECT - mov rdx, 0 - mov rcx, qword [_req_host] - xcall BIO_ctrl - mov rdi, qword [_req_bio] - mov rsi, BIO_C_DO_STATE - mov rdx, 0 - mov rcx, 0 - xcall BIO_ctrl - cmp rax, 1 - jl __req_err_conn - - ;; -->> Send Request - mov rdi, qword [_req_pack] - xcall strlen - mov rdx, rax - mov rdi, qword [_req_bio] - mov rsi, qword [_req_pack] - xcall BIO_write - - ; -->> Read Response Loop - __req_read_loop: - mov rdi, qword [_req_bio] - mov rsi, qword [_req_buff] - mov rdx, 1024 - xcall BIO_read - test eax, eax - jle __req_exit - add qword [_req_buff], rax - jmp __req_read_loop - - - __req_err_bio: - mov r13, -1 - jmp __req_exit - __req_err_verify: - mov r13, -2 - jmp __req_exit - __req_err_ctx: - ;;-->> CTX Error - mov r13, -3 - jmp __req_exit - __req_err_conn: - mov r13, -4 - ;; fall through.. - __req_exit: - mov r13, rax - mov rdi, qword [_req_bio] - xcall BIO_free_all - mov rdi, qword [_req_ctx] - xcall SSL_CTX_free - mov rax, r13 - epilog 6*8 - ret - - global main - main: - prolog 4*8 - - ; request(hostname, request_str, buffer) - xlea rdi, hostname - xlea rsi, request_str - xlea rdx, buffer - call xrequest - mov rsi, rax - xlea rdi, fmt_ret - xcall printf - - ; Print the response buffer - xlea rdi, fmt_str - xlea rsi, buffer - xor rax, rax - xcall printf - xor rdi, rdi - xcall exit - prolog 4*8 ;;Never gets here but w/e. - ret - -section .data - hostname db "google.com:443", 0 - request_str db "GET / HTTP/1.1", 13, 10 - db "Host: google.com", 13, 10 - db "Connection: close", 13, 10 - db "User-Agent: TLS-TEST/0.5", 13, 10 - db 13, 10, 0 - - fmt_str db "%s", 0 - fmt_ret db "%i",10,0 - -section .bss - buffer resb 16384 diff --git a/Task/Hailstone-sequence/ABC/hailstone-sequence.abc b/Task/Hailstone-sequence/ABC/hailstone-sequence.abc deleted file mode 100644 index 7241e86e8f..0000000000 --- a/Task/Hailstone-sequence/ABC/hailstone-sequence.abc +++ /dev/null @@ -1,22 +0,0 @@ -HOW TO RETURN hailstone n: - PUT {} IN seq - WHILE 1=1: - PUT n IN seq[#seq] - SELECT: - n=1: RETURN seq - n mod 2=0: PUT floor(n/2) IN n - n mod 2=1: PUT 3*n+1 IN n - RETURN seq - -PUT hailstone 27 IN h27 -WRITE "Length of Hailstone sequence for 27:", #h27/ -WRITE "First 4 elements:", h27[0], h27[1], h27[2], h27[3]/ -WRITE "Last 4 elements:", h27[#h27-4], h27[#h27-3], h27[#h27-2], h27[#h27-1]/ - -PUT 0, 0 IN longest, length -FOR n IN {1..100000}: - PUT hailstone n IN hn - IF #hn > length: - PUT n, #hn IN longest, length - -WRITE longest, "has the longest hailstone sequence < 100,000, of length:", length/ diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-1.adb b/Task/Hailstone-sequence/Ada/hailstone-sequence-1.ada similarity index 100% rename from Task/Hailstone-sequence/Ada/hailstone-sequence-1.adb rename to Task/Hailstone-sequence/Ada/hailstone-sequence-1.ada diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-2.adb b/Task/Hailstone-sequence/Ada/hailstone-sequence-2.ada similarity index 100% rename from Task/Hailstone-sequence/Ada/hailstone-sequence-2.adb rename to Task/Hailstone-sequence/Ada/hailstone-sequence-2.ada diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-3.adb b/Task/Hailstone-sequence/Ada/hailstone-sequence-3.ada similarity index 100% rename from Task/Hailstone-sequence/Ada/hailstone-sequence-3.adb rename to Task/Hailstone-sequence/Ada/hailstone-sequence-3.ada diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-4.adb b/Task/Hailstone-sequence/Ada/hailstone-sequence-4.ada similarity index 100% rename from Task/Hailstone-sequence/Ada/hailstone-sequence-4.adb rename to Task/Hailstone-sequence/Ada/hailstone-sequence-4.ada diff --git a/Task/Hailstone-sequence/Amazing-Hopper/hailstone-sequence.hopper b/Task/Hailstone-sequence/Amazing-Hopper/hailstone-sequence.hopper deleted file mode 100644 index 4458a6198f..0000000000 --- a/Task/Hailstone-sequence/Amazing-Hopper/hailstone-sequence.hopper +++ /dev/null @@ -1,43 +0,0 @@ -#include - -#proto Hailstone(_X_,_SW_) - -algoritmo - - valor=27, máxima secuencia=0, vtemp=0 - imprimir ( _Hailstone(27,1) ---copiar en 'máxima secuencia'--- , NL ) - - i=28 - iterar - _Hailstone(i,0), copiar en 'vtemp' - cuando( sea mayor que 'máxima secuencia' ) { - máxima secuencia = vtemp - valor=i - } - ++i - hasta que ' #(i==100000) ' - imprimir ( #(utf8("Máxima longitud ")),máxima secuencia,\ - " fue encontrada para Hailstone(",valor,\ - #(utf8(") para números <100,000")), NL ) - -terminar - -subrutinas - -Hailstone(n, sw) - largo_de_secuencia = 0 - v={}, n, mete(v) - iterar - tomar si ( es par(n), #(n/2), \ - tomar si ( #(n<>1), #(3*n+1), 1) ) - ---copiar en 'n'--- mete(v) - hasta que ' #(n==1) ' - #(length(v)), mover a 'largo_de_secuencia' - cuando (sw){ - decimales '0' - #( v[1:4] ), ",...,", - #( v[largo_de_secuencia-4 : largo_de_secuencia] ) - NL, #(utf8("Tamaño de la secuencia: ")) - imprime esto; decimales normales - } -retornar ' largo_de_secuencia ' diff --git a/Task/Hailstone-sequence/AppleScript/hailstone-sequence-2.applescript b/Task/Hailstone-sequence/AppleScript/hailstone-sequence-2.applescript index 5212c2123f..2c60a4ef18 100644 --- a/Task/Hailstone-sequence/AppleScript/hailstone-sequence-2.applescript +++ b/Task/Hailstone-sequence/AppleScript/hailstone-sequence-2.applescript @@ -11,4 +11,3 @@ repeat with n from 2 to 99999 set end of nums to n end if end repeat -return {|number(s) giving longest sequence length|:nums, |length of sequence|:longestLength} diff --git a/Task/Hailstone-sequence/Arturo/hailstone-sequence.arturo b/Task/Hailstone-sequence/Arturo/hailstone-sequence.arturo index 1050130f7d..a8510e757c 100644 --- a/Task/Hailstone-sequence/Arturo/hailstone-sequence.arturo +++ b/Task/Hailstone-sequence/Arturo/hailstone-sequence.arturo @@ -1,10 +1,10 @@ hailstone: function [n][ ret: @[n] while [n>1][ - switch 1 = and n 1 -> n: 1+3*n - -> n: n/2 + if? 1 = and n 1 -> n: 1+3*n + else -> n: n/2 - append 'ret n + 'ret ++ n ] ret ] diff --git a/Task/Hailstone-sequence/AutoIt/hailstone-sequence.au3 b/Task/Hailstone-sequence/AutoIt/hailstone-sequence.autoit similarity index 100% rename from Task/Hailstone-sequence/AutoIt/hailstone-sequence.au3 rename to Task/Hailstone-sequence/AutoIt/hailstone-sequence.autoit diff --git a/Task/Hailstone-sequence/Ballerina/hailstone-sequence.ballerina b/Task/Hailstone-sequence/Ballerina/hailstone-sequence.ballerina deleted file mode 100644 index 775dc1646d..0000000000 --- a/Task/Hailstone-sequence/Ballerina/hailstone-sequence.ballerina +++ /dev/null @@ -1,34 +0,0 @@ -import ballerina/io; - -function hailstone(int m) returns int[] { - int n = m; - int[] h = [n]; - while n != 1 { - n = n % 2 == 0 ? n / 2 : 3 * n + 1; - h.push(n); - } - return h; -} - -public function main() { - int[] h = hailstone(27); - int len = h.length(); - io:println("For the Hailstone sequence starting with n = 27:"); - io:println(" Number of elements = ", len); - io:println(" First four elements = ", h.slice(0, 4)); - io:println(" Final four elements = ", h.slice(len - 4)); - - io:println("\nThe Hailstone sequence for n < 100,000 with the longest length is:"); - int longest = 0; - int longlen = 0; - foreach int n in 1...99999 { - h = hailstone(n); - len = h.length(); - if len > longlen { - longest = n; - longlen = len; - } - } - io:println(` Longest = ${longest}`); - io:println(` Length = ${longlen}`); -} diff --git a/Task/Hailstone-sequence/Binary-Lambda-Calculus/hailstone-sequence.blc b/Task/Hailstone-sequence/Binary-Lambda-Calculus/hailstone-sequence.blc deleted file mode 100644 index 85e3c77b13..0000000000 --- a/Task/Hailstone-sequence/Binary-Lambda-Calculus/hailstone-sequence.blc +++ /dev/null @@ -1,40 +0,0 @@ -(let ((div2 (lambda (n) - (n (lambda (x) - (x (lambda (so-far odd?) - (odd? - ;; lambda (p) here and after is inlined cons - (lambda (p) - (p - ;; Inlined successor - (lambda (f x) - (f (so-far f x))) - nil)) - ;; cons so-far t - (lambda (p) (p so-far t)))))) - (lambda (p) (p 0 nil))))) - (fixpoint-combinator - #+nil - (lambda (g) - (let ((inner (lambda (x) (g (x x))))) - (inner inner))) - (lambda (f) - (let ((inner (lambda (x) - (f (lambda (y) - (x x y)))))) - (inner inner)))) - (hailstone (fixpoint-combinator - (lambda (recur n) - ((div2 n) - (lambda (half n-odd?) - (half - (lambda (x) - ;; lambda (p) is inlined cons - (lambda (p) - (p n (recur (n-odd? - (lambda (f x) - ;; (succ (mult 3 n)) - (f (3 (n f) x))) - half))))) - ;; lambda (p) is inlined cons - (lambda (p) (p 1 nil))))))))) - hailstone) diff --git a/Task/Hailstone-sequence/Bruijn/hailstone-sequence.bruijn b/Task/Hailstone-sequence/Bruijn/hailstone-sequence.bruijn deleted file mode 100644 index cd759cb715..0000000000 --- a/Task/Hailstone-sequence/Bruijn/hailstone-sequence.bruijn +++ /dev/null @@ -1,21 +0,0 @@ -:import std/Combinator . -:import std/List . -:import std/Math M -:import std/Number/Binary . - -# hailstone sequence using binary shifts -hailstone y [[(0 =? (+1b)) {}0 go]] - go 0 : (=²?0 (1 /²0) (1 (↑¹0 + 0))) - -# --- tests --- - -seq-27 hailstone (+27b) - -:test (∀seq-27) ((+112)) -:test (take (+4) seq-27) ((+27b) : ((+82b) : ((+41b) : {}(+124b)))) -:test (take (+4) <~>seq-27) ((+1b) : ((+2b) : ((+4b) : {}(+8b)))) - -below-100000 [0 : ∀(hailstone 0)] <$> seq - seq take (+99999) (iterate ++‣ (+1b)) - -main [head (max-by (M.compare ⋔ tail) below-100000)] diff --git a/Task/Hailstone-sequence/COBOL/hailstone-sequence.cob b/Task/Hailstone-sequence/COBOL/hailstone-sequence.cobol similarity index 100% rename from Task/Hailstone-sequence/COBOL/hailstone-sequence.cob rename to Task/Hailstone-sequence/COBOL/hailstone-sequence.cobol diff --git a/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp b/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp index c113be9365..88bd0f3f1f 100644 --- a/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp +++ b/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp @@ -3,7 +3,7 @@ ((evenp n) (cons n (hailstone (/ n 2)))) (t (cons n (hailstone (+ (* 3 n) 1)))))) -(defun longest-hailstone (n) +(defun longest (n) (let ((k 0) (l 0)) (loop for i from 1 below n do (let ((len (length (hailstone i)))) diff --git a/Task/Hailstone-sequence/Crystal/hailstone-sequence.cr b/Task/Hailstone-sequence/Crystal/hailstone-sequence.crystal similarity index 100% rename from Task/Hailstone-sequence/Crystal/hailstone-sequence.cr rename to Task/Hailstone-sequence/Crystal/hailstone-sequence.crystal diff --git a/Task/Hailstone-sequence/Delphi/hailstone-sequence-1.pas b/Task/Hailstone-sequence/Delphi/hailstone-sequence-1.delphi similarity index 100% rename from Task/Hailstone-sequence/Delphi/hailstone-sequence-1.pas rename to Task/Hailstone-sequence/Delphi/hailstone-sequence-1.delphi diff --git a/Task/Hailstone-sequence/Delphi/hailstone-sequence-2.pas b/Task/Hailstone-sequence/Delphi/hailstone-sequence-2.delphi similarity index 100% rename from Task/Hailstone-sequence/Delphi/hailstone-sequence-2.pas rename to Task/Hailstone-sequence/Delphi/hailstone-sequence-2.delphi diff --git a/Task/Hailstone-sequence/DuckDB/hailstone-sequence.duckdb b/Task/Hailstone-sequence/DuckDB/hailstone-sequence.duckdb deleted file mode 100644 index d1d48d9211..0000000000 --- a/Task/Hailstone-sequence/DuckDB/hailstone-sequence.duckdb +++ /dev/null @@ -1,27 +0,0 @@ -# Generate the hailstone sequence without an index -create or replace function hailstone(start) as table ( - with recursive cte as ( - select start as n - union all - select if( n % 2 = 0, n // 2, 3 * n + 1) as n - from cte - where n != 1 - ) from cte -); - -# The length of the hailstone sequence of nn using count() -create or replace function hailstone_length(nn) as ( - select count() as n from hailstone(nn) -); - -# Return a tuple giving the seed and the hailstone sequence length -create or replace function hailstone_max_of_lengths(mx) as ( - select max_by( (n,hailstone_length(n)), hailstone_length(n)) - from range(1,mx+1) _(n) -); - -# Table of lengths (e.g. for use with histogram()) -create or replace function hailstone_lengths(mx) as table ( - select hailstone_length(n) as length - from range(1,mx+1) _(n) -); diff --git a/Task/Hailstone-sequence/EMal/hailstone-sequence.emal b/Task/Hailstone-sequence/EMal/hailstone-sequence.emal index 88e9413884..535c4f65df 100644 --- a/Task/Hailstone-sequence/EMal/hailstone-sequence.emal +++ b/Task/Hailstone-sequence/EMal/hailstone-sequence.emal @@ -1,26 +1,26 @@ -fun hailstone ← List by int n - List h ← int[n] - while n ≠ 1 - n ← when((n % 2 æ 0), n / 2, 3 * n + 1) +fun hailstone = List by int n + List h = int[n] + while n != 1 + n = when((n % 2 == 0), n / 2, 3 * n + 1) h.append(n) end return h end -int NUMBER ← 27 -int LESS_THAN ← 100000 -List sequence ← hailstone(NUMBER) +int NUMBER = 27 +int LESS_THAN = 100000 +List sequence = hailstone(NUMBER) writeLine("The hailstone sequence for the number " + NUMBER + " has " + sequence.length + " elements") writeLine("starting with " + sequence.extractStart(4).join(", ") + " and ending with " + sequence.extractEnd(4).join(", ") + ".") -int number ← 0 -sequence ← int[] -for int i ← 1; i < LESS_THAN; ++i - List current ← hailstone(i) +int number = 0 +sequence = int[] +for int i = 1; i < LESS_THAN; ++i + List current = hailstone(i) if current.length > sequence.length - sequence ← current - number ← i + sequence = current + number = i end end writeLine("The number less than 100000 with longest hailstone sequence is " + diff --git a/Task/Hailstone-sequence/EasyLang/hailstone-sequence.easy b/Task/Hailstone-sequence/EasyLang/hailstone-sequence.easy deleted file mode 100644 index ff201550a8..0000000000 --- a/Task/Hailstone-sequence/EasyLang/hailstone-sequence.easy +++ /dev/null @@ -1,26 +0,0 @@ -proc hailstone n &list[] . - list[] = [ ] - while n <> 1 - list[] &= n - if n mod 2 = 0 - n = n / 2 - else - n = 3 * n + 1 - . - . - list[] &= 1 -. -hailstone 27 l[] -write "27 has length " & len l[] & " with " -for i to 4 : write l[i] & " " -write "... " -for i = len l[] - 3 to len l[] : write l[i] & " " -print "" -for i = 1 to 100000 - hailstone i l[] - if len l[] >= max_iter - max_i = i - max_iter = len l[] - . -. -print max_i & " has length " & max_iter diff --git a/Task/Hailstone-sequence/Elena/hailstone-sequence.elena b/Task/Hailstone-sequence/Elena/hailstone-sequence.elena index 6933f48a7b..f7a6b6523d 100644 --- a/Task/Hailstone-sequence/Elena/hailstone-sequence.elena +++ b/Task/Hailstone-sequence/Elena/hailstone-sequence.elena @@ -30,13 +30,13 @@ Hailstone(int n,Map lengths) } } -public Program() +public program() { int longestChain := 0; int longestNumber := 0; auto recursiveLengths := new Map(4096,4096); - for(int i := 1; i < maxNumber; i+=1) + for(int i := 1, i < maxNumber, i+=1) { var chainLength := Hailstone(i, recursiveLengths); if (longestChain < chainLength) diff --git a/Task/Hailstone-sequence/Elixir/hailstone-sequence.ex b/Task/Hailstone-sequence/Elixir/hailstone-sequence.elixir similarity index 100% rename from Task/Hailstone-sequence/Elixir/hailstone-sequence.ex rename to Task/Hailstone-sequence/Elixir/hailstone-sequence.elixir diff --git a/Task/Hailstone-sequence/Euphoria/hailstone-sequence.eu b/Task/Hailstone-sequence/Euphoria/hailstone-sequence.euphoria similarity index 100% rename from Task/Hailstone-sequence/Euphoria/hailstone-sequence.eu rename to Task/Hailstone-sequence/Euphoria/hailstone-sequence.euphoria diff --git a/Task/Hailstone-sequence/Jq/hailstone-sequence-2.jq b/Task/Hailstone-sequence/Jq/hailstone-sequence-2.jq index 06fd8b01e9..c6b0fe55d9 100644 --- a/Task/Hailstone-sequence/Jq/hailstone-sequence-2.jq +++ b/Task/Hailstone-sequence/Jq/hailstone-sequence-2.jq @@ -3,5 +3,5 @@ "The first four numbers: \($h[0:4])", "The last four numbers: \($h|.[length-4:length])", "", - (max_hailstone(100000) as $m - | "Maximum length for n|hailstone for n in 1..100000 is \($m[1]) (n == \($m[0]))") + max_hailstone(100000) as $m + | "Maximum length for n|hailstone for n in 1..100000 is \($m[1]) (n == \($m[0]))" diff --git a/Task/Hailstone-sequence/Julia/hailstone-sequence-1.jl b/Task/Hailstone-sequence/Julia/hailstone-sequence-1.julia similarity index 100% rename from Task/Hailstone-sequence/Julia/hailstone-sequence-1.jl rename to Task/Hailstone-sequence/Julia/hailstone-sequence-1.julia diff --git a/Task/Hailstone-sequence/Julia/hailstone-sequence-2.jl b/Task/Hailstone-sequence/Julia/hailstone-sequence-2.julia similarity index 100% rename from Task/Hailstone-sequence/Julia/hailstone-sequence-2.jl rename to Task/Hailstone-sequence/Julia/hailstone-sequence-2.julia diff --git a/Task/Hailstone-sequence/Julia/hailstone-sequence-3.jl b/Task/Hailstone-sequence/Julia/hailstone-sequence-3.julia similarity index 100% rename from Task/Hailstone-sequence/Julia/hailstone-sequence-3.jl rename to Task/Hailstone-sequence/Julia/hailstone-sequence-3.julia diff --git a/Task/Hailstone-sequence/Kotlin/hailstone-sequence-1.kts b/Task/Hailstone-sequence/Kotlin/hailstone-sequence-1.kts deleted file mode 100644 index 26c85fffea..0000000000 --- a/Task/Hailstone-sequence/Kotlin/hailstone-sequence-1.kts +++ /dev/null @@ -1,17 +0,0 @@ -fun hailstone(start: Int) = generateSequence(start) { n -> - when { - n == 1 -> null - n % 2 == 0 -> n / 2 - else -> n * 3 + 1 - } -} - -fun main() { - val hail27 = hailstone(27).toList() - println("The hailstone sequence for 27 has ${hail27.size} elements:\n$hail27") - - val (n, length) = (1..100000).asSequence() - .map { it to hailstone(it).count() } - .maxBy { it.second } - println("The number between 1 and 100000 with the longest hailstone sequence is $n, of length $length") -} diff --git a/Task/Hailstone-sequence/Kotlin/hailstone-sequence-2.kts b/Task/Hailstone-sequence/Kotlin/hailstone-sequence.kotlin similarity index 100% rename from Task/Hailstone-sequence/Kotlin/hailstone-sequence-2.kts rename to Task/Hailstone-sequence/Kotlin/hailstone-sequence.kotlin diff --git a/Task/Hailstone-sequence/M2000-Interpreter/hailstone-sequence.m2000 b/Task/Hailstone-sequence/M2000-Interpreter/hailstone-sequence.m2000 index 6cdcbfba59..36d886dcb9 100644 --- a/Task/Hailstone-sequence/M2000-Interpreter/hailstone-sequence.m2000 +++ b/Task/Hailstone-sequence/M2000-Interpreter/hailstone-sequence.m2000 @@ -7,7 +7,7 @@ Module hailstone.Task { n*=3 : n++: val=n } } - count=Lambda (n as long) ->{ + Count=Lambda (n) ->{ m=lambda n ->{ if n=1 then =false: exit =true :if n mod 2=0 then n/=2 :exit diff --git a/Task/Hailstone-sequence/MiniScript/hailstone-sequence-1.mini b/Task/Hailstone-sequence/MiniScript/hailstone-sequence-1.mini deleted file mode 100644 index dcfc96c687..0000000000 --- a/Task/Hailstone-sequence/MiniScript/hailstone-sequence-1.mini +++ /dev/null @@ -1,31 +0,0 @@ -getSequence = function(n) - results = [n] - while n > 1 - if n % 2 then - n = 3 * n + 1 - else - n = n / 2 - end if - results.push n - end while - return results -end function - -h = getSequence(27) -print "The hailstone sequence for 27 has 112 elements starting with" -print h[:4] -print "and ending with" -print h[-4:] - -maxSeqLen = 0 -maxSeqVal = 0 -for i in range(1,100000) - h = getSequence(i) - if h.len > maxSeqLen then - maxSeqLen = h.len - maxSeqVal = i - end if -end for -print -print "The number < 100,000 which has the longest hailstone sequence is " + maxSeqVal + "." -print "This sequence has " + maxSeqLen + " elements." diff --git a/Task/Hailstone-sequence/MiniScript/hailstone-sequence-2.mini b/Task/Hailstone-sequence/MiniScript/hailstone-sequence-2.mini deleted file mode 100644 index 14269d6451..0000000000 --- a/Task/Hailstone-sequence/MiniScript/hailstone-sequence-2.mini +++ /dev/null @@ -1,45 +0,0 @@ -cache = {} -calc = function(n) - if cache.hasIndex(n) then return - items = [n] - origNum = n - while n > 1 and not cache.hasIndex(n) - if n % 2 then - n = 3 * n + 1 - else - n = n /2 - end if - items.push n - end while - cache[origNum] = {"len": items.len,"items":items} -end function - -getLen = function(n) - if not cache.hasIndex(n) then calc n - if n == 1 then return 1 - return cache[n].len + getLen(cache[n].items[-1]) - 1 -end function - -getSequence = function(n) - if not cache.hasIndex(n) then calc n - if n == 1 then return [1] - return cache[n].items[:-1] + getSequence(cache[n].items[-1]) -end function - -h = getSequence(27) -print "The hailstone sequence for 27 has " + h.len + " elements starting with" -print h[:4] -print "and ending with" -print h[-4:] - -longSeq = 0 -longSeqVal =0 -for i in range(2, 100000) - seq = getLen(i) - if longSeq < seq then - longSeq = seq - longSeqVal = i - end if -end for -print "The number < 100,000 which has the longest hailstone sequence is " + longSeqVal + "." -print "This sequence has " + longSeq + " elements." diff --git a/Task/Hailstone-sequence/Miranda/hailstone-sequence.miranda b/Task/Hailstone-sequence/Miranda/hailstone-sequence.miranda deleted file mode 100644 index 9b7381cd1c..0000000000 --- a/Task/Hailstone-sequence/Miranda/hailstone-sequence.miranda +++ /dev/null @@ -1,22 +0,0 @@ -main :: [sys_message] -main = [Stdout h27m, Stdout biggestm] - where h27 = hailstone 27 - h27n = #h27 - h27f = take 4 h27 - h27l = drop (h27n - 4) h27 - h27m = "The hailstone sequence for 27 has " ++ - show h27n ++ " elements starting with " ++ - show h27f ++ " and ending with " ++ - show h27l ++ "\n" - - range = [1..100000] - biggest = max [#hailstone n | n<-range] - nbiggest = hd [n | n<-range; #hailstone n = biggest] - biggestm = "The number with the longest Hailstone " ++ - "sequence < 100.000 is " ++ show nbiggest ++ - " with length " ++ show biggest ++ "\n" - -hailstone :: num->[num] -hailstone = (++[1]) . takewhile (>1) . iterate step - where step n = (3 * n) + 1, if n mod 2 = 1 - = n div 2, otherwise diff --git a/Task/Hailstone-sequence/OCaml/hailstone-sequence.ml b/Task/Hailstone-sequence/OCaml/hailstone-sequence.ocaml similarity index 100% rename from Task/Hailstone-sequence/OCaml/hailstone-sequence.ml rename to Task/Hailstone-sequence/OCaml/hailstone-sequence.ocaml diff --git a/Task/Hailstone-sequence/Oberon/hailstone-sequence.oberon b/Task/Hailstone-sequence/Oberon-2/hailstone-sequence.oberon similarity index 100% rename from Task/Hailstone-sequence/Oberon/hailstone-sequence.oberon rename to Task/Hailstone-sequence/Oberon-2/hailstone-sequence.oberon diff --git a/Task/Hailstone-sequence/Odin/hailstone-sequence.odin b/Task/Hailstone-sequence/Odin/hailstone-sequence.odin deleted file mode 100644 index dbe6f83782..0000000000 --- a/Task/Hailstone-sequence/Odin/hailstone-sequence.odin +++ /dev/null @@ -1,65 +0,0 @@ -package main - -import "core:fmt" - -collatz :: proc(array:^[dynamic]int,n:int){ - i:=1 - n:=n - for n!=1{ - - if (n%2==0){ - n=n/2 - append(&array^,n) - } - else{ - n=3*n+1 - append(&array^,n) - } - - } -} - -main :: proc() { - n:=27 - - max:=0 - max_length:=0 - - dummy:[dynamic]int - defer delete(dummy) - append(&dummy,n) - collatz(&dummy,n) - - - fmt.println("the first four of sequence for 27: ") - for jj:=0;jj<4;jj+=1{ - fmt.println(dummy[jj]) - } - fmt.println("the last four of sequence for 27: ") - for jj:=0;jj<4;jj+=1{ - fmt.println(dummy[len(dummy)-4+jj]) - } - fmt.println("length of sequence for 27") - fmt.println(len(dummy)) - - - for (len(dummy)>0){ - pop(&dummy) - } - - for ii:=1;ii<100000;ii+=1{ - append(&dummy,ii) - collatz(&dummy,ii) - if(len(dummy)>max_length){ - max = ii - max_length=len(dummy) - } - for (len(dummy)>0){ - pop(&dummy) - } - } - fmt.println("Max number: ") - fmt.println(max) - fmt.println("Max length: ") - fmt.println(max_length) -} diff --git a/Task/Hailstone-sequence/Onyx-(wasm)/hailstone-sequence.onyx b/Task/Hailstone-sequence/Onyx-(wasm)/hailstone-sequence.onyx deleted file mode 100644 index db662f03ce..0000000000 --- a/Task/Hailstone-sequence/Onyx-(wasm)/hailstone-sequence.onyx +++ /dev/null @@ -1,61 +0,0 @@ -use core { * } - -hailstone :: (n: u32) -> [..]u32 { - seq: [..]u32; - array.push(&seq, n); - while n > 1 { - n = n/2 if n%2 == 0 else (n*3)+1; - array.push(&seq, n); - } - return seq; -} - -Longest :: struct { num, len : u32; } - -main :: () { - - // ------- - // task 1: - // ------- - // "Create a routine to generate the hailstone - // sequence for a number." - - i := 27; - seq := hailstone(i); - printf("Task 1:\n{}: {}\n\n", - i, - seq - ); - - // ------- - // task 2: - // ------- - // "Use the routine to show that the hailstone - // sequence for the number 27 has - // 112 elements starting with - // 27, 82, 41, 124 and ending with 8, 4, 2, 1" - - slice_size := 4; - len := seq.length; - slice_first := seq[0..slice_size]; - slice_last := seq[seq.length-slice_size..seq.length]; - printf("Task 2:\nlength: {}, first: {}, last: {}\n\n", - len, - slice_first, - slice_last - ); - - // ------- - // task 3: - // ------- - // "Show the number less than 100,000 - // which has the longest hailstone sequence - // together with that sequences length." - - l : Longest; - for i in 1..100000 { - seq := hailstone(i); - if l.len < seq.length { l = .{num = i, len = seq.length}; } - } - printf("Task 3:\nLongest Num: {}, Sequence Length: {}\n", l.num, l.len); -} diff --git a/Task/Hailstone-sequence/PascalABC.NET/hailstone-sequence.pas b/Task/Hailstone-sequence/PascalABC.NET/hailstone-sequence.pas deleted file mode 100644 index d19f3dd6db..0000000000 --- a/Task/Hailstone-sequence/PascalABC.NET/hailstone-sequence.pas +++ /dev/null @@ -1,23 +0,0 @@ -function hailstone(n: Integer): sequence of integer; -begin - result := seq(n); - while n > 1 do - begin - n := n.IsEven ? n div 2 : 3 * n + 1; - result := result + seq(n); - end; -end; - -begin - var a := hailstone(27); - println(a.Count, a.Take(4), a.TakeLast(4)); - var max := 0; - var maxi := 0; - for var i := 1 to 100_000 do - if hailstone(i).Count > max then - begin - max := hailstone(i).Count; - maxi := i; - end; - println(maxi, max); -end. diff --git a/Task/Hailstone-sequence/Pluto/hailstone-sequence.pluto b/Task/Hailstone-sequence/Pluto/hailstone-sequence.pluto deleted file mode 100644 index 0e55f4d7b9..0000000000 --- a/Task/Hailstone-sequence/Pluto/hailstone-sequence.pluto +++ /dev/null @@ -1,26 +0,0 @@ -function hailstone(n, p=true) - local len = 1 - - while n > 1 do - ++len - if p do io.write(n,'\t') end - n = (n%2==0)?n//2:3*n+1 - end - - if p do print(1) end - return len -end - -hailstone(27) -print("------") - -local max = 1 -local len = 1 -for i = 2,99999 do - local t = hailstone(i,false) - if t > len then - max = i - len = t - end -end -print(max, len) diff --git a/Task/Hailstone-sequence/PowerShell/hailstone-sequence.ps1 b/Task/Hailstone-sequence/PowerShell/hailstone-sequence.psh similarity index 100% rename from Task/Hailstone-sequence/PowerShell/hailstone-sequence.ps1 rename to Task/Hailstone-sequence/PowerShell/hailstone-sequence.psh diff --git a/Task/Hailstone-sequence/Rebol/hailstone-sequence.rebol b/Task/Hailstone-sequence/REBOL/hailstone-sequence.rebol similarity index 100% rename from Task/Hailstone-sequence/Rebol/hailstone-sequence.rebol rename to Task/Hailstone-sequence/REBOL/hailstone-sequence.rebol diff --git a/Task/Hailstone-sequence/Refal/hailstone-sequence.refal b/Task/Hailstone-sequence/Refal/hailstone-sequence.refal deleted file mode 100644 index b8c16a96d3..0000000000 --- a/Task/Hailstone-sequence/Refal/hailstone-sequence.refal +++ /dev/null @@ -1,42 +0,0 @@ -$ENTRY Go { - = - ; -} - -Hailstone { - 1 = 1; - s.N, : { - 0 = s.N >; - 1 = s.N >>; - }; -}; - -ShowHailstone { - s.N, : e.Seq, - : s.Len s.1 s.2 s.3 s.4 e.X s.D4 s.D3 s.D2 s.D1 - = ' has ' ' elements,\n' - 'starting with ' s.1 s.2 s.3 s.4 - 'and ending with ' s.D4 s.D3 s.D2 '.'>; -} - -FindLongest { - s.Max = ; - s.Max s.Max s.Long s.Len = s.Long s.Len; - s.Max s.Cur s.Long s.Len, - : e.CurSeq, - : s.CurLen e.X, - <+ s.Cur 1>: s.Next, - : { - '+' = ; - s.X = ; - }; -}; - -ShowLongest { - s.Max, : s.Long s.Len - = ' which has the longest' - ' hailstone sequence is ' '.\n' - 'The length of its Hailstone sequence is ' - '.'>; -}; diff --git a/Task/Hailstone-sequence/Rust/hailstone-sequence.rs b/Task/Hailstone-sequence/Rust/hailstone-sequence.rust similarity index 100% rename from Task/Hailstone-sequence/Rust/hailstone-sequence.rs rename to Task/Hailstone-sequence/Rust/hailstone-sequence.rust diff --git a/Task/Hailstone-sequence/SETL/hailstone-sequence.setl b/Task/Hailstone-sequence/SETL/hailstone-sequence.setl deleted file mode 100644 index b0f14b69df..0000000000 --- a/Task/Hailstone-sequence/SETL/hailstone-sequence.setl +++ /dev/null @@ -1,24 +0,0 @@ -program hailstone_sequence; - hail27 := hailstone(27); - print("The hailstone sequence for the number 27 has", #hail27, "elements,"); - print("starting with", hail27(..4), "and ending with", hail27(#hail27-3..)); - - sizes := [#hailstone(n) : n in [1..99999]]; - maxsize := max/sizes; - maxelem := [n : n in [1..#sizes] | sizes(n) = maxsize](1); - - print("The number < 100,000 with the longest hailstone sequence is",maxelem); - print("The length of its sequence is",sizes(maxelem)); - - proc hailstone(n); - seq := []; - loop doing seq with:= n; while n/=1 do - if even n then - n div:= 2; - else - n := 3*n + 1; - end if; - end loop; - return seq; - end proc; -end program; diff --git a/Task/Hailstone-sequence/Scheme/hailstone-sequence.scm b/Task/Hailstone-sequence/Scheme/hailstone-sequence.scm deleted file mode 100644 index 5219a0c4e9..0000000000 --- a/Task/Hailstone-sequence/Scheme/hailstone-sequence.scm +++ /dev/null @@ -1,36 +0,0 @@ -(define (collatz n) - (if (= n 1) - (list 1) - (cons n - (collatz (if (even? n) (/ n 2) (+ 1 (* 3 n))))))) - -(define (collatz-length n) - (let aux ((n n) (r 1)) - (if (= n 1) - r - (aux (if (even? n) (/ n 2) (+ 1 (* 3 n))) - (+ r 1))))) - -(define (collatz-max a b) - (let aux ((i a) (j 0) (k 0)) - (if (> i b) - (list j k) - (let ((h (collatz-length i))) - (if (> h k) - (aux (+ i 1) i h) - (aux (+ i 1) j k)))))) - -(collatz 27) -; (27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 -; 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 -; 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 -; 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 -; 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 -; 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 -; 106 53 160 80 40 20 10 5 16 8 4 2 1) - -(collatz-length 27) -; 112 - -(collatz-max 1 100000) -; (77031 351) diff --git a/Task/Hailstone-sequence/Scheme/hailstone-sequence.ss b/Task/Hailstone-sequence/Scheme/hailstone-sequence.ss new file mode 100644 index 0000000000..b0311a38ee --- /dev/null +++ b/Task/Hailstone-sequence/Scheme/hailstone-sequence.ss @@ -0,0 +1,28 @@ +(define (collatz n) +(if (= n 1) '(1) +(cons n (collatz (if (even? n) (/ n 2) (+ 1 (* 3 n))))))) + +(define (collatz-length n) +(let aux ((n n) (r 1)) (if (= n 1) r +(aux (if (even? n) (/ n 2) (+ 1 (* 3 n))) (+ r 1))))) + +(define (collatz-max a b) +(let aux ((i a) (j 0) (k 0)) +(if (> i b) (list j k) +(let ((h (collatz-length i))) +(if (> h k) (aux (+ i 1) i h) (aux (+ i 1) j k)))))) + +(collatz 27) +; (27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 +; 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 +; 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 +; 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 +; 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 +; 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 +; 106 53 160 80 40 20 10 5 16 8 4 2 1) + +(collatz-length 27) +; 112 + +(collatz-max 1 100000) +; (77031 351) diff --git a/Task/Hailstone-sequence/Uiua/hailstone-sequence.uiua b/Task/Hailstone-sequence/Uiua/hailstone-sequence.uiua deleted file mode 100644 index 81cdf542a0..0000000000 --- a/Task/Hailstone-sequence/Uiua/hailstone-sequence.uiua +++ /dev/null @@ -1,7 +0,0 @@ -Next ← ⨬(÷2|+1×3)⊸◿2 -Sequence ← ˜⊂1⊢[⍢⊸Next≠₁] - -⊃(↙4|↙¯4) Sequence 27 -# Calculate and cache lengths (export UIUA_RECURSION_LIMIT=3000 first) -Length ← |1 memo(⨬(+1Length Next|∘)⊸=₁) -⊸Length⊢⊏⍖⊸⍚Length+1⇡99999 diff --git a/Task/Hailstone-sequence/Ursalang/hailstone-sequence.ursa b/Task/Hailstone-sequence/Ursalang/hailstone-sequence.ursa deleted file mode 100644 index ecc665c418..0000000000 --- a/Task/Hailstone-sequence/Ursalang/hailstone-sequence.ursa +++ /dev/null @@ -1,33 +0,0 @@ -let hailstone = fn(n_) { - var n = n_ - let steps = [n] - loop { - if n < 2 { break steps } - n := (if n % 2 == 0 { n / 2 } else { n * 3 + 1 }) - steps.push(n) - } -} - -let twentySeven = hailstone(27) -print("The Hailstone sequence for 27 starts with:") -print(twentySeven.slice(0, 4)) -print("and ends with:") -print(twentySeven.slice(-4)) -print("and its length is:") -print(twentySeven.len()) - -print("Checking sequences up to 100,000") -var longest = 0 -var longestLen = 0 -for i in range(100000) { - let len = hailstone(i).len() - if len > longestLen { - longest := i - longestLen := len - } - if i % 10000 == 0 {print(i)} -} -print("The longest sequence under 100,000 is for:") -print(longest) -print("and has length:") -print(longestLen) diff --git a/Task/Hailstone-sequence/V-(Vlang)/hailstone-sequence.v b/Task/Hailstone-sequence/V-(Vlang)/hailstone-sequence.v index 2f1d091903..665f9dc8b1 100644 --- a/Task/Hailstone-sequence/V-(Vlang)/hailstone-sequence.v +++ b/Task/Hailstone-sequence/V-(Vlang)/hailstone-sequence.v @@ -2,7 +2,7 @@ // 2nd arg is a slice to recycle, to reduce garbage. fn hs(nn int, recycle []int) []int { mut n := nn - mut s := recycle[..0].clone() + mut s := recycle[..0] s << n for n > 1 { if n&1 == 0 { diff --git a/Task/Hailstone-sequence/VBScript/hailstone-sequence.vbs b/Task/Hailstone-sequence/VBScript/hailstone-sequence.vb similarity index 100% rename from Task/Hailstone-sequence/VBScript/hailstone-sequence.vbs rename to Task/Hailstone-sequence/VBScript/hailstone-sequence.vb diff --git a/Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire-2.8086 b/Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire-2.8086 deleted file mode 100644 index fe4a93e86e..0000000000 --- a/Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire-2.8086 +++ /dev/null @@ -1 +0,0 @@ -jmp $ diff --git a/Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire-1.8086 b/Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire.8086 similarity index 100% rename from Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire-1.8086 rename to Task/Halt-and-catch-fire/8086-Assembly/halt-and-catch-fire.8086 diff --git a/Task/Halt-and-catch-fire/AArch64-Assembly/halt-and-catch-fire.aarch64 b/Task/Halt-and-catch-fire/AArch64-Assembly/halt-and-catch-fire.aarch64 deleted file mode 100644 index b35e4e4e7f..0000000000 --- a/Task/Halt-and-catch-fire/AArch64-Assembly/halt-and-catch-fire.aarch64 +++ /dev/null @@ -1,50 +0,0 @@ -/* ARM assembly AARCH64 Raspberry PI 3B */ -/* program craharm64.s */ - -/*******************************************/ -/* Constantes */ -/*******************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeConstantesARM64.inc" - -/*******************************************/ -/* Macros */ -/*******************************************/ -//.include "../../ficmacros64.inc" // for developer debugging - -/*********************************/ -/* Initialized data */ -/*********************************/ -.data -szMessDebutPgm: .asciz "Program 64 bits start. \n" -szMessFinOK: .asciz "Program normal end. \n" - -/*********************************/ -/* UnInitialized data */ -/*********************************/ -.bss -/*********************************/ -/* code section */ -/*********************************/ -.text -.global main -main: - ldr x0,qAdrszMessDebutPgm - bl affichageMess // start message - mov x0,#0 - ldr x1,[x0] // load value at address zero - - - ldr x0,qAdrszMessFinOK - bl affichageMess - - mov x8,EXIT - svc #0 // system call -qAdrszMessDebutPgm: .quad szMessDebutPgm -qAdrszMessFinOK: .quad szMessFinOK - -/***************************************************/ -/* ROUTINES INCLUDE */ -/***************************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeARM64.inc" diff --git a/Task/Halt-and-catch-fire/ARM-Assembly/halt-and-catch-fire.arm b/Task/Halt-and-catch-fire/ARM-Assembly/halt-and-catch-fire.arm deleted file mode 100644 index b2d0b3b307..0000000000 --- a/Task/Halt-and-catch-fire/ARM-Assembly/halt-and-catch-fire.arm +++ /dev/null @@ -1,55 +0,0 @@ -/* ARM assembly Raspberry PI */ -/* program craharm.s */ - -/* REMARK 1 : this program use routines in a include file - see task Include a file language arm assembly - for the routine affichageMess conversion10 - see at end of this program the instruction include */ - -/*******************************************/ -/* Constantes */ -/*******************************************/ -.include "../constantes.inc" - -/*******************************************/ -/* Macros */ -/*******************************************/ -//.include "../../ficmacros32.inc" @ for developer debugging - -/*********************************/ -/* Initialized data */ -/*********************************/ -.data -szMessDebutPgm: .asciz "Program 32 bits start. \n" -szMessFinOK: .asciz "Program normal end. \n" - - -/*********************************/ -/* UnInitialized data */ -/*********************************/ -.bss -/*********************************/ -/* code section */ -/*********************************/ -.text -.global main -main: - ldr r0,iAdrszMessDebutPgm - bl affichageMess @ start message - mov r0,#0 - ldr r1,[r0] @ load value at address zero - - - ldr r0,iAdrszMessFinOK - bl affichageMess - - mov r7,#EXIT @ program end - svc #0 @ system call -iAdrszMessDebutPgm: .int szMessDebutPgm -iAdrszMessFinOK: .int szMessFinOK - - -/***************************************************/ -/* ROUTINES INCLUDE */ -/***************************************************/ -.include "../affichage.inc" diff --git a/Task/Halt-and-catch-fire/Ada/halt-and-catch-fire.adb b/Task/Halt-and-catch-fire/Ada/halt-and-catch-fire.ada similarity index 100% rename from Task/Halt-and-catch-fire/Ada/halt-and-catch-fire.adb rename to Task/Halt-and-catch-fire/Ada/halt-and-catch-fire.ada diff --git a/Task/Halt-and-catch-fire/Bruijn/halt-and-catch-fire.bruijn b/Task/Halt-and-catch-fire/Bruijn/halt-and-catch-fire.bruijn deleted file mode 100644 index e053451775..0000000000 --- a/Task/Halt-and-catch-fire/Bruijn/halt-and-catch-fire.bruijn +++ /dev/null @@ -1,3 +0,0 @@ -:test ([[0]]) ([[1]]) - -main [[0 0] [0 0]] diff --git a/Task/Halt-and-catch-fire/Crystal/halt-and-catch-fire.cr b/Task/Halt-and-catch-fire/Crystal/halt-and-catch-fire.crystal similarity index 100% rename from Task/Halt-and-catch-fire/Crystal/halt-and-catch-fire.cr rename to Task/Halt-and-catch-fire/Crystal/halt-and-catch-fire.crystal diff --git a/Task/Halt-and-catch-fire/Delphi/halt-and-catch-fire.pas b/Task/Halt-and-catch-fire/Delphi/halt-and-catch-fire.delphi similarity index 100% rename from Task/Halt-and-catch-fire/Delphi/halt-and-catch-fire.pas rename to Task/Halt-and-catch-fire/Delphi/halt-and-catch-fire.delphi diff --git a/Task/Halt-and-catch-fire/EMal/halt-and-catch-fire.emal b/Task/Halt-and-catch-fire/EMal/halt-and-catch-fire.emal deleted file mode 100644 index 681461a281..0000000000 --- a/Task/Halt-and-catch-fire/EMal/halt-and-catch-fire.emal +++ /dev/null @@ -1 +0,0 @@ -error(256, "Internal Corruption") diff --git a/Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy b/Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy deleted file mode 100644 index cb387a3101..0000000000 --- a/Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy +++ /dev/null @@ -1,2 +0,0 @@ -a[] = [ ] -print a[1] diff --git a/Task/Halt-and-catch-fire/FutureBasic/halt-and-catch-fire.basic b/Task/Halt-and-catch-fire/FutureBasic/halt-and-catch-fire.basic deleted file mode 100644 index 858825d80b..0000000000 --- a/Task/Halt-and-catch-fire/FutureBasic/halt-and-catch-fire.basic +++ /dev/null @@ -1 +0,0 @@ -~ 0,0 diff --git a/Task/Halt-and-catch-fire/Icon/halt-and-catch-fire.icon b/Task/Halt-and-catch-fire/Icon/halt-and-catch-fire.icon deleted file mode 100644 index a90590d6f8..0000000000 --- a/Task/Halt-and-catch-fire/Icon/halt-and-catch-fire.icon +++ /dev/null @@ -1,3 +0,0 @@ -procedure main() - 5/0 -end diff --git a/Task/Halt-and-catch-fire/Java/halt-and-catch-fire.java b/Task/Halt-and-catch-fire/Java/halt-and-catch-fire.java deleted file mode 100644 index 436cffff07..0000000000 --- a/Task/Halt-and-catch-fire/Java/halt-and-catch-fire.java +++ /dev/null @@ -1,11 +0,0 @@ -public final class HaltAndCatchFire { - - public static void main(String[] aArgs) { - // Any one of the lines below, when uncommented, will cause a program halt. - -// throw new AssertionError("Stop now!"); -// System.out.println(0/0); -// Runtime.getRuntime().exit(1); - } - -} diff --git a/Task/Halt-and-catch-fire/JavaScript/halt-and-catch-fire.js b/Task/Halt-and-catch-fire/JavaScript/halt-and-catch-fire.js deleted file mode 100644 index c3ab4d8f76..0000000000 --- a/Task/Halt-and-catch-fire/JavaScript/halt-and-catch-fire.js +++ /dev/null @@ -1,3 +0,0 @@ -f=()=>f();f(); -/* This also does the same thing, but is harder to read */ -(f=()=>f())(); diff --git a/Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-1.jl b/Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-1.julia similarity index 100% rename from Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-1.jl rename to Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-1.julia diff --git a/Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-2.jl b/Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-2.julia similarity index 100% rename from Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-2.jl rename to Task/Halt-and-catch-fire/Julia/halt-and-catch-fire-2.julia diff --git a/Task/Halt-and-catch-fire/Microsoft-Small-Basic/halt-and-catch-fire.basic b/Task/Halt-and-catch-fire/Microsoft-Small-Basic/halt-and-catch-fire.basic deleted file mode 100644 index 22d7fa590a..0000000000 --- a/Task/Halt-and-catch-fire/Microsoft-Small-Basic/halt-and-catch-fire.basic +++ /dev/null @@ -1 +0,0 @@ -a = 0 / 0 diff --git a/Task/Halt-and-catch-fire/PascalABC.NET/halt-and-catch-fire.pas b/Task/Halt-and-catch-fire/PascalABC.NET/halt-and-catch-fire.pas deleted file mode 100644 index ac79a4cfa2..0000000000 --- a/Task/Halt-and-catch-fire/PascalABC.NET/halt-and-catch-fire.pas +++ /dev/null @@ -1 +0,0 @@ -## raise new Exception(''); diff --git a/Task/Halt-and-catch-fire/Pluto/halt-and-catch-fire.pluto b/Task/Halt-and-catch-fire/Pluto/halt-and-catch-fire.pluto deleted file mode 100644 index 13a2c75adb..0000000000 --- a/Task/Halt-and-catch-fire/Pluto/halt-and-catch-fire.pluto +++ /dev/null @@ -1 +0,0 @@ -print(0 // 0) diff --git a/Task/Halt-and-catch-fire/R/halt-and-catch-fire-1.r b/Task/Halt-and-catch-fire/R/halt-and-catch-fire-1.r deleted file mode 100644 index 39a97b302c..0000000000 --- a/Task/Halt-and-catch-fire/R/halt-and-catch-fire-1.r +++ /dev/null @@ -1 +0,0 @@ -stop() diff --git a/Task/Halt-and-catch-fire/R/halt-and-catch-fire-2.r b/Task/Halt-and-catch-fire/R/halt-and-catch-fire-2.r deleted file mode 100644 index 1e5b3ea0c8..0000000000 --- a/Task/Halt-and-catch-fire/R/halt-and-catch-fire-2.r +++ /dev/null @@ -1 +0,0 @@ -array()[,] diff --git a/Task/Halt-and-catch-fire/Rebol/halt-and-catch-fire.rebol b/Task/Halt-and-catch-fire/Rebol/halt-and-catch-fire.rebol deleted file mode 100644 index 2350d4fe2a..0000000000 --- a/Task/Halt-and-catch-fire/Rebol/halt-and-catch-fire.rebol +++ /dev/null @@ -1,5 +0,0 @@ -halt ;; Stops evaluation and returns to the input prompt. - ;; or -quit ;; Stops evaluation and exits the interpreter. - ;; or -quit/return 1 ;; with some status code diff --git a/Task/Halt-and-catch-fire/Rust/halt-and-catch-fire.rs b/Task/Halt-and-catch-fire/Rust/halt-and-catch-fire.rust similarity index 100% rename from Task/Halt-and-catch-fire/Rust/halt-and-catch-fire.rs rename to Task/Halt-and-catch-fire/Rust/halt-and-catch-fire.rust diff --git a/Task/Halt-and-catch-fire/TAV/halt-and-catch-fire.tav b/Task/Halt-and-catch-fire/TAV/halt-and-catch-fire.tav deleted file mode 100644 index beb3a1a07a..0000000000 --- a/Task/Halt-and-catch-fire/TAV/halt-and-catch-fire.tav +++ /dev/null @@ -1 +0,0 @@ -! ?- diff --git a/Task/Halt-and-catch-fire/Uiua/halt-and-catch-fire.uiua b/Task/Halt-and-catch-fire/Uiua/halt-and-catch-fire.uiua deleted file mode 100644 index 414ff2f8ec..0000000000 --- a/Task/Halt-and-catch-fire/Uiua/halt-and-catch-fire.uiua +++ /dev/null @@ -1 +0,0 @@ -⍤@a 0 diff --git a/Task/Halt-and-catch-fire/Zig/halt-and-catch-fire.zig b/Task/Halt-and-catch-fire/Zig/halt-and-catch-fire.zig deleted file mode 100644 index d8b5049869..0000000000 --- a/Task/Halt-and-catch-fire/Zig/halt-and-catch-fire.zig +++ /dev/null @@ -1,3 +0,0 @@ -pub fn main() void { - unreachable; -} diff --git a/Task/Hamming-numbers/Ada/hamming-numbers.adb b/Task/Hamming-numbers/Ada/hamming-numbers.ada similarity index 100% rename from Task/Hamming-numbers/Ada/hamming-numbers.adb rename to Task/Hamming-numbers/Ada/hamming-numbers.ada diff --git a/Task/Hamming-numbers/Bruijn/hamming-numbers.bruijn b/Task/Hamming-numbers/Bruijn/hamming-numbers.bruijn deleted file mode 100644 index 426223d327..0000000000 --- a/Task/Hamming-numbers/Bruijn/hamming-numbers.bruijn +++ /dev/null @@ -1,28 +0,0 @@ -:import std/Combinator . -:import std/Number . -:import std/List . - -merge y [[[∅?1 0 (1 [[2 [[go]]]])]]] - go 3 ((+1) : 0))]]] - -:test ((hammings-classic !! (+42)) =? (+162)) ([[1]]) - -# enumeration by a chain of folded merges (faster) -hammings-folded ([(0 ∘ a) ∘ (0 ∘ b)] (foldr merge1 empty)) $ c - merge1 [[1 [[1 : (merge 0 2)]]]] - a iterate (map (mul (+5))) - b iterate (map (mul (+3))) - c iterate (mul (+2)) (+1) - -:test ((hammings-folded !! (+42)) =? (+162)) ([[1]]) - -# --- output --- - -main [first-twenty : (n1691 : {}n1000000)] - first-twenty take (+20) hammings-folded - n1691 hammings-folded !! (+1690) - n1000000 hammings-folded !! (+999999) diff --git a/Task/Hamming-numbers/Chapel/hamming-numbers-1.chpl b/Task/Hamming-numbers/Chapel/hamming-numbers-1.chapel similarity index 100% rename from Task/Hamming-numbers/Chapel/hamming-numbers-1.chpl rename to Task/Hamming-numbers/Chapel/hamming-numbers-1.chapel diff --git a/Task/Hamming-numbers/Chapel/hamming-numbers-2.chpl b/Task/Hamming-numbers/Chapel/hamming-numbers-2.chapel similarity index 100% rename from Task/Hamming-numbers/Chapel/hamming-numbers-2.chpl rename to Task/Hamming-numbers/Chapel/hamming-numbers-2.chapel diff --git a/Task/Hamming-numbers/Chapel/hamming-numbers-3.chpl b/Task/Hamming-numbers/Chapel/hamming-numbers-3.chapel similarity index 100% rename from Task/Hamming-numbers/Chapel/hamming-numbers-3.chpl rename to Task/Hamming-numbers/Chapel/hamming-numbers-3.chapel diff --git a/Task/Hamming-numbers/Chapel/hamming-numbers-4.chpl b/Task/Hamming-numbers/Chapel/hamming-numbers-4.chapel similarity index 100% rename from Task/Hamming-numbers/Chapel/hamming-numbers-4.chpl rename to Task/Hamming-numbers/Chapel/hamming-numbers-4.chapel diff --git a/Task/Hamming-numbers/Chapel/hamming-numbers-5.chpl b/Task/Hamming-numbers/Chapel/hamming-numbers-5.chapel similarity index 100% rename from Task/Hamming-numbers/Chapel/hamming-numbers-5.chpl rename to Task/Hamming-numbers/Chapel/hamming-numbers-5.chapel diff --git a/Task/Hamming-numbers/Crystal/hamming-numbers-1.cr b/Task/Hamming-numbers/Crystal/hamming-numbers-1.crystal similarity index 100% rename from Task/Hamming-numbers/Crystal/hamming-numbers-1.cr rename to Task/Hamming-numbers/Crystal/hamming-numbers-1.crystal diff --git a/Task/Hamming-numbers/Crystal/hamming-numbers-2.cr b/Task/Hamming-numbers/Crystal/hamming-numbers-2.crystal similarity index 100% rename from Task/Hamming-numbers/Crystal/hamming-numbers-2.cr rename to Task/Hamming-numbers/Crystal/hamming-numbers-2.crystal diff --git a/Task/Hamming-numbers/Crystal/hamming-numbers-3.cr b/Task/Hamming-numbers/Crystal/hamming-numbers-3.crystal similarity index 100% rename from Task/Hamming-numbers/Crystal/hamming-numbers-3.cr rename to Task/Hamming-numbers/Crystal/hamming-numbers-3.crystal diff --git a/Task/Hamming-numbers/Crystal/hamming-numbers-4.cr b/Task/Hamming-numbers/Crystal/hamming-numbers-4.crystal similarity index 100% rename from Task/Hamming-numbers/Crystal/hamming-numbers-4.cr rename to Task/Hamming-numbers/Crystal/hamming-numbers-4.crystal diff --git a/Task/Hamming-numbers/EasyLang/hamming-numbers.easy b/Task/Hamming-numbers/EasyLang/hamming-numbers.easy deleted file mode 100644 index 5f54b97603..0000000000 --- a/Task/Hamming-numbers/EasyLang/hamming-numbers.easy +++ /dev/null @@ -1,27 +0,0 @@ -func hamming lim . - len h[] lim - h[1] = 1 - x2 = 2 ; x3 = 3 ; x5 = 5 - i = 1 ; j = 1 ; k = 1 - for n = 2 to lim - h[n] = lower x2 lower x3 x5 - if x2 = h[n] - i += 1 - x2 = 2 * h[i] - . - if x3 = h[n] - j += 1 - x3 = 3 * h[j] - . - if x5 = h[n] - k += 1 - x5 = 5 * h[k] - . - . - return h[lim] -. -for nr = 1 to 20 - write hamming nr & " " -. -print "" -print hamming 1691 diff --git a/Task/Hamming-numbers/Elixir/hamming-numbers.ex b/Task/Hamming-numbers/Elixir/hamming-numbers.elixir similarity index 100% rename from Task/Hamming-numbers/Elixir/hamming-numbers.ex rename to Task/Hamming-numbers/Elixir/hamming-numbers.elixir diff --git a/Task/Hamming-numbers/FutureBasic/hamming-numbers.basic b/Task/Hamming-numbers/FutureBasic/hamming-numbers.basic deleted file mode 100644 index 96bab3ac63..0000000000 --- a/Task/Hamming-numbers/FutureBasic/hamming-numbers.basic +++ /dev/null @@ -1,42 +0,0 @@ -include "NSLog.incl" - -NSUInteger local fn Minimum( a as NSUInteger, b as NSUInteger ) - return (a < b) ? a : b -end fn = 0 - -UInt64 local fn HammingNumberAtPosition( position as NSUInteger ) - if (position == 0) then return 0 - CFMutableArrayRef hammingNumbers = fn MutableArrayWithCapacity( position ) - MutableArrayAddObject( hammingNumbers, @1 ) - - NSUInteger i2 = 0, i3 = 0, i5 = 0 - for NSUInteger i = 1 to position - 1 - NSUInteger nxt2 = fn NumberUnsignedLongLongValue( hammingNumbers[i2] ) * 2 - NSUInteger nxt3 = fn NumberUnsignedLongLongValue( hammingNumbers[i3] ) * 3 - NSUInteger nxt5 = fn NumberUnsignedLongLongValue( hammingNumbers[i5] ) * 5 - NSUInteger nxt = fn Minimum( nxt2, fn Minimum( nxt3, nxt5 ) ) - - NSUInteger nextHamming = fn Minimum( nxt2, fn Minimum( nxt3, nxt5 ) ) - MutableArrayAddObject( hammingNumbers, @(nextHamming) ) - - if (nxt == nxt2) then i2++ - if (nxt == nxt3) then i3++ - if (nxt == nxt5) then i5++ - next - - return fn NumberUnsignedLongLongValue( hammingNumbers[position - 1] ) -end fn = 0 - -local fn RunHammingNumberTests - CFMutableArrayRef mutArr = fn MutableArrayNew - - for NSUInteger i = 1 to 20 - MutableArrayAddObject( mutArr, @(fn HammingNumberAtPosition(i)) ) - next - NSLog( @"First 20 Hamming Numbers: %@", fn ArrayComponentsJoinedByString( mutArr, @" " ) ) - NSLog( @" 1691st Hamming Number: %llu", fn HammingNumberAtPosition( 1691 ) ) -end fn - -fn RunHammingNumberTests - -HandleEvents diff --git a/Task/Hamming-numbers/Julia/hamming-numbers-1.jl b/Task/Hamming-numbers/Julia/hamming-numbers-1.julia similarity index 100% rename from Task/Hamming-numbers/Julia/hamming-numbers-1.jl rename to Task/Hamming-numbers/Julia/hamming-numbers-1.julia diff --git a/Task/Hamming-numbers/Julia/hamming-numbers-2.jl b/Task/Hamming-numbers/Julia/hamming-numbers-2.julia similarity index 100% rename from Task/Hamming-numbers/Julia/hamming-numbers-2.jl rename to Task/Hamming-numbers/Julia/hamming-numbers-2.julia diff --git a/Task/Hamming-numbers/Julia/hamming-numbers-3.jl b/Task/Hamming-numbers/Julia/hamming-numbers-3.julia similarity index 100% rename from Task/Hamming-numbers/Julia/hamming-numbers-3.jl rename to Task/Hamming-numbers/Julia/hamming-numbers-3.julia diff --git a/Task/Hamming-numbers/Julia/hamming-numbers-4.jl b/Task/Hamming-numbers/Julia/hamming-numbers-4.julia similarity index 100% rename from Task/Hamming-numbers/Julia/hamming-numbers-4.jl rename to Task/Hamming-numbers/Julia/hamming-numbers-4.julia diff --git a/Task/Hamming-numbers/Julia/hamming-numbers-5.jl b/Task/Hamming-numbers/Julia/hamming-numbers-5.julia similarity index 100% rename from Task/Hamming-numbers/Julia/hamming-numbers-5.jl rename to Task/Hamming-numbers/Julia/hamming-numbers-5.julia diff --git a/Task/Hamming-numbers/Kotlin/hamming-numbers-1.kts b/Task/Hamming-numbers/Kotlin/hamming-numbers-1.kotlin similarity index 100% rename from Task/Hamming-numbers/Kotlin/hamming-numbers-1.kts rename to Task/Hamming-numbers/Kotlin/hamming-numbers-1.kotlin diff --git a/Task/Hamming-numbers/Kotlin/hamming-numbers-2.kts b/Task/Hamming-numbers/Kotlin/hamming-numbers-2.kotlin similarity index 100% rename from Task/Hamming-numbers/Kotlin/hamming-numbers-2.kts rename to Task/Hamming-numbers/Kotlin/hamming-numbers-2.kotlin diff --git a/Task/Hamming-numbers/Kotlin/hamming-numbers-3.kts b/Task/Hamming-numbers/Kotlin/hamming-numbers-3.kotlin similarity index 100% rename from Task/Hamming-numbers/Kotlin/hamming-numbers-3.kts rename to Task/Hamming-numbers/Kotlin/hamming-numbers-3.kotlin diff --git a/Task/Hamming-numbers/Kotlin/hamming-numbers-4.kts b/Task/Hamming-numbers/Kotlin/hamming-numbers-4.kotlin similarity index 100% rename from Task/Hamming-numbers/Kotlin/hamming-numbers-4.kts rename to Task/Hamming-numbers/Kotlin/hamming-numbers-4.kotlin diff --git a/Task/Hamming-numbers/Mojo/hamming-numbers.mojo b/Task/Hamming-numbers/Mojo/hamming-numbers.mojo deleted file mode 100644 index 1d093d1922..0000000000 --- a/Task/Hamming-numbers/Mojo/hamming-numbers.mojo +++ /dev/null @@ -1,187 +0,0 @@ -# HammingsLogImp.mojo - uses queue instead of frequent draining... -# compile with: mojo build --march=native Hammings.mojo - -# import bigints, std/math # no big ints -from math import (log2, trunc) -from memory import (memset_zero) #, memcpy) -from time import (monotonic) - -alias cCOUNT: Int = 1_000_000 - -struct BigNat(Movable, ImplicitlyCopyable, Stringable): # enough just to support conversion and printing - ''' Enough "infinite" precision to support as required here - multiply and - divide by 10 conversion to string... - ''' - var contents: List[UInt32] - fn __init__(out self): - self.contents = List[UInt32]() - fn __init__(out self, val: UInt32): - self.contents = List[UInt32](length=1, fill=val) - fn __copyinit__(out self, existing: Self): - self.contents = List[UInt32](existing.contents) - fn __str__(self) -> String: - var rslt: String = "" - var v = List[UInt32](self.contents) - while len(v) > 0: - var t: UInt64 = 0 - for i in range(len(v) - 1, -1, -1): - t = (t << 32) + Int(v[i]) - v[i] = Int(t // 10); t -= Int(v[i]) * 10 - var sz = len(v) - 1 - while sz >= 0 and v[sz] == 0: sz -= 1 - v.resize(sz + 1, 0) - rslt = String(t) + rslt - return rslt - fn __imul__(mut self, rhs: Self): - var lenl = len(self.contents); var lenr = len(rhs.contents) - var rslt = List[UInt32](length = lenl + lenr, fill = 0) - for i in range(lenr): - var t: UInt64 = 0 - for j in range(lenl): - t += Int(self.contents[j]) * Int(rhs.contents[i]) + Int(rslt[i + j]) - rslt[i + j] = Int(t & 0xFFFFFFFF); t >>= 32 - rslt[i + lenl] += Int(t) - var sz = len(rslt) - 1 - while sz >= 0 and rslt[sz] == 0: sz -= 1 - rslt.resize(sz + 1, 0); self.contents = rslt^ - -alias lb2: Float64 = 1.0 -alias lb3: Float64 = log2(Float64(3.0)) -alias lb5: Float64 = log2(Float64(5.0)) - -@fieldwise_init -struct LogRep(ImplicitlyCopyable, Movable, Stringable): - var logrep: Float64 - var x2: UInt32 - var x3: UInt32 - var x5: UInt32 - fn __del__(deinit self): return - @always_inline - fn mul2(self) -> Self: - return LogRep(self.logrep + lb2, self.x2 + 1, self.x3, self.x5) - @always_inline - fn mul3(self) -> Self: - return LogRep(self.logrep + lb3, self.x2, self.x3 + 1, self.x5) - @always_inline - fn mul5(self) -> Self: - return LogRep(self.logrep + lb5, self.x2, self.x3, self.x5 + 1) - fn __str__(self) -> String: -# return "( " + String(self.x2) + ", " + String(self.x3) + ", " + String(self.x5) + " )" - var rslt = BigNat(1) - fn expnd(mut rslt: BigNat, bs: UInt32, n: UInt32): - var bsm = BigNat(bs); var nm = n - while nm > 0: - if (nm & 1) != 0: rslt *= bsm - tmp = bsm; bsm *= tmp; nm >>= 1 - expnd(rslt, 2, self.x2); expnd(rslt, 3, self.x3); expnd(rslt, 5, self.x5) - return String(rslt) - -alias oneLR: LogRep = LogRep(0.0, 0, 0, 0) - -alias LogRepThunk = fn() escaping -> LogRep - -# Since an escaping closure doesn't currently move even for last used captures, and -# List's can't be copied into closures, we could write a minimal List to do the job, or -# probably easier is to just use a Mojo Iterator struct.... -struct _HammingsLogImpIter(ImplicitlyCopyable, Movable, Iterator): - alias __copyinit__is_trivial = False - alias __moveinit__is_trivial = False - alias __del__is_trivial = False - alias Element = LogRep - var s2: List[LogRep]; var s3: List[LogRep]; var s5: LogRep; var mrg: LogRep -# var s2p: UnsafePointer[LogRep]; var s3p: UnsafePointer[LogRep] - var s2hdi: Int; var s2tli: Int; var s3hdi: Int; var s3tli: Int - fn __init__(out self: Self): - self.s2 = List[LogRep](length=512, fill=oneLR); self.s2[0] = oneLR.mul2() - self.s3 = List[LogRep](length=1, fill=oneLR); self.s3[0] = oneLR.mul3() - self.s5 = oneLR.mul5(); self.mrg = oneLR -# self.s2p = self.s2.steal_data(); self.s3p = self.s3.steal_data() - self.s2hdi = 0; self.s2tli = -1; self.s3hdi = 0; self.s3tli = -1 - fn __copyinit__(out self: Self, existing: Self, /): - self.s2 = existing.s2.copy(); self.s3 = existing.s3.copy() - self.s5 = existing.s5; self.mrg = existing.mrg -# self.s2p = existing.s2p; self.s3p = existing.s3p - self.s2hdi = existing.s2hdi; self.s2tli = existing.s2tli - self.s3hdi = existing.s3hdi; self.s3tli = existing.s3tli -# fn __moveinit__(out self: Self, var existing: Self, /): -# self = existing^ - fn __has_next__(self: Self) -> Bool: - return True # "infinite" series! - fn __next__(mut self: Self) -> Self.Element: - var rslt = self.s2.unsafe_get(self.s2hdi) - var s2len = len(self.s2) - self.s2tli += 1; - if self.s2tli >= s2len: - self.s2tli = 0 - if self.s2hdi == self.s2tli: - if s2len < 1024: - self.s2.resize(1024, oneLR) # ; self.s2p = self.s2.steal_data() - else: - self.s2.resize(s2len + s2len, oneLR) # ; self.s2p = self.s2.steal_data() - for i in range(self.s2hdi): - self.s2.unsafe_set(s2len + i, self.s2.unsafe_get(i)) -# memcpy[UInt8, 0](s2p + s2len, s2p, sizeof[LogRep]() * s2hdi) - self.s2tli += s2len; s2len += s2len - if rslt.logrep < self.mrg.logrep: - self.s2hdi += 1 - if self.s2hdi >= s2len: - self.s2hdi = 0 - else: - rslt = self.mrg - var s3len = len(self.s3) - self.s3tli += 1; - if self.s3tli >= s3len: - self.s3tli = 0 - if self.s3hdi == self.s3tli: - if s3len < 1024: - self.s3.resize(1024, oneLR) # ; self.s3p = self.s3.steal_data() - else: - self.s3.resize(s3len + s3len, oneLR) # ; self.s3p = self.s3.steal_data() - for i in range(self.s3hdi): - self.s3.unsafe_set(s3len + i, self.s3.unsafe_get(i)) -# memcpy[UInt8, 0](s3p + s3len, s3p, sizeof[LogRep]() * s3hdi) - self.s3tli += s3len; s3len += s3len - if self.mrg.logrep < self.s5.logrep: - self.s3hdi += 1 - if self.s3hdi >= s3len: - self.s3hdi = 0 - else: - self.s5 = self.s5.mul5() - self.s3[self.s3tli] = rslt.mul3(); var t = self.s3[self.s3hdi]; - self.mrg = t if t.logrep < self.s5.logrep else self.s5 - self.s2.unsafe_set(self.s2tli, rslt.mul2()); return rslt - -@fieldwise_init -struct HammingsLogImp(ImplicitlyCopyable, Movable, Iterable): - alias __del__is_trivial = True - alias IteratorType[ - iterable_mut: Bool, //, iterable_origin: Origin[iterable_mut] - ]: Iterator = _HammingsLogImpIter - fn __iter__(ref self: Self) -> _HammingsLogImpIter: - return _HammingsLogImpIter() - -fn main(): - print("The first 20 Hamming numbers are:") - for i, h in enumerate(HammingsLogImp()): - print(String(h) + " ", end='') - if i >= 19: break - print() - for i, h in enumerate(HammingsLogImp()): - if i >= 1691 - 1: print("The 1691st Hamming number is " + String(h)); break - var strt: Int = monotonic() - var ham = oneLR - for i, h in enumerate(HammingsLogImp()): - if i >= cCOUNT - 1: ham = h; break - var elpsd = (monotonic() - strt) / 1000 - - print("The " + String(cCOUNT) + "th Hamming number is:") - print("2**" + String(ham.x2) + " * 3**" + String(ham.x3) + " * 5**" + String(ham.x5)) - var lg2 = lb2 * Float64(Int(ham.x2)) + lb3 * Float64(Int(ham.x3)) + lb5 * Float64(Int(ham.x5)) - var lg10 = lg2 / log2(Float64(10)) - var expnt = trunc(lg10); var num = Float64(10.0)**(lg10 - expnt) - var apprxstr = String(num) + "E+" + String(Int(expnt)) - print("Approximately: ", apprxstr) - var answrstr = String(ham) - print("The result has", len(answrstr), "digits.") - print(answrstr) - print("This took " + String(elpsd) + " microseconds.") diff --git a/Task/Hamming-numbers/OCaml/hamming-numbers-1.ml b/Task/Hamming-numbers/OCaml/hamming-numbers-1.ocaml similarity index 100% rename from Task/Hamming-numbers/OCaml/hamming-numbers-1.ml rename to Task/Hamming-numbers/OCaml/hamming-numbers-1.ocaml diff --git a/Task/Hamming-numbers/OCaml/hamming-numbers-2.ml b/Task/Hamming-numbers/OCaml/hamming-numbers-2.ocaml similarity index 100% rename from Task/Hamming-numbers/OCaml/hamming-numbers-2.ml rename to Task/Hamming-numbers/OCaml/hamming-numbers-2.ocaml diff --git a/Task/Hamming-numbers/PascalABC.NET/hamming-numbers.pas b/Task/Hamming-numbers/PascalABC.NET/hamming-numbers.pas deleted file mode 100644 index 2f3354df97..0000000000 --- a/Task/Hamming-numbers/PascalABC.NET/hamming-numbers.pas +++ /dev/null @@ -1,34 +0,0 @@ -function Hamming(n: integer): BigInteger; -begin - var (two,three,five) := (2bi, 3bi, 5bi); - var h := new BigInteger[n]; - h[0] := 1; - var (x2,x3,x5) := (2bi, 3bi, 5bi); - var (i,j,k) := (0, 0, 0); - for var ind := 1 to n-1 do - begin - h[ind] := Min(x2, x3, x5); - if h[ind] = x2 then - begin - i += 1; - x2 := two * h[i]; - end; - if h[ind] = x3 then - begin - j += 1; - x3 := three * h[j]; - end; - if h[ind] = x5 then - begin - k += 1; - x5 := five * h[k]; - end; - end; - Result := h[n-1]; -end; - -begin - (1..20).Select(x -> Hamming(x)).Println; - Hamming(1691).Println; - Hamming(1000000).Println; -end. diff --git a/Task/Hamming-numbers/REXX/hamming-numbers-1.rexx b/Task/Hamming-numbers/REXX/hamming-numbers-1.rexx new file mode 100644 index 0000000000..cc53b7ad15 --- /dev/null +++ b/Task/Hamming-numbers/REXX/hamming-numbers-1.rexx @@ -0,0 +1,20 @@ +/*REXX program computes Hamming numbers: 1 ──► 20, # 1691, and the one millionth. */ +numeric digits 100 /*ensure enough decimal digits. */ +call hamming 1, 20 /*show the 1st ──► twentieth Hamming #s*/ +call hamming 1691 /*show the 1,691st Hamming number. */ +call hamming 1000000 /*show the 1 millionth Hamming number.*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +hamming: procedure; parse arg x,y; if y=='' then y= x; w= length(y) + #2= 1; #3= 1; #5= 1; @.= 0; @.1= 1 + do n=2 for y-1 + @.n= min(2*@.#2, 3*@.#3, 5*@.#5) /*pick the minimum of 3 Hamming numbers*/ + if 2*@.#2 == @.n then #2= #2 + 1 /*number already defined? Use next #. */ + if 3*@.#3 == @.n then #3= #3 + 1 /* " " " " " " */ + if 5*@.#5 == @.n then #5= #5 + 1 /* " " " " " " */ + end /*n*/ /* [↑] maybe assign next 3 Hamming#s. */ + do j=x to y; say 'Hamming('right(j, w)") =" @.j + end /*j*/ + + say right( 'length of last Hamming number =' length(@.y), 70); say + return diff --git a/Task/Hamming-numbers/REXX/hamming-numbers-2.rexx b/Task/Hamming-numbers/REXX/hamming-numbers-2.rexx new file mode 100644 index 0000000000..bccf09bbe0 --- /dev/null +++ b/Task/Hamming-numbers/REXX/hamming-numbers-2.rexx @@ -0,0 +1,26 @@ +/*REXX program computes Hamming numbers: 1 ──► 20, # 1691, and the one millionth.*/ +call hamming 1, 20 /*show the 1st ──► twentieth Hamming #s*/ +call hamming 1691 /*show the 1,691st Hamming number. */ +call hamming 1000000 /*show the 1 millionth Hamming number.*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +hamming: procedure; arg x,y; if y=='' then y= x; w= length(y); L= length(y-1); p= 2**L + numeric digits max(9, p + p%4 + p%16) /*ensure enough decimal digits. */ + #2= 1; #3= 1; #5= 1; @.= 0; @.1= 1 + do n=2 for y-1 + _2= @.#2 + @.#2 /*this is faster than: @.#2 * 2 */ + _3= @.#3 + @.#3 + @.#3 /* " " " " @,#3 * 3 */ + _5= @.#5 * 5 + m= _2 /*assume a minimum (of the 3 Hammings).*/ + if _3 < m then m= _3 /*is this number less than the minimum?*/ + if _5 < m then m= _5 /* " " " " " " " */ + @.n= m /*now, assign the next Hamming number.*/ + if _2 == m then #2= #2 + 1 /*number already defined? Use next #.*/ + if _3 == m then #3= #3 + 1 /* " " " " " " */ + if _5 == m then #5= #5 + 1 /* " " " " " " */ + end /*n*/ /* [↑] maybe assign next Hamming #'s. */ + do j=x to y; say 'Hamming('right(j, w)") =" @.j + end /*j*/ + + say right( 'length of last Hamming number =' length(@.y), 70); say + return diff --git a/Task/Hamming-numbers/REXX/hamming-numbers-3.rexx b/Task/Hamming-numbers/REXX/hamming-numbers-3.rexx new file mode 100644 index 0000000000..ed4dfa5cbb --- /dev/null +++ b/Task/Hamming-numbers/REXX/hamming-numbers-3.rexx @@ -0,0 +1,26 @@ +/*REXX program computes Hamming numbers: 1 ──► 20, # 1691, and the one millionth.*/ +call hamming 1, 20 /*show the 1st ──► twentieth Hamming #s*/ +call hamming 1691 /*show the 1,691st Hamming number. */ +call hamming 1000000 /*show the 1 millionth Hamming number.*/ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +hamming: procedure; arg x,y; if y=='' then y= x; w= length(y); L= length(y-1); p= 2**L + numeric digits max(9, p + p%4 + p%16) /*ensure enough decimal digits. */ + #2= 1; #3= 1; #5= 1; @.= 0; @.1= 1 + do n=2 for y-1 + _2= @.#2 + @.#2 /*this is faster than: @.#2 * 2 */ + _3= @.#3 + @.#3 + @.#3 /* " " " " @,#3 * 3 */ + _5= @.#5 * 5 + m= _2 /*assume a minimum (of the 3 Hammings).*/ + if _3 < m then m= _3 /*is this number less than the minimum?*/ + if _5 < m then m= _5 /* " " " " " " " */ + @.n= format(m,,,,0) /*now, assign the next Hamming number.*/ + if _2 == m then #2= #2 + 1 /*number already defined? Use next #.*/ + if _3 == m then #3= #3 + 1 /* " " " " " " */ + if _5 == m then #5= #5 + 1 /* " " " " " " */ + end /*n*/ /* [↑] maybe assign next Hamming #'s. */ + do j=x to y; say 'Hamming('right(j, w)") =" @.j / 1 + end /*j*/ + + say right( 'length of last Hamming number =' length(@.y / 1), 70); say + return diff --git a/Task/Hamming-numbers/REXX/hamming-numbers.rexx b/Task/Hamming-numbers/REXX/hamming-numbers.rexx deleted file mode 100644 index 7ab126e8ff..0000000000 --- a/Task/Hamming-numbers/REXX/hamming-numbers.rexx +++ /dev/null @@ -1,38 +0,0 @@ --- 23 Aug 2025 -include Setting - -say 'HAMMING NUMBERS' -say version -say -call Hammings 1000000 -call ShowFirstN 20 -call ShowNth 1691 -call ShowNth 1000000 -call Hammings 10000000 -call ShowNth 10000000 -say Time('e')/1 'seconds' -exit - -ShowFirstN: -procedure expose Hamm. -arg xx -xx = xx/1 -say 'First' xx 'Hamming numbers are' -do i = 1 to xx - call Charout ,Right(Hamm.i,5) - if i//10 = 0 then - say -end -say -return - -ShowNth: -procedure expose Hamm. -arg xx -xx = xx/1 -say xx'th Hamming number is' -say Hamm.xx '('Length(Hamm.xx) 'digits)' -say -return - -include Math diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-1.rs b/Task/Hamming-numbers/Rust/hamming-numbers-1.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-1.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-1.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-2.rs b/Task/Hamming-numbers/Rust/hamming-numbers-2.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-2.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-2.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-3.rs b/Task/Hamming-numbers/Rust/hamming-numbers-3.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-3.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-3.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-4.rs b/Task/Hamming-numbers/Rust/hamming-numbers-4.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-4.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-4.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-5.rs b/Task/Hamming-numbers/Rust/hamming-numbers-5.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-5.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-5.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-6.rs b/Task/Hamming-numbers/Rust/hamming-numbers-6.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-6.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-6.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-7.rs b/Task/Hamming-numbers/Rust/hamming-numbers-7.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-7.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-7.rust diff --git a/Task/Hamming-numbers/Rust/hamming-numbers-8.rs b/Task/Hamming-numbers/Rust/hamming-numbers-8.rust similarity index 100% rename from Task/Hamming-numbers/Rust/hamming-numbers-8.rs rename to Task/Hamming-numbers/Rust/hamming-numbers-8.rust diff --git a/Task/Hamming-numbers/Scheme/hamming-numbers-1.scm b/Task/Hamming-numbers/Scheme/hamming-numbers-1.ss similarity index 100% rename from Task/Hamming-numbers/Scheme/hamming-numbers-1.scm rename to Task/Hamming-numbers/Scheme/hamming-numbers-1.ss diff --git a/Task/Hamming-numbers/Scheme/hamming-numbers-2.scm b/Task/Hamming-numbers/Scheme/hamming-numbers-2.ss similarity index 100% rename from Task/Hamming-numbers/Scheme/hamming-numbers-2.scm rename to Task/Hamming-numbers/Scheme/hamming-numbers-2.ss diff --git a/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-1.v b/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-1.v index bd63012c8d..509ec16025 100644 --- a/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-1.v +++ b/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-1.v @@ -1,7 +1,9 @@ import math.big fn min(a big.Integer, b big.Integer) big.Integer { - if a < b {return a} + if a < b { + return a + } return b } diff --git a/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-2.v b/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-2.v index 4fa74da146..3f7755a80b 100644 --- a/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-2.v +++ b/Task/Hamming-numbers/V-(Vlang)/hamming-numbers-2.v @@ -63,7 +63,7 @@ fn (lr LogRep) str() string { } struct HammingsLog { - mut: + mut: // automatically initialized with LogRep = one (defult)... s2 []LogRep = []LogRep { len: 1024, cap: 1024 } s3 []LogRep = []LogRep { len: 1024, cap: 1024 } diff --git a/Task/Hamming-numbers/VBScript/hamming-numbers.vbs b/Task/Hamming-numbers/VBScript/hamming-numbers.vb similarity index 100% rename from Task/Hamming-numbers/VBScript/hamming-numbers.vbs rename to Task/Hamming-numbers/VBScript/hamming-numbers.vb diff --git a/Task/Hamming-numbers/Wren/hamming-numbers-1.wren b/Task/Hamming-numbers/Wren/hamming-numbers-1.wren index 266c36c8c0..650b3d95af 100644 --- a/Task/Hamming-numbers/Wren/hamming-numbers-1.wren +++ b/Task/Hamming-numbers/Wren/hamming-numbers-1.wren @@ -1,4 +1,4 @@ -import "./big" for BigInt, BigInts +import "/big" for BigInt, BigInts var primes = [2, 3, 5].map { |p| BigInt.new(p) }.toList diff --git a/Task/Handle-a-signal/Ada/handle-a-signal-1.adb b/Task/Handle-a-signal/Ada/handle-a-signal-1.ada similarity index 100% rename from Task/Handle-a-signal/Ada/handle-a-signal-1.adb rename to Task/Handle-a-signal/Ada/handle-a-signal-1.ada diff --git a/Task/Handle-a-signal/Ada/handle-a-signal-2.adb b/Task/Handle-a-signal/Ada/handle-a-signal-2.ada similarity index 100% rename from Task/Handle-a-signal/Ada/handle-a-signal-2.adb rename to Task/Handle-a-signal/Ada/handle-a-signal-2.ada diff --git a/Task/Handle-a-signal/Ada/handle-a-signal-3.adb b/Task/Handle-a-signal/Ada/handle-a-signal-3.ada similarity index 100% rename from Task/Handle-a-signal/Ada/handle-a-signal-3.adb rename to Task/Handle-a-signal/Ada/handle-a-signal-3.ada diff --git a/Task/Handle-a-signal/Batch-File/handle-a-signal.bat b/Task/Handle-a-signal/Batch-File/handle-a-signal.bat deleted file mode 100644 index 6c25ba9c5d..0000000000 --- a/Task/Handle-a-signal/Batch-File/handle-a-signal.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -setlocal enableextensions enabledelayedexpansion -if defined sigintEnd goto timerCalc -if defined sigintMain goto main -set timer=for /f "tokens=1-4 delims=:.," %%a in ("^!time^!"^) do set start_h=%%a^&set /a start_m=100%%b %% 100^&set /a start_s=100%%c %% 100^&set /a start_ms=100%%d %% 100 -( -%timer% -set sigintMain=1 -%= "echo y" to skip a prompt and proceed to time reporting =% -echo y| cmd /d /c "%~f0" -cmd /d /c set sigintEnd=1^&"%~f0" -goto :eof -) -:main -set i=1 -:loop -echo %i% -:: sleep for 1 second -ping 0.0.0.0 -n 2 >nul -set /a i+=1 -goto loop -:timerCalc -%timer:start=end% -for %%i in (h m s ms) do set /a %%i=end_%%i-start_%%i -if %ms% lss 0 set /a s-=1 & set /a ms=100%ms% -if %s% lss 0 set /a m-=1 & set /a s=60%s% -if %m% lss 0 set /a h-=1 & set /a m=60%m% -if %h% lss 0 set /a h=24%h% -if 1%ms% lss 100 set ms=0%ms% -set /a totalsecs=h*3600 + m*60 +s -echo Execution time: %totalsecs%.%ms%s diff --git a/Task/Handle-a-signal/COBOL/handle-a-signal.cob b/Task/Handle-a-signal/COBOL/handle-a-signal.cobol similarity index 100% rename from Task/Handle-a-signal/COBOL/handle-a-signal.cob rename to Task/Handle-a-signal/COBOL/handle-a-signal.cobol diff --git a/Task/Handle-a-signal/Crystal/handle-a-signal.cr b/Task/Handle-a-signal/Crystal/handle-a-signal.crystal similarity index 100% rename from Task/Handle-a-signal/Crystal/handle-a-signal.cr rename to Task/Handle-a-signal/Crystal/handle-a-signal.crystal diff --git a/Task/Handle-a-signal/Julia/handle-a-signal.jl b/Task/Handle-a-signal/Julia/handle-a-signal.julia similarity index 100% rename from Task/Handle-a-signal/Julia/handle-a-signal.jl rename to Task/Handle-a-signal/Julia/handle-a-signal.julia diff --git a/Task/Handle-a-signal/Kotlin/handle-a-signal.kts b/Task/Handle-a-signal/Kotlin/handle-a-signal.kotlin similarity index 100% rename from Task/Handle-a-signal/Kotlin/handle-a-signal.kts rename to Task/Handle-a-signal/Kotlin/handle-a-signal.kotlin diff --git a/Task/Handle-a-signal/Lua/handle-a-signal.lua b/Task/Handle-a-signal/Lua/handle-a-signal.lua deleted file mode 100644 index 8b97e083d7..0000000000 --- a/Task/Handle-a-signal/Lua/handle-a-signal.lua +++ /dev/null @@ -1,20 +0,0 @@ -local start_date = os.time() - -local loop = true -local Exit = function () - print() - loop = false -end - -local posix = require"posix" -posix.signal(posix.SIGINT, Exit) -posix.signal(posix.SIGQUIT, Exit) - -local int = 0 -while loop do - int = int+1 - print(int) - posix.time.nanosleep{tv_sec=0,tv_nsec=500*1000*1000} -end - -print(os.time() - start_date) diff --git a/Task/Handle-a-signal/OCaml/handle-a-signal.ml b/Task/Handle-a-signal/OCaml/handle-a-signal.ocaml similarity index 100% rename from Task/Handle-a-signal/OCaml/handle-a-signal.ml rename to Task/Handle-a-signal/OCaml/handle-a-signal.ocaml diff --git a/Task/Handle-a-signal/PascalABC.NET/handle-a-signal.pas b/Task/Handle-a-signal/PascalABC.NET/handle-a-signal.pas deleted file mode 100644 index 751e61da9f..0000000000 --- a/Task/Handle-a-signal/PascalABC.NET/handle-a-signal.pas +++ /dev/null @@ -1,13 +0,0 @@ -begin - var counter := 0; - while True do - begin - Print(counter); - counter += 1; - Sleep(500); - end; - Console.CancelKeyPress += (o,e) -> begin - Println(Milliseconds); - halt - end; -end. diff --git a/Task/Handle-a-signal/PowerShell/handle-a-signal.ps1 b/Task/Handle-a-signal/PowerShell/handle-a-signal.psh similarity index 100% rename from Task/Handle-a-signal/PowerShell/handle-a-signal.ps1 rename to Task/Handle-a-signal/PowerShell/handle-a-signal.psh diff --git a/Task/Handle-a-signal/Rebol/handle-a-signal.rebol b/Task/Handle-a-signal/Rebol/handle-a-signal.rebol deleted file mode 100644 index 89e69e09f1..0000000000 --- a/Task/Handle-a-signal/Rebol/handle-a-signal.rebol +++ /dev/null @@ -1 +0,0 @@ -catch/quit/with [i: 0 t: stats/timer forever [print ++ i wait 0.5]][print ["Done!" stats/timer - t]] diff --git a/Task/Handle-a-signal/Rust/handle-a-signal.rs b/Task/Handle-a-signal/Rust/handle-a-signal.rust similarity index 100% rename from Task/Handle-a-signal/Rust/handle-a-signal.rs rename to Task/Handle-a-signal/Rust/handle-a-signal.rust diff --git a/Task/Handle-a-signal/Sidef/handle-a-signal.sidef b/Task/Handle-a-signal/Sidef/handle-a-signal.sidef index 41b5408755..b77cad0bb3 100644 --- a/Task/Handle-a-signal/Sidef/handle-a-signal.sidef +++ b/Task/Handle-a-signal/Sidef/handle-a-signal.sidef @@ -1,11 +1,11 @@ -var start = Time.sec - -Sig.INT { - say "Ran for #{Time.sec - start} seconds." - Sys.exit +var start = Time.sec; +  +Sig.INT { |_| + Sys.say("Ran for #{Time.sec - start} seconds."); + Sys.exit; } - +  { |i| - say i - Sys.sleep(0.5) -} * Inf + Sys.say(i); + Sys.sleep(0.5); +} * Math.inf; diff --git a/Task/Happy-numbers/00-META.yaml b/Task/Happy-numbers/00-META.yaml index 6e331dac93..2fb428f9fa 100644 --- a/Task/Happy-numbers/00-META.yaml +++ b/Task/Happy-numbers/00-META.yaml @@ -1,3 +1,3 @@ --- from: http://rosettacode.org/wiki/Happy_numbers -note: Numbers +note: Arithmetic operations diff --git a/Task/Happy-numbers/00-TASK.txt b/Task/Happy-numbers/00-TASK.txt index ff58f52d73..1201ba43c3 100644 --- a/Task/Happy-numbers/00-TASK.txt +++ b/Task/Happy-numbers/00-TASK.txt @@ -14,9 +14,6 @@ Find and print the first   '''8'''   happy numbers. Display an example of your output here on this page. -;Related tasks: -* [[Iterated digits squaring]] - ;See also: *   The OEIS entry:   [[oeis:A007770|The     happy numbers:   A007770]] *   The OEIS entry:   [[oeis:A031177|The unhappy numbers;   A031177]] diff --git a/Task/Happy-numbers/ABC/happy-numbers.abc b/Task/Happy-numbers/ABC/happy-numbers.abc deleted file mode 100644 index befec4774e..0000000000 --- a/Task/Happy-numbers/ABC/happy-numbers.abc +++ /dev/null @@ -1,24 +0,0 @@ -HOW TO RETURN square.digit.sum n: - PUT 0 IN sum - WHILE n>0: - PUT n mod 10 IN digit - PUT sum + digit ** 2 IN sum - PUT floor (n/10) IN n - RETURN sum - -HOW TO REPORT happy n: - PUT {} IN seen - WHILE n not.in seen: - INSERT n IN seen - PUT square.digit.sum n IN n - REPORT n=1 - -HOW TO RETURN next.happy n: - PUT n+1 IN n - WHILE NOT happy n: PUT n+1 IN n - RETURN n - -PUT 0 IN n -FOR i IN {1..8}: - PUT next.happy n IN n - WRITE n/ diff --git a/Task/Happy-numbers/Ada/happy-numbers.adb b/Task/Happy-numbers/Ada/happy-numbers.ada similarity index 100% rename from Task/Happy-numbers/Ada/happy-numbers.adb rename to Task/Happy-numbers/Ada/happy-numbers.ada diff --git a/Task/Happy-numbers/Arturo/happy-numbers.arturo b/Task/Happy-numbers/Arturo/happy-numbers.arturo index 388d4db91b..bc1ccc3bbb 100644 --- a/Task/Happy-numbers/Arturo/happy-numbers.arturo +++ b/Task/Happy-numbers/Arturo/happy-numbers.arturo @@ -1,7 +1,7 @@ -ord0: to :integer '0' +ord0: to :integer `0` happy?: function [x][ n: x - past: [] + past: new [] while [n <> 1][ s: to :string n diff --git a/Task/Happy-numbers/AutoIt/happy-numbers-1.au3 b/Task/Happy-numbers/AutoIt/happy-numbers-1.autoit similarity index 100% rename from Task/Happy-numbers/AutoIt/happy-numbers-1.au3 rename to Task/Happy-numbers/AutoIt/happy-numbers-1.autoit diff --git a/Task/Happy-numbers/AutoIt/happy-numbers-2.au3 b/Task/Happy-numbers/AutoIt/happy-numbers-2.autoit similarity index 100% rename from Task/Happy-numbers/AutoIt/happy-numbers-2.au3 rename to Task/Happy-numbers/AutoIt/happy-numbers-2.autoit diff --git a/Task/Happy-numbers/COBOL/happy-numbers.cob b/Task/Happy-numbers/COBOL/happy-numbers.cobol similarity index 100% rename from Task/Happy-numbers/COBOL/happy-numbers.cob rename to Task/Happy-numbers/COBOL/happy-numbers.cobol diff --git a/Task/Happy-numbers/Crystal/happy-numbers.cr b/Task/Happy-numbers/Crystal/happy-numbers.crystal similarity index 100% rename from Task/Happy-numbers/Crystal/happy-numbers.cr rename to Task/Happy-numbers/Crystal/happy-numbers.crystal diff --git a/Task/Happy-numbers/Delphi/happy-numbers.pas b/Task/Happy-numbers/Delphi/happy-numbers.delphi similarity index 100% rename from Task/Happy-numbers/Delphi/happy-numbers.pas rename to Task/Happy-numbers/Delphi/happy-numbers.delphi diff --git a/Task/Happy-numbers/EasyLang/happy-numbers.easy b/Task/Happy-numbers/EasyLang/happy-numbers.easy deleted file mode 100644 index 922506ed62..0000000000 --- a/Task/Happy-numbers/EasyLang/happy-numbers.easy +++ /dev/null @@ -1,27 +0,0 @@ -func dsum n . - while n > 0 - d = n mod 10 - s += d * d - n = n div 10 - . - return s -. -func happy n . - while n > 999 - n = dsum n - . - len seen[] 999 - repeat - n = dsum n - until seen[n] = 1 - seen[n] = 1 - . - return if n = 1 -. -while cnt < 8 - n += 1 - if happy n = 1 - cnt += 1 - write n & " " - . -. diff --git a/Task/Happy-numbers/Elena/happy-numbers.elena b/Task/Happy-numbers/Elena/happy-numbers.elena index 0b49f2db3e..ce34920d51 100644 --- a/Task/Happy-numbers/Elena/happy-numbers.elena +++ b/Task/Happy-numbers/Elena/happy-numbers.elena @@ -9,14 +9,14 @@ isHappy(int n) int num := n; while (num != 1) { - if (cache.indexOfElement(num) != -1) + if (cache.indexOfElement:num != -1) { ^ false }; cache.append(num); while (num != 0) { - int digit := num.mod(10); + int digit := num.mod:10; sum += (digit*digit); num /= 10 }; @@ -27,7 +27,7 @@ isHappy(int n) ^ true } -public Program() +public program() { auto happynums := new List(8); int num := 1; diff --git a/Task/Happy-numbers/Elixir/happy-numbers.ex b/Task/Happy-numbers/Elixir/happy-numbers.elixir similarity index 100% rename from Task/Happy-numbers/Elixir/happy-numbers.ex rename to Task/Happy-numbers/Elixir/happy-numbers.elixir diff --git a/Task/Happy-numbers/Euphoria/happy-numbers.eu b/Task/Happy-numbers/Euphoria/happy-numbers.euphoria similarity index 100% rename from Task/Happy-numbers/Euphoria/happy-numbers.eu rename to Task/Happy-numbers/Euphoria/happy-numbers.euphoria diff --git a/Task/Happy-numbers/Frink/happy-numbers.frink b/Task/Happy-numbers/Frink/happy-numbers.frink deleted file mode 100644 index ce9c4e404d..0000000000 --- a/Task/Happy-numbers/Frink/happy-numbers.frink +++ /dev/null @@ -1,19 +0,0 @@ -isHappy = {|n| - sqf = {|x| x^2} - seen = new set[n] - - while true - { - n = sum[map[sqf, integerDigits[n]]] - if n == 1 - return true - - if seen.contains[n] - return false - else - seen.put[n] - } -} - - -println[first[select[count[1], isHappy], 8]] diff --git a/Task/Happy-numbers/Haskell/happy-numbers-3.hs b/Task/Happy-numbers/Haskell/happy-numbers-3.hs deleted file mode 100644 index 04713b0ba9..0000000000 --- a/Task/Happy-numbers/Haskell/happy-numbers-3.hs +++ /dev/null @@ -1,14 +0,0 @@ -happy x = sum (map (\x -> x * x) (digits x)) - where - digits 0 = [0] - digits x = (x `mod` 10):(digits (x `div` 10)) -- could function digits be more concise? - -ishappy x = floyd (happy x) (happy (happy x)) - where - floyd :: Int -> Int -> Bool - floyd 1 _ = True - floyd _ 1 = True - floyd a b | a == b = False - floyd x y = floyd (happy x) (happy (happy y)) - -main = (print $ take 8 $ filter ishappy [1..]) >> (print $ sum $ take 10000 $ filter ishappy [1..] diff --git a/Task/Happy-numbers/Julia/happy-numbers-1.jl b/Task/Happy-numbers/Julia/happy-numbers-1.jl deleted file mode 100644 index d9d5a0d343..0000000000 --- a/Task/Happy-numbers/Julia/happy-numbers-1.jl +++ /dev/null @@ -1,16 +0,0 @@ -function happy(x) - happy_ints = Int[] - int_try = 1 - while length(happy_ints) < x - n = int_try - past = Int[] - while n != 1 - n = sum(y^2 for y in digits(n)) - n in past && break - push!(past, n) - end - n == 1 && push!(happy_ints,int_try) - int_try += 1 - end - return happy_ints -end diff --git a/Task/Happy-numbers/Julia/happy-numbers-1.julia b/Task/Happy-numbers/Julia/happy-numbers-1.julia new file mode 100644 index 0000000000..f4fc223f7c --- /dev/null +++ b/Task/Happy-numbers/Julia/happy-numbers-1.julia @@ -0,0 +1,15 @@ +function happy(x) + happy_ints = ref(Int) + int_try = 1 + while length(happy_ints) < x + n = int_try + past = ref(Int) + while n != 1 + n = sum([y^2 for y in digits(n)]) + contains(past,n) ? break : push!(past,n) + end + n == 1 && push!(happy_ints,int_try) + int_try += 1 + end + return happy_ints +end diff --git a/Task/Happy-numbers/Julia/happy-numbers-2.jl b/Task/Happy-numbers/Julia/happy-numbers-2.jl deleted file mode 100644 index 3d6947b562..0000000000 --- a/Task/Happy-numbers/Julia/happy-numbers-2.jl +++ /dev/null @@ -1,10 +0,0 @@ -sumhappy(n) = sum(x->x^2, digits(n)) - -function ishappy(x, mem = Int[]) - x == 1 ? true : - x in mem ? false : - ishappy(sumhappy(x), [mem ; x]) -end - -nexthappy(x) = ishappy(x+1) ? x+1 : nexthappy(x+1) -happy(n) = accumulate((a, b) -> nexthappy(a), 1:n) diff --git a/Task/Happy-numbers/Julia/happy-numbers-2.julia b/Task/Happy-numbers/Julia/happy-numbers-2.julia new file mode 100644 index 0000000000..82b71edb0c --- /dev/null +++ b/Task/Happy-numbers/Julia/happy-numbers-2.julia @@ -0,0 +1,11 @@ +sumhappy(n) = sum(x->x^2, digits(n)) + +function ishappy(x, mem = []) + x == 1? true : + x in mem? false : + ishappy(sumhappy(x),[mem ; x]) +end + +nexthappy (x) = ishappy(x+1) ? x+1 : nexthappy(x+1) + +happy(n) = [z = 1 ; [z = nexthappy(z) for i = 1:n-1]] diff --git a/Task/Happy-numbers/Julia/happy-numbers-3.jl b/Task/Happy-numbers/Julia/happy-numbers-3.jl deleted file mode 100644 index 9a2d149a42..0000000000 --- a/Task/Happy-numbers/Julia/happy-numbers-3.jl +++ /dev/null @@ -1,30 +0,0 @@ -const CACHE = 256 -buf = zeros(Int, CACHE) -buf[begin] = 1 - -function happy(n) - if n < CACHE - buf[n] > 0 && return 2-buf[n] - buf[n] = 2 - end - sqsum = 0 - nn = n - while nn != 0 - nn, x = divrem(nn, 10) - sqsum += x * x - end - x = happy(sqsum) - n < CACHE && (buf[n] = 2 - x) - return x -end - -function main() - i, counter = 1, 1000000 - while counter > 0 - if happy(i) != 0 - counter -= 1 - end - i += 1 - end - return i - 1 -end diff --git a/Task/Happy-numbers/Julia/happy-numbers-3.julia b/Task/Happy-numbers/Julia/happy-numbers-3.julia new file mode 100644 index 0000000000..6fbebd76e6 --- /dev/null +++ b/Task/Happy-numbers/Julia/happy-numbers-3.julia @@ -0,0 +1,30 @@ +const CACHE = 256 +buf = zeros(Int,CACHE) +buf[1] = 1 +#happy(n) returns 1 if happy, 0 if not +function happy(n) + if n < CACHE + buf[n] > 0 && return 2-buf[n] + buf[n] = 2 + end + sum = 0 + nn = n + while nn != 0 + x = nn%10 + sum += x*x + nn = int8(nn/10) + end + x = happy(sum) + n < CACHE && (buf[n] = 2-x) + return x +end +function main() + i = 1; counter = 1000000 + while counter > 0 + if happy(i) == 1 + counter -= 1 + end + i += 1 + end + return i-1 +end diff --git a/Task/Happy-numbers/Kotlin/happy-numbers.kts b/Task/Happy-numbers/Kotlin/happy-numbers.kotlin similarity index 100% rename from Task/Happy-numbers/Kotlin/happy-numbers.kts rename to Task/Happy-numbers/Kotlin/happy-numbers.kotlin diff --git a/Task/Happy-numbers/Maxima/happy-numbers.maxima b/Task/Happy-numbers/Maxima/happy-numbers.maxima deleted file mode 100644 index 48ff21b660..0000000000 --- a/Task/Happy-numbers/Maxima/happy-numbers.maxima +++ /dev/null @@ -1,25 +0,0 @@ -/* Function that decomposes te number into a list */ -decompose(N) := block( - digits: [], - while N > 0 do - (remainder: mod(N, 10), - digits: cons(remainder, digits), - N: floor(N/10)), - digits -)$ - -/* Function that given a number returns the sum of their digits */ -sum_squares_digits(n):=block( - decompose(n), - map(lambda([x],x^2),%%), - apply("+",%%))$ - -/* Predicate function based on the task iterated digits squaring */ -happyp(n):=if n=1 then true else if n=89 then false else block(iter:n,while not member(iter,[1,89]) do iter:sum_squares_digits(iter),iter,if iter=1 then true)$ - -/* Test case */ -/* First eight happy numbers */ -block( - happy:[],i:1, - while length(happy)<8 do (if happyp(i) then happy:endcons(i,happy),i:i+1), - happy); diff --git a/Task/Happy-numbers/OCaml/happy-numbers.ml b/Task/Happy-numbers/OCaml/happy-numbers.ocaml similarity index 100% rename from Task/Happy-numbers/OCaml/happy-numbers.ml rename to Task/Happy-numbers/OCaml/happy-numbers.ocaml diff --git a/Task/Happy-numbers/PascalABC.NET/happy-numbers.pas b/Task/Happy-numbers/PascalABC.NET/happy-numbers.pas deleted file mode 100644 index 15d02a6478..0000000000 --- a/Task/Happy-numbers/PascalABC.NET/happy-numbers.pas +++ /dev/null @@ -1,27 +0,0 @@ -uses School; - -function IsHappy(n: integer): boolean; -begin - Result := False; - var cache := new HashSet; - while n <> 1 do - begin - if n in cache then - exit; - cache.Add(n); - n := n.Digits.Sum(d -> d*d); - end; - Result := True; -end; - -begin - var n := 1; - var happyNums := new List; - while happyNums.Count < 8 do - begin - if IsHappy(n) then - happyNums.Add(n); - n += 1; - end; - happyNums.Print -end. diff --git a/Task/Happy-numbers/Pluto/happy-numbers.pluto b/Task/Happy-numbers/Pluto/happy-numbers.pluto deleted file mode 100644 index 80a7ecb196..0000000000 --- a/Task/Happy-numbers/Pluto/happy-numbers.pluto +++ /dev/null @@ -1,26 +0,0 @@ -local function happy(n) - local m = {} - while n > 1 do - m[n] = true - local x = n - n = 0 - while x > 0 do - local d = x % 10 - n += d * d - x //= 10 - end - if m[n] then return false end -- m[n] will be nil if 'n' is not a key - end - return true -end - -local found = 0 -local n = 1 -while found < 8 do - if happy(n) then - io.write($"{n} ") - found += 1 - end - n += 1 -end -print() diff --git a/Task/Happy-numbers/PowerShell/happy-numbers-1.ps1 b/Task/Happy-numbers/PowerShell/happy-numbers-1.psh similarity index 100% rename from Task/Happy-numbers/PowerShell/happy-numbers-1.ps1 rename to Task/Happy-numbers/PowerShell/happy-numbers-1.psh diff --git a/Task/Happy-numbers/PowerShell/happy-numbers-2.ps1 b/Task/Happy-numbers/PowerShell/happy-numbers-2.psh similarity index 100% rename from Task/Happy-numbers/PowerShell/happy-numbers-2.ps1 rename to Task/Happy-numbers/PowerShell/happy-numbers-2.psh diff --git a/Task/Happy-numbers/REXX/happy-numbers-1.rexx b/Task/Happy-numbers/REXX/happy-numbers-1.rexx index ff5e99ee46..8fb8f111be 100644 --- a/Task/Happy-numbers/REXX/happy-numbers-1.rexx +++ b/Task/Happy-numbers/REXX/happy-numbers-1.rexx @@ -1,78 +1,19 @@ -/*REXX program computes and displays a specified range of happy numbers. */ -Call time 'R' -linesize=80 -Parse Arg low high /* obtain range of happy numbers */ -If low='?' Then Call help -If low='' Then low=10 -If high='' Then - Parse Value 1 low With low high -Do i=0 To 9 /*build a squared decimal digit table. */ - square.i=i*i - End -happy.=0 /* happy.m=1 - m is a happy number */ -unhappy.=0 /* unhappy.n=1 - n is an unhappy number*/ -hapn=0 /* count of the happy numbers */ -ol='' -Do n=1 While hapn0 Then Do /* or was already encountered */ - -- If wordpos(sum,suml)>0 Then say 'Loop' n':' suml sum - -- If n<7 Then say n':' suml sum - unhappy.n=1 /* n is unhappy */ - Call set suml /* amd so are all sums so far */ - Iterate n - End - When sum=1 Then Do /* we reached sum=1 */ - hapn+=1 /* increment number of happy numbers */ - happy.n=1 /* n is happy */ - If hapn>=low Then /* if it is in specified range */ - Call out n /* output it */ - If hapn=high Then /* end of range reached */ - Leave n /* we are done */ - Iterate n /* otherwise proceed */ - End - Otherwise Do /* otherwise */ - suml=suml sum /* add sum to list of sums */ - work=sum /* proceed with the new sum */ - End - End - End - End -If ol>'' Then /* more output data */ - Say strip(ol) /* write to console */ --- Say time('E') -Exit +/*REXX program computes and displays a specified amount of happy numbers. */ +parse arg limit . /*obtain optional argument from the CL.*/ +if limit=='' | limit=="," then limit=8 /*Not specified? Then use the default.*/ +haps=0 /*count of the happy numbers (so far).*/ -set: /* all intermediate sums are unhappy */ -Parse Arg list -Do While list<>'' - Parse Var list s list - unhappy.s=1 - End -Return + do n=1 while hapslinesize Then Do /* if it does not fit */ - Say strip(ol) /* output the line */ - ol=hn /* and start a new line */ - End - Else /* otherwise */ - ol=ol hn /* append is to the output line */ - Return - -help: - Say 'rexx hno n compute and show the first n happy numbers' - Say 'rexx hno low high show happy numbers from index low to high' - Exit + if @.s then iterate n /*if already summed, Q is unhappy. */ + @.s=1; q=s /*mark the sum as found; try Q sum.*/ + end /*until*/ + say n /*display the number (N is happy). */ + haps=haps+1 /*bump the count of happy numbers. */ + end /*n*/ + /*stick a fork in it, we're all done. */ diff --git a/Task/Happy-numbers/REXX/happy-numbers-2.rexx b/Task/Happy-numbers/REXX/happy-numbers-2.rexx index 11cc8094fd..9e7fb6cae2 100644 --- a/Task/Happy-numbers/REXX/happy-numbers-2.rexx +++ b/Task/Happy-numbers/REXX/happy-numbers-2.rexx @@ -1,106 +1,27 @@ --- 23 Aug 2025 -include Setting +/*REXX program computes and displays a specified range of happy numbers. */ +parse arg L H . /*obtain optional arguments from the CL*/ +if L=='' | L=="," then L=8 /*Not specified? Then use the default.*/ +if H=='' | H=="," then do; H=L; L=1; end /*use a range for the displaying of #s.*/ + do i=0 to 9; #.i=i**2; end /*i*/ /*build a squared decimal digit table. */ +@.=0; @.1=1; !.=@.; !.2=1; !.4=1 /*sparse array: @≡happy, !≡unhappy. */ +haps=0 /*count of the happy numbers (so far).*/ -say 'HAPPY NUMBERS' -say version -say -say 'Process first 8...' -call HappyS 8 -call ShowFirst8 -say -say 'Process first 10 million...' -call HappyS 1e7 -call ShowNth 1e1 -call ShowNth 1e2 -call ShowNth 1e3 -call ShowNth 1e4 -call ShowNth 1e5 -call ShowNth 1e6 -call ShowNth 1e7 -say -call Timer 'R' -exit - -HappyS: -procedure expose Happ. Flag. -arg xx --- Preset squares for digital sum -do i = 0 to 9 - Pow2.i=i*i -end --- Collect happy numbers <= 1000 -Flag.=0; Happ.=0; n=0 -do i = 1 while n < xx - h=i; ll='' - do forever --- Squared digital sum - ss=0 - do Length(h) - parse var h d +1 h; ss=ss+Pow2.d - end - select --- Unhappy? Flag sad sums, next number - when Flag.ss then do - do while ll <> '' - parse var ll s ll; Flag.s=1 - end - iterate i - end --- Repeating? Flag sad sums, next number - when WordPos(ss,ll) > 0 then do - do while ll <> '' - parse var ll s ll; Flag.s=1 - end - iterate i - end --- Happy? Bump, next number - when ss = 1 then do - n=n+1; Happ.n=i - iterate i - end --- Next sum - otherwise do - ll=ll ss; h=ss - end - end - end -end i --- Flag happy numbers <= 1000 -Flag.=0 -do i = 1 to n - h=Happ.i; Flag.h=1 -end --- Collect happy numbers > 1000 using flagged numbers -do i = 1001 while n < xx - h=i --- Squared digital sum - ss=0 - do Length(h) - parse var h d +1 h; ss=ss+Pow2.d - end --- Happy? Bump - if Flag.ss then do - n=n+1; Happ.n=i - end -end i --- Count -Happ.0=n -return n - -ShowFirst8: -procedure expose Happ. -say 'First 8 Happy numbers are' -do i = 1 to 8 - call Charout ,Right(Happ.i,3) -end -say -return - -ShowNth: -procedure expose Happ. -arg xx -xx = xx/1 -say xx'th Happy number is' Happ.xx -return - -include Math + do n=1 while hapssw then do /*if the list is too long, then split */ + say strip($) /* ··· and display what we've got. */ + $=n /*Set the next line to overflow. */ + end /* [↑] new line now contains overflow.*/ + end /*n*/ +if $\='' then say strip($) /*display any residual happy numbers. */ + /*stick a fork in it, we're all done. */ diff --git a/Task/Happy-numbers/Refal/happy-numbers.refal b/Task/Happy-numbers/Refal/happy-numbers.refal deleted file mode 100644 index 68c1b6b4e1..0000000000 --- a/Task/Happy-numbers/Refal/happy-numbers.refal +++ /dev/null @@ -1,26 +0,0 @@ -$ENTRY Go { - = ; -}; - -ShowFirst { - 0 s.F s.I = ; - s.N s.F s.I, : T = - - s.F <+ s.I 1>>; - s.N s.F s.I = - >; -}; - -Happy { - 1 e.X = T; - s.N e.X s.N e.Y = F; - s.N e.X = s.N e.X>; -}; - -SqDigSum { - 0 = 0; - s.N, : s.Ds e.Rs, - : s.D, - : s.R = - <+ <* s.D s.D> >; -}; diff --git a/Task/Happy-numbers/Rust/happy-numbers.rs b/Task/Happy-numbers/Rust/happy-numbers.rs deleted file mode 100644 index a0097862a0..0000000000 --- a/Task/Happy-numbers/Rust/happy-numbers.rs +++ /dev/null @@ -1,37 +0,0 @@ -fn sumsqd(mut n: i32) -> i32 { - let mut sq = 0; - while n > 0 { - let d = n % 10; - sq += d * d; - n /= 10; - } - sq -} - -fn cycle(a: T, f: F) -> T -where - T: Copy + PartialEq, - F: Fn(T) -> T, -{ - let mut t = a; - let mut h = f(a); - - while t != h { - t = f(t); - h = f(f(h)); - } - t -} - -fn ishappy(n: i32) -> bool { - cycle(n, sumsqd) == 1 -} - -fn main() { - let happy: Vec = (1..) - .filter(|&n| ishappy(n)) - .take(8) - .collect(); - - println!("{:?}", happy); -} diff --git a/Task/Happy-numbers/Rust/happy-numbers.rust b/Task/Happy-numbers/Rust/happy-numbers.rust new file mode 100644 index 0000000000..9b6647bd6e --- /dev/null +++ b/Task/Happy-numbers/Rust/happy-numbers.rust @@ -0,0 +1,36 @@ +#![feature(core)] + +fn sumsqd(mut n: i32) -> i32 { + let mut sq = 0; + while n > 0 { + let d = n % 10; + sq += d*d; + n /= 10 + } + sq +} + +use std::num::Int; +fn cycle(a: T, f: fn(T) -> T) -> T { + let mut t = a; + let mut h = f(a); + + while t != h { + t = f(t); + h = f(f(h)) + } + t +} + +fn ishappy(n: i32) -> bool { + cycle(n, sumsqd) == 1 +} + +fn main() { + let happy = std::iter::count(1, 1) + .filter(|&n| ishappy(n)) + .take(8) + .collect::>(); + + println!("{:?}", happy) +} diff --git a/Task/Happy-numbers/Scheme/happy-numbers.scm b/Task/Happy-numbers/Scheme/happy-numbers.ss similarity index 100% rename from Task/Happy-numbers/Scheme/happy-numbers.scm rename to Task/Happy-numbers/Scheme/happy-numbers.ss diff --git a/Task/Happy-numbers/Uiua/happy-numbers.uiua b/Task/Happy-numbers/Uiua/happy-numbers.uiua deleted file mode 100644 index a7189fe111..0000000000 --- a/Task/Happy-numbers/Uiua/happy-numbers.uiua +++ /dev/null @@ -1,3 +0,0 @@ -HC ← /+ⁿ2⊥₁₀ # Happiness = sum of squares of digits. -Happy ← memo(=1⊢⍢(⊂HC⊸⊢|¬˜∊°⊂)[∘]) # Apply HC until it repeats or = 1. -↙8▽⊸≡Happy⇡40 diff --git a/Task/Happy-numbers/V-(Vlang)/happy-numbers.v b/Task/Happy-numbers/V-(Vlang)/happy-numbers.v index 93b56b1751..4e492e47a7 100644 --- a/Task/Happy-numbers/V-(Vlang)/happy-numbers.v +++ b/Task/Happy-numbers/V-(Vlang)/happy-numbers.v @@ -1,14 +1,16 @@ fn happy(h int) bool { mut m := map[int]bool{} - mut n, mut x := h, 0 + mut n := h for n > 1 { m[n] = true - x = 0 + mut x := 0 for x, n = n, 0; x > 0; x /= 10 { d := x % 10 n += d * d } - if m[n] { return false } + if m[n] { + return false + } } return true } @@ -20,5 +22,5 @@ fn main() { found++ } } - println("") + println('') } diff --git a/Task/Happy-numbers/VBScript/happy-numbers.vbs b/Task/Happy-numbers/VBScript/happy-numbers.vb similarity index 100% rename from Task/Happy-numbers/VBScript/happy-numbers.vbs rename to Task/Happy-numbers/VBScript/happy-numbers.vb diff --git a/Task/Harmonic-series/ALGOL-60/harmonic-series.alg b/Task/Harmonic-series/ALGOL-60/harmonic-series.alg deleted file mode 100644 index 7b5f62d6ba..0000000000 --- a/Task/Harmonic-series/ALGOL-60/harmonic-series.alg +++ /dev/null @@ -1,32 +0,0 @@ -begin - -real i, h, n, limit; - -limit := 20; -h := 0; -outstring(1,"First"); -outreal(1,limit); -outstring(1,"numbers in the harmonic series\n"); -for i := 1, i + 1 while i <= limit do - begin - h := h + 1 / i; - outreal(1,i); - outreal(1,h); - outstring(1,"\n"); - end; - -for i := 1, i + 1 while i <= 5 do - begin - h := 1; - for n := 2, n + 1 while h <= i do - begin - h := h + 1 / n; - end; - outstring(1,"First harmonic number >"); - outreal(1,i); - outstring(1,"is at position"); - outreal(1,n-1); - outstring(1,"\n"); - end; - -end diff --git a/Task/Harmonic-series/ALGOL-68/harmonic-series.alg b/Task/Harmonic-series/ALGOL-68/harmonic-series.alg index a050da661d..b9fee50a9e 100644 --- a/Task/Harmonic-series/ALGOL-68/harmonic-series.alg +++ b/Task/Harmonic-series/ALGOL-68/harmonic-series.alg @@ -1,13 +1,13 @@ -BEGIN # find some harmonic numbers, Hn is the sum of the reciprocals of 1..n # +BEGIN # find some harmonic numbers, Hn is the sum if the reciprocals of 1..n # # returns the first n Harmonic numbers # OP HARMONIC = ( INT n )[]REAL: BEGIN - [ 1 : n ]REAL hs; - hs[ 1 ] := 1; + [ 1 : n ]REAL h; + h[ 1 ] := 1; FOR i FROM 2 TO n DO - hs[ i ] := hs[ i - 1 ] + ( 1 / i ) + h[ i ] := h[ i - 1 ] + ( 1 / i ) OD; - hs + h END # HARMONIC # ; # find the first 20 000 harmonic numbers # []REAL h = HARMONIC 20 000; @@ -21,8 +21,7 @@ BEGIN # find some harmonic numbers, Hn is the sum of the reciprocals of 1..n # FOR i TO UPB h DO IF h[ i ] > rqd real THEN # found the first harmonic number greater than rqd real # - print( ( "Position of the first harmonic number > ", whole( rqd int, -2 ) ) ); - print( ( ": ", whole( i, 0 ), newline ) ); + print( ( "Position of the first harmonic number > ", whole( rqd int, -2 ), ": ", whole( i, 0 ), newline ) ); rqd int +:= 1; rqd real +:= 1 FI diff --git a/Task/Harmonic-series/Ada/harmonic-series.adb b/Task/Harmonic-series/Ada/harmonic-series.adb deleted file mode 100644 index 4e1c360707..0000000000 --- a/Task/Harmonic-series/Ada/harmonic-series.adb +++ /dev/null @@ -1,41 +0,0 @@ -with Ada.Text_IO; - -procedure Harmonic_Numbers is - type Harmonic_State is record - N : Positive := 1; - Hn : Float := 1.0; - end record; - - procedure Iterate_Harmonics (Hs : in out Harmonic_State; Max_Steps : Positive := 1; Stop : Float := Float'Last) is - begin - for I in 1 .. Max_Steps loop - exit when Hs.Hn > Stop; - Hs.N := Hs.N + 1; - Hs.Hn := Hs.Hn + 1.0 / Float (Hs.N); - end loop; - end Iterate_Harmonics; - - procedure Show_First_Harmonics (N : Positive) is - Hs : Harmonic_State; - begin - for I in 1 .. N loop - Ada.Text_IO.Put_Line (Hs.N'Image & " => " & Hs.Hn'Image); - Iterate_Harmonics (Hs); - end loop; - end Show_First_Harmonics; - - -- Assume Floats is in order - type Floats is array (Positive range <>) of Float; - procedure Show_Harmonics_Greater (Ns : Floats) is - Hs : Harmonic_State; - begin - for I of Ns loop - Iterate_Harmonics (Hs, Positive'Last, I); - Ada.Text_IO.Put_Line (">" & I'Image & ":" & Hs.N'Image & " => " & Hs.Hn'Image); - end loop; - end Show_Harmonics_Greater; - -begin - Show_First_Harmonics (20); - Show_Harmonics_Greater ((1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)); -end Harmonic_Numbers; diff --git a/Task/Harmonic-series/BQN/harmonic-series.bqn b/Task/Harmonic-series/BQN/harmonic-series.bqn deleted file mode 100644 index 2d5eb490b2..0000000000 --- a/Task/Harmonic-series/BQN/harmonic-series.bqn +++ /dev/null @@ -1,6 +0,0 @@ -Harmonic ← +`1÷∘+↕ - -⟨ - > 8↑⟜•Fmt¨ 5e¯7+ Harmonic 20 - 1+⍉(⊣≍(⌈ Harmonic 12400)⊐2+⊢)↕10 -⟩ diff --git a/Task/Harmonic-series/Bruijn/harmonic-series.bruijn b/Task/Harmonic-series/Bruijn/harmonic-series.bruijn deleted file mode 100644 index 747d370e68..0000000000 --- a/Task/Harmonic-series/Bruijn/harmonic-series.bruijn +++ /dev/null @@ -1,16 +0,0 @@ -:import std/List . -:import std/Combinator . -:import std/Math/Rational Q -:import std/Number N - -# fun Church iteration hack -harmonic [0 &[[(Q.add 1 op) : N.++0]] start [[1]]] ⧗ Unary → Rational - op (+1) : N.--0 - start (+0.0f) : (+1) - -custom-gt? &[[[N.gt? 2 (N.mul 0 N.++1)]]] ⧗ Rational → Νumber → Boolean - -main [φ cons first-20 first-10-above (harmonic <$> (iterate [[[1 (2 1 0)]]] (+0u)))] - first-20 take (+20) - first-10-above [take (+10) first-above] - first-above [find-index [custom-gt? 0 1] 1] <$> (iterate N.inc (+0)) diff --git a/Task/Harmonic-series/C-sharp/harmonic-series.cs b/Task/Harmonic-series/C-sharp/harmonic-series.cs deleted file mode 100644 index 2fc08009b4..0000000000 --- a/Task/Harmonic-series/C-sharp/harmonic-series.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Numerics; - -public class BigRational -{ - public BigInteger Numerator { get; private set; } - public BigInteger Denominator { get; private set; } - - public BigRational(BigInteger numerator, BigInteger denominator) - { - if (denominator == 0) - throw new ArgumentException("Denominator cannot be zero.", nameof(denominator)); - - BigInteger gcd = BigInteger.GreatestCommonDivisor(numerator, denominator); - Numerator = numerator / gcd; - Denominator = denominator / gcd; - - if (Denominator < 0) - { - Numerator = -Numerator; - Denominator = -Denominator; - } - } - - public static BigRational operator +(BigRational a, BigRational b) - { - return new BigRational(a.Numerator * b.Denominator + b.Numerator * a.Denominator, a.Denominator * b.Denominator); - } - - public override string ToString() - { - return $"{Numerator}/{Denominator}"; - } -} - -class Program -{ - static BigRational Harmonic(int n) - { - BigRational sum = new BigRational(0, 1); - for (int i = 1; i <= n; i++) - { - BigRational r = new BigRational(1, i); - sum += r; - } - return sum; - } - - static void Main(string[] args) - { - Console.WriteLine("The first 20 harmonic numbers and the 100th, expressed in rational form, are:"); - int[] numbers = new int[21]; - for (int i = 1; i <= 20; i++) - { - numbers[i - 1] = i; - } - numbers[20] = 100; - foreach (int i in numbers) - { - Console.WriteLine($"{i,3} : {Harmonic(i)}"); - } - - Console.WriteLine("\nThe first harmonic number to exceed the following integers is:"); - const int limit = 10; - for (int i = 1, n = 1; i <= limit; n++) - { - double h = 0; - for (int j = 1; j <= n; j++) - { - h += 1.0 / j; - } - if (h > i) - { - Console.WriteLine($"integer = {i,2} -> n = {n,6} -> harmonic number = {h,9:F6} (to 6dp)"); - i++; - } - } - } -} diff --git a/Task/Harmonic-series/C/harmonic-series.c b/Task/Harmonic-series/C/harmonic-series.c deleted file mode 100644 index db4f01b2d4..0000000000 --- a/Task/Harmonic-series/C/harmonic-series.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -/* return nth harmonic number */ -double harmonic(int n) { - double h, i; - h = 0; - for (i = 1; i <= (double) n; i += 1.0) - h += 1 / i; - return h; -} - -int main(void) { - int i, n; - printf("First 20 harmonic numbers:\n"); - for (i = 1; i <= 20; i++) - printf("%2d %8.6lf\n", i, harmonic(i)); - for (i = 1; i <= 5; i++) { - int n = 2; - while (harmonic(n) <= (double) i) n++; - printf("First term > %d is at position %d\n", i, n); - } - return EXIT_SUCCESS; -} diff --git a/Task/Harmonic-series/CBASIC/harmonic-series.basic b/Task/Harmonic-series/CBASIC/harmonic-series.basic deleted file mode 100644 index 35bb0c4f57..0000000000 --- a/Task/Harmonic-series/CBASIC/harmonic-series.basic +++ /dev/null @@ -1,19 +0,0 @@ -limit = 20 -h = 0 -print "First";limit;"numbers in the harmonic series" -for i = 1 to limit - h = h + 1 / i - print using "## #.#####"; i; h -next i - -for i = 1 to 5 - h = 1 - n = 2 - while h <= i - h = h + 1 / n - n = n + 1 - wend - print "Position of first harmonic number >"; i; "is at"; n-1 -next i - -end diff --git a/Task/Harmonic-series/COBOL/harmonic-series.cob b/Task/Harmonic-series/COBOL/harmonic-series.cobol similarity index 100% rename from Task/Harmonic-series/COBOL/harmonic-series.cob rename to Task/Harmonic-series/COBOL/harmonic-series.cobol diff --git a/Task/Harmonic-series/Craft-Basic/harmonic-series.basic b/Task/Harmonic-series/Craft-Basic/harmonic-series.basic deleted file mode 100644 index 0aabb0830e..0000000000 --- a/Task/Harmonic-series/Craft-Basic/harmonic-series.basic +++ /dev/null @@ -1,34 +0,0 @@ -precision 5 - -print "the first twenty harmonic numbers are:" - -for n = 1 to 20 - - let h = h + 1 / n - print n, tab, h - -next n - -print newline, "the nth index of the first harmonic number that exceeds the nth integer:" - -let h = 1 -let n = 2 - -for i = 2 to 10 - - do - - if h < i then - - let h = h + 1 / n - let n = n + 1 - - endif - - wait - - loop h < i - - print tab, n - 1, - -next i diff --git a/Task/Harmonic-series/Delphi/harmonic-series.pas b/Task/Harmonic-series/Delphi/harmonic-series.delphi similarity index 100% rename from Task/Harmonic-series/Delphi/harmonic-series.pas rename to Task/Harmonic-series/Delphi/harmonic-series.delphi diff --git a/Task/Harmonic-series/DuckDB/harmonic-series.duckdb b/Task/Harmonic-series/DuckDB/harmonic-series.duckdb deleted file mode 100644 index c0297fcc3c..0000000000 --- a/Task/Harmonic-series/DuckDB/harmonic-series.duckdb +++ /dev/null @@ -1,21 +0,0 @@ -# If mx > 0, then return a table of the first mx harmonic numbers, -# otherwise return a table with h up to: floor(h) < - mx -create or replace function harmonic_table(mx) as table ( - with recursive cte(ix,h) as ( - select 1 as ix, 1::DOUBLE as h - union all - select ix+1, h + 1/(ix+1) - from cte - where if (mx>0, ix < mx, floor(h) < - mx) - ) - from cte -); - -# First 20: -from harmonic_table(20); - -# Milestones: -from ( - select ix, lag(h) over () as hlag, h - from harmonic_table(-10) ) -where ceil(hlag) = trunc(h); diff --git a/Task/Harmonic-series/EasyLang/harmonic-series.easy b/Task/Harmonic-series/EasyLang/harmonic-series.easy deleted file mode 100644 index fbf03db1cf..0000000000 --- a/Task/Harmonic-series/EasyLang/harmonic-series.easy +++ /dev/null @@ -1,17 +0,0 @@ -numfmt 2 5 -print "The first twenty harmonic numbers are:" -for n = 1 to 20 - h += 1 / n - print n & " " & h -. -print "" -print "The first harmonic number greater than: " -h = 1 -n = 2 -for i = 2 to 10 - while h < i - h += 1 / n - n += 1 - . - print i & " is " & h & ", at position " & n - 1 -. diff --git a/Task/Harmonic-series/Fortran/harmonic-series.f b/Task/Harmonic-series/Fortran/harmonic-series.f deleted file mode 100644 index 2ab5783463..0000000000 --- a/Task/Harmonic-series/Fortran/harmonic-series.f +++ /dev/null @@ -1,83 +0,0 @@ -program harmonic_numbers - use :: iso_fortran_env, only: int64, output_unit - implicit none - integer, parameter :: real64 = selected_real_kind(15, 307) - - type :: fraction - integer(int64) :: numerator - integer(int64) :: denominator - end type fraction - - integer :: i, target_int - type(fraction) :: h_exact - real(real64) :: sum_h, h_decimal - character(len=200) :: fmt_str - - ! Print first 20 harmonic numbers as fractions - write(output_unit, '(a)') "## First 20 Harmonic Numbers" - write(output_unit, '(a)') "**Fractional Form**" - h_exact = fraction(0_int64, 1_int64) - do i = 1, 20 - h_exact = add_reciprocal(h_exact, i) - write(output_unit, '(i2, ": ", i0, "/", i0)') i, h_exact%numerator, h_exact%denominator - end do - - ! Print decimal approximations - write(output_unit, '(/, a)') "**Decimal Approximations**" - h_exact = fraction(0_int64, 1_int64) - do i = 1, 20 - h_exact = add_reciprocal(h_exact, i) - h_decimal = real(h_exact%numerator, real64) / real(h_exact%denominator, real64) - write(output_unit, '(i2, ": ", f0.12)') i, h_decimal - end do - - ! Find positions where harmonic numbers exceed integers 1-10 - write(output_unit, '(/, a)') "## Positions Where H? First Exceeds Integers" - write(output_unit, '(a)') "| Target | Position (n) | Decimal Approximation |" - write(output_unit, '(a)') "|--------|--------------|------------------------|" - write(fmt_str, '(a)') '(a, i2, a, T10, A, i0,T25, a, f0.6, T50,a)' - - do target_int = 1, 10 - sum_h = 0._real64 - i = 0 - do - i = i + 1 - sum_h = sum_h + 1.0_real64 / real(i, real64) - if (sum_h > real(target_int, real64)) then - if (target_int <= 5 .or. target_int >= 6) then - write(output_unit, FMT_STR) "| **", target_int, "**","| ", i, & - "| ", real(sum_h, real64), "|" - end if - exit - end if - end do - end do - -contains - - function add_reciprocal(h, n) result(new_h) - type(fraction), intent(in) :: h - integer, intent(in) :: n - type(fraction) :: new_h - integer(int64) :: common_denominator, new_numerator, divisor - - common_denominator = h%denominator * int(n, int64) - new_numerator = h%numerator * int(n, int64) + h%denominator - divisor = gcd(new_numerator, common_denominator) - - new_h%numerator = new_numerator / divisor - new_h%denominator = common_denominator / divisor - end function add_reciprocal - - recursive function gcd(a, b) result(greatest_common_divisor) - integer(int64), intent(in) :: a, b - integer(int64) :: greatest_common_divisor - - if (b == 0) then - greatest_common_divisor = a - else - greatest_common_divisor = gcd(b, mod(a, b)) - end if - end function gcd - -end program harmonic_numbers diff --git a/Task/Harmonic-series/Julia/harmonic-series-1.jl b/Task/Harmonic-series/Julia/harmonic-series-1.julia similarity index 100% rename from Task/Harmonic-series/Julia/harmonic-series-1.jl rename to Task/Harmonic-series/Julia/harmonic-series-1.julia diff --git a/Task/Harmonic-series/Julia/harmonic-series-2.jl b/Task/Harmonic-series/Julia/harmonic-series-2.julia similarity index 100% rename from Task/Harmonic-series/Julia/harmonic-series-2.jl rename to Task/Harmonic-series/Julia/harmonic-series-2.julia diff --git a/Task/Harmonic-series/Maxima/harmonic-series.maxima b/Task/Harmonic-series/Maxima/harmonic-series.maxima deleted file mode 100644 index 2cc5d0f540..0000000000 --- a/Task/Harmonic-series/Maxima/harmonic-series.maxima +++ /dev/null @@ -1,10 +0,0 @@ -harmonic(n):=apply("+",1/makelist(i,i,n))$ - -first_greater_than_n(len):=block(i:1,result:[],while harmonic(i)<=len do (result:endcons(i,result),i:i+1),last(result)+1)$ - -/* Test cases */ -/* First 20 harmonic numbers */ -makelist(harmonic(j),j,20); - -/* First harmonic number that exceeds a positive integer from 1 to 5 */ -makelist(first_greater_than_n(k),k,5); diff --git a/Task/Harmonic-series/OCaml/harmonic-series-1.ml b/Task/Harmonic-series/OCaml/harmonic-series-1.ml deleted file mode 100644 index 0ace1720f1..0000000000 --- a/Task/Harmonic-series/OCaml/harmonic-series-1.ml +++ /dev/null @@ -1,9 +0,0 @@ -let series = - Seq.scan (fun sum i -> Q.(sum + inv ~$i)) Q.one (Seq.ints 2) - -let positions = - Seq.unfold - (fun (n, s) -> - Seq.uncons (Seq.drop_while (fun iq -> Q.(n >= snd iq)) s) - |> Option.map (fun (iq, s) -> fst iq, Q.(n + one, s))) - (Q.one, Seq.zip (Seq.ints 1) series) diff --git a/Task/Harmonic-series/OCaml/harmonic-series-2.ml b/Task/Harmonic-series/OCaml/harmonic-series-2.ml deleted file mode 100644 index 8350a4ae7d..0000000000 --- a/Task/Harmonic-series/OCaml/harmonic-series-2.ml +++ /dev/null @@ -1,4 +0,0 @@ -let _ = - let print fmt = Format.printf (fmt ^^ "\n") in - Seq.iteri (fun i h -> print "H(%d) =\t%a" (i + 1) Q.pp_print h) (Seq.take 20 series); - Seq.iteri (fun i n -> print "nth harmonic > %d:\t%d" (i + 1) n) (Seq.take 10 positions) diff --git a/Task/Harmonic-series/OCaml/harmonic-series-3.ml b/Task/Harmonic-series/OCaml/harmonic-series-3.ml deleted file mode 100644 index 3e25736172..0000000000 --- a/Task/Harmonic-series/OCaml/harmonic-series-3.ml +++ /dev/null @@ -1,7 +0,0 @@ -module Q = struct - include Stdlib.Float - let (~$) = of_int - let (+) = add - let inv = div 1. - let pp_print = Stdlib.Format.pp_print_float -end diff --git a/Task/Harmonic-series/Oberon-07/harmonic-series.oberon b/Task/Harmonic-series/Oberon-07/harmonic-series.oberon deleted file mode 100644 index c0fb7af5d8..0000000000 --- a/Task/Harmonic-series/Oberon-07/harmonic-series.oberon +++ /dev/null @@ -1,37 +0,0 @@ -MODULE HarmonicSeries; (* find some harmonic numbers, Hn is the sum of the reciprocals of 1..n *) - IMPORT Out; - - VAR h : ARRAY 20001 OF REAL; - rqdInt, i : INTEGER; - rqdReal : REAL; - - PROCEDURE harmonic( VAR hs : ARRAY OF REAL ); (* sets hs to the first LEN(hs) - 1 Harmonic numbers *) - VAR i : INTEGER; (* hs[0] is unused *) - BEGIN - hs[ 1 ] := 1.0; - FOR i := 2 TO LEN( hs ) - 1 DO - hs[ i ] := hs[ i - 1 ] + ( 1.0 / FLT( i ) ) - END - END harmonic ; - -BEGIN - - harmonic( h ); (* find the first 20 000 harmonic numbers *) - - FOR i := 1 TO 20 DO (* show the first 20 harmonic numbers *) - Out.Int( i, 2 );Out.String( ":" );Out.Real( h[ i ], 14 );Out.Ln - END; - - (* find the positions of the first harmonic number > n where n in 1... *) - rqdInt := 1; - rqdReal := 1.0; - FOR i := 1 TO LEN( h ) - 1 DO - IF h[ i ] > rqdReal THEN - (* found the first harmonic number greater than rqdReal *) - Out.String( "Position of the first harmonic number > " );Out.Int( rqdInt, 2 ); - Out.String( ": " );Out.Int( i, 0 );Out.Ln; - INC( rqdInt ); - rqdReal := FLT( rqdInt ) - END - END -END HarmonicSeries. diff --git a/Task/Harmonic-series/PascalABC.NET/harmonic-series.pas b/Task/Harmonic-series/PascalABC.NET/harmonic-series.pas deleted file mode 100644 index e767fc50cc..0000000000 --- a/Task/Harmonic-series/PascalABC.NET/harmonic-series.pas +++ /dev/null @@ -1,17 +0,0 @@ -function H(n: integer): real := (1..n).Sum(i -> 1/i); - -begin - for var i:=1 to 20 do - Println($'{i,2}: {H(i),10:f8}'); - var i := 1; - var num := 1; - while num < 11 do - begin - if H(i) > num then - begin - Println('Position of the first harmonic number >',num,':',i); - num += 1; - end; - i += 1; - end; -end. diff --git a/Task/Harmonic-series/Phix/harmonic-series-1.phix b/Task/Harmonic-series/Phix/harmonic-series-1.phix index 458bbff449..757038f636 100644 --- a/Task/Harmonic-series/Phix/harmonic-series-1.phix +++ b/Task/Harmonic-series/Phix/harmonic-series-1.phix @@ -1,24 +1,26 @@ -with javascript_semantics -include mpfr.e -integer n = 1, gn = 1, lim = iff(platform()=JS?9:10) -mpq hn = mpq_init_set_si(1) -sequence gt = {} -puts(1,"First twenty harmonic numbers as rationals:\n") -while gn<=lim do - if n<=20 then - printf(1,"%18s%n",{mpq_get_str(hn),rmdr(n,5)=0}) - end if - if n=100 then - printf(1,"\nOne Hundredth:\n%s\n\n",{mpq_get_str(hn)}) - end if - if mpq_cmp_si(hn,gn)>0 then - gt &= n - gn += 1 - end if - n += 1 - mpq_add_si(hn,hn,1,n) -end while -printf(1,"(one based) Index of first value:\n") -for i,g in gt do - printf(1," greater than %2d: %,6d (%s term)\n",{i,g,ordinal(g)}) -end for +(phixonline)--> + requires("0.8.4") + include mpfr.e + integer n = 1, gn = 1, lim = iff(platform()=JS?8:10) + mpq hn = mpq_init_set_si(1) + sequence gt = {} + puts(1,"First twenty harmonic numbers as rationals:\n") + while gn<=lim do + if n<=20 then + printf(1,"%18s%s",{mpq_get_str(hn),iff(mod(n,5)?" ","\n")}) + end if + if n=100 then + printf(1,"\nOne Hundredth:\n%s\n\n",{mpq_get_str(hn)}) + end if + if mpq_cmp_si(hn,gn)>0 then + gt &= n + gn += 1 + end if + n += 1 + mpq_add_si(hn,hn,1,n) + end while + printf(1,"(one based) Index of first value:\n") + for i=1 to length(gt) do + printf(1," greater than %2d: %,6d (%s term)\n",{i,gt[i],ordinal(gt[i])}) + end for + + integer n = 1, gn = 1 + atom hn = 1 + sequence gt = {} + puts(1,"First twenty harmonic numbers as fractions:\n") + while gn<=10 do + if n<=20 then + printf(1,"%18.15f%s",{hn,iff(mod(n,5)?" ","\n")}) + end if + if n=100 then + printf(1,"\nOne Hundredth: %18.15f\n\n",{hn}) + end if + if hn>gn then + gt &= n + gn += 1 + end if + n += 1 + hn += 1/n + end while + printf(1,"(one based) Index of first value:\n") + for i=1 to length(gt) do + printf(1," greater than %2d: %,6d (%s term)\n",{i,gt[i],ordinal(gt[i])}) + end for + {} = wait_key() + + with javascript_semantics + constant A = {{27,"Jonah"}, + {18,"Alan"}, + {28,"Glory"}, + {18,"Popeye"}, + {28,"Alan"}}, + B = {{"Jonah","Whales"}, + {"Jonah","Spiders"}, + {"Alan", "Ghosts"}, + {"Alan", "Zombies"}, + {"Glory","Buffy"}}, + jA = 2, + jB = 1, + MB = new_dict() + sequence C = {} + for i=1 to length(B) do + object key = B[i][jB] + object data = getd(key,MB) + if data=0 then + data = {B[i]} + else + data = append(data,B[i]) + end if + putd(key,data,MB) + end for + for i=1 to length(A) do + object data = getd(A[i][jA],MB) + if sequence(data) then + for j=1 to length(data) do + C = append(C,{A[i],data[j]}) + end for + end if + end for + destroy_dict(MB) + pp(C,{pp_Nest,1}) +( (age,age...), (nemesis,...) ) if (r:=d.find(name)){ diff --git a/Task/Haversine-formula/ALGOL-W/haversine-formula.alg b/Task/Haversine-formula/ALGOL-W/haversine-formula.alg index 8e58f6c95f..9fc4fa5d35 100644 --- a/Task/Haversine-formula/ALGOL-W/haversine-formula.alg +++ b/Task/Haversine-formula/ALGOL-W/haversine-formula.alg @@ -16,8 +16,8 @@ begin % compute the distance between places using the Haversine formula % real d; integer mi, km; d := distance( 36.12, -86.67, 33.94, -118.4 ); - km := round( d ); - mi := round( d / 1.609344 ); - writeon( i_w := 4, s_w := 0, "distance: ", km, " km (", mi, " mi.)" ) + mi := round( d ); + km := round( d / 1.609344 ); + writeon( i_w := 4, s_w := 0, "distance: ", mi, " km (", km, " mi.)" ) end end. diff --git a/Task/Haversine-formula/Ada/haversine-formula.adb b/Task/Haversine-formula/Ada/haversine-formula.ada similarity index 100% rename from Task/Haversine-formula/Ada/haversine-formula.adb rename to Task/Haversine-formula/Ada/haversine-formula.ada diff --git a/Task/Haversine-formula/Agena/haversine-formula.agena b/Task/Haversine-formula/Agena/haversine-formula.agena deleted file mode 100644 index cb1dad8071..0000000000 --- a/Task/Haversine-formula/Agena/haversine-formula.agena +++ /dev/null @@ -1,18 +0,0 @@ -scope # compute the distance between places using the Haversine formula - - local proc distance( th1Deg :: number, ph1Deg :: number, th2Deg :: number, ph2Deg :: number ) :: number - local constant ph1 := ( ph1Deg - ph2Deg ) * radians; - local constant th1 := th1Deg * radians; - local constant th2 := th2Deg * radians; - local constant dz := sin( th1 ) - sin( th2 ); - local constant dx := cos( ph1 ) * cos( th1 ) - cos( th2 ); - local constant dy := sin( ph1 ) * cos( th1 ); - return arcsin( sqrt( dx * dx + dy * dy + dz * dz ) / 2 ) * 2 * 6371 - end; - - scope - local constant d := distance( 36.12, -86.67, 33.94, -118.4 ); - local constant km, constant mi := round( d ), round( d / 1.609344 ); - printf( "distance: %4d km (%4d mi.)", km, mi ) - epocs -epocs diff --git a/Task/Haversine-formula/Amazing-Hopper/haversine-formula.hopper b/Task/Haversine-formula/Amazing-Hopper/haversine-formula.hopper deleted file mode 100644 index 2990f4560e..0000000000 --- a/Task/Haversine-formula/Amazing-Hopper/haversine-formula.hopper +++ /dev/null @@ -1,40 +0,0 @@ -/* fórmula de Haversine para distancias en una - superficie esférica */ - -#include - -#define MIN 60 -#define SEG 3600 -#define RADIO 6372.8 -#define UNAMILLA 1.609344 - -algoritmo - - números ( lat1, lon1, lat2, lon2, dlat, dlon, millas ) - - si ' total argumentos es (9) ' // LAT1 M LON1 M LAT2 M LON2 M - #basic{ lat1 = narg(2) + narg(3)/MIN - lon1 = narg(4) + narg(5)/MIN - lat2 = narg(6) + narg(7)/MIN - lon2 = narg(8) + narg(9)/MIN } - - sino si ' total argumentos es (13) ' // LAT1 M LON1 M S LAT2 M LON2 M S - #basic{ lat1 = narg(2) + narg(3)/MIN + narg(4)/SEG - lon1 = narg(5) + narg(6)/MIN + narg(7)/SEG - lat2 = narg(8) + narg(9)/MIN + narg(10)/SEG - lon2 = narg(11) + narg(12)/MIN + narg(13)/SEG } - sino - imprimir("Modo de uso:\ndist.bas La1 M [S] Lo1 M [S] La2 M [S] Lo2 M [S]\n") - término prematuro - fin si - - #basic{ - dlat = sin(radian(lat2 - lat1)/2)^2 - dlon = sin(radian(lon2 - lon1)/2)^2 - RADIO*(2*arc sin(sqrt(dlat + cos(radian(lat1)) * cos(radian(lat2)) * dlon ))) - } - - ---copiar en 'millas'---, " km. (",millas,dividido por (UNA MILLA)," mi.)\n" - decimales '2', imprimir - -terminar diff --git a/Task/Haversine-formula/Bc/haversine-formula.bc b/Task/Haversine-formula/Bc/haversine-formula.bc index eaeea4816d..3aad71d5b6 100644 --- a/Task/Haversine-formula/Bc/haversine-formula.bc +++ b/Task/Haversine-formula/Bc/haversine-formula.bc @@ -1,11 +1,8 @@ #!/bin/sh #- -# © 2021 mirabilos Ⓕ CC0 or MirBSD +# © 2021 mirabilos Ⓕ CC0; implementation of Haversine GCD from public sources # -# implementation of Haversine GCD from public sources -# output is in metres (rounded to millimetres), error < ¼% -# -# now developed online: (user/pass public) +# now developed online: # https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=useful-scripts/mirkarte.git;a=blob;f=geo.sh;hb=HEAD if test "$#" -ne 4; then @@ -26,8 +23,8 @@ export BC_ENV_ARGS # h: haversine intermediate # i,j: (lat,lon) point 1 # x,y: (lat,lon) point 2 -# k: delta lat/ΔΦ -# l: delta lon/Δλ +# k: delta lat +# l: delta lon # m: sin(k/2) (square root of hav(k)) # n: sin(l/2) ( partial haversine ) # n(x): arcsin(x) @@ -35,7 +32,7 @@ export BC_ENV_ARGS # v(x): sign (Vorzeichen) # w(x): min(1, sqrt(x)) (Wurzel) -exec bc -l <<-EOF +bc -l <<-EOF scale=64 define n(x) { if (x == -1) return (-2 * a(1)) @@ -62,8 +59,7 @@ define w(x) { return (sqrt(x)) } /* WGS84 reference ellipsoid: große Halbachse (metres), Abplattung */ -/* (6378137 in WGS84); this radius from Astronomical Almanac 2021 */ -i = 6378136.600 +i = 6378137.000 x = 1/298.257223563 /* other axis */ j = i * (1 - x) @@ -84,3 +80,5 @@ h = ((m * m) + (c(i) * c(x) * n * n)) d = 2 * r * n(w(h)) r(d, 3) EOF + +# output is in metres, rounded to millimetres, error < ¼% in WGS84 diff --git a/Task/Haversine-formula/Crystal/haversine-formula.cr b/Task/Haversine-formula/Crystal/haversine-formula.crystal similarity index 100% rename from Task/Haversine-formula/Crystal/haversine-formula.cr rename to Task/Haversine-formula/Crystal/haversine-formula.crystal diff --git a/Task/Haversine-formula/Delphi/haversine-formula.pas b/Task/Haversine-formula/Delphi/haversine-formula.delphi similarity index 100% rename from Task/Haversine-formula/Delphi/haversine-formula.pas rename to Task/Haversine-formula/Delphi/haversine-formula.delphi diff --git a/Task/Haversine-formula/DuckDB/haversine-formula.duckdb b/Task/Haversine-formula/DuckDB/haversine-formula.duckdb deleted file mode 100644 index f301d80fe5..0000000000 --- a/Task/Haversine-formula/DuckDB/haversine-formula.duckdb +++ /dev/null @@ -1,7 +0,0 @@ -# install spatial; -- if required -load spatial; - -select [lat1, lon1], [lat2, lon2], - ST_Distance_sphere( ST_Point(lat1, lon1), ST_Point(lat2,lon2)) as "Haversine (m)", - ST_Distance_spheroid(ST_Point(lat1, lon1), ST_Point(lat2,lon2)) as "ellipsoid (m)" -from (select 36.12 as lat1, -86.67 as lon1, 33.94 at lat2, -118.40 as lon2); diff --git a/Task/Haversine-formula/EDSAC-order-code/haversine-formula.edsac b/Task/Haversine-formula/EDSAC-order-code/haversine-formula.edsac deleted file mode 100644 index e6a18551aa..0000000000 --- a/Task/Haversine-formula/EDSAC-order-code/haversine-formula.edsac +++ /dev/null @@ -1,181 +0,0 @@ -[Haversine formula, for Rosetta Code.] -[EDSAC, initial orders 2.] - [Arrange the storage] - T49K P56F [L, 35 locations: library s/r R4 to read integer.] - [Can overwrite R9 once R9 is no longer needed.] - T46K P92F [N, 35 locations: library s/r P7 (print integer)] - T52K P128F [A, 33 locations: library subroutine T4 (arccos)] - T53K P162F [B, 44 locations: 1ibrary subroutine T1 (cos)] - T54K P206F [C, 10 locations: wrapper for library subroutine T1] - T51K P216F [G, 24 locations: inverse haversine function] - T45K P240F [H, 36 locations: haversine function] - T55K P276F [V, 11 locations: constants] - T47K P288F [M, 92 locations: main routine] -[----------------------------------------------------------------------------] -[Library subroutine R9 to read integers from tape at load time.] -[Must be placed at location 56; occupies 15 locations.] - T56K -GKT20FVDL8FA40DUDTFI40FA40FS39FG@S2FG23FA5@T5@E4@ -[----------------------------------------------------------------------------] -[Library subroutine M3. Prints header at load time and is then overwritten.] -[In this program, also sets teleprinter to figures.] -PFGKIFAFRDLFUFOFE@A6FG@E8FEZPF - *DISTANCES!IN!METRES@&WITH!RADIUS# - .. PK [after header, blank tape and PK (WWG, 1951, page 91)] -[----------------------------------------------------------------------------] -[Constants. Load at even address.] - E25K TV GK - E69K [at load time, call library s/r R9 to read 35-bit contants] - T#V [tell R9 where to store constants] - [0] 1800000000F [180 degrees, in units of 10^-7 degree] - [2] 900000000F [90 ditto] - [4] 16097821018F [for changing angle unit to radians] - [6] 13493037750F [pi/4 as EDSAC integer, i.e. times 2^34] - [8] 6371100# [Earth radius in metres, from MK-61/52 solution] - T10Z [resume normal loading] - [10] RF [17-bit 1/4] -[----------------------------------------------------------------------------] -[Main routine. Load at even address.] - E25K TM GK -[35-bit variables, general workspace] - [0] [2] [4] [6] [8] -[17-bit variables] - [10] [number of examples] - [11] [example number] - T12Z [variablss are not initialized; skip over them at load time] -[17-bit constants] - [12] PD [1] - [13] CF [ teleprinter colon (in figures mode)] - [14] @F [15] &F [16] K4096F [CR, LF, null] - [Enter with acc = 0] - [17] A8#V TD [pass Earth's radius to printer routine] - A19@ GN [finish header: print radius followed by CR, LF] - O14@ O15@ - A23@ GL [call library s/r R4, 0D := number of examples] - AF T10@ [store (assume < 2^16)] - [Here acc = example number just done (0 first time)] - [27] S10@ E98@ [if all done, jump to exit] - A10@ A12@ T11@ [inc and store example number] - TD A11@ TF [0D := example number, extended to 35 bits] - A35@ GN O13@ [print example number followed by colon] - [Use library subroutine R4 to read data from tape to 0D.] - [Coordinates are lat1, lon1, lat2, lon2.] - A38@ GL AD U#@ T4D [lat1 to work{0} and 4D] - A43@ GC A4D T2#@ [0.5*cos(lat1) to work{1}] - A47@ GL AD T8#@ [lon1 to work{4}] - A51@ GL AD U4#@ T4D [lat2 to work{2} and 4D] - A56@ GC A4D T6#@ [0.5*cos(lat2) to work{3}] - A60@ GL AD S8#@ T4D [lon2 - lon1 to 4D] - A65@ GH [0.5*hav(lon2 - lon1) to 4D] - H2#@ V4D LD YF T4D [times cos(lat1) to 4D] - H6#@ V4D LD YF T8#@ [times cos(lat2) to work{4}] - A#@ S4#@ T4D [lat1 - lat2 to 4D] - A80@ GH A4D [0.5*hav(lat1 - lat2) to acc] - A8#@ T4D [add product from above, sum to 4D] - A85@ GG H4D [mult reg := angle/4 in radians] - V8#V L1F YF TD [times radius*4, to 0D for printing] - A92@ GN O14@ O15@ [print distance followed by CR, LF] - A11@ E27@ [acc := example numbr; loop back] - [Exit] - [98] O16@ [print null to flush teleprinter buffer] - ZF [stop] -[----------------------------------------------------------------------------] -[Haversine function, for Rosetta Code.] -[Input: 4D = angle x in range -360..360 deg,] - [expressed as integer multiple of 10^-7 deg.] -[Output: 4D = hav(x)/2 = (1 - cos(x))/4] -[Load at even address. Requires library subroutines R9 and T1.] - E25K TH GK - A3F T35@ [plant return link as usual] - [2] A4D E6@ [acc := x; jump if x >= 0] - T4D - [5] S4D [else x := -x] - [Here with acc = abs(x). Use symmetry about 180 deg.] - [6] S#V G10@ [jump if x < 180] - TD SD [else acc := 180 - x] - [10] A2#V [combine next 2 orders, which are shown as comments] - [A #V] [add 180: either restore x, or set x := 360 - x] - [Here 0 <= x <= 180. Use antisymmetry about 90 deg.] - [S 2 #V] [subtract 90] - E17@ [jump if x >= 90 degrees] - TD A5@ T30@ [save acc, plant S4D below] - AD G21@ [acc := x - 90, join common code] - [17] TD A2@ T30@ [save acc, plant A4D below] - SD [acc := 90 - x] - [21] A2#V [either restore x, or set x := 180 - x] - TD H4#V VD L4F YF [apply angle conversion factor] - [Here acc = x/2, now in radians. Pass it to cosine function] - T4D - A28@ GB [call cosine function; returns 4D := cos(x)/2] - [30] XF [(planted) either A4D or S4D] - RD YF A10V [divide by 2, round, add 1/4] - T4D [return haversine/2 in 4D] - [35] ZF [(planted) jump back to caller] -[----------------------------------------------------------------------------] -[Inverse haversine function.] -[Input: 4D = hav(x)/2] -[Output: 4D = x/4 in radians, where 0 <= x <= pi] - E25K TG GK - A3F T23@ [plant return link as usual] - A10V S4D LD YF [acc := 1/2 - hav(x) = cos(x)/2] - G13@ [jumo if cos(x) < 0] - T4D [pass cos(x)/2 to library subroutine T4 (arccis)] - A8@ GA AD RD [call T4, 0D ;= x/2; then acc := x/4] - E21@ [join common code] - [13] TD SD T4D [here if cos(x) < 0; set 4D := -cos(x)/2] - A16@ GA [call T4 (arccos); 0D := (pi - x)/2] - SD RD A6#V [acc := -(pi - x)/4 + pi/4 = x/4] - [21] YF T4D [round redult and return it in 4D] - [23] ZF [(planted) jump back to caller] -[----------------------------------------------------------------------------] -[Wrapper for library subroutine T1 (cosine).] -[Input: 4D = angle x as integer multiple of 10^-7 degree.] -[Output: 4D = cos(x)/2] - E25K TC GK - A3F T9@ [plant return link as usual] - H4#V V4D L4F YF T4D [4D := x/2 in radians] - A7@ GB [call T1, puts cos(x)/2 into 4D] - [9] ZF [jump back to caller] -[----------------------------------------------------------------------------] -[Library subroutine T1: calculates cos(x), where abs(x) <= pi/2] -[Input: 4D = x/2] -[Output: 4D = cos(x)/2] -[Requires library subroutine R9.] - E25K TB -GKT20FVDL8FA40DUDTFI40FA40FS39FG@S2FG23FA5@T5@E4@E13ZT32#@ -1614F73454F243967F54539267F763549741F5726623061# -TZA3FT30@H4DV4DYFT4DH4DN32#@A34#@TDNDA36#@TDNDA38#@ -TDNDA40#@TDNDA42#@TDNDYFTDNDS4DA31@YFT4DEFIFT44Z -[----------------------------------------------------------------------------] -[Library subroutine T4: calculates arccos] -[Input: 4D = cos(x)/2, assumed >= 0] -[Output: 0D = x/2 where 0 <= x <= pi/2] - E25K TA -GKA3FT28@TDA32@T6DH4DV4DL1FS29@YFE16@T4DSDA6DTDS4DT4DA6DRD -YFG4@HDN30#@YFE27@T4DS4DTDEFIFT30#ZD888FT30ZO699DT32ZK4096F -[----------------------------------------------------------------------------] -[Library subroutine P7. Prints 35-bit positive integer in 0D.] -[Up to 10 digits, right-justified, padded on left with spaces.] - E25K TN -GKA3FT26@H28#@NDYFLDT4DS27@TFH8@S8@T1FV4DAFG31@SFLDUFOFFFSF -L4FT4DA1FA27@G11@T28#ZPFT27ZP1024FP610D@524D!FO30@SFL8FE22@ -[----------------------------------------------------------------------------] -[Library subroutine R4. Reads signed integer from tape at run time.] -[Input : None] -[Output : 0D = 35-bit signed integer.] - E25K TL -GKA3FT21@T4DH6@E11@P5DJFT6FVDL4FA4DTDI4FA4FS5@G7@S5@G20@SDTDT6FEF -[----------------------------------------------------------------------------] - E25K TM GK [M parameter again] - E17Z [define entry point] - PF [acc = 0 on entry] -[----------------------------------------------------------------------------] -[Latitude and longitude of each airport, in units of 10^-7 degree.] -[Read from tape by library subroutine R4. Note that sign comes after value.] -3+ [number of examples] -361200000+866700000- [Nashville] -339400000+1184000000- [Los Angeles] -547166667+205000000+ [Kaliningrad] -431166667+1319000000+ [Vladivostok] -499133333+62916667- [St Mary's, Scilly Isles] -601919444+12436111- [Tingwall, Shetland Isles] diff --git a/Task/Haversine-formula/EasyLang/haversine-formula.easy b/Task/Haversine-formula/EasyLang/haversine-formula.easy deleted file mode 100644 index 5f50b5807f..0000000000 --- a/Task/Haversine-formula/EasyLang/haversine-formula.easy +++ /dev/null @@ -1,9 +0,0 @@ -func dist th1 ph1 th2 ph2 . - r = 6371 - ph1 -= ph2 - dz = sin th1 - sin th2 - dx = cos ph1 * cos th1 - cos th2 - dy = sin ph1 * cos th1 - return 2 * r * pi / 180 * asin (sqrt (dx * dx + dy * dy + dz * dz) / 2) -. -print dist 36.12 -86.67 33.94 -118.4 diff --git a/Task/Haversine-formula/Elena/haversine-formula.elena b/Task/Haversine-formula/Elena/haversine-formula.elena index 49527462a5..a88153e368 100644 --- a/Task/Haversine-formula/Elena/haversine-formula.elena +++ b/Task/Haversine-formula/Elena/haversine-formula.elena @@ -15,7 +15,7 @@ Haversine(lat1,lon1,lat2,lon2) ^ R * 2 * a.sqrt().arcsin() } -public Program() +public program() { console.printLineFormatted("The distance between coordinates {0},{1} and {2},{3} is: {4}", 36.12r, -86.67r, 33.94r, -118.40r, Haversine(36.12r, -86.67r, 33.94r, -118.40r)) diff --git a/Task/Haversine-formula/Elixir/haversine-formula.ex b/Task/Haversine-formula/Elixir/haversine-formula.elixir similarity index 100% rename from Task/Haversine-formula/Elixir/haversine-formula.ex rename to Task/Haversine-formula/Elixir/haversine-formula.elixir diff --git a/Task/Haversine-formula/Fennel/haversine-formula.fennel b/Task/Haversine-formula/Fennel/haversine-formula.fennel deleted file mode 100644 index d4b0b8029b..0000000000 --- a/Task/Haversine-formula/Fennel/haversine-formula.fennel +++ /dev/null @@ -1,18 +0,0 @@ -(do ;;; compute the distance between places using the Haversine formula - (fn distance [th1Deg ph1Deg th2Deg ph2Deg] - (local ph1 (math.rad (- ph1Deg ph2Deg))) - (local th1 (math.rad th1Deg)) - (local th2 (math.rad th2Deg)) - (local dz (- (math.sin th1) (math.sin th2))) - (local dx (- (* (math.cos ph1) (math.cos th1)) (math.cos th2))) - (local dy (* (math.sin ph1) (math.cos th1))) - (* (math.asin (/ (math.sqrt (+ (* dx dx) (* dy dy) (* dz dz))) 2)) 2 6371) - ) - (do - (fn round [n] (math.floor (+ n 0.49999999999))) - - (local d (distance 36.12 -86.67 33.94 -118.4)) - (local (km mi) (values (round d) (round (/ d 1.609344)))) - (print (.. "distance: " km " km (" mi " mi.)")) - ) -) diff --git a/Task/Haversine-formula/Free-Pascal-Lazarus/haversine-formula.pas b/Task/Haversine-formula/Free-Pascal/haversine-formula.pas similarity index 100% rename from Task/Haversine-formula/Free-Pascal-Lazarus/haversine-formula.pas rename to Task/Haversine-formula/Free-Pascal/haversine-formula.pas diff --git a/Task/Haversine-formula/Gambas/haversine-formula.gambas b/Task/Haversine-formula/Gambas/haversine-formula.gambas deleted file mode 100644 index c330f292a2..0000000000 --- a/Task/Haversine-formula/Gambas/haversine-formula.gambas +++ /dev/null @@ -1,21 +0,0 @@ -Public deg2rad As Float = Pi / 180 ' define grados a radianes 0.01745.. -Public radioTierra As Float = 6372.8 ' radio de la tierra en km - -Public Sub Main() - - Print "\n Distancia de Haversine entre BNA y LAX = "; Haversine(36.12, -86.67, 33.94, -118.4, radioTierra); " km" - -End - -Function Haversine(lat1 As Float, long1 As Float, lat2 As Float, long2 As Float, radio As Float) As Float - - Dim d_long As Float = deg2rad * (long1 - long2) - Dim theta1 As Float = deg2rad * lat1 - Dim theta2 As Float = deg2rad * lat2 - Dim dx As Float = Cos(d_long) * Cos(theta1) - Cos(theta2) - Dim dy As Float = Sin(d_long) * Cos(theta1) - Dim dz As Float = Sin(theta1) - Sin(theta2) - - Return ASin(Sqr(dx * dx + dy * dy + dz * dz) / 2) * radio * 2 - -End Function diff --git a/Task/Haversine-formula/Julia/haversine-formula.jl b/Task/Haversine-formula/Julia/haversine-formula.julia similarity index 100% rename from Task/Haversine-formula/Julia/haversine-formula.jl rename to Task/Haversine-formula/Julia/haversine-formula.julia diff --git a/Task/Haversine-formula/Kotlin/haversine-formula.kts b/Task/Haversine-formula/Kotlin/haversine-formula.kotlin similarity index 100% rename from Task/Haversine-formula/Kotlin/haversine-formula.kts rename to Task/Haversine-formula/Kotlin/haversine-formula.kotlin diff --git a/Task/Haversine-formula/MiniScript/haversine-formula.mini b/Task/Haversine-formula/MiniScript/haversine-formula.mini deleted file mode 100644 index 6e4952c0d7..0000000000 --- a/Task/Haversine-formula/MiniScript/haversine-formula.mini +++ /dev/null @@ -1,17 +0,0 @@ -// compute the distance between places using the Haversine formula - -distance = function( th1Deg, ph1Deg, th2Deg, ph2Deg ) - toRadians = pi / 180 - ph1 = toRadians * ( ph1Deg - ph2Deg ) - th1 = toRadians * th1Deg - th2 = toRadians * th2Deg - dz = sin( th1 ) - sin( th2 ) - dx = cos( ph1 ) * cos( th1 ) - cos( th2 ) - dy = sin( ph1 ) * cos( th1 ) - return asin( sqrt( dx * dx + dy * dy + dz * dz ) / 2 ) * 2 * 6371 -end function - -d = distance( 36.12, -86.67, 33.94, -118.4 ) -km = round( d ) -mi = round( d / 1.609344 ) -print( "distance: " + km + " km (" + mi + " mi.)" ) diff --git a/Task/Haversine-formula/NetRexx/haversine-formula.netrexx b/Task/Haversine-formula/NetRexx/haversine-formula.netrexx deleted file mode 100644 index ded11a6a34..0000000000 --- a/Task/Haversine-formula/NetRexx/haversine-formula.netrexx +++ /dev/null @@ -1,40 +0,0 @@ -/*REXX pgm calculates distance between Nashville & Los Angles airports. */ -say " Nashville: north 36° 7.2', west 86° 40.2' = 36.12°, -86.67°" -say "Los Angles: north 33° 56.4', west 118° 24.0' = 33.94°, -118.40°" -say -dist=surfaceDistance(36.12, -86.67, 33.94, -118.4) -say dist - -bef = Length(dist/1) -kdist=format(dist/1,bef,2) -mdist=format(dist/1.609344,bef,2) -ndist=format(mdist*5280/6076.1,bef,2) -say ' distance between= ' kdist " kilometers," -say ' or ' mdist " statute miles," -say ' or ' ndist " nautical or air miles." -exit /*stick a fork in it, we're done.*/ -/*----------------------------------SURFACEDISTANCE subroutine----------*/ - -method radians(x) static - return x * Math.PI / 180 - -method surfaceDistance(lat1,lon1,lat2,lon2) public static /*use haversine formula for dist.*/ - radius = 6372.8 /*earth's mean radius in km */ - dLat = radians(lat2 - lat1) - dLon = radians(lon2 - lon1) - lat1 = radians(lat1) - lat2 = radians(lat2) - - a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2) ** 2 - c = 2 * asin(sqrt(a)) - - return radius * c - -method cos(x) static - return Rexx Math.cos(x) -method sin(x) static - return Rexx Math.sin(x) -method asin(x) static - return Rexx Math.asin(x) -method sqrt(x) static - return Rexx Math.sqrt(x) diff --git a/Task/Haversine-formula/OCaml/haversine-formula.ml b/Task/Haversine-formula/OCaml/haversine-formula.ocaml similarity index 100% rename from Task/Haversine-formula/OCaml/haversine-formula.ml rename to Task/Haversine-formula/OCaml/haversine-formula.ocaml diff --git a/Task/Haversine-formula/Oberon/haversine-formula.oberon b/Task/Haversine-formula/Oberon-2/haversine-formula.oberon similarity index 100% rename from Task/Haversine-formula/Oberon/haversine-formula.oberon rename to Task/Haversine-formula/Oberon-2/haversine-formula.oberon diff --git a/Task/Haversine-formula/PascalABC.NET/haversine-formula.pas b/Task/Haversine-formula/PascalABC.NET/haversine-formula.pas deleted file mode 100644 index 8eafc78a1a..0000000000 --- a/Task/Haversine-formula/PascalABC.NET/haversine-formula.pas +++ /dev/null @@ -1,19 +0,0 @@ -const - r = 6372.8; - -function haversine(lat1, lon1, lat2, lon2: real): real; -begin - var dLat := degToRad(lat2 - lat1); - var dLon := degToRad(lon2 - lon1); - lat1 := degToRad(lat1); - lat2 := degToRad(lat2); - - var a := sin(dLat / 2) * sin(dLat / 2) + cos(lat1) * cos(lat2) * sin(dLon / 2) * sin(dLon / 2); - var c := 2 * arcsin(sqrt(a)); - - result := r * c; -end; - -begin - haversine(36.12, -86.67, 33.94, -118.40).Println; -end. diff --git a/Task/Haversine-formula/Phix/haversine-formula.phix b/Task/Haversine-formula/Phix/haversine-formula.phix index 921a3dcd5e..a5c8ad31c1 100644 --- a/Task/Haversine-formula/Phix/haversine-formula.phix +++ b/Task/Haversine-formula/Phix/haversine-formula.phix @@ -1,15 +1,14 @@ -with javascript_semantics -constant MER = 6371, -- mean earth radius, authalic(km) ---constant MER = 6372.8, -- mean earth radius, average(km) - DEG_TO_RAD = PI/180 +(phixonline)--> + function haversine(atom lat1, long1, lat2, long2) + constant MER = 6371, -- mean earth radius(km) + DEG_TO_RAD = PI/180 + lat1 *= DEG_TO_RAD + lat2 *= DEG_TO_RAD + long1 *= DEG_TO_RAD + long2 *= DEG_TO_RAD + return MER*arccos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(long2-long1)) + end function -function haversine(atom lat1, long1, lat2, long2) - lat1 *= DEG_TO_RAD - lat2 *= DEG_TO_RAD - long1 *= DEG_TO_RAD - long2 *= DEG_TO_RAD - return MER*arccos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(long2-long1)) -end function - -atom d = haversine(36.12,-86.67,33.94,-118.4) -printf(1,"Distance is %.10f km (%.10f miles)\n",{d,d/1.609344}) + atom d = haversine(36.12,-86.67,33.94,-118.4) + printf(1,"Distance is %f km (%f miles)\n",{d,d/1.609344}) + + puts(1,"Hello world!") + + puts(1,"Hello world!") + + puts(1,"Hello world!") + + -- + -- pwa\phix\hello_world.exw + -- ======================== + -- + with javascript_semantics + include pGUI.e + + IupOpen() + Ihandle lbl = IupFlatLabel("World!","EXPAND=YES, ALIGNMENT=ACENTER") + Ihandln dlg = IupDialog(lbl,"TITLE=Hello, RASTERSIZE=215x85") + IupShow(dlg) + if platform()!=JS then + IupMainLoop() + dlg = IupDestroy(dlg) + IupClose() + end if + - string ts1 = """ - this - "string"\thing""" +string ts1 = """ +this +"string"\thing""" - string ts2 = """this - "string"\thing""" +string ts2 = """this +"string"\thing""" - string ts3 = """ - _____________this - "string"\thing""" +string ts3 = """ +_____________this + "string"\thing""" - string ts4 = ` - this - "string"\thing` +string ts4 = ` +this +"string"\thing` - string ts5 = `this - "string"\thing` +string ts5 = `this +"string"\thing` - string ts6 = ` - _____________this - "string"\thing` +string ts6 = ` +_____________this + "string"\thing` - string ts7 = "this\n\"string\"\\thing" +string ts7 = "this\n\"string\"\\thing" - constant tests={ts1,ts2,ts3,ts4,ts5,ts6,ts7} - for i=1 to length(tests) do - for j=1 to length(tests) do - if tests[i]!=tests[j] then crash("error") end if - end for - end for - printf(1,""" - ____________Everything - (all %d tests) - works - just - file.""",length(tests)) - printf(1,"""`""") - printf(1,`"""`) - + with javascript_semantics + function af(string s) return max(s)<='f' and min(s)>='a' end function + function digital_root(integer n) + assert(n>=0) + while n>9 do + integer tot = 0 + while n>0 do + tot += remainder(n,10) + n = floor(n/10) + end while + n = tot + end while + return n + end function + sequence words = filter(unix_dict(4),af), + decml = apply(true,to_integer,{words,0,16}), + roots = apply(decml,digital_root), + tags = custom_sort(roots,tagset(length(roots))) -function caejasp() -- columnize/apply/extract/join/apply/sprint(...) - sequence s = columnize(apply(true,extract,{{words,decml,roots},{tags}})) - return join(apply(true,sprintf,{{"%6s -> %8d -> %d\n"},s})) -end function -printf(1," %s\n %d hex words with 4 or more letters found,\n",{caejasp(),length(tags)}) -function ge4(integer t) return length(unique(words[t]))>=4 end function -tags = filter(tags,ge4) -tags = extract(tags,reverse(custom_sort(extract(decml,tags),tagset(length(tags))))) -printf(1," %d with 4 or more distinct characters:\n\n %s\n",{length(tags),caejasp()}) + function caejasp() -- columnize/apply/extract/join/apply/sprint(...) + sequence s = columnize(apply(true,extract,{{words,decml,roots},{tags}})) + return join(apply(true,sprintf,{{"%6s -> %8d -> %d\n"},s})) + end function + printf(1," %s\n %d hex words with 4 or more letters found,\n",{caejasp(),length(tags)}) + function ge4(integer t) return length(unique(words[t]))>=4 end function + tags = filter(tags,ge4) + tags = extract(tags,reverse(custom_sort(extract(decml,tags),tagset(length(tags))))) + printf(1," %d with 4 or more distinct characters:\n\n %s\n",{length(tags),caejasp()}) + + without javascript_semantics -- (no mpfr_log() for pwa/p2js) + requires("1.0.0") -- (mpfr_set_default_prec[ision] renamed) + include mpfr.e + mpfr_set_default_precision(-23) -- (found by trial/error) + mpfr ln2 = mpfr_init(2), + hn = mpfr_init(0.5) + mpfr_log(ln2,ln2) + mpfr_div(hn,hn,ln2) + for n=1 to 17 do + mpfr_mul_si(hn,hn,n) + mpfr_div(hn,hn,ln2) + string n10 = mpfr_sprintf("%24.4Rf ",hn) + n10 &= iff(find(n10[21],"09")?"Y":"N") + printf(1,"%2d:%s\n",{n,n10}) + end for +} 'assign + +records: function [historyVar][ + historyVar\record +] + +retrieve: function [historyVar][ + result: last historyVar\record + historyVar\record: chop historyVar\record + return result +] + +current: function [historyVar][ + return last historyVar\record +] + +do [ + h: to :history [] -do :: print "Assigning three values: 1, 2, 3..." - h\assign 1 - h\assign 2 - h\assign 3 + h --> 1 + h --> 2 + h --> 3 print "\nHistory (oldest values first):" - print [">" h\records] + print [">" records h] - print ["\nCurrent value is:" h\current] + print ["\nCurrent value is:" current h] print "\nRecalling the three values..." loop 1..3 'x -> - print ["- Recalled:" h\retrieve] + print ["- Recalled:" retrieve h] print "\nHistory:" - print [">" h\records] + print [">" records h] +] diff --git a/Task/History-variables/C++/history-variables.cpp b/Task/History-variables/C++/history-variables.cpp deleted file mode 100644 index 1cb38271cd..0000000000 --- a/Task/History-variables/C++/history-variables.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -template -class with_history { -public: - with_history(const T& element) { - history.push_front(element); - } - - T get() { - return history.front(); - } - - void set(const T& element) { - history.push_front(element); - } - - std::deque get_history() { - return std::deque(history); - } - - T rollback() { - if ( history.size() > 1 ) { - history.pop_front(); - } - return history.front(); - } - -private: - std::deque history; -}; - -int main() { - with_history number(1.2345); - std::cout << "Current value of number: " << number.get() << std::endl; - - number.set(3.4567); - number.set(5.6789); - - std::cout << "Historical values of number: "; - for ( const double& value : number.get_history() ) { - std::cout << value << " "; - } - std::cout << std::endl << std::endl; - - with_history word("Goodbye"); - word.set("Farewell"); - word.set("Hello"); - - std::cout << word.get() << std::endl; - word.rollback(); - std::cout << word.get() << std::endl; - word.rollback(); - std::cout << word.get() << std::endl; - word.rollback(); - std::cout << word.get() << std::endl; - word.rollback(); -} diff --git a/Task/History-variables/C/history-variables.c b/Task/History-variables/C/history-variables.c deleted file mode 100644 index 8b26474871..0000000000 --- a/Task/History-variables/C/history-variables.c +++ /dev/null @@ -1,126 +0,0 @@ -#include -#include -#include - -// -// high address________ -// |________| length -// T *p ---> |___ ____| most recent value -// |____ ___| -// | -// |___ ____ -// |_____ __| -// |________| oldest value -// low address -// - -static size_t hv__align(void const *p, size_t z) { - return z + ((sizeof(z) - (((size_t)p + z) % sizeof(z))) % sizeof(z)); -} - -static size_t hvlen(void const *p, size_t z) { - return *(size_t *)((char *)p + hv__align(p, z)); -} - -static void *hv__malloc(size_t z) { - size_t const m = z + (2 * sizeof(z)); - void *const p = malloc(m); - if(p) { - *(size_t *)((char *)p + hv__align(p, z)) = 1; - return p; - } - perror(""); - abort(); -} - -static void *hv__realloc(void *p, size_t z, size_t n) { - size_t const u = hvlen(p, z); - size_t const o = (n > 1) ? n * z : z; - size_t const g = (u > 1) ? u * z : z; - size_t const m = o + (2 * sizeof(z)); - void *const b = (char *)p - (g - z); - p = realloc(b, m); - if(p) { - p = (char *)p + (o - z); - *(size_t *)((char *)p + hv__align(p, z)) = n; - return p; - } - perror(""); - abort(); -} - -static void *hvfree(void const *p, size_t z) { - if(p) { - size_t u = hvlen(p, z); - size_t const o = (u > 1) ? u * z : z; - free((char *)p - (o - z)); - } - return NULL; -} - -static void *hv(void const *p, size_t z) { - return p ? hv__realloc((void *)p, z, hvlen(p, z) + 1) : hv__malloc(z); -} -#define HV__TYPE(T,V) \ - T: *(T *)(V = (hv)((V), sizeof(*(V)))) -#define hv(V) _Generic(*(V), \ - HV__TYPE( char , (V)), \ - HV__TYPE( short , (V)), \ - HV__TYPE( int , (V)), \ - HV__TYPE( long , (V)), \ - HV__TYPE( long long, (V)), \ - HV__TYPE(unsigned char , (V)), \ - HV__TYPE(unsigned short , (V)), \ - HV__TYPE(unsigned int , (V)), \ - HV__TYPE(unsigned long , (V)), \ - HV__TYPE(unsigned long long, (V)), \ - HV__TYPE(float , (V)), \ - HV__TYPE(double , (V)), \ - HV__TYPE(long double , (V)) \ -) - -static void const *hvundo(void const *p, size_t z) { - return p ? hv__realloc((void *)p, z, hvlen(p, z) - 1) : p; -} -#define hvundo(V) (V = (hvundo)((V), sizeof(*(V)))) - -#define hvfree(V) (hvfree)((V), sizeof(*(V))) -#define hvlen(V) (hvlen)((V), sizeof(*(V))) - -int main(int argc, char **argv) { - char const *c = NULL; - unsigned const *u = NULL; - double const *d = NULL; - hv(c) = '1'; - hv(c) = '2'; - hv(c) = '3'; - hv(u) = 1; - hv(u) = 21; - hvundo(u); - hv(u) = 12; - hv(u) = 123; - hv(d) = 1.23; - hv(d) = 2.31; - hv(d) = 3.12; - printf("current values : '%c', %u, %g", *c, *u, *d); - putchar('\n'); - printf("char value history :"); - for(size_t n = hvlen(c), i = 0; i < n; i++) { - printf(" [%zu] '%c',", i, c[-i]); - } - putchar('\n'); - printf("unsigned value history:"); - for(size_t n = hvlen(u), i = 0; i < n; i++) { - printf(" [%zu] %4u,", i, u[-i]); - } - putchar('\n'); - printf("double value history :"); - for(size_t n = hvlen(d), i = 0; i < n; i++) { - printf(" [%zu] %4g,", i, d[-i]); - } - putchar('\n'); - hvfree(c); - hvfree(u); - hvfree(d); - return 0; -} diff --git a/Task/History-variables/Delphi/history-variables.pas b/Task/History-variables/Delphi/history-variables.delphi similarity index 100% rename from Task/History-variables/Delphi/history-variables.pas rename to Task/History-variables/Delphi/history-variables.delphi diff --git a/Task/History-variables/Elena/history-variables.elena b/Task/History-variables/Elena/history-variables.elena index f726d15563..96f171d09b 100644 --- a/Task/History-variables/Elena/history-variables.elena +++ b/Task/History-variables/Elena/history-variables.elena @@ -25,7 +25,7 @@ class HistoryVariable undo() { - if:not (previous.isEmpty()) + ifnot (previous.isEmpty()) { value := previous.pop() } @@ -40,7 +40,7 @@ class HistoryVariable string toPrintable() => this value; } -public Program() +public program() { var o := new HistoryVariable(); o.Value := 5; @@ -49,7 +49,7 @@ public Program() console.printLine(o); - o.forEach(printingLn); + o.forEach:printingLn; o.undo().undo().undo(); diff --git a/Task/History-variables/FreeBASIC/history-variables.basic b/Task/History-variables/FreeBASIC/history-variables.basic deleted file mode 100644 index 2c61e3f4d2..0000000000 --- a/Task/History-variables/FreeBASIC/history-variables.basic +++ /dev/null @@ -1,60 +0,0 @@ -REM integer history variable - -Type HistoryInt - As Integer Ptr values - As Integer cnt - As Integer capacity -End Type - -Function InitHistory() As HistoryInt Ptr - Dim As HistoryInt Ptr hist = Allocate(Sizeof(HistoryInt)) - hist->capacity = 10 - hist->values = Allocate(hist->capacity * Sizeof(Integer)) - hist->cnt = 0 - Return hist -End Function - -Sub SetInt(hist As HistoryInt Ptr, value As Integer) - If hist->cnt >= hist->capacity Then - hist->capacity *= 2 - hist->values = Reallocate(hist->values, hist->capacity * Sizeof(Integer)) - End If - - If hist->cnt = 0 Then - hist->values[hist->cnt] = 0 - hist->cnt += 1 - End If - - hist->values[hist->cnt] = value - hist->cnt += 1 -End Sub - -Sub ShowHistory(hist As HistoryInt Ptr) - For i As Integer = 0 To hist->cnt - 1 - Print hist->values[i] - Next -End Sub - -Function UndoInt(hist As HistoryInt Ptr) As Integer - If hist->cnt <= 1 Then Return hist->values[0] - hist->cnt -= 1 - Return hist->values[hist->cnt - 1] -End Function - -' Main program -Randomize Timer -Dim As HistoryInt Ptr x = InitHistory() - -For i As Integer = 0 To 3 - SetInt(x, Int(Rnd * 50) + 100) -Next - -Print "x history:" -ShowHistory(x) -Print - -For i As Integer = 0 To 3 - Print "undo, x ="; UndoInt(x) -Next - -Sleep diff --git a/Task/History-variables/Icon/history-variables.icon b/Task/History-variables/Icon/history-variables.icon deleted file mode 100644 index d19277f3a6..0000000000 --- a/Task/History-variables/Icon/history-variables.icon +++ /dev/null @@ -1,22 +0,0 @@ -procedure main(A) - \A := ["cat","hat",7] - x := history() - every x.set(!A) - write("x current value is: ",x.val()) - write("Number of saved values is: ",x.size()) - writes("3 most recent x values from newest to oldest: ") - every writes(" ",x.gen()\3) - write() - while write("x value was: ",\x.get()) - write("Number of saved values is now: ",x.size()) -end - -class history(x) - method size(); return *x; end - method val(); return x[-1]; end - method set(v); put(x,v); end - method get(); return pull(x); end - method gen(); suspend x[*x to 1 by -1]; end -initially - x := [] -end diff --git a/Task/History-variables/Julia/history-variables.jl b/Task/History-variables/Julia/history-variables.julia similarity index 100% rename from Task/History-variables/Julia/history-variables.jl rename to Task/History-variables/Julia/history-variables.julia diff --git a/Task/History-variables/Kotlin/history-variables.kts b/Task/History-variables/Kotlin/history-variables.kotlin similarity index 100% rename from Task/History-variables/Kotlin/history-variables.kts rename to Task/History-variables/Kotlin/history-variables.kotlin diff --git a/Task/History-variables/OCaml/history-variables.ml b/Task/History-variables/OCaml/history-variables.ocaml similarity index 100% rename from Task/History-variables/OCaml/history-variables.ml rename to Task/History-variables/OCaml/history-variables.ocaml diff --git a/Task/History-variables/Oberon/history-variables.oberon b/Task/History-variables/Oberon-2/history-variables.oberon similarity index 100% rename from Task/History-variables/Oberon/history-variables.oberon rename to Task/History-variables/Oberon-2/history-variables.oberon diff --git a/Task/History-variables/Phix/history-variables-1.phix b/Task/History-variables/Phix/history-variables-1.phix index 8270fe1bbe..0d84745f09 100644 --- a/Task/History-variables/Phix/history-variables-1.phix +++ b/Task/History-variables/Phix/history-variables-1.phix @@ -1,13 +1,15 @@ -without js -- (desktop/Phix only) -sequence history = {} +--> + without js -- (desktop/Phix only) + sequence history = {} -type hv(object o) - history = append(history,o) - return true -end type + type hvt(object o) + history = append(history,o) + return true + end type -hv test = 1 -test = 2 -test = 3 -?{"current",test} -?{"history",history} + hvt test = 1 + test = 2 + test = 3 + ?{"current",test} + ?{"history",history} + + -- history.e + sequence histories = {} -global function new_history_id(object v) - histories = append(histories,{v}) - return length(histories) -end function + global function new_history_id(object v) + histories = append(histories,{v}) + return length(histories) + end function -global procedure set_hv(integer hv, object v) - histories[hv] = append(histories[hv],v) -end procedure + global procedure set_hv(integer hv, object v) + histories[hv] = append(histories[hv],v) + end procedure -global function get_hv(integer hv) - return histories[hv][$] -end function + global function get_hv(integer hv) + return histories[hv][$] + end function -global function get_hv_full_history(integer hv) - return histories[hv] -end function + global function get_hv_full_history(integer hv) + return histories[hv] + end function + + include history.e -constant test2 = new_history_id(1) -set_hv(test2, 2) -set_hv(test2, 3) -?{"current",get_hv(test2)} -?{"history",get_hv_full_history(test2)} + constant test2 = new_history_id(1) + set_hv(test2, 2) + set_hv(test2, 3) + ?{"current",get_hv(test2)} + ?{"history",get_hv_full_history(test2)} + r s ) - - [ over size 1 - - over swap peek - dip [ over -1 peek ] - + swap dip join - over -2 split nip do - temp put - 1 + from - [ temp share - index = iff - end done - index join ] - temp release ] is extend ( r s --> r s ) - - [ temp put - [ over size - temp share < while - extend again ] - over - temp take 1 - peek ] is ffr ( r s n --> r s n ) - - [ temp put - [ dup size - temp share < while - extend again ] - dup - temp take 1 - peek ] is ffs ( r s n --> r s n ) - - initialise - say "R(1)..R(10): " - 10 times - [ i^ 1+ ffr echo sp ] - cr cr - 960 ffs drop - 960 split drop - dip [ 40 split drop ] - join sort - [] 1000 times - [ i^ 1+ join ] - != - say "All integers from 1 to 1000" - if say " not" - say " found once and only once." diff --git a/Task/Hofstadter-Figure-Figure-sequences/Rust/hofstadter-figure-figure-sequences.rs b/Task/Hofstadter-Figure-Figure-sequences/Rust/hofstadter-figure-figure-sequences.rust similarity index 100% rename from Task/Hofstadter-Figure-Figure-sequences/Rust/hofstadter-figure-figure-sequences.rs rename to Task/Hofstadter-Figure-Figure-sequences/Rust/hofstadter-figure-figure-sequences.rust diff --git a/Task/Hofstadter-Figure-Figure-sequences/SETL/hofstadter-figure-figure-sequences.setl b/Task/Hofstadter-Figure-Figure-sequences/SETL/hofstadter-figure-figure-sequences.setl deleted file mode 100644 index 0f8d6e335b..0000000000 --- a/Task/Hofstadter-Figure-Figure-sequences/SETL/hofstadter-figure-figure-sequences.setl +++ /dev/null @@ -1,24 +0,0 @@ -program figure_figure; - init R := [1], S := [2]; - - print("R(1..10):", [ffr(n) : n in [1..10]]); - print("R(1..40) + S(1..960) = {1..1000}:", - {ffr(n) : n in {1..40}} + {ffs(n) : n in {1..960}} = {1..1000}); - - proc ffr(n); - loop while n > #R do - nextR := R(#R) + S(#R); - S +:= [S(#S)+1 .. nextR-1]; - R with:= nextR; - S with:= nextR + 1; - end loop; - return R(n); - end proc; - - proc ffs(n); - loop while n > #S do - ffr(#R + 1); - end loop; - return S(n); - end proc; -end program; diff --git a/Task/Hofstadter-Figure-Figure-sequences/VBScript/hofstadter-figure-figure-sequences.vbs b/Task/Hofstadter-Figure-Figure-sequences/VBScript/hofstadter-figure-figure-sequences.vb similarity index 100% rename from Task/Hofstadter-Figure-Figure-sequences/VBScript/hofstadter-figure-figure-sequences.vbs rename to Task/Hofstadter-Figure-Figure-sequences/VBScript/hofstadter-figure-figure-sequences.vb diff --git a/Task/Hofstadter-Q-sequence/AArch64-Assembly/hofstadter-q-sequence.aarch64 b/Task/Hofstadter-Q-sequence/AArch64-Assembly/hofstadter-q-sequence.aarch64 deleted file mode 100644 index 8a3597f613..0000000000 --- a/Task/Hofstadter-Q-sequence/AArch64-Assembly/hofstadter-q-sequence.aarch64 +++ /dev/null @@ -1,181 +0,0 @@ -/* ARM assembly AARCH64 Raspberry PI 3B */ -/* program hofstader64.s */ - -/*******************************************/ -/* Constantes */ -/*******************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeConstantesARM64.inc" - -/*******************************************/ -/* macros */ -/*******************************************/ -//.include "../../ficmacros64.inc" // for developper debugging - -/*********************************/ -/* Initialized data */ -/*********************************/ -.data -szMessDebutPgm: .asciz "Program 64 bits start. \n" -szCarriageReturn: .asciz "\n" -szMessFinOK: .asciz "Program normal end. \n" -szMessErreur: .asciz "Error !!!\n" -szMessHofs: .asciz "Hofstader numbers :\n" -szSpace: .asciz " " - -.align 4 -/*********************************/ -/* UnInitialized data */ -/*********************************/ -.bss -sZoneConv: .skip 24 -.align 4 - -/*********************************/ -/* code section */ -/*********************************/ -.text -.global main -main: - ldr x0,qAdrszMessDebutPgm - bl affichageMess // start message - - ldr x0,qAdrszMessHofs - bl affichageMess - - mov x0,10 // maxi - mov x1,1 // display number - bl genererHofs - ldr x0,qAdrszCarriageReturn - bl affichageMess - - mov x0,1000 // maxi - mov x1,0 // display last number - bl genererHofs - ldr x0,qAdrszCarriageReturn - bl affichageMess - - ldr x0,qMax100000 // maxi - mov x1,2 // display counter - bl genererHofs - bl displayNumber // display return number - ldr x0,qAdrszCarriageReturn - bl affichageMess - - ldr x0,qAdrszMessFinOK - bl affichageMess - b 100f -99: - ldr x0,qAdrszMessErreur // error - bl affichageMess - mov x0, #1 // return code error - b 100f -100: - mov x8,EXIT - svc #0 // system call -qAdrszMessDebutPgm: .quad szMessDebutPgm -qAdrszMessFinOK: .quad szMessFinOK -qAdrszMessErreur: .quad szMessErreur -qAdrsZoneConv: .quad sZoneConv -qAdrszMessHofs: .quad szMessHofs -qMax100000: .quad 100000 -/***************************************************/ -/* Generation Fibonacci numbers */ -/***************************************************/ -/* x0 contains limit number */ -/* x1 display the last number */ -genererHofs: - stp x1,lr,[sp,-16]! - stp x2,x3,[sp,-16]! - stp x4,x5,[sp,-16]! - stp x6,x7,[sp,-16]! - stp x8,x9,[sp,-16]! - stp x10,x11,[sp,-16]! - mov x2,x0 - lsl x10,x0,3 - sub sp,sp,x10 // reserve area on stack - mov x7,sp - mov x4,#0 - mov x5,#0 -1: // init area loop - str x4,[x7,x5,lsl #3] - add x5,x5,#1 - cmp x5,x2 - blt 1b - mov x4,#1 - str x4,[x7] // store value 1 in first item - str x4,[x7,8] // store value 1 in second item - cmp x1,1 // display number ? - bne 2f - mov x0,1 // display L(1) - bl displayNumber - mov x0,1 // display L(2) - bl displayNumber -2: - mov x9,0 - mov x4,#2 -3: - sub x3,x4,#1 // L -1 - ldr x11,[x7,x3,lsl #3] // load ancien result - sub x6,x4,x11 - ldr x5,[x7,x6,lsl #3] - sub x3,x3,#1 // L - 2 - ldr x8,[x7,x3,lsl #3] // load ancien result - sub x6,x4,x8 - ldr x8,[x7,x6,lsl #3] - add x5,x5,x8 - str x5,[x7,x4,lsl #3] - cmp x5,x11 - cinc x9,x9,lt - - cmp x1,1 - bne 4f - mov x0,x5 - bl displayNumber -4: - - add x4,x4,#1 // increment counter - cmp x4,x2 // end compute ? - blt 3b - cmp x1,1 - bge 100f - mov x0,x5 - bl displayNumber -100: - mov x0,x9 - add sp,sp,x10 // free reserved area - ldp x10,x11,[sp],16 - ldp x8,x9,[sp],16 - ldp x6,x7,[sp],16 - ldp x4,x5,[sp],16 - ldp x2,x3,[sp],16 - ldp x1,lr,[sp],16 - ret -/***************************************************/ -/* display number */ -/***************************************************/ -/* x0 contains number */ -displayNumber: - stp x1,lr,[sp,-16]! - stp x2,x3,[sp,-16]! - ldr x1,qAdrsZoneConv - bl conversion10 - mov x2,#0 - add x1,x1,x0 - strb w2,[x1] - ldr x0,qAdrsZoneConv - bl affichageMess - ldr x0,qAdrszSpace - bl affichageMess -100: - ldp x2,x3,[sp],16 - ldp x1,lr,[sp],16 - ret -qAdrszCarriageReturn: .quad szCarriageReturn -qAdrszSpace: .quad szSpace - -/***************************************************/ -/* ROUTINES INCLUDE */ -/***************************************************/ -/* for this file see task include a file in language AArch64 assembly*/ -.include "../includeARM64.inc" diff --git a/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg b/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg index 02d0922aa4..071be33dcf 100644 --- a/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg +++ b/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg @@ -1,16 +1,24 @@ -BEGIN - [100000]INT q; +#!/usr/local/bin/a68g --script # + +INT n = 100000; +main: +( + INT flip; + [n]INT q; - INT flips := 0; q[1] := q[2] := 1; - FOR i FROM 3 TO UPB q DO - q[i] := q[i - q[i - 1]] + q[i - q[i - 2]]; - IF q[i] < q[i - 1] THEN flips +:= 1 FI - OD; + + FOR i FROM 3 TO n DO + q[i] := q[i - q[i - 1]] + q[i - q[i - 2]] OD; FOR i TO 10 DO - print((whole(q[i],0), IF i = 10 THEN newline ELSE space FI)) OD; + printf(($g(0)$, q[i], $b(l,x)$, i = 10)) OD; - print((whole(q[1000],0), newline)); - print(("flips: ", whole(flips,0), newline)) -END + printf(($g(0)l$, q[1000])); + + flip := 0; + FOR i TO n-1 DO + flip +:= ABS (q[i] > q[i + 1]) OD; + + printf(($"flips: "g(0)l$, flip)) +) diff --git a/Task/Hofstadter-Q-sequence/Ada/hofstadter-q-sequence.adb b/Task/Hofstadter-Q-sequence/Ada/hofstadter-q-sequence.ada similarity index 100% rename from Task/Hofstadter-Q-sequence/Ada/hofstadter-q-sequence.adb rename to Task/Hofstadter-Q-sequence/Ada/hofstadter-q-sequence.ada diff --git a/Task/Hofstadter-Q-sequence/Arturo/hofstadter-q-sequence.arturo b/Task/Hofstadter-Q-sequence/Arturo/hofstadter-q-sequence.arturo index ddd5248a8d..2089f585d3 100644 --- a/Task/Hofstadter-Q-sequence/Arturo/hofstadter-q-sequence.arturo +++ b/Task/Hofstadter-Q-sequence/Arturo/hofstadter-q-sequence.arturo @@ -1,4 +1,4 @@ -q: [1 1] +q: new [1 1] n: 2 while [n<1001][ 'q ++ (get q n-q\[n-1]) + get q n-q\[n-2] diff --git a/Task/Hofstadter-Q-sequence/COBOL/hofstadter-q-sequence.cob b/Task/Hofstadter-Q-sequence/COBOL/hofstadter-q-sequence.cobol similarity index 100% rename from Task/Hofstadter-Q-sequence/COBOL/hofstadter-q-sequence.cob rename to Task/Hofstadter-Q-sequence/COBOL/hofstadter-q-sequence.cobol diff --git a/Task/Hofstadter-Q-sequence/Crystal/hofstadter-q-sequence.cr b/Task/Hofstadter-Q-sequence/Crystal/hofstadter-q-sequence.cr deleted file mode 100644 index d7110a4f3e..0000000000 --- a/Task/Hofstadter-Q-sequence/Crystal/hofstadter-q-sequence.cr +++ /dev/null @@ -1,22 +0,0 @@ -class Q - @@cache = [0, 1, 1] - - def self.[] (n) - if n >= @@cache.size - (@@cache.size ... n).each do |i| - Q[i] - end - @@cache << @@cache[n - @@cache[n-1]] + @@cache[n - @@cache[n-2]] - end - @@cache[n] - end -end - -print "First 10 terms: " -puts (1..10).map {|i| Q[i] }.join(" ") - -puts "1000th term: #{ Q[1000] }" - -c = (2..100_000).count {|i| Q[i] < Q[i-1] } - -puts "Less than preceding: #{c}" diff --git a/Task/Hofstadter-Q-sequence/Delphi/hofstadter-q-sequence.pas b/Task/Hofstadter-Q-sequence/Delphi/hofstadter-q-sequence.delphi similarity index 100% rename from Task/Hofstadter-Q-sequence/Delphi/hofstadter-q-sequence.pas rename to Task/Hofstadter-Q-sequence/Delphi/hofstadter-q-sequence.delphi diff --git a/Task/Hofstadter-Q-sequence/EasyLang/hofstadter-q-sequence.easy b/Task/Hofstadter-Q-sequence/EasyLang/hofstadter-q-sequence.easy deleted file mode 100644 index 20beb55cac..0000000000 --- a/Task/Hofstadter-Q-sequence/EasyLang/hofstadter-q-sequence.easy +++ /dev/null @@ -1,17 +0,0 @@ -proc hofstadter limit &q[] . - q[] = [ 1 1 ] - for n = 3 to limit - q[] &= q[n - q[n - 1]] + q[n - q[n - 2]] - . -. -proc count &q[] &cnt . - for i = 2 to len q[] - if q[i] < q[i - 1] : cnt += 1 - . -. -hofstadter 100000 hofq[] -for i = 1 to 10 : write hofq[i] & " " -print "" -print hofq[1000] -count hofq[] cnt -print cnt diff --git a/Task/Hofstadter-Q-sequence/Elixir/hofstadter-q-sequence.ex b/Task/Hofstadter-Q-sequence/Elixir/hofstadter-q-sequence.elixir similarity index 100% rename from Task/Hofstadter-Q-sequence/Elixir/hofstadter-q-sequence.ex rename to Task/Hofstadter-Q-sequence/Elixir/hofstadter-q-sequence.elixir diff --git a/Task/Hofstadter-Q-sequence/FutureBasic/hofstadter-q-sequence.basic b/Task/Hofstadter-Q-sequence/FutureBasic/hofstadter-q-sequence.basic deleted file mode 100644 index c9f3691860..0000000000 --- a/Task/Hofstadter-Q-sequence/FutureBasic/hofstadter-q-sequence.basic +++ /dev/null @@ -1,19 +0,0 @@ -_limit = 100000 - -Long Q(_limit), i, count = 0 - -Q(1) = 1 -Q(2) = 1 -For i = 3 To _limit - Q(i) = Q(i-Q(i-1)) + Q(i-Q(i-2)) - If Q(i) < Q(i-1) Then count += 1 -Next i - -Print "First 10 elements:"; -For i = 1 To 10 - Print str$(Q(i)) + " "; -Next i -Print -Print "Q(1000) is "; Q(1000) -Print "There were" + str$(count) + " inversions" -handleevents diff --git a/Task/Hofstadter-Q-sequence/Gambas/hofstadter-q-sequence.gambas b/Task/Hofstadter-Q-sequence/Gambas/hofstadter-q-sequence.gambas deleted file mode 100644 index e3e51a24a3..0000000000 --- a/Task/Hofstadter-Q-sequence/Gambas/hofstadter-q-sequence.gambas +++ /dev/null @@ -1,23 +0,0 @@ -Public Const limite As Integer = 100000 -Public Q[limite + 1] As Long - -Public Sub Main() - - Dim i As Long, cont As Long = 0 - - Q[1] = 1 - Q[2] = 1 - For i = 3 To limite - Q[i] = Q[i - Q[i - 1]] + Q[i - Q[i - 2]] - If Q[i] < Q[i - 1] Then cont += 1 - Next - - Print "Primeros 10 terminos: "; - For i = 1 To 10 - Print Q[i] & " "; - Next - - Print "\nTermino numero 1000: "; Q[1000] - Print "Terminos menores que los anteriores: " & cont - -End diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs index 3a361b185b..37c7f28e2d 100644 --- a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs @@ -1,13 +1,21 @@ -douglasHofstadter :: Int -> [Int] -douglasHofstadter m = reverse (dSeqEffect [1,1] 2 m) - where - dSeqEffect xs n m | n > m = xs - | otherwise = dSeqEffect (((xs !! (xs !! (n - 1))) + (xs !! (n - (xs !! (n - 1)))) ) : xs) (n + 1) m +import Data.Array --- main -getIntArg :: IO Int -getIntArg = fmap (read . head) getArgs +qSequence n = arr + where + arr = listArray (1,n) $ 1:1: map g [3..n] + g i = arr!(i - arr!(i-1)) + + arr!(i - arr!(i-2)) -main = do - args <- getIntArg - print (douglasHofstadter args) +gradualth m k arr -- gradually precalculate m-th item + | m <= v = pre `seq` arr!m -- in steps of k + where -- to prevent STACK OVERFLOW + pre = foldl1 (\a b-> a `seq` arr!b) [u,u+k..m] + (u,v) = bounds arr + +qSeqTest m n = let arr = qSequence $ max m n in + ( take 10 . elems $ arr -- 10 first items + , gradualth m 10000 $ arr -- m-th item + , length . filter (> 0) -- reversals in n items + . _S (zipWith (-)) tail . take n . elems $ arr ) + +_S f g x = f x (g x) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs index 37c7f28e2d..162d5cee47 100644 --- a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs @@ -1,21 +1,7 @@ -import Data.Array +Prelude Main> qSeqTest 1000 100000 -- reversals in 100,000 +([1,1,2,3,3,4,5,5,6,6],502,49798) +(0.09 secs, 18879708 bytes) -qSequence n = arr - where - arr = listArray (1,n) $ 1:1: map g [3..n] - g i = arr!(i - arr!(i-1)) + - arr!(i - arr!(i-2)) - -gradualth m k arr -- gradually precalculate m-th item - | m <= v = pre `seq` arr!m -- in steps of k - where -- to prevent STACK OVERFLOW - pre = foldl1 (\a b-> a `seq` arr!b) [u,u+k..m] - (u,v) = bounds arr - -qSeqTest m n = let arr = qSequence $ max m n in - ( take 10 . elems $ arr -- 10 first items - , gradualth m 10000 $ arr -- m-th item - , length . filter (> 0) -- reversals in n items - . _S (zipWith (-)) tail . take n . elems $ arr ) - -_S f g x = f x (g x) +Prelude Main> qSeqTest 1000000 100000 -- 1,000,000-th item +([1,1,2,3,3,4,5,5,6,6],512066,49798) +(2.80 secs, 87559640 bytes) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs index 162d5cee47..40d00cdae6 100644 --- a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs @@ -1,7 +1,16 @@ -Prelude Main> qSeqTest 1000 100000 -- reversals in 100,000 -([1,1,2,3,3,4,5,5,6,6],502,49798) -(0.09 secs, 18879708 bytes) +q = qq (listArray (1,2) [1,1]) 1 where + qq ar n = (arr!n) : qq arr (n+1) where + l = snd (bounds ar) + step n =arr!(n - (fromIntegral (arr!(n - 1)))) + + arr!(n - (fromIntegral (arr!(n - 2)))) + arr :: Array Int Integer + arr | n <= l = ar + | otherwise = listArray (1, l*2)$ + ([ar!i | i <- [1..l]] ++ + [step i | i <- [l+1..l*2]]) -Prelude Main> qSeqTest 1000000 100000 -- 1,000,000-th item -([1,1,2,3,3,4,5,5,6,6],512066,49798) -(2.80 secs, 87559640 bytes) +main = do + putStr("first 10: "); print (take 10 q) + putStr("1000-th: "); print (q !! 999) + putStr("flips: ") + print $ length $ filter id $ take 100000 (zipWith (>) q (tail q)) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs index 40d00cdae6..d7722cbb4d 100644 --- a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs @@ -1,16 +1,21 @@ -q = qq (listArray (1,2) [1,1]) 1 where - qq ar n = (arr!n) : qq arr (n+1) where - l = snd (bounds ar) - step n =arr!(n - (fromIntegral (arr!(n - 1)))) + - arr!(n - (fromIntegral (arr!(n - 2)))) - arr :: Array Int Integer - arr | n <= l = ar - | otherwise = listArray (1, l*2)$ - ([ar!i | i <- [1..l]] ++ - [step i | i <- [l+1..l*2]]) +import Data.Array +import Data.Int (Int64) -main = do - putStr("first 10: "); print (take 10 q) - putStr("1000-th: "); print (q !! 999) - putStr("flips: ") - print $ length $ filter id $ take 100000 (zipWith (>) q (tail q)) +q = qq [listArray (1,2) [1,1]] 1 where + qq a n = seek aa n : qq aa (1 + n) where + aa | n <= l = a + | otherwise = listArray (l+1,l*2) (take l $ drop 2 lst):a + where + l = snd (bounds $ head a) + lst = seek a (l-1):seek a l:(ext lst (l+1)) + ext (q1:q2:qs) i = (g (i-q2) + g (i-q1)):ext (q2:qs) (1+i) + g = seek aa + seek (ar:ars) n + | n >= fst (bounds ar) = ar ! n + | otherwise = seek ars n + +-- Only a perf test. Task can be done exactly the same as above +main = print $ sum qqq + where + qqq :: [Int64] + qqq = map fromIntegral $ take 3000000 q diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-6.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-6.hs deleted file mode 100644 index d7722cbb4d..0000000000 --- a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-6.hs +++ /dev/null @@ -1,21 +0,0 @@ -import Data.Array -import Data.Int (Int64) - -q = qq [listArray (1,2) [1,1]] 1 where - qq a n = seek aa n : qq aa (1 + n) where - aa | n <= l = a - | otherwise = listArray (l+1,l*2) (take l $ drop 2 lst):a - where - l = snd (bounds $ head a) - lst = seek a (l-1):seek a l:(ext lst (l+1)) - ext (q1:q2:qs) i = (g (i-q2) + g (i-q1)):ext (q2:qs) (1+i) - g = seek aa - seek (ar:ars) n - | n >= fst (bounds ar) = ar ! n - | otherwise = seek ars n - --- Only a perf test. Task can be done exactly the same as above -main = print $ sum qqq - where - qqq :: [Int64] - qqq = map fromIntegral $ take 3000000 q diff --git a/Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-1.jl b/Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-1.julia similarity index 100% rename from Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-1.jl rename to Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-1.julia diff --git a/Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-2.jl b/Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-2.julia similarity index 100% rename from Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-2.jl rename to Task/Hofstadter-Q-sequence/Julia/hofstadter-q-sequence-2.julia diff --git a/Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence-2.kts b/Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence-2.kts deleted file mode 100644 index ac07d6cc8e..0000000000 --- a/Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence-2.kts +++ /dev/null @@ -1,24 +0,0 @@ -fun Q(n: Int): List { - val mem = mutableMapOf().also { - it[1] = 1 - it[2] = 1 - } - q(n, mem) - return mem.values.toList() -} - -private fun q(n: Int, mem: MutableMap): Int { - if (!mem.containsKey(n)) { - mem[n] = - q(n - q(n - 1, mem), mem) + q(n - q(n - 2, mem), mem) - } - return mem[n]!! -} - -fun main() { - val n = 1000 - Q(n).also { qList -> - println("Q[1..10] = ${qList.take(10)}") - println("Q($n) = ${qList[1000 - 1]}") // 502 - } -} diff --git a/Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence-1.kts b/Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence.kotlin similarity index 100% rename from Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence-1.kts rename to Task/Hofstadter-Q-sequence/Kotlin/hofstadter-q-sequence.kotlin diff --git a/Task/Hofstadter-Q-sequence/Lua/hofstadter-q-sequence.lua b/Task/Hofstadter-Q-sequence/Lua/hofstadter-q-sequence.lua deleted file mode 100644 index 1e5530d33e..0000000000 --- a/Task/Hofstadter-Q-sequence/Lua/hofstadter-q-sequence.lua +++ /dev/null @@ -1,28 +0,0 @@ -function hofstadter (limit) - local Q = {1, 1} - for n = 3, limit do - Q[n] = Q[n - Q[n - 1]] + Q[n - Q[n - 2]] - end - return Q -end - -function countDescents (t) - local count = 0 - for i = 2, #t do - if t[i] < t[i - 1] then - count = count + 1 - end - end - return count -end - -local noError, hofSeq = pcall(hofstadter, 1e5) -if noError == false then - print("The sequence could not be calculated up to the specified limit.") - os.exit() -end -for i = 1, 10 do - io.write(hofSeq[i] .. " ") -end -print("\n" .. hofSeq[1000]) -print(countDescents(hofSeq)) diff --git a/Task/Hofstadter-Q-sequence/Maxima/hofstadter-q-sequence.maxima b/Task/Hofstadter-Q-sequence/Maxima/hofstadter-q-sequence.maxima deleted file mode 100644 index 9516c7747d..0000000000 --- a/Task/Hofstadter-Q-sequence/Maxima/hofstadter-q-sequence.maxima +++ /dev/null @@ -1,11 +0,0 @@ -/* Function that return the terms of the Hofstadter Q sequence */ -hofstadter(n):=block( - if member(n,[1,2]) then L[n]:1 else L[n]:L[n-L[n-1]]+L[n-L[n-2]], - L[n])$ - -/* Test cases */ -/* First ten terms */ -makelist(hofstadter(i),i,1,10); - -/* 1000th term */ -last(makelist(hofstadter(i),i,1,1000)); diff --git a/Task/Hofstadter-Q-sequence/OCaml/hofstadter-q-sequence.ml b/Task/Hofstadter-Q-sequence/OCaml/hofstadter-q-sequence.ocaml similarity index 100% rename from Task/Hofstadter-Q-sequence/OCaml/hofstadter-q-sequence.ml rename to Task/Hofstadter-Q-sequence/OCaml/hofstadter-q-sequence.ocaml diff --git a/Task/Hofstadter-Q-sequence/Oberon/hofstadter-q-sequence.oberon b/Task/Hofstadter-Q-sequence/Oberon-2/hofstadter-q-sequence.oberon similarity index 100% rename from Task/Hofstadter-Q-sequence/Oberon/hofstadter-q-sequence.oberon rename to Task/Hofstadter-Q-sequence/Oberon-2/hofstadter-q-sequence.oberon diff --git a/Task/Hofstadter-Q-sequence/OxygenBasic/hofstadter-q-sequence.basic b/Task/Hofstadter-Q-sequence/OxygenBasic/hofstadter-q-sequence.basic deleted file mode 100644 index 6015f7c4ab..0000000000 --- a/Task/Hofstadter-Q-sequence/OxygenBasic/hofstadter-q-sequence.basic +++ /dev/null @@ -1,26 +0,0 @@ -uses console - -int limite = 100000 - -dim long Q[100000] -long i, cont = 0 - -Q[1] = 1 -Q[2] = 1 -For i = 3 To limite - Q[i] = Q[i-Q[i-1]] + Q[i-Q[i-2]] - If Q(i) < Q(i-1) Then cont += 1 -Next i - -print "Primeros 10 terminos: " -For i = 1 To 10 - print Q(i) " "; -Next i -print cr - -printl "Termino numero 1000: " Q(1000) - -printl "Terminos menores que los anteriores: " cont - -printl cr "Enter ..." -waitkey diff --git a/Task/Hofstadter-Q-sequence/PascalABC.NET/hofstadter-q-sequence.pas b/Task/Hofstadter-Q-sequence/PascalABC.NET/hofstadter-q-sequence.pas deleted file mode 100644 index 6c1be48d54..0000000000 --- a/Task/Hofstadter-Q-sequence/PascalABC.NET/hofstadter-q-sequence.pas +++ /dev/null @@ -1,16 +0,0 @@ -## -var q := |1, 1|.ToList; -for var n := 2 to 100_000 do - q.add(q[n - q[n - 1]] + q[n - q[n - 2]]); - -q.take(10).println; -assert(q.Take(10).SequenceEqual(|1, 1, 2, 3, 3, 4, 5, 5, 6, 6|)); - -q[999].println; -assert(q[999] = 502); - -var lessCount := 0; -for var n := 1 to 100_000 do - if q[n] < q[n - 1] then - lessCount += 1; -lessCount.Println; diff --git a/Task/Hofstadter-Q-sequence/Pluto/hofstadter-q-sequence.pluto b/Task/Hofstadter-Q-sequence/Pluto/hofstadter-q-sequence.pluto deleted file mode 100644 index 68a73a3bf0..0000000000 --- a/Task/Hofstadter-Q-sequence/Pluto/hofstadter-q-sequence.pluto +++ /dev/null @@ -1,18 +0,0 @@ -require "table2" -local fmt = require "fmt" - -local N = 100_000 -local q = table.rep(N, 0) -q[0] = 0 -q[1] = 1 -q[2] = 1 -for n = 3, N do q[n] = q[n - q[n-1]] + q[n - q[n-2]] end - -print("The first ten terms of the Hofstadter Q sequence are:") -fmt.lprint(q:slice(1, 10)) -print($"\nThe thousandth term is {q[1000]}.") -local flips = 0 -for n = 2, N do - if (q[n] < q[n-1]) then flips += 1 end -end -print($"\nThere are {fmt.int(flips)} flips in the first {fmt.int(N)} terms.") diff --git a/Task/Hofstadter-Q-sequence/QB64/hofstadter-q-sequence.qb64 b/Task/Hofstadter-Q-sequence/QB64/hofstadter-q-sequence.qb64 deleted file mode 100644 index 0ff10d7b9a..0000000000 --- a/Task/Hofstadter-Q-sequence/QB64/hofstadter-q-sequence.qb64 +++ /dev/null @@ -1,20 +0,0 @@ -Const limite = 100000 - -Dim As Long Q(limite) -Q(1) = 1 -Q(2) = 1 - -cont = 0 -For i = 3 To limite - Q(i) = Q(i - Q(i - 1)) + Q(i - Q(i - 2)) - If Q(i) < Q(i - 1) Then cont = cont + 1 -Next i - -Print "First 10 terms:"; -For i = 1 To 10 - Print Q(i); -Next i - -Print -Print "Term 1000: "; Q(1000) -Print "Terms less than preceding in first 100k:"; cont diff --git a/Task/Hofstadter-Q-sequence/Rust/hofstadter-q-sequence.rs b/Task/Hofstadter-Q-sequence/Rust/hofstadter-q-sequence.rust similarity index 100% rename from Task/Hofstadter-Q-sequence/Rust/hofstadter-q-sequence.rs rename to Task/Hofstadter-Q-sequence/Rust/hofstadter-q-sequence.rust diff --git a/Task/Hofstadter-Q-sequence/SETL/hofstadter-q-sequence.setl b/Task/Hofstadter-Q-sequence/SETL/hofstadter-q-sequence.setl deleted file mode 100644 index d01b79474d..0000000000 --- a/Task/Hofstadter-Q-sequence/SETL/hofstadter-q-sequence.setl +++ /dev/null @@ -1,10 +0,0 @@ -program hofstadter_q; - q := [1,1]; - loop for n in [3..100000] do - q(n) := q(n-q(n-1)) + q(n-q(n-2)); - end loop; - - print("First 10 terms: " + q(1..10)); - print("1000th term: " + q(1000)); - print("q(x) < q(x-1): " + #[x : x in [2..#q] | q(x) < q(x-1)]); -end program; diff --git a/Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence.scm b/Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence.ss similarity index 100% rename from Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence.scm rename to Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence.ss diff --git a/Task/Hofstadter-Q-sequence/Sidef/hofstadter-q-sequence-2.sidef b/Task/Hofstadter-Q-sequence/Sidef/hofstadter-q-sequence-2.sidef index eb85f13832..21c50bd482 100644 --- a/Task/Hofstadter-Q-sequence/Sidef/hofstadter-q-sequence-2.sidef +++ b/Task/Hofstadter-Q-sequence/Sidef/hofstadter-q-sequence-2.sidef @@ -2,7 +2,7 @@ var Q = [0, 1, 1] 100_000.times { Q << (Q[-Q[-1]] + Q[-Q[-2]]) } - -say "First 10 terms: #{Q.slice(1).first(10)}" +  +say "First 10 terms: #{Q.ft(1, 10)}" say "Term 1000: #{Q[1000]}" say "Terms less than preceding in first 100k: #{2..100000->count{|i|Q[i] # ! - when <|$@::length~..> do - ..|@ set $@($ - $@($ - 1)) + $@($ - $@($ - 2)); - $ -> # ! - when <|$outputFrom..> do - $@($) ! -end q - -[1,10] -> q -> '$; ' ! -' -' ! - -[1000,1000] -> q -> '$; -' ! - -countDownSteps templates - @ set 0; - qs is $; - 2..$qs::length -> !# - $@ ! - when <|?($qs($) matches <|..~$qs($-1)>)> do @ set $@ + 1; -end countDownSteps - -[[1, 100000] -> q] -> countDownSteps -> 'Less than previous $; times' ! diff --git a/Task/Hofstadter-Q-sequence/Tailspin/hofstadter-q-sequence-1.tailspin b/Task/Hofstadter-Q-sequence/Tailspin/hofstadter-q-sequence.tailspin similarity index 100% rename from Task/Hofstadter-Q-sequence/Tailspin/hofstadter-q-sequence-1.tailspin rename to Task/Hofstadter-Q-sequence/Tailspin/hofstadter-q-sequence.tailspin diff --git a/Task/Hofstadter-Q-sequence/VBScript/hofstadter-q-sequence.vbs b/Task/Hofstadter-Q-sequence/VBScript/hofstadter-q-sequence.vb similarity index 100% rename from Task/Hofstadter-Q-sequence/VBScript/hofstadter-q-sequence.vbs rename to Task/Hofstadter-Q-sequence/VBScript/hofstadter-q-sequence.vb diff --git a/Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.adb b/Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.ada similarity index 100% rename from Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.adb rename to Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.ada diff --git a/Task/Holidays-related-to-Easter/C++/holidays-related-to-easter.cpp b/Task/Holidays-related-to-Easter/C++/holidays-related-to-easter.cpp deleted file mode 100644 index c8d9222004..0000000000 --- a/Task/Holidays-related-to-Easter/C++/holidays-related-to-easter.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include -#include - -std::chrono::year_month_day date_of_easter(const int32_t& year) { - const int32_t a = year % 19; - const int32_t b = year / 100; - const int32_t c = year % 100; - const int32_t d = b / 4; - const int32_t e = b % 4; - const int32_t f = ( b + 8 ) / 25; - const int32_t g = ( b - f + 1 ) / 3; - const int32_t h = ( 19 * a + b - d - g + 15 ) % 30; - const int32_t i = c / 4; - const int32_t k = c % 4; - const int32_t l = ( 32 + 2 * e + 2 * i - h - k ) % 7; - const int32_t m = ( a + 11 * h + 22 * l ) / 451; - const int32_t n = h + l - 7 * m + 114; - const unsigned int month = n / 31; - const unsigned int day = ( n % 31 ) + 1; - - return { std::chrono::year{year}, std::chrono::month{month}, std::chrono::day{day} }; -} - -void display(const int32_t& year, const std::vector& holiday_offsets) { - std::chrono::year_month_day easter = date_of_easter(year); - - std::cout << std::setw(4) << year; - for ( const int32_t& holiday_offset : holiday_offsets ) { - std::chrono::year_month_day date = std::chrono::sys_days(easter) + std::chrono::days{holiday_offset}; - std::cout << std::setw(7) << date.day() << std::setw(4) << date.month(); - } - std::cout << std::endl; -} - -int main() { - const std::vector holiday_offsets{ 0, 39, 49, 56, 60 }; - - std::cout << "Year Easter Ascension Pentecost Trinity Corpus Christi" << std::endl; - std::cout << " CE Sunday Thursday Sunday Sunday Thursday " << std::endl; - std::cout << "---- ------ --------- --------- ------- --------------" << std::endl; - for ( int32_t year = 400; year <= 2100; year += 100 ) { - display(year, holiday_offsets); - } - std::cout << std::endl; - - for ( int32_t year= 2010; year <= 2020; ++year ) { - display(year, holiday_offsets); - } -} diff --git a/Task/Holidays-related-to-Easter/COBOL/holidays-related-to-easter.cob b/Task/Holidays-related-to-Easter/COBOL/holidays-related-to-easter.cobol similarity index 100% rename from Task/Holidays-related-to-Easter/COBOL/holidays-related-to-easter.cob rename to Task/Holidays-related-to-Easter/COBOL/holidays-related-to-easter.cobol diff --git a/Task/Holidays-related-to-Easter/Delphi/holidays-related-to-easter.pas b/Task/Holidays-related-to-Easter/Delphi/holidays-related-to-easter.delphi similarity index 100% rename from Task/Holidays-related-to-Easter/Delphi/holidays-related-to-easter.pas rename to Task/Holidays-related-to-Easter/Delphi/holidays-related-to-easter.delphi diff --git a/Task/Holidays-related-to-Easter/Elixir/holidays-related-to-easter.ex b/Task/Holidays-related-to-Easter/Elixir/holidays-related-to-easter.elixir similarity index 100% rename from Task/Holidays-related-to-Easter/Elixir/holidays-related-to-easter.ex rename to Task/Holidays-related-to-Easter/Elixir/holidays-related-to-easter.elixir diff --git a/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter-2.f b/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter-2.f deleted file mode 100644 index 409769bad1..0000000000 --- a/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter-2.f +++ /dev/null @@ -1,183 +0,0 @@ -program christian_feasts - implicit none - integer :: year, i - character(len=6), parameter :: NONE = ' --- ' - - write(*,'(A)') 'CHRISTIAN FEAST DAYS' - write(*,'(A)') repeat('=', 72) - write(*,'(A)') 'Pre-Gregorian reform (400-1500 CE): Julian computus only' - write(*,'(A)') 'Dates: DDMon(Julian) / DDMon(Gregorian proleptic)' - write(*,'(A)') '(*) Trinity ~10th c. (**) Corpus Christi from 1264 CE' - write(*,'(A)') repeat('-', 72) - write(*,'(A4,2X,A13,2X,A13,2X,A13,2X,A13,2X,A13)') & - 'Year', 'Easter ', 'Ascension ', 'Pentecost ', & - 'Trinity* ', 'CorpusChr** ' - write(*,'(A)') repeat('-', 72) - do i = 4, 15 - call pre_row(i * 100) - end do - - write(*,*) - write(*,'(A)') repeat('=', 72) - write(*,'(A)') 'Post-Gregorian reform (1600-2100 CE + 2010-2020): Gregorian calendar' - write(*,'(A)') 'Orthodox = Julian computus | Catholic = Gregorian computus' - write(*,'(A)') 'Col 6: All Saints Sunday (+56) for Orthodox; Trinity Sunday (+56) for Catholic' - write(*,'(A)') 'Col 7: Corpus Christi (+60) Catholic only' - write(*,'(A)') repeat('-', 72) - write(*,'(A4,2X,A8,2X,A6,2X,A6,2X,A6,2X,A6,2X,A6)') & - 'Year', 'Church ', 'Easter', 'Ascensn', 'Pentecos', 'AS/Trin ', 'CorpChr ' - write(*,'(A)') repeat('-', 72) - do i = 16, 21 - call post_rows(i * 100) - end do - write(*,'(A)') repeat('-', 72) - write(*,'(A)') ' -- 2010 to 2020 --' - write(*,'(A)') repeat('-', 72) - do year = 2010, 2026 - call post_rows(year) - end do - -contains - - ! Julian computus: returns Easter month/day in Julian calendar - subroutine julian_easter(yr, mo, dy) - integer, intent(in) :: yr - integer, intent(out) :: mo, dy - integer :: a, b, c, d, e - a = mod(yr, 4) - b = mod(yr, 7) - c = mod(yr, 19) - d = mod(19*c + 15, 30) - e = mod(2*a + 4*b - d + 34, 7) - mo = (d + e + 114) / 31 - dy = mod(d + e + 114, 31) + 1 - end subroutine julian_easter - - ! Gregorian computus (Anonymous Gregorian algorithm): returns Easter in Gregorian calendar - subroutine gregorian_easter(yr, mo, dy) - integer, intent(in) :: yr - integer, intent(out) :: mo, dy - integer :: a, b, c, d, e, f, g, h, ii, k, l, m - a = mod(yr, 19) - b = yr / 100 - c = mod(yr, 100) - d = b / 4 - e = mod(b, 4) - f = (b + 8) / 25 - g = (b - f + 1) / 3 - h = mod(19*a + b - d - g + 15, 30) - ii = c / 4 - k = mod(c, 4) - l = mod(32 + 2*e + 2*ii - h - k, 7) - m = (a + 11*h + 22*l) / 451 - mo = (h + l - 7*m + 114) / 31 - dy = mod(h + l - 7*m + 114, 31) + 1 - end subroutine gregorian_easter - - ! Julian calendar date -> Julian Day Number - pure function jul2jdn(y, m, d) result(jdn) - integer, intent(in) :: y, m, d - integer :: jdn, a, yy, mm - a = (14 - m) / 12 - yy = y + 4800 - a - mm = m + 12*a - 3 - jdn = d + (153*mm + 2)/5 + 365*yy + yy/4 - 32083 - end function jul2jdn - - ! Gregorian calendar date -> Julian Day Number - pure function greg2jdn(y, m, d) result(jdn) - integer, intent(in) :: y, m, d - integer :: jdn, a, yy, mm - a = (14 - m) / 12 - yy = y + 4800 - a - mm = m + 12*a - 3 - jdn = d + (153*mm + 2)/5 + 365*yy + yy/4 - yy/100 + yy/400 - 32045 - end function greg2jdn - - ! Julian Day Number -> Gregorian calendar date - subroutine jdn2greg(jdn, y, m, d) - integer, intent(in) :: jdn - integer, intent(out) :: y, m, d - integer :: a, b, c, dd, e, mm - a = jdn + 32044 - b = (4*a + 3) / 146097 - c = a - (146097*b) / 4 - dd = (4*c + 3) / 1461 - e = c - (1461*dd) / 4 - mm = (5*e + 2) / 153 - d = e - (153*mm + 2)/5 + 1 - m = mm + 3 - 12*(mm/10) - y = 100*b + dd - 4800 + mm/10 - end subroutine jdn2greg - - ! Julian Day Number -> Julian calendar date - subroutine jdn2jul(jdn, y, m, d) - integer, intent(in) :: jdn - integer, intent(out) :: y, m, d - integer :: c, dd, e, mm - c = jdn + 32082 - dd = (4*c + 3) / 1461 - e = c - (1461*dd) / 4 - mm = (5*e + 2) / 153 - d = e - (153*mm + 2)/5 + 1 - m = mm + 3 - 12*(mm/10) - y = dd - 4800 + mm/10 - end subroutine jdn2jul - - function mname(m) result(s) - integer, intent(in) :: m - character(len=3) :: s - character(len=3), parameter :: names(12) = & - ['Jan','Feb','Mar','Apr','May','Jun', & - 'Jul','Aug','Sep','Oct','Nov','Dec'] - s = names(m) - end function mname - - ! Format JDN as "DDMon/DDMon" (Julian cal. / Gregorian proleptic), 13 chars - function fmtjg(jdn) result(s) - integer, intent(in) :: jdn - character(len=13) :: s - integer :: jy, jm, jd, gy, gm, gd - call jdn2jul(jdn, jy, jm, jd) - call jdn2greg(jdn, gy, gm, gd) - write(s,'(I2.2,A3,A1,I2.2,A3)') jd, mname(jm), '/', gd, mname(gm) - end function fmtjg - - ! Format JDN as "DD Mon" (Gregorian), 6 chars - function fmtg(jdn) result(s) - integer, intent(in) :: jdn - character(len=6) :: s - integer :: gy, gm, gd - call jdn2greg(jdn, gy, gm, gd) - write(s,'(I2.2,1X,A3)') gd, mname(gm) - end function fmtg - - subroutine pre_row(year) - integer, intent(in) :: year - integer :: em, ed, jdn - call julian_easter(year, em, ed) - jdn = jul2jdn(year, em, ed) - write(*,'(I4,2X,A13,2X,A13,2X,A13,2X,A13,2X,A13)') year, & - fmtjg(jdn), fmtjg(jdn+39), fmtjg(jdn+49), & - fmtjg(jdn+56), fmtjg(jdn+60) - end subroutine pre_row - - subroutine post_rows(year) - integer, intent(in) :: year - integer :: em, ed, jdn_o, jdn_c - ! Orthodox: Julian computus -> Julian calendar -> convert to Gregorian for display - call julian_easter(year, em, ed) - jdn_o = jul2jdn(year, em, ed) - write(*,'(I4,2X,A8,2X,A6,2X,A6,2X,A6,2X,A6,2X,A6)') year, & - 'Orthodox', fmtg(jdn_o), fmtg(jdn_o+39), fmtg(jdn_o+49), & - fmtg(jdn_o+56), NONE - ! Catholic: Gregorian computus, already in Gregorian calendar - call gregorian_easter(year, em, ed) - jdn_c = greg2jdn(year, em, ed) - write(*,'(4X,2X,A8,2X,A6,2X,A6,2X,A6,2X,A6,2X,A6)') & - 'Catholic', fmtg(jdn_c), fmtg(jdn_c+39), fmtg(jdn_c+49), & - fmtg(jdn_c+56), fmtg(jdn_c+60) - write(*,*) - end subroutine post_rows - -end program christian_feasts diff --git a/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter-1.f b/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter.f similarity index 100% rename from Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter-1.f rename to Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter.f diff --git a/Task/Holidays-related-to-Easter/FutureBasic/holidays-related-to-easter.basic b/Task/Holidays-related-to-Easter/FutureBasic/holidays-related-to-easter.basic deleted file mode 100644 index 14a98a2d12..0000000000 --- a/Task/Holidays-related-to-Easter/FutureBasic/holidays-related-to-easter.basic +++ /dev/null @@ -1,80 +0,0 @@ -begin enum 1 - _window : _scroll : _showOff - _clmYear : _clmEaster : _lblYear : _lblEaster - _inField : _outField -end enum - -void local fn buildInterface - window _window, @"Easter dates", ( 0, 0, 200, 200 ), 3 - scrollview _scroll, ( 20, 80, 170, 91 ) - textview _showOff, , _scroll - textlabel _clmYear, @"Year", ( 21, 168, 60, 22 ) - textlabel _clmEaster, @"Easter", ( 92, 168, 140, 22 ) - textlabel _lblYear, @"Year:", ( 40, 40, 100, 22 ) - textlabel _lblEaster, @"Easter:", ( 31, 10, 100, 22 ) - textlabel _outField, @"14 April", ( 87, 10, 100, 22 ) - textfield _inField, , @"14250", ( 85, 42, 70, 22 ) - ControlSetFormat ( _inField, @"0123456789", YES, 7, 0 ) - TextSetFont( _showOff, fn FontMonospacedDigitSystemFontOfSize( 12 , 0 ) ) - menu 1, , , @"File" : menu 1, 0, , @"Close", @"w" - MenuItemSetAction(1, 0, @"performClose:") - editmenu 2 - WindowMakeFirstResponder( _window, _inField ) -end fn - -clear local fn easter( year as NSInteger) as CFStringRef - NSInteger goldenNumber, leapDays, century, epact - NSInteger moonAdjust, leapAdjust,fullMoon, easter - CFStringRef s = @"" - goldenNumber = year mod 19 + 1 ' moon phase on 1 Jan - if year < 1583 - // Algorithm by Dionysius Exiguus, 525 - leapDays = 5 * year / 4 ' one leap year every four years - epact = ( 11 * goldenNumber - 4 ) mod 30 ' moon phase on 22 March - else - // Algorithm by Christoph Clavius, 1582 (see D. Knuth: CACM 1962;5:209) - century = int( year / 100 ) + 1 - leapAdjust = int( ( 3 * century / 4 ) - 12 ) ' correct leap years - leapDays = int( 5 * year / 4 ) - leapAdjust - 10 ' new calculation of leap days - moonAdjust = int( ( 8 * century + 5 ) / 25 ) - 5 ' correct moon cycle - epact = ( 11 * goldenNumber + moonAdjust - leapAdjust + 20 ) mod 30 ' new calculation of moon phase - if epact < 0 then epact += 30 - if ( epact = 24 or ( epact = 25 and goldenNumber > 11 ) ) then epact ++ ' final tweaks - end if - fullMoon = 44 - epact ' find first full moon in March - if fullMoon < 21 then fullMoon += 30 ' not before 21 March - easter = fullMoon + 7 - ( ( leapDays + fullMoon ) mod 7 ) ' find Sunday after first full moon in March - if easter < 32 - s = fn StringWithFormat( @"%u March", easter ) - else - s = fn StringWithFormat( @"%u April", easter - 31 ) - end if -end fn = s - -void local fn showOff - NSInteger year - CFMutableStringRef s = @"", t - for year = 532 to 2100 ' 532 is first year of Dionysius' tables - t = fn StringWithFormat( @"%u%@%@\n", year, @" ", fn easter( year) ) - s = fn StringByAppendingString( s, t ) - next - s = left( s, len( s ) - 1 ) ' cosmetic: remove last line feed - TextSetString( _showOff, s ) -end fn - -void local fn doEvents( evt as Long, tag as Long ) - NSInteger t - select evt - case _textFieldDidChange - ControlSetStringValue ( _outField, @"" ) - t = fn ControlIntegerValue( _inField ) - if t > 531 then ControlSetStringValue ( _outField, fn easter( t ) ) - case _windowShouldClose : end - end select -end fn - -fn buildInterface -fn showOff -on dialog fn doEvents - -handleevents diff --git a/Task/Holidays-related-to-Easter/JavaScript/holidays-related-to-easter-1.js b/Task/Holidays-related-to-Easter/JavaScript/holidays-related-to-easter-1.js index 9b43ccc463..eb688361e3 100644 --- a/Task/Holidays-related-to-Easter/JavaScript/holidays-related-to-easter-1.js +++ b/Task/Holidays-related-to-Easter/JavaScript/holidays-related-to-easter-1.js @@ -1,6 +1,8 @@ -const Пасха = г => { - let д = (д => д + (г % 4 * 2 + г * 4 + 6 * д + 6) % 7)((г % 19 * 19 + 15) % 30); - return new Date(г, 2, 22 + д + (г >= 1918 ? (г / 100 | 0) - (г / 400 | 0) - 2 : 0)); +const Пасха = год => { + let дата = (год % 19 * 19 + 15) % 30; + дата += (год % 4 * 2 + год % 7 * 4 + 6 * дата + 6) % 7; + if (год >= 1918) дата += (год / 100 | 0) - (год / 400 | 0) - 2; + return new Date(год, 2, 22 + дата); }; for (let год = 400; год <= 2100; год += год < 2000 ? 100 : год >= 2020 ? 80 : год < 2010 ? 10 : 1) { diff --git a/Task/Holidays-related-to-Easter/Julia/holidays-related-to-easter.jl b/Task/Holidays-related-to-Easter/Julia/holidays-related-to-easter.jl deleted file mode 100644 index 28209ba962..0000000000 --- a/Task/Holidays-related-to-Easter/Julia/holidays-related-to-easter.jl +++ /dev/null @@ -1,42 +0,0 @@ -using Dates -using Printf - -function easter(year::Int)::Date - a = rem(year, 19) - b, c = divrem(year, 100) - d = rem(19a + b - div(b, 4) - div(b - div(b + 8, 25) + 1, 3) + 15, 30) - e = rem(32 + 2 * rem(b, 4) + 2 * div(c, 4) - d - rem(c, 4), 7) - f = d + e - 7 * div(a + 11d + 22e, 451) + 114 - month, day = divrem(f, 31) - day += 1 - return Date(year, month, day) -end - -function holiday_values(year::Int)::Dict{String,Date} - offsets = Dict{String,Day}("Easter" => Day(0), "Ascension" => Day(39), - "Pentecost" => Day(49), "Trinity" => Day(56), "Corpus" => Day(60)) - easterdate = easter(year) - rst = Dict{String,Date}(holiday => easterdate + days for (holiday, days) in offsets) - return rst -end - -function holiday2str(year::Int)::String - function holiday2str(holiday::String, date::Date)::String - dayname, daynumb, month = dayabbr(date), day(date), monthabbr(date) - return @sprintf "%s: %s %2i %s" holiday dayname daynumb month - end - cal = holiday_values(year) - rst = join(collect(holiday2str(hday, cal[hday]) for hday in - ("Easter", "Ascension", "Pentecost", "Trinity", "Corpus")), ", ") - return "$year -> " * rst -end - -println("\nChristian holidays, related to Easter, for each centennial from 400 to 2100 CE:") -for yr in 400:100:2200 - println(holiday2str(yr)) -end - -println("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:") -for yr in 2010:2020 - println(holiday2str(yr)) -end diff --git a/Task/Holidays-related-to-Easter/Julia/holidays-related-to-easter.julia b/Task/Holidays-related-to-Easter/Julia/holidays-related-to-easter.julia new file mode 100644 index 0000000000..f194811192 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Julia/holidays-related-to-easter.julia @@ -0,0 +1,43 @@ +# v0.6 + +using Dates + +function easter(year::Int)::Date + a = rem(year, 19) + b, c = divrem(year, 100) + d = rem(19a + b - div(b, 4) - div(b - div(b + 8, 25) + 1, 3) + 15, 30) + e = rem(32 + 2 * rem(b, 4) + 2 * div(c, 4) - d - rem(c, 4), 7) + f = d + e - 7 * div(a + 11d + 22e, 451) + 114 + month, day = divrem(f, 31) + day += 1 + return Date(year, month, day) +end + +function holiday_values(year::Int)::Dict{String,Date} + offsets = Dict{String,Day}("Easter" => Day(0), "Ascension" => Day(39), + "Pentecost" => Day(49), "Trinity" => Day(56), "Corpus" => Day(60)) + easterdate = easter(year) + rst = Dict{String,Date}(holiday => easterdate + days for (holiday, days) in offsets) + return rst +end + +function holiday2str(year::Int)::String + function holiday2str(holiday::String, date::Date)::String + dayname, daynumb, month = dayabbr(date), day(date), monthabbr(date) + return @sprintf "%s: %s %2i %s" holiday dayname daynumb month + end + cal = holiday_values(year) + rst = join(collect(holiday2str(hday, cal[hday]) for hday in + ("Easter", "Ascension", "Pentecost", "Trinity", "Corpus")), ", ") + return "$year -> " * rst +end + +println("\nChristian holidays, related to Easter, for each centennial from 400 to 2100 CE:") +for yr in 400:100:2200 + println(holiday2str(yr)) +end + +println("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:") +for yr in 2010:2020 + println(holiday2str(yr)) +end diff --git a/Task/Holidays-related-to-Easter/Kotlin/holidays-related-to-easter.kts b/Task/Holidays-related-to-Easter/Kotlin/holidays-related-to-easter.kotlin similarity index 100% rename from Task/Holidays-related-to-Easter/Kotlin/holidays-related-to-easter.kts rename to Task/Holidays-related-to-Easter/Kotlin/holidays-related-to-easter.kotlin diff --git a/Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-1.ps1 b/Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-1.psh similarity index 100% rename from Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-1.ps1 rename to Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-1.psh diff --git a/Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-2.ps1 b/Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-2.psh similarity index 100% rename from Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-2.ps1 rename to Task/Holidays-related-to-Easter/PowerShell/holidays-related-to-easter-2.psh diff --git a/Task/Holidays-related-to-Easter/Rust/holidays-related-to-easter.rs b/Task/Holidays-related-to-Easter/Rust/holidays-related-to-easter.rs deleted file mode 100644 index 787d95bfe8..0000000000 --- a/Task/Holidays-related-to-Easter/Rust/holidays-related-to-easter.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::ops::Add; - -use chrono::{prelude::*, Duration}; - -#[allow(clippy::cast_possible_truncation)] -#[allow(clippy::cast_sign_loss)] -#[allow(clippy::cast_possible_wrap)] -fn get_easter_day(year: u32) -> chrono::NaiveDate { - let k = (f64::from(year) / 100.).floor(); - let d = (19 * (year % 19) - + ((15 - ((13. + 8. * k) / 25.).floor() as u32 + k as u32 - (k / 4.).floor() as u32) % 30)) - % 30; - let e = - (2 * (year % 4) + 4 * (year % 7) + 6 * d + ((4 + k as u32 - (k / 4.).floor() as u32) % 7)) - % 7; - - let (month, day) = match d { - 29 if e == 6 => (4, 19), - 28 if e == 6 => (4, 18), - _ if d + e < 10 => (3, 22 + d + e), - _ => (4, d + e - 9), - }; - - NaiveDate::from_ymd_opt(year as i32, month, day).unwrap() -} -fn main() { - let holidays = vec![ - ("Easter", Duration::days(0)), - ("Ascension", Duration::days(39)), - ("Pentecost", Duration::days(49)), - ("Trinity", Duration::days(56)), - ("Corpus Christi", Duration::days(60)), - ]; - for year in (400..=2100).step_by(100).chain(2010..=2020) { - print!("{}: ", year); - for (name, offset) in &holidays { - print!( - "{}: {}, ", - name, - get_easter_day(year).add(*offset).format("%a %d %h") - ); - } - println!(); - } -} diff --git a/Task/Holidays-related-to-Easter/Rust/holidays-related-to-easter.rust b/Task/Holidays-related-to-Easter/Rust/holidays-related-to-easter.rust new file mode 100644 index 0000000000..41c481bee7 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Rust/holidays-related-to-easter.rust @@ -0,0 +1,45 @@ +use std::ops::Add; + +use chrono::{prelude::*, Duration}; + +#[allow(clippy::cast_possible_truncation)] +#[allow(clippy::cast_sign_loss)] +#[allow(clippy::cast_possible_wrap)] +fn get_easter_day(year: u32) -> chrono::NaiveDate { + let k = (f64::from(year) / 100.).floor(); + let d = (19 * (year % 19) + + ((15 - ((13. + 8. * k) / 25.).floor() as u32 + k as u32 - (k / 4.).floor() as u32) % 30)) + % 30; + let e = + (2 * (year % 4) + 4 * (year % 7) + 6 * d + ((4 + k as u32 - (k / 4.).floor() as u32) % 7)) + % 7; + + let (month, day) = match d { + 29 if e == 6 => (4, 19), + 28 if e == 6 => (4, 18), + _ if d + e < 10 => (3, 22 + d + e), + _ => (4, d + e - 9), + }; + + NaiveDate::from_ymd(year as i32, month, day) +} +fn main() { + let holidays = vec![ + ("Easter", Duration::days(0)), + ("Ascension", Duration::days(39)), + ("Pentecost", Duration::days(49)), + ("Trinity", Duration::days(56)), + ("Corpus Christi", Duration::days(60)), + ]; + for year in (400..=2100).step_by(100).chain(2010..=2020) { + print!("{}: ", year); + for (name, offset) in &holidays { + print!( + "{}: {}, ", + name, + get_easter_day(year).add(*offset).format("%a %d %h") + ); + } + println!(); + } +} diff --git a/Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.scm b/Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.ss similarity index 100% rename from Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.scm rename to Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.ss diff --git a/Task/Holidays-related-to-Easter/Wren/holidays-related-to-easter.wren b/Task/Holidays-related-to-Easter/Wren/holidays-related-to-easter.wren index 4e79976f3c..f6eb5af1bd 100644 --- a/Task/Holidays-related-to-Easter/Wren/holidays-related-to-easter.wren +++ b/Task/Holidays-related-to-Easter/Wren/holidays-related-to-easter.wren @@ -1,6 +1,6 @@ -import "./date" for Date -import "./fmt" for Fmt -import "./iterate" for Stepped +import "/date" for Date +import "/fmt" for Fmt +import "/iterate" for Stepped var holidayOffsets = [ ["Easter", 0], diff --git a/Task/Home-primes/FutureBasic/home-primes.basic b/Task/Home-primes/FutureBasic/home-primes.basic deleted file mode 100644 index e88f384f48..0000000000 --- a/Task/Home-primes/FutureBasic/home-primes.basic +++ /dev/null @@ -1,888 +0,0 @@ -// ------------------------------------------------------------ -// Home primes -// -// Using FutureBasic 7.0.37 -// November 2025, R.W. -// -// This code is a lot longer than needed. Simply because I -// refused to use Pollard Rho (it's very slow and unreliable). -// So I used pseudo ECM (ECF) for factorization. Much faster. -// -// Output includes Rosetta Task requiring HP65 to be included -// it also has the "impossible" HP49 (just click [next]..) -// ------------------------------------------------------------ - -include "gmp.incl" - -CFTimeInterval tim - -long gN // the next starting integer for [Next] batches -// Global mpz_t bigints reused for speed -mpz_t num, den, inv, t1, t2, g - -mpz_t pp, tmpN, tmpFactor -mpz_t fm -mpz_t gFactors(31) -int gFactorCount - - -// ----------------------------------------------------------- -// Helper: Abbreviate big numeric CFString: head...tail -// ----------------------------------------------------------- -local fn AbbrevString( s as CFStringRef, head as int, ¬ - tail as int ) as CFStringRef - if s == 0 then RETURN @"" - CFStringRef a, b, out - int nLen - nLen = len( s ) - if nLen <= head + tail then RETURN s - a = left( s, head ) - b = right( s, tail ) - out = @"" - out = concat( a, @"...", b ) -end fn = out - -// ----------------------------------------------------------- -// Helper: Get mpz_t result and abbreviate if > 43 digits -// ----------------------------------------------------------- -local fn Abbrev( ts as mpz_t ) as CFStringRef - CFStringRef result - result = fn mpz_cf2( ts ) // FB wrapper mpz_t to CFString - int nLen - nLen = len( result ) - if nLen <= 43 then RETURN result - result = fn AbbrevString( result, 20, 20 ) -end fn = result - -// ----------------------------------------------------------- -// Helper: Convert mpz_t to CFString -// ----------------------------------------------------------- -local fn mpz_to_CFString( m as mpz_t ) as CFStringRef - CFStringRef result = @"" - result = fn mpz_cf2( m ) //FB wrapper mpz_t to CFString base 10 -end fn = result -// ----------------------------------------------------------- -// Helper: Is n probably prime? -// ----------------------------------------------------------- -local fn IsProbablePrime( n as mpz_t ) as boolean - int r - r = fn mpz_probab_prime_p( n, 25 ) // 25 reps should be sufficient - // r = 0 (composite), 1 (probable prime), 2 (definite prime) - if r > 0 then RETURN _true -end fn = _false - -// ------------------------------------------------------------ -// Small prime test for Int input -// Uses mpz_probab_prime_p with gmp -// ------------------------------------------------------------ -local fn IsPrimeInt( n as long ) as Boolean - if n < 2 then RETURN _false - fn mpz_set_si( pp, n ) - int r - r = fn mpz_probab_prime_p( pp, 15 ) - if r > 0 then RETURN _true -end fn = _false - -// ----------------------------------------------------------- -// Helper: Simple 32-bit primality test for Stage 1 ECM -// ----------------------------------------------------------- -local fn IsSmallPrime32( p as UInt32 ) as boolean - if p < 2 then return _false - if p = 2 then return _true - if (p AND 1) == 0 then return _false - - UInt32 d - d = 3 - while d * d <= p - if (p MOD d) == 0 then return _false - d = d + 2 - wend - -end fn = _true - -// Clear global mpz -void local fn clear_MPZ - mpz_clear( num ) - mpz_clear( den ) - mpz_clear( inv ) - mpz_clear( t1 ) - mpz_clear( t2 ) - mpz_clear( g ) -end fn - -// Init global mpz -void local fn Init_MPZ - mpz_init( num ) - mpz_init( den ) - mpz_init( inv ) - mpz_init( t1 ) - mpz_init( t2 ) - mpz_init( g ) -end fn - -// --------------------------------------------------------------- -// ECM_PointDouble -// Point doubling: P = (x,y) → 2P on y^2 = x^3 + a x + b (MOD n) -// Returns _true if a nontrivial factor found (in 'factor'), -// else _false. -// On success, 'factor' holds GCD > 1, < n, and x,y are undefined -// On normal completion, x,y are updated to 2P. -// --------------------------------------------------------------- - -local fn ECM_PointDouble( n as mpz_t, a as mpz_t, ¬ - x as mpz_t, y as mpz_t, factor as mpz_t ) as boolean - - fn Init_MPZ - - mpz_mul( t1, x, x ) // num = 3 * x^2 + a (MOD n) - mpz_mod( t1, t1, n ) // t1 = x^2 - mpz_mul_ui( num, t1, 3 ) // num = 3*x^2 - mpz_add( num, num, a ) - mpz_mod( num, num, n ) - - mpz_mul_ui( den, y, 2 ) // den = 2*y (MOD n) - mpz_mod( den, den, n ) - - if fn mpz_invert( inv, den, n ) == 0 // try to invert den - // inversion failed -> GCD(den, n) may give a factor? - // do you feel lucky, punk? - mpz_GCD( g, den, n ) - if (fn mpz_cmp_ui( g, 1 ) > 0) && (fn mpz_cmp( g, n ) < 0) - mpz_set( factor, g ) - fn Clear_MPZ - return _true - end if - // GCD == 1 or GCD == n -> useless curve (sigh) - fn Clear_MPZ - return _false - end if - - mpz_mul( t1, num, inv ) // lambda = num * inv (MOD n) - mpz_mod( t1, t1, n ) // t1 = lambda - - // x3 = lambda^2 - 2 * x (MOD n) - mpz_mul( t2, t1, t1 ) // lambda^2 - mpz_mod( t2, t2, n ) - mpz_mul_ui( num, x, 2 ) // 2x - mpz_mod( num, num, n ) - mpz_sub( t2, t2, num ) - mpz_mod( t2, t2, n ) // t2 = x3 - - // y3 = lambda * (x - x3) - y (MOD n) - mpz_sub( num, x, t2 ) // x - x3 - mpz_mod( num, num, n ) - mpz_mul( num, t1, num ) // lambda * (x - x3) - mpz_mod( num, num, n ) - mpz_sub( num, num, y ) // lambda * (x - x3) - y - mpz_mod( num, num, n ) // num = y3 - - mpz_set( x, t2 ) // update P ← (x3, y3) - mpz_set( y, num ) - - fn Clear_MPZ -end fn = _false - -// ----------------------------------------------------------- -// ECM_PointAdd -// Point addition: P1 = (x1,y1) ← P1 + P2, with P2 = (x2,y2) -// Curve: y^2 = x^3 + a x + b (MOD n) -// Returns _true if a factor found (in 'factor'), else _false. -// ----------------------------------------------------------- -local fn ECM_PointAdd( n as mpz_t, a as mpz_t, x1 as mpz_t, ¬ - y1 as mpz_t, x2 as mpz_t, y2 as mpz_t, factor as mpz_t ) as boolean - - fn Init_MPZ - - mpz_sub( t1, n, y2 ) // t1 = -y2 MOD n - mpz_mod( t1, t1, n ) - // If x1 == x2 and y1 == -y2, point is infinity - // For our purposes, treat this as a useless -> just return _false. - if (fn mpz_cmp( x1, x2 ) == 0) && (fn mpz_cmp( y1, t1 )== 0) - fn Clear_MPZ - return _false - end if - - mpz_sub( num, y2, y1 ) // num = y2 - y1 (MOD n) - mpz_mod( num, num, n ) - - mpz_sub( den, x2, x1 ) // den = x2 - x1 (MOD n) - mpz_mod( den, den, n ) - - // try to invert den - if fn mpz_invert( inv, den, n ) == 0 - mpz_GCD( g, den, n ) - if (fn mpz_cmp_ui( g, 1 ) > 0) && (fn mpz_cmp( g, n ) < 0) - mpz_set( factor, g ) - fn Clear_MPZ - return _true - end if - fn Clear_MPZ - return _false - end if - - mpz_mul( t1, num, inv ) // lambda = num * inv (MOD n) - mpz_mod( t1, t1, n ) // t1 = lambda - - // x3 = lambda^2 - x1 - x2 (MOD n) - mpz_mul( t2, t1, t1 ) // lambda^2 - mpz_mod( t2, t2, n ) - mpz_sub( t2, t2, x1 ) - mpz_sub( t2, t2, x2 ) - mpz_mod( t2, t2, n ) // t2 = x3 - - // y3 = lambda * (x1 - x3) - y1 (MOD n) - mpz_sub( num, x1, t2 ) // x1 - x3 - mpz_mod( num, num, n ) - mpz_mul( num, t1, num ) - mpz_mod( num, num, n ) - mpz_sub( num, num, y1 ) - mpz_mod( num, num, n ) // num = y3 - - mpz_set( x1, t2 ) - mpz_set( y1, num ) - - fn Clear_MPZ - -end fn = _false - -// ------------------------------------------------------------ -// ECM_ScalarMul -// Scalar multiply P = (x,y) by k: P ← k * P -// Uses binary double-and-add. Returns _true if a factor found. -// ------------------------------------------------------------ - -local fn ECM_ScalarMul( n as mpz_t, a as mpz_t, x as mpz_t, ¬ - y as mpz_t, k as UInt64, factor as mpz_t ) as boolean - - if k <= 1 then return _false - - mpz_t rx, ry, qx, qy - mpz_init( rx ) - mpz_init( ry ) - mpz_init( qx ) - mpz_init( qy ) - - int hasR - hasR = _false // R (result) is "not set" yet - - mpz_set( qx, x ) // Q = P (base) - mpz_set( qy, y ) - - // find highest bit of k - int sbit - sbit = 63 - while (sbit > 0) && ((k AND (1ULL << sbit)) = 0) - sbit -- // decrement bit - wend - - // process bits from MSB down to 0 - while sbit >= 0 - if hasR - // R = 2R - if fn ECM_PointDouble( n, a, rx, ry, factor ) - // factor found - mpz_clear( rx ) - mpz_clear( ry ) - mpz_clear( qx ) - mpz_clear( qy ) - return _true - end if - end if - - if (k AND (1ULL << sbit)) != 0 - if hasR = _false - // first 1 bit: R = Q - mpz_set( rx, qx ) - mpz_set( ry, qy ) - hasR = _true - else - // R = R + Q - if fn ECM_PointAdd( n, a, rx, ry, qx, qy, factor ) - mpz_clear( rx ) - mpz_clear( ry ) - mpz_clear( qx ) - mpz_clear( qy ) - return _true - end if - end if - end if - - sbit -- // decrement bit - wend - - if hasR - mpz_set( x, rx ) - mpz_set( y, ry ) - end if - - mpz_clear( rx ) - mpz_clear( ry ) - mpz_clear( qx ) - mpz_clear( qy ) -end fn = _false - - -// ---------------------------------------------------------------- -// ECM_Stage1Curve -// Stage-1 ECM on one curve determined by 'sigma' -// Curve: y^2 = x^3 + a x + b (MOD n) with (x,y) chosen from sigma. -// B1: first-stage bound, e.g. 10000. -// Returns _true and sets 'factor' if a factor was -// found, else _false. -// ---------------------------------------------------------------- - -local fn ECM_Stage1Curve( n as mpz_t, factor as mpz_t, ¬ - B1 as UInt32, sigma as UInt32 ) as boolean - - mpz_t a, b, x, y, tmp - mpz_init( a ) - mpz_init( b ) - mpz_init( x ) - mpz_init( y ) - mpz_init( tmp ) - - mpz_set_ui( x, sigma ) // x = sigma (MOD n) - mpz_mod( x, x, n ) - - mpz_set_ui( y, sigma + 1 ) // y = sigma + 1 (MOD n) - mpz_mod( y, y, n ) - - mpz_set_ui( a, sigma + 2 ) // a = sigma + 2 (MOD n) - mpz_mod( a, a, n ) - - // b = y^2 - x^3 - a*x (MOD n) - mpz_mul( b, y, y ) // y^2 - mpz_mod( b, b, n ) - - mpz_mul( tmp, x, x ) // x^2 - mpz_mod( tmp, tmp, n ) - mpz_mul( tmp, tmp, x ) // x^3 - mpz_mod( tmp, tmp, n ) - mpz_sub( b, b, tmp ) // y^2 - x^3 - - mpz_mul( tmp, a, x ) // a * x - mpz_mod( tmp, tmp, n ) - mpz_sub( b, b, tmp ) // y^2 - x^3 - a*x - mpz_mod( b, b, n ) - - // Multiply P by prime powers p^e with p <= B1 - UInt32 p, pe - p = 2 - - while p <= B1 - if fn IsSmallPrime32( p ) - // pe = p^e <= B1 - pe = p - while (pe * p) <= B1 - pe = pe * p - wend - - if fn ECM_ScalarMul( n, a, x, y, pe, factor ) - // factor found - mpz_clear( a ) - mpz_clear( b ) - mpz_clear( x ) - mpz_clear( y ) - mpz_clear( tmp ) - return _true - end if - end if - - if p == 2 then p = 3 else p = p + 2 - wend - - mpz_clear( a ) - mpz_clear( b ) - mpz_clear( x ) - mpz_clear( y ) - mpz_clear( tmp ) -end fn = _false - -// ----------------------------------------------------------- -// ECM_FindFactor -// Try several Stage-1 ECM curves with increasing sigma. -// Returns _true and sets 'factor' if a factor is found. -// ----------------------------------------------------------- - -local fn ECM_FindFactor( n as mpz_t, factor as mpz_t ) as boolean - UInt32 B1, sigma - int curves - int i - B1 = 10000 // bound (bigger = slower) - curves = 20 // number of different curves to try - sigma = 2 - i = 0 - while i < curves - if fn ECM_Stage1Curve( n, factor, B1, sigma ) - return _true - end if - sigma ++ - i ++ - wend -end fn = _false - -// Safely divide mpz_t - -local fn SafeMpzDiv( z as mpz_t, x as mpz_t, y as mpz_t ) as boolean - if ( fn mpz_sgn( y ) == 0 ) // div by zero? - mpz_set_ui( z, 0) - return _false - end if - // Call GMP division (truncate toward zero) - mpz_tdiv_q( z, x, y ) -end fn = _true - - -// ----------------------------------------------------------- -// Recursive factorization using ECM Stage 1 -// Results go into global gFactors() / gFactorCount -// trustProbPrime = _true → use IsProbablePrime shortcut -// trustProbPrime = _false → NEVER trust IsProbablePrime; rely on ECM -// ----------------------------------------------------------- -void local fn FactorRec( n as mpz_t, trustProbPrime as boolean ) - // if n == 1 → nothing - if fn mpz_cmp_ui( n, 1 ) = 0 then RETURN - - // If allowed, trust mpz_probab_prime_p - if trustProbPrime - if fn IsProbablePrime( n ) - mpz_set( gFactors( gFactorCount ), n ) - gFactorCount = gFactorCount + 1 - RETURN - end if - end if - - mpz_t d, q - mpz_init( d ) - mpz_init( q ) - - Boolean got - got = fn ECM_FindFactor( n, d ) - - if got == _false - // ECM did not find a nontrivial factor; treat n as final factor - mpz_set( gFactors( gFactorCount ), n ) - gFactorCount = gFactorCount + 1 - mpz_clear( d ) - mpz_clear( q ) - RETURN - end if - - if fn SafeMpzDiv( q, n, d ) // q = n / d - // recurse on d and q with the same mode - fn FactorRec( d, trustProbPrime ) - fn FactorRec( q, trustProbPrime ) - end if - - mpz_clear( d ) - mpz_clear( q ) -end fn - -// ------------------------------------------------------------ -// FactorStringUnderscore -// Factor j into primes and build "p1_p2_p3" as CFStringRef -// forceFull = _false → use IsProbablePrime shortcut (fast) -// forceFull = _true → ignore IsProbablePrime, full ECM -// ------------------------------------------------------------ -local fn FactorStringUnderscore( j as mpz_t, forceFull as boolean ) as CFStringRef - CFStringRef outStr = @"" - - // Work copy of j in fm, factor |j| - fn mpz_set( fm, j ) - fn mpz_abs( fm, fm ) - - // If fm < 2, nothing to do - if fn mpz_cmp_ui( fm, 2 ) < 0 then RETURN outStr - - // Reset factor buffer - gFactorCount = 0 - - // Fill gFactors[0..gFactorCount-1] with prime factors (not sorted) - // trustProbPrime = NOT forceFull - Boolean trustProbPrime - trustProbPrime = _true - if forceFull then trustProbPrime = _false - - fn FactorRec( fm, trustProbPrime ) - - // If FactorRec somehow didn't produce anything, bail out - if gFactorCount <= 0 then RETURN outStr - - // sort factors in ascending order (same as before) - int i, jidx - mpz_t tmp - mpz_init( tmp ) - - i = 0 - while i < gFactorCount - 1 - jidx = i + 1 - while jidx < gFactorCount - if fn mpz_cmp( gFactors(i), gFactors(jidx) ) > 0 - fn mpz_set( tmp, gFactors(i) ) - fn mpz_set( gFactors(i), gFactors(jidx) ) - fn mpz_set( gFactors(jidx), tmp ) - end if - jidx++ - wend - i++ - wend - - mpz_clear( tmp ) - - // build "p1_p2_p3_..." string - outStr = @"" - i = 0 - while i < gFactorCount - if i > 0 - outStr = concat( outStr, @"_" ) - end if - outStr = concat( outStr, fn mpz_to_CFString( gFactors(i) ) ) - i++ - wend - -end fn = outStr - -// ------------------------------------------------------------ -// FactorConcat (ECM-based) -// Factor j into primes using FactorRec (ECM + primality test), -// collect factors in ascending order, and concatenate them -// ------------------------------------------------------------ -local fn FactorConcat( j as mpz_t ) as CFStringRef - CFStringRef outStr = @"" - - // Work copy of j in fm, factor |j| - fn mpz_set( fm, j ) - fn mpz_abs( fm, fm ) - - // If fm < 2, nothing to do - if fn mpz_cmp_ui( fm, 2 ) < 0 then RETURN outStr - - // Reset factor buffer - gFactorCount = 0 - - // Fill gFactors[0..gFactorCount-1] with prime factors (not sorted) - fn FactorRec( fm, _true ) // for chain math, trust probable primes - - // If FactorRec somehow didn't produce anything, bail out - if gFactorCount <= 0 then RETURN outStr - - // sort factors in ascending order - int i, jidx - mpz_t tmp - mpz_init( tmp ) - - i = 0 - while i < gFactorCount - 1 - jidx = i + 1 - while jidx < gFactorCount - if fn mpz_cmp( gFactors(i), gFactors(jidx) ) > 0 - // swap gFactors(i) and gFactors(jidx) - fn mpz_set( tmp, gFactors(i) ) - fn mpz_set( gFactors(i), gFactors(jidx) ) - fn mpz_set( gFactors(jidx), tmp ) - end if - jidx++ - wend - i++ - wend - - mpz_clear( tmp ) - - // build concatenated decimal string of prime factors - outStr = @"" - i = 0 - while i < gFactorCount - outStr = concat( outStr, fn mpz_to_CFString( gFactors(i) ) ) - i++ - wend - -end fn = outStr - - -// Max chain length we’re willing to handle -_kMaxChain = 32 - -// ------------------------------------------------------------ -// Home_Prime_Chain -// Build Home Prime chain for integer n -// - Uses FactorConcat (ECM-backed) for factoring -// - Stops when value is prime OR when no progress is made -// ------------------------------------------------------------ -local fn Home_Prime_Chain( n as long ) as CFStringRef - CFStringRef result = @"" - CFStringRef pad = @" " - CFStringRef chain - CFStringRef nStr, iterStr, tmpCF - - // Guard: n < 2 → empty - if n < 2 then RETURN result - - // If n is prime: "HPn = n" - if fn IsPrimeInt( n ) - nStr = mid( str( n ), 1 ) - chain = concat( @"HP", nStr ) - chain = concat( chain, left( pad, 10 - len( chain ) ), @"= " ) - chain = concat( chain, nStr ) - result = chain - RETURN result - end if - - // ---------------------------------------- - // Otherwise, build the chain using GMP - // h[0..iterCount] hold the successive values - // ---------------------------------------- - _kMaxSteps = 64 - mpz_t h( _kMaxSteps - 1 ) - int i - - // initialize mpz_t array - i = 0 - while i < _kMaxSteps - fn mpz_init( h(i) ) - i++ - wend - - int iterCount - iterCount = 0 - - CFStringRef concatStr - CFStringRef oneDigit - - // Track previous value to detect "no progress" stalls - mpz_t prevN - fn mpz_init( prevN ) - int stalled - stalled = _false - - // h[0] = initial n - fn mpz_set_si( h(0), n ) - fn mpz_set_si( tmpN, n ) // current value in the chain - - // iterate until prime, stall, or max steps - while iterCount < _kMaxSteps - int isPrime - isPrime = fn mpz_probab_prime_p( tmpN, 15 ) - if isPrime > 0 - // Probable prime: normal termination - exit while - end if - - // Save previous value so we can detect no progress - fn mpz_set( prevN, tmpN ) - - // Not prime: factor tmpN, build concatenation string of prime factors - concatStr = fn FactorConcat( tmpN ) // decimal string of concatenated factors - - // Build new tmpN from decimal digits of concatStr - fn mpz_set_ui( tmpN, 0 ) - - int L, dpos, digit - L = len( concatStr ) - dpos = 1 - - while dpos <= L - // CFString mid() is 0-based: start at dpos-1 - oneDigit = mid( concatStr, dpos - 1, 1 ) - digit = IntVal( oneDigit ) // CFStringRef → int digit (0–9) - fn mpz_mul_ui( tmpN, tmpN, 10 ) - fn mpz_add_ui( tmpN, tmpN, digit ) - dpos++ - wend - - // Check for "no progress": new tmpN == prevN ⇒ factoring failed / stalled - if fn mpz_cmp( tmpN, prevN ) == 0 - stalled = _true - exit while - end if - - // Store this term in the chain - iterCount++ - if iterCount < _kMaxSteps - fn mpz_set( h(iterCount), tmpN ) - end if - wend - - // Safety clamp if we bailed by hitting the step cap - if iterCount >= _kMaxSteps - iterCount = _kMaxSteps - 1 - stalled = _true - end if - - // iterCount is the index of the final value in h[] - CFStringRef finalStr - finalStr = fn Abbrev( h(iterCount) ) - - // ---------------------------------------------- - // Build the chain in multi-line readable format - // ---------------------------------------------- - chain = @"" - - // First line: HPn(iterCount) - pad = @" " - nStr = mid( str( n ), 1 ) - iterStr = mid( str( iterCount ), 1 ) - - chain = concat( chain, @"HP" ) - chain = concat( chain, nStr ) - if iterCount > 1 - chain = concat( chain, @" (" ) - chain = concat( chain, iterStr ) - chain = concat( chain, @")" ) - end if - chain = concat( chain, left( pad, 10 - len( chain ) ), @"= " ) - - // ---------------------------------------------------- - // Print each step on its own line, as factor strings: - // stepIndex = 1 → factors of h(0) (original n) - // stepIndex = 2 → factors of h(1), etc. - // remaining = iterCount - stepIndex - // ---------------------------------------------------- - int stepIndex - stepIndex = 1 - while stepIndex <= iterCount - 1 - int remaining - remaining = iterCount - stepIndex - - // Factor h(stepIndex-1) and show "p1_p2_p3" - // For intermediate steps we can use the fast mode (trust probable primes). - tmpCF = fn FactorStringUnderscore( h(stepIndex - 1), _false ) - iterStr = mid( str( remaining ), 1 ) - - if stepIndex == 1 - pad = @"" - else - pad = @" " - end if - - chain = concat( chain, pad ) - tmpCF = fn AbbrevString( tmpCF, 20, 20 ) - chain = concat( chain, tmpCF ) - chain = concat( chain, @" (" ) - chain = concat( chain, iterStr ) - chain = concat( chain, @")" ) - chain = concat( chain, @"\n" ) - - stepIndex++ - wend - - // Final line: just show the final value (probable prime) - if stepIndex > 1 - chain = concat( chain, @" " ) - end if - - //CFStringRef finalStr - finalStr = fn Abbrev( h(iterCount) ) - chain = concat( chain, finalStr ) - if stalled - chain = concat( chain, @" (stalled – factoring limit)" ) - end if - - result = chain - - // clear h[] and prevN - i = 0 - while i < _kMaxSteps - fn mpz_clear( h(i) ) - i++ - wend - fn mpz_clear( prevN ) - -end fn = result - -// ------------------------------------------------------------ -// More_HP -// show the next 20 Home Primes -// ------------------------------------------------------------ -void local fn More_HP - CFStringRef pline - long n - int count - - tim = fn CACurrentMediaTime - - count = 0 - n = gN - while count < 20 - pline = fn Home_Prime_Chain( n ) - print @pline - n++ - count++ - wend - - gN = n - if gN > 160 then button 2, NO - printf @"\nElapsed time: %.3f secs\n", ( fn CACurrentMediaTime - tim ) -end fn - -// ------------------------------------------------------------ -// Main — compute 2 to 20 Home primes -// ------------------------------------------------------------ -local fn Main - CFStringRef pline - long k - // init globals - fn mpz_init( pp ) - fn mpz_init( tmpN ) - fn mpz_init( tmpFactor ) - - int i - i = 0 - while i <= 30 - mpz_init( gFactors(i) ) - i++ - wend - - print @"Home Prime for integer 2 through 20:\n" - - tim = fn CACurrentMediaTime - - k = 2 - while k <= 20 - pline = fn Home_Prime_Chain( k ) - print @pline - k++ - wend - - printf @"\nElapsed time: %.3f secs\n", ( fn CACurrentMediaTime - tim ) - print @"Click [Next] for the next 20 Home primes.\n" - - // Prepare next batch start - gN = 21 -end fn - -// ------------------------------------------------------------ -// Dialog handler -// ------------------------------------------------------------ -void local fn DoDialog( ev as long, tag as long, wnd as long, obj as CFTypeRef ) - select ( ev ) - case _btnClick - select ( tag ) - case 2 - fn More_HP - end select - - case _windowShouldClose - // clear any uncleared mpz - fn mpz_clear( pp ) - fn mpz_clear( tmpN ) - fn mpz_clear( tmpFactor ) - end - end select -end fn - -on dialog fn DoDialog - -// ------------------------------------------------------------ -// Main -// ------------------------------------------------------------ -window 1, @"Home primes", (0,0,800,600) -button 2, YES,, @"Next", (680,20,100,20),,, 1 - -// init globals -fn mpz_init( pp ) -fn mpz_init( tmpN ) -fn mpz_init( tmpFactor ) - -fn Main - -HandleEvents diff --git a/Task/Home-primes/Java/home-primes.java b/Task/Home-primes/Java/home-primes.java deleted file mode 100644 index fb257016c4..0000000000 --- a/Task/Home-primes/Java/home-primes.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public final class HomePrimes { - - public static void main(String[] aArgs) { - listPrimes(PRIME_LIMIT); - - List values = - List.of( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 65 ); - for ( int value : values ) { - BigInteger number = BigInteger.valueOf(value); - List previousNumbers = Stream.of( number ).collect(Collectors.toList()); - boolean searching = true; - while ( searching ) { - number = concatenate(primeFactors(number)); - previousNumbers.add(number); - if ( number.isProbablePrime(CERTAINTY_LEVEL) ) { - final int lastIndex = previousNumbers.size() - 1; - for ( int k = lastIndex; k >= 1; k-- ) { - System.out.print("HP" + previousNumbers.get(lastIndex - k) + "(" + k + ") = "); - } - System.out.println(previousNumbers.get(lastIndex)); - searching = false; - } - } - } - } - - private static List primeFactors(BigInteger aNumber) { - List result = new ArrayList(); - - if ( aNumber.compareTo(BigInteger.valueOf(PRIME_LIMIT * PRIME_LIMIT)) <= 0 ) { - return smallPrimeFactors(aNumber); - } - - if ( aNumber.isProbablePrime(CERTAINTY_LEVEL) ) { - result.add(aNumber); - return result; - } - - BigInteger divisor = pollardRho(aNumber); - result.addAll(primeFactors(divisor)); - aNumber = aNumber.divide(divisor); - result.addAll(primeFactors(aNumber)); - Collections.sort(result); - return result; - } - - private static List smallPrimeFactors(BigInteger aNumber) { - int number = aNumber.intValueExact(); - List result = new ArrayList(); - - for ( int i = 0; i < primes.size() && number > 1; i++ ) { - while ( number % primes.get(i) == 0 ) { - result.add(BigInteger.valueOf(primes.get(i))); - number /= primes.get(i); - } - } - - if ( number > 1 ) { - result.add(BigInteger.valueOf(number)); - } - return result; - } - - private static BigInteger pollardRho(BigInteger aNumber) { - if ( ! aNumber.testBit(0) ) { - return BigInteger.TWO; - } - - final BigInteger constant = new BigInteger(aNumber.bitLength(), RANDOM); - BigInteger x = new BigInteger(aNumber.bitLength(), RANDOM); - BigInteger y = x; - BigInteger divisor = null; - - do { - x = x.multiply(x).add(constant).mod(aNumber); - y = y.multiply(y).add(constant).mod(aNumber); - y = y.multiply(y).add(constant).mod(aNumber); - divisor = x.subtract(y).gcd(aNumber); - } while ( divisor.compareTo(BigInteger.ONE) == 0 ); - return divisor; - } - - private static BigInteger concatenate(List aList) { - String number = aList.stream().map(String::valueOf).collect(Collectors.joining()); - return new BigInteger(number); - } - - public static void listPrimes(int aNumber) { - BitSet sieve = new BitSet(aNumber + 1); - sieve.set(2, aNumber + 1); - for ( int i = 2; i <= Math.sqrt(aNumber); i = sieve.nextSetBit(i + 1) ) { - for ( int j = i * i; j <= aNumber; j = j + i ) { - sieve.clear(j); - } - } - - primes = new ArrayList(sieve.cardinality()); - for ( int i = 2; i >= 0; i = sieve.nextSetBit(i + 1) ) { - primes.add(i); - } - } - - private static List primes; - - private static final int CERTAINTY_LEVEL = 20; - private static final int PRIME_LIMIT = 10_000; - private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current(); - -} diff --git a/Task/Home-primes/JavaScript/home-primes.js b/Task/Home-primes/JavaScript/home-primes.js deleted file mode 100644 index b848e04c01..0000000000 --- a/Task/Home-primes/JavaScript/home-primes.js +++ /dev/null @@ -1,240 +0,0 @@ -/** - * Home Primes calculator - JavaScript version - * Finds the home prime for a given number by repeatedly factorizing and concatenating - */ - -const CERTAINTY_LEVEL = 20; -const PRIME_LIMIT = 10000; - -class HomePrimes { - constructor() { - this.primes = []; - this.listPrimes(PRIME_LIMIT); - } - - /** - * Main function to calculate home primes for test values - */ - main() { - const values = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 65]; - - for (const value of values) { - let number = BigInt(value); - const previousNumbers = [number]; - let searching = true; - - while (searching) { - number = this.concatenate(this.primeFactors(number)); - previousNumbers.push(number); - - if (this.isProbablePrime(number, CERTAINTY_LEVEL)) { - const lastIndex = previousNumbers.length - 1; - let output = ''; - for (let k = lastIndex; k >= 1; k--) { - output += `HP${previousNumbers[lastIndex - k]}(${k}) = `; - } - output += previousNumbers[lastIndex]; - console.log(output); - searching = false; - } - } - } - } - - /** - * Get prime factors of a number using trial division or Pollard's Rho - */ - primeFactors(num) { - if (num <= BigInt(PRIME_LIMIT * PRIME_LIMIT)) { - return this.smallPrimeFactors(num); - } - - if (this.isProbablePrime(num, CERTAINTY_LEVEL)) { - return [num]; - } - - const divisor = this.pollardRho(num); - const result = [ - ...this.primeFactors(divisor), - ...this.primeFactors(num / divisor) - ]; - return result.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)); - } - - /** - * Trial division for smaller numbers - */ - smallPrimeFactors(num) { - let number = Number(num); - const result = []; - - for (let i = 0; i < this.primes.length && number > 1; i++) { - while (number % this.primes[i] === 0) { - result.push(BigInt(this.primes[i])); - number = Math.floor(number / this.primes[i]); - } - } - - if (number > 1) { - result.push(BigInt(number)); - } - return result; - } - - /** - * Pollard's Rho algorithm for integer factorization - */ - pollardRho(num) { - // Check if even - if ((num & BigInt(1)) === BigInt(0)) { - return BigInt(2); - } - - const bitLength = num.toString(2).length; - const constant = this.randomBigInt(bitLength); - let x = this.randomBigInt(bitLength); - let y = x; - let divisor = BigInt(1); - - while (divisor === BigInt(1)) { - x = (x * x + constant) % num; - y = (y * y + constant) % num; - y = (y * y + constant) % num; - divisor = this.gcd(x > y ? x - y : y - x, num); - } - - return divisor; - } - - /** - * Concatenate list of BigInts into a single BigInt - */ - concatenate(list) { - const str = list.map(n => n.toString()).join(''); - return BigInt(str); - } - - /** - * Sieve of Eratosthenes to generate primes up to limit - */ - listPrimes(limit) { - const sieve = new Array(limit + 1).fill(true); - sieve[0] = false; - sieve[1] = false; - - for (let i = 2; i * i <= limit; i++) { - if (sieve[i]) { - for (let j = i * i; j <= limit; j += i) { - sieve[j] = false; - } - } - } - - this.primes = []; - for (let i = 2; i <= limit; i++) { - if (sieve[i]) { - this.primes.push(i); - } - } - } - - /** - * Miller-Rabin primality test - */ - isProbablePrime(n, k) { - if (n === BigInt(2) || n === BigInt(3)) return true; - if (n <= BigInt(1) || (n & BigInt(1)) === BigInt(0)) return false; - - // Write n-1 as d * 2^r - let d = n - BigInt(1); - let r = 0; - while ((d & BigInt(1)) === BigInt(0)) { - d >>= BigInt(1); - r++; - } - - // Witness loop - for (let i = 0; i < k; i++) { - const a = this.randomBigIntRange(BigInt(2), n - BigInt(2)); - let x = this.modPow(a, d, n); - - if (x === BigInt(1) || x === n - BigInt(1)) continue; - - let composite = true; - for (let j = 0; j < r - 1; j++) { - x = this.modPow(x, BigInt(2), n); - if (x === n - BigInt(1)) { - composite = false; - break; - } - } - - if (composite) return false; - } - - return true; - } - - /** - * Modular exponentiation: (base^exp) % mod - */ - modPow(base, exp, mod) { - let result = BigInt(1); - base = base % mod; - - while (exp > BigInt(0)) { - if ((exp & BigInt(1)) === BigInt(1)) { - result = (result * base) % mod; - } - exp >>= BigInt(1); - base = (base * base) % mod; - } - - return result; - } - - /** - * Euclidean algorithm for GCD - */ - gcd(a, b) { - a = a < BigInt(0) ? -a : a; - b = b < BigInt(0) ? -b : b; - - while (b !== BigInt(0)) { - const temp = b; - b = a % b; - a = temp; - } - return a; - } - - /** - * Generate random BigInt with specified bit length - */ - randomBigInt(bits) { - const bytes = Math.ceil(bits / 8); - const hex = Array(bytes) - .fill(0) - .map(() => Math.floor(Math.random() * 256).toString(16).padStart(2, '0')) - .join(''); - const num = BigInt('0x' + hex); - return num >> BigInt(bytes * 8 - bits); // Trim to exact bit length - } - - /** - * Generate random BigInt in range [min, max] - */ - randomBigIntRange(min, max) { - const range = max - min + BigInt(1); - const bits = range.toString(2).length; - let result; - do { - result = this.randomBigInt(bits); - } while (result >= range); - return result + min; - } -} - -// Run the program -const hp = new HomePrimes(); -hp.main(); diff --git a/Task/Home-primes/Julia/home-primes.jl b/Task/Home-primes/Julia/home-primes.julia similarity index 100% rename from Task/Home-primes/Julia/home-primes.jl rename to Task/Home-primes/Julia/home-primes.julia diff --git a/Task/Home-primes/PARI-GP/home-primes.parigp b/Task/Home-primes/PARI-GP/home-primes.parigp deleted file mode 100644 index dd584f6a2d..0000000000 --- a/Task/Home-primes/PARI-GP/home-primes.parigp +++ /dev/null @@ -1,30 +0,0 @@ -homeprimechain(n) = { - my(chain = [], concat_result, factors, factor_str); - while (!isprime(n), - chain = concat(chain, n); /* Append n to the chain */ - factors = factor(n); - /* Correctly build the concatenated string of factors */ - factor_str = Str(concat(Vec(vector(#factors~, i, - concat(Vec(concat(vector(factors[i, 2], j, Str(factors[i, 1]))))))))); - concat_result = factor_str; - \\print("concat_result=" concat_result); - n = eval(concat_result); /* Convert string back to number */ - ); - concat(chain, n); /* Append the final prime to the chain */ -} - -printHPiter(n, numperline = 4) = { - my(chain = homeprimechain(n), len = #chain, i); - for (i = 1, len, - if (i < len, - print1("HP" , chain[i] , " (" , len - i , ") = " , if(i % numperline == 0, "\n", "")), - print(chain[i], " is prime.\n\n"); - ); - ); -} - -{ -/* Iterate over a set of numbers */ -forstep(i = 2, 20, 1, print("Home Prime chain for ", i, ": "); printHPiter(i);); -printHPiter(65); -} diff --git a/Task/Home-primes/Phix/home-primes.phix b/Task/Home-primes/Phix/home-primes.phix index 9ac18748b8..b818d65a8e 100644 --- a/Task/Home-primes/Phix/home-primes.phix +++ b/Task/Home-primes/Phix/home-primes.phix @@ -1,35 +1,37 @@ -with javascript_semantics -requires("1.0.0") -- mpz_pollard_rho -include mpfr.e +(phixonline)--> + with javascript_semantics + requires("1.0.0") + include mpfr.e -procedure test(integer n) - string s = sprintf("%d",n), lastp = "" - sequence res = {s} - atom t0 = time() - while true do - s = substitute(s,"_","") - sequence rr = mpz_pollard_rho(s,true) - if length(rr)=1 then exit end if - s = join(rr,"_") - res = append(res,s) - end while - atom t = time()-t0 - integer niter = length(res)-1 - string iter = iff(niter>1?sprintf("(%d)",niter):""), - e = iff(t>0.1?" ["&elapsed(t)&"]":"") - s = sprintf("HP%d%s = ",{n,iter}) - if niter=0 then - printf(1,"%s%d %s\n",{s,n,e}) - else - for i=2 to niter do - niter -= 1 - printf(1,"%sHP%s(%d)\n",{s,res[i],niter}) - if i=2 then - s = repeat(' ',length(s)) - s[-2] = '=' - end if - end for - printf(1,"%s%s %s\n",{s,res[$],e}) - end if -end procedure -papply(tagset(20,2)&65,test) + procedure test(integer n) + string s = sprintf("%d",n), lastp = "" + sequence res = {s} + atom t0 = time() + while true do + s = substitute(s,"_","") + sequence rr = mpz_pollard_rho(s,true) + if length(rr)=1 then exit end if + s = join(rr,"_") + res = append(res,s) + end while + atom t = time()-t0 + integer niter = length(res)-1 + string iter = iff(niter>1?sprintf("(%d)",niter):""), + e = iff(t>0.1?" ["&elapsed(t)&"]":"") + s = sprintf("HP%d%s = ",{n,iter}) + if niter=0 then + printf(1,"%s%d %s\n",{s,n,e}) + else + for i=2 to niter do + niter -= 1 + printf(1,"%sHP%s(%d)\n",{s,res[i],niter}) + if i=2 then + s = repeat(' ',length(s)) + s[-2] = '=' + end if + end for + printf(1,"%s%s %s\n",{s,res[$],e}) + end if + end procedure + papply(tagset(20,2)&65,test) + + without js -- (system_exec, file i/o) + constant tmp = "hostname.txt", + cmd = iff(platform()=WINDOWS?"hostname":"uname -n") + {} = system_exec(sprintf("%s > %s",{cmd,tmp}),4) + string host = trim(get_text(tmp)) + {} = delete_file("hostname.txt") + ?host +(encode dictionary, decode dictionary) // build the tree, which is a list of lists of ... tree:=ft.pump(List,fcn([(c,cnt)]){ //-->L( (cnt, ((sym,code))), ...) L(cnt, L(L(c,""))) - }).copy(); // make it writable + }).copy(); // make it writable while(tree.len()>1){ // fake up a [lame] priorty queue tree=tree.sort(fcn(a,b){ a[0]>b[0] }); //prioritize high to low - a,b:=tree.pop(-2,2); //remove 2 least frequent symbols - mc:=fcn(n,c){ n[1] = c + n[1]; }; //(sym,code),"0"|"1" + a,b:=tree.pop(-2,2); //remove 2 least frequent symbols + mc:=fcn(n,c){ n[1] = c + n[1]; }; //(sym,code),"0"|"1" a[1].apply2(mc,"0"); b[1].apply2(mc,"1"); // mc(a[1],"0") tree.append( L(a[0]+b[0],a[1].extend(b[1])) ); //(a,b)-->new node }//-->L(L(39, L( L(" ","000"),L("e","0010"),L("a","0011") ... tree=tree[0][1].pump(List,fcn(i){ // flatten rather than traverse - if(T.isType(i))return(Void.Recurse,i,self.fcn); i }); + if(T.isType(i))return(Void.Recurse,i,self.fcn); i }); encodeTable:=tree.toDictionary(); // symbol:Huffman code decodeTable:=encodeTable.pump(Dictionary(),"reverse"); // code:symbol return(encodeTable,decodeTable); diff --git a/Task/Humble-numbers/ALGOL-68/humble-numbers.alg b/Task/Humble-numbers/ALGOL-68/humble-numbers.alg index b0a103ca81..09ce86b2ae 100644 --- a/Task/Humble-numbers/ALGOL-68/humble-numbers.alg +++ b/Task/Humble-numbers/ALGOL-68/humble-numbers.alg @@ -17,10 +17,10 @@ BEGIN # find some Humble numbers - numbers with no prime factors above 7 # INT m = min( min( min( p2, p3 ), p5 ), p7 ); h[ n ] := m; IF n <= max shown humble THEN print( ( " ", whole( m, 0 ) ) ) FI; - IF m = p2 THEN p2 := 2 * h[ last2 +:= 1 ] FI; - IF m = p3 THEN p3 := 3 * h[ last3 +:= 1 ] FI; - IF m = p5 THEN p5 := 5 * h[ last5 +:= 1 ] FI; - IF m = p7 THEN p7 := 7 * h[ last7 +:= 1 ] FI; + IF m = p2 THEN p2 := 2 * h[ last2 := last2 + 1 ] FI; + IF m = p3 THEN p3 := 3 * h[ last3 := last3 + 1 ] FI; + IF m = p5 THEN p5 := 5 * h[ last5 := last5 + 1 ] FI; + IF m = p7 THEN p7 := 7 * h[ last7 := last7 + 1 ] FI; h count[ IF m < 10 THEN 1 ELIF m < 100 THEN 2 ELIF m < 1 000 THEN 3 diff --git a/Task/Humble-numbers/Ada/humble-numbers.adb b/Task/Humble-numbers/Ada/humble-numbers.ada similarity index 100% rename from Task/Humble-numbers/Ada/humble-numbers.adb rename to Task/Humble-numbers/Ada/humble-numbers.ada diff --git a/Task/Humble-numbers/Agena/humble-numbers.agena b/Task/Humble-numbers/Agena/humble-numbers.agena deleted file mode 100644 index cddec65d4a..0000000000 --- a/Task/Humble-numbers/Agena/humble-numbers.agena +++ /dev/null @@ -1,32 +0,0 @@ -scope # find some Humble numbers - numbers with no prime factors above 7 - local constant maxHumble, constant maxShownHumble := 2048, 50; - local h, hCount := seq(), [ 0, 0, 0, 0, 0, 0 ]; hCount[ 0 ] := 0; - local p2, p3, p5, p7 := 2, 3, 5, 7; - local last2, last3, last5, last7 := 1, 1, 1, 1; - # 1 is the first humble number ( 2^0 * 3^0 * 5^0 * 7^0 ) and has 1 digit - h[ 1 ], hCount[ 1 ] := 1, 1; - io.write( "1" ); - for n from 2 to maxHumble do - # the next humble number is the lowest of the next multiples of 2, 3, 5, 7 - local constant m := math.min( p2, p3, p5, p7 ); - h[ n ] := m; - if n <= maxShownHumble then io.write( " ", m ) fi; - if m = p2 then last2 +:= 1; p2 := 2 * h[ last2 ] fi; - if m = p3 then last3 +:= 1; p3 := 3 * h[ last3 ] fi; - if m = p5 then last5 +:= 1; p5 := 5 * h[ last5 ] fi; - if m = p7 then last7 +:= 1; p7 := 7 * h[ last7 ] fi; - hCount[ if m < 10 then 1 - elif m < 100 then 2 - elif m < 1_000 then 3 - elif m < 10_000 then 4 - elif m < 100_000 then 5 - elif m < 1_000_000 then 6 - else 0 - fi - ] +:= 1 - od; - print(); - for i to 6 do - printf( "There are %4d Humble numbers with %d digits\n", hCount[ i ], i ) - od -end diff --git a/Task/Humble-numbers/BBC-BASIC/humble-numbers.basic b/Task/Humble-numbers/BBC-BASIC/humble-numbers.basic deleted file mode 100644 index a9ecf04dbf..0000000000 --- a/Task/Humble-numbers/BBC-BASIC/humble-numbers.basic +++ /dev/null @@ -1,30 +0,0 @@ - MaxDigs%=8 - DIM Humble%(MaxDigs% - 1) - I%=1 - @%=4 - - PRINT "The first 50 humble numbers:" - WHILE TRUE - IF FNIsHumble(I%) THEN - IF C% < 50 PRINT ;I% " "; - C%+=1 - S%=LENSTR$I% - IF S% > MaxDigs% EXIT WHILE - Humble%(S%-1)+=1 - ENDIF - I%+=1 - ENDWHILE - - PRINT ''"Of the first ";C% " humble numbers:" - FOR I%=0 TO MaxDigs% - 1 - PRINT Humble%(I%) " have ";I% + 1 LEFT$(" digits", I% + 6) - NEXT - END - - DEF FNIsHumble(i%) - IF i% <= 1 THEN =TRUE - IF i% MOD 2 == 0 THEN =FNIsHumble(i% / 2) - IF i% MOD 3 == 0 THEN =FNIsHumble(i% / 3) - IF i% MOD 5 == 0 THEN =FNIsHumble(i% / 5) - IF i% MOD 7 == 0 THEN =FNIsHumble(i% / 7) - =FALSE diff --git a/Task/Humble-numbers/Crystal/humble-numbers-1.cr b/Task/Humble-numbers/Crystal/humble-numbers-1.crystal similarity index 100% rename from Task/Humble-numbers/Crystal/humble-numbers-1.cr rename to Task/Humble-numbers/Crystal/humble-numbers-1.crystal diff --git a/Task/Humble-numbers/Crystal/humble-numbers-2.cr b/Task/Humble-numbers/Crystal/humble-numbers-2.crystal similarity index 100% rename from Task/Humble-numbers/Crystal/humble-numbers-2.cr rename to Task/Humble-numbers/Crystal/humble-numbers-2.crystal diff --git a/Task/Humble-numbers/EasyLang/humble-numbers.easy b/Task/Humble-numbers/EasyLang/humble-numbers.easy deleted file mode 100644 index adc26578a1..0000000000 --- a/Task/Humble-numbers/EasyLang/humble-numbers.easy +++ /dev/null @@ -1,26 +0,0 @@ -fastfunc humble i . - if i <= 1 : return 1 - if i mod 2 = 0 : return humble (i / 2) - if i mod 3 = 0 : return humble (i / 3) - if i mod 5 = 0 : return humble (i / 5) - if i mod 7 = 0 : return humble (i / 7) - return 0 -. -fastfunc next_humble n . - repeat - n += 1 - until humble n = 1 - . - return n -. -len arr[] 9 -while cnt < 5193 - n = next_humble n - idx = floor (log n 10 + 1) - arr[idx] += 1 - cnt += 1 - if cnt <= 50 : write n & " " -. -print "" -print "" -for i to 9 : print arr[i] & " with " & i & " digits" diff --git a/Task/Humble-numbers/Fortran/humble-numbers.f b/Task/Humble-numbers/Fortran/humble-numbers.f deleted file mode 100644 index 84ed5074c5..0000000000 --- a/Task/Humble-numbers/Fortran/humble-numbers.f +++ /dev/null @@ -1,81 +0,0 @@ -! Humble Numbers -! tested with GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 -! -! Note that both intel ifx and VSI Fortran do not compile this code because they cannot -! deal with 16-byte-integers. -! -! U.B., July 2025 -! - - -program humbleNumbers - -implicit none - -integer, parameter :: int_kind = 16 ! Fortran compilers other than gfortran can't handle this -integer, parameter :: printLimit = 50 ! need to print first 50 humble numbers - -integer :: max_digits = 38 ! (signed) Integer(kind=16) can carry 38 digits -integer, parameter :: maxhSize=1160000 ! array size for all stored humble numbers -integer (kind=int_kind) :: humble ( maxhSize ) ! the humble numbers -integer :: usedH = 1 ! highest index into humble -integer (kind=int_kind) :: powersOf2=2, powersOf3=3,powersOf5=5,powersOf7=7,currentHumble=2, lim=10 -integer :: i=1, j=1,k=1,m=1,lastCount=0,d=1 - -humble (1) = 1 - -do while (.true.) - - usedH = usedH + 1 - if (usedH .le. maxhSize) then ! B sure we dont crash. - humble (usedH) = currentHumble - else - exit ! otherwise terminate. - endif - - ! construct next humble number as 2^i* 3^j * 5^k * 7^m - ! - ! What comes next? - if (currentHumble .eq. powersOf2) then - i = i + 1 - powersOf2 = humble (i) * 2 - endif - if (currentHumble .eq. powersOf3) then - j = j + 1 - powersOf3 = humble (j) * 3 - endif - if (currentHumble .eq. powersOf5) then - k = k + 1 - powersOf5 = humble (k) * 5 - endif - if (currentHumble .eq. powersOf7) then - m = m + 1 - powersOf7 = humble (m) * 7 - endif - currentHumble = powersOf2 - - ! Select next larger humble number - if (powersOf3=lim) then ! another digit ? - write (6, '(I0, " digits: ", i0)') d, usedH -lastCount - lastCount = usedH - d = d + 1 - - if (d .gt. max_digits) then ! Maximum number of digits reached, terminate. - exit - endif - lim = lim * 10 ! to detect next larger number of digits - endif -enddo - -write (6, '(/"total = ", I0 )') usedH -write (6,'(/"The first " ,I0, " humble numbers are:" )') printLimit -do i=1,printLimit - write (6,'(X, I0)', advance='no') humble (i) -enddo -write (6,*) ! terminate last output line. - -end program humbleNumbers diff --git a/Task/Humble-numbers/Icon/humble-numbers.icon b/Task/Humble-numbers/Icon/humble-numbers.icon deleted file mode 100644 index 9788c9eba9..0000000000 --- a/Task/Humble-numbers/Icon/humble-numbers.icon +++ /dev/null @@ -1,40 +0,0 @@ -global count - -procedure main(A) - limit1 := \A[1] | 50 - limit2 := \A[2] | 1000 - showcounts(humbles(limit1, limit2)) -end - -procedure humbles(limit1,limit2) - scounts := table(0) - every (count := 0, n := genhumbles()\limit2, count +:= 1, x := *n) do { - if 0 < (limit1 -:= 1) then writes(" ",n) - else if 0 = limit1 then write(" ",n) - scounts[x] +:= 1 - } - return scounts -end - -procedure genhumbles() - suspend 1 - p := [2,3,5,7] - l := [0,0,0,0] - ch := [] - every n := seq() do { - suspend m := min(p[1],p[2],p[3],p[4]) - put(ch, m) - if m = p[1] then p[1] := 2*ch[l[1] +:= 1] - if m = p[2] then p[2] := 3*ch[l[2] +:= 1] - if m = p[3] then p[3] := 5*ch[l[3] +:= 1] - if m = p[4] then p[4] := 7*ch[l[4] +:= 1] - } -end - -procedure showcounts(counts) - write("\nOut of the first ",count," humble numbers:\n") - write(" length ",center("count",16)) - write(" ",repl("-",5)," ",repl("-",16)) - every p := !sort(counts) do - write(right(p[1],7)," ",right(p[2],16)) -end diff --git a/Task/Humble-numbers/Julia/humble-numbers.jl b/Task/Humble-numbers/Julia/humble-numbers.julia similarity index 100% rename from Task/Humble-numbers/Julia/humble-numbers.jl rename to Task/Humble-numbers/Julia/humble-numbers.julia diff --git a/Task/Humble-numbers/Kotlin/humble-numbers.kts b/Task/Humble-numbers/Kotlin/humble-numbers.kotlin similarity index 100% rename from Task/Humble-numbers/Kotlin/humble-numbers.kts rename to Task/Humble-numbers/Kotlin/humble-numbers.kotlin diff --git a/Task/Humble-numbers/Maxima/humble-numbers.maxima b/Task/Humble-numbers/Maxima/humble-numbers.maxima deleted file mode 100644 index a9f5e2d00a..0000000000 --- a/Task/Humble-numbers/Maxima/humble-numbers.maxima +++ /dev/null @@ -1,13 +0,0 @@ -factors_only: true$ -is_humble(n) := length(sublist(ifactors(n), lambda([x], x>7)))=0$ - -block(count: 0, n: 1, while(count<50) do( - if is_humble(n) then block( - sprint(n), - count: count+1, - if mod(count, 10)=0 then newline() - ), - n: n+1))$ - -humble_digits(n) := length(sublist(makelist(i, i, 10^(n-1), (10^n)-1), is_humble))$ -map(humble_digits, makelist(i, i, 1, 6)); diff --git a/Task/Humble-numbers/PascalABC.NET/humble-numbers.pas b/Task/Humble-numbers/PascalABC.NET/humble-numbers.pas deleted file mode 100644 index 4ea1f2542b..0000000000 --- a/Task/Humble-numbers/PascalABC.NET/humble-numbers.pas +++ /dev/null @@ -1,25 +0,0 @@ -## -function humbles: sequence of uint64; -begin - var s := hset(uint64(1)); - while True do - begin - var m := s.min; - yield m; - s -= m; - foreach var k in |2, 3, 5, 7| do s += k * m; - end; -end; - -println('The first 50 humble numbers are:'); -foreach var n in humbles.Take(50) index i do - write(n:4, if i mod 10 = 9 then #10 else ''); - -println; -println('Digits Count'); -for var dig := 1 to 18 do -begin - var count := humbles.SkipWhile(x -> x < 10 ** (dig - 1)) - .TakeWhile(x -> x < 10 ** dig).Count; - writeln(dig:2, count:10); -end; diff --git a/Task/Humble-numbers/Pluto/humble-numbers.pluto b/Task/Humble-numbers/Pluto/humble-numbers.pluto deleted file mode 100644 index faca83857a..0000000000 --- a/Task/Humble-numbers/Pluto/humble-numbers.pluto +++ /dev/null @@ -1,31 +0,0 @@ -do -- find some Humble numbers - numbers with no prime factors above 7 - local maxHumble , maxShownHumble = 2048, 50 - local h, hCount = {}, { [0] = 0, 0, 0, 0, 0, 0, 0 } - local p2, p3, p5, p7 = 2, 3, 5, 7 - local last2, last3, last5, last7 = 1, 1, 1, 1 - -- 1 is the first humble number ( 2^0 * 3^0 * 5^0 * 7^0 ) and has 1 digit - h[ 1 ], hCount[ 1 ] = 1, 1 - io.write( "1" ) - for n = 2, maxHumble do - -- the next humble number is the lowest of the next multiples of 2, 3, 5, 7 - local m = math.min( p2, p3, p5, p7 ) - h[ n ] = m - if n <= maxShownHumble then io.write( " ", m ) end - if m == p2 then last2 += 1 p2 = 2 * h[ last2 ] end - if m == p3 then last3 += 1 p3 = 3 * h[ last3 ] end - if m == p5 then last5 += 1 p5 = 5 * h[ last5 ] end - if m == p7 then last7 += 1 p7 = 7 * h[ last7 ] end - hCount[ ( m < 10 ) ? 1 - : ( m < 100 ) ? 2 - : ( m < 1_000 ) ? 3 - : ( m < 10_000 ) ? 4 - : ( m < 100_000 ) ? 5 - : ( m < 1_000_000 ) ? 6 - : 0 - ] += 1 - end - io.write( "\n" ) - for i = 1, 6 do - io.write( string.format( "There are %4d Humble numbers with %d digits\n", hCount[ i ], i ) ) - end -end diff --git a/Task/Humble-numbers/R/humble-numbers.r b/Task/Humble-numbers/R/humble-numbers.r deleted file mode 100644 index 328aa77434..0000000000 --- a/Task/Humble-numbers/R/humble-numbers.r +++ /dev/null @@ -1,16 +0,0 @@ -next_humble <- function(n) nextn(n, c(2,3,5,7)) -humblenums <- function(n) Reduce(function(x, f) 1+f(x), - rep(list(next_humble),n-1), - init=2, - accumulate=TRUE)-1 - -humblenums(50) - -humble_digits <- function(n){ - digcounts <- rle(floor(log10(humblenums(n))))$lengths - for(i in seq_along(digcounts[-1])){ - cat("There are", digcounts[i], "humble numbers with", i, "digit(s)", "\n") - } -} - -humble_digits(5000) diff --git a/Task/Humble-numbers/REXX/humble-numbers.rexx b/Task/Humble-numbers/REXX/humble-numbers.rexx index 3a4ca3c7dd..c4f9c240cd 100644 --- a/Task/Humble-numbers/REXX/humble-numbers.rexx +++ b/Task/Humble-numbers/REXX/humble-numbers.rexx @@ -1,46 +1,44 @@ --- 23 Aug 2025 -include Setting +/*REXX program computes and displays humble numbers, also will display counts of sizes.*/ +parse arg n m . /*obtain optional arguments from the CL*/ +if n=='' | n=="," then n= 50 /*Not specified? Then use the default.*/ +if m=='' | m=="," then m= 60 /* " " " " " " */ +numeric digits 1 + max(20, m) /*be able to handle some big numbers. */ +$.= 0 /*a count array for X digit humble #s*/ +call humble n; list= /*call HUMBLE sub; initialize the list.*/ + do j=1 for n; list= list @.j /*append a humble number to the list.*/ + end /*j*/ -say 'HUMBLE NUMBERS' -say version +if list\='' then do; say "A list of the first " n ' humble numbers are:' + say strip(list) /*elide the leading blank in the list. */ + end say -call Humbles 50 -call ShowFirstN 50 -call Humbles 10000000 -call ShowDistribution -say Time('e')/1 'seconds' -exit - -ShowFirstN: -procedure expose humb. -arg xx -xx = xx/1 -say 'First' xx 'humble numbers are' -do i = 1 to xx - call Charout ,Right(humb.i,4) - if i//10 = 0 then - say -end -say -return - -ShowDistribution: -procedure expose humb. -say 'Digit distribution for the first' humb.0 'humble numbers' -d. = 0 -do i = 1 to humb.0 - l = Length(humb.i); d.l = d.l + 1; d.0 = Max(l,d.0) -end -l = Copies('-',17) -say l -say 'Dg Count Cum' -say l -c = 0 -do i = 1 to d.0-1 - c = c + d.i - say Right(i,2) Right(d.i,6) Right(c,7) -end -say l -return - -include Math +call humble -m /*invoke subroutine for counting nums. */ +if $.1==0 then exit /*if no counts, then we're all finished*/ +total= 0 /*initialize count of humble numbers. */ +$.1= $.1 + 1 /*adjust count for absent 1st humble #.*/ +say ' The digit counts of humble numbers:' +say ' ═════════════════════════════════════════' + do c=1 while $.c>0; s= left('s', length($.c)>1) /*count needs pluralization?*/ + say right( commas($.c), 30) ' have ' right(c, 2) " digit"s + total= total + $.c /* ◄─────────────────────────────────┐ */ + end /*k*/ /*bump humble number count (so far)──┘ */ +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +commas: procedure; arg _; do i=length(_)-3 to 1 by -3; _=insert(',', _, i); end; return _ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +humble: procedure expose @. $.; parse arg x; if x==0 then return + y= abs(x); a= y; noCount= x>0; if x<0 then y= 999999999 + #2= 1; #3= 1; #5= 1; #7= 1 /*define the initial humble constants. */ + $.= 0; @.= 0; @.1= 1 /*initialize counts and humble numbers.*/ + do h=2 for y-1 + @.h= min(2*@.#2,3*@.#3,5*@.#5,7*@.#7) /*pick the minimum of 4 humble numbers.*/ + m= @.h /*M: " " " " " " */ + if 2*@.#2 == m then #2 = #2 + 1 /*Is number already defined? Use next #*/ + if 3*@.#3 == m then #3 = #3 + 1 /* " " " " " " "*/ + if 5*@.#5 == m then #5 = #5 + 1 /* " " " " " " "*/ + if 7*@.#7 == m then #7 = #7 + 1 /* " " " " " " "*/ + if noCount then iterate /*Not counting digits? Then iterate. */ + L= length(m); if L>a then leave /*Are we done with counting? Then quit*/ + $.L= $.L + 1 /*bump the digit count for this number.*/ + end /*h*/ /*the humble numbers are in the @ array*/ + return /* " count results " " " $ " */ diff --git a/Task/Humble-numbers/Rust/humble-numbers.rs b/Task/Humble-numbers/Rust/humble-numbers.rs deleted file mode 100644 index 839c434188..0000000000 --- a/Task/Humble-numbers/Rust/humble-numbers.rs +++ /dev/null @@ -1,51 +0,0 @@ -fn num_length( number : u32 ) -> usize { - let numberstring : String = number.to_string( ) ; - let numstr = numberstring.as_str( ) ; - numstr.chars( ).count( ) -} - -fn is_humble( number : u32 ) -> bool { - let result : bool = match number { - num if num <= 1 => true , - num if num % 2 == 0 => is_humble( number / 2 ) , - num if num % 3 == 0 => is_humble( number / 3 ) , - num if num % 4 == 0 => is_humble( number / 4 ) , - num if num % 5 == 0 => is_humble( number / 5 ) , - num if num % 6 == 0 => is_humble( number / 6 ) , - num if num % 7 == 0 => is_humble( number / 7 ) , - _ => false - } ; - result -} - -fn main() { - let mut first_fifty : Vec = Vec::new( ) ; - let mut pairs : Vec<(usize , usize)> = Vec::new( ) ; - let mut oldlength : usize = 0 ; - let mut currentnum : u32 = 1 ; - let mut length : usize = 1 ; - let mut lengthsum : usize = 0 ; - while length < 10 { - if is_humble( currentnum ) { - if first_fifty.len( ) < 50 { - first_fifty.push( currentnum ) ; - } - if length == oldlength { - lengthsum += 1 ; - } - else { - let temp_len : usize = length - 1 ; - pairs.push( (temp_len , lengthsum ) ) ; - lengthsum = 1 ; - oldlength = length ; - } - } - currentnum += 1 ; - length = num_length( currentnum ) ; - } - pairs.push((length - 1 , lengthsum )) ; - println!("{:?}" , first_fifty ) ; - for p in pairs { - println!("length {} with {} humble numbers!" , p.0 , p.1 ) ; - } -} diff --git a/Task/Humble-numbers/V-(Vlang)/humble-numbers.v b/Task/Humble-numbers/V-(Vlang)/humble-numbers.v deleted file mode 100644 index 42182166d6..0000000000 --- a/Task/Humble-numbers/V-(Vlang)/humble-numbers.v +++ /dev/null @@ -1,38 +0,0 @@ -fn is_humble(i int) bool { - if i <= 1 {return true} - if i % 2 == 0 {return is_humble(i / 2)} - if i % 3 == 0 {return is_humble(i / 3)} - if i % 5 == 0 {return is_humble(i / 5)} - if i % 7 == 0 {return is_humble(i / 7)} - return false -} - -fn main() { - limit := max_i16 - mut humble := map[int]int{} - mut count, mut len, mut total, mut num := 0, 0, 0, 1 - mut str :="" - - for count < limit { - if is_humble(num) == true { - str = num.str() - len = str.len - humble[len]++ - if count < 50 {print("${num} ")} - count++ - } - num++ - } - println("\n") - - println("Of the first ${count} humble numbers:") - num = 1 - for num < humble.len - 1 { - if num in humble { - total = humble[num] - println("${total:5} have ${num:2} digits") - num++ - } - else {break} - } -} diff --git a/Task/Humble-numbers/Wren/humble-numbers.wren b/Task/Humble-numbers/Wren/humble-numbers.wren index d9ca0da8b1..bed71678a5 100644 --- a/Task/Humble-numbers/Wren/humble-numbers.wren +++ b/Task/Humble-numbers/Wren/humble-numbers.wren @@ -1,6 +1,6 @@ -import "./fmt" for Fmt -import "./math" for Nums -import "./sort" for Find +import "/fmt" for Fmt +import "/math" for Int, Nums +import "/sort" for Find var humble = Fn.new { |n| var h = List.filled(n, 0) @@ -40,9 +40,9 @@ var h = humble.call(n) System.print("The first 50 humble numbers are:") System.print(h[0..49]) -var f = Find.all(h, Num.maxSafeInteger) // binary search +var f = Find.all(h, Int.maxSafe) // binary search var maxUsed = f[0] ? f[2].min + 1 : f[2].min -var maxDigits = 16 // Num.maxSafeInteger (2^53 -1) has 16 digits +var maxDigits = 16 // Int.maxSafe (2^53 -1) has 16 digits var counts = List.filled(maxDigits + 1, 0) var digits = 1 var pow10 = 10 diff --git a/Task/Hunt-the-Wumpus/00-TASK.txt b/Task/Hunt-the-Wumpus/00-TASK.txt index c59a0f8a9f..d01fe12b94 100644 --- a/Task/Hunt-the-Wumpus/00-TASK.txt +++ b/Task/Hunt-the-Wumpus/00-TASK.txt @@ -1,5 +1,5 @@ {{Clarify_task}} -Create a simple implementation of the classic textual game [[w:Hunt the Wumpus|Hunt the Wumpus]]. +Create a simple implementation of the classic textual game [http://en.wikipedia.org/wiki/Hunt_the_Wumpus Hunt The Wumpus]. The rules are: diff --git a/Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-1.adb b/Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-1.ada similarity index 100% rename from Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-1.adb rename to Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-1.ada diff --git a/Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-2.adb b/Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-2.ada similarity index 100% rename from Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-2.adb rename to Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-2.ada diff --git a/Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-3.adb b/Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-3.ada similarity index 100% rename from Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-3.adb rename to Task/Hunt-the-Wumpus/Ada/hunt-the-wumpus-3.ada diff --git a/Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c b/Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c deleted file mode 100644 index 79b70d3cf7..0000000000 --- a/Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include -#include - -#define NUM_ROOMS 20 -#define ARROWS 5 - -typedef enum { false, true } bool; - -typedef struct { - int connected[3]; - bool has_wumpus; - bool has_bat; - bool has_pit; -} Room; - -Room cave[NUM_ROOMS + 1]; // Cave rooms are numbered from 1 to 20 - -void initialize_cave() { - int i, j; - // Initialize cave rooms - for (i = 1; i <= NUM_ROOMS; i++) { - for (j = 0; j < 3; j++) { - cave[i].connected[j] = (i + j) % NUM_ROOMS + 1; // Circular connections - } - cave[i].has_wumpus = false; - cave[i].has_bat = false; - cave[i].has_pit = false; - } - // Randomly place wumpus, bats, and pits - cave[rand() % NUM_ROOMS + 1].has_wumpus = true; - for (i = 0; i < 2; i++) { - cave[rand() % NUM_ROOMS + 1].has_bat = true; - cave[rand() % NUM_ROOMS + 1].has_pit = true; - } -} - -void sense(int room) { - printf("You are in room %d.\n", room); - int i, adjacent_room; - for (i = 0; i < 3; i++) { - adjacent_room = cave[room].connected[i]; - if (cave[adjacent_room].has_wumpus) - printf("You smell something terrible nearby.\n"); - if (cave[adjacent_room].has_bat) - printf("You hear a rustling.\n"); - if (cave[adjacent_room].has_pit) - printf("You feel a cold wind blowing from a nearby cavern.\n"); - } -} - -void move(int *room) { - int choice; - printf("Choose an adjacent room to move into: "); - scanf("%d", &choice); - if (choice < 1 || choice > 3) { - printf("Invalid choice. Please choose a number between 1 and 3.\n"); - move(room); - return; - } - *room = cave[*room].connected[choice - 1]; -} - -void shoot(int room, int *arrows, bool *game_over) { - int choice, adjacent_room; - printf("Choose an adjacent room to shoot into: "); - scanf("%d", &choice); - if (choice < 1 || choice > 3) { - printf("Invalid choice. Please choose a number between 1 and 3.\n"); - shoot(room, arrows, game_over); - return; - } - adjacent_room = cave[room].connected[choice - 1]; - if (cave[adjacent_room].has_wumpus) { - printf("Congratulations! You've killed the Wumpus!\n"); - *game_over = true; - return; - } - else { - if (rand() % 4 != 0) { // 75% chance of waking up the wumpus - if (cave[adjacent_room].has_wumpus) { - printf("The Wumpus has woken up and eaten you!\n"); - *game_over = true; - return; - } - } - printf("You missed! The Wumpus is still asleep.\n"); - } - (*arrows)--; -} - -int main() { - srand(time(NULL)); - initialize_cave(); - int current_room = 1; - int arrows = ARROWS; - bool game_over = false; - - printf("Welcome to Hunt the Wumpus!\n"); - - while (!game_over) { - sense(current_room); - printf("Choose your action:\n"); - printf("1. Move to an adjacent room\n"); - printf("2. Shoot into an adjacent room\n"); - - int choice; - printf("Enter your choice (1 or 2): "); - scanf("%d", &choice); - - switch(choice) { - case 1: - move(¤t_room); - break; - case 2: - if (arrows > 0) { - shoot(current_room, &arrows, &game_over); - } else { - printf("You're out of arrows! You lost the game.\n"); - game_over = true; - } - break; - default: - printf("Invalid choice. Please choose 1 or 2.\n"); - } - } - - return 0; -} diff --git a/Task/Hunt-the-Wumpus/EasyLang/hunt-the-wumpus.easy b/Task/Hunt-the-Wumpus/EasyLang/hunt-the-wumpus.easy deleted file mode 100644 index 9fbc981fa3..0000000000 --- a/Task/Hunt-the-Wumpus/EasyLang/hunt-the-wumpus.easy +++ /dev/null @@ -1,92 +0,0 @@ -exits[][] = [ [ 2 5 8 ] [ 1 3 10 ] [ 2 4 12 ] [ 3 5 14 ] [ 1 4 6 ] [ 5 7 15 ] [ 6 8 17 ] [ 1 7 9 ] [ 8 10 18 ] [ 2 9 11 ] [ 10 12 19 ] [ 2 11 13 ] [ 12 14 20 ] [ 4 13 15 ] [ 6 14 16 ] [ 15 17 20 ] [ 7 16 18 ] [ 9 17 19 ] [ 11 18 20 ] [ 13 16 19 ] ] -len hazard$[] 20 -func emptyRoom . - repeat - room = random 1 20 - until hazard$[room] = "" - . - return room -. -for i to 2 - hazard$[emptyRoom] = "bat" - hazard$[emptyRoom] = "pit" -. -hazard$[emptyRoom] = "wumpus" -# -print "*** HUNT THE WUMPUS ***" -print "-----------------------" -curRoom = emptyRoom -arrows = 5 -func checkWumpus . - if hazard$[curRoom] = "wumpus" - print "You find yourself face to face with the wumpus." - print "It eats you whole." - print "GAME OVER" - return 1 - . -. -repeat - print "You are in room " & curRoom & "." - until checkWumpus = 1 - for r in exits[curRoom][] - if hazard$[r] = "wumpus" : print "You smell something terrible nearby." - if hazard$[r] = "bat" : print "You hear a rustling." - if hazard$[r] = "pit" : print "You feel a cold wind blowing from a nearby cavern." - . - print "Tunnels lead to: " & strjoin exits[curRoom][] ", " - print "You have " & arrows & " arrows." - print "" - repeat - repeat - write "M)ove, S)hoot, or Q)uit? " - in$ = input - print in$ - m$ = substr in$ 1 1 - until m$ = "m" or m$ = "s" or m$ = "q" - . - if m$ = "q" : break 2 - target = number substr in$ 2 99 - if target = 0 - write "Which room? " - target = number input - print target - . - for i to 3 - if exits[curRoom][i] = target : break 1 - . - until i <= 3 - print "Cannot get there from here." - . - if m$ = "m" - curRoom = target - if hazard$[curRoom] = "bat" - print "You have entered the lair of a giant bat." - curRoom = emptyRoom - print "It picks you up and drops you in room " & curRoom & "." - elif hazard$[curRoom] = "pit" - print "The ground gives way beneath your feet." - print "You fall into a deep abyss." - print "GAME OVER" - break 1 - . - else - arrows -= 1 - if hazard$[target] = "wumpus" - print "Congratulations! You shot the wumpus!" - break 1 - . - print "You missed." - if randomf < 0.75 - print "The wumpus wakes from his slumber." - for i to 20 : if hazard$[i] = "wumpus" : hazard$[i] = "" - hazard$[emptyRoom] = "wumpus" - if checkWumpus = 1 : break 1 - . - if arrows = 0 - print "As you grasp at your empty quiver, " - print "you hear a large beast approaching..." - hazard$[curRoom] = "wumpus" - if checkWumpus = 1 : break 1 - . - . -. diff --git a/Task/Hunt-the-Wumpus/FOCAL/hunt-the-wumpus.focal b/Task/Hunt-the-Wumpus/FOCAL/hunt-the-wumpus.focal deleted file mode 100644 index 3308bdd6d1..0000000000 --- a/Task/Hunt-the-Wumpus/FOCAL/hunt-the-wumpus.focal +++ /dev/null @@ -1,213 +0,0 @@ -1.10 S FOUT(12); C HUNT THE WUMPUS - BY GREGORY YOB, 1973. -1.11 C FOCAL-65 VERSION CONVERTED FROM BASIC SOURCE IN -1.12 C 'CREATIVE COMPUTING' MAGAZINE, SEPT/OCT 1975 -1.20 T %2,!"INSTRUCTIONS (Y-N)? "; S I=FCHR(); T ! -1.30 I (I-78),1.45; -1.40 G 90.1 -1.45 S FRAN(-1); T "SETTING UP CAVE..."! -1.46 C SET UP CAVE (DODECAHEDRAL NODE LIST) -1.47 C FOCAL-65 DOESN'T HAVE DATA/READ STMTS, SO DATA PACKED IN A $ -1.48 C OTHER VERSIONS MAY NEED TO ASSIGN EACH ELEMENT OF S TO S(X) -1.50 S FISL(120,S$); C 60 2-DIG DATA ELEMENTS -1.52 S FODV(S$); C PREPARES S$ FOR INPUT FROM CURRENT OUTPUT DEVICE -1.53 T "020508010310020412030514010406" -1.54 T "050715060817010709081018020911" -1.55 T "101219031113121420041315061416" -1.56 T "151720071618091719111820131619" -1.58 R O; S FIDV(S$),; C RESET OUTPUT DEV., SET S$ AS INPUT DEVICE -1.60 F I=1,60; D 1.8 -1.70 R I; G 2.1 -1.80 S X=FCHR(), X=X-48, S(I)=X*10, X=FCHR(), X=X-48, S(I)=S(I)+X -1.90 R - -2.10 C LOCATE L ARRAY ITEMS: 1-YOU,2-WUMPUS,3&4-PITS,5&6-BATS -2.20 F J=1,6; S L(J)=FINT(FRAN(0)*20)+1, M(J)=L(J) -2.22 C CHECK FOR CROSSOVERS (IE L(1)=L(2), ETC) -2.25 S J=1 -2.27 S K=1 -2.30 I (J-K),2.5; -2.40 I (L(J)-L(K)),2.2; C IF L(J)=L(K), RESET -2.50 S K=K+1; I (K-6)2.52,2.52,2.56 -2.52 G 2.3 -2.56 S J=J+1; I (J-6)2.27,2.27; - -2.60 C SET ARROWS, RUN GAME -2.70 S A=5, L=L(1) - -3.10 T "HUNT THE WUMPUS"! -3.20 C HAZARD WARNINGS & LOCATION -3.30 G 20.1 - -4.05 C MOVE OR SHOOT -4.10 D 25 -4.20 I (I),4.3,4.8 -4.30 G 30.1; C SHOOT -4.50 I (G)5.1,3.3,5.5 -4.80 G 40.1; C MOVE -4.90 I (G),3.3,5.5 - -5.09 C LOSE -5.10 T "HA HA HA - YOU LOSE!"!; G 5.6 -5.40 C WIN -5.50 T "HEE HEE HEE - THE WUMPUS'LL GETCHA NEXT TIME!!"! -5.60 F J=1,6; S L(J)=M(J) -5.70 T "PLAY AGAIN (Y-N)? ";S I=FCHR(); T ! -5.80 I (I-89)7.1,5.9,7.1 -5.90 T "SAME SETUP (Y-N)? ";S I=FCHR(); T !"STAND BY..."! -6.10 I (I-89)2.2,2.7,2,2 - -7.10 Q - -20.05 C - PRINT LOCATION & HAZARD WARNING -20.10 S J=2 -20.12 I (J-7),21.3; -20.20 S K=1 -20.30 S T=(L(1)-1)*3+K -20.40 I (S(T)-L(J))20.9,20.5,20.9 -20.50 I (J-2),20.6; -20.52 I (J-3),20.7; -20.53 I (J-4),20.7; -20.54 I (J-5),20.8; -20.55 I (J-6),20.8; -20.60 T "I SMELL A WUMPUS!"!; G 20.9 -20.70 T "I FEEL A DRAFT."!; G 20.9 -20.80 T "BATS NEARBY!"! -20.90 S K=K+1; I (K-3)20.3,20.3; -20.92 S J=J+1; G 20.12 - -21.30 T "YOU ARE IN ROOM ",L(1),!; S T=(L(1)-1)*3 -21.40 T "TUNNELS LEAD TO ",S(T+1)," ",S(T+2)," ",S(T+3) -21.50 T !! -21.60 G 4.1 - -25.05 C - CHOOSE OPTION *** -25.10 T "SHOOT OR MOVE (S-M)? " -25.20 S I=FCHR(); T !; I (I-77),25.4; -25.30 I (I-83)25.1,25.5,25.1 -25.40 S I=1; R -25.50 S I=0; R - -30.01 C - ARROW ROUTINE -30.10 S G=0 -30.20 C - PATH OF ARROW -30.30 S L=L(1) -30.40 T "NO. OF ROOMS (1-5)? "; A J7 -30.50 I (J7-1)30.4; -30.60 I (J7-5),,30.4 -30.70 S K=1 -30.80 T "ROOM #? "; A P(K) -30.90 I (K-2)31.15,31.15; -31.05 I (P(K)-P(K-2))31.15,,31.15 -31.10 T ""ARROWS AREN'T THAT CROOKED - TRY ANOTHER ROOM."!; G 30.8 -31.15 S K=K+1; I (K-J7)30.8,30.8; - -31.20 C - SHOOT ARROW -31.30 C S L=L(1) <- NOT IN 'MORE BASIC COMP GMS' -31.40 S K=1 -31.50 S K1=1 -31.60 S T=((L-1)*3)+K1; I (S(T)-P(K)),32.95; -31.70 S K1=K1+1; I (K1-3)31.6,31.6; -31.80 C - NO TUNNEL FOR ARROW -31.90 S T=FINT(FRAN(0)*3)+1, L=S(((L-1)*3)+T) -32.01 G 33.1 -32.10 S K=K+1; I (K-J7)31.5,31.5; -32.20 T "MISSED."!; S L=L(1) -32.30 C - MOVE WUMPUS -32.40 S B=-1; G 33.7; C D 33.7 -32.50 C - AMMO CHECK -32.60 S A=A-1; I (A),,32.8 -32.70 S G=-1 -32.80 G 4.5 - -32.90 C - SEE IF ARROW IS AT L(1) OR AT L(2) -32.95 S L=P(K) -33.10 I (L-L(2))33.4,,33.4 -33.15 T "AHA! YOU GOT THE WUMPUS!"! -33.20 S G=1; G 4.5 -33.40 I (L-L(1))32.1,,32.1 -33.50 T "OUCH! ARROW GOT YOU!"!; G 32.7 - -33.70 C - MOVE WUMPUS ROUTINE -33.72 S K=FINT(FRAN(0)*4)+1 -33.74 I (K-4),33.78 -33.76 S T=((L(2)-1)*3)+K, L(2)=S(T) -33.78 I (L(2)-L)33.9,,33.9 -33.80 T "TSK TSK TSK - WUMPUS GOT YOU!"! -33.85 S G=-1 -33.90 I (B)32.6,41.9; - -40.01 C - MOVE ROUTINE -40.10 S G=0 -40.20 T "WHERE TO? "; A L -40.30 I (L-1)40.2; -40.40 I (L-20),,40.2 -40.50 C - CHECK IF LEGAL MOVE -40.60 S K=1 -40.70 S T=L(1)-1, T=T*3+K -40.75 I (S(T)-L),41.3; -40.80 S K=K+1; I (K-3)40.7,40.7; -40.90 I (L-L(1)),41.3; -41.10 T "NOT POSSIBLE - " -41.15 G 40.2 -41.20 C - CHECK FOR HAZARDS -41.30 S L(1)=L -41.40 C - WUMPUS *** -41.50 I (L-L(2))42.15,,42.15 -41.60 T "... OOPS! BUMPED A WUMPUS!"! -41.70 C - MOVE WUMPUS -41.80 S B=0; G 33.7; C D 33.7 -41.90 I (G),42.2; -42.10 C - PIT -42.15 I (L-L(3))42.2,42.3,42.2 -42.20 I (L-L(4))42.7,42.3,42.7 -42.30 T "YYYYIIIIEEEE . . . FELL IN PIT!"! -42.40 S G=-1; G 4.9 -42.60 C - BATS -42.70 I (L-L(5))42.75,42.8,42.75 -42.75 I (L-L(6))43.1,42.8,43.1 -42.80 T "ZAP--SUPER BAT SNATCH! ELSEWHEREVILLE FOR YOU!"! -42.90 S L=FINT(FRAN(0)*20)+1 -43.05 G 41.3 -43.10 G 4.9 - -50.10 Q - -90.05 C - INSTRUCTIONS -90.10 T "WELCOME TO 'HUNT THE WUMPUS'"! -90.20 T " THE WUMPUS LIVES IN A CAVE OF 20 ROOMS. EACH ROOM"! -90.30 T "HAS 3 TUNNELS LEADING TO OTHER ROOMS. (LOOK AT A"! -90.40 T "DODECAHEDRON TO SEE HOW THIS WORKS-IF YOU DON'T KNOW"! -90.50 T "WHAT A DODECAHEDRON IS, ASK SOMEONE)"!! -90.70 T " HAZARDS:"! -90.80 T " BOTTOMLESS PITS - TWO ROOMS HAVE BOTTOMLESS PITS IN THEM."! -90.90 T " IF YOU GO THERE, YOU FALL INTO THE PIT (& LOSE!)."! -90.95 T " SUPER BATS - TWO OTHER ROOMS HAVE SUPER BATS. IF YOU"! -91.10 T " GO THERE, A BAT GRABS YOU AND TAKES YOU TO SOME OTHER"! -91.20 T " ROOM AT RANDOM (WHICH MAY BE TROUBLESOME)."!! -91.40 T " WUMPUS:"! -91.50 T " THE WUMPUS IS NOT BOTHERED BY HAZARDS (HE HAS SUCKER"! -91.60 T " FEET AND IS TOO BIG FOR A BAT TO LIFT). USUALLY"! -91.70 T " HE IS ASLEEP. TWO THINGS WAKE HIM UP: YOU ENTERING HIS"! -91.80 T " ROOM OR YOU SHOOTING AN ARROW."! -91.90 T " IF THE WUMPUS WAKES, HE MOVES (P=.75) ONE ROOM"! -92.10 T " OR STAYS STILL (P=.25). AFTER THAT, IF HE IS WHERE YOU"! -92.20 T " ARE, HE EATS YOU UP AND YOU LOSE!"!! -92.25 T "(PRESS ANY KEY TO CONTINUE)"; S Z=FCHR(); T !! -92.30 T " YOU:"! -92.40 T " EACH TURN YOU MAY MOVE OR SHOOT A CROOKED ARROW."! -92.50 T " MOVING: YOU CAN MOVE ONE ROOM (THRU ONE TUNNEL)."! -92.60 T " ARROWS: YOU HAVE 5 ARROWS. YOU LOSE WHEN YOU RUN OUT."! -92.70 T " EACH ARROW CAN GO FROM 1 TO 5 ROOMS. YOU AIM BY TELLING"! -92.80 T " THE COMPUTER THE ROOM #S YOU WANT THE ARROW TO GO TO."! -92.90 T " IF THE ARROW CAN'T GO THAT WAY (IF NO TUNNEL) IT MOVES"! -93.10 T " AT RANDOM TO THE NEXT ROOM."! -93.20 T " IF THE ARROW HITS THE WUMPUS, YOU WIN."! -93.30 T " IF THE ARROW HITS YOU, YOU LOSE."!! -93.40 T " WARNINGS:"! -93.50 T " WHEN YOU ARE ONE ROOM AWAY FROM A WUMPUS OR HAZARD,"! -93.60 T " THE COMPUTER SAYS:"! -93.70 T " WUMPUS: 'I SMELL A WUMPUS'"! -93.80 T " BAT : 'BATS NEARBY'"! -93.90 T " PIT : 'I FEEL A DRAFT'"!! -94.05 T "(PRESS ANY KEY TO BEGIN)"; S Z=FCHR(); T !! -94.10 G 1.45 diff --git a/Task/Hunt-the-Wumpus/Forth/hunt-the-wumpus.fth b/Task/Hunt-the-Wumpus/Forth/hunt-the-wumpus.fth deleted file mode 100644 index 77842adb0d..0000000000 --- a/Task/Hunt-the-Wumpus/Forth/hunt-the-wumpus.fth +++ /dev/null @@ -1,733 +0,0 @@ -\ Hunt the Wumpus - FORTH - v 1.00 - -: wumpus-version ( -- ) - ." Version 1.00 - FORTH " - ; - -[DEFINED] UTIME [IF] ( -- Dusec ) - : MS@ UTIME DROP ; \ gforth -[ELSE] -[DEFINED] counter [IF] - : MS@ counter ; \ SwiftForth -[THEN] [THEN] - -include random.fs \ defines random ( n -- 0..n-1 ) - -\ Initialize random seed from a -\ value that changes with time -MS@ SEED ! - -\ -\ The cave: 20 rooms, each connected to 3 others, -\ as a dodecahedron -\ -20 CONSTANT COUNT-ROOMS - 3 CONSTANT COUNT-NEIGHBORS -CREATE CAVE \ adjacency list - 5 C, 8 C, 2 C, \ ROOM 1 - 1 C, 10 C, 3 C, \ ROOM 2 - 2 C, 12 C, 4 C, \ ROOM 3 - 3 C, 14 C, 5 C, \ ROOM 4 - 4 C, 6 C, 1 C, \ ROOM 5 - 15 C, 5 C, 7 C, \ ROOM 6 - 6 C, 17 C, 8 C, \ ROOM 7 - 7 C, 1 C, 9 C, \ ROOM 8 - 8 C, 18 C, 10 C, \ ROOM 9 - 9 C, 2 C, 11 C, \ ROOM 10 - 10 C, 19 C, 12 C, \ ROOM 11 - 11 C, 3 C, 13 C, \ ROOM 12 - 12 C, 20 C, 14 C, \ ROOM 13 - 13 C, 4 C, 15 C, \ ROOM 14 - 14 C, 16 C, 6 C, \ ROOM 15 - 20 C, 15 C, 17 C, \ ROOM 16 - 16 C, 7 C, 18 C, \ ROOM 17 - 17 C, 9 C, 19 C, \ ROOM 18 - 18 C, 11 C, 20 C, \ ROOM 19 - 19 C, 13 C, 16 C, \ ROOM 20 - -\ Game state -CREATE HUNTER 1 CHARS ALLOT \ Player location -CREATE WUMPUS 1 CHARS ALLOT \ Wumpus location -CREATE PITS 2 CHARS ALLOT \ Rooms with pits -CREATE BATS 2 CHARS ALLOT \ Rooms with bats - -CREATE ARROWS 1 CHARS ALLOT \ Crooked arrows left -CREATE PLAYER 1 CHARS ALLOT \ IN-PLAY, WON, LOST - -\ Keep track of whether bats snatched the Hunter -\ TRUE if bats moved player -CREATE BATS-MOVED-HUNTER 1 CELLS ALLOT - -\ Arrow path -CREATE ARROW-PATH-LENGTH 1 CHARS ALLOT -CREATE ARROW-PATH-ROOMS 5 CHARS ALLOT - -\ Initial room assignments in order: -\ Hunter, Wumpus, pits, bats -CREATE INITIAL-ROOMS 6 CHARS ALLOT - -\ Scratch area for generating a random shuffle -\ of the 20 room numbers -CREATE ROOM-NUMBERS COUNT-ROOMS CHARS ALLOT - -\ Player states -0 CONSTANT IN-PLAY -1 CONSTANT WON -2 CONSTANT LOST - -\ Quit, or play again with new or same initial state -0 CONSTANT QUIT-GAME -1 CONSTANT SAME-ROOMS -2 CONSTANT NEW-ROOMS - -\ A pointer to a prompt string -CREATE PROMPT-STRING 2 CELLS ALLOT - -\ An 8-character buffer for prompt answers -8 CONSTANT MAX-ANSWER-LENGTH -CREATE PROMPT-ANSWER MAX-ANSWER-LENGTH CHARS ALLOT - -\ Responses to a yes-no question -CHAR y CONSTANT YES -CHAR n CONSTANT NO - -\ Responses to a command prompt -CHAR w CONSTANT WHERE-AM-I? -CHAR m CONSTANT MOVE-ME -CHAR s CONSTANT SHOOT -\ - undocumented - -CHAR g CONSTANT GAME-STATE \ show the game state -CHAR c CONSTANT CAVE-ROOMS \ show all the cave rooms - -ALIGN \ Align to next slot boundary - -\ -\ The Cave -\ room-number in 1..20 -\ WARNING: These cave referencing words -\ don't validate room numbers!!! -\ - -\ Determine if a room number is in the cave -: ?cave-room-number-valid ( room-number -- flag ) - DUP 0 < SWAP COUNT-ROOMS > OR INVERT - ; - -\ Get a pointer to a room -: cave-room-address ( room-number -- room-address ) - 1- COUNT-NEIGHBORS * CHARS CAVE + - ; - -\ Get the room number of a neighbor -: cave-room-neighbor ( index room-number -- room-number ) - cave-room-address SWAP CHARS + C@ - ; - -\ Get a list of a room's neighbors -: cave-room-neighbors ( room-number -- n_1 n_2 n_3 ) - DUP cave-room-address C@ SWAP - DUP cave-room-address CHAR+ C@ SWAP - cave-room-address 2 CHARS + C@ - ; - -\ Determine if a room is a neighbor -: ?cave-room-reachable ( to from -- flag ) - cave-room-neighbors FALSE - 4 PICK 4 PICK = OR - 4 PICK 3 PICK = OR - 4 PICK 2 PICK = OR - SWAP DROP SWAP DROP SWAP DROP SWAP DROP - ; - -\ Does this room have the Hunter in it? -: ?cave-room-has-hunter ( room-number -- flag ) - HUNTER C@ = - ; - -\ Does this room have the Wumpus in it? -: ?cave-room-has-wumpus ( room-number -- flag ) - WUMPUS C@ = - ; - -\ Does this room have a bottomless pit in it? -: ?cave-room-has-pit ( room-number -- flag ) - DUP PITS C@ = SWAP PITS CHAR+ C@ = OR - ; - -\ Does this room have super bats in it? -: ?cave-room-has-bats ( room-number -- flag ) - DUP BATS C@ = SWAP BATS CHAR+ C@ = OR - ; - -\ -\ Room number selection - for initial room assignments -\ -\ This is a variant of the -\ Fisher-Yates shuffle (a.k.a. the Knuth shuffle), -\ starting from the beginning of the rooms list, -\ and selecting only as many rooms as needed. -\ - -\ Fill room numbers with the sequence 1..20 -: reset-room-numbers ( -- ) - COUNT-ROOMS 0 DO I CHARS ROOM-NUMBERS + I 1+ SWAP C! LOOP - ; - -\ Display the room numbers -: show-room-numbers ( -- ) - COUNT-ROOMS 0 DO I CHARS ROOM-NUMBERS + C@ . LOOP - ; - -\ Choose a room in i..19 (yes, it could be i) -: choose-room-in-tail ( i -- r ) - DUP COUNT-ROOMS 1- SWAP - \ max-index-within-tail - 1+ random + \ r - ; - -\ Swap ith (i in 0..19) room with a room in i..19 -: swap-random-in-tail ( i -- ) - DUP ROOM-NUMBERS CHARS + C@ SWAP \ -- Ni i - DUP choose-room-in-tail TUCK \ -- Ni r i r - ROOM-NUMBERS CHARS + C@ SWAP \ -- Ni r Nr i - ROOM-NUMBERS CHARS + C! \ -- Ni r - ROOM-NUMBERS CHARS + C! - ; - -\ Select n <= 20 rooms at random -: select-random-rooms ( n -- random-rooms ) - DUP COUNT-ROOMS > IF - CR . ABORT" Can't select more than 20 rooms " - THEN - reset-room-numbers - 0 DO - I swap-random-in-tail - \ CR I . ." : " show-room-numbers - LOOP - ; - -\ Create and save a new room configuration -: create-new-room-assignments ( -- ) - 6 select-random-rooms - ROOM-NUMBERS INITIAL-ROOMS 6 CMOVE - ; - -\ -\ Player dialogue -\ - -\ Show the game state -: show-game-state ( -- ) - CR ." HUNTER: " HUNTER C@ . - CR ." WUMPUS: " WUMPUS C@ . - CR ." PITS: " PITS C@ . PITS CHAR+ C@ . - CR ." BATS: " BATS C@ . BATS CHAR+ C@ . - CR ." ARROWS: " ARROWS C@ . - CR ." PLAYER: " PLAYER C@ - CASE - LOST OF ." LOST " ENDOF - IN-PLAY OF ." IN-PLAY " ENDOF - WON OF ." WON " ENDOF - DUP CR . ." unexpected PLAYER state " - ENDCASE - ; - -\ List the neighboring rooms -: list-neighbors ( room-number -- ) - cave-room-neighbors - . . . - ; - -\ Show a list of all the cave's rooms -: show-cave-rooms ( -- ) - COUNT-ROOMS 0 DO - I 1+ DUP CR . ." : " list-neighbors - LOOP - ; - -\ Accept an answer from the player -: input-answer ( max-length -- length ; chars in PROMPT-ANSWER ) - MAX-ANSWER-LENGTH MIN \ Limit input to buffer length - BEGIN - CR ." > " - DUP PROMPT-ANSWER SWAP ACCEPT - DUP 0 > DUP INVERT IF - CR ." Huh? " - SWAP DROP \ Forget zero length - THEN - UNTIL \ Try again if no characters entered - SWAP DROP \ Forget max input length - ; - -\ Input one lowercase ASCII character from the player -: input-ascii-lowercase ( -- answer ) - 1 input-answer DROP \ Forget length - \ Convert ASCII alpha to lowercase; others don't care - PROMPT-ANSWER C@ 32 OR PROMPT-ANSWER C! - PROMPT-ANSWER C@ - ; - -\ Accept a numeric answer from the player -: input-number ( -- number ) - BEGIN - 2 input-answer PROMPT-ANSWER SWAP \ -- answer-address length - \ try to convert the answer into a number - 0 0 2SWAP >NUMBER \ -- n 0 remnant-address remnant-length - 0= DUP INVERT IF \ -- n 0 remnant-address flag - CR ." That is not a number. " - 2SWAP 2DROP \ Forget invalid answer - SWAP DROP \ Forget remnant-address, leaving FALSE - ELSE \ Entire answer was converted to a number - SWAP DROP \ Forget remnant-address - SWAP DROP \ Forget high-order zero of number in 0..99 - THEN - UNTIL \ Try again if answer was invalid - ; - -\ Ask a yes-no question, don't accept anything else -: prompt-yes-no ( question -- YES | NO ) - PROMPT-STRING 2! - BEGIN - CR PROMPT-STRING 2@ TYPE ." (y|n)? " - input-ascii-lowercase - DUP YES = OVER NO = OR - DUP INVERT IF - CR ." Huh? " - SWAP DROP \ Forget invalid answer - THEN - UNTIL \ Try again if answer was invalid - ; - -\ Show the stored crooked arrow path -: show-arrow-path ( -- ) - CR ." ARROW PATH - " - ARROW-PATH-LENGTH C@ DUP . ." : " 0 DO - ARROW-PATH-ROOMS I CHARS + C@ . - LOOP - ; - -\ Prompt for path length when shooting a crooked arrow -: prompt-arrow-path-length ( -- 1..5 ) - BEGIN - CR ." How many rooms should the arrow traverse (1..5)? " - input-number - DUP 1 < OVER 5 > OR - DUP IF - CR ." Huh? " - SWAP DROP \ Forget invalid answer - THEN - INVERT - UNTIL \ Try again if room count was invalid - ; - -\ Get room number arrow can't go back to -: arrow-path-backtrack-room ( index -- invalid-room ) - \ The arrow is not so crooked that it - \ can go out the tunnel it came in through. - DUP 1 > IF - \ Path has more than one room already; - \ the arrow can't go back to the room - \ before the last one entered. - 2 - CHARS ARROW-PATH-ROOMS + C@ - ELSE - 1 = IF - \ Path has exactly one room so far; the arrow - \ can't go back to the room the Hunter is in. - HUNTER C@ - ELSE - \ This is to be the first room in the path; - \ the arrow can be sent anywhere, - \ including the room the Hunter is in. - 0 \ Zero won't match any room. - THEN - THEN - ; - -\ Prompt for the next room in the arrow's path -: prompt-arrow-path-room ( index -- room ) - BEGIN - CR ." Enter room " DUP 1+ . - input-number \ -- index room - OVER arrow-path-backtrack-room \ -- index room invalid-room - OVER = DUP IF \ -- index room flag - CR ." Huh, arrows aren't that crooked! " - SWAP DROP \ Forget chosen room - ELSE - ROT DROP \ Forget the index - THEN \ -- index TRUE | room FALSE - INVERT - UNTIL \ Try again if room was invalid - ; - -\ Prompt for the arrow's path when shooting a crooked arrow -: prompt-arrow-path ( -- ; sets arrow path length and rooms ) - prompt-arrow-path-length - DUP ARROW-PATH-LENGTH C! 0 DO - I prompt-arrow-path-room - ARROW-PATH-ROOMS I CHARS + C! - LOOP - ; - -\ Prompt for a command -: prompt-command ( -- MOVE-ME | SHOOT | WHERE-AM-I? ) - BEGIN - CR ." What do you want to do " - ." (m=move, s=shoot, w=where am I?)? " - input-ascii-lowercase - DUP MOVE-ME = OVER SHOOT = OR - OVER WHERE-AM-I? = OR - \ - undocumented - - OVER GAME-STATE = OR - OVER CAVE-ROOMS = OR - DUP INVERT IF - CR ." Huh? " - SWAP DROP \ Forget invalid answer - THEN - UNTIL \ Try again if command was invalid - ; - -\ Prompt to play again, with same or new room assignments -: prompt-play-again ( -- QUIT-GAME | SAME-ROOMS | NEW-ROOMS ) - s" Play again " prompt-yes-no - YES = IF - CR ." OK, play again ... " - s" Same rooms " prompt-yes-no - YES = IF - CR ." OK, you, the Wumpus, pits, and bats in the same rooms. " - SAME-ROOMS - ELSE - CR ." OK, you, the Wumpus, pits, and bats in new rooms (probably). " - NEW-ROOMS - THEN - ELSE - CR ." Bye " - QUIT-GAME - THEN - ; - -\ Display congratulations or condolences -: show-result ( WON | LOST -- ) - DUP WON = IF - CR ." Congratulations! You got the Wumpus! But next time, hee, hee, hee!" - DROP - ELSE - DUP LOST = IF - CR ." Condolences, maybe better luck next time." - DROP - ELSE - CR . ." unknown game result." - THEN - THEN - ; - -\ Get a new room for the player -: prompt-new-hunter-room ( -- room ) - BEGIN - CR ." Where do you want to go? " - input-number - DUP ?cave-room-has-hunter IF - CR ." You are already in room " . ." ... " - DROP \ Forget room Hunter already in - FALSE \ answer not valid, try again - ELSE - DUP HUNTER C@ ?cave-room-reachable - DUP INVERT IF - CR ." Can't get there from here. " - SWAP DROP \ Forget unreachable room - THEN - THEN - UNTIL \ Try again if room was invalid - ; - -\ Display instructions -: show-instructions ( -- ) - CR ." ---- INSTRUCTIONS ---- " - CR - CR ." Welcome to Hunt the Wumpus! You are a hunter, looking to bag a Wumpus. " - CR - CR ." The Wumpus lives in a cave of twenty rooms, each connected by " - CR ." tunnels to three other rooms, as in a dodecahedron. " - CR - CR ." There are HAZARDS!! " - CR - CR ." The Wumpus - One room has the Wumpus in it. If the Wumpus " - CR ." finds you in the room with it, it will eat you and you lose. " - CR - CR ." Bottomless Pits - Two rooms have bottomless pits in them. " - CR ." If you go there, you fall into the pit and lose. " - CR - CR ." Super Bats - Two other rooms have super bats in them. " - CR ." If you go there, a bat grabs you and takes you to another " - CR ." room, at random. This might be troublesome. " - CR - CR ." As you are hunting, you will be able to sense something of " - CR ." the hazards, when you are in a room adjacent to one. " - CR - CR ." - You can smell the Wumpus, when it is nearby. " - CR ." - You can feel a breeze, when there is a pit nearby " - CR ." - You can hear a rustling sound, when there are bats nearby. " - CR - CR ." The Wumpus is not bothered by the hazards. It has sucker " - CR ." feet, so can cling to the walls of a pit, and is too heavy " - CR ." for the super bats to lift. Usually, it is asleep. " - CR - CR ." Two things wake up the Wumpus: you entering its room, or " - CR ." you shooting an arrow (anywhere in the cave!). When it " - CR ." wakes, it moves into an adjacent room (P=3/4) or stays " - CR ." where it is (P=1/4). After that, if it is where you are " - CR ." it eats you and you lose. " - CR - CR ." The computer starts you in a randomly chosen room. " - CR ." Each turn you can move to an adjacent room or shoot an arrow. " - CR - CR ." You are furnished with 5 crooked arrows, which you can program " - CR ." to go into 1 to 5 rooms. Starting from the room you are in, " - CR ." the arrow will go from room to room provided there is a tunnel " - CR ." from where it is to the next room on its list. If there is no " - CR ." tunnel, the arrow bounces on the walls of the cave and moves into " - CR ." an adjacent room at random, possibly the one you are in. " - CR - CR ." - If the arrow hits the Wumpus, you win. " - CR ." - If the arrow hits you, you lose. " - CR ." - If you run out of arrows, you lose. " - CR - CR ." When the game is over, you can start a new game. " - CR ." You can choose to start over with the same configuration " - CR ." as the game you just finished, that is: with you, the Wumpus, " - CR ." the pits, and the bats where they started in the game you " - CR ." just finished; or you can start fresh, with everything in " - CR ." new places (well, probably). In any case, you get a fresh " - CR ." supply of five arrows. " - CR - CR ." Good luck! " - ; - -\ Display instructions if wanted -: show-instructions-if-wanted ( -- ) - s" Show instructions " prompt-yes-no - YES = IF - show-instructions - THEN - ; - -\ Display a greeting -: show-greeting ( -- ) - CR ." ---- ---- Hunt the Wumpus ---- ---- " - CR ." - " wumpus-version - CR ." ---- ---- --------------- ---- ---- " - ; - -\ -\ Game play -\ - -\ List any hazards in a room -: hazards-in-room ( room-number -- ) - DUP ?cave-room-has-wumpus IF - CR ." I smell a Wumpus!" - THEN - DUP ?cave-room-has-pit IF - CR ." I feel a draft!" - THEN - DUP ?cave-room-has-bats IF - CR ." I hear a rustling sound!" - THEN - DROP \ Forget room number - ; - -\ Warn of any hazards in the neighboring rooms -: warn-of-hazards ( room-number -- ) - cave-room-neighbors - hazards-in-room - hazards-in-room - hazards-in-room - ; - -\ Describe the Hunter's location -: describe-hunter-location ( -- ) - HUNTER C@ - CR ." You are in room " DUP . - CR ." Tunnels lead to rooms " DUP list-neighbors - warn-of-hazards - ; - -\ The Wumpus eats the Hunter if in the same room -: wumpus-ate-hunter? ( -- ; may set player state to LOST ) - HUNTER C@ ?cave-room-has-wumpus IF - CR ." Aaaaggghhh! The Wumpus got you! You lose! " - LOST PLAYER C! - ELSE - CR ." Phew! The Wumpus didn't get you. " - THEN - ; - -\ Move the Wumpus - did it get the Hunter? -: move-wumpus ( -- ; may set player state to LOST ) - CR ." Uh oh! You disturbed the Wumpus! " - 4 random DUP 3 < IF - WUMPUS C@ cave-room-neighbor WUMPUS C! - ELSE - DROP \ Forget index indicating Wumpus didn't move - THEN - wumpus-ate-hunter? \ may set player state to LOST - ; - -\ Did the crooked arrow hit the Wumpus? -: arrow-hit-wumpus? ( room -- flag ; may set player state to WON ) - ?cave-room-has-wumpus DUP IF - CR ." Aha! You got the Wumpus! " - WON PLAYER C! - THEN - ; - -\ Did the crooked arrow hit the Hunter? -: arrow-hit-hunter? ( room -- flag ; may set player state to LOST ) - ?cave-room-has-hunter DUP IF - CR ." Ouch! Arrow got you! You lose!" - LOST PLAYER C! - THEN - ; - -\ Did the Hunter run out of crooked arrows? -: arrows-all-gone? ( -- ; may set player state to LOST ) - ARROWS C@ 1- DUP ARROWS C! 0 = IF - CR ." You're out of arrows, you lose! " - LOST PLAYER C! - THEN - ; - -\ Fly a crooked arrow -: fly-arrow ( -- ; may set player state to WON or LOST ) - HUNTER C@ \ arrow starts where player is - DUP CR . - ARROW-PATH-LENGTH C@ 0 DO - ." --> " - ARROW-PATH-ROOMS I CHARS + C@ \ Rf -- Rf Rt - 2DUP SWAP ?cave-room-reachable IF - SWAP DROP \ Rf Rt -- Rt ; Arrow now in next room in path - ELSE - DROP \ Rf Rt -- Rf ; Forget the unreachable room - CR ." Uh oh! You hit the cave wall, arrow gone astray! " - \ Arrow enters one of the adjoining rooms - cave-room-address 3 random CHARS + C@ \ Rf -- Rt - THEN - DUP . - \ OK, what happens when the arrow reaches this room? - DUP arrow-hit-hunter? OVER arrow-hit-wumpus? OR IF - LEAVE \ That's the end of the arrow's flight - THEN - LOOP - DROP \ Forget the last room the arrow went into - ; - -\ Shoot a crooked arrow -: shoot-arrow ( -- ) - prompt-arrow-path - show-arrow-path - fly-arrow \ may set player state to WON or LOST - PLAYER C@ IN-PLAY = IF - \ The arrow didn't hit anything - CR ." You missed! " - \ Shooting an arrow always disturbs the Wumpus - move-wumpus \ may set player state to LOST - arrows-all-gone? \ may set player state to LOST - THEN - ; - -\ Hunter went into a room with super bats? -: entered-room-with-bats? ( -- flag ) - HUNTER C@ ?cave-room-has-bats DUP IF - CR ." Oh oh oh! A bat's got you! Oh ohhh ... " - COUNT-ROOMS random 1+ DUP HUNTER C! - CR ." You are now in room " . - THEN - \ Return TRUE if a super bat moved the Hunter - ; - -\ Hunter went into a room with a bottomless pit? -: entered-room-with-pit? ( -- ; may set player state to LOST ) - HUNTER C@ ?cave-room-has-pit IF - CR ." Aaaaggghhh! You fell in a pit! You lose! " - LOST PLAYER C! - THEN - ; - -\ Hunter went into a room with the Wumpus? -: entered-room-with-wumpus? ( -- ; may set player state to LOST ) - HUNTER C@ ?cave-room-has-wumpus IF - move-wumpus \ may set player state to LOST - THEN - ; - -\ Move the Hunter to a new room -: move-hunter ( -- ; may set player state to LOST ) - prompt-new-hunter-room HUNTER C! - BEGIN - FALSE BATS-MOVED-HUNTER ! - entered-room-with-wumpus? \ may set player state to LOST - PLAYER C@ IN-PLAY = IF - entered-room-with-pit? \ may set player state to LOST - PLAYER C@ IN-PLAY = IF - entered-room-with-bats? BATS-MOVED-HUNTER ! - THEN - THEN - BATS-MOVED-HUNTER @ INVERT - UNTIL \ repeat if the bats moved the Hunter - PLAYER C@ IN-PLAY = IF - \ Nothing too bad happened, let's take a moment - \ to take in our surroundings - describe-hunter-location - THEN - ; - -\ Play the game until won or lost -: play ( -- WON | LOST ) - BEGIN PLAYER C@ IN-PLAY = WHILE - prompt-command \ -- MOVE-ME | SHOOT | WHERE-AM-I? - CASE - MOVE-ME OF move-hunter ENDOF - SHOOT OF shoot-arrow ENDOF - WHERE-AM-I? OF describe-hunter-location ENDOF - \ - undocumented - - GAME-STATE OF show-game-state ENDOF - CAVE-ROOMS OF show-cave-rooms ENDOF - CR . ." unexpected command." - ENDCASE - REPEAT - PLAYER C@ - ; - -\ Set the room configuration to the saved one -: set-rooms-to-initial-assignments ( -- ) - INITIAL-ROOMS C@ HUNTER C! - INITIAL-ROOMS CHAR+ C@ WUMPUS C! - INITIAL-ROOMS 2 CHARS + C@ PITS C! - INITIAL-ROOMS 3 CHARS + C@ PITS CHAR+ C! - INITIAL-ROOMS 4 CHARS + C@ BATS C! - INITIAL-ROOMS 5 CHARS + C@ BATS CHAR+ C! - ; - -\ Reset the state for a new game -: new-game ( SAME-ROOMS | NEW-ROOMS -- ) - NEW-ROOMS = IF - create-new-room-assignments - THEN - set-rooms-to-initial-assignments - 5 ARROWS C! - IN-PLAY PLAYER C! - ; - -\ Greet the player, play, then prompt for a new game -: Hunt-the-Wumpus ( -- ) - show-greeting - show-instructions-if-wanted - NEW-ROOMS - BEGIN - new-game \ SAME-ROOMS | NEW-ROOMS -- - describe-hunter-location \ -- - play \ -- WON | LOST - show-result \ WON | LOST -- - prompt-play-again \ -- QUIT-GAME | SAME-ROOMS | NEW-ROOMS - DUP QUIT-GAME = - UNTIL - DROP \ Forget the QUIT-GAME indicator - ; diff --git a/Task/Hunt-the-Wumpus/FutureBasic/hunt-the-wumpus.basic b/Task/Hunt-the-Wumpus/FutureBasic/hunt-the-wumpus.basic deleted file mode 100644 index 714df4ab49..0000000000 --- a/Task/Hunt-the-Wumpus/FutureBasic/hunt-the-wumpus.basic +++ /dev/null @@ -1,229 +0,0 @@ -// Hunt the Wumpus -// https://rosettacode.org/wiki/Hunt_the_Wumpus# - - -_w = 640 // window size width and height -_h = 400 -_window = 1 - -local fn BuildWindow - - CGRect r = fn cgrectmake(0,0,_w,_h) - window _Window, @"Hunt the Wumpus", r, NSWindowStyleMaskTitled + NSWindowStyleMaskMiniaturizable - windowcenter(_Window) - WindowSetBackgroundColor(_Window,fn ColorBlack) - WindowPrintViewSetTextInset( _window, 20) - - text ,14,fn colorWhite - -end fn - - -fn BuildWindow - - -//////////// Main Program ////////////// - -"Start" - -cls:restore - -data 7,13,19,12,18,20,16,17,19,11,14,18,13,15,18,9,14,16,1,15,17,10,16,20,6,11,19,8,12,17 -data 4,9,13,2,10,15,1,5,11,4,6,20,5,7,12,3,6,8,3,7,10,2,4,5,1,3,9,2,8,14 -data 1,2,3,1,3,2,2,1,3,2,3,1,3,1,2,3,2,1 - -uint32 i, j,tunnel(21,4),lost(7,4),targ,wump,player,bat1, bat2, pit1, pit2, d6, epi -player = int(rnd(20)) -uint32 arrows = 5 -CFStringRef choice - -for i = 1 to 20 //set up rooms - for j = 1 to 3 - read tunnel(i,j) - next j -next i - -for i = 1 to 6 //set up list of permuatations of 1-2-3 - for j = 1 to 3 - read lost(i,j) - next j -next i - - -//place wumpus, bats, and pits -do - wump = int(rnd(20)) -until wump <> player -do - pit1 = int(rnd(20)) -until pit1 <> player -do - pit2 = int(rnd(20)) -until pit2 <> player && pit2 <> pit1 -do - bat1 = int(rnd(20)) -until bat1 <> player && bat1 <> pit1 && bat1 <> pit2 -do - bat2 = int(rnd(20)) -until bat2 <> player && bat2 <> pit1 && bat2 <> pit2 && bat2 <> bat1 - -do - if player = wump - text ,,fn colorRed - print "You have been eaten by the Wumpus!" - Print: WindowPrintViewScrollToBottom( _window ) - goto "defeat" - end if - if player = pit1 || player = pit2 - text ,,fn colorRed - print "Aaaaaaaaaaa! You have fallen into a bottomless pit." - Print: WindowPrintViewScrollToBottom( _window ) - goto "defeat" - end if - if player = bat1 || player = bat2 - text ,,fn colorOrange - print "A bat has carried you into another empty room." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - do - player = (rnd(20)) - until player <> wump && player <> pit1 && player <> pit2 && player <> bat1 && player <> bat2 - end if - - print - text ,,fn colorGreen - print "You are in room number" + str$(player) + ". There are tunnels to rooms"¬ - + str$(tunnel(player,1)) + "," str$(tunnel(player,2)) + " and" +str$(tunnel(player,3)) - if (tunnel(player,1)) + (tunnel(player,2)) + (tunnel(player,3)) = 0 then arrows = 5 : goto "Start" - text ,,fn colorYellow - print "You have" + str$(arrows) + " arrows left." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - - d6 = int(rnd(6)) - for i = 1 to 3 - epi = tunnel(player,lost(d6,i)) - if epi = wump - text ,,fn colorRed - print "You smell something terrible nearby." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - end if - if epi = bat1 || epi = bat2 - text ,,fn colorRed - print "You hear a rustling." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - end if - if epi = pit1 || epi = pit2 - print "You feel a cold wind blowing from a nearby cavern." - Print: WindowPrintViewScrollToBottom( _window ) - end if - next i - "choices" - print - print "What would you like to do?" - Print: WindowPrintViewScrollToBottom( _window ) - - choice = input %(_w/2 - 260 , _h + 20),@"Type A to shoot an arrow, or a number to move to another room. ( or Q to quit )" - - select case left(choice,1) - - case @"q", @"Q" , @"x" , @"X" - end - - case @"a", @"A" - - CFStringRef targString - targString = input %(_w/2 - 140 , _h + 20), @"Which room would you like to shoot into? " - targ = fn StringIntegerValue(targString) - - print "You shot an arrow into room " + str$(targ) - - if targ = player - text ,,fn colorRed - print "You shot yourself. Why would you want to do such a thing?" - Print: WindowPrintViewScrollToBottom( _window ) - goto "defeat" - end if - - text ,,fn colorGreen - if targ = wump then goto "victory" - - if targ = tunnel(player,1) || targ = tunnel(player,2) || targ = tunnel(player,3) - text ,,fn colorYellow - print "The Wumpus awakes!" - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - if rnd(100) <= 75 - print "He moves to a nearby cavern." - Print: WindowPrintViewScrollToBottom( _window ) - short wumpRnd - wumpRnd = Int(Rnd(3)) - wump = Tunnel(wump,wumpRnd) - else - print "He goes back to sleep." - Print: WindowPrintViewScrollToBottom( _window ) - end if - else - text ,,fn colorRed - print "You can't shoot that room from here." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - goto "choices" - end if - arrows -= 1 - - case @"0", @"1" ,@"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9" - - targ = fn StringIntegerValue(choice) - if targ = player then print "You are already there." - - if targ = tunnel(player,1) || targ = tunnel(player,2) || targ = tunnel(player,3) - print using "You walk to room ##"; targ - player = targ - else - text ,,fn colorOrange - print "You can't get there from here." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - end if - case else - text ,,fn colorRed - print "You are making no sense." - text ,,fn colorWhite - Print: WindowPrintViewScrollToBottom( _window ) - end select -until arrows = 0 -text ,,fn colorRed -print "You have run out of arrows!" -Print: WindowPrintViewScrollToBottom( _window ) -"defeat" -text ,,fn colorRed -print "You lose! Better luck next time." -Print: WindowPrintViewScrollToBottom( _window ) - -goto "End" - -"victory" -text ,20,fn colorGreen -print "You have slain the Wumpus!" -print "You won!" -Print: WindowPrintViewScrollToBottom( _window ) - -"End" - -text ,14,fn colorWhite -choice = input %(_w/2 -140 , _h + 20),@"Hit Return for another. ( or Q to quit )" - -select case left(choice,1) - - case @"q", @"Q" , @"x" , @"X" - end - - case else arrows = 5: goto "Start" - -end select - - -handleevents diff --git a/Task/Hunt-the-Wumpus/Julia/hunt-the-wumpus.jl b/Task/Hunt-the-Wumpus/Julia/hunt-the-wumpus.julia similarity index 100% rename from Task/Hunt-the-Wumpus/Julia/hunt-the-wumpus.jl rename to Task/Hunt-the-Wumpus/Julia/hunt-the-wumpus.julia diff --git a/Task/Hunt-the-Wumpus/Liberty-BASIC/hunt-the-wumpus.basic b/Task/Hunt-the-Wumpus/Liberty-BASIC/hunt-the-wumpus.basic deleted file mode 100644 index cd667ebfab..0000000000 --- a/Task/Hunt-the-Wumpus/Liberty-BASIC/hunt-the-wumpus.basic +++ /dev/null @@ -1,272 +0,0 @@ -' ============================================ -' HUNT THE WUMPUS - Liberty BASIC (Text Version) -' Text-only game played in Mainwin -' ============================================ - -' --- Global Variables --- -dim rooms(20, 3) ' Adjacency map -dim hazard(20) ' 0=nothing, 1=Wumpus, 2=Bat, 3=Pit - -global playerRoom, arrowsLeft, gameOver, wRoom - -playerRoom = 0 -arrowsLeft = 5 -gameOver = 0 - -call setupMap -call placeHazards - -print "WELCOME TO HUNT THE WUMPUS!" -print "===========================" -print "You can enter commands like M10 to move to room 10" -print " or S18 to shoot into room 18. Of couse commands" -print " like M, S and Q are permitted as well. Good luck" -print "" -call mainLoop -end - -' ---------------------------- -sub setupMap - ' Each room has 3 connections - ' Standard dodecahedron layout - - data 2,5,8 - data 1,3,10 - data 2,4,12 - data 3,5,14 - data 1,4,6 - data 5,7,15 - data 6,8,17 - data 1,7,9 - data 8,10,18 - data 2,9,11 - data 10,12,19 - data 3,11,13 - data 12,14,20 - data 4,13,15 - data 6,14,16 - data 15,17,20 - data 7,16,18 - data 9,17,19 - data 11,18,20 - data 13,16,19 - - for i = 1 to 20 - for j = 1 to 3 - read a - rooms(i,j) = a - next - next -end sub - -' ---------------------------- -sub placeHazards - for i = 1 to 20 - hazard(i) = 0 - next - - wRoom = getEmptyRoom(0) - hazard(wRoom) = 1 - - for i = 1 to 2 - bRoom = getEmptyRoom(0) - hazard(bRoom) = 2 - next - - for i = 1 to 2 - pRoom = getEmptyRoom(0) - hazard(pRoom) = 3 - next - - playerRoom = getEmptyRoom(0) -end sub - -' ---------------------------- -function getEmptyRoom(avoid) - do - room = int(rnd(0)*20) + 1 - loop until hazard(room)=0 and room <> avoid - getEmptyRoom = room -end function - -' ---------------------------- -sub mainLoop - while gameOver = 0 - call describeHazards - print "You are in room "; playerRoom - print "Tunnels lead to "; rooms(playerRoom,1); ", "; rooms(playerRoom,2); ", "; rooms(playerRoom,3) - print "Arrows left: "; arrowsLeft - - input "Shoot, Move or Quit (S/M/Q)? "; a$ - a$ = upper$(trim$(a$)) - - if len(a$) > 1 then - 'assume characters 2 and 3 are part of a number - num = val(mid$(a$,2)) - if num > 20 then num = 0 - a$ = left$(a$,1) - end if - - select case a$ - case "S" - call shoot num - case "M" - call move num - case "Q" - Print "You have decided to quit." - gameOver = 1 - case else - print "Invalid choice." - end select - wend - - input "Press Enter to quit the game"; dummy$ -end sub - -' ---------------------------- -sub describeHazards - for i = 1 to 3 - adj = rooms(playerRoom,i) - select case hazard(adj) - case 1 - print "You smell something terrible nearby." - case 2 - print "You hear a rustling." - case 3 - print "You feel a cold wind blowing from a nearby cavern." - end select - next -end sub - -' ---------------------------- -sub move num - - if num = 0 then - input "Which room do you want to enter? "; n - if n < 1 or n > 20 then - print "That's not a valid room!" - exit sub - end if - else - n = num - end if - - adjacent = 0 - for i = 1 to 3 - if rooms(playerRoom,i) = n then adjacent = 1 - next - - if adjacent = 0 then - print "You can't go there directly!" - exit sub - end if - - playerRoom = n - select case hazard(playerRoom) - case 1 - print "You walked into the Wumpus room!" - print "The Wumpus eats you. GAME OVER!" - gameOver = 1 - case 2 - print "A giant bat grabs you!" - playerRoom = getEmptyRoom(0) - print "The bat drops you into room "; playerRoom - call checkNewRoom - case 3 - print "You fall into a bottomless pit!" - print "GAME OVER!" - gameOver = 1 - case else - ' safe - end select -end sub - -' ---------------------------- -sub checkNewRoom - select case hazard(playerRoom) - case 1 - print "The bat dropped you into the Wumpus room!" - print "The Wumpus eats you. GAME OVER!" - gameOver = 1 - case 3 - print "The bat dropped you into a pit!" - print "GAME OVER!" - gameOver = 1 - case 2 - print "Another bat grabs you!" - playerRoom = getEmptyRoom(0) - print "The bat drops you into room "; playerRoom - call checkNewRoom - case else - ' safe - end select -end sub - -' ---------------------------- -sub shoot num - - if num = 0 then - input "Shoot into which room? "; t - if t < 1 or t > 20 then - print "That's not a valid room!" - exit sub - end if - else - t = num - end if - - adjacent = 0 - for i = 1 to 3 - if rooms(playerRoom,i) = t then adjacent = 1 - next - - if adjacent = 0 then - print "You can't shoot there directly!" - exit sub - end if - - arrowsLeft = arrowsLeft - 1 - - if hazard(t) = 1 then - print "Your arrow flies true... and you hear a terrible scream!" - print "You have slain the Wumpus! YOU WIN!" - gameOver = 1 - exit sub - else - print "You missed." - wWake = int(rnd(0)*100) + 1 - if wWake <= 75 then - call moveWumpus - end if - if playerRoom = wRoom then - print "The Wumpus has moved into your room!" - print "It eats you. GAME OVER!" - gameOver = 1 - end if - end if - - 'check to see if you are out of arrows - if arrowsLeft <= 0 then - print "You're out of arrows!" - print "GAME OVER - You have lost." - gameOver = 1 - exit sub - end if - -end sub - -' ---------------------------- -sub moveWumpus - oldRoom = wRoom - found = 0 - for tries = 1 to 10 - adj = rooms(oldRoom, int(rnd(0)*3)+1) - if hazard(adj) = 0 and adj <> playerRoom then - hazard(oldRoom) = 0 - hazard(adj) = 1 - wRoom = adj - found = 1 - exit for - end if - next -end sub diff --git a/Task/Hunt-the-Wumpus/Mojo/hunt-the-wumpus.mojo b/Task/Hunt-the-Wumpus/Mojo/hunt-the-wumpus.mojo deleted file mode 100644 index 2c67a185ae..0000000000 --- a/Task/Hunt-the-Wumpus/Mojo/hunt-the-wumpus.mojo +++ /dev/null @@ -1,203 +0,0 @@ -from random import shuffle, seed, random_ui64 - -alias adjacent_rooms: List[List[Int]] = [ - [], - [2, 5, 8], [1, 3, 10], [2, 4, 12], [3, 5, 14], [1, 4, 6], - [5, 7, 15], [6, 8, 17], [1, 7, 9], [8, 10, 18], [2, 9, 11], - [10, 12, 19],[2, 11, 13],[12, 14, 20], [4, 13, 15], [6, 14, 16], - [15, 17, 20],[7, 16, 18], [9, 17, 19], [11, 18, 20], [13, 16, 19] -] - -struct Game_State: - var winloss_state: Int - var player_location: Int - var wumpus_location: Int - var pit_locations: Tuple[Int, Int] - var bat_locations: Tuple[Int, Int] - var arrows_remaining: Int - - fn __init__(out self): - var all_locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] - shuffle(all_locations) - - self.winloss_state = 0 - self.player_location = all_locations[0] - self.wumpus_location = all_locations[1] - self.pit_locations = (all_locations[2], all_locations[3]) - self.bat_locations = (all_locations[4], all_locations[5]) - self.arrows_remaining = 5 - - fn __copyinit__(out self, other: Self): - self.winloss_state = other.winloss_state - self.player_location = other.player_location - self.wumpus_location = other.wumpus_location - self.pit_locations = other.pit_locations - self.bat_locations = other.bat_locations - self.arrows_remaining = other.arrows_remaining - -fn print_instructions() -> None: - print("WELCOME TO 'HUNT THE WUMPUS'") - print(" THE WUMPUS LIVES IN A CAVE OF 20 ROOMS. EACH ROOM") - print("HAS 3 TUNNELS LEADING TO OTHER ROOMS. (LOOK AT A") - print("DODECAHEDRON TO SEE HOW THIS WORKS-IF YOU DON'T KNOW") - print("WHAT A DODECAHEDRON IS, ASK SOMEONE)\n") - print(" HAZARDS:") - print(" BOTTOMLESS PITS - TWO ROOMS HAVE BOTTOMLESS PITS IN THEM") - print(" IF YOU GO THERE, YOU FALL INTO THE PIT (& LOSE!)") - print(" SUPER BATS - TWO OTHER ROOMS HAVE SUPER BATS. IF YOU") - print(" GO THERE, A BAT GRABS YOU AND TAKES YOU TO SOME OTHER") - print(" ROOM AT RANDOM. (WHICH MIGHT BE TROUBLESOME)\n") - print(" WUMPUS:") - print(" THE WUMPUS IS NOT BOTHERED BY THE HAZARDS (HE HAS SUCKER") - print(" FEET AND IS TOO BIG FOR A BAT TO LIFT). USUALLY") - print(" HE IS ASLEEP. TWO THINGS WAKE HIM UP: YOUR ENTERING") - print(" HIS ROOM OR YOUR SHOOTING AN ARROW.") - print(" IF THE WUMPUS WAKES, HE MOVES (P=.75) ONE ROOM") - print(" OR STAYS STILL (P=.25). AFTER THAT, IF HE IS WHERE YOU") - print(" ARE, HE EATS YOU UP (& YOU LOSE!)\n") - print(" YOU:") - print(" EACH TURN YOU MAY MOVE OR SHOOT A CROOKED ARROW") - print(" MOVING: YOU CAN GO ONE ROOM (THRU ONE TUNNEL)") - print(" ARROWS: YOU HAVE 5 ARROWS. YOU LOSE WHEN YOU RUN OUT.") - print(" EACH ARROW CAN GO FROM 1 TO 5 ROOMS. YOU AIM BY TELLING") - print(" THE COMPUTER THE ROOM#S YOU WANT THE ARROW TO GO TO.") - print(" IF THE ARROW CAN'T GO THAT WAY (IE NO TUNNEL) IT MOVES") - print(" AT RAMDOM TO THE NEXT ROOM.") - print(" IF THE ARROW HITS THE WUMPUS, YOU WIN.") - print(" IF THE ARROW HITS YOU, YOU LOSE.\n") - print(" WARNINGS:") - print(" WHEN YOU ARE ONE ROOM AWAY FROM WUMPUS OR HAZARD,") - print(" THE COMPUTER SAYS:") - print(" WUMPUS- 'I SMELL A WUMPUS'") - print(" BAT - 'BATS NEARBY'") - print(" PIT - 'I FEEL A DRAFT'\n") - return None - -fn print_location(game_state: Game_State) -> None: - if game_state.wumpus_location in adjacent_rooms[game_state.player_location]: - print("I SMELL A WUMPUS!") - if game_state.pit_locations[0] in adjacent_rooms[game_state.player_location] or game_state.pit_locations[1] in adjacent_rooms[game_state.player_location]: - print("I FEEL A DRAFT") - if game_state.bat_locations[0] in adjacent_rooms[game_state.player_location] or game_state.bat_locations[1] in adjacent_rooms[game_state.player_location]: - print("BATS NEARBY!") - print("YOU ARE IN ROOM", game_state.player_location) - print("TUNNELS LEAD TO", adjacent_rooms[game_state.player_location][0], adjacent_rooms[game_state.player_location][1], adjacent_rooms[game_state.player_location][2]) - return None - -fn move_wumpus(mut game_state: Game_State) -> Bool: - if random_ui64(0,3) != 3: - game_state.wumpus_location = adjacent_rooms[game_state.wumpus_location][random_ui64(0,2)] - if game_state.wumpus_location == game_state.player_location: - print("TSK TSK TSK- WUMPUS GOT YOU!") - game_state.winloss_state = -1 - return True - return False - -def shoot_action(mut game_state: Game_State) -> None: - while True: - distance = Int(input("NO. OF ROOMS(1-5)")) - if distance >= 1 and distance <= 5: - break - path: List[Int] = [] - for i in range(distance): - while True: - fork = Int(input("ROOM #")) - if i <= 1: - break - elif fork != path[-2]: - break - else: - print("ARROWS AREN'T THAT CROOKED - TRY ANOTHER ROOM") - pass - path.append(fork) - arrow_location = game_state.player_location - for i in range(distance): - if path[i] in adjacent_rooms[arrow_location]: - arrow_location = path[i] - else: - arrow_location = adjacent_rooms[arrow_location][random_ui64(0, 2)] - if arrow_location == game_state.wumpus_location: - print("AHA! YOU GOT THE WUMPUS!") - game_state.winloss_state = 1 - return - elif arrow_location == game_state.player_location: - print("OUCH! ARROW GOT YOU!") - game_state.winloss_state = -1 - return - print("MISSED") - if move_wumpus(game_state): - return - game_state.arrows_remaining -= 1 - if game_state.arrows_remaining == 0: - game_state.winloss_state = -1 - return - -def move_action(mut game_state: Game_State) -> None: - while True: - next_room = Int(input("WHERE TO")) - if next_room < 1 or next_room > 20: - pass - if next_room in adjacent_rooms[game_state.player_location]: - game_state.player_location = next_room - break - if next_room == game_state.player_location: - break - print("NOT POSSIBLE -") - if game_state.player_location == game_state.wumpus_location: - print("...OOPS! BUMPED A WUMPUS!") - if move_wumpus(game_state): - return - if game_state.player_location == game_state.pit_locations[0] or game_state.player_location == game_state.pit_locations[1]: - print("YYYIIIIEEEE . . . FELL IN PIT") - game_state.winloss_state = -1 - return - if game_state.player_location == game_state.bat_locations[0] or game_state.player_location == game_state.bat_locations[1]: - print("ZAP--SUPER BAT SNATCH! ELSEWHEREVILLE FOR YOU!") - move_action(game_state, Int(random_ui64(1, 20))) - return - -fn move_action(mut game_state: Game_State, room_number: Int) -> None: - game_state.player_location = room_number - if game_state.player_location == game_state.wumpus_location: - print("...OOPS! BUMPED A WUMPUS!") - if move_wumpus(game_state): - return - if game_state.player_location == game_state.pit_locations[0] or game_state.player_location == game_state.pit_locations[1]: - print("YYYIIIIEEEE . . . FELL IN PIT") - game_state.winloss_state = -1 - return - if game_state.player_location == game_state.bat_locations[0] or game_state.player_location == game_state.bat_locations[1]: - print("ZAP--SUPER BAT SNATCH! ELSEWHEREVILLE FOR YOU!") - move_action(game_state, Int(random_ui64(1, 20))) - return - -def main(): - seed() - instruct_cond = input("INSTRUCTIONS (Y-N)") - if instruct_cond != 'N': - print_instructions() - - game_state = Game_State() - saved_state = game_state - - game_is_running = True - while game_is_running: - print("HUNT THE WUMPUS\n") - print_location(game_state) - action = input("SHOOT OR MOVE (S-M)") - - if action == 'S': - shoot_action(game_state) - elif action == 'M': - move_action(game_state) - if game_state.winloss_state == -1: - print("HA HA HA - YOU LOSE!") - elif game_state.winloss_state == 1: - print("HEE HEE HEE - THE WUMPUS'LL GETCHA NEXT TIME!!") - if game_state.winloss_state != 0: - state_update = input("SAME SET-UP (Y-N)") - if state_update == 'Y': - game_state = saved_state - else: - game_state = Game_State() - saved_state = game_state diff --git a/Task/Hunt-the-Wumpus/Quackery/hunt-the-wumpus.quackery b/Task/Hunt-the-Wumpus/Quackery/hunt-the-wumpus.quackery deleted file mode 100644 index 831dc08b10..0000000000 --- a/Task/Hunt-the-Wumpus/Quackery/hunt-the-wumpus.quackery +++ /dev/null @@ -1,138 +0,0 @@ - [ table - [ 1 4 7 ] [ 0 2 9 ] [ 1 3 11 ] [ 2 4 13 ] - [ 0 3 5 ] [ 4 6 14 ] [ 5 7 16 ] [ 0 6 8 ] - [ 7 9 17 ] [ 1 8 10 ] [ 9 11 18 ] [ 2 10 12 ] - [ 11 13 19 ] [ 3 12 14 ] [ 5 13 15 ] [ 14 16 19 ] - [ 6 15 17 ] [ 8 16 18 ] [ 10 17 19 ] [ 12 15 18 ] ] is adjacent ( n --> [ ) - - [ stack ] is player ( --> s ) - [ stack ] is arrows ( --> s ) - [ stack ] is wumpus ( --> s ) - [ stack ] is bat1 ( --> s ) - [ stack ] is bat2 ( --> s ) - [ stack ] is pit1 ( --> s ) - [ stack ] is pit2 ( --> s ) - - [ over find swap found ] is has ( [ n --> b ) - - [ dup dup size random peek join ] is addrand ( [ --> [ ) - - [ trim reverse trim reverse - $->n not if [ drop -1 ] ] is validate ( $ --> n ) - - [ say "A giant bat transports you to chamber " - 20 random dup echo say "." cr - player replace - 20 random swap replace ] is relocate ( s --> ) - - [ player share - dup bat1 share = iff - [ drop bat1 relocate ] again - dup bat2 share = iff - [ drop bat2 relocate ] again - dup pit1 share = - over pit2 share = or iff - [ say "You fell into a bottomless pit." - drop false ] - done - dup wumpus share = iff - [ say "The Wumpus eats you." drop false ] - done - say "You are in chamber " dup echo say "." cr - say "Adjacent chambers are: " - adjacent dup witheach - [ echo i 0 = iff [ say "." cr ] - else - [ say ", " - i 1 = if [ say "and " ] ] ] - say "You have " arrows share echo say " arrows." cr - dup wumpus share has if - [ say "You smell something terrible nearby." cr ] - dup bat1 share has - over bat2 share has or if - [ say "You hear a rustling." cr ] - dup pit1 share has - swap pit2 share has or if - [ say "You feel a cold wind " - say "blowing from a nearby chamber." cr ] - true ] is report ( --> b ) - - [ $ "Move to which chamber? " input validate - player share adjacent - dup addrand unrot find - peek player put true ] is move ( --> b ) - - [ true - $ "Shoot into which chambers? " input nest$ - dup [] = if [ drop ' [ [ -1 ] ] ] - player share swap witheach - [ $->n not if [ drop -1 ] - swap adjacent - dup addrand unrot find peek - say "The arrow enters chamber " - dup echo say "." cr - dup player share = iff - [ say "You shot yourself." cr - dip not conclude ] - done - dup wumpus share = iff - [ say "You shot the Wumpus." cr - dip not conclude ] - done ] - drop dup while - say "You did not hit anything." cr - 4 random 0 != if - [ wumpus take adjacent - 3 random peek wumpus put ] - -1 arrows tally - arrows share 0 = if - [ say "You have run out of arrows." cr not ] ] is shoot ( --> b ) - - [ $ "Move or shoot? " input space join - 0 peek upper dup char M = iff [ drop move ] done - char S = iff shoot done - again ] is action ( b --> b ) - - [ cr - say "Your mission is to anaesthetise an ailing " - say "Wumpus so that it can be healed." cr - say "It is in a dodecahedral labyrinth " - say "that is fraught with dangers." cr - say "The labyrinth has 20 chambers numbered 0 to " - say "19 which are connected by tunnels." cr cr - say "- The Wumpus will eat you if it sees you." cr - say "- Two of the chambers are bottomless pits." cr - say "- There are two giant bats that will " - say "transport you to a random chamber." cr cr - say "You can smell the Wumpus from an adjoining " - say "chamber. It smells terrible." cr - say "When you are in a chamber next to a bottomless " - say "pit you can feel a cold wind." cr - say "You can hear the giant bats rustle from a " - say "chamber away." cr cr - say "You are equipped with five progammable arrows." cr - say "They can be programmed with up to five " - say "adjoining chambers." cr - say "If a destination is invalid the arrow will move " - say "to a random adjoining chamber." cr cr - say "Be careful! Do not shoot yourself. Wumpus " - say "anasthetic is lethal to humans." cr - say "If you miss the Wumpus it will probably wake " - say "and move to an adjoining chamber." cr cr ] is rules ( --> ) - - [ say "Hunt the Wumpus, the Quackery cut." cr cr - randomise - 5 arrows put - [] 20 times [ i join ] shuffle - ' [ player wumpus bat1 bat2 pit1 pit2 ] - witheach [ dip behead put ] - drop - $ "Would you like to see the rules? " input - space join 0 peek upper char Y = if rules - [ report while - action while - cr again ] - ' [ player arrows wumpus bat1 bat2 pit1 pit2 ] - witheach release ] is play ( --> ) - - play diff --git a/Task/Hunt-the-Wumpus/Wren/hunt-the-wumpus.wren b/Task/Hunt-the-Wumpus/Wren/hunt-the-wumpus.wren index f053916bea..ad665375ea 100644 --- a/Task/Hunt-the-Wumpus/Wren/hunt-the-wumpus.wren +++ b/Task/Hunt-the-Wumpus/Wren/hunt-the-wumpus.wren @@ -1,7 +1,7 @@ import "random" for Random -import "./fmt" for Fmt -import "./ioutil" for Input -import "./str" for Str +import "/fmt" for Fmt +import "/ioutil" for Input +import "/str" for Str var cave = { 1: [ 2, 3, 4], 2: [ 1, 5, 6], 3: [ 1, 7, 8], 4: [ 1, 9, 10], diff --git a/Task/I-before-E-except-after-C/00-TASK.txt b/Task/I-before-E-except-after-C/00-TASK.txt index 74e62f2023..b342d03475 100644 --- a/Task/I-before-E-except-after-C/00-TASK.txt +++ b/Task/I-before-E-except-after-C/00-TASK.txt @@ -3,7 +3,7 @@ widely known mnemonic which is supposed to help when spelling English words. ;Task: -Using the word list from   [https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt], +Using the word list from   [http://wiki.puzzlers.org/pub/wordlists/unixdict.txt http://wiki.puzzlers.org/pub/wordlists/unixdict.txt],
check if the two sub-clauses of the phrase are plausible individually: :::#   ''"I before E when not preceded by C"'' :::#   ''"E before I when preceded by C"'' diff --git a/Task/I-before-E-except-after-C/8080-Assembly/i-before-e-except-after-c.8080 b/Task/I-before-E-except-after-C/8080-Assembly/i-before-e-except-after-c.8080 index 75a59a9a6a..1b4b015117 100644 --- a/Task/I-before-E-except-after-C/8080-Assembly/i-before-e-except-after-c.8080 +++ b/Task/I-before-E-except-after-C/8080-Assembly/i-before-e-except-after-c.8080 @@ -1,207 +1,207 @@ - ;;; I before E, except after C -fcb1: equ 5Ch ; FCB 1 (populated by file on command line) -dma: equ 80h ; Standard DMA location -bdos: equ 5 ; CP/M entry point -puts: equ 9 ; CP/M call to write a string to the console -fopen: equ 0Fh ; CP/M call to open a file -fread: equ 14h ; CP/M call to read from a file -CR: equ 13 -LF: equ 10 -EOF: equ 26 - org 100h - ;;; Open the file given on the command line - lxi d,fcb1 - mvi c,fopen - call bdos - inr a ; FF = error - jz die - ;;; We can only read one 128-byte block at a time, and the file - ;;; will not fit in memory (max 64 k). So there are two things - ;;; going on here: we copy from the block into a word buffer - ;;; until we see the end of a line, at which point we process - ;;; the word. In the meantime, if while copying we reach the end - ;;; of the block, we read the next block. - lxi b,curwrd ; Word pointer -block: push b ; Keep word pointer while reading - lxi d,fcb1 ; Read a block from the file - mvi c,fread - call bdos - pop b ; Restore word pointer - dcr a ; 1 = EOF - jz done - inr a ; otherwise, <>0 = error - jnz die - lxi h,dma ; Start reading at DMA -char: mov a,m ; Get character - cpi EOF ; If it's an EOF character, we're done - jz done - stax b ; Store character in current word - inx b - cpi LF ; If it's LF, then we've got a full word - cz word ; Process the word - inr l ; Go to next character - jz block ; If we're done with this block, get next one - jmp char - ;;; When done, report the statistics -done: lxi d,scie ; CIE - call sout - lhld cie - call puthl - lxi d,sxie ; xIE - call sout - lhld xie - call puthl - lxi d,scei ; CEI - call sout - lhld cei - call puthl - lxi d,sxei ; xEI - call sout - lhld xei - call puthl - ;;; Then say what is and isn't plausible - lxi d,s_ienc ; I before E when not preceded by C - call sout ; plausible if 2*xIE>CIE - lhld cie - xchg - lhld xie - call pplaus - lxi d,s_eic ; E before I when preceded by C - call sout ; plausible if 2*CEI>xEI - lhld xei - xchg - lhld cei - ;;; If HL = amount of words with feature, and - ;;; DE = amount of words with opposit feature, then print - ;;; '(not) plausible', as appropriate. -pplaus: dad h ; 2 * feature - mov a,d ; Compare high byte - cmp h - jc plaus ; If 2*H>D then plausible - mov a,e ; Otherwise, compare low byte - cmp l - jc plaus ; If 2*L>E then plausible - lxi d,snop ; Otherwise, not plausible - jmp sout -plaus: lxi d,splau - jmp sout - ;;; Process a word -word: push h ; Save file read address - xra a ; Zero out end of word - stax b - dcx b - lxi h,curwrd ; Scan word -start: mov a,m ; Get current character - inx h ; Move pointer ahead - ana a ; If zero, - jz w_end ; we're done - cpi 'c' ; Did we find a 'c'? - jz findc - cpi 'e' ; Otherwise, did we find 'e'? - jz finde - cpi 'i' ; Otherwise, did we find 'i'? - jz findi - jmp start ; Otherwise, keep going - ;;; We found an 'e' -finde: mov a,m ; Get following character - cpi 'i' ; Is it 'i'? - jnz start ; If not, keep going - inx h ; Otherwise, move past it, - xchg ; keep pointer in DE, - lhld xie ; We found ie without c - inx h - shld xie - xchg - jmp start - ;;; We found an 'i' -findi: mov a,m ; Get following character - cpi 'e' ; Is it 'e'? - jnz start ; If not, keep going - inx h ; Otherwise, move past it, - xchg ; keep pointer in DE, - lhld xei ; We found ei without c - inx h - shld xei - xchg - jmp start - ;;; We found a 'c' -findc: mov a,m ; Get following character - cpi 'e' ; Is it 'e'? - jz findce ; Then we have 'ce' - cpi 'i' ; Is it 'i'? - jz findci ; Then we have 'ci' - jmp start ; Otherwise, just keep going -findce: mov d,h ; set DE = start of 'e?' - mov e,l - inx d ; Get next character - ldax d - cpi 'i' ; Is it 'i'? - jnz start ; If not, do nothing - lhld cei ; But if so, we found 'cei' - inx h ; Increment the counter - shld cei - xchg ; Keep scanning _after_ the 'cei' - inx h - jmp start -findci: mov d,h ; set DE = start of 'i?' - mov e,l - inx d ; Get next character - ldax d - cpi 'e' ; Is it 'e'? - jnz start ; If not, do nothing - lhld cie ; But if so, we found 'cie' - inx h ; Increment the counter - shld cie - xchg ; Keep scanning _after_ the 'cie' - inx h - jmp start -w_end: lxi b,curwrd ; Set word pointer to beginning - pop h ; Restore file read address - ret - ;;; Print error message and stop the program -die: lxi d,errmsg - mvi c,puts - call bdos - rst 0 - ;;; Print string -sout: mvi c,puts - jmp bdos - ;;; Print HL to the console as a decimal number -puthl: push h - lxi h,num - xthl - lxi b,-10 -dgt: lxi d,-1 -clcdgt: inx d - dad b - jc clcdgt - mov a,l - adi 10+'0' - xthl - dcx h - mov m,a - xthl - xchg - mov a,h - ora l - jnz dgt - pop d - mvi c,puts - jmp bdos -errmsg: db 'Error$' ; Good enough -s_ienc: db 'I before E when not preceded by C:$' -s_eic: db 'E before I when preceded by C:$' -snop: db ' not' -splau: db ' plausible',CR,LF,'$' -scie: db 'CIE: $' ; Report strings -sxie: db 'xIE: $' -scei: db 'CEI: $' -sxei: db 'xEI: $' - db '00000' -num: db CR,LF,'$' ; Space for number - ;;; Counters -xie: dw 0 ; I before E when not preceded by C -cie: dw 0 ; I before E when preceded by C -cei: dw 0 ; E before I when preceded by C -xei: dw 0 ; E before I when not preceded by C -curwrd: equ $ ; Current word stored here + ;;; I before E, except after C +fcb1: equ 5Ch ; FCB 1 (populated by file on command line) +dma: equ 80h ; Standard DMA location +bdos: equ 5 ; CP/M entry point +puts: equ 9 ; CP/M call to write a string to the console +fopen: equ 0Fh ; CP/M call to open a file +fread: equ 14h ; CP/M call to read from a file +CR: equ 13 +LF: equ 10 +EOF: equ 26 + org 100h + ;;; Open the file given on the command line + lxi d,fcb1 + mvi c,fopen + call bdos + inr a ; FF = error + jz die + ;;; We can only read one 128-byte block at a time, and the file + ;;; will not fit in memory (max 64 k). So there are two things + ;;; going on here: we copy from the block into a word buffer + ;;; until we see the end of a line, at which point we process + ;;; the word. In the meantime, if while copying we reach the end + ;;; of the block, we read the next block. + lxi b,curwrd ; Word pointer +block: push b ; Keep word pointer while reading + lxi d,fcb1 ; Read a block from the file + mvi c,fread + call bdos + pop b ; Restore word pointer + dcr a ; 1 = EOF + jz done + inr a ; otherwise, <>0 = error + jnz die + lxi h,dma ; Start reading at DMA +char: mov a,m ; Get character + cpi EOF ; If it's an EOF character, we're done + jz done + stax b ; Store character in current word + inx b + cpi LF ; If it's LF, then we've got a full word + cz word ; Process the word + inr l ; Go to next character + jz block ; If we're done with this block, get next one + jmp char + ;;; When done, report the statistics +done: lxi d,scie ; CIE + call sout + lhld cie + call puthl + lxi d,sxie ; xIE + call sout + lhld xie + call puthl + lxi d,scei ; CEI + call sout + lhld cei + call puthl + lxi d,sxei ; xEI + call sout + lhld xei + call puthl + ;;; Then say what is and isn't plausible + lxi d,s_ienc ; I before E when not preceded by C + call sout ; plausible if 2*xIE>CIE + lhld cie + xchg + lhld xie + call pplaus + lxi d,s_eic ; E before I when preceded by C + call sout ; plausible if 2*CEI>xEI + lhld xei + xchg + lhld cei + ;;; If HL = amount of words with feature, and + ;;; DE = amount of words with opposit feature, then print + ;;; '(not) plausible', as appropriate. +pplaus: dad h ; 2 * feature + mov a,d ; Compare high byte + cmp h + jc plaus ; If 2*H>D then plausible + mov a,e ; Otherwise, compare low byte + cmp l + jc plaus ; If 2*L>E then plausible + lxi d,snop ; Otherwise, not plausible + jmp sout +plaus: lxi d,splau + jmp sout + ;;; Process a word +word: push h ; Save file read address + xra a ; Zero out end of word + stax b + dcx b + lxi h,curwrd ; Scan word +start: mov a,m ; Get current character + inx h ; Move pointer ahead + ana a ; If zero, + jz w_end ; we're done + cpi 'c' ; Did we find a 'c'? + jz findc + cpi 'e' ; Otherwise, did we find 'e'? + jz finde + cpi 'i' ; Otherwise, did we find 'i'? + jz findi + jmp start ; Otherwise, keep going + ;;; We found an 'e' +finde: mov a,m ; Get following character + cpi 'i' ; Is it 'i'? + jnz start ; If not, keep going + inx h ; Otherwise, move past it, + xchg ; keep pointer in DE, + lhld xie ; We found ie without c + inx h + shld xie + xchg + jmp start + ;;; We found an 'i' +findi: mov a,m ; Get following character + cpi 'e' ; Is it 'e'? + jnz start ; If not, keep going + inx h ; Otherwise, move past it, + xchg ; keep pointer in DE, + lhld xei ; We found ei without c + inx h + shld xei + xchg + jmp start + ;;; We found a 'c' +findc: mov a,m ; Get following character + cpi 'e' ; Is it 'e'? + jz findce ; Then we have 'ce' + cpi 'i' ; Is it 'i'? + jz findci ; Then we have 'ci' + jmp start ; Otherwise, just keep going +findce: mov d,h ; set DE = start of 'e?' + mov e,l + inx d ; Get next character + ldax d + cpi 'i' ; Is it 'i'? + jnz start ; If not, do nothing + lhld cei ; But if so, we found 'cei' + inx h ; Increment the counter + shld cei + xchg ; Keep scanning _after_ the 'cei' + inx h + jmp start +findci: mov d,h ; set DE = start of 'i?' + mov e,l + inx d ; Get next character + ldax d + cpi 'e' ; Is it 'e'? + jnz start ; If not, do nothing + lhld cie ; But if so, we found 'cie' + inx h ; Increment the counter + shld cie + xchg ; Keep scanning _after_ the 'cie' + inx h + jmp start +w_end: lxi b,curwrd ; Set word pointer to beginning + pop h ; Restore file read address + ret + ;;; Print error message and stop the program +die: lxi d,errmsg + mvi c,puts + call bdos + rst 0 + ;;; Print string +sout: mvi c,puts + jmp bdos + ;;; Print HL to the console as a decimal number +puthl: push h + lxi h,num + xthl + lxi b,-10 +dgt: lxi d,-1 +clcdgt: inx d + dad b + jc clcdgt + mov a,l + adi 10+'0' + xthl + dcx h + mov m,a + xthl + xchg + mov a,h + ora l + jnz dgt + pop d + mvi c,puts + jmp bdos +errmsg: db 'Error$' ; Good enough +s_ienc: db 'I before E when not preceded by C:$' +s_eic: db 'E before I when preceded by C:$' +snop: db ' not' +splau: db ' plausible',CR,LF,'$' +scie: db 'CIE: $' ; Report strings +sxie: db 'xIE: $' +scei: db 'CEI: $' +sxei: db 'xEI: $' + db '00000' +num: db CR,LF,'$' ; Space for number + ;;; Counters +xie: dw 0 ; I before E when not preceded by C +cie: dw 0 ; I before E when preceded by C +cei: dw 0 ; E before I when preceded by C +xei: dw 0 ; E before I when not preceded by C +curwrd: equ $ ; Current word stored here diff --git a/Task/I-before-E-except-after-C/ALGOL-68/i-before-e-except-after-c.alg b/Task/I-before-E-except-after-C/ALGOL-68/i-before-e-except-after-c.alg index e67eb3f84b..3193288160 100644 --- a/Task/I-before-E-except-after-C/ALGOL-68/i-before-e-except-after-c.alg +++ b/Task/I-before-E-except-after-C/ALGOL-68/i-before-e-except-after-c.alg @@ -1,67 +1,80 @@ -BEGIN # use unixdict.txt to test the plausibility of # - # "i before e except after c" # +# tests the plausibility of "i before e except after c" using unixdict.txt # - PR read "files.incl.a68" PR # include file utilities # +# implements the plausibility test specified by the task # +# returns TRUE if with > 2 * without # +PROC plausible = ( INT with, without )BOOL: with > 2 * without; - # implements the plausibility test specified by the task # - # returns TRUE if with > 2 * without # - PROC plausible = ( INT with, without )BOOL: with > 2 * without; - - # shows the plausibility of with and without # - PROC show plausibility = ( STRING legend, INT with, without )VOID: - print( ( legend, " is ", IF plausible( with, without ) THEN "" ELSE "not " FI - , "plausible", newline - ) - ); +# shows the plausibility of with and without # +PROC show plausibility = ( STRING legend, INT with, without )VOID: + print( ( legend, IF plausible( with, without ) THEN " is plausible" ELSE " is not plausible" FI, newline ) ); +IF FILE input file; + STRING file name = "unixdict.txt"; + open( input file, file name, stand in channel ) /= 0 +THEN + # failed to open the file # + print( ( "Unable to open """ + file name + """", newline ) ) +ELSE + # file opened OK # + BOOL at eof := FALSE; + # set the EOF handler for the file # + on logical file end( input file, ( REF FILE f )BOOL: + BEGIN + # note that we reached EOF on the # + # latest read # + at eof := TRUE; + # return TRUE so processing can continue # + TRUE + END + ); INT cei := 0; INT xei := 0; INT cie := 0; INT xie := 0; - - # examines word for cie, xie (x /= c), cei and xei (x /= c) # - PROC test i before e = ( STRING word )VOID: - IF word = "ie" THEN + WHILE STRING word; + get( input file, ( word, newline ) ); + NOT at eof + DO + # examine the word for cie, xie (x /= c), cei and xei (x /= c) # + FOR pos FROM LWB word TO UPB word DO word[ pos ] := to lower( word[ pos ] ) OD; + IF word = "ie" THEN xie +:= 1 - ELIF word = "ei" THEN + ELIF word = "ei" THEN xei +:= 1 - ELSE + ELSE INT length = ( UPB word - LWB word ) + 1; IF length > 1 THEN IF word[ LWB word ] = "i" AND word[ LWB word + 1 ] = "e" THEN - # word starts ie # + # word starts ie # xie +:= 1 ELIF word[ LWB word ] = "e" AND word[ LWB word + 1 ] = "i" THEN - # word starts ei # + # word starts ei # xei +:= 1 FI; FOR pos FROM LWB word + 1 TO UPB word - 1 DO IF word[ pos ] = "i" AND word[ pos + 1 ] = "e" THEN - # have i before e, check the preceeding character # + # have i before e, check the preceeding character # IF word[ pos - 1 ] = "c" THEN cie ELSE xie FI +:= 1 ELIF word[ pos ] = "e" AND word[ pos + 1 ] = "i" THEN - # have e before i, check the preceeding character # + # have e before i, check the preceeding character # IF word[ pos - 1 ] = "c" THEN cei ELSE xei FI +:= 1 FI OD FI - FI # test i before e # ; + FI + OD; + # close the file # + close( input file ); # test the hypothesis # - - IF "unixdict.txt" EACHLINE test i before e < 0 THEN - print( ( "Unable to open unixdict.txt", newline ) ) - ELSE - print( ( "cie occurances: ", whole( cie, 0 ), newline ) ); - print( ( "xie occurances: ", whole( xie, 0 ), newline ) ); - print( ( "cei occurances: ", whole( cei, 0 ), newline ) ); - print( ( "xei occurances: ", whole( xei, 0 ), newline ) ); - show plausibility( "i before e except after c", xie, cie ); - show plausibility( "e before i except after c", xei, cei ); - show plausibility( "i before e when after c", cie, xie ); - show plausibility( "e before i when after c", cei, xei ); - show plausibility( "i before e in general", xie + cie, xei + cei ); - show plausibility( "e before i in general", xei + cei, xie + cie ) - FI - -END + print( ( "cie occurances: ", whole( cie, 0 ), newline ) ); + print( ( "xie occurances: ", whole( xie, 0 ), newline ) ); + print( ( "cei occurances: ", whole( cei, 0 ), newline ) ); + print( ( "xei occurances: ", whole( xei, 0 ), newline ) ); + show plausibility( "i before e except after c", xie, cie ); + show plausibility( "e before i except after c", xei, cei ); + show plausibility( "i before e when after c", cie, xie ); + show plausibility( "e before i when after c", cei, xei ); + show plausibility( "i before e in general", xie + cie, xei + cei ); + show plausibility( "e before i in general", xei + cei, xie + cie ) +FI diff --git a/Task/I-before-E-except-after-C/AWK/i-before-e-except-after-c.awk b/Task/I-before-E-except-after-C/AWK/i-before-e-except-after-c.awk index 0d1c85ae20..a9ab9fde37 100644 --- a/Task/I-before-E-except-after-C/AWK/i-before-e-except-after-c.awk +++ b/Task/I-before-E-except-after-C/AWK/i-before-e-except-after-c.awk @@ -7,20 +7,20 @@ /cie/ {cie+=cnt($3)} function cnt(c) { - if (c<1) return 1; - return c; + if (c<1) return 1; + return c; } END { - printf("cie: %i\nnie: %i\ncei: %i\nnei: %i\n",cie,nie-cie,cei,nei-cei); - v = v2 = ""; - if (nie < 3 * cie) { - v =" not"; - } - print "I before E when not preceded by C: is"v" plausible"; - if (nei > 3 * cei) { - v = v2 =" not"; - } - print "E before I when preceded by C: is"v2" plausible"; + printf("cie: %i\nnie: %i\ncei: %i\nnei: %i\n",cie,nie-cie,cei,nei-cei); + v = v2 = ""; + if (nie < 3 * cie) { + v =" not"; + } + print "I before E when not preceded by C: is"v" plausible"; + if (nei > 3 * cei) { + v = v2 =" not"; + } + print "E before I when preceded by C: is"v2" plausible"; print "Overall rule is"v" plausible"; } diff --git a/Task/I-before-E-except-after-C/AutoHotkey/i-before-e-except-after-c.ahk b/Task/I-before-E-except-after-C/AutoHotkey/i-before-e-except-after-c.ahk index a0ee96da0f..a9fc81bf1f 100644 --- a/Task/I-before-E-except-after-C/AutoHotkey/i-before-e-except-after-c.ahk +++ b/Task/I-before-E-except-after-C/AutoHotkey/i-before-e-except-after-c.ahk @@ -1,4 +1,4 @@ -WordList := URL_ToVar("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") +WordList := URL_ToVar("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") WordList := RegExReplace(WordList, "i)cie", "", cieN) WordList := RegExReplace(WordList, "i)cei", "", ceiN) RegExReplace(WordList, "i)ie", "", ieN) diff --git a/Task/I-before-E-except-after-C/BASIC256/i-before-e-except-after-c.basic b/Task/I-before-E-except-after-C/BASIC256/i-before-e-except-after-c.basic index 0a47a1548e..c2e1212f95 100644 --- a/Task/I-before-E-except-after-C/BASIC256/i-before-e-except-after-c.basic +++ b/Task/I-before-E-except-after-C/BASIC256/i-before-e-except-after-c.basic @@ -2,13 +2,13 @@ CI = 0 : XI = 0 : CE = 0 : XE = 0 open 1, "unixdict.txt" do - pal$ = readline (1) - if instr(pal$, "ie") then - if instr(pal$, "cie") then CI += 1 else XI += 1 - endif - if instr(pal$, "ei") then - if instr(pal$, "cei") then CE += 1 else XE += 1 - endif + pal$ = readline (1) + if instr(pal$, "ie") then + if instr(pal$, "cie") then CI += 1 else XI += 1 + endif + if instr(pal$, "ei") then + if instr(pal$, "cei") then CE += 1 else XE += 1 + endif until eof(1) close 1 diff --git a/Task/I-before-E-except-after-C/BBC-BASIC/i-before-e-except-after-c.basic b/Task/I-before-E-except-after-C/BBC-BASIC/i-before-e-except-after-c.basic deleted file mode 100644 index dbef67d8e6..0000000000 --- a/Task/I-before-E-except-after-C/BBC-BASIC/i-before-e-except-after-c.basic +++ /dev/null @@ -1,39 +0,0 @@ - F%=OPENIN"unixdict.txt" - IF F% == 0 ERROR 100, "unixdict not found!" - - CI=0 : XI=0 : CE=0 : XE=0 - WHILE NOT EOF#F% - Line$=GET$#F% - - P%=INSTR(Line$, "ie") - WHILE P% - IF MID$(Line$, P% - 1, 1) == "c" CI+=1 ELSE XI+=1 - P%=INSTR(Line$, "ie", P% + 1) - ENDWHILE - - P%=INSTR(Line$, "ei") - WHILE P% - IF MID$(Line$, P% - 1, 1) == "c" CE+=1 ELSE XE+=1 - P%=INSTR(Line$, "ei", P% + 1) - ENDWHILE - ENDWHILE - CLOSE#F% - - PRINT "Instances of 'ie', proceeded by a 'c' = ";CI - PRINT "Instances of 'ie', NOT proceeded by a 'c' = ";XI - P1%=XI * 2 > CI - PRINT "Therefore 'I before E when not preceded by C' is" FNTest(P1%) - PRINT - - PRINT "Instances of 'ei', proceeded by a 'c' = ";CE - PRINT "Instances of 'ei', NOT proceeded by a 'c' = ";XE - P2%=CE * 2 > XE - PRINT "Therefore 'E before I when preceded by C' is" FNTest(P2%) - PRINT - - IF P1% AND P2% PRINT "B"; ELSE PRINT "Not b"; - PRINT "oth sub-phrases are plausible, therefore the phrase " +\ - \ "'I before E, except after C' can be said to be" FNTest(P1% AND P2%) "!" - END - - DEF FNTest(plausible%)=MID$(" not plausible", 1 - 4 * plausible%) diff --git a/Task/I-before-E-except-after-C/BQN/i-before-e-except-after-c.bqn b/Task/I-before-E-except-after-C/BQN/i-before-e-except-after-c.bqn deleted file mode 100644 index dbbec600b8..0000000000 --- a/Task/I-before-E-except-after-C/BQN/i-before-e-except-after-c.bqn +++ /dev/null @@ -1,15 +0,0 @@ -Func ← { - Filter ← {+´(∨´∘(𝕨⊸⍷))¨𝕩} - nei ← "ei" Filter 𝕩 - cei ← "cei" Filter 𝕩 - nie ← "ie" Filter 𝕩 - cie ← "cie" Filter 𝕩 - •Show (nie < 2×cie)◶⟨ - "I before E when not preceded by C is plausible" - "I before E when not preceded by C is not plausible" - ⟩@ - (nei > 2×cei)◶⟨ - "E before I when preceded by C is plausible" - "E before I when preceded by C is not plausible" - ⟩@ -} diff --git a/Task/I-before-E-except-after-C/Batch-File/i-before-e-except-after-c-1.bat b/Task/I-before-E-except-after-C/Batch-File/i-before-e-except-after-c-1.bat index 6a0a353d2b..1962c47d0e 100644 --- a/Task/I-before-E-except-after-C/Batch-File/i-before-e-except-after-c-1.bat +++ b/Task/I-before-E-except-after-C/Batch-File/i-before-e-except-after-c-1.bat @@ -3,7 +3,7 @@ @echo off setlocal enabledelayedexpansion - ::Initialization + ::Initialization set ie=0 set ei=0 set cie=0 @@ -13,13 +13,13 @@ set propos1=FALSE set propos2=FALSE set propos3=FALSE - ::Do the matching + ::Do the matching for /f %%X in (unixdict.txt) do ( - set word=%%X - if not "!word:ie=!"=="!word!" if "!word:cie=!"=="!word!" (set /a ie+=1) - if not "!word:ei=!"=="!word!" if "!word:cei=!"=="!word!" (set /a ei+=1) - if not "!word:cei=!"=="!word!" (set /a cei+=1) - if not "!word:cie=!"=="!word!" (set /a cie+=1) + set word=%%X + if not "!word:ie=!"=="!word!" if "!word:cie=!"=="!word!" (set /a ie+=1) + if not "!word:ei=!"=="!word!" if "!word:cei=!"=="!word!" (set /a ei+=1) + if not "!word:cei=!"=="!word!" (set /a cei+=1) + if not "!word:cie=!"=="!word!" (set /a cie+=1) ) set /a "counter1=!ei!*2,counter2=!cie!*2" diff --git a/Task/I-before-E-except-after-C/Clojure/i-before-e-except-after-c.clj b/Task/I-before-E-except-after-C/Clojure/i-before-e-except-after-c.clj index 9d895b2b68..73fef20309 100644 --- a/Task/I-before-E-except-after-C/Clojure/i-before-e-except-after-c.clj +++ b/Task/I-before-E-except-after-C/Clojure/i-before-e-except-after-c.clj @@ -47,7 +47,7 @@ format-line))) (defn -main [] - (with-open [rdr (clojure.java.io/reader "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")] + (with-open [rdr (clojure.java.io/reader "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")] (i-before-e-except-after-c-plausible? "Check unixdist list" (apply-freq-1 (line-seq rdr)))) (with-open [rdr (clojure.java.io/reader "http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt")] (i-before-e-except-after-c-plausible? "Word frequencies (stretch goal)" (map format-freq-line (drop 1 (line-seq rdr)))))) diff --git a/Task/I-before-E-except-after-C/Delphi/i-before-e-except-after-c.pas b/Task/I-before-E-except-after-C/Delphi/i-before-e-except-after-c.delphi similarity index 100% rename from Task/I-before-E-except-after-C/Delphi/i-before-e-except-after-c.pas rename to Task/I-before-E-except-after-C/Delphi/i-before-e-except-after-c.delphi diff --git a/Task/I-before-E-except-after-C/Ed/i-before-e-except-after-c-1.ed b/Task/I-before-E-except-after-C/Ed/i-before-e-except-after-c-1.ed deleted file mode 100644 index b8a34ecd14..0000000000 --- a/Task/I-before-E-except-after-C/Ed/i-before-e-except-after-c-1.ed +++ /dev/null @@ -1,32 +0,0 @@ -# i-before-e.ed -H -# Remove all the non-rule-related words -v/(ie|ei)/d -# Replace the occurences with one-letter markers -g/ei/s/.*/e/ -g/ie/s/.*/i/ -,j -# Remove 1 occurence of e (alternative) per two i (null) -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -s/eii//g -s/iie//g -# Check whether there are more i's in the output (null hypothesis true) or not -,p -Q diff --git a/Task/I-before-E-except-after-C/Ed/i-before-e-except-after-c-2.ed b/Task/I-before-E-except-after-C/Ed/i-before-e-except-after-c-2.ed deleted file mode 100644 index 44cdaeb3a9..0000000000 --- a/Task/I-before-E-except-after-C/Ed/i-before-e-except-after-c-2.ed +++ /dev/null @@ -1,35 +0,0 @@ -# e-before-i-with-c.ed -H -# Remove all the non-rule-related words -v/(cie|cei)/d -# Replace the occurences with one-letter markers -g/ei/s/.*/e/ -g/ie/s/.*/i/ -,j -# Remove 1 occurence of i (alternative) per two e (null) -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -s/eei// -s/iee// -# Check whether there are more e's in the output (null hypothesis true) or not -,p -Q diff --git a/Task/I-before-E-except-after-C/Elixir/i-before-e-except-after-c.ex b/Task/I-before-E-except-after-C/Elixir/i-before-e-except-after-c.elixir similarity index 100% rename from Task/I-before-E-except-after-C/Elixir/i-before-e-except-after-c.ex rename to Task/I-before-E-except-after-C/Elixir/i-before-e-except-after-c.elixir diff --git a/Task/I-before-E-except-after-C/F-Sharp/i-before-e-except-after-c.fs b/Task/I-before-E-except-after-C/F-Sharp/i-before-e-except-after-c.fs deleted file mode 100644 index 501506f0fb..0000000000 --- a/Task/I-before-E-except-after-C/F-Sharp/i-before-e-except-after-c.fs +++ /dev/null @@ -1,9 +0,0 @@ -// I before E except after C. Nigel Galloway: September 30th., 2024 -type plausibility=Plausible|Implausible -let fN n g=System.Text.RegularExpressions.Regex.Matches(n,g).Count -let fG n g=g|>Array.map2(fun n g->n+g)[|n("ie");n("ei");n("cie");n("cei")|] -let n=System.IO.File.ReadLines("unixdict.txt")|>Seq.fold(fun n g->fG (fN g) n)[|0;0;0;0|] -printfn($"I before E except after C is {if n[0]-n[2]>2*n[2] then Plausible else Implausible}") -printfn($"E before I except after C is {if n[1]-n[3]>2*n[3] then Plausible else Implausible}") -printfn($"I before E when after C is {if n[2]>2*n[3] then Plausible else Implausible}") -printfn($"E before I when after C is {if n[3]>2*n[2] then Plausible else Implausible}") diff --git a/Task/I-before-E-except-after-C/FutureBasic/i-before-e-except-after-c.basic b/Task/I-before-E-except-after-C/FutureBasic/i-before-e-except-after-c.basic index 86599ccbef..8e02afd17b 100644 --- a/Task/I-before-E-except-after-C/FutureBasic/i-before-e-except-after-c.basic +++ b/Task/I-before-E-except-after-C/FutureBasic/i-before-e-except-after-c.basic @@ -22,7 +22,7 @@ void local fn CheckWord( wrd as CFStringRef, txt as CFStringRef, c as ^long, x a end fn void local fn Doit - CFURLRef url = fn URLWithString( @"https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" ) + CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" ) CFStringRef string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL ) CFArrayRef words = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet ) long cei = 0, cie = 0, xei = 0, xie = 0 diff --git a/Task/I-before-E-except-after-C/Go/i-before-e-except-after-c.go b/Task/I-before-E-except-after-C/Go/i-before-e-except-after-c.go index 90b5c6c681..69374b52c6 100644 --- a/Task/I-before-E-except-after-C/Go/i-before-e-except-after-c.go +++ b/Task/I-before-E-except-after-C/Go/i-before-e-except-after-c.go @@ -1,68 +1,68 @@ package main import ( - "bufio" - "fmt" - "log" - "os" - "regexp" - "strings" + "bufio" + "fmt" + "log" + "os" + "regexp" + "strings" ) func main() { - f, err := os.Open("unixdict.txt") - if err != nil { - log.Fatalln(err) - } - defer f.Close() + f, err := os.Open("unixdict.txt") + if err != nil { + log.Fatalln(err) + } + defer f.Close() - s := bufio.NewScanner(f) - rie := regexp.MustCompile("^ie|[^c]ie") - rei := regexp.MustCompile("^ei|[^c]ei") - var cie, ie int - var cei, ei int - for s.Scan() { - line := s.Text() - if strings.Contains(line, "cie") { - cie++ - } - if strings.Contains(line, "cei") { - cei++ - } - if rie.MatchString(line) { - ie++ - } - if rei.MatchString(line) { - ei++ - } - } - err = s.Err() - if err != nil { - log.Fatalln(err) - } + s := bufio.NewScanner(f) + rie := regexp.MustCompile("^ie|[^c]ie") + rei := regexp.MustCompile("^ei|[^c]ei") + var cie, ie int + var cei, ei int + for s.Scan() { + line := s.Text() + if strings.Contains(line, "cie") { + cie++ + } + if strings.Contains(line, "cei") { + cei++ + } + if rie.MatchString(line) { + ie++ + } + if rei.MatchString(line) { + ei++ + } + } + err = s.Err() + if err != nil { + log.Fatalln(err) + } - if check(ie, ei, "I before E when not preceded by C") && - check(cei, cie, "E before I when preceded by C") { - fmt.Println("Both plausable.") - fmt.Println(`"I before E, except after C" is plausable.`) - } else { - fmt.Println("One or both implausable.") - fmt.Println(`"I before E, except after C" is implausable.`) - } + if check(ie, ei, "I before E when not preceded by C") && + check(cei, cie, "E before I when preceded by C") { + fmt.Println("Both plausable.") + fmt.Println(`"I before E, except after C" is plausable.`) + } else { + fmt.Println("One or both implausable.") + fmt.Println(`"I before E, except after C" is implausable.`) + } } // check checks if a statement is plausible. Something is plausible if a is more // than two times b. func check(a, b int, s string) bool { - switch { - case a > b*2: - fmt.Printf("%q is plausible (%d vs %d).\n", s, a, b) - return true - case a >= b: - fmt.Printf("%q is implausible (%d vs %d).\n", s, a, b) - default: - fmt.Printf("%q is implausible and contra-indicated (%d vs %d).\n", - s, a, b) - } - return false + switch { + case a > b*2: + fmt.Printf("%q is plausible (%d vs %d).\n", s, a, b) + return true + case a >= b: + fmt.Printf("%q is implausible (%d vs %d).\n", s, a, b) + default: + fmt.Printf("%q is implausible and contra-indicated (%d vs %d).\n", + s, a, b) + } + return false } diff --git a/Task/I-before-E-except-after-C/Haskell/i-before-e-except-after-c.hs b/Task/I-before-E-except-after-C/Haskell/i-before-e-except-after-c.hs index 120acd246d..a39c070d5a 100644 --- a/Task/I-before-E-except-after-C/Haskell/i-before-e-except-after-c.hs +++ b/Task/I-before-E-except-after-C/Haskell/i-before-e-except-after-c.hs @@ -6,7 +6,7 @@ getWordList :: IO String getWordList = do response <- simpleHTTP.getRequest$ url getResponseBody response - where url = "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" + where url = "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" main = do words <- getWordList diff --git a/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-1.icon b/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-1.icon index d7c5f7c825..088d2b2af3 100644 --- a/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-1.icon +++ b/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-1.icon @@ -1,4 +1,4 @@ -import Utils # To get the FindFirst class +import Utils # To get the FindFirst class procedure main(a) showCounts := "--showcounts" == !a diff --git a/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-2.icon b/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-2.icon index c3df84f390..2f669b47d1 100644 --- a/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-2.icon +++ b/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-2.icon @@ -1,4 +1,4 @@ -import Utils # To get the FindFirst class +import Utils # To get the FindFirst class procedure main(a) WS := " \t" diff --git a/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-2.java b/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-2.java index 5ccca284f7..83eba7931c 100644 --- a/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-2.java +++ b/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-2.java @@ -12,7 +12,7 @@ static int cei = 0; static int cie = 0; static void count() throws URISyntaxException, IOException { - URL url = new URI("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").toURL(); + URL url = new URI("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").toURL(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) { String line; while ((line = reader.readLine()) != null) { diff --git a/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-3.java b/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-3.java index 2af84999ac..f53d8476aa 100644 --- a/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-3.java +++ b/Task/I-before-E-except-after-C/Java/i-before-e-except-after-c-3.java @@ -3,56 +3,56 @@ import java.io.FileReader; public class IbeforeE { - public static void main(String[] args) - { - IbeforeE now=new IbeforeE(); - String wordlist="unixdict.txt"; - if(now.isPlausibleRule(wordlist)) - System.out.println("Rule is plausible."); - else - System.out.println("Rule is not plausible."); - } - boolean isPlausibleRule(String filename) - { - int truecount=0,falsecount=0; - try - { - BufferedReader br=new BufferedReader(new FileReader(filename)); - String word; - while((word=br.readLine())!=null) - { - if(isPlausibleWord(word)) - truecount++; - else if(isOppPlausibleWord(word)) - falsecount++; - } - br.close(); - } - catch(Exception e) - { - System.out.println("Something went horribly wrong: "+e.getMessage()); - } - - System.out.println("Plausible count: "+truecount); - System.out.println("Implausible count: "+falsecount); - if(truecount>2*falsecount) - return true; - return false; - } - boolean isPlausibleWord(String word) - { - if(!word.contains("c")&&word.contains("ie")) - return true; - else if(word.contains("cei")) - return true; - return false; - } - boolean isOppPlausibleWord(String word) - { - if(!word.contains("c")&&word.contains("ei")) - return true; - else if(word.contains("cie")) - return true; - return false; - } + public static void main(String[] args) + { + IbeforeE now=new IbeforeE(); + String wordlist="unixdict.txt"; + if(now.isPlausibleRule(wordlist)) + System.out.println("Rule is plausible."); + else + System.out.println("Rule is not plausible."); + } + boolean isPlausibleRule(String filename) + { + int truecount=0,falsecount=0; + try + { + BufferedReader br=new BufferedReader(new FileReader(filename)); + String word; + while((word=br.readLine())!=null) + { + if(isPlausibleWord(word)) + truecount++; + else if(isOppPlausibleWord(word)) + falsecount++; + } + br.close(); + } + catch(Exception e) + { + System.out.println("Something went horribly wrong: "+e.getMessage()); + } + + System.out.println("Plausible count: "+truecount); + System.out.println("Implausible count: "+falsecount); + if(truecount>2*falsecount) + return true; + return false; + } + boolean isPlausibleWord(String word) + { + if(!word.contains("c")&&word.contains("ie")) + return true; + else if(word.contains("cei")) + return true; + return false; + } + boolean isOppPlausibleWord(String word) + { + if(!word.contains("c")&&word.contains("ei")) + return true; + else if(word.contains("cie")) + return true; + return false; + } } diff --git a/Task/I-before-E-except-after-C/Julia/i-before-e-except-after-c.jl b/Task/I-before-E-except-after-C/Julia/i-before-e-except-after-c.julia similarity index 100% rename from Task/I-before-E-except-after-C/Julia/i-before-e-except-after-c.jl rename to Task/I-before-E-except-after-C/Julia/i-before-e-except-after-c.julia diff --git a/Task/I-before-E-except-after-C/Kotlin/i-before-e-except-after-c.kotlin b/Task/I-before-E-except-after-C/Kotlin/i-before-e-except-after-c.kotlin new file mode 100644 index 0000000000..b1cc1898fb --- /dev/null +++ b/Task/I-before-E-except-after-C/Kotlin/i-before-e-except-after-c.kotlin @@ -0,0 +1,61 @@ +// version 1.0.6 + +import java.net.URL +import java.io.InputStreamReader +import java.io.BufferedReader + +fun isPlausible(n1: Int, n2: Int) = n1 > 2 * n2 + +fun printResults(source: String, counts: IntArray) { + println("Results for $source") + println(" i before e except after c") + println(" for ${counts[0]}") + println(" against ${counts[1]}") + val plausible1 = isPlausible(counts[0], counts[1]) + println(" sub-rule is${if (plausible1) "" else " not"} plausible\n") + println(" e before i when preceded by c") + println(" for ${counts[2]}") + println(" against ${counts[3]}") + val plausible2 = isPlausible(counts[2], counts[3]) + println(" sub-rule is${if (plausible2) "" else " not"} plausible\n") + val plausible = plausible1 && plausible2 + println(" rule is${if (plausible) "" else " not"} plausible") +} + +fun main(args: Array) { + val url = URL("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") + val isr = InputStreamReader(url.openStream()) + val reader = BufferedReader(isr) + val regexes = arrayOf( + Regex("(^|[^c])ie"), // i before e when not preceded by c (includes words starting with ie) + Regex("(^|[^c])ei"), // e before i when not preceded by c (includes words starting with ei) + Regex("cei"), // e before i when preceded by c + Regex("cie") // i before e when preceded by c + ) + val counts = IntArray(4) // corresponding counts of occurrences + var word = reader.readLine() + while (word != null) { + for (i in 0..3) counts[i] += regexes[i].findAll(word).toList().size + word = reader.readLine() + } + reader.close() + printResults("unixdict.txt", counts) + + val url2 = URL("http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt") + val isr2 = InputStreamReader(url2.openStream()) + val reader2 = BufferedReader(isr2) + val counts2 = IntArray(4) + reader2.readLine() // read header line + var line = reader2.readLine() // read first line and store it + var words: List + val splitter = Regex("""(\t+|\s+)""") + while (line != null) { + words = line.split(splitter) + if (words.size == 4) // first element is empty + for (i in 0..3) counts2[i] += regexes[i].findAll(words[1]).toList().size * words[3].toInt() + line = reader2.readLine() + } + reader2.close() + println() + printResults("British National Corpus", counts2) +} diff --git a/Task/I-before-E-except-after-C/Kotlin/i-before-e-except-after-c.kts b/Task/I-before-E-except-after-C/Kotlin/i-before-e-except-after-c.kts deleted file mode 100644 index 038c8a089d..0000000000 --- a/Task/I-before-E-except-after-C/Kotlin/i-before-e-except-after-c.kts +++ /dev/null @@ -1,61 +0,0 @@ -// version 1.0.6 - -import java.net.URL -import java.io.InputStreamReader -import java.io.BufferedReader - -fun isPlausible(n1: Int, n2: Int) = n1 > 2 * n2 - -fun printResults(source: String, counts: IntArray) { - println("Results for $source") - println(" i before e except after c") - println(" for ${counts[0]}") - println(" against ${counts[1]}") - val plausible1 = isPlausible(counts[0], counts[1]) - println(" sub-rule is${if (plausible1) "" else " not"} plausible\n") - println(" e before i when preceded by c") - println(" for ${counts[2]}") - println(" against ${counts[3]}") - val plausible2 = isPlausible(counts[2], counts[3]) - println(" sub-rule is${if (plausible2) "" else " not"} plausible\n") - val plausible = plausible1 && plausible2 - println(" rule is${if (plausible) "" else " not"} plausible") -} - -fun main(args: Array) { - val url = URL("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") - val isr = InputStreamReader(url.openStream()) - val reader = BufferedReader(isr) - val regexes = arrayOf( - Regex("(^|[^c])ie"), // i before e when not preceded by c (includes words starting with ie) - Regex("(^|[^c])ei"), // e before i when not preceded by c (includes words starting with ei) - Regex("cei"), // e before i when preceded by c - Regex("cie") // i before e when preceded by c - ) - val counts = IntArray(4) // corresponding counts of occurrences - var word = reader.readLine() - while (word != null) { - for (i in 0..3) counts[i] += regexes[i].findAll(word).toList().size - word = reader.readLine() - } - reader.close() - printResults("unixdict.txt", counts) - - val url2 = URL("http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt") - val isr2 = InputStreamReader(url2.openStream()) - val reader2 = BufferedReader(isr2) - val counts2 = IntArray(4) - reader2.readLine() // read header line - var line = reader2.readLine() // read first line and store it - var words: List - val splitter = Regex("""(\t+|\s+)""") - while (line != null) { - words = line.split(splitter) - if (words.size == 4) // first element is empty - for (i in 0..3) counts2[i] += regexes[i].findAll(words[1]).toList().size * words[3].toInt() - line = reader2.readLine() - } - reader2.close() - println() - printResults("British National Corpus", counts2) -} diff --git a/Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur b/Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur deleted file mode 100644 index 77ef21052e..0000000000 --- a/Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur +++ /dev/null @@ -1,24 +0,0 @@ -val words = less(split(readfile("./data/unixdict.txt"), delim="\n"), of=1) - -val print = fn*(support number, against number) { - val ratio = support / against - writeln "{{support}} / {{against}} = {{ratio : r2}}:", (ratio < 2) * " NOT", " PLAUSIBLE" - return if(ratio >= 2: 1; 0) -} - -val ks = fw/ei cei ie cie/ -var cnt = {:} - -for w in words { - for k in ks { - cnt[k; 0] += if(k in w: 1; 0) - } -} - -val support = cnt'ie - cnt'cie -val against = cnt'ei - cnt'cei - -var result = print(support, against) -result += print(cnt'cei, cnt'cie) - -writeln "Overall:", (result < 2) * " NOT", " PLAUSIBLE\n" diff --git a/Task/I-before-E-except-after-C/Lasso/i-before-e-except-after-c.lasso b/Task/I-before-E-except-after-C/Lasso/i-before-e-except-after-c.lasso index 12f0b1464b..abf4c7e67f 100644 --- a/Task/I-before-E-except-after-C/Lasso/i-before-e-except-after-c.lasso +++ b/Task/I-before-E-except-after-C/Lasso/i-before-e-except-after-c.lasso @@ -3,7 +3,7 @@ local(cie,cei,ie,ei) = (:0,0,0,0) local(match_ie) = regExp(`[^c]ie`) local(match_ei) = regExp(`[^c]ei`) -with word in include_url(`https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt`)->asString->split("\n") +with word in include_url(`http://wiki.puzzlers.org/pub/wordlists/unixdict.txt`)->asString->split("\n") where #word >> `ie` or #word >> `ei` do { #word >> `cie` diff --git a/Task/I-before-E-except-after-C/Lua/i-before-e-except-after-c.lua b/Task/I-before-E-except-after-C/Lua/i-before-e-except-after-c.lua index 7c37aaeb8a..50509a26fa 100644 --- a/Task/I-before-E-except-after-C/Lua/i-before-e-except-after-c.lua +++ b/Task/I-before-E-except-after-C/Lua/i-before-e-except-after-c.lua @@ -22,7 +22,7 @@ function plaus (case, opposite, words) end -- Main procedure -local page = http.request("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") +local page = http.request("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") io.write("I before E when not preceded by C: ") local sub1 = plaus("[^c]ie", "cie", page) io.write("E before I when preceded by C: ") diff --git a/Task/I-before-E-except-after-C/MATLAB/i-before-e-except-after-c.m b/Task/I-before-E-except-after-C/MATLAB/i-before-e-except-after-c.m index 14c84de23a..e1d2657819 100644 --- a/Task/I-before-E-except-after-C/MATLAB/i-before-e-except-after-c.m +++ b/Task/I-before-E-except-after-C/MATLAB/i-before-e-except-after-c.m @@ -1,5 +1,5 @@ function iBeforeE() -check('https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'); +check('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'); fprintf('\n'); check('http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt'); end diff --git a/Task/I-before-E-except-after-C/Maple/i-before-e-except-after-c.maple b/Task/I-before-E-except-after-C/Maple/i-before-e-except-after-c.maple index 12d72b4118..8bf9b10be0 100644 --- a/Task/I-before-E-except-after-C/Maple/i-before-e-except-after-c.maple +++ b/Task/I-before-E-except-after-C/Maple/i-before-e-except-after-c.maple @@ -1,22 +1,22 @@ -words:= HTTP:-Get("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"): +words:= HTTP:-Get("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"): lst := StringTools:-Split(words[2],"\n"): xie, cie, cei, xei := 0, 0, 0, 0: for item in lst do - if searchtext("ie", item) <> 0 then - if searchtext("cie", item) <> 0 then - cie := cie + 1: - else - xie := xie + 1: - fi: - fi: - if searchtext("ei", item) <> 0 then - if searchtext("cei", item) <> 0 then - cei := cei + 1: - else - xei := xei + 1: - fi: - fi: -od: + if searchtext("ie", item) <> 0 then + if searchtext("cie", item) <> 0 then + cie := cie + 1: + else + xie := xie + 1: + fi: + fi: + if searchtext("ei", item) <> 0 then + if searchtext("cei", item) <> 0 then + cei := cei + 1: + else + xei := xei + 1: + fi: + fi: +od: p1, p2 := evalb(xie > 2*xei),evalb(cei > 2*cie); printf("The first phrase is %s with supporting features %d, anti features %d\n", piecewise(p1, "plausible", "not plausible"), xie, xei); printf("The seond phrase is %s with supporting features %d, anti features %d\n", piecewise(p2, "plausible", "not plausible"), cei, cie); diff --git a/Task/I-before-E-except-after-C/Mathematica/i-before-e-except-after-c-1.math b/Task/I-before-E-except-after-C/Mathematica/i-before-e-except-after-c-1.math index 38e8577727..62109c191c 100644 --- a/Task/I-before-E-except-after-C/Mathematica/i-before-e-except-after-c-1.math +++ b/Task/I-before-E-except-after-C/Mathematica/i-before-e-except-after-c-1.math @@ -1,5 +1,5 @@ wordlist = - Import["https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", + Import["http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", "Words"]; Print["The number of words in unixdict.txt = " <> ToString[Length[wordlist]]] diff --git a/Task/I-before-E-except-after-C/Microsoft-Small-Basic/i-before-e-except-after-c.basic b/Task/I-before-E-except-after-C/Microsoft-Small-Basic/i-before-e-except-after-c.basic deleted file mode 100644 index b7b18e8361..0000000000 --- a/Task/I-before-E-except-after-C/Microsoft-Small-Basic/i-before-e-except-after-c.basic +++ /dev/null @@ -1,25 +0,0 @@ -For i = 1 To 25104 - ' Assumes that unixdict.txt is in C:\ - word = File.ReadLine("C:\unixdict.txt", i) - If Text.IsSubText(word, "cie") Then - cie = cie + 1 - ElseIf Text.IsSubText(word, "ie") Then - ie = ie + 1 - EndIf - If Text.IsSubText(word, "cei") Then - cei = cei + 1 - ElseIf Text.IsSubText(word, "ei") Then - ei = ei + 1 - EndIf -EndFor - -If ie / ei > 2 Then - TextWindow.WriteLine("I before E when not preceded by C is plausible") -Else - TextWindow.WriteLine("I before E when not preceded by C is not plausible") -EndIf -If cei / cie > 2 Then - TextWindow.WriteLine("E before I when preceded by C is plausible") -Else - TextWindow.WriteLine("E before I when preceded by C is not plausible") -EndIf diff --git a/Task/I-before-E-except-after-C/Nim/i-before-e-except-after-c.nim b/Task/I-before-E-except-after-C/Nim/i-before-e-except-after-c.nim index 41a8ff75bf..2a549064b1 100644 --- a/Task/I-before-E-except-after-C/Nim/i-before-e-except-after-c.nim +++ b/Task/I-before-E-except-after-C/Nim/i-before-e-except-after-c.nim @@ -17,7 +17,7 @@ proc plausibility(rule: string; count1, count2: int): bool = let client = newHttpClient() var nie, cie, nei, cei = 0 -for word in client.getContent("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").split(): +for word in client.getContent("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").split(): if word.contains("ie"): if word.contains("cie"): inc cie diff --git a/Task/I-before-E-except-after-C/Nu/i-before-e-except-after-c-1.nu b/Task/I-before-E-except-after-C/Nu/i-before-e-except-after-c-1.nu deleted file mode 100644 index 2c9926743c..0000000000 --- a/Task/I-before-E-except-after-C/Nu/i-before-e-except-after-c-1.nu +++ /dev/null @@ -1,32 +0,0 @@ -# Fetch and process the word list -let words = open unixdict.txt | lines | where { ($in | str length) > 3 } - -# Function to count matches for a pattern -def count-pattern [pattern: string] { - $words | where $it =~ $pattern | length -} - -# Count occurrences for "I before E" rule -let ie_not_c = (count-pattern "(^|[^c])ie") # ie not preceded by c -let ei_not_c = (count-pattern "(^|[^c])ei") # ei not preceded by c - -# Count occurrences for "E before I" rule -let cei = (count-pattern "cei") # ei preceded by c -let cie = (count-pattern "cie") # ie preceded by c - -# Check plausibility (more than 2x occurrences of opposite) -let rule1_plausible = ($ie_not_c > ($ei_not_c * 2)) -let rule2_plausible = ($cei > ($cie * 2)) - -# Output results -print [ - $"Analyzing 'I before E when not preceded by C':" - $" correct for : ($ie_not_c)" - $" not correct for : ($ei_not_c)" - $" Plausible: ($rule1_plausible)" - $"" - $"Analyzing 'E before I when preceded by C':" - $" correct for : ($cei)" - $" not correct for : ($cie)" - $" Plausible: ($rule2_plausible)" - ] diff --git a/Task/I-before-E-except-after-C/Nu/i-before-e-except-after-c-2.nu b/Task/I-before-E-except-after-C/Nu/i-before-e-except-after-c-2.nu deleted file mode 100644 index 4519c2d750..0000000000 --- a/Task/I-before-E-except-after-C/Nu/i-before-e-except-after-c-2.nu +++ /dev/null @@ -1,48 +0,0 @@ -# Fetch and filter words -let words = open unixdict.txt | lines | where { $in | str length | $in > 3 } - -# Define patterns and their processing in a functional way -let patterns = [ - { name: "ie_not_c", pattern: "(^|[^c])ie", desc: "I before E when not preceded by C" } - { name: "ei_not_c", pattern: "(^|[^c])ei", desc: null } - { name: "cei", pattern: "cei", desc: "E before I when preceded by C" } - { name: "cie", pattern: "cie", desc: null } -] - -# Count matches for each pattern functionally -let counts = $patterns | - each { |p| - $p | upsert count ($words | where $it =~ $p.pattern | length) - } - -# Calculate plausibility using match -let results = $counts | - each { |row| - match $row.name { - "ie_not_c" => { - let opposite = ($counts | where name == "ei_not_c" | get count.0) - $row | upsert plausible ($row.count > ($opposite * 2)) - } - "cei" => { - let opposite = ($counts | where name == "cie" | get count.0) - $row | upsert plausible ($row.count > ($opposite * 2)) - } - _ => $row - } - } - -# Format and print results functionally -$results | - where desc != null | - each { |rule| - let opposite = ($results | where name == (if $rule.name == "ie_not_c" { "ei_not_c" } else { "cie" }) | get 0) - [ - $"Analyzing '($rule.desc)':" - $" correct for : ($rule.count)" - $" not correct for : ($opposite.count)" - $" Plausible: ($rule.plausible)" - "" - ] - } | - flatten | - print $in diff --git a/Task/I-before-E-except-after-C/Objeck/i-before-e-except-after-c.objeck b/Task/I-before-E-except-after-C/Objeck/i-before-e-except-after-c.objeck index eb0643dc33..637dc3013a 100644 --- a/Task/I-before-E-except-after-C/Objeck/i-before-e-except-after-c.objeck +++ b/Task/I-before-E-except-after-C/Objeck/i-before-e-except-after-c.objeck @@ -3,7 +3,7 @@ use Collection; class HttpTest { function : Main(args : String[]) ~ Nil { - IsPlausibleRule("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"); + IsPlausibleRule("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"); } function : PlausibilityCheck(comment : String, x : Int, y : Int) ~ Bool { diff --git a/Task/I-before-E-except-after-C/Octave/i-before-e-except-after-c.octave b/Task/I-before-E-except-after-C/Octave/i-before-e-except-after-c.octave index 3eb8bf3576..adc2b9f124 100644 --- a/Task/I-before-E-except-after-C/Octave/i-before-e-except-after-c.octave +++ b/Task/I-before-E-except-after-C/Octave/i-before-e-except-after-c.octave @@ -6,27 +6,27 @@ cei = 0; nie = 0; cie = 0; while ~feof(fid) - c = strsplit(strtrim(fgetl(fid)),char([9,32])); - if length(c) > 2, - n = str2num(c{3}); - else - n = 1; - end; - if strfind(c{1},'ei')>1, nei=nei+n; end; - if strfind(c{1},'cei'), cei=cei+n; end; - if strfind(c{1},'ie')>1, nie=nie+n; end; - if strfind(c{1},'cie'), cie=cie+n; end; + c = strsplit(strtrim(fgetl(fid)),char([9,32])); + if length(c) > 2, + n = str2num(c{3}); + else + n = 1; + end; + if strfind(c{1},'ei')>1, nei=nei+n; end; + if strfind(c{1},'cei'), cei=cei+n; end; + if strfind(c{1},'ie')>1, nie=nie+n; end; + if strfind(c{1},'cie'), cie=cie+n; end; end; fclose(fid); printf('cie: %i\nnie: %i\ncei: %i\nnei: %i\n',cie,nie-cie,cei,nei-cei); v = ''; if (nie < 3 * cie) - v=' not'; + v=' not'; end printf('I before E when not preceded by C: is%s plausible\n',v); v = ''; if (nei > 3 * cei) - v=' not'; + v=' not'; end printf('E before I when preceded by C: is%s plausible\n',v); diff --git a/Task/I-before-E-except-after-C/PascalABC.NET/i-before-e-except-after-c.pas b/Task/I-before-E-except-after-C/PascalABC.NET/i-before-e-except-after-c.pas deleted file mode 100644 index 4a3d98472f..0000000000 --- a/Task/I-before-E-except-after-C/PascalABC.NET/i-before-e-except-after-c.pas +++ /dev/null @@ -1,11 +0,0 @@ -// I before E except after C. Nigel Galloway: September 30th., 2024 -type plausibility=(plausible,implausible); -var fN:string->string->integer:=n->g->System.Text.RegularExpressions.Regex.Matches(n,g).count; -var fG:Func->(array of integer)->array of integer:=n->g->g.Zip(|n('ie'),n('ei'),n('cie'),n('cei')|,(n,g)->n+g).ToArray; -begin - var n:=System.IO.File.ReadLines('unixdict.txt').Aggregate(|0,0,0,0|,(n,g)->fG(fN(g))(n)); - println($'I before E except after C is {if n[0]-n[2]>2*n[2] then plausible else implausible}'); - println($'E before I except after C is {if n[1]-n[3]>2*n[3] then plausible else implausible}'); - println($'I before E when after C is {if n[2]>2*n[3] then plausible else implausible}'); - println($'E before I when after C is {if n[3]>2*n[2] then plausible else implausible}'); -end. diff --git a/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c.ps1 b/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c.ps1 deleted file mode 100644 index c3e30c0516..0000000000 --- a/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -$Web = New-Object -TypeName Net.Webclient -$Words = $web.DownloadString('https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt') - -$IE = $EI = $CIE = $CEI = @() - -$Clause1 = $Clause2 = $MainClause = $false - -foreach ($Word in $Words.split()) -{ - switch ($Word) - { - {($_ -like '*ie*') -and ($_ -notlike '*cie*')} {$IE += $Word} - {($_ -like '*ei*') -and ($_ -notlike '*cei*')} {$EI += $Word} - {$_ -like '*cei*'} {$CEI += $Word} - {$_ -like '*cie*'} {$CIE += $Word} - } -} - -if ($IE.count -gt $EI.count * 2) -{$Clause1 = $true} -"The plausibility of 'I before E when not preceded by C' is $Clause1" - -if ($CEI.count -gt $CIE.count * 2) -{$Clause2 = $true} -"The plausibility of 'E before I when preceded by C' is $Clause2" - -if ($Clause1 -and $Clause2) -{$MainClause = $True} -"The plausibility of the phrase 'I before E except after C' is $MainClause" diff --git a/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c.psh b/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c.psh new file mode 100644 index 0000000000..c1c8f167b4 --- /dev/null +++ b/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c.psh @@ -0,0 +1,29 @@ +$Web = New-Object -TypeName Net.Webclient +$Words = $web.DownloadString('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt') + +$IE = $EI = $CIE = $CEI = @() + +$Clause1 = $Clause2 = $MainClause = $false + +foreach ($Word in $Words.split()) +{ + switch ($Word) + { + {($_ -like '*ie*') -and ($_ -notlike '*cie*')} {$IE += $Word} + {($_ -like '*ei*') -and ($_ -notlike '*cei*')} {$EI += $Word} + {$_ -like '*cei*'} {$CEI += $Word} + {$_ -like '*cie*'} {$CIE += $Word} + } +} + +if ($IE.count -gt $EI.count * 2) +{$Clause1 = $true} +"The plausibility of 'I before E when not preceded by C' is $Clause1" + +if ($CEI.count -gt $CIE.count * 2) +{$Clause2 = $true} +"The plausibility of 'E before I when preceded by C' is $Clause2" + +if ($Clause1 -and $Clause2) +{$MainClause = $True} +"The plausibility of the phrase 'I before E except after C' is $MainClause" diff --git a/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c-1.py b/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c-1.py index 081cfb99da..4d00caa257 100644 --- a/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c-1.py +++ b/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c-1.py @@ -17,7 +17,7 @@ def plausibility_check(comment, x, y): % (x, y, x / y)) return x > PLAUSIBILITY_RATIO * y -def simple_stats(url='https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'): +def simple_stats(url='http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'): words = urllib.request.urlopen(url).read().decode().lower().split() cie = len({word for word in words if 'cie' in word}) cei = len({word for word in words if 'cei' in word}) diff --git a/Task/I-before-E-except-after-C/R/i-before-e-except-after-c.r b/Task/I-before-E-except-after-C/R/i-before-e-except-after-c.r index 8756b79215..aa3ad856c5 100644 --- a/Task/I-before-E-except-after-C/R/i-before-e-except-after-c.r +++ b/Task/I-before-E-except-after-C/R/i-before-e-except-after-c.r @@ -1,4 +1,4 @@ -words = tolower(readLines("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")) +words = tolower(readLines("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")) ie.npc = sum(grepl("(?2) )'plausible.' +p2=#.ie.c / max(1, #.ei.c); phrase= '"E before I when preceded by C"' +say mantra phrase ' is ' word("im", 1 + (p2>2) )'plausible.' +po=(p1>2 & p2>2); say 'Overall, it is' word("im", 1 + po)'plausible.' +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +find: arg x; s=1; do forever; _=pos(x, u, s); if _==0 then return + if substr(u, _ - 1 + (_==1)*999, 1)=='C' then #.x.c=#.x.c + 1 + else #.x.z=#.x.z + 1 + s=_ + 1 /*handle the cases of multiple finds. */ + end /*forever*/ diff --git a/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c-2.rexx b/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c-2.rexx new file mode 100644 index 0000000000..59c7da9267 --- /dev/null +++ b/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c-2.rexx @@ -0,0 +1,61 @@ +/*REXX program shows plausibility of "I before E" when not preceded by C, and */ +/*───────────────────────────────────── "E before I" when preceded by C, using a */ +/*───────────────────────────────────── weighted frequency for each word. */ +parse arg iFID wFID . /*obtain optional arguments from the CL*/ +if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT' /*Not specified? Then use the default.*/ +if wFID=='' | wFID=="," then wFID='WORDFREQ.TXT' /* " " " " " " */ +cntl=xrange(, ' ') /*get all manner of tabs, control chars*/ +#.=0 /*zero out the various word counters. */ +f.=1 /*default word frequency multiplier. */ + do recs=0 while lines(wFID)\==0 /*read a record from the file 'til done*/ + u=translate( linein(wFID), , cntl); upper u /*translate various tabs and cntl chars*/ + u=translate(u, '*', "~") /*translate tildes (~) to an asterisk.*/ + if u=='' then iterate /*Is this a blank line? Then ignore it.*/ + freq=word(u, words(u) ) /*obtain the last token on the line. */ + if \datatype(freq, 'W') then iterate /*FREQ not an integer? Then ignore it.*/ + parse var u w.1 '/' w.2 . /*handle case of: ααα/ßßß ··· */ + + do j=1 for 2; w.j=word(w.j, 1) /*strip leading and/or trailing blanks.*/ + _=w.j; if _=='' then iterate /*if not present, then ignore it. */ + if j==2 then if w.2==w.1 then iterate /*second word ≡ first word? Then skip.*/ + #.freqs=#.freqs + 1 /*bump word counter in the FREQ list.*/ + f._=f._ + freq /*add to a word's frequency count. */ + end /*ws*/ + end /*recs*/ /*at exit of DO loop, RECS = # of recs.*/ + +if recs\==0 then say 'lines in the ' wFID " list: " recs +if #.freqs\==0 then say 'words in the ' wFID " list: " #.freqs +if #.freqs ==0 then weighted= + else weighted= ' (weighted)' +say + do r=0 while lines(iFID)\==0 /*keep reading the dictionary 'til done*/ + u=space( linein(iFID), 0); upper u /*elide superfluous blanks and tabs. */ + if u=='' then iterate /*Is it a blank line? Then ignore it.*/ + #.words=#.words + 1 /*keep running count of number of words*/ + one=f.u + if pos('EI', u)\==0 & pos('IE', u)\==0 then #.both=#.both + one /*the word has both*/ + call find 'ie' /*look for ie */ + call find 'ei' /* " " ei */ + end /*r*/ /*at exit of DO loop, R = # of lines.*/ + +L=length(#.words) /*use this to align the output numbers.*/ +say 'lines in the ' iFID ' dictionary: ' r +say 'words in the ' iFID ' dictionary: ' #.words +say +say 'words with "IE" and "EI" (in same word): ' right(#.both, L) weighted +say 'words with "IE" and preceded by "C": ' right(#.ie.c ,L) weighted +say 'words with "IE" and not preceded by "C": ' right(#.ie.z ,L) weighted +say 'words with "EI" and preceded by "C": ' right(#.ei.c ,L) weighted +say 'words with "EI" and not preceded by "C": ' right(#.ei.z ,L) weighted +say; mantra= 'The spelling mantra ' +p1=#.ie.z / max(1, #.ei.z); phrase= '"I before E when not preceded by C"' +say mantra phrase ' is ' word("im", 1 + (p1>2) )'plausible.' +p2=#.ie.c / max(1, #.ei.c); phrase= '"E before I when preceded by C"' +say mantra phrase ' is ' word("im", 1 + (p2>2) )'plausible.' +po=(p1>2 & p2>2); say 'Overall, it is' word("im",1 + po)'plausible.' +exit /*stick a fork in it, we're all done. */ +/*──────────────────────────────────────────────────────────────────────────────────────*/ +find: arg x; s=1; do forever; _=pos(x, u, s); if _==0 then return + if substr(u, _ - 1 + (_==1)*999, 1)=='C' then #.x.c=#.x.c + one + else #.x.z=#.x.z + one + s=_ + 1 /*handle the cases of multiple finds. */ diff --git a/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c.rexx b/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c.rexx deleted file mode 100644 index febe0ab972..0000000000 --- a/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c.rexx +++ /dev/null @@ -1,59 +0,0 @@ --- 10 Nov 2025 -include Setting - -say 'I BEFORE E AFTER C' -say version -say -call UnixDict -call Show -exit - -UnixDict: -file='UnixDict.txt' -say 'Process' file'...' -n=0; cie=0; cei=0; xie=0; xei=0 -do while Lines(file) > 0 - line=Lower(Linein(file)); n+=1 - a=Pos('ie',line) - if a>0 then do - a+=99*(a<2) - if Substr(line,a-1,1)='c' then - cie+=1 - else - xie+=1 - end - a=Pos('ei',line) - if a>0 then do - a+=99*(a<2) - if Substr(line,a-1,1)='c' then - cei+=1 - else - xei+=1 - end -end -say n 'Lines processed' -say -return - -Show: -say 'IE preceded by C occurs' cie 'times' -say 'EI preceded by C occurs' cei 'times' -say 'IE not preceded by C occurs' xie 'times' -say 'EI not preceded by C occurs' xei 'times' -say -ie=(2*xie<=cie); ei=(2*cei<=xei) -call Charout ,'I before E when not preceded by C is ' -if ie then - call Charout ,'not ' -say 'plausible' -call Charout ,'E before I when preceded by C is ' -if ei then - call Charout ,'not ' -say 'plausible' -call Charout ,'I before E except after C is ' -if ie | ei then - call Charout ,'not ' -say 'plausible' -return - -include Abend diff --git a/Task/I-before-E-except-after-C/Rebol/i-before-e-except-after-c.rebol b/Task/I-before-E-except-after-C/Rebol/i-before-e-except-after-c.rebol deleted file mode 100644 index 53e916ca1b..0000000000 --- a/Task/I-before-E-except-after-C/Rebol/i-before-e-except-after-c.rebol +++ /dev/null @@ -1,50 +0,0 @@ -Rebol [ - title: "Rosetta code: I before E except after C" - file: %I_before_E_except_after_C.r3 - url: https://rosettacode.org/wiki/I_before_E_except_after_C - note: "Based on Red language solution" - needs: 3.15.0 ;; or something like that -] - -testlist: function [wordlist /wfreq] [ - ;; Initialize counters for each pattern - cie: cei: ie: ei: 0 - - ;; Select iteration mode: if /wfreq, expect [word freq] pairs; else assume word-only - words: either wfreq [[word freq]][freq: 1 [word]] - - ;; Loop through each word or [word freq] pair in the list - foreach :words wordlist [ - ;; Use PARSE to search for each pattern within the word string - parse word [ some [ - "cie" (cie: cie + freq) | ;; Count "cie" and increment by frequency - "cei" (cei: cei + freq) | ;; Count "cei" and increment by frequency - "ie" ( ie: ie + freq) | ;; Count standalone "ie" not preceded by c - "ei" ( ei: ei + freq) | ;; Count standalone "ei" not preceded by c - skip - ]] - ] - ;; Print results, comparing "i before e except after c" rule against pattern frequencies - print rejoin [ - "i is before e " ie " times, and also " cie " times following c.^/" - "i is after e " ei " times, and also " cei " times following c.^/" - "Hence ^"i before e^" is " either a: 2 * ei < ie [""] ["not "] "plausible,^/" - "while ^"except after c^" is " either b: 2 * cie < cei [""] ["not "] "plausible.^/" - "Overall the rule is " either a and b [""] ["not "] "plausible." - ] -] - -print "Results for unixdict.txt:" -testlist read/lines %unixdict.txt - -print "^/Results for British National Corpus:" -bnc: next read/lines %1_2_all_freq.txt -spaces: charset "^- " -bnclist: collect [ - foreach w bnc [ - if 3 = length? seq: split trim w spaces [ - keep seq/1 keep to-integer seq/3 - ] - ] -] -testlist/wfreq bnclist diff --git a/Task/I-before-E-except-after-C/Red/i-before-e-except-after-c.red b/Task/I-before-E-except-after-C/Red/i-before-e-except-after-c.red index 4589f32f1b..b7e21dc1e8 100644 --- a/Task/I-before-E-except-after-C/Red/i-before-e-except-after-c.red +++ b/Task/I-before-E-except-after-C/Red/i-before-e-except-after-c.red @@ -1,33 +1,33 @@ Red ["i before e except after c"] testlist: function [wordlist /wfreq] [ - cie: cei: ie: ei: 0 - if not wfreq [forall wordlist [insert wordlist: next wordlist 1]] - foreach [word freq] wordlist [ - parse word [ some [ - "cie" (cie: cie + freq) | - "cei" (cei: cei + freq) | - "ie" (ie: ie + freq) | - "ei" (ei: ei + freq) | - skip - ]] - ] - print rejoin [ - "i is before e " ie " times, and also " cie " times following c.^/" - "i is after e " ei " times, and also " cei " times following c.^/" - "Hence ^"i before e^" is " either a: 2 * ei < ie [""] ["not "] "plausible,^/" - "while ^"except after c^" is " either b: 2 * cie < cei [""] ["not "] "plausible.^/" - "Overall the rule is " either a and b [""] ["not "] "plausible."] + cie: cei: ie: ei: 0 + if not wfreq [forall wordlist [insert wordlist: next wordlist 1]] + foreach [word freq] wordlist [ + parse word [ some [ + "cie" (cie: cie + freq) | + "cei" (cei: cei + freq) | + "ie" (ie: ie + freq) | + "ei" (ei: ei + freq) | + skip + ]] + ] + print rejoin [ + "i is before e " ie " times, and also " cie " times following c.^/" + "i is after e " ei " times, and also " cei " times following c.^/" + "Hence ^"i before e^" is " either a: 2 * ei < ie [""] ["not "] "plausible,^/" + "while ^"except after c^" is " either b: 2 * cie < cei [""] ["not "] "plausible.^/" + "Overall the rule is " either a and b [""] ["not "] "plausible."] ] print "Results for unixdict.txt:" -testlist read/lines https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt +testlist read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt print "^/Results for British National Corpus:" bnc: next read/lines %1_2_all_freq.txt spaces: charset "^- " -bnclist: collect [ foreach w bnc [ - if 3 = length? seq: split trim w spaces [ - keep seq/1 keep to-integer seq/3 +bnclist: collect [ foreach w bnc [ + if 3 = length? seq: split trim w spaces [ + keep seq/1 keep to-integer seq/3 ]]] testlist/wfreq bnclist diff --git a/Task/I-before-E-except-after-C/Ruby/i-before-e-except-after-c.rb b/Task/I-before-E-except-after-C/Ruby/i-before-e-except-after-c.rb index 8c07c86b90..566bf86072 100644 --- a/Task/I-before-E-except-after-C/Ruby/i-before-e-except-after-c.rb +++ b/Task/I-before-E-except-after-C/Ruby/i-before-e-except-after-c.rb @@ -2,7 +2,7 @@ require 'open-uri' plausibility_ratio = 2 counter = Hash.new(0) -path = 'https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt' +path = 'http://wiki.puzzlers.org/pub/wordlists/unixdict.txt' rules = [['I before E when not preceded by C:', 'ie', 'ei'], ['E before I when preceded by C:', 'cei', 'cie']] diff --git a/Task/I-before-E-except-after-C/Rust/i-before-e-except-after-c.rs b/Task/I-before-E-except-after-C/Rust/i-before-e-except-after-c.rs deleted file mode 100644 index f1f0733b63..0000000000 --- a/Task/I-before-E-except-after-C/Rust/i-before-e-except-after-c.rs +++ /dev/null @@ -1,79 +0,0 @@ -use std::default::Default; -use std::ops::AddAssign; - -use itertools::Itertools; -use reqwest::get; - -#[derive(Default, Debug)] -struct Feature { - pub cie: T, - pub xie: T, - pub cei: T, - pub xei: T, -} - -impl AddAssign> for Feature { - fn add_assign(&mut self, rhs: Feature) { - self.cei += rhs.cei as u64; - self.xei += rhs.xei as u64; - self.cie += rhs.cie as u64; - self.xie += rhs.xie as u64; - } -} - -fn check_feature(word: &str) -> Feature { - let mut feature: Feature = Default::default(); - - for window in word.chars().tuple_windows::<(char, char, char)>() { - match window { - ('c', 'e', 'i') => { feature.cei = true } - ('c', 'i', 'e') => { feature.cie = true } - (not_c, 'e', 'i') if not_c != 'c' => (feature.xei = true), - (not_c, 'i', 'e') if not_c != 'c' => (feature.xie = true), - _ => {} - } - } - - feature -} - - -fn maybe_is_feature_plausible(feature_count: u64, opposing_count: u64) -> Option { - if feature_count > 2 * opposing_count { Some(true) } else if opposing_count > 2 * feature_count { Some(false) } else { None } -} - -fn print_feature_plausibility(feature_plausibility: Option, feature_name: &str) { - let plausible_msg = - match feature_plausibility { - None => " is implausible", - Some(true) => "is plausible", - Some(false) => "is definitely implausible", - }; - - println!("{} {}", feature_name, plausible_msg) -} - -fn main() { - let mut res = get(" https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").unwrap(); - let texts = res.text().unwrap(); - - let mut feature_count: Feature = Default::default(); - for word in texts.lines() { - let feature = check_feature(word); - feature_count += feature; - } - - println!("Counting {:#?}", feature_count); - - let xie_plausibility = - maybe_is_feature_plausible(feature_count.xie, feature_count.cie); - let cei_plausibility = - maybe_is_feature_plausible(feature_count.cei, feature_count.xei); - - print_feature_plausibility(xie_plausibility, "I before E when not preceded by C"); - print_feature_plausibility(cei_plausibility, "E before I when preceded by C"); - println!("The rule in general is {}", - if xie_plausibility.unwrap_or(false) && cei_plausibility.unwrap_or(false) - { "Plausible" } else { "Implausible" } - ); -} diff --git a/Task/I-before-E-except-after-C/Rust/i-before-e-except-after-c.rust b/Task/I-before-E-except-after-C/Rust/i-before-e-except-after-c.rust new file mode 100644 index 0000000000..8682f51edb --- /dev/null +++ b/Task/I-before-E-except-after-C/Rust/i-before-e-except-after-c.rust @@ -0,0 +1,79 @@ +use std::default::Default; +use std::ops::AddAssign; + +use itertools::Itertools; +use reqwest::get; + +#[derive(Default, Debug)] +struct Feature { + pub cie: T, + pub xie: T, + pub cei: T, + pub xei: T, +} + +impl AddAssign> for Feature { + fn add_assign(&mut self, rhs: Feature) { + self.cei += rhs.cei as u64; + self.xei += rhs.xei as u64; + self.cie += rhs.cie as u64; + self.xie += rhs.xie as u64; + } +} + +fn check_feature(word: &str) -> Feature { + let mut feature: Feature = Default::default(); + + for window in word.chars().tuple_windows::<(char, char, char)>() { + match window { + ('c', 'e', 'i') => { feature.cei = true } + ('c', 'i', 'e') => { feature.cie = true } + (not_c, 'e', 'i') if not_c != 'c' => (feature.xei = true), + (not_c, 'i', 'e') if not_c != 'c' => (feature.xie = true), + _ => {} + } + } + + feature +} + + +fn maybe_is_feature_plausible(feature_count: u64, opposing_count: u64) -> Option { + if feature_count > 2 * opposing_count { Some(true) } else if opposing_count > 2 * feature_count { Some(false) } else { None } +} + +fn print_feature_plausibility(feature_plausibility: Option, feature_name: &str) { + let plausible_msg = + match feature_plausibility { + None => " is implausible", + Some(true) => "is plausible", + Some(false) => "is definitely implausible", + }; + + println!("{} {}", feature_name, plausible_msg) +} + +fn main() { + let mut res = get(" http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").unwrap(); + let texts = res.text().unwrap(); + + let mut feature_count: Feature = Default::default(); + for word in texts.lines() { + let feature = check_feature(word); + feature_count += feature; + } + + println!("Counting {:#?}", feature_count); + + let xie_plausibility = + maybe_is_feature_plausible(feature_count.xie, feature_count.cie); + let cei_plausibility = + maybe_is_feature_plausible(feature_count.cei, feature_count.xei); + + print_feature_plausibility(xie_plausibility, "I before E when not preceded by C"); + print_feature_plausibility(cei_plausibility, "E before I when preceded by C"); + println!("The rule in general is {}", + if xie_plausibility.unwrap_or(false) && cei_plausibility.unwrap_or(false) + { "Plausible" } else { "Implausible" } + ); +} diff --git a/Task/I-before-E-except-after-C/SETL/i-before-e-except-after-c.setl b/Task/I-before-E-except-after-C/SETL/i-before-e-except-after-c.setl deleted file mode 100644 index 1632b84178..0000000000 --- a/Task/I-before-E-except-after-C/SETL/i-before-e-except-after-c.setl +++ /dev/null @@ -1,34 +0,0 @@ -program i_before_e_except_after_c; - init cie := 0, xie := 0, cei := 0, xei := 0; - - dict := open("unixdict.txt", "r"); - loop doing word := getline(dict); while word /= om do - classify(word); - end loop; - close(dict); - - p := - plausible("I before E when not preceded by C", xie, cie) and - plausible("E before I when preceded by C", cei, xei); - print; - print("I before E, except after C:" + (if p then "" else " not" end) - + " plausible."); - - proc classify(word); - if "ie" in word then - if "cie" in word then cie +:= 1; - else xie +:= 1; - end if; - elseif "ei" in word then - if "cei" in word then cei +:= 1; - else xei +:= 1; - end if; - end if; - end proc; - - proc plausible(clause, feature, opposite); - p := 2 * feature > opposite; - print(clause + ":" + (if p then "" else " not" end) + " plausible."); - return p; - end proc; -end program; diff --git a/Task/I-before-E-except-after-C/Scala/i-before-e-except-after-c.scala b/Task/I-before-E-except-after-C/Scala/i-before-e-except-after-c.scala index 2a27cab5c3..f1455bf125 100644 --- a/Task/I-before-E-except-after-C/Scala/i-before-e-except-after-c.scala +++ b/Task/I-before-E-except-after-C/Scala/i-before-e-except-after-c.scala @@ -7,7 +7,7 @@ object I_before_E_except_after_C extends App { val testCEI2 = "(^|[^c])ei".r // e before i when not preceded by c var countsCEI = (0,0) - scala.io.Source.fromURL("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").getLines.map(_.toLowerCase).foreach{word => + scala.io.Source.fromURL("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").getLines.map(_.toLowerCase).foreach{word => if (testIE1.findFirstIn(word).isDefined) countsIE = (countsIE._1 + 1, countsIE._2) if (testIE2.findFirstIn(word).isDefined) countsIE = (countsIE._1, countsIE._2 + 1) if (testCEI1.findFirstIn(word).isDefined) countsCEI = (countsCEI._1 + 1, countsCEI._2) diff --git a/Task/I-before-E-except-after-C/Swift/i-before-e-except-after-c.swift b/Task/I-before-E-except-after-C/Swift/i-before-e-except-after-c.swift index 14028c69b2..ed3120606c 100644 --- a/Task/I-before-E-except-after-C/Swift/i-before-e-except-after-c.swift +++ b/Task/I-before-E-except-after-C/Swift/i-before-e-except-after-c.swift @@ -1,6 +1,6 @@ import Foundation -let request = NSURLRequest(URL: NSURL(string: "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")!) +let request = NSURLRequest(URL: NSURL(string: "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")!) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue()) {res, data, err in if (data != nil) { diff --git a/Task/I-before-E-except-after-C/TUSCRIPT/i-before-e-except-after-c.tu b/Task/I-before-E-except-after-C/TUSCRIPT/i-before-e-except-after-c.tu index e0b0fd9e71..736ae22160 100644 --- a/Task/I-before-E-except-after-C/TUSCRIPT/i-before-e-except-after-c.tu +++ b/Task/I-before-E-except-after-C/TUSCRIPT/i-before-e-except-after-c.tu @@ -1,5 +1,5 @@ $$ MODE TUSCRIPT,{} -words=REQUEST("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") +words=REQUEST("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") size=SIZE(words) ieei=cie=xie=cei=xei=0 diff --git a/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl b/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl index a3199937e3..e0a7b5692f 100644 --- a/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl +++ b/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl @@ -5,24 +5,24 @@ proc plausible {description x y} { variable PLAUSIBILITY_RATIO puts " Checking plausibility of: $description" if {$x > $PLAUSIBILITY_RATIO * $y} { - set conclusion "PLAUSIBLE" - set fmt "As we have counts of %i vs %i words, a ratio of %.1f times" - set result true + set conclusion "PLAUSIBLE" + set fmt "As we have counts of %i vs %i words, a ratio of %.1f times" + set result true } elseif {$x > $y} { - set conclusion "IMPLAUSIBLE" - set fmt "As although we have counts of %i vs %i words," - append fmt " a ratio of %.1f times does not make it plausible" - set result false + set conclusion "IMPLAUSIBLE" + set fmt "As although we have counts of %i vs %i words," + append fmt " a ratio of %.1f times does not make it plausible" + set result false } else { - set conclusion "IMPLAUSIBLE, probably contra-indicated" - set fmt "As we have counts of %i vs %i words, a ratio of %.1f times" - set result false + set conclusion "IMPLAUSIBLE, probably contra-indicated" + set fmt "As we have counts of %i vs %i words, a ratio of %.1f times" + set result false } puts [format " %s.\n $fmt" $conclusion $x $y [expr {double($x)/$y}]] return $result } -set t [http::geturl https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt] +set t [http::geturl http://wiki.puzzlers.org/pub/wordlists/unixdict.txt] set words [split [http::data $t] "\n"] http::cleanup $t foreach {name pattern} {ie (?:^|[^c])ie ei (?:^|[^c])ei cie cie cei cei} { @@ -39,4 +39,4 @@ if { puts "\nOVERALL IT IS IMPLAUSIBLE!" } puts "\n(To be plausible, one word count must exceed another by\ - $PLAUSIBILITY_RATIO times)" + $PLAUSIBILITY_RATIO times)" diff --git a/Task/I-before-E-except-after-C/V-(Vlang)/i-before-e-except-after-c.v b/Task/I-before-E-except-after-C/V-(Vlang)/i-before-e-except-after-c.v index 1f88bdbb7a..e677b3c2fa 100644 --- a/Task/I-before-E-except-after-C/V-(Vlang)/i-before-e-except-after-c.v +++ b/Task/I-before-E-except-after-C/V-(Vlang)/i-before-e-except-after-c.v @@ -2,26 +2,26 @@ import os import strconv fn main() { - mut cei, mut cie, mut ie, mut ei := f32(0), f32(0), f32(0), f32(0) + mut cei, mut cie, mut ie, mut ei := f32(0), f32(0), f32(0), f32(0) unixdict := os.read_file('./unixdict.txt') or {println('Error: file not found') exit(1)} - words := unixdict.split_into_lines() - println("The number of words in unixdict: ${words.len}") - for word in words { - cei += word.count('cei') - cie += word.count('cie') - ei += word.count('ei') - ie += word.count('ie') - } - print("Rule: 'e' before 'i' when preceded by 'c' at the ratio of ") - print("${strconv.f64_to_str_lnd1((cei / cie), 2)} is ") - if cei > cie {println("plausible.")} else {println("implausible.")} - println("$cei cases for and $cie cases against.") + words := unixdict.split_into_lines() + println("The number of words in unixdict: ${words.len}") + for word in words { + cei += word.count('cei') + cie += word.count('cie') + ei += word.count('ei') + ie += word.count('ie') + } + print("Rule: 'e' before 'i' when preceded by 'c' at the ratio of ") + print("${strconv.f64_to_str_lnd1((cei / cie), 2)} is ") + if cei > cie {println("plausible.")} else {println("implausible.")} + println("$cei cases for and $cie cases against.") - print("Rule: 'i' before 'e' except after 'c' at the ratio of ") - print("${strconv.f64_to_str_lnd1(((ie - cie) / (ei - cei)), 2)} is ") - if ie > ei {println("plausible.")} else {println("implausible.")} - println("${(ie - cie)} cases for and ${(ei - cei)} cases against.") + print("Rule: 'i' before 'e' except after 'c' at the ratio of ") + print("${strconv.f64_to_str_lnd1(((ie - cie) / (ei - cei)), 2)} is ") + if ie > ei {println("plausible.")} else {println("implausible.")} + println("${(ie - cie)} cases for and ${(ei - cei)} cases against.") - print("Overall the rules are ") - if cei > cie && ie > ei {println("plausible.")} else {println("implausible.")} + print("Overall the rules are ") + if cei > cie && ie > ei {println("plausible.")} else {println("implausible.")} } diff --git a/Task/I-before-E-except-after-C/VBScript/i-before-e-except-after-c.vb b/Task/I-before-E-except-after-C/VBScript/i-before-e-except-after-c.vb new file mode 100644 index 0000000000..41f01c4eba --- /dev/null +++ b/Task/I-before-E-except-after-C/VBScript/i-before-e-except-after-c.vb @@ -0,0 +1,48 @@ +Set objFSO = CreateObject("Scripting.FileSystemObject") +Set srcFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ + "\unixdict.txt",1,False,0) + +cei = 0 : cie = 0 : ei = 0 : ie = 0 + +Do Until srcFile.AtEndOfStream + word = srcFile.ReadLine + If InStr(word,"cei") Then + cei = cei + 1 + ElseIf InStr(word,"cie") Then + cie = cie + 1 + ElseIf InStr(word,"ei") Then + ei = ei + 1 + ElseIf InStr(word,"ie") Then + ie = ie + 1 + End If +Loop + +FirstClause = False +SecondClause = False +Overall = False + +'testing the first clause +If ie > ei*2 Then + WScript.StdOut.WriteLine "I before E when not preceded by C is plausible." + FirstClause = True +Else + WScript.StdOut.WriteLine "I before E when not preceded by C is NOT plausible." +End If + +'testing the second clause +If cei > cie*2 Then + WScript.StdOut.WriteLine "E before I when not preceded by C is plausible." + SecondClause = True +Else + WScript.StdOut.WriteLine "E before I when not preceded by C is NOT plausible." +End If + +'overall clause +If FirstClause And SecondClause Then + WScript.StdOut.WriteLine "Overall it is plausible." +Else + WScript.StdOut.WriteLine "Overall it is NOT plausible." +End If + +srcFile.Close +Set objFSO = Nothing diff --git a/Task/I-before-E-except-after-C/VBScript/i-before-e-except-after-c.vbs b/Task/I-before-E-except-after-C/VBScript/i-before-e-except-after-c.vbs deleted file mode 100644 index 411c9183c1..0000000000 --- a/Task/I-before-E-except-after-C/VBScript/i-before-e-except-after-c.vbs +++ /dev/null @@ -1,48 +0,0 @@ -Set objFSO = CreateObject("Scripting.FileSystemObject") -Set srcFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ - "\unixdict.txt",1,False,0) - -cei = 0 : cie = 0 : ei = 0 : ie = 0 - -Do Until srcFile.AtEndOfStream - word = srcFile.ReadLine - If InStr(word,"cei") Then - cei = cei + 1 - ElseIf InStr(word,"cie") Then - cie = cie + 1 - ElseIf InStr(word,"ei") Then - ei = ei + 1 - ElseIf InStr(word,"ie") Then - ie = ie + 1 - End If -Loop - -FirstClause = False -SecondClause = False -Overall = False - -'testing the first clause -If ie > ei*2 Then - WScript.StdOut.WriteLine "I before E when not preceded by C is plausible." - FirstClause = True -Else - WScript.StdOut.WriteLine "I before E when not preceded by C is NOT plausible." -End If - -'testing the second clause -If cei > cie*2 Then - WScript.StdOut.WriteLine "E before I when not preceded by C is plausible." - SecondClause = True -Else - WScript.StdOut.WriteLine "E before I when not preceded by C is NOT plausible." -End If - -'overall clause -If FirstClause And SecondClause Then - WScript.StdOut.WriteLine "Overall it is plausible." -Else - WScript.StdOut.WriteLine "Overall it is NOT plausible." -End If - -srcFile.Close -Set objFSO = Nothing diff --git a/Task/I-before-E-except-after-C/Visual-Basic-.NET/i-before-e-except-after-c.vb b/Task/I-before-E-except-after-C/Visual-Basic-.NET/i-before-e-except-after-c.vb index 60ee3a0d15..2b5d1a8478 100644 --- a/Task/I-before-E-except-after-C/Visual-Basic-.NET/i-before-e-except-after-c.vb +++ b/Task/I-before-E-except-after-C/Visual-Basic-.NET/i-before-e-except-after-c.vb @@ -9,7 +9,7 @@ Imports System.Text.RegularExpressions Module Program ' Supports both local and remote files - Const WORDLIST_URI = "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" + Const WORDLIST_URI = "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" ' The support factor of a word for EI or IE is the number of occurrences that support the rule minus the number that oppose it. diff --git a/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-1.wren b/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-1.wren index 3de929e85b..6e6559d8b1 100644 --- a/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-1.wren +++ b/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-1.wren @@ -1,6 +1,6 @@ import "io" for File -import "./pattern" for Pattern -import "./fmt" for Fmt +import "/pattern" for Pattern +import "/fmt" for Fmt var yesNo = Fn.new { |b| (b) ? "yes" : "no" } diff --git a/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-2.wren b/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-2.wren index f7ef9f5868..37daa47fae 100644 --- a/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-2.wren +++ b/Task/I-before-E-except-after-C/Wren/i-before-e-except-after-c-2.wren @@ -1,6 +1,6 @@ import "io" for File -import "./pattern" for Pattern -import "./fmt" for Fmt +import "/pattern" for Pattern +import "/fmt" for Fmt var yesNo = Fn.new { |b| (b) ? "yes" : "no" } diff --git a/Task/I-before-E-except-after-C/XPL0/i-before-e-except-after-c.xpl0 b/Task/I-before-E-except-after-C/XPL0/i-before-e-except-after-c.xpl0 deleted file mode 100644 index 4c9870b998..0000000000 --- a/Task/I-before-E-except-after-C/XPL0/i-before-e-except-after-c.xpl0 +++ /dev/null @@ -1,32 +0,0 @@ -include xpllib; \for StrFind and Print -int I, Ch, CI, XI, CE, XE; -char Word(100); \(longest word in unixdict.txt is 22 chars) -[FSet(FOpen("unixdict.txt", 0), ^I); \open dictionary and set it to device 3 -OpenI(3); -repeat I:= 0; - loop [Ch:= ChIn(3); - if Ch=LF or Ch=EOF then quit; - Word(I):= Ch; - I:= I+1; - ]; - Word(I):= 0; \terminate string - - if StrFind(Word, "ie") then - if StrFind(Word, "cie") then CI:= CI+1 else XI:= XI+1; - if StrFind(Word, "ei") then - if StrFind(Word, "cei") then CE:= CE+1 else XE:= XE+1; -until Ch = EOF; - -Print("CIE: %d\n", CI); -Print("xIE: %d\n", XI); -Print("CEI: %d\n", CE); -Print("xEI: %d\n\n", XE); - -Print("I before E when not preceded by C: "); -if 2*XI < CI then Print("not "); -Print("plausible.\n"); - -Print("E before I when preceded by C: "); -if 2*CI < XE then Print("not "); -Print("plausible.\n"); -] diff --git a/Task/I-before-E-except-after-C/Yabasic/i-before-e-except-after-c.basic b/Task/I-before-E-except-after-C/Yabasic/i-before-e-except-after-c.basic index fde65240f8..65f3fa6df9 100644 --- a/Task/I-before-E-except-after-C/Yabasic/i-before-e-except-after-c.basic +++ b/Task/I-before-E-except-after-C/Yabasic/i-before-e-except-after-c.basic @@ -3,11 +3,11 @@ open "unixdict.txt" for reading as #1 repeat line input #1 pal$ if instr(pal$, "ie") then - if instr(pal$, "cie") then CI = CI + 1 else XI = XI + 1 : fi - endif + if instr(pal$, "cie") then CI = CI + 1 else XI = XI + 1 : fi + endif if instr(pal$, "ei") then - if instr(pal$, "cei") then CE = CE + 1 else XE = XE + 1 : fi - endif + if instr(pal$, "cei") then CE = CE + 1 else XE = XE + 1 : fi + endif until eof(1) close #1 diff --git a/Task/IBAN/ALGOL-68/iban.alg b/Task/IBAN/ALGOL-68/iban.alg deleted file mode 100644 index 93dc56bbc2..0000000000 --- a/Task/IBAN/ALGOL-68/iban.alg +++ /dev/null @@ -1,104 +0,0 @@ -BEGIN # validate IBAN numbers # - - # country code and expected bank account length for IBAN codes # - MODE IBANCOUNTRY = STRUCT( [ 1 : 2 ]CHAR code, INT length ); - - []IBANCOUNTRY country info = - ( ("AL",28), ("AD",24), ("AT",20), ("AZ",28), ("BE",16), ("BH",22), ("BA",20), ("BR",29) - , ("BG",22), ("CR",21), ("HR",21), ("CY",28), ("CZ",24), ("DK",18), ("DO",28), ("EE",20) - , ("FO",18), ("FI",18), ("FR",27), ("GE",22), ("DE",22), ("GI",23), ("GR",27), ("GL",18) - , ("GT",28), ("HU",28), ("IS",26), ("IE",22), ("IL",23), ("IT",27), ("KZ",20), ("KW",30) - , ("LV",21), ("LB",28), ("LI",21), ("LT",20), ("LU",20), ("MK",19), ("MT",31), ("MR",27) - , ("MU",30), ("MC",27), ("MD",24), ("ME",22), ("NL",18), ("NO",15), ("PK",24), ("PS",29) - , ("PL",28), ("PT",25), ("RO",24), ("SM",27), ("SA",24), ("RS",22), ("SK",24), ("SI",19) - , ("ES",24), ("SE",24), ("CH",21), ("TN",24), ("TR",26), ("AE",23), ("GB",22), ("VG",24) - ); - - # returns "" if s could be a valid IBAN, an error message otherwise # - OP POSSIBLEIBAN = ( STRING s )STRING: - BEGIN - BOOL is valid := TRUE; - STRING result := ""; - # remove spaces and check we only have digits and spaces # - STRING iban := ""; - FOR s pos FROM LWB s TO UPB s WHILE is valid DO - CHAR c = s[ s pos ]; - IF c /= " " THEN - IF NOT ( is valid := ( c >= "A" AND c <= "Z" ) OR ( c >= "0" AND c <= "9" ) ) - THEN result := "Invalid character: " + c - FI; - iban +:= c - FI - OD; - IF is valid THEN - # OK so far - check the length matches the country code # - INT supplied length = ( UPB iban - LWB iban ) + 1; - is valid := FALSE; - IF supplied length <= 4 - THEN result := "Code is too short" - ELSE # enough characters for a country code and a check sum # - INT expected length := -1; - STRING supplied country = iban[ LWB iban : LWB iban + 1 ]; - FOR c pos FROM LWB country info TO UPB country info WHILE NOT is valid DO - IF is valid := code OF country info[ c pos ] = supplied country THEN - expected length := length OF country info[ c pos ] - FI - OD; - IF NOT is valid - THEN result := "Not a known IBAN country: " + supplied country - ELIF NOT ( is valid := expected length = supplied length ) - THEN result := "Expected code length: " + whole( expected length, 0 ) - + " but actual length is: " + whole( supplied length, 0 ) - ELSE # OK so far - check the checksum # - STRING rearranged iban = iban[ LWB iban + 4 : ] + iban[ LWB iban : LWB iban + 3 ]; - LONG LONG INT numeric iban := 0; - FOR c pos FROM LWB rearranged iban TO UPB rearranged iban DO - CHAR c = rearranged iban[ c pos ]; - IF c >= "0" AND c <= "9" THEN - numeric iban *:= 10 +:= ( ABS c - ABS "0" ) - ELSE - numeric iban *:= 100 +:= ( ABS c - ABS "A" ) + 10 - FI - OD; - IF NOT ( is valid := numeric iban MOD 97 = 1 ) - THEN result := "Incorrect checksum" - FI - FI - FI - FI; - IF is valid THEN "" ELIF result = "" THEN "Unknown error" ELSE result FI - END # POSSIBLEIBAN # ; - - BEGIN # tests # - []STRING valid codes = ( "GB82 WEST 1234 5698 7654 32", "GB82WEST12345698765432" - , "GR16 0110 1250 0000 0001 2300 695", "GB29 NWBK 6016 1331 9268 19" - , "SA03 8000 0000 6080 1016 7519", "CH93 0076 2011 6238 5295 7" - , "IL62 0108 0000 0009 9999 999" - ); - []STRING invalid codes = ( "gb82 west 1234 5698 7654 32" # invalid characters # - , "GB82 TEST 1234 5698 7654 32" # invalid check digits # - , "IL62-0108-0000-0009-9999-999" # invalid characters # - , "US12 3456 7890 0987 6543 210" # invalid country code # - , "GR16 0110 1250 0000 0001 2300 695X" # invalid code length # - , "" # code is too short # - , "G2" # code is too short # - , "GB271" # invalid code length # - ); - FOR t pos FROM LWB valid codes TO UPB valid codes DO - STRING code = valid codes[ t pos ]; - STRING message = POSSIBLEIBAN code; - IF message = "" - THEN print( ( "Possible IBAN: ", code, newline ) ) - ELSE print( ( "INVALID IBAN: ", code, ": UNEXPECTED ERROR: ", message, newline ) ) - FI - OD; - FOR t pos FROM LWB invalid codes TO UPB invalid codes DO - STRING code = invalid codes[ t pos ]; - STRING message = POSSIBLEIBAN code; - IF message = "" - THEN print( ( "POSSIBLE IBAN: ", code, " BUT EXPECTED AN ERROR MESSAGE", newline ) ) - ELSE print( ( "Invalid IBAN: ", code, ": ", message, newline ) ) - FI - OD - END -END diff --git a/Task/IBAN/Ada/iban-1.adb b/Task/IBAN/Ada/iban-1.ada similarity index 100% rename from Task/IBAN/Ada/iban-1.adb rename to Task/IBAN/Ada/iban-1.ada diff --git a/Task/IBAN/Ada/iban-2.adb b/Task/IBAN/Ada/iban-2.ada similarity index 100% rename from Task/IBAN/Ada/iban-2.adb rename to Task/IBAN/Ada/iban-2.ada diff --git a/Task/IBAN/Ada/iban-3.adb b/Task/IBAN/Ada/iban-3.ada similarity index 100% rename from Task/IBAN/Ada/iban-3.adb rename to Task/IBAN/Ada/iban-3.ada diff --git a/Task/IBAN/BQN/iban.bqn b/Task/IBAN/BQN/iban.bqn deleted file mode 100644 index b2f46623bc..0000000000 --- a/Task/IBAN/BQN/iban.bqn +++ /dev/null @@ -1,4 +0,0 @@ -sym ← ∾"0A"+⟜↕¨10‿26 -CheckIBAN ← 1=·(97|⊣+(10⋆1+>⟜9)⊸×)´∘⌽4⌽36(>/⊢)sym⊸⊐ - -CheckIBAN "GB82 WEST 1234 5698 7654 32" diff --git a/Task/IBAN/COBOL/iban.cob b/Task/IBAN/COBOL/iban.cobol similarity index 100% rename from Task/IBAN/COBOL/iban.cob rename to Task/IBAN/COBOL/iban.cobol diff --git a/Task/IBAN/EasyLang/iban.easy b/Task/IBAN/EasyLang/iban.easy deleted file mode 100644 index 161c31d836..0000000000 --- a/Task/IBAN/EasyLang/iban.easy +++ /dev/null @@ -1,63 +0,0 @@ -cc$[] = [ "AD" "AE" "AL" "AO" "AT" "AZ" "BA" "BE" "BF" "BG" "BH" "BI" "BJ" "BR" "CG" "CH" "CI" "CM" "CR" "CV" "CY" "CZ" "DE" "DK" "DO" "DZ" "EE" "EG" "ES" "FI" "FO" "FR" "GA" "GB" "GE" "GI" "GL" "GR" "GT" "HR" "HU" "IE" "IL" "IR" "IS" "IT" "JO" "KW" "KZ" "LB" "LI" "LT" "LU" "LV" "MC" "MD" "ME" "MG" "MK" "ML" "MR" "MT" "MU" "MZ" "NL" "NO" "PK" "PL" "PS" "PT" "QA" "RO" "RS" "SA" "SE" "SI" "SK" "SM" "SN" "TN" "TR" "UA" "VG" ] -ln[] = [ 24 23 28 25 20 28 20 16 27 22 22 16 28 29 27 21 28 27 21 25 28 24 22 18 28 24 20 27 24 18 18 27 27 22 22 23 18 27 28 21 28 22 23 26 26 27 30 30 20 28 21 20 20 21 27 24 22 27 19 28 27 31 30 25 18 15 24 28 29 25 29 24 22 24 24 19 24 27 28 24 26 29 24 ] -# -func validcc iban$ . - c$ = substr iban$ 1 2 - for i to len cc$[] - if c$ = cc$[i] - return if len iban$ = ln[i] - . - . - return 0 -. -func mod97 s$ . - while s$ <> "" - h$ = r div 10 - h$ &= r mod 10 - h$ &= substr s$ 1 13 - s$ = substr s$ 14 9999 - r = number h$ mod 97 - . - return r -. -func isvalid hiban$ . - for c$ in strchars hiban$ - c = strcode c$ - if c > 32 - if c >= 97 and c < 122 - c -= 32 - c$ = strchar c - elif c < 48 or c > 57 and c < 65 or c > 90 - return 0 - . - miban$ &= c$ - . - . - if validcc miban$ = 0 - return 0 - . - for c$ in strchars substr miban$ 5 999 & substr miban$ 1 4 - c = strcode c$ - if c >= 65 and c <= 90 - t$ &= (c - 55) div 10 - t$ &= (c - 55) mod 10 - else - t$ &= c$ - . - . - return if mod97 t$ = 1 -. -proc check s$ . - write s$ & " is " - if isvalid s$ = 1 - print "valid" - else - print "not valid" - . -. -check "GB82 WEST 1234 5698 7654 32" -check "GB82WEST12345698765432" -check "gb82 west 1234 5698 7654 32" -check "GB82 TEST 1234 5698 7654 32" -check "GB82 WEST 1243 5698 7654 32" -check "GB82 west 1243 5698 7654 32" diff --git a/Task/IBAN/Elixir/iban.ex b/Task/IBAN/Elixir/iban.elixir similarity index 100% rename from Task/IBAN/Elixir/iban.ex rename to Task/IBAN/Elixir/iban.elixir diff --git a/Task/IBAN/Free-Pascal-Lazarus/iban.pas b/Task/IBAN/Free-Pascal/iban.pas similarity index 100% rename from Task/IBAN/Free-Pascal-Lazarus/iban.pas rename to Task/IBAN/Free-Pascal/iban.pas diff --git a/Task/IBAN/Julia/iban.jl b/Task/IBAN/Julia/iban.julia similarity index 100% rename from Task/IBAN/Julia/iban.jl rename to Task/IBAN/Julia/iban.julia diff --git a/Task/IBAN/Kotlin/iban-1.kts b/Task/IBAN/Kotlin/iban-1.kotlin similarity index 100% rename from Task/IBAN/Kotlin/iban-1.kts rename to Task/IBAN/Kotlin/iban-1.kotlin diff --git a/Task/IBAN/Kotlin/iban-2.kts b/Task/IBAN/Kotlin/iban-2.kotlin similarity index 100% rename from Task/IBAN/Kotlin/iban-2.kts rename to Task/IBAN/Kotlin/iban-2.kotlin diff --git a/Task/IBAN/OCaml/iban.ml b/Task/IBAN/OCaml/iban.ocaml similarity index 100% rename from Task/IBAN/OCaml/iban.ml rename to Task/IBAN/OCaml/iban.ocaml diff --git a/Task/IBAN/Oberon/iban.oberon b/Task/IBAN/Oberon-2/iban.oberon similarity index 100% rename from Task/IBAN/Oberon/iban.oberon rename to Task/IBAN/Oberon-2/iban.oberon diff --git a/Task/IBAN/PascalABC.NET/iban.pas b/Task/IBAN/PascalABC.NET/iban.pas deleted file mode 100644 index ad59a4e740..0000000000 --- a/Task/IBAN/PascalABC.NET/iban.pas +++ /dev/null @@ -1,33 +0,0 @@ -var - countryLen := Dict( - ('AL', 28), ('AD', 24), ('AT', 20), ('AZ', 28), ('BE', 16), ('BH', 22), ('BA', 20), ('BR', 29), - ('BG', 22), ('CR', 21), ('HR', 21), ('CY', 28), ('CZ', 24), ('DK', 18), ('DO', 28), ('EE', 20), - ('FO', 18), ('FI', 18), ('FR', 27), ('GE', 22), ('DE', 22), ('GI', 23), ('GR', 27), ('GL', 18), - ('GT', 28), ('HU', 28), ('IS', 26), ('IE', 22), ('IL', 23), ('IT', 27), ('KZ', 20), ('KW', 30), - ('LV', 21), ('LB', 28), ('LI', 21), ('LT', 20), ('LU', 20), ('MK', 19), ('MT', 31), ('MR', 27), - ('MU', 30), ('MC', 27), ('MD', 24), ('ME', 22), ('NL', 18), ('NO', 15), ('PK', 24), ('PS', 29), - ('PL', 28), ('PT', 25), ('RO', 24), ('SM', 27), ('SA', 24), ('RS', 22), ('SK', 24), ('SI', 19), - ('ES', 24), ('SE', 24), ('CH', 21), ('TN', 24), ('TR', 26), ('AE', 23), ('GB', 22), ('VG', 24)); - -function validIban(iban: string): boolean; -begin - result := False; - iban := iban.Replace(' ', '').Replace(#9, ''); - if not iban.All(c -> c.isupper or c.isdigit) then exit; - - if iban.Length <> countryLen.Get(iban[1:3]) then exit; - - iban := iban[5:iban.Length + 1] + iban[1:5]; - var digits: string := ''; - foreach var ch in iban do - case ch of - '0'..'9': digits += ch; - 'A'..'Z': digits += (Ord(ch) - Ord('A') + 10).ToString; - end; - result := digits.ToBigInteger mod 97 = 1; -end; - -begin - foreach var account in |'GB82 WEST 1234 5698 7654 32', 'GB82 TEST 1234 5698 7654 32'| do - Println(account, 'validation is:', validIban(account)); -end. diff --git a/Task/IBAN/Phix/iban.phix b/Task/IBAN/Phix/iban.phix index 0d609477cd..63cedf18ed 100644 --- a/Task/IBAN/Phix/iban.phix +++ b/Task/IBAN/Phix/iban.phix @@ -1,56 +1,61 @@ --- demo\rosetta\IBAN.exw -constant nations = {{"AD",24}, -- Andorra - -- (full list in distro) - {"CH",21}, -- Switzerland - {"GB",22}, -- United Kingdom - {"SA",24}, -- Saudi Arabia - {"XK",20}} -- Kosovo +(phixonline)--> + -- + -- demo\rosetta\IBAN.exw + -- ===================== + -- + constant nations = {{"AD",24}, -- Andorra + -- (full list in distro) + {"CH",21}, -- Switzerland + {"GB",22}, -- United Kingdom + {"SA",24}, -- Saudi Arabia + {"XK",20}} -- Kosovo -constant {countries,lengths} = columnize(nations) + constant {countries,lengths} = columnize(nations) -function iban(string code) --- This routine does and should reject codes containing spaces etc. --- Use iban_s() below for otherwise. - integer country = find(code[1..2],countries) - if country!=0 - and length(code)=lengths[country] then - code = code[5..$]&code[1..4] - integer c = 0 - for i=1 to length(code) do - integer ch=code[i] - if ch>='0' and ch<='9' then - c = c*10+ch-'0' - elsif ch>='A' and ch<='Z' then - c = c*100+ch-55 - else - return false - end if - c = mod(c,97) - end for - return c=1 - end if - return false -end function + function iban(string code) + -- This routine does and should reject codes containing spaces etc. + -- Use iban_s() below for otherwise. + integer country = find(code[1..2],countries) + if country!=0 + and length(code)=lengths[country] then + code = code[5..$]&code[1..4] + integer c = 0 + for i=1 to length(code) do + integer ch=code[i] + if ch>='0' and ch<='9' then + c = c*10+ch-'0' + elsif ch>='A' and ch<='Z' then + c = c*100+ch-55 + else + return false + end if + c = mod(c,97) + end for + return c=1 + end if + return false + end function -function iban_s(string code) --- strips any embedded spaces and hyphens before validating. - code = substitute_all(code,{" ","-"},{"",""}) - return iban(code) -end function + function iban_s(string code) + -- strips any embedded spaces and hyphens before validating. + code = substitute_all(code,{" ","-"},{"",""}) + return iban(code) + end function -procedure test(string code, bool expected) - bool valid = iban_s(code) - string state - if valid=expected then - state = iff(valid?"ok":"invalid (as expected)") - else - state = iff(valid?"OK!!":"INVALID!!")&" (NOT AS EXPECTED)" - end if - printf(1,"%-34s :%s\n",{code,state}) -end procedure + procedure test(string code, bool expected) + bool valid = iban_s(code) + string state + if valid=expected then + state = iff(valid?"ok":"invalid (as expected)") + else + state = iff(valid?"OK!!":"INVALID!!")&" (NOT AS EXPECTED)" + end if + printf(1,"%-34s :%s\n",{code,state}) + end procedure -test("GB82 WEST 1234 5698 7654 32",true) -test("GB82 TEST 1234 5698 7654 32",false) -test("GB81 WEST 1234 5698 7654 32",false) -test("SA03 8000 0000 6080 1016 7519",true) -test("CH93 0076 2011 6238 5295 7",true) + test("GB82 WEST 1234 5698 7654 32",true) + test("GB82 TEST 1234 5698 7654 32",false) + test("GB81 WEST 1234 5698 7654 32",false) + test("SA03 8000 0000 6080 1016 7519",true) + test("CH93 0076 2011 6238 5295 7",true) + + with javascript_semantics + procedure check_isbn13(string isbn) + integer digits = 0, checksum = 0, w = 1 + for i=1 to length(isbn) do + integer ch = isbn[i] + if ch!=' ' and ch!='-' then + ch -= '0' + if ch<0 or ch>9 then checksum = 9 exit end if + checksum += ch*w + digits += 1 + w = 4-w + end if + end for + checksum = remainder(checksum,10) + string gb = iff(digits=13 and checksum=0 ? "good" : "bad") + printf(1,"%s: %s\n",{isbn,gb}) + end procedure -constant isbns = {"978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083", - "978-2-74839-908-0","978-2-74839-908-5","978 1 86197 876 9"} -for isbn in isbns do check_isbn13(isbn) end for + constant isbns = {"978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083", + "978-2-74839-908-0","978-2-74839-908-5","978 1 86197 876 9"} + for i=1 to length(isbns) do check_isbn13(isbns[i]) end for + { Number in 0..9, Number #= Number0 - 48 }, digit(Number0). - -isbn13 --> - sequence(base10_digit, [D1, D2, D3]), "-", - sequence(base10_digit, [D4, D5, D6, D7, D8, D9, D10, D11, D12, D13]), - { ( D1 + 3 * D2 + D3 + 3 * D4 + - D5 + 3 * D6 + D7 + 3 * D8 + - D9 + 3 * D10 + D11 + 3 * D12 + D13 ) mod 10 #= 0 }. diff --git a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro deleted file mode 100644 index 7f3a3f0e20..0000000000 --- a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro +++ /dev/null @@ -1,11 +0,0 @@ -?- phrase(isbn13, "978-0596528126"). -true. - -?- phrase(isbn13, "978-0596528120"). -false. - -?- phrase(isbn13, "978-1788399081"). -true. - -?- phrase(isbn13, "978-1788399083"). -false. diff --git a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro deleted file mode 100644 index 7225eeca85..0000000000 --- a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro +++ /dev/null @@ -1,12 +0,0 @@ -?- ISBN = [0'9, 0'7, 0'8, 0'-, 0'0, 0'3, 0'0, 0'6, 0'4, 0'0, _, _, 0'5, 0'7], phrase(isbn13, ISBN). -ISBN = "978-0306400957" ; -ISBN = "978-0306401657" ; -ISBN = "978-0306402357" ; -ISBN = "978-0306403057" ; -ISBN = "978-0306404757" ; -ISBN = "978-0306405457" ; -ISBN = "978-0306406157" ; -ISBN = "978-0306407857" ; -ISBN = "978-0306408557" ; -ISBN = "978-0306409257" ; -false. diff --git a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro deleted file mode 100644 index 0b5d9cc7dc..0000000000 --- a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro +++ /dev/null @@ -1,12 +0,0 @@ -?- phrase(isbn13, ISBN). -ISBN = "000-0000000000" ; -ISBN = "000-0000000017" ; -ISBN = "000-0000000024" ; -ISBN = "000-0000000031" ; -ISBN = "000-0000000048" ; -ISBN = "000-0000000055" ; -ISBN = "000-0000000062" ; -ISBN = "000-0000000079" ; -ISBN = "000-0000000086" ; -ISBN = "000-0000000093" ; -ISBN = "000-0000000109" . % etc... diff --git a/Task/ISBN13-check-digit/PureBasic/isbn13-check-digit.basic b/Task/ISBN13-check-digit/PureBasic/isbn13-check-digit.basic index 844f77dc0d..f27c87fe3e 100644 --- a/Task/ISBN13-check-digit/PureBasic/isbn13-check-digit.basic +++ b/Task/ISBN13-check-digit/PureBasic/isbn13-check-digit.basic @@ -13,8 +13,8 @@ Procedure.b IsISBN13(ISBN13.s) EndProcedure If OpenConsole() - TestISBN13("978-0596528126") - TestISBN13("978-0596528120") + TestISBN13("978-1734314502") + TestISBN13("978-1734314509") TestISBN13("978-1788399081") TestISBN13("978-1788399083") Input() diff --git a/Task/ISBN13-check-digit/Python/isbn13-check-digit-1.py b/Task/ISBN13-check-digit/Python/isbn13-check-digit-1.py index 6afe0ad879..b2a2a8bf08 100644 --- a/Task/ISBN13-check-digit/Python/isbn13-check-digit-1.py +++ b/Task/ISBN13-check-digit/Python/isbn13-check-digit-1.py @@ -8,8 +8,8 @@ def is_isbn13(n): if __name__ == '__main__': tests = ''' -978-0596528126 -978-0596528120 +978-1734314502 +978-1734314509 978-1788399081 978-1788399083'''.strip().split() for t in tests: diff --git a/Task/ISBN13-check-digit/Python/isbn13-check-digit-2.py b/Task/ISBN13-check-digit/Python/isbn13-check-digit-2.py index 14147d2576..106ea857a8 100644 --- a/Task/ISBN13-check-digit/Python/isbn13-check-digit-2.py +++ b/Task/ISBN13-check-digit/Python/isbn13-check-digit-2.py @@ -28,8 +28,8 @@ def main(): print('\n'.join( repr((s, isISBN13(s))) for s - in ["978-0596528126", - "978-0596528120", + in ["978-1734314502", + "978-1734314509", "978-1788399081", "978-1788399083" ] diff --git a/Task/ISBN13-check-digit/Quackery/isbn13-check-digit.quackery b/Task/ISBN13-check-digit/Quackery/isbn13-check-digit.quackery index 3a2466d98e..0511932043 100644 --- a/Task/ISBN13-check-digit/Quackery/isbn13-check-digit.quackery +++ b/Task/ISBN13-check-digit/Quackery/isbn13-check-digit.quackery @@ -26,7 +26,7 @@ iff [ say "Good" ] else [ say "Bad" ] cr ] is isbn-test ( $ --> ) -$ '978-0596528126' isbn-test -$ '978-0596528120' isbn-test +$ '978-1734314502' isbn-test +$ '978-1734314509' isbn-test $ '978-1788399081' isbn-test $ '978-1788399083' isbn-test diff --git a/Task/ISBN13-check-digit/R/isbn13-check-digit.r b/Task/ISBN13-check-digit/R/isbn13-check-digit.r deleted file mode 100644 index 971ee0438e..0000000000 --- a/Task/ISBN13-check-digit/R/isbn13-check-digit.r +++ /dev/null @@ -1,28 +0,0 @@ -isbncheck <- function(str) { - # Remove non-digit characters - digits <- gsub("\\D", "", str) - - # Split into individual characters and convert to numeric - digit_vec <- as.numeric(strsplit(digits, "")[[1]]) - - # Calculate weighted sum - weighted_sum <- sum(sapply(seq_along(digit_vec), function(i) { - if (i %% 2 == 0) { - 3 * digit_vec[i] - } else { - digit_vec[i] - } - })) - - # Check if divisible by 10 - return(weighted_sum %% 10 == 0) -} - -# Test codes -testing_codes <- c("978-0596528126", "978-0596528120", - "978-1788399081", "978-1788399083") - -for (code in testing_codes) { - result <- ifelse(isbncheck(code), "good", "bad") - cat(code, ": ", result, "\n", sep = "") -} diff --git a/Task/ISBN13-check-digit/REXX/isbn13-check-digit.rexx b/Task/ISBN13-check-digit/REXX/isbn13-check-digit.rexx index cfb6e8d470..ac2bb1acc9 100644 --- a/Task/ISBN13-check-digit/REXX/isbn13-check-digit.rexx +++ b/Task/ISBN13-check-digit/REXX/isbn13-check-digit.rexx @@ -1,6 +1,6 @@ /*REXX pgm validates the check digit of an ISBN─13 code (it may have embedded minuses).*/ parse arg $ /*obtain optional arguments from the CL*/ -if $='' | if $="," then $= '978-0596528126 978-0596528120 978-1788399081 978-1788399083' +if $='' | if $="," then $= '978-1734314502 978-1734314509 978-1788399081 978-1788399083' @ISBN= "ISBN─13 code isn't" /*a literal used when displaying msgs. */ /* [↓] remove all minuses from X code.*/ do j=1 for words($); y= word($,j) /*obtain an ISBN─13 code from $ list.*/ diff --git a/Task/ISBN13-check-digit/Racket/isbn13-check-digit.rkt b/Task/ISBN13-check-digit/Racket/isbn13-check-digit.rkt index 3b0f0f3f63..3c0cadc63c 100644 --- a/Task/ISBN13-check-digit/Racket/isbn13-check-digit.rkt +++ b/Task/ISBN13-check-digit/Racket/isbn13-check-digit.rkt @@ -9,7 +9,7 @@ (module+ test (require rackunit) - (check-true (isbn13-check-digit-valid? "978-0596528126")) - (check-false (isbn13-check-digit-valid? "978-0596528120")) + (check-true (isbn13-check-digit-valid? "978-1734314502")) + (check-false (isbn13-check-digit-valid? "978-1734314509")) (check-true (isbn13-check-digit-valid? "978-1788399081")) (check-false (isbn13-check-digit-valid? "978-1788399083"))) diff --git a/Task/ISBN13-check-digit/Raku/isbn13-check-digit.raku b/Task/ISBN13-check-digit/Raku/isbn13-check-digit.raku index a5a76b6df9..88e9fdc77d 100644 --- a/Task/ISBN13-check-digit/Raku/isbn13-check-digit.raku +++ b/Task/ISBN13-check-digit/Raku/isbn13-check-digit.raku @@ -9,8 +9,8 @@ sub check-digit ($isbn) { 'Good' !! "Bad check-digit $check; should be $check-digit" } for words < - 978-0596528126 - 978-0596528120 + 978-1734314502 + 978-1734314509 978-1788399081 978-1788399083 978-2-74839-908-0 diff --git a/Task/ISBN13-check-digit/Rebol/isbn13-check-digit.rebol b/Task/ISBN13-check-digit/Rebol/isbn13-check-digit.rebol deleted file mode 100644 index 568cd2a141..0000000000 --- a/Task/ISBN13-check-digit/Rebol/isbn13-check-digit.rebol +++ /dev/null @@ -1,27 +0,0 @@ -Rebol [ - title: "Rosetta code: ISBN13 check digit" - file: %ISBN13_check_digit.r3 - url: https://rosettacode.org/wiki/ISBN13_check_digit - needs: 3.15.0 ;; or something like that -] -valid-isbn13?: function/with [ - "Validate the check digit of an ISBN-13 code" - value [any-string!] -][ - sum: 0 - parse value [ - 6 [ - to numeric set n: skip (sum: sum + n - #"0") ;; Add digit at odd index (weight 1) - to numeric set n: skip (sum: sum + (3 * (n - #"0"))) ;; Add digit at even index (weight 3) - ] - to numeric set n: skip (sum: sum + n - #"0") ;; Add the 13th digit (weight 1) - opt [to numeric (return false)] ;; If not exactly 13 digits, abort as invalid - ] - zero? (sum % 10) ;; Valid if weighted sum is divisible by 10 -] system/catalog/bitsets ;; Supply numeric bitset for parse (matches digits) - - -;; Check given examples -foreach [str] ["978-0596528126" "978-0596528120" "978-1788399081" "978-1788399083" "978-2-74839-908-0"] [ - print [pad str 18 "-" valid-isbn13? str] -] diff --git a/Task/ISBN13-check-digit/Red/isbn13-check-digit.red b/Task/ISBN13-check-digit/Red/isbn13-check-digit.red index ac16d0ea46..405e8b0f3b 100644 --- a/Task/ISBN13-check-digit/Red/isbn13-check-digit.red +++ b/Task/ISBN13-check-digit/Red/isbn13-check-digit.red @@ -16,7 +16,7 @@ check_valid_isbn13: function [str] [ ] ; check given examples -foreach [str] ["978-0596528126" "978-0596528120" "978-1788399081" "978-1788399083"] [ +foreach [str] ["978-1734314502" "978-1734314509" "978-1788399081" "978-1788399083"] [ prin str prin " - " print check_valid_isbn13 str diff --git a/Task/ISBN13-check-digit/Refal/isbn13-check-digit.refal b/Task/ISBN13-check-digit/Refal/isbn13-check-digit.refal deleted file mode 100644 index c0720f93be..0000000000 --- a/Task/ISBN13-check-digit/Refal/isbn13-check-digit.refal +++ /dev/null @@ -1,46 +0,0 @@ -$ENTRY Go { - = - - - -}; - -Test { - e.X = >; -}; - -ISBN { - e.X, : e.DS, - : { - False = Bad; - True = ; - }; -}; - -ISBN1 { - (13 s.Sum), : 0 = Good; - (13 s.Sum) e.X = Bad; - (s.N s.Sum) = Bad; - - (s.N s.Sum) s.D e.X, - <+ s.N 1>: s.N1, - : s.V, - : { - 0 = ) e.X>; - 1 = >) e.X>; - }; - - e.X = ; -}; - -Remove { - s.1 = ; - s.1 s.1 e.X = ; - s.1 s.2 e.X = s.2 ; -}; - -CheckDigits { - = True; - s.D e.X, '0123456789': e.A s.D e.B = ; - e.X = False; -}; diff --git a/Task/ISBN13-check-digit/Ring/isbn13-check-digit.ring b/Task/ISBN13-check-digit/Ring/isbn13-check-digit.ring index 98958ab94a..d6c5e41207 100644 --- a/Task/ISBN13-check-digit/Ring/isbn13-check-digit.ring +++ b/Task/ISBN13-check-digit/Ring/isbn13-check-digit.ring @@ -1,6 +1,6 @@ load "stdlib.ring" -isbn = ["978-0596528126","978-0596528120", "978-1788399081", "978-1788399083","978-2-74839-908-0","978-2-74839-908-5","978 1 86197 876 9"] +isbn = ["978-1734314502","978-1734314509", "978-1788399081", "978-1788399083","978-2-74839-908-0","978-2-74839-908-5","978 1 86197 876 9"] for n = 1 to len(isbn) sum = 0 diff --git a/Task/ISBN13-check-digit/Ruby/isbn13-check-digit.rb b/Task/ISBN13-check-digit/Ruby/isbn13-check-digit.rb index d46e18462d..f734cdfdf6 100644 --- a/Task/ISBN13-check-digit/Ruby/isbn13-check-digit.rb +++ b/Task/ISBN13-check-digit/Ruby/isbn13-check-digit.rb @@ -4,5 +4,5 @@ def validISBN13?(str) cleaned.each_slice(2).sum{|d1, d2| d1.to_i + 3*d2.to_i }.remainder(10) == 0 end -isbns = ["978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083"] +isbns = ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083"] isbns.each{|isbn| puts "#{isbn}: #{validISBN13?(isbn)}" } diff --git a/Task/ISBN13-check-digit/Rust/isbn13-check-digit.rs b/Task/ISBN13-check-digit/Rust/isbn13-check-digit.rs deleted file mode 100644 index 081a5323e7..0000000000 --- a/Task/ISBN13-check-digit/Rust/isbn13-check-digit.rs +++ /dev/null @@ -1,14 +0,0 @@ -fn main() { - let isbns = ["978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083"]; - isbns.iter().for_each(|isbn| println!("{}: {}", isbn, check_isbn(isbn))); -} - -fn check_isbn(isbn: &str) -> bool { - if isbn.chars().filter(|c| c.is_digit(10)).count() != 13 { - return false; - } - let checksum = isbn.chars().filter_map(|c| c.to_digit(10)) - .zip([1, 3].iter().cycle()) - .fold(0, |acc, (val, fac)| acc + val * fac); - checksum % 10 == 0 -} diff --git a/Task/ISBN13-check-digit/Rust/isbn13-check-digit.rust b/Task/ISBN13-check-digit/Rust/isbn13-check-digit.rust new file mode 100644 index 0000000000..76efbed13f --- /dev/null +++ b/Task/ISBN13-check-digit/Rust/isbn13-check-digit.rust @@ -0,0 +1,14 @@ +fn main() { + let isbns = ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083"]; + isbns.iter().for_each(|isbn| println!("{}: {}", isbn, check_isbn(isbn))); +} + +fn check_isbn(isbn: &str) -> bool { + if isbn.chars().filter(|c| c.is_digit(10)).count() != 13 { + return false; + } + let checksum = isbn.chars().filter_map(|c| c.to_digit(10)) + .zip([1, 3].iter().cycle()) + .fold(0, |acc, (val, fac)| acc + val * fac); + checksum % 10 == 0 +} diff --git a/Task/ISBN13-check-digit/SETL/isbn13-check-digit.setl b/Task/ISBN13-check-digit/SETL/isbn13-check-digit.setl deleted file mode 100644 index 30d4490ddc..0000000000 --- a/Task/ISBN13-check-digit/SETL/isbn13-check-digit.setl +++ /dev/null @@ -1,22 +0,0 @@ -program isbn13; - loop for test in [ - "978-0596528126", "978-0596528120", - "978-1788399081", "978-1788399083" - ] do - print(test + if valid_isbn13 test then ": good" else ": bad" end); - end loop; - - op valid_isbn13(isbn); - if #isbn /= 14 - or isbn(4) /= '-' - or exists c in isbn | not c in "0123456789-" then - return false; - end if; - - m := 3; - loop for ch in isbn | ch in "0123456789" do - s +:= val ch * (m := 4 - m); - end loop; - return s mod 10 = 0; - end op; -end program; diff --git a/Task/ISBN13-check-digit/Scala/isbn13-check-digit.scala b/Task/ISBN13-check-digit/Scala/isbn13-check-digit.scala deleted file mode 100644 index 910add1d43..0000000000 --- a/Task/ISBN13-check-digit/Scala/isbn13-check-digit.scala +++ /dev/null @@ -1,26 +0,0 @@ -object ISBNValidator: - private def checkChecksum(isbn: String): Boolean = - val digits = isbn.map(_.asDigit) - val checksum = digits.zipWithIndex.map { - case (digit, idx) => - if idx % 2 == 0 then digit - else digit * 3 - }.sum - checksum % 10 == 0 - - def isValidISBN13(isbn: String): Boolean = - val cleaned = isbn.filter(_.isDigit) - cleaned.length == 13 && checkChecksum(cleaned) - -@main def main(): Unit = - def test(isbn: String): Unit = - val result = ISBNValidator.isValidISBN13(isbn) - println(s"$isbn: $result") - - List( - "978-0596528126", - "978-0596528120", - "978-1788399081", - "978-1788399083" - ) - .foreach(test) diff --git a/Task/ISBN13-check-digit/Seed7/isbn13-check-digit.seed7 b/Task/ISBN13-check-digit/Seed7/isbn13-check-digit.seed7 index 9d29803ea3..f9553006ec 100644 --- a/Task/ISBN13-check-digit/Seed7/isbn13-check-digit.seed7 +++ b/Task/ISBN13-check-digit/Seed7/isbn13-check-digit.seed7 @@ -28,7 +28,7 @@ const proc: main is func local var string: str is ""; begin - for str range [] ("978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083") do + for str range [] ("978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083") do writeln(str <& ": " <& isISBN13(str)); end for; end func; diff --git a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml deleted file mode 100644 index 55acb3f3db..0000000000 --- a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml +++ /dev/null @@ -1,22 +0,0 @@ -(* these type decorations are optional, you could just as well put: - fun isValidISBN s = -*) -fun isValidISBN (s : string) : bool = - let - val digits = List.filter Char.isDigit (explode s) - val nums = map (fn x => ord x - ord #"0") digits - val len = length nums - fun sumISBN [] = raise Domain - | sumISBN [x] = x - | sumISBN (x1::x2::xs) = x1 + 3*x2 + sumISBN xs - in - len = 13 andalso sumISBN nums mod 10 = 0 - end - -val test = ["978-1734314502", "978-1734314509", - "978-1788399081", "978-1788399083"] - -fun printTest (s : string) : unit = - (print s; print (if isValidISBN s then ": good\n" else ": bad\n")) - -fun main () = app printTest test diff --git a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-2.ml b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-2.ml deleted file mode 100644 index c81cfd25c5..0000000000 --- a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-2.ml +++ /dev/null @@ -1,15 +0,0 @@ -let - fun check (c, p as (m, n)) = - if Char.isDigit c then - (not m, (if m then 3 * (ord c - 48) else ord c - 48) + n) - else - p -in - fun checkISBN s = - Int.rem (#2 (CharVector.foldl check (false, 0) s), 10) = 0 -end - -val test = ["978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083"] -val () = (print - o concat - o map (fn s => s ^ (if checkISBN s then ": good\n" else ": bad\n"))) test diff --git a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit.ml b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit.ml new file mode 100644 index 0000000000..3ea0737bff --- /dev/null +++ b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit.ml @@ -0,0 +1,15 @@ +local + fun check (c, p as (m, n)) = + if Char.isDigit c then + (not m, (if m then 3 * (ord c - 48) else ord c - 48) + n) + else + p +in + fun checkISBN s = + Int.rem (#2 (CharVector.foldl check (false, 0) s), 10) = 0 +end + +val test = ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083"] +val () = (print + o concat + o map (fn s => s ^ (if checkISBN s then ": good\n" else ": bad\n"))) test diff --git a/Task/ISBN13-check-digit/Swift/isbn13-check-digit.swift b/Task/ISBN13-check-digit/Swift/isbn13-check-digit.swift index b5c70229ac..cefe08f9fb 100644 --- a/Task/ISBN13-check-digit/Swift/isbn13-check-digit.swift +++ b/Task/ISBN13-check-digit/Swift/isbn13-check-digit.swift @@ -13,8 +13,8 @@ func checkISBN(isbn: String) -> Bool { } let cases = [ - "978-0596528126", - "978-0596528120", + "978-1734314502", + "978-1734314509", "978-1788399081", "978-1788399083" ] diff --git a/Task/ISBN13-check-digit/Tcl/isbn13-check-digit-1.tcl b/Task/ISBN13-check-digit/Tcl/isbn13-check-digit-1.tcl index 9a8d8f0d03..6dfa79dbbb 100644 --- a/Task/ISBN13-check-digit/Tcl/isbn13-check-digit-1.tcl +++ b/Task/ISBN13-check-digit/Tcl/isbn13-check-digit-1.tcl @@ -12,8 +12,8 @@ proc validISBN13 code { return false } foreach test { - 978-0596528126 - 978-0596528120 + 978-1734314502 + 978-1734314509 978-1788399081 978-1788399083 } {puts $test:[validISBN13 $test]} diff --git a/Task/ISBN13-check-digit/UNIX-Shell/isbn13-check-digit.sh b/Task/ISBN13-check-digit/UNIX-Shell/isbn13-check-digit.sh index 301b5984c7..c0de8e51b3 100644 --- a/Task/ISBN13-check-digit/UNIX-Shell/isbn13-check-digit.sh +++ b/Task/ISBN13-check-digit/UNIX-Shell/isbn13-check-digit.sh @@ -8,7 +8,7 @@ check_isbn13 () { (( 0 == t % 10 )) } -for isbn in 978-0596528126 978-0596528120 978-1788399081 978-1788399083; do +for isbn in 978-1734314502 978-1734314509 978-1788399081 978-1788399083; do printf '%s: ' "$isbn" if check_isbn13 "$isbn"; then printf '%s\n' OK diff --git a/Task/ISBN13-check-digit/V-(Vlang)/isbn13-check-digit.v b/Task/ISBN13-check-digit/V-(Vlang)/isbn13-check-digit.v index da68e4c3de..fdaef1252b 100644 --- a/Task/ISBN13-check-digit/V-(Vlang)/isbn13-check-digit.v +++ b/Task/ISBN13-check-digit/V-(Vlang)/isbn13-check-digit.v @@ -22,7 +22,7 @@ fn check_isbn13(isbn13 string) bool { } fn main() { - isbns := ["978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083"] + isbns := ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083"] for isbn in isbns { mut res := "bad" if check_isbn13(isbn) { diff --git a/Task/ISBN13-check-digit/Visual-Basic-.NET/isbn13-check-digit.vb b/Task/ISBN13-check-digit/Visual-Basic-.NET/isbn13-check-digit.vb index be6ff129a9..bdacc7a702 100644 --- a/Task/ISBN13-check-digit/Visual-Basic-.NET/isbn13-check-digit.vb +++ b/Task/ISBN13-check-digit/Visual-Basic-.NET/isbn13-check-digit.vb @@ -19,8 +19,8 @@ Module Module1 End Function Sub Main() - Console.WriteLine(CheckISBN13("978-0596528126")) - Console.WriteLine(CheckISBN13("978-0596528120")) + Console.WriteLine(CheckISBN13("978-1734314502")) + Console.WriteLine(CheckISBN13("978-1734314509")) Console.WriteLine(CheckISBN13("978-1788399081")) Console.WriteLine(CheckISBN13("978-1788399083")) End Sub diff --git a/Task/ISBN13-check-digit/Wren/isbn13-check-digit.wren b/Task/ISBN13-check-digit/Wren/isbn13-check-digit.wren index bca6ca7452..af45d2f2a2 100644 --- a/Task/ISBN13-check-digit/Wren/isbn13-check-digit.wren +++ b/Task/ISBN13-check-digit/Wren/isbn13-check-digit.wren @@ -15,7 +15,7 @@ var isbn13 = Fn.new { |s| return sum % 10 == 0 } -var tests = ["978-0596528126", "978-0596528120", "978-1788399081", "978-1788399083"] +var tests = ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083"] for (test in tests) { System.print("%(test) -> %(isbn13.call(test) ? "good" : "bad")") } diff --git a/Task/ISBN13-check-digit/XPL0/isbn13-check-digit.xpl0 b/Task/ISBN13-check-digit/XPL0/isbn13-check-digit.xpl0 index c2eaf4e120..e045aab504 100644 --- a/Task/ISBN13-check-digit/XPL0/isbn13-check-digit.xpl0 +++ b/Task/ISBN13-check-digit/XPL0/isbn13-check-digit.xpl0 @@ -18,8 +18,8 @@ Text(0, if rem(Sum/10)=0 & Cnt=13 then ": good" else ": bad"); CrLf(0); ]; -[ISBN13("978-0596528126"); - ISBN13("978-0596528120"); +[ISBN13("978-1734314502"); + ISBN13("978-1734314509"); ISBN13("978-1788399081"); ISBN13("978-1788399083"); ISBN13("978-1-59327-220-3"); diff --git a/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-1.zkl b/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-1.zkl index 4f8dc9bcbd..c4be69768b 100644 --- a/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-1.zkl +++ b/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-1.zkl @@ -1,4 +1,4 @@ -fcn ISBN13_check(isbn){ // "978-0596528126", throws on invalid digits +fcn ISBN13_check(isbn){ // "978-1734314502", throws on invalid digits var [const] one3=("13"*6 + 1).split("").apply("toInt"); // examine 13 digits // one3=("13"*6) if you want to calculate what the check digit should be one3.zipWith('*,isbn - " -").sum(0) % 10 == 0 diff --git a/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-2.zkl b/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-2.zkl index ea42f0f25a..c96ff21fd2 100644 --- a/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-2.zkl +++ b/Task/ISBN13-check-digit/Zkl/isbn13-check-digit-2.zkl @@ -1,7 +1,7 @@ isbns:= #<<<" - 978-0596528126 - 978-0596528120 + 978-1734314502 + 978-1734314509 978-1788399081 978-1788399083 978-2-74839-908-0 diff --git a/Task/Identity-matrix/Ada/identity-matrix-1.adb b/Task/Identity-matrix/Ada/identity-matrix-1.ada similarity index 100% rename from Task/Identity-matrix/Ada/identity-matrix-1.adb rename to Task/Identity-matrix/Ada/identity-matrix-1.ada diff --git a/Task/Identity-matrix/Ada/identity-matrix-2.adb b/Task/Identity-matrix/Ada/identity-matrix-2.ada similarity index 100% rename from Task/Identity-matrix/Ada/identity-matrix-2.adb rename to Task/Identity-matrix/Ada/identity-matrix-2.ada diff --git a/Task/Identity-matrix/Amazing-Hopper/identity-matrix.hopper b/Task/Identity-matrix/Amazing-Hopper/identity-matrix.hopper deleted file mode 100644 index 71c3a4df34..0000000000 --- a/Task/Identity-matrix/Amazing-Hopper/identity-matrix.hopper +++ /dev/null @@ -1,19 +0,0 @@ -#include - -Main - Dim( 10,10 ) as eyes 'UMatrix' - - Printnl ' "UNIT MATRIX:\n", UMatrix ' - - /* Classical method */ - - Dim (10,10) as zeros (ZM) - i=1 - Iterator ( ++i, #(i<=10), #( ZM[i,i]=1 ) ) - Printnl ' "UNIT MATRIX:\n", ZM ' - - /* unit matrix non square*/ - Dim ( 5,8 ) as eyes 'rare unit matrix' - - Printnl ' "RARE UNIT MATRIX:\n", rare unit matrix ' -End diff --git a/Task/Identity-matrix/Beads/identity-matrix.beads b/Task/Identity-matrix/Beads/identity-matrix.beads index 095255f228..5a440d7c66 100644 --- a/Task/Identity-matrix/Beads/identity-matrix.beads +++ b/Task/Identity-matrix/Beads/identity-matrix.beads @@ -1,10 +1,10 @@ beads 1 program 'Identity matrix' var - id : array^2 of num - n = 5 - + id : array^2 of num + n = 5 + calc main_init - loop from:1 to:n index:i - loop from:1 to:n index:j - id[i,j] = 1 if i == j else 0 + loop from:1 to:n index:i + loop from:1 to:n index:j + id[i,j] = 1 if i == j else 0 diff --git a/Task/Identity-matrix/Component-Pascal/identity-matrix.pas b/Task/Identity-matrix/Component-Pascal/identity-matrix.pas index 80e25dbec2..297f88e2d6 100644 --- a/Task/Identity-matrix/Component-Pascal/identity-matrix.pas +++ b/Task/Identity-matrix/Component-Pascal/identity-matrix.pas @@ -2,34 +2,34 @@ MODULE Algebras; IMPORT StdLog,Strings; TYPE - Matrix = POINTER TO ARRAY OF ARRAY OF INTEGER; - + Matrix = POINTER TO ARRAY OF ARRAY OF INTEGER; + PROCEDURE NewIdentityMatrix(n: INTEGER): Matrix; VAR - m: Matrix; - i: INTEGER; + m: Matrix; + i: INTEGER; BEGIN - NEW(m,n,n); - FOR i := 0 TO n - 1 DO - m[i,i] := 1; - END; - RETURN m; + NEW(m,n,n); + FOR i := 0 TO n - 1 DO + m[i,i] := 1; + END; + RETURN m; END NewIdentityMatrix; PROCEDURE Show(m: Matrix); VAR - i,j: INTEGER; + i,j: INTEGER; BEGIN - FOR i := 0 TO LEN(m,0) - 1 DO - FOR j := 0 TO LEN(m,1) - 1 DO - StdLog.Int(m[i,j]); - END; - StdLog.Ln - END + FOR i := 0 TO LEN(m,0) - 1 DO + FOR j := 0 TO LEN(m,1) - 1 DO + StdLog.Int(m[i,j]); + END; + StdLog.Ln + END END Show; PROCEDURE Do*; BEGIN - Show(NewIdentityMatrix(5)); + Show(NewIdentityMatrix(5)); END Do; END Algebras. diff --git a/Task/Identity-matrix/Delphi/identity-matrix.pas b/Task/Identity-matrix/Delphi/identity-matrix.delphi similarity index 100% rename from Task/Identity-matrix/Delphi/identity-matrix.pas rename to Task/Identity-matrix/Delphi/identity-matrix.delphi diff --git a/Task/Identity-matrix/DuckDB/identity-matrix.duckdb b/Task/Identity-matrix/DuckDB/identity-matrix.duckdb deleted file mode 100644 index 26cbc7a159..0000000000 --- a/Task/Identity-matrix/DuckDB/identity-matrix.duckdb +++ /dev/null @@ -1,20 +0,0 @@ -# Produce an (i,j,value) table representing the matrix I(m,n) -# which is the identity matrix if m = n -create or replace function I(m,n,zero) as table ( - with recursive cte(i,j,ij,value) as ( - select 1, 1, (null,null), zero - union all - select if(j=n, i+1, i) as i, - if(j=n, 1, j+1) as j, - (i, j) as ij, - zero + if(i=j, 1, 0) as value - from cte - where i <= m - ) - select ij[1] as i, ij[2] as j, value - from cte - offset 1 -); - -# Generate a 3x3 matrix with DOUBLE(3,2) values: -from I(3, 3, 0.000); diff --git a/Task/Identity-matrix/EasyLang/identity-matrix.easy b/Task/Identity-matrix/EasyLang/identity-matrix.easy deleted file mode 100644 index b85b3166c1..0000000000 --- a/Task/Identity-matrix/EasyLang/identity-matrix.easy +++ /dev/null @@ -1,9 +0,0 @@ -proc idmat lng &mat[][] . - len mat[][] lng - for i to lng - len mat[i][] lng - mat[i][i] = 1 - . -. -idmat 4 m[][] -print m[][] diff --git a/Task/Identity-matrix/Eiffel/identity-matrix.e b/Task/Identity-matrix/Eiffel/identity-matrix.e index 084a34437f..ffeeb3ee35 100644 --- a/Task/Identity-matrix/Eiffel/identity-matrix.e +++ b/Task/Identity-matrix/Eiffel/identity-matrix.e @@ -1,61 +1,61 @@ class - APPLICATION + APPLICATION inherit - ARGUMENTS + ARGUMENTS create - make + make feature {NONE} -- Initialization - make - -- Run application. - local - dim : INTEGER -- Dimension of the identity matrix - do - from dim := 1 until dim > 10 loop - print_matrix( identity_matrix(dim) ) - dim := dim + 1 - io.new_line - end + make + -- Run application. + local + dim : INTEGER -- Dimension of the identity matrix + do + from dim := 1 until dim > 10 loop + print_matrix( identity_matrix(dim) ) + dim := dim + 1 + io.new_line + end - end + end feature -- Access - identity_matrix(dim : INTEGER) : ARRAY2[REAL_64] + identity_matrix(dim : INTEGER) : ARRAY2[REAL_64] - require - dim > 0 - local - matrix : ARRAY2[REAL_64] - i : INTEGER - do + require + dim > 0 + local + matrix : ARRAY2[REAL_64] + i : INTEGER + do - create matrix.make_filled (0.0, dim, dim) - from i := 1 until i > dim loop - matrix.put(1.0, i, i) - i := i + 1 - end + create matrix.make_filled (0.0, dim, dim) + from i := 1 until i > dim loop + matrix.put(1.0, i, i) + i := i + 1 + end - Result := matrix - end + Result := matrix + end - print_matrix(matrix : ARRAY2[REAL_64]) - local - i, j : INTEGER - do - from i := 1 until i > matrix.height loop - print("[ ") - from j := 1 until j > matrix.width loop - print(matrix.item (i, j)) - print(" ") - j := j + 1 - end - print("]%N") - i := i + 1 - end - end + print_matrix(matrix : ARRAY2[REAL_64]) + local + i, j : INTEGER + do + from i := 1 until i > matrix.height loop + print("[ ") + from j := 1 until j > matrix.width loop + print(matrix.item (i, j)) + print(" ") + j := j + 1 + end + print("]%N") + i := i + 1 + end + end end diff --git a/Task/Identity-matrix/Elena/identity-matrix.elena b/Task/Identity-matrix/Elena/identity-matrix.elena index e02c88a428..661d1ef051 100644 --- a/Task/Identity-matrix/Elena/identity-matrix.elena +++ b/Task/Identity-matrix/Elena/identity-matrix.elena @@ -2,13 +2,13 @@ import extensions; import system'routines; import system'collections; -public Program() +public program() { - var n := console.write("Enter the matrix size:").readLine().toInt(); + var n := console.write:"Enter the matrix size:".readLine().toInt(); - var identity := new Range(0, n).selectBy::(i => new Range(0,n).selectBy::(j => (i == j).iif(1,0) ).summarize(new ArrayList())) + var identity := new Range(0, n).selectBy:(i => new Range(0,n).selectBy:(j => (i == j).iif(1,0) ).summarize(new ArrayList())) .summarize(new ArrayList()); - identity.forEach:: + identity.forEach: (row) { console.printLine(row.asEnumerable()) } } diff --git a/Task/Identity-matrix/Elixir/identity-matrix.ex b/Task/Identity-matrix/Elixir/identity-matrix.elixir similarity index 100% rename from Task/Identity-matrix/Elixir/identity-matrix.ex rename to Task/Identity-matrix/Elixir/identity-matrix.elixir diff --git a/Task/Identity-matrix/Excel/identity-matrix-2.excel b/Task/Identity-matrix/Excel/identity-matrix-2.excel deleted file mode 100644 index f72b963773..0000000000 --- a/Task/Identity-matrix/Excel/identity-matrix-2.excel +++ /dev/null @@ -1 +0,0 @@ -=MUNIT(A2) diff --git a/Task/Identity-matrix/Excel/identity-matrix-1.excel b/Task/Identity-matrix/Excel/identity-matrix.excel similarity index 100% rename from Task/Identity-matrix/Excel/identity-matrix-1.excel rename to Task/Identity-matrix/Excel/identity-matrix.excel diff --git a/Task/Identity-matrix/J/identity-matrix.j b/Task/Identity-matrix/J/identity-matrix.j index a87aa8e298..a209ace2c5 100644 --- a/Task/Identity-matrix/J/identity-matrix.j +++ b/Task/Identity-matrix/J/identity-matrix.j @@ -1,10 +1,10 @@ - =i.4 NB. create an Identity matrix of size 4 + = i. 4 NB. create an Identity matrix of size 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 - Id=: =@i. NB. define as a verb with a user-defined name - Id 5 NB. create an Identity matrix of size 5 + makeI=: =@i. NB. define as a verb with a user-defined name + makeI 5 NB. create an Identity matrix of size 5 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 diff --git a/Task/Identity-matrix/Julia/identity-matrix-1.jl b/Task/Identity-matrix/Julia/identity-matrix-1.julia similarity index 100% rename from Task/Identity-matrix/Julia/identity-matrix-1.jl rename to Task/Identity-matrix/Julia/identity-matrix-1.julia diff --git a/Task/Identity-matrix/Julia/identity-matrix-2.jl b/Task/Identity-matrix/Julia/identity-matrix-2.julia similarity index 100% rename from Task/Identity-matrix/Julia/identity-matrix-2.jl rename to Task/Identity-matrix/Julia/identity-matrix-2.julia diff --git a/Task/Identity-matrix/Julia/identity-matrix-3.jl b/Task/Identity-matrix/Julia/identity-matrix-3.julia similarity index 100% rename from Task/Identity-matrix/Julia/identity-matrix-3.jl rename to Task/Identity-matrix/Julia/identity-matrix-3.julia diff --git a/Task/Identity-matrix/Kotlin/identity-matrix.kotlin b/Task/Identity-matrix/Kotlin/identity-matrix.kotlin new file mode 100644 index 0000000000..8e873fc892 --- /dev/null +++ b/Task/Identity-matrix/Kotlin/identity-matrix.kotlin @@ -0,0 +1,17 @@ +// version 1.0.6 + +fun main(args: Array) { + print("Enter size of matrix : ") + val n = readLine()!!.toInt() + println() + val identity = Array(n) { IntArray(n) } // create n x n matrix of integers + + // enter 1s in diagonal elements + for(i in 0 until n) identity[i][i] = 1 + + // print identity matrix if n <= 40 + if (n <= 40) + for (i in 0 until n) println(identity[i].joinToString(" ")) + else + println("Matrix is too big to display on 80 column console") +} diff --git a/Task/Identity-matrix/Kotlin/identity-matrix.kts b/Task/Identity-matrix/Kotlin/identity-matrix.kts deleted file mode 100644 index 4b0278fd6e..0000000000 --- a/Task/Identity-matrix/Kotlin/identity-matrix.kts +++ /dev/null @@ -1,16 +0,0 @@ -fun main() { - print("Enter size of matrix : ") - val n = readln().toInt() - println() - val identity = Array(n) { i -> - IntArray(n) { j -> - if (i == j) 1 else 0 - } - } - - // print identity matrix if n <= 40 - if (n <= 40) - for (row in identity) println(row.joinToString(" ")) - else - println("Matrix is too big to display on 80 column console") -} diff --git a/Task/Identity-matrix/LSL/identity-matrix.lsl b/Task/Identity-matrix/LSL/identity-matrix.lsl index 92a0644c63..feec4fb3cc 100644 --- a/Task/Identity-matrix/LSL/identity-matrix.lsl +++ b/Task/Identity-matrix/LSL/identity-matrix.lsl @@ -1,19 +1,19 @@ default { - state_entry() { - llListen(PUBLIC_CHANNEL, "", llGetOwner(), ""); - llOwnerSay("Please Enter a Dimension for an Identity Matrix."); - } - listen(integer iChannel, string sName, key kId, string sMessage) { - llOwnerSay("You entered "+sMessage+"."); - list lMatrix = []; - integer x = 0; - integer n = (integer)sMessage; - for(x=0 ; x i = j ? 1 : 0); - matrix.Println -end. diff --git a/Task/Identity-matrix/Pluto/identity-matrix.pluto b/Task/Identity-matrix/Pluto/identity-matrix.pluto deleted file mode 100644 index 46f405c2cb..0000000000 --- a/Task/Identity-matrix/Pluto/identity-matrix.pluto +++ /dev/null @@ -1,4 +0,0 @@ -require "matrix" - -local num_rows = 10 -- say -print(matrix.identity(num_rows)) diff --git a/Task/Identity-matrix/PowerShell/identity-matrix-1.ps1 b/Task/Identity-matrix/PowerShell/identity-matrix-1.psh similarity index 100% rename from Task/Identity-matrix/PowerShell/identity-matrix-1.ps1 rename to Task/Identity-matrix/PowerShell/identity-matrix-1.psh diff --git a/Task/Identity-matrix/PowerShell/identity-matrix-2.ps1 b/Task/Identity-matrix/PowerShell/identity-matrix-2.psh similarity index 100% rename from Task/Identity-matrix/PowerShell/identity-matrix-2.ps1 rename to Task/Identity-matrix/PowerShell/identity-matrix-2.psh diff --git a/Task/Identity-matrix/Prolog/identity-matrix.pro b/Task/Identity-matrix/Prolog/identity-matrix.pro index 6397d9d7d0..94044cad1f 100644 --- a/Task/Identity-matrix/Prolog/identity-matrix.pro +++ b/Task/Identity-matrix/Prolog/identity-matrix.pro @@ -1,29 +1,29 @@ %rotates one list clockwise by one integer rotate(Int,List,Rotated) :- - integer(Int), - length(Suff,Int), - append(Pre,Suff,List), - append(Suff,Pre,Rotated). + integer(Int), + length(Suff,Int), + append(Pre,Suff,List), + append(Suff,Pre,Rotated). %rotates a list of lists by a list of integers rotate(LoInts,LoLists,Rotated) :- - is_list(LoInts), - maplist(rotate,LoInts,LoLists,Rotated). + is_list(LoInts), + maplist(rotate,LoInts,LoLists,Rotated). %helper function append_(Suff,Pre,List) :- - append([Pre],Suff,List). + append([Pre],Suff,List). idmatrix(N,IdMatrix):- - %make an N length list of 1s and append with N-1 0s - length(Ones,N), - maplist(=(1),Ones), - succ(N0,N), - length(Zeros,N0), - maplist(=(0),Zeros), - maplist(append_(Zeros),Ones,M), - %create the offsets at rotate each row - numlist(0,N0,Offsets), - rotate(Offsets,M,IdMatrix). + %make an N length list of 1s and append with N-1 0s + length(Ones,N), + maplist(=(1),Ones), + succ(N0,N), + length(Zeros,N0), + maplist(=(0),Zeros), + maplist(append_(Zeros),Ones,M), + %create the offsets at rotate each row + numlist(0,N0,Offsets), + rotate(Offsets,M,IdMatrix). main :- - idmatrix(5,I), - maplist(writeln,I). + idmatrix(5,I), + maplist(writeln,I). diff --git a/Task/Identity-matrix/Rebol/identity-matrix-1.rebol b/Task/Identity-matrix/Rebol/identity-matrix-1.rebol deleted file mode 100644 index 5260ef0941..0000000000 --- a/Task/Identity-matrix/Rebol/identity-matrix-1.rebol +++ /dev/null @@ -1,7 +0,0 @@ -identity-matrix: function[size [integer!]][ - matrix: array/initial reduce [size size] 0 - repeat i size [matrix/:i/:i: 1] - new-line/all matrix true - matrix -] -probe identity-matrix 5 diff --git a/Task/Identity-matrix/Rebol/identity-matrix-2.rebol b/Task/Identity-matrix/Rebol/identity-matrix-2.rebol deleted file mode 100644 index 02d78116c0..0000000000 --- a/Task/Identity-matrix/Rebol/identity-matrix-2.rebol +++ /dev/null @@ -1,9 +0,0 @@ -identity-matrix: function [size [integer!]][ - matrix: array/initial size * size 0 ;; Create a flat array with size^2 elements, all zeros - repeat i size [ - matrix/((i - 1) * size + i): 1 ;; Set 1 on the diagonal: row-major position - ] - new-line/skip matrix true size - matrix -] -probe identity-matrix 5 diff --git a/Task/Identity-matrix/Ring/identity-matrix-2.ring b/Task/Identity-matrix/Ring/identity-matrix-2.ring index 7c8f780d4a..4c2d938b39 100644 --- a/Task/Identity-matrix/Ring/identity-matrix-2.ring +++ b/Task/Identity-matrix/Ring/identity-matrix-2.ring @@ -18,30 +18,30 @@ LayoutButtonRow = list(size) app = new qApp { win = new qWidget() { - setWindowTitle('Identity Matrix') - move(500,100) - reSize(600,600) - winheight = win.height() - fontSize = 18 + (winheight / 100) + setWindowTitle('Identity Matrix') + move(500,100) + reSize(600,600) + winheight = win.height() + fontSize = 18 + (winheight / 100) - LayoutButtonMain = new QVBoxLayout() - LayoutButtonMain.setSpacing(C_Spacing) - LayoutButtonMain.setContentsmargins(0,0,0,0) + LayoutButtonMain = new QVBoxLayout() + LayoutButtonMain.setSpacing(C_Spacing) + LayoutButtonMain.setContentsmargins(0,0,0,0) - for Row = 1 to size - LayoutButtonRow[Row] = new QHBoxLayout() { - setSpacing(C_Spacing) - setContentsmargins(0,0,0,0) - } - for Col = 1 to size - Button[Row][Col] = new QPushButton(win) { + for Row = 1 to size + LayoutButtonRow[Row] = new QHBoxLayout() { + setSpacing(C_Spacing) + setContentsmargins(0,0,0,0) + } + for Col = 1 to size + Button[Row][Col] = new QPushButton(win) { setSizePolicy(1,1) - } - - LayoutButtonRow[Row].AddWidget(Button[Row][Col]) - next - LayoutButtonMain.AddLayout(LayoutButtonRow[Row]) - next + } + + LayoutButtonRow[Row].AddWidget(Button[Row][Col]) + next + LayoutButtonMain.AddLayout(LayoutButtonRow[Row]) + next LayoutDataRow1 = new QHBoxLayout() { setSpacing(C_Spacing) setContentsMargins(0,0,0,0) } LayoutButtonMain.AddLayout(LayoutDataRow1) setLayout(LayoutButtonMain) @@ -61,6 +61,6 @@ func pBegin() Button[Row][Col].setStyleSheet(C_ButtonBlueStyle) Button[Row][Col].settext("0") ok - next + next next score = 0 diff --git a/Task/Identity-matrix/Rust/identity-matrix.rs b/Task/Identity-matrix/Rust/identity-matrix.rust similarity index 100% rename from Task/Identity-matrix/Rust/identity-matrix.rs rename to Task/Identity-matrix/Rust/identity-matrix.rust diff --git a/Task/Identity-matrix/Scheme/identity-matrix-1.scm b/Task/Identity-matrix/Scheme/identity-matrix-1.scm deleted file mode 100644 index 7ed20ab33c..0000000000 --- a/Task/Identity-matrix/Scheme/identity-matrix-1.scm +++ /dev/null @@ -1,15 +0,0 @@ -(define (identity n) - (letrec - ((uvec - (lambda (m i acc) - (if (= i n) - acc - (uvec m (+ i 1) - (cons (if (= i m) 1 0) acc))))) - (idgen - (lambda (i acc) - (if (= i n) - acc - (idgen (+ i 1) - (cons (uvec i 0 '()) acc)))))) - (idgen 0 '()))) diff --git a/Task/Identity-matrix/Scheme/identity-matrix-1.ss b/Task/Identity-matrix/Scheme/identity-matrix-1.ss new file mode 100644 index 0000000000..fcd8fd0dcc --- /dev/null +++ b/Task/Identity-matrix/Scheme/identity-matrix-1.ss @@ -0,0 +1,15 @@ +(define (identity n) + (letrec + ((uvec + (lambda (m i acc) + (if (= i n) + acc + (uvec m (+ i 1) + (cons (if (= i m) 1 0) acc))))) + (idgen + (lambda (i acc) + (if (= i n) + acc + (idgen (+ i 1) + (cons (uvec i 0 '()) acc)))))) + (idgen 0 '()))) diff --git a/Task/Identity-matrix/Scheme/identity-matrix-2.scm b/Task/Identity-matrix/Scheme/identity-matrix-2.ss similarity index 100% rename from Task/Identity-matrix/Scheme/identity-matrix-2.scm rename to Task/Identity-matrix/Scheme/identity-matrix-2.ss diff --git a/Task/Identity-matrix/SenseTalk/identity-matrix.sensetalk b/Task/Identity-matrix/SenseTalk/identity-matrix.sensetalk index ece24bf611..5b8c568f1e 100644 --- a/Task/Identity-matrix/SenseTalk/identity-matrix.sensetalk +++ b/Task/Identity-matrix/SenseTalk/identity-matrix.sensetalk @@ -1,28 +1,28 @@ set matrix to buildIdentityMatrix(3) repeat for each item in matrix - put it + put it end repeat set matrix to buildIdentityMatrix(17) repeat for each item in matrix - put it + put it end repeat function buildIdentityMatrix matrixSize - set matrixList to () - repeat matrixSize times - set rowMatrixIndex to the counter - set rowMatrix to () - repeat matrixSize times - if the counter equals rowMatrixIndex - insert 1 after rowMatrix - else - insert 0 after rowMatrix - end if - end repeat - insert rowMatrix nested after matrixList - end repeat - return matrixList + set matrixList to () + repeat matrixSize times + set rowMatrixIndex to the counter + set rowMatrix to () + repeat matrixSize times + if the counter equals rowMatrixIndex + insert 1 after rowMatrix + else + insert 0 after rowMatrix + end if + end repeat + insert rowMatrix nested after matrixList + end repeat + return matrixList end buildIdentityMatrix diff --git a/Task/Identity-matrix/Sparkling/identity-matrix.sparkling b/Task/Identity-matrix/Sparkling/identity-matrix.sparkling index 7db205e1c4..ea0381bc1b 100644 --- a/Task/Identity-matrix/Sparkling/identity-matrix.sparkling +++ b/Task/Identity-matrix/Sparkling/identity-matrix.sparkling @@ -1,7 +1,7 @@ function unitMatrix(n) { - return map(range(n), function(k1, v1) { - return map(range(n), function(k2, v2) { - return v2 == v1 ? 1 : 0; - }); - }); + return map(range(n), function(k1, v1) { + return map(range(n), function(k2, v2) { + return v2 == v1 ? 1 : 0; + }); + }); } diff --git a/Task/Identity-matrix/Tailspin/identity-matrix-2.tailspin b/Task/Identity-matrix/Tailspin/identity-matrix-2.tailspin deleted file mode 100644 index 301d97f5fd..0000000000 --- a/Task/Identity-matrix/Tailspin/identity-matrix-2.tailspin +++ /dev/null @@ -1,8 +0,0 @@ -identityMatrix templates - n is $; - [1..$n -> [1..~$ -> 0, 1, $~..$n -> 0]] ! -end identityMatrix - -identity is 5 -> identityMatrix; -$identity... -> '|$(1);$(2..)... -> ', $;';| -' ! diff --git a/Task/Identity-matrix/Tailspin/identity-matrix-1.tailspin b/Task/Identity-matrix/Tailspin/identity-matrix.tailspin similarity index 100% rename from Task/Identity-matrix/Tailspin/identity-matrix-1.tailspin rename to Task/Identity-matrix/Tailspin/identity-matrix.tailspin diff --git a/Task/Identity-matrix/Tcl/identity-matrix-1.tcl b/Task/Identity-matrix/Tcl/identity-matrix-1.tcl index 652bacb01b..17692fce2d 100644 --- a/Task/Identity-matrix/Tcl/identity-matrix-1.tcl +++ b/Task/Identity-matrix/Tcl/identity-matrix-1.tcl @@ -1,7 +1,7 @@ proc I {rank {zero 0.0} {one 1.0}} { set m [lrepeat $rank [lrepeat $rank $zero]] for {set i 0} {$i < $rank} {incr i} { - lset m $i $i $one + lset m $i $i $one } return $m } diff --git a/Task/Identity-matrix/Tcl/identity-matrix-2.tcl b/Task/Identity-matrix/Tcl/identity-matrix-2.tcl index c2560fe41a..2342fdd286 100644 --- a/Task/Identity-matrix/Tcl/identity-matrix-2.tcl +++ b/Task/Identity-matrix/Tcl/identity-matrix-2.tcl @@ -5,9 +5,9 @@ proc I {rank {zero 0.0} {one 1.0}} { $m add columns $rank $m add rows $rank for {set i 0} {$i < $rank} {incr i} { - for {set j 0} {$j < $rank} {incr j} { - $m set cell $i $j [expr {$i==$j ? $one : $zero}] - } + for {set j 0} {$j < $rank} {incr j} { + $m set cell $i $j [expr {$i==$j ? $one : $zero}] + } } return $m } diff --git a/Task/Identity-matrix/Uiua/identity-matrix.uiua b/Task/Identity-matrix/Uiua/identity-matrix.uiua deleted file mode 100644 index 2c76013a8d..0000000000 --- a/Task/Identity-matrix/Uiua/identity-matrix.uiua +++ /dev/null @@ -1,2 +0,0 @@ -IdMatrix ← ⊞=.⇡ -IdMatrix 7 diff --git a/Task/Identity-matrix/VBScript/identity-matrix-1.vb b/Task/Identity-matrix/VBScript/identity-matrix-1.vb new file mode 100644 index 0000000000..5c7a77dd67 --- /dev/null +++ b/Task/Identity-matrix/VBScript/identity-matrix-1.vb @@ -0,0 +1,29 @@ +build_matrix(7) + +Sub build_matrix(n) + Dim matrix() + ReDim matrix(n-1,n-1) + i = 0 + 'populate the matrix + For row = 0 To n-1 + For col = 0 To n-1 + If col = i Then + matrix(row,col) = 1 + Else + matrix(row,col) = 0 + End If + Next + i = i + 1 + Next + 'display the matrix + For row = 0 To n-1 + For col = 0 To n-1 + If col < n-1 Then + WScript.StdOut.Write matrix(row,col) & " " + Else + WScript.StdOut.Write matrix(row,col) + End If + Next + WScript.StdOut.WriteLine + Next +End Sub diff --git a/Task/Identity-matrix/VBScript/identity-matrix-1.vbs b/Task/Identity-matrix/VBScript/identity-matrix-1.vbs deleted file mode 100644 index a9e51579b8..0000000000 --- a/Task/Identity-matrix/VBScript/identity-matrix-1.vbs +++ /dev/null @@ -1,29 +0,0 @@ -build_matrix(7) - -Sub build_matrix(n) - Dim matrix() - ReDim matrix(n-1,n-1) - i = 0 - 'populate the matrix - For row = 0 To n-1 - For col = 0 To n-1 - If col = i Then - matrix(row,col) = 1 - Else - matrix(row,col) = 0 - End If - Next - i = i + 1 - Next - 'display the matrix - For row = 0 To n-1 - For col = 0 To n-1 - If col < n-1 Then - WScript.StdOut.Write matrix(row,col) & " " - Else - WScript.StdOut.Write matrix(row,col) - End If - Next - WScript.StdOut.WriteLine - Next -End Sub diff --git a/Task/Identity-matrix/VBScript/identity-matrix-2.vbs b/Task/Identity-matrix/VBScript/identity-matrix-2.vb similarity index 100% rename from Task/Identity-matrix/VBScript/identity-matrix-2.vbs rename to Task/Identity-matrix/VBScript/identity-matrix-2.vb diff --git a/Task/Identity-matrix/Vala/identity-matrix.vala b/Task/Identity-matrix/Vala/identity-matrix.vala index 6365ad13d8..a061d4d56b 100644 --- a/Task/Identity-matrix/Vala/identity-matrix.vala +++ b/Task/Identity-matrix/Vala/identity-matrix.vala @@ -1,25 +1,25 @@ int main (string[] args) { - if (args.length < 2) { - print ("Please, input an integer > 0.\n"); - return 0; - } - var n = int.parse (args[1]); - if (n <= 0) { - print ("Please, input an integer > 0.\n"); - return 0; - } - int[,] array = new int[n, n]; - for (var i = 0; i < n; i ++) { - for (var j = 0; j < n; j ++) { - if (i == j) array[i,j] = 1; - else array[i,j] = 0; - } - } - for (var i = 0; i < n; i ++) { - for (var j = 0; j < n; j ++) { - print ("%d ", array[i,j]); - } - print ("\b\n"); - } - return 0; + if (args.length < 2) { + print ("Please, input an integer > 0.\n"); + return 0; + } + var n = int.parse (args[1]); + if (n <= 0) { + print ("Please, input an integer > 0.\n"); + return 0; + } + int[,] array = new int[n, n]; + for (var i = 0; i < n; i ++) { + for (var j = 0; j < n; j ++) { + if (i == j) array[i,j] = 1; + else array[i,j] = 0; + } + } + for (var i = 0; i < n; i ++) { + for (var j = 0; j < n; j ++) { + print ("%d ", array[i,j]); + } + print ("\b\n"); + } + return 0; } diff --git a/Task/Identity-matrix/Wren/identity-matrix.wren b/Task/Identity-matrix/Wren/identity-matrix.wren index 9e717f28f2..da703414a2 100644 --- a/Task/Identity-matrix/Wren/identity-matrix.wren +++ b/Task/Identity-matrix/Wren/identity-matrix.wren @@ -1,5 +1,5 @@ -import "./matrix" for Matrix -import "./fmt" for Fmt +import "/matrix" for Matrix +import "/fmt" for Fmt var numRows = 10 // say Fmt.mprint(Matrix.identity(numRows), 2, 0) diff --git a/Task/Identity-matrix/XBasic/identity-matrix.basic b/Task/Identity-matrix/XBasic/identity-matrix.basic index 8af9483abb..eede4569ac 100644 --- a/Task/Identity-matrix/XBasic/identity-matrix.basic +++ b/Task/Identity-matrix/XBasic/identity-matrix.basic @@ -1,5 +1,5 @@ PROGRAM "Identity matrix" -VERSION "0.0000" +VERSION "0.0000" DECLARE FUNCTION Entry () diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.adb b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.adb deleted file mode 100644 index d2d6842033..0000000000 --- a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.adb +++ /dev/null @@ -1,12 +0,0 @@ -with Ada.Strings.Maps; use Ada.Strings.Maps; -with Ada.Text_IO; - -procedure Show_Valid_Identifiers is - Valid_First_Character : constant Character_Set := To_Set (Ranges => (1 => ('a', 'z'), 2 => ('A', 'Z'))); - Valid_Last_Character : constant Character_Set := Valid_First_Character or To_Set (Ranges => (1 => ('0', '9'))); - Valid_Middle_Character : constant Character_Set := Valid_Last_Character or To_Set ('_'); -begin - Ada.Text_IO.Put_Line ("Valid for the first character: " & String (To_Sequence (Valid_First_Character))); - Ada.Text_IO.Put_Line ("Valid for any middle character: " & String (To_Sequence (Valid_Middle_Character))); - Ada.Text_IO.Put_Line ("Valid for the last character: " & String (To_Sequence (Valid_Last_Character))); -end Show_Valid_Identifiers; diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Delphi/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.pas b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Delphi/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.delphi similarity index 100% rename from Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Delphi/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.pas rename to Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Delphi/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.delphi diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb deleted file mode 100644 index 44a338df57..0000000000 --- a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb +++ /dev/null @@ -1,27 +0,0 @@ -# Generate a string of all the codepoints in the range [m,n) -# corresponding to the given Unicode character class, where `class` -# could be '[a-z]' or '\p{Ll}', etc. -# -# Note: codepoints 55296 to 57343 (xD800–xDFFF) are reserved for the -# surrogates mechanism and are excluded as they are regarded as "illegal" -# as characters. -# -create or replace function generate(class, m, n) as ( - select string_agg(s, '') - from (select - case when 55296 <=i and i <= 57343 then null - else regexp_extract( chr(i::INTEGER), class) - end as s - from range(m, n) t(i)) -); - -# ident_start minus NBSP -select generate( '[A-Za-z\200-\237\241-\377_]',0, 1024); - -.mode list - -with ident_start as ( - select generate( '[A-Za-z\200-\237\241-\377_]',0,1024 ) as s - ) - select unnest(regexp_extract_all(s, '.{1,26}')) - from ident_start; diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/EasyLang/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.easy b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/EasyLang/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.easy deleted file mode 100644 index 700c376ff1..0000000000 --- a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/EasyLang/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.easy +++ /dev/null @@ -1,13 +0,0 @@ -print "First character:" -write "_" -for i = strcode "A" to strcode "Z" - write strchar i -. -for i = strcode "a" to strcode "z" - write strchar i -. -print "" -print "Not as the first character additionally:" -for i = strcode "0" to strcode "9" - write strchar i -. diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Julia/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.jl b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Julia/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.julia similarity index 100% rename from Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Julia/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.jl rename to Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Julia/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.julia diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Kotlin/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.kts b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Kotlin/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.kotlin similarity index 100% rename from Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Kotlin/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.kts rename to Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Kotlin/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.kotlin diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/M2000-Interpreter/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.m2000 b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/M2000-Interpreter/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.m2000 deleted file mode 100644 index 1ab74f5f29..0000000000 --- a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/M2000-Interpreter/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.m2000 +++ /dev/null @@ -1,12 +0,0 @@ -for=100 -print for=100 -for for=1 to 10:Print for: Next for -Print for=11 -to=100 -print to=100 -for to=1 to 10:Print to: Next to -Print to=11 -Print=100 -print Print=100 -for Print=1 to 10:Print Print: Next Print -Print Print=11 diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren index 8e2277f929..381544e810 100644 --- a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren +++ b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren @@ -1,4 +1,3 @@ for (i in 97..122) System.write(String.fromByte(i)) for (i in 65..90) System.write(String.fromByte(i)) -for (i in 48..57) System.write(String.fromByte(i)) System.print("_") diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/8080-Assembly/idiomatically-determine-all-the-lowercase-and-uppercase-letters.8080 b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/8080-Assembly/idiomatically-determine-all-the-lowercase-and-uppercase-letters.8080 deleted file mode 100644 index 57af11d0de..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/8080-Assembly/idiomatically-determine-all-the-lowercase-and-uppercase-letters.8080 +++ /dev/null @@ -1,94 +0,0 @@ - ;------------------------------------------------------ - ; useful equates - ;------------------------------------------------------ -bdos equ 5h ; BDOS entry -wboot equ 0 ; BDOS warm boot function -conout equ 2 ; BDOS write character to console function -prtstr equ 9 ; BDOS write string to console function -cr equ 13 ; ASCII carriage return -lf equ 10 ; ASCII line feed - ;------------------------------------------------------ - ; main code begins here - ;------------------------------------------------------ - org 100h ; entry point under CP/M - lxi sp,stack ; set a local stack - ; - ; show upper case alphabet - ; - lxi d,ucmsg - call message - mvi a,'A' -ucloop: push a - call putchr - pop a - inr a - cpi 'Z'+1 - jc ucloop - call crlf - ; - ; show lower case alphabet - ; - lxi d,lcmsg - call message - mvi a,'a' -lcloop: push a - call putchr - pop a - inr a - cpi 'z'+1 - jc lcloop - call crlf - ; - ; we're finished; exit to operating system - ; - jmp wboot - ;------------------------------------------------------- - ; console output of $-terminated string pointed to by DE - ;------------------------------------------------------- -message: - push b - push d - push h - mvi c,prtstr - call bdos - pop h - pop d - pop b - ret - ;------------------------------------------------------- - ; output CRLF to console - ;------------------------------------------------------- -crlf: push b - push d - push h - mvi e,cr - mvi c,conout - call bdos - mvi e,lf - mvi c,conout - call bdos - pop h - pop d - pop b - ret - ;------------------------------------------------------- - ; console output of char in A register - ;------------------------------------------------------- -putchr: push b - push d - push h - mov e,a - mvi c,conout - call bdos - pop h - pop d - pop b - ret - ;------------------------------------------------------ - ; messages and data area - ;------------------------------------------------------ -ucmsg: db 'Upper case: $' -lcmsg: db 'Lower case: $' -stack equ $+128 ; 64-level stack is sufficient - ; - end diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Ada/idiomatically-determine-all-the-lowercase-and-uppercase-letters.adb b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Ada/idiomatically-determine-all-the-lowercase-and-uppercase-letters.ada similarity index 100% rename from Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Ada/idiomatically-determine-all-the-lowercase-and-uppercase-letters.adb rename to Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Ada/idiomatically-determine-all-the-lowercase-and-uppercase-letters.ada diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Arturo/idiomatically-determine-all-the-lowercase-and-uppercase-letters.arturo b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Arturo/idiomatically-determine-all-the-lowercase-and-uppercase-letters.arturo index 7c6cd7e44d..05b8a27f68 100644 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Arturo/idiomatically-determine-all-the-lowercase-and-uppercase-letters.arturo +++ b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Arturo/idiomatically-determine-all-the-lowercase-and-uppercase-letters.arturo @@ -1,2 +1,2 @@ -print ["lowercase letters:" @'a'..'z'] -print ["uppercase letters:" @'A'..'Z'] +print ["lowercase letters:" `a`..`z`] +print ["uppercase letters:" `A`..`Z`] diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/COBOL/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cob b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/COBOL/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cobol similarity index 100% rename from Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/COBOL/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cob rename to Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/COBOL/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cobol diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Crystal/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cr b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Crystal/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cr deleted file mode 100644 index 5c334faa07..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Crystal/idiomatically-determine-all-the-lowercase-and-uppercase-letters.cr +++ /dev/null @@ -1,10 +0,0 @@ -letters = ((0.chr)..Char::MAX).group_by { |ch| - case ch - when .lowercase? then :lower - when .uppercase? then :upper - else :neither - end -} - -puts "Lowercase: #{letters[:lower].join(" ")}" -puts "Uppercase: #{letters[:upper].join(" ")}" diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Delphi/idiomatically-determine-all-the-lowercase-and-uppercase-letters.pas b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Delphi/idiomatically-determine-all-the-lowercase-and-uppercase-letters.delphi similarity index 100% rename from Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Delphi/idiomatically-determine-all-the-lowercase-and-uppercase-letters.pas rename to Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Delphi/idiomatically-determine-all-the-lowercase-and-uppercase-letters.delphi diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb deleted file mode 100644 index 825cc013b9..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb +++ /dev/null @@ -1,19 +0,0 @@ -# The number of Unicode codepoints -set variable maxu = 1114112; - -# Generate a string of all the codepoints in the range [m,n) -# corresponding to the given Unicode character class, where `class` -# could be '[a-z]' or '\p{Ll}', etc. -# -# Note: codepoints 55296 to 57343 (xD800–xDFFF) are reserved for the -# surrogates mechanism and are excluded as they are regarded "illegal" -# as characters. -# -create or replace function generate(class, m, n) as ( - select string_agg(s, '') - from (select - case when 55296 <=i and i <= 57343 then null - else regexp_extract( chr(i::INTEGER), class) - end as s - from range(m, n) t(i)) -); diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/EasyLang/idiomatically-determine-all-the-lowercase-and-uppercase-letters.easy b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/EasyLang/idiomatically-determine-all-the-lowercase-and-uppercase-letters.easy deleted file mode 100644 index a8bb064adb..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/EasyLang/idiomatically-determine-all-the-lowercase-and-uppercase-letters.easy +++ /dev/null @@ -1,6 +0,0 @@ -proc out a b . - for i = a to b : write strchar i - print "" -. -out 97 122 -out 65 90 diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Haskell/idiomatically-determine-all-the-lowercase-and-uppercase-letters-3.hs b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Haskell/idiomatically-determine-all-the-lowercase-and-uppercase-letters-3.hs deleted file mode 100644 index f3f86f5e34..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Haskell/idiomatically-determine-all-the-lowercase-and-uppercase-letters-3.hs +++ /dev/null @@ -1,4 +0,0 @@ -(let chars-between (comp range (map char-code) (... str))) - -"Upper-case: {chars-between 65 91} -Lower-case: {chars-between 97 123}" diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Haskell/idiomatically-determine-all-the-lowercase-and-uppercase-letters-4.hs b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Haskell/idiomatically-determine-all-the-lowercase-and-uppercase-letters-4.hs deleted file mode 100644 index 5db1667a8e..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Haskell/idiomatically-determine-all-the-lowercase-and-uppercase-letters-4.hs +++ /dev/null @@ -1,4 +0,0 @@ -(let ascii (map char-code (range 127))) - -(.. str "Upper-case: " (filter upper? ascii) " -Lower-case: " (filter lower? ascii)) diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Julia/idiomatically-determine-all-the-lowercase-and-uppercase-letters.jl b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Julia/idiomatically-determine-all-the-lowercase-and-uppercase-letters.jl deleted file mode 100644 index 19a26a3ffa..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Julia/idiomatically-determine-all-the-lowercase-and-uppercase-letters.jl +++ /dev/null @@ -1,24 +0,0 @@ -function countunicode() - count = 0 - az = "" - AZ = "" - for i in 0:0xffffff - if isvalid(Char, i) - c = Char(i) - count += 1 - if i < 128 && isletter(c) - if islowercase(c) - az *= "$c" - elseif isuppercase(c) - AZ *= "$c" - end - end - end - end - count, az, AZ -end - -unicodecount, lcletters, ucletters = countunicode() - -println("There are $unicodecount valid Chars and the ASCII English ones are:") -println("lowercase: $lcletters and uppercase: $ucletters .") diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Julia/idiomatically-determine-all-the-lowercase-and-uppercase-letters.julia b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Julia/idiomatically-determine-all-the-lowercase-and-uppercase-letters.julia new file mode 100644 index 0000000000..9a83077168 --- /dev/null +++ b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Julia/idiomatically-determine-all-the-lowercase-and-uppercase-letters.julia @@ -0,0 +1,25 @@ +function countunicode() + englishlettercodes = [Int(c) for c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] + count = 0 + az = "" + AZ = "" + for i in 0:0xffffff + if is_assigned_char(i) + count += 1 + end + if i in englishlettercodes + c = Char(i) + if islower(c) + az *= "$c" + else + AZ *= "$c" + end + end + end + count, az, AZ +end + +unicodecount, lcletters, ucletters = countunicode() + +print("There are $unicodecount valid Chars and the English ones are ") +println("lowercase: $lcletters and uppercase: $ucletters.") diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Kotlin/idiomatically-determine-all-the-lowercase-and-uppercase-letters.kts b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Kotlin/idiomatically-determine-all-the-lowercase-and-uppercase-letters.kotlin similarity index 100% rename from Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Kotlin/idiomatically-determine-all-the-lowercase-and-uppercase-letters.kts rename to Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Kotlin/idiomatically-determine-all-the-lowercase-and-uppercase-letters.kotlin diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Maxima/idiomatically-determine-all-the-lowercase-and-uppercase-letters.maxima b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Maxima/idiomatically-determine-all-the-lowercase-and-uppercase-letters.maxima deleted file mode 100644 index 0079bab024..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Maxima/idiomatically-determine-all-the-lowercase-and-uppercase-letters.maxima +++ /dev/null @@ -1,2 +0,0 @@ -sublist(makelist(unicode(i),i,0,127),lowercasep); -sublist(makelist(unicode(i),i,0,127),uppercasep); diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters-1.phix b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters-1.phix deleted file mode 100644 index b307e0490a..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters-1.phix +++ /dev/null @@ -1,10 +0,0 @@ -with javascript_semantics -sequence lc = {}, uc = {} -for ch=1 to 255 do - if islower(ch) then lc &= ch end if - if isupper(ch) then uc &= ch end if -end for -lc = utf32_to_utf8(lc)&"\n" -uc = utf32_to_utf8(uc)&"\n" -puts(1,lc) -puts(1,uc) diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters-2.phix b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters-2.phix deleted file mode 100644 index a2d8ee8e1d..0000000000 --- a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters-2.phix +++ /dev/null @@ -1,4 +0,0 @@ -?tagset('z','a') -?tagstart('a',26) -?tagset('Z','A') -?tagstart('A',26) diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters.phix b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters.phix new file mode 100644 index 0000000000..be7c73650e --- /dev/null +++ b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/Phix/idiomatically-determine-all-the-lowercase-and-uppercase-letters.phix @@ -0,0 +1,11 @@ +(phixonline)--> + sequence lc = {}, uc = {} + for ch=1 to 255 do + if islower(ch) then lc &= ch end if + if isupper(ch) then uc &= ch end if + end for + lc = utf32_to_utf8(lc)&"\n" + uc = utf32_to_utf8(uc)&"\n" + puts(1,lc) + puts(1,uc) + + without js -- (class) + class Animal + private string species + end class + class Dog extends Animal + public procedure bark() + puts(1,"woof\n") + end procedure + end class + class Lab extends Dog end class + class Collie extends Dog end class + class Cat extends Animal end class + loop next position - j 1b - -2: - li t0,'-' # first byte is - ? - bne t5,t0,21f - li t1,1 # negative sign - j 4f # next position -21: - li t0,'+' # first byte is + ? - beq t5,t0,4f # yes -> next position -3: # debut de boucle de traitement des chiffres - li t0,'0' - blt t5,t0,4f # byte is not numeric - li t0,'9' - bgt t5,t0,4f # byte is not numeric - addi t5,t5,-48 - li t0,NUMMAXI - bgt a0,t0,99f # number maxi ? - - mul a0,t2,a0 # multiply by factor 10 - add a0,a0,t5 # and add new byte - -4: - addi t3,t3,1 # next position - add t0,t4,t3 - lbu t5,(t0) # load byte - beq t5,x0,5f # string end -> end - li t0,0x0A - beq t5,t0,5f # string end -> end - j 3b # or loop -5: - beqz t1,100f # positive sign ? - neg a0,a0 # no - j 100f -99: # overflow error - la a0,szMessErrDep - call writeString - li a0,0 # on error return zero -100: - lw ra, 0(sp) - addi sp, sp, 4 - ret - -/************************************/ -/* file include Fonctions */ -/***********************************/ -/* for this file see risc-v task include a file */ -.include "../../includeFunctions.s" diff --git a/Task/Integer-comparison/ReScript/integer-comparison.res b/Task/Integer-comparison/ReScript/integer-comparison.re similarity index 100% rename from Task/Integer-comparison/ReScript/integer-comparison.res rename to Task/Integer-comparison/ReScript/integer-comparison.re diff --git a/Task/Integer-comparison/Rust/integer-comparison.rs b/Task/Integer-comparison/Rust/integer-comparison.rust similarity index 100% rename from Task/Integer-comparison/Rust/integer-comparison.rs rename to Task/Integer-comparison/Rust/integer-comparison.rust diff --git a/Task/Integer-comparison/Rye/integer-comparison.rye b/Task/Integer-comparison/Rye/integer-comparison.rye deleted file mode 100644 index 961dc50523..0000000000 --- a/Task/Integer-comparison/Rye/integer-comparison.rye +++ /dev/null @@ -1,4 +0,0 @@ -a: integer input "Enter value of a" -b: integer input "Enter value of b" - -cases a { { a < b } { print "Less than" } { a = b } { print "Equal to" } { a > b } { print "Greater than" } } diff --git a/Task/Integer-comparison/Scheme/integer-comparison.scm b/Task/Integer-comparison/Scheme/integer-comparison.ss similarity index 100% rename from Task/Integer-comparison/Scheme/integer-comparison.scm rename to Task/Integer-comparison/Scheme/integer-comparison.ss diff --git a/Task/Integer-comparison/V-(Vlang)/integer-comparison.v b/Task/Integer-comparison/V-(Vlang)/integer-comparison.v deleted file mode 100644 index cf27fc8509..0000000000 --- a/Task/Integer-comparison/V-(Vlang)/integer-comparison.v +++ /dev/null @@ -1,17 +0,0 @@ -import os - -fn main(){ - mut enter := "" - mut a, mut b := 0, 0 - enter = os.input("Enter number for a: ") - if enter.is_int() {a = enter.int()} else {println("Invalid input!") exit(1)} - enter = os.input("Enter number for b: ") - if enter.is_int() {b = enter.int()} else {println("Invalid input!") exit(1)} - match true { - a < b {println("${a} less than ${b}")} - a == b {println("${a} equal to ${b}")} - a > b {println("${a} greater than ${b}")} - else{} - } - exit(0) -} diff --git a/Task/Integer-comparison/VBScript/integer-comparison.vbs b/Task/Integer-comparison/VBScript/integer-comparison.vb similarity index 100% rename from Task/Integer-comparison/VBScript/integer-comparison.vbs rename to Task/Integer-comparison/VBScript/integer-comparison.vb diff --git a/Task/Integer-comparison/YAMLScript/integer-comparison.ys b/Task/Integer-comparison/YAMLScript/integer-comparison.ys deleted file mode 100644 index 59b265bd8e..0000000000 --- a/Task/Integer-comparison/YAMLScript/integer-comparison.ys +++ /dev/null @@ -1,8 +0,0 @@ -!YS-v0 - -defn main(x y): - say: - cond: - x < y: "$x is less than $y" - x > y: "$x is greater than $y" - else : "$x is equal to $y" diff --git a/Task/Integer-overflow/ALGOL-M/integer-overflow.alg b/Task/Integer-overflow/ALGOL-M/integer-overflow.alg deleted file mode 100644 index c285f7d9f2..0000000000 --- a/Task/Integer-overflow/ALGOL-M/integer-overflow.alg +++ /dev/null @@ -1,6 +0,0 @@ -begin -integer n; -n := 16383; % maximum integer value % -write(n+2); -write(n*2); -end diff --git a/Task/Integer-overflow/Ada/integer-overflow.ada b/Task/Integer-overflow/Ada/integer-overflow.ada new file mode 100644 index 0000000000..1deb7a7c8b --- /dev/null +++ b/Task/Integer-overflow/Ada/integer-overflow.ada @@ -0,0 +1,51 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Overflow is + + generic + type T is Range <>; + Name_Of_T: String; + procedure Print_Bounds; -- first instantiate this with T, Name + -- then call the instantiation + procedure Print_Bounds is + begin + Put_Line(" " & Name_Of_T & " " & T'Image(T'First) + & " .." & T'Image(T'Last)); + end Print_Bounds; + + procedure P_Int is new Print_Bounds(Integer, "Integer "); + procedure P_Nat is new Print_Bounds(Natural, "Natural "); + procedure P_Pos is new Print_Bounds(Positive, "Positive"); + procedure P_Long is new Print_Bounds(Long_Integer, "Long "); + + type Unsigned_Byte is range 0 .. 255; + type Signed_Byte is range -128 .. 127; + type Unsigned_Word is range 0 .. 2**32-1; + type Thousand is range 0 .. 999; + type Signed_Double is range - 2**63 .. 2**63-1; + type Crazy is range -11 .. -3; + + procedure P_UB is new Print_Bounds(Unsigned_Byte, "U 8 "); + procedure P_SB is new Print_Bounds(Signed_Byte, "S 8 "); + procedure P_UW is new Print_Bounds(Unsigned_Word, "U 32 "); + procedure P_Th is new Print_Bounds(Thousand, "Thous"); + procedure P_SD is new Print_Bounds(Signed_Double, "S 64 "); + procedure P_Cr is new Print_Bounds(Crazy, "Crazy"); + + A: Crazy := Crazy'First; + +begin + Put_Line("Predefined Types:"); + P_Int; P_Nat; P_Pos; P_Long; + New_Line; + + Put_Line("Types defined by the user:"); + P_UB; P_SB; P_UW; P_Th; P_SD; P_Cr; + New_Line; + + Put_Line("Forcing a variable of type Crazy to overflow:"); + loop -- endless loop + Put(" " & Crazy'Image(A) & "+1"); + A := A + 1; -- line 49 -- this will later raise a CONSTRAINT_ERROR + end loop; +end Overflow; diff --git a/Task/Integer-overflow/Ada/integer-overflow.adb b/Task/Integer-overflow/Ada/integer-overflow.adb deleted file mode 100644 index da4fe71c7b..0000000000 --- a/Task/Integer-overflow/Ada/integer-overflow.adb +++ /dev/null @@ -1,51 +0,0 @@ -with Ada.Text_IO; use Ada.Text_IO; - -procedure Overflow is - - generic - type T is Range <>; - Name_Of_T: String; - procedure Print_Bounds; -- first instantiate this with T, Name - -- then call the instantiation - procedure Print_Bounds is - begin - Put_Line(" " & Name_Of_T & " " & T'Image(T'First) - & " .." & T'Image(T'Last)); - end Print_Bounds; - - procedure P_Int is new Print_Bounds(Integer, "Integer "); - procedure P_Nat is new Print_Bounds(Natural, "Natural "); - procedure P_Pos is new Print_Bounds(Positive, "Positive"); - procedure P_Long is new Print_Bounds(Long_Integer, "Long "); - - type Unsigned_Byte is range 0 .. 255; - type Signed_Byte is range -128 .. 127; - type Unsigned_Word is range 0 .. 2**32-1; - type Thousand is range 0 .. 999; - type Signed_Double is range - 2**63 .. 2**63-1; - type Crazy is range -11 .. -3; - - procedure P_UB is new Print_Bounds(Unsigned_Byte, "U 8 "); - procedure P_SB is new Print_Bounds(Signed_Byte, "S 8 "); - procedure P_UW is new Print_Bounds(Unsigned_Word, "U 32 "); - procedure P_Th is new Print_Bounds(Thousand, "Thous"); - procedure P_SD is new Print_Bounds(Signed_Double, "S 64 "); - procedure P_Cr is new Print_Bounds(Crazy, "Crazy"); - - A: Crazy := Crazy'First; - -begin - Put_Line("Predefined Types:"); - P_Int; P_Nat; P_Pos; P_Long; - New_Line; - - Put_Line("Types defined by the user:"); - P_UB; P_SB; P_UW; P_Th; P_SD; P_Cr; - New_Line; - - Put_Line("Forcing a variable of type Crazy to overflow:"); - loop -- endless loop - Put(" " & Crazy'Image(A) & "+1"); - A := A + 1; -- line 49 -- this will later raise a CONSTRAINT_ERROR - end loop; -end Overflow; diff --git a/Task/Integer-overflow/Applesoft-BASIC/integer-overflow-5.basic b/Task/Integer-overflow/Applesoft-BASIC/integer-overflow-5.basic index 342b708226..af3e54154a 100644 --- a/Task/Integer-overflow/Applesoft-BASIC/integer-overflow-5.basic +++ b/Task/Integer-overflow/Applesoft-BASIC/integer-overflow-5.basic @@ -1 +1 @@ -A% = -32767 : POKE PEEK(131) + PEEK(132) * 256 + 1, 0 : ? A% +A% = -32767 : POKE PEEK(131) + PEEK(132) * 256, 0 : ? A% diff --git a/Task/Integer-overflow/COBOL/integer-overflow-1.cob b/Task/Integer-overflow/COBOL/integer-overflow-1.cobol similarity index 100% rename from Task/Integer-overflow/COBOL/integer-overflow-1.cob rename to Task/Integer-overflow/COBOL/integer-overflow-1.cobol diff --git a/Task/Integer-overflow/COBOL/integer-overflow-2.cob b/Task/Integer-overflow/COBOL/integer-overflow-2.cobol similarity index 100% rename from Task/Integer-overflow/COBOL/integer-overflow-2.cob rename to Task/Integer-overflow/COBOL/integer-overflow-2.cobol diff --git a/Task/Integer-overflow/Crystal/integer-overflow.cr b/Task/Integer-overflow/Crystal/integer-overflow.cr deleted file mode 100644 index 2a14023b37..0000000000 --- a/Task/Integer-overflow/Crystal/integer-overflow.cr +++ /dev/null @@ -1,38 +0,0 @@ -macro try (expr) - printf "%-*s # => ", padding, {{expr.stringify}} - begin - puts {{expr}} - rescue ex - puts "Exception: #{ex.message}" - end -end - -padding = 25 -puts "Result does not fit into a 32-bit signed integer:" -try -(-2147483647-1) -try 2000000000 + 2000000000 -try -2147483647 - 2147483647 -try 46341 * 46341 -try (-2147483647-1) // -1 - -padding = 52 -puts "\nResult does not fit into a 64-bit signed integer:" -try -(-9223372036854775807 - 1) -try 5000000000000000000 + 5000000000000000000 -try -9223372036854775807 - 9223372036854775807 -try 3037000500 * 3037000500 -try (-9223372036854775807 - 1) // -1 - -padding = 32 -puts "\nResult does not fit into a 32-bit unsigned integer:" -try -4294967295.to_u32 -try 3000000000_u32 + 3000000000_u32 -try 2147483647_u32 - 4294967295_u32 -try 65537_u32 * 65537_u32 - -padding = 52 -puts "\nResult that does not fit into a 64-bit unsigned integer:" -try -18446744073709551615_i128.to_u64 -try 10000000000000000000_u64 + 10000000000000000000_u64 -try 9223372036854775807_u64 - 18446744073709551615_u64 -try 4294967296_u64 * 4294967296_64 diff --git a/Task/Integer-overflow/Delphi/integer-overflow.delphi b/Task/Integer-overflow/Delphi/integer-overflow.delphi new file mode 100644 index 0000000000..05327d8aee --- /dev/null +++ b/Task/Integer-overflow/Delphi/integer-overflow.delphi @@ -0,0 +1,123 @@ +var IS32: integer; {Signed 32-bit integer} +var IS64: Int64; {Signed 64-bit integer} +var IU32: cardinal; {Unsigned 32-bit integer} + +{============ Signed 32 bit tests ===================================} + +procedure TestSigned32_1; +begin +IS32:=-(-2147483647-1); +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + +procedure TestSigned32_2; +begin +IS32:=2000000000 + 2000000000; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + + +procedure TestSigned32_3; +begin +IS32:=-2147483647 - 2147483647; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + +procedure TestSigned32_4; +begin +IS32:=46341 * 46341; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + + +procedure TestSigned32_5; +begin +IS32:=(-2147483647-1) div -1; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + +{============ Signed 64 bit tests ===================================} + +procedure TestSigned64_1; +begin +IS64:=-(-9223372036854775807-1); +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestSigned64_2; +begin +IS64:=5000000000000000000+5000000000000000000; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestSigned64_3; +begin +IS64:=-9223372036854775807 - 9223372036854775807; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestSigned64_4; +begin +IS64:=3037000500 * 3037000500; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestSigned64_5; +begin +IS64:=(-9223372036854775807-1) div -1; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +{============ UnSigned 32 bit tests ===================================} + +procedure TestUnSigned32_1; +begin +IU32:=-4294967295; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestUnSigned32_2; +begin +IU32:=3000000000 + 3000000000; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestUnSigned32_3; +begin +IU32:=2147483647 - 4294967295; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +procedure TestUnSigned32_4; +begin +IU32:=65537 * 65537; +end; + +// Compiler: "Overflow in conversion or arithmetic operation" + + +//Delphi-6 does not have 64-bit unsigned integers. +//Later version have 64-bit unsigned integers. diff --git a/Task/Integer-overflow/Delphi/integer-overflow.pas b/Task/Integer-overflow/Delphi/integer-overflow.pas deleted file mode 100644 index 865888a299..0000000000 --- a/Task/Integer-overflow/Delphi/integer-overflow.pas +++ /dev/null @@ -1,123 +0,0 @@ -var IS32: integer; {Signed 32-bit integer} -var IS64: Int64; {Signed 64-bit integer} -var IU32: cardinal; {Unsigned 32-bit integer} - -{============ Signed 32 bit tests ===================================} - -procedure TestSigned32_1; -begin -IS32:=-(-2147483647-1); -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - -procedure TestSigned32_2; -begin -IS32:=2000000000 + 2000000000; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - - -procedure TestSigned32_3; -begin -IS32:=-2147483647 - 2147483647; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - -procedure TestSigned32_4; -begin -IS32:=46341 * 46341; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - - -procedure TestSigned32_5; -begin -IS32:=(-2147483647-1) div -1; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - -{============ Signed 64 bit tests ===================================} - -procedure TestSigned64_1; -begin -IS64:=-(-9223372036854775807-1); -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestSigned64_2; -begin -IS64:=5000000000000000000+5000000000000000000; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestSigned64_3; -begin -IS64:=-9223372036854775807 - 9223372036854775807; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestSigned64_4; -begin -IS64:=3037000500 * 3037000500; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestSigned64_5; -begin -IS64:=(-9223372036854775807-1) div -1; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -{============ UnSigned 32 bit tests ===================================} - -procedure TestUnSigned32_1; -begin -IU32:=-4294967295; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestUnSigned32_2; -begin -IU32:=3000000000 + 3000000000; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestUnSigned32_3; -begin -IU32:=2147483647 - 4294967295; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -procedure TestUnSigned32_4; -begin -IU32:=65537 * 65537; -end; - -// Compiler: "Overflow in conversion or arithmetic operation" - - -//Delphi-6 does not have 64-bit unsigned integers. -//Later version have 64-bit unsigned integers. diff --git a/Task/Integer-overflow/FutureBasic/integer-overflow.basic b/Task/Integer-overflow/FutureBasic/integer-overflow.basic deleted file mode 100644 index 722195a19e..0000000000 --- a/Task/Integer-overflow/FutureBasic/integer-overflow.basic +++ /dev/null @@ -1,17 +0,0 @@ -include "NSLog.incl" - -NSLog( @"FB Integer ranges:\n" ) - -NSLog( @"UInt64: 0 to %llu", ULLONG_MAX ) -NSLog( @"SInt64: %lld to %lld\n", LLONG_MIN, LLONG_MAX ) - -NSLog( @"UInt32: 0 to %u", UINT_MAX ) -NSLog( @"SInt32: %ld to %ld\n", INT_MIN, INT_MAX ) - -NSLog( @"UInt16: 0 to %hu", USHRT_MAX ) -NSLog( @"SInt16: %hd to %hd\n", SHRT_MIN, SHRT_MAX ) - -NSLog( @"UInt8: 0 to %u", UCHAR_MAX ) -NSLog( @"SInt8: %d to %d", CHAR_MIN, CHAR_MAX ) - -HandleEvents diff --git a/Task/Integer-overflow/Go/integer-overflow.go b/Task/Integer-overflow/Go/integer-overflow.go index 755a63b7f1..0beb5da9a1 100644 --- a/Task/Integer-overflow/Go/integer-overflow.go +++ b/Task/Integer-overflow/Go/integer-overflow.go @@ -3,106 +3,106 @@ package main import "fmt" func main() { - // Go's builtin integer types are: - // int, int8, int16, int32, int64 - // uint, uint8, uint16, uint32, uint64 - // byte, rune, uintptr - // - // int is either 32 or 64 bit, depending on the system - // uintptr is large enough to hold the bit pattern of any pointer - // byte is 8 bits like int8 - // rune is 32 bits like int32 - // - // Overflow and underflow is silent. The math package defines a number - // of constants that can be helpfull, e.g.: - // math.MaxInt64 = 1<<63 - 1 - // math.MinInt64 = -1 << 63 - // math.MaxUint64 = 1<<64 - 1 - // - // The math/big package implements multi-precision - // arithmetic (big numbers). - // - // In all cases assignment from one type to another requires - // an explicit cast, even if the types are otherwise identical - // (e.g. rune and int32 or int and either int32 or int64). - // Casts silently truncate if required. - // - // Invalid: - // var i int = int32(0) - // var r rune = int32(0) - // var b byte = int8(0) - // - // Valid: - var i64 int64 = 42 - var i32 int32 = int32(i64) - var i16 int16 = int16(i64) - var i8 int8 = int8(i16) - var i int = int(i8) - var r rune = rune(i) - var b byte = byte(r) - var u64 uint64 = uint64(b) - var u32 uint32 + // Go's builtin integer types are: + // int, int8, int16, int32, int64 + // uint, uint8, uint16, uint32, uint64 + // byte, rune, uintptr + // + // int is either 32 or 64 bit, depending on the system + // uintptr is large enough to hold the bit pattern of any pointer + // byte is 8 bits like int8 + // rune is 32 bits like int32 + // + // Overflow and underflow is silent. The math package defines a number + // of constants that can be helpfull, e.g.: + // math.MaxInt64 = 1<<63 - 1 + // math.MinInt64 = -1 << 63 + // math.MaxUint64 = 1<<64 - 1 + // + // The math/big package implements multi-precision + // arithmetic (big numbers). + // + // In all cases assignment from one type to another requires + // an explicit cast, even if the types are otherwise identical + // (e.g. rune and int32 or int and either int32 or int64). + // Casts silently truncate if required. + // + // Invalid: + // var i int = int32(0) + // var r rune = int32(0) + // var b byte = int8(0) + // + // Valid: + var i64 int64 = 42 + var i32 int32 = int32(i64) + var i16 int16 = int16(i64) + var i8 int8 = int8(i16) + var i int = int(i8) + var r rune = rune(i) + var b byte = byte(r) + var u64 uint64 = uint64(b) + var u32 uint32 - //const c int = -(-2147483647 - 1) // Compiler error on 32 bit systems, ok on 64 bit - const c = -(-2147483647 - 1) // Allowed even on 32 bit systems, c is untyped - i64 = c - //i32 = c // Compiler error - //i32 = -(-2147483647 - 1) // Compiler error - i32 = -2147483647 - i32 = -(-i32 - 1) - fmt.Println("32 bit signed integers") - fmt.Printf(" -(-2147483647 - 1) = %d, got %d\n", i64, i32) + //const c int = -(-2147483647 - 1) // Compiler error on 32 bit systems, ok on 64 bit + const c = -(-2147483647 - 1) // Allowed even on 32 bit systems, c is untyped + i64 = c + //i32 = c // Compiler error + //i32 = -(-2147483647 - 1) // Compiler error + i32 = -2147483647 + i32 = -(-i32 - 1) + fmt.Println("32 bit signed integers") + fmt.Printf(" -(-2147483647 - 1) = %d, got %d\n", i64, i32) - i64 = 2000000000 + 2000000000 - //i32 = 2000000000 + 2000000000 // Compiler error - i32 = 2000000000 - i32 = i32 + i32 - fmt.Printf(" 2000000000 + 2000000000 = %d, got %d\n", i64, i32) - i64 = -2147483647 - 2147483647 - i32 = 2147483647 - i32 = -i32 - i32 - fmt.Printf(" -2147483647 - 2147483647 = %d, got %d\n", i64, i32) - i64 = 46341 * 46341 - i32 = 46341 - i32 = i32 * i32 - fmt.Printf(" 46341 * 46341 = %d, got %d\n", i64, i32) - i64 = (-2147483647 - 1) / -1 - i32 = -2147483647 - i32 = (i32 - 1) / -1 - fmt.Printf(" (-2147483647-1) / -1 = %d, got %d\n", i64, i32) + i64 = 2000000000 + 2000000000 + //i32 = 2000000000 + 2000000000 // Compiler error + i32 = 2000000000 + i32 = i32 + i32 + fmt.Printf(" 2000000000 + 2000000000 = %d, got %d\n", i64, i32) + i64 = -2147483647 - 2147483647 + i32 = 2147483647 + i32 = -i32 - i32 + fmt.Printf(" -2147483647 - 2147483647 = %d, got %d\n", i64, i32) + i64 = 46341 * 46341 + i32 = 46341 + i32 = i32 * i32 + fmt.Printf(" 46341 * 46341 = %d, got %d\n", i64, i32) + i64 = (-2147483647 - 1) / -1 + i32 = -2147483647 + i32 = (i32 - 1) / -1 + fmt.Printf(" (-2147483647-1) / -1 = %d, got %d\n", i64, i32) - fmt.Println("\n64 bit signed integers") - i64 = -9223372036854775807 - fmt.Printf(" -(%d - 1): %d\n", i64, -(i64 - 1)) - i64 = 5000000000000000000 - fmt.Printf(" %d + %d: %d\n", i64, i64, i64+i64) - i64 = 9223372036854775807 - fmt.Printf(" -%d - %d: %d\n", i64, i64, -i64-i64) - i64 = 3037000500 - fmt.Printf(" %d * %d: %d\n", i64, i64, i64*i64) - i64 = -9223372036854775807 - fmt.Printf(" (%d - 1) / -1: %d\n", i64, (i64-1)/-1) + fmt.Println("\n64 bit signed integers") + i64 = -9223372036854775807 + fmt.Printf(" -(%d - 1): %d\n", i64, -(i64 - 1)) + i64 = 5000000000000000000 + fmt.Printf(" %d + %d: %d\n", i64, i64, i64+i64) + i64 = 9223372036854775807 + fmt.Printf(" -%d - %d: %d\n", i64, i64, -i64-i64) + i64 = 3037000500 + fmt.Printf(" %d * %d: %d\n", i64, i64, i64*i64) + i64 = -9223372036854775807 + fmt.Printf(" (%d - 1) / -1: %d\n", i64, (i64-1)/-1) - fmt.Println("\n32 bit unsigned integers:") - //u32 = -4294967295 // Compiler error - u32 = 4294967295 - fmt.Printf(" -%d: %d\n", u32, -u32) - u32 = 3000000000 - fmt.Printf(" %d + %d: %d\n", u32, u32, u32+u32) - a := uint32(2147483647) - u32 = 4294967295 - fmt.Printf(" %d - %d: %d\n", a, u32, a-u32) - u32 = 65537 - fmt.Printf(" %d * %d: %d\n", u32, u32, u32*u32) + fmt.Println("\n32 bit unsigned integers:") + //u32 = -4294967295 // Compiler error + u32 = 4294967295 + fmt.Printf(" -%d: %d\n", u32, -u32) + u32 = 3000000000 + fmt.Printf(" %d + %d: %d\n", u32, u32, u32+u32) + a := uint32(2147483647) + u32 = 4294967295 + fmt.Printf(" %d - %d: %d\n", a, u32, a-u32) + u32 = 65537 + fmt.Printf(" %d * %d: %d\n", u32, u32, u32*u32) - fmt.Println("\n64 bit unsigned integers:") - u64 = 18446744073709551615 - fmt.Printf(" -%d: %d\n", u64, -u64) - u64 = 10000000000000000000 - fmt.Printf(" %d + %d: %d\n", u64, u64, u64+u64) - aa := uint64(9223372036854775807) - u64 = 18446744073709551615 - fmt.Printf(" %d - %d: %d\n", aa, u64, aa-u64) - u64 = 4294967296 - fmt.Printf(" %d * %d: %d\n", u64, u64, u64*u64) + fmt.Println("\n64 bit unsigned integers:") + u64 = 18446744073709551615 + fmt.Printf(" -%d: %d\n", u64, -u64) + u64 = 10000000000000000000 + fmt.Printf(" %d + %d: %d\n", u64, u64, u64+u64) + aa := uint64(9223372036854775807) + u64 = 18446744073709551615 + fmt.Printf(" %d - %d: %d\n", aa, u64, aa-u64) + u64 = 4294967296 + fmt.Printf(" %d * %d: %d\n", u64, u64, u64*u64) } diff --git a/Task/Integer-overflow/Java/integer-overflow-2.java b/Task/Integer-overflow/Java/integer-overflow-2.java deleted file mode 100644 index f67ad7136d..0000000000 --- a/Task/Integer-overflow/Java/integer-overflow-2.java +++ /dev/null @@ -1,47 +0,0 @@ -public final class IntegerOverflow { - - public static void main(String[] args) { - // The following examples show that Java allows integer overflow without warning - // and calculates an incorrect result. - - // From version 8, Java introduced methods which throw an ArithmeticException when overflow occurs, - // which prevents the calculation of an incorrect result. It also allows the programmer to replace an "int" - // with a "long" and to replace a "long" with a BigInteger. - - // Uncomment the lines below to see the use of the new methods: - // addExact(), subtractExact(), multiplyExact() and negateExact(). - System.out.println("Signed 32-bit:"); - System.out.println(-(-2_147_483_647 - 1)); -// System.out.println(Math.negateExact(-2_147_483_647 - 1)); - - System.out.println(2_000_000_000 + 2_000_000_000); -// System.out.println(Math.addExact(2_000_000_000, 2_000_000_000)); - - System.out.println(-2_147_483_647 - 2_147_483_647); -// System.out.println(Math.subtractExact(-2_147_483_647, 2_147_483_647)); - - System.out.println(46_341 * 46_341); -// System.out.println(Math.multiplyExact(46_341, 46_341)); - - System.out.println((-2_147_483_647 - 1) / -1); -// System.out.println(Math.negateExact(Math.subtractExact(-2_147_483_647, 1) / 1)); - - System.out.println(); - System.out.println("Signed 64-bit:"); - System.out.println(-(-9_223_372_036_854_775_807L - 1)); -// System.out.println(Math.negateExact(-9_223_372_036_854_775_807L - 1)); - - System.out.println(5_000_000_000_000_000_000L + 5_000_000_000_000_000_000L); -// System.out.println(Math.addExact(5_000_000_000_000_000_000L, 5_000_000_000_000_000_000L)); - - System.out.println(-9_223_372_036_854_775_807L - 9_223_372_036_854_775_807L); -// System.out.println(Math.subtractExact(-9_223_372_036_854_775_807L, 9_223_372_036_854_775_807L)); - - System.out.println(3_037_000_500L * 3_037_000_500L); -// System.out.println(Math.multiplyExact(3_037_000_500L, 3_037_000_500L)); - - System.out.println((-9_223_372_036_854_775_807L - 1) / -1); -// System.out.println(Math.negateExact(Math.subtractExact(-9_223_372_036_854_775_807L, 1) / 1)); - } - -} diff --git a/Task/Integer-overflow/Java/integer-overflow-1.java b/Task/Integer-overflow/Java/integer-overflow.java similarity index 100% rename from Task/Integer-overflow/Java/integer-overflow-1.java rename to Task/Integer-overflow/Java/integer-overflow.java diff --git a/Task/Integer-overflow/Jq/integer-overflow.jq b/Task/Integer-overflow/Jq/integer-overflow.jq index b61ca08e1f..b74f2de480 100644 --- a/Task/Integer-overflow/Jq/integer-overflow.jq +++ b/Task/Integer-overflow/Jq/integer-overflow.jq @@ -10,16 +10,16 @@ def compare: [ -(-2147483647-1),"2147483648"], [2000000000 + 2000000000, "4000000000"], -[-2147483647 - 2147483647, "-4294967294"], -[46341 * 46341, "2147488281"], -[(-2147483647-1) / -1, "2147483648"], +[-2147483647 - 2147483647, "-4294967294"], +[46341 * 46341, "2147488281"], +[(-2147483647-1) / -1, "2147483648"], "For 64-bit signed integers:", -[-(-9223372036854775807-1), "9223372036854775808"], -[5000000000000000000+5000000000000000000, "10000000000000000000"], -[-9223372036854775807 - 9223372036854775807, "-18446744073709551614"], -[3037000500 * 3037000500, "9223372037000250000"], +[-(-9223372036854775807-1), "9223372036854775808"], +[5000000000000000000+5000000000000000000, "10000000000000000000"], +[-9223372036854775807 - 9223372036854775807, "-18446744073709551614"], +[3037000500 * 3037000500, "9223372037000250000"], [(-9223372036854775807-1) / -1, "9223372036854775808"], "For 32-bit unsigned integers:", diff --git a/Task/Integer-overflow/Julia/integer-overflow-1.jl b/Task/Integer-overflow/Julia/integer-overflow-1.julia similarity index 100% rename from Task/Integer-overflow/Julia/integer-overflow-1.jl rename to Task/Integer-overflow/Julia/integer-overflow-1.julia diff --git a/Task/Integer-overflow/Julia/integer-overflow-2.jl b/Task/Integer-overflow/Julia/integer-overflow-2.julia similarity index 100% rename from Task/Integer-overflow/Julia/integer-overflow-2.jl rename to Task/Integer-overflow/Julia/integer-overflow-2.julia diff --git a/Task/Integer-overflow/Kotlin/integer-overflow.kts b/Task/Integer-overflow/Kotlin/integer-overflow.kotlin similarity index 100% rename from Task/Integer-overflow/Kotlin/integer-overflow.kts rename to Task/Integer-overflow/Kotlin/integer-overflow.kotlin diff --git a/Task/Integer-overflow/Ksh/integer-overflow.ksh b/Task/Integer-overflow/Ksh/integer-overflow.ksh index a88605d4e4..94d4d6dedf 100644 --- a/Task/Integer-overflow/Ksh/integer-overflow.ksh +++ b/Task/Integer-overflow/Ksh/integer-overflow.ksh @@ -2,7 +2,7 @@ # Integer overflow -# # Variables: +# # Variables: # typeset -si SHORT_INT typeset -i INTEGER diff --git a/Task/Integer-overflow/PL-I-80/integer-overflow.pli b/Task/Integer-overflow/PL-I-80/integer-overflow.pli deleted file mode 100644 index 1e873986b5..0000000000 --- a/Task/Integer-overflow/PL-I-80/integer-overflow.pli +++ /dev/null @@ -1,6 +0,0 @@ -overflow_demo: proc options (main); - dcl n fixed bin; - n = 32767; - put skip list (n+2); - put skip list (n*2); -end overflow_demo; diff --git a/Task/Integer-overflow/Pluto/integer-overflow.pluto b/Task/Integer-overflow/Pluto/integer-overflow.pluto deleted file mode 100644 index a8af75f375..0000000000 --- a/Task/Integer-overflow/Pluto/integer-overflow.pluto +++ /dev/null @@ -1,7 +0,0 @@ -local expressions = { - -(-9223372036854775807 - 1), - 5000000000000000000 + 5000000000000000000, - -9223372036854775807 - 9223372036854775807 -} - -for expressions as expr do print(expr) end diff --git a/Task/Integer-overflow/PowerShell/integer-overflow.ps1 b/Task/Integer-overflow/PowerShell/integer-overflow.ps1 deleted file mode 100644 index 86bbd55c7f..0000000000 --- a/Task/Integer-overflow/PowerShell/integer-overflow.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -try { - # All of these raise an exception, which is caught below. - # The try block is aborted after the first exception, - # so the subsequent lines are never executed. - - [int32] (-(-2147483647-1)) - [int32] (2000000000 + 2000000000) - [int32] (-2147483647 - 2147483647) - [int32] (46341 * 46341) - [int32] ((-2147483647-1) / -1) - - [int64] (-(-9223372036854775807-1)) - [int64] (5000000000000000000+5000000000000000000) - [int64] (-9223372036854775807 - 9223372036854775807) - [int64] (3037000500 * 3037000500) - [int64] ((-9223372036854775807-1) / -1) - - [uint32] (-4294967295) - [uint32] (3000000000 + 3000000000) - [uint32] (2147483647 - 4294967295) - [uint32] (65537 * 65537) - - [uint64] (-18446744073709551615) - [uint64] (10000000000000000000 + 10000000000000000000) - [uint64] (9223372036854775807 - 18446744073709551615) - [uint64] (4294967296 * 4294967296) -} -catch { - $Error.Exception -} diff --git a/Task/Integer-overflow/PowerShell/integer-overflow.psh b/Task/Integer-overflow/PowerShell/integer-overflow.psh new file mode 100644 index 0000000000..48524e2b56 --- /dev/null +++ b/Task/Integer-overflow/PowerShell/integer-overflow.psh @@ -0,0 +1,30 @@ +try { + # All of these raise an exception, which is caught below. + # The try block is aborted after the first exception, + # so the subsequent lines are never executed. + + [int32] (-(-2147483647-1)) + [int32] (2000000000 + 2000000000) + [int32] (-2147483647 - 2147483647) + [int32] (46341 * 46341) + [int32] ((-2147483647-1) / -1) + + [int64] (-(-9223372036854775807-1)) + [int64] (5000000000000000000+5000000000000000000) + [int64] (-9223372036854775807 - 9223372036854775807) + [int64] (3037000500 * 3037000500) + [int64] ((-9223372036854775807-1) / -1) + + [uint32] (-4294967295) + [uint32] (3000000000 + 3000000000) + [uint32] (2147483647 - 4294967295) + [uint32] (65537 * 65537) + + [uint64] (-18446744073709551615) + [uint64] (10000000000000000000 + 10000000000000000000) + [uint64] (9223372036854775807 - 18446744073709551615) + [uint64] (4294967296 * 4294967296) +} +catch { + $Error.Exception +} diff --git a/Task/Integer-overflow/Python/integer-overflow-1.py b/Task/Integer-overflow/Python/integer-overflow-1.py index 0627deacc4..b31607a136 100644 --- a/Task/Integer-overflow/Python/integer-overflow-1.py +++ b/Task/Integer-overflow/Python/integer-overflow-1.py @@ -5,11 +5,11 @@ Type "copyright", "credits" or "license()" for more information. -2147483647 - 2147483647 46341 * 46341 (-2147483647-1) / -1'''.split('\n'): - ans = eval(calc) - print('Expression: %r evaluates to %s of type %s' - % (calc.strip(), ans, type(ans))) - + ans = eval(calc) + print('Expression: %r evaluates to %s of type %s' + % (calc.strip(), ans, type(ans))) + Expression: '-(-2147483647-1)' evaluates to 2147483648 of type Expression: '2000000000 + 2000000000' evaluates to 4000000000 of type Expression: '-2147483647 - 2147483647' evaluates to -4294967294 of type diff --git a/Task/Integer-overflow/Python/integer-overflow-2.py b/Task/Integer-overflow/Python/integer-overflow-2.py index 1da7b38e6f..ce1671d160 100644 --- a/Task/Integer-overflow/Python/integer-overflow-2.py +++ b/Task/Integer-overflow/Python/integer-overflow-2.py @@ -5,11 +5,11 @@ Type "copyright", "credits" or "license()" for more information. -2147483647 - 2147483647 46341 * 46341 (-2147483647-1) / -1'''.split('\n'): - ans = eval(calc) - print('Expression: %r evaluates to %s of type %s' - % (calc.strip(), ans, type(ans))) - + ans = eval(calc) + print('Expression: %r evaluates to %s of type %s' + % (calc.strip(), ans, type(ans))) + Expression: '-(-2147483647-1)' evaluates to 2147483648 of type Expression: '2000000000 + 2000000000' evaluates to 4000000000 of type Expression: '-2147483647 - 2147483647' evaluates to -4294967294 of type diff --git a/Task/Integer-overflow/R/integer-overflow.r b/Task/Integer-overflow/R/integer-overflow.r deleted file mode 100644 index ff8070a2d2..0000000000 --- a/Task/Integer-overflow/R/integer-overflow.r +++ /dev/null @@ -1,2 +0,0 @@ -46341*46341L -46341L*46341L diff --git a/Task/Integer-overflow/Rebol/integer-overflow.rebol b/Task/Integer-overflow/Rebol/integer-overflow.rebol deleted file mode 100644 index ec032950ee..0000000000 --- a/Task/Integer-overflow/Rebol/integer-overflow.rebol +++ /dev/null @@ -1,33 +0,0 @@ -Rebol [ - title: "Rosetta code: Integer overflow" - file: %Integer_overflow.r3 - url: https://rosettacode.org/wiki/Integer_overflow -] - -foreach expr [ - ;; For 32-bit signed integers: - [negate (-2147483647 - 1) ] - [2000000000 + 2000000000 ] - [-2147483647 - 2147483647 ] - [46341 * 46341 ] - [(-2147483647 - 1) / -1 ] - ;; For 64-bit signed integers: - [negate (-9223372036854775807 - 1) ] - [5000000000000000000 + 5000000000000000000 ] - [-9223372036854775807 - 9223372036854775807] - [3037000500 * 3037000500 ] - [(-9223372036854775807 - 1) / -1 ] - ;; For 32-bit unsigned integers: - [-4294967295 ] - [3000000000 + 3000000000 ] - [2147483647 - 4294967295 ] - [65537 * 65537 ] - ;; For 64-bit unsigned integers: - [transcode "-18446744073709551615" ] - [transcode " 10000000000000000000" ] - [transcode " 18446744073709551615" ] - [4294967296 * 4294967296 ] -][ - prin [pad mold/only expr 44 ";== "] - print either error? res: try expr [as-red reform [res/type res/id]][res] -] diff --git a/Task/Integer-overflow/Rust/integer-overflow-1.rs b/Task/Integer-overflow/Rust/integer-overflow-1.rust similarity index 100% rename from Task/Integer-overflow/Rust/integer-overflow-1.rs rename to Task/Integer-overflow/Rust/integer-overflow-1.rust diff --git a/Task/Integer-overflow/Rust/integer-overflow-2.rs b/Task/Integer-overflow/Rust/integer-overflow-2.rust similarity index 100% rename from Task/Integer-overflow/Rust/integer-overflow-2.rs rename to Task/Integer-overflow/Rust/integer-overflow-2.rust diff --git a/Task/Integer-overflow/S-BASIC/integer-overflow.basic b/Task/Integer-overflow/S-BASIC/integer-overflow.basic deleted file mode 100644 index 2bd1b5aa2c..0000000000 --- a/Task/Integer-overflow/S-BASIC/integer-overflow.basic +++ /dev/null @@ -1,5 +0,0 @@ -var n = integer -n = 32767 rem - maximum integer value -print n+2 -print n*2 -end diff --git a/Task/Integer-overflow/VBScript/integer-overflow.vb b/Task/Integer-overflow/VBScript/integer-overflow.vb new file mode 100644 index 0000000000..fc10958150 --- /dev/null +++ b/Task/Integer-overflow/VBScript/integer-overflow.vb @@ -0,0 +1,14 @@ +'Binary Integer overflow - vbs +i=(-2147483647-1)/-1 +wscript.echo i +i0=32767 '=32767 Integer (Fixed) type=2 +i1=2147483647 '=2147483647 Long (Fixed) type=3 +i2=-(-2147483647-1) '=2147483648 Double (Float) type=5 +wscript.echo Cstr(i0) & " : " & typename(i0) & " , " & vartype(i0) & vbcrlf _ + & Cstr(i1) & " : " & typename(i1) & " , " & vartype(i1) & vbcrlf _ + & Cstr(i2) & " : " & typename(i2) & " , " & vartype(i2) +ii=2147483648-2147483647 +if vartype(ii)<>3 or vartype(ii)<>2 then wscript.echo "Integer overflow type=" & typename(ii) +i1=1000000000000000-1 '1E+15-1 +i2=i1+1 '1E+15 +wscript.echo Cstr(i1) & " , " & Cstr(i2) diff --git a/Task/Integer-overflow/VBScript/integer-overflow.vbs b/Task/Integer-overflow/VBScript/integer-overflow.vbs deleted file mode 100644 index 2aef204024..0000000000 --- a/Task/Integer-overflow/VBScript/integer-overflow.vbs +++ /dev/null @@ -1,14 +0,0 @@ -'Binary Integer overflow - vbs -i=(-2147483647-1)/-1 -wscript.echo i -i0=32767 '=32767 Integer (Fixed) type=2 -i1=2147483647 '=2147483647 Long (Fixed) type=3 -i2=-(-2147483647-1) '=2147483648 Double (Float) type=5 -wscript.echo Cstr(i0) & " : " & typename(i0) & " , " & vartype(i0) & vbcrlf _ - & Cstr(i1) & " : " & typename(i1) & " , " & vartype(i1) & vbcrlf _ - & Cstr(i2) & " : " & typename(i2) & " , " & vartype(i2) -ii=2147483648-2147483647 -if vartype(ii)<>3 or vartype(ii)<>2 then wscript.echo "Integer overflow type=" & typename(ii) -i1=1000000000000000-1 '1E+15-1 -i2=i1+1 '1E+15 -wscript.echo Cstr(i1) & " , " & Cstr(i2) diff --git a/Task/Integer-overflow/YAMLScript/integer-overflow.ys b/Task/Integer-overflow/YAMLScript/integer-overflow.ys deleted file mode 100644 index d7618a29d2..0000000000 --- a/Task/Integer-overflow/YAMLScript/integer-overflow.ys +++ /dev/null @@ -1,14 +0,0 @@ -!YS-v0 - -tests =: | - -9223372036854775807.-- * -1 - 5000000000000000000 + 5000000000000000000 - -9223372036854775807 - 9223372036854775807 - 3037000500 * 3037000500 - -each test tests:lines: - say: test - try: - eval: test - catch e: - say: "$e\n" diff --git a/Task/Integer-sequence/Ada/integer-sequence-1.adb b/Task/Integer-sequence/Ada/integer-sequence-1.ada similarity index 100% rename from Task/Integer-sequence/Ada/integer-sequence-1.adb rename to Task/Integer-sequence/Ada/integer-sequence-1.ada diff --git a/Task/Integer-sequence/Ada/integer-sequence-2.adb b/Task/Integer-sequence/Ada/integer-sequence-2.ada similarity index 100% rename from Task/Integer-sequence/Ada/integer-sequence-2.adb rename to Task/Integer-sequence/Ada/integer-sequence-2.ada diff --git a/Task/Integer-sequence/ArkScript/integer-sequence-1.ark b/Task/Integer-sequence/ArkScript/integer-sequence-1.ark deleted file mode 100644 index 3292a2f31d..0000000000 --- a/Task/Integer-sequence/ArkScript/integer-sequence-1.ark +++ /dev/null @@ -1,4 +0,0 @@ -(mut i 0) -(while true { - (print i) - (set i (+ 1 i)) }) diff --git a/Task/Integer-sequence/ArkScript/integer-sequence-2.ark b/Task/Integer-sequence/ArkScript/integer-sequence-2.ark deleted file mode 100644 index 99a3156c43..0000000000 --- a/Task/Integer-sequence/ArkScript/integer-sequence-2.ark +++ /dev/null @@ -1,5 +0,0 @@ -(let loop (fun (i) { - (print i) - (loop (+ i 1)) })) - -(loop 0) diff --git a/Task/Integer-sequence/Ballerina/integer-sequence.ballerina b/Task/Integer-sequence/Ballerina/integer-sequence.ballerina deleted file mode 100644 index ac60f4738e..0000000000 --- a/Task/Integer-sequence/Ballerina/integer-sequence.ballerina +++ /dev/null @@ -1,9 +0,0 @@ -import ballerina/io; - -public function main() { - int a = 1; - while true { - io:println(a); - a += 1; - } -} diff --git a/Task/Integer-sequence/COBOL/integer-sequence.cob b/Task/Integer-sequence/COBOL/integer-sequence.cobol similarity index 100% rename from Task/Integer-sequence/COBOL/integer-sequence.cob rename to Task/Integer-sequence/COBOL/integer-sequence.cobol diff --git a/Task/Integer-sequence/Crystal/integer-sequence.cr b/Task/Integer-sequence/Crystal/integer-sequence.crystal similarity index 100% rename from Task/Integer-sequence/Crystal/integer-sequence.cr rename to Task/Integer-sequence/Crystal/integer-sequence.crystal diff --git a/Task/Integer-sequence/Delphi/integer-sequence.pas b/Task/Integer-sequence/Delphi/integer-sequence.delphi similarity index 100% rename from Task/Integer-sequence/Delphi/integer-sequence.pas rename to Task/Integer-sequence/Delphi/integer-sequence.delphi diff --git a/Task/Integer-sequence/EasyLang/integer-sequence.easy b/Task/Integer-sequence/EasyLang/integer-sequence.easy index 8891f16bc4..d3bcc6068c 100644 --- a/Task/Integer-sequence/EasyLang/integer-sequence.easy +++ b/Task/Integer-sequence/EasyLang/integer-sequence.easy @@ -1,10 +1,9 @@ max = pow 2 53 repeat print i - if i = 5 - print "." - print "." - i = max - 6 + if i = 10 + print ".\n." + i = max - 10 . until i = max i += 1 diff --git a/Task/Integer-sequence/Elena/integer-sequence.elena b/Task/Integer-sequence/Elena/integer-sequence.elena index 6e18d53cf6..2294d76879 100644 --- a/Task/Integer-sequence/Elena/integer-sequence.elena +++ b/Task/Integer-sequence/Elena/integer-sequence.elena @@ -1,11 +1,11 @@ import extensions; -public Program() +public program() { var i := 0u; while (true) { - Console.printLine(i); + console.printLine(i); i += 1u } diff --git a/Task/Integer-sequence/Elixir/integer-sequence.ex b/Task/Integer-sequence/Elixir/integer-sequence.elixir similarity index 100% rename from Task/Integer-sequence/Elixir/integer-sequence.ex rename to Task/Integer-sequence/Elixir/integer-sequence.elixir diff --git a/Task/Integer-sequence/Emacs-Lisp/integer-sequence.el b/Task/Integer-sequence/Emacs-Lisp/integer-sequence.l similarity index 100% rename from Task/Integer-sequence/Emacs-Lisp/integer-sequence.el rename to Task/Integer-sequence/Emacs-Lisp/integer-sequence.l diff --git a/Task/Integer-sequence/Euphoria/integer-sequence.eu b/Task/Integer-sequence/Euphoria/integer-sequence.euphoria similarity index 100% rename from Task/Integer-sequence/Euphoria/integer-sequence.eu rename to Task/Integer-sequence/Euphoria/integer-sequence.euphoria diff --git a/Task/Integer-sequence/Gleam/integer-sequence.gleam b/Task/Integer-sequence/Gleam/integer-sequence.gleam deleted file mode 100644 index 36185b1127..0000000000 --- a/Task/Integer-sequence/Gleam/integer-sequence.gleam +++ /dev/null @@ -1,11 +0,0 @@ -import gleam/int -import gleam/io - -pub fn main() { - count_forever(from: 1) -} - -pub fn count_forever(from n: Int) -> Nil { - n |> int.to_string |> io.println - count_forever(n + 1) -} diff --git a/Task/Integer-sequence/Java/integer-sequence-1.java b/Task/Integer-sequence/Java/integer-sequence-1.java index 4b9843e2ba..d8edfd20e6 100644 --- a/Task/Integer-sequence/Java/integer-sequence-1.java +++ b/Task/Integer-sequence/Java/integer-sequence-1.java @@ -1,5 +1,5 @@ -public class Count { - public static void main(String[] args) { +public class Count{ + public static void main(String[] args){ for(long i = 1; ;i++) System.out.println(i); } } diff --git a/Task/Integer-sequence/Java/integer-sequence-2.java b/Task/Integer-sequence/Java/integer-sequence-2.java index 4d89ad5342..2ef70e280e 100644 --- a/Task/Integer-sequence/Java/integer-sequence-2.java +++ b/Task/Integer-sequence/Java/integer-sequence-2.java @@ -1,7 +1,7 @@ import java.math.BigInteger; -public class Count { - public static void main(String[] args) { +public class Count{ + public static void main(String[] args){ for(BigInteger i = BigInteger.ONE; ;i = i.add(BigInteger.ONE)) System.out.println(i); } } diff --git a/Task/Integer-sequence/Java/integer-sequence-3.java b/Task/Integer-sequence/Java/integer-sequence-3.java deleted file mode 100644 index 53d98e12a4..0000000000 --- a/Task/Integer-sequence/Java/integer-sequence-3.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.stream.LongStream; - -public class Count { - public static void main(String[] args) { - LongStream.iterate(1, l -> l + 1) - .forEach(System.out::println); - } -} diff --git a/Task/Integer-sequence/Java/integer-sequence-4.java b/Task/Integer-sequence/Java/integer-sequence-4.java deleted file mode 100644 index fbef74497d..0000000000 --- a/Task/Integer-sequence/Java/integer-sequence-4.java +++ /dev/null @@ -1,10 +0,0 @@ -import static java.math.BigInteger.ONE; - -import java.util.stream.Stream; - -public class Count { - public static void main(String[] args) { - Stream.iterate(ONE, i -> i.add(ONE)) - .forEach(System.out::println); - } -} diff --git a/Task/Integer-sequence/Jq/integer-sequence-1.jq b/Task/Integer-sequence/Jq/integer-sequence-1.jq index 02faf0b0e5..66b3bcd40c 100644 --- a/Task/Integer-sequence/Jq/integer-sequence-1.jq +++ b/Task/Integer-sequence/Jq/integer-sequence-1.jq @@ -1 +1,2 @@ -0 | recurse(. + 1) +def iota: ., (. + 1 | iota); +0 | iota diff --git a/Task/Integer-sequence/Jq/integer-sequence-2.jq b/Task/Integer-sequence/Jq/integer-sequence-2.jq index 66b3bcd40c..75004d0a70 100644 --- a/Task/Integer-sequence/Jq/integer-sequence-2.jq +++ b/Task/Integer-sequence/Jq/integer-sequence-2.jq @@ -1,2 +1 @@ -def iota: ., (. + 1 | iota); -0 | iota +0 | while(true;. + 1) diff --git a/Task/Integer-sequence/Jq/integer-sequence-3.jq b/Task/Integer-sequence/Jq/integer-sequence-3.jq index ed60432096..02faf0b0e5 100644 --- a/Task/Integer-sequence/Jq/integer-sequence-3.jq +++ b/Task/Integer-sequence/Jq/integer-sequence-3.jq @@ -1 +1 @@ -0 | while(true; . + 1) +0 | recurse(. + 1) diff --git a/Task/Integer-sequence/Julia/integer-sequence.jl b/Task/Integer-sequence/Julia/integer-sequence.julia similarity index 100% rename from Task/Integer-sequence/Julia/integer-sequence.jl rename to Task/Integer-sequence/Julia/integer-sequence.julia diff --git a/Task/Integer-sequence/Kotlin/integer-sequence.kotlin b/Task/Integer-sequence/Kotlin/integer-sequence.kotlin new file mode 100644 index 0000000000..72fec53d9d --- /dev/null +++ b/Task/Integer-sequence/Kotlin/integer-sequence.kotlin @@ -0,0 +1,15 @@ +import java.math.BigInteger + +// version 1.0.5-2 + +fun main(args: Array) { + // print until 2147483647 + (0..Int.MAX_VALUE).forEach { println(it) } + + // print forever + var n = BigInteger.ZERO + while (true) { + println(n) + n += BigInteger.ONE + } +} diff --git a/Task/Integer-sequence/Kotlin/integer-sequence.kts b/Task/Integer-sequence/Kotlin/integer-sequence.kts deleted file mode 100644 index b9260df8b4..0000000000 --- a/Task/Integer-sequence/Kotlin/integer-sequence.kts +++ /dev/null @@ -1,10 +0,0 @@ -import java.math.BigInteger - -fun main() { - // Using a 64-bit unsigned type, print until 18446744073709551615 - (1uL..ULong.MAX_VALUE).forEach { println(it) } - - // Using unlimited-size integers, print forever - var n = BigInteger.ONE - while (true) println(n++) -} diff --git a/Task/Integer-sequence/Nu/integer-sequence.nu b/Task/Integer-sequence/Nu/integer-sequence.nu deleted file mode 100644 index 230e385c07..0000000000 --- a/Task/Integer-sequence/Nu/integer-sequence.nu +++ /dev/null @@ -1 +0,0 @@ -for n in 1.. { print $n } diff --git a/Task/Integer-sequence/OCaml/integer-sequence-1.ml b/Task/Integer-sequence/OCaml/integer-sequence-1.ocaml similarity index 100% rename from Task/Integer-sequence/OCaml/integer-sequence-1.ml rename to Task/Integer-sequence/OCaml/integer-sequence-1.ocaml diff --git a/Task/Integer-sequence/OCaml/integer-sequence-2.ml b/Task/Integer-sequence/OCaml/integer-sequence-2.ocaml similarity index 100% rename from Task/Integer-sequence/OCaml/integer-sequence-2.ml rename to Task/Integer-sequence/OCaml/integer-sequence-2.ocaml diff --git a/Task/Integer-sequence/Oberon/integer-sequence.oberon b/Task/Integer-sequence/Oberon-2/integer-sequence.oberon similarity index 100% rename from Task/Integer-sequence/Oberon/integer-sequence.oberon rename to Task/Integer-sequence/Oberon-2/integer-sequence.oberon diff --git a/Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas b/Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas deleted file mode 100644 index 7b206716fb..0000000000 --- a/Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas +++ /dev/null @@ -1 +0,0 @@ -## 1.Step.Print diff --git a/Task/Integer-sequence/PascalABC.NET/integer-sequence-1.pas b/Task/Integer-sequence/PascalABC.NET/integer-sequence.pas similarity index 100% rename from Task/Integer-sequence/PascalABC.NET/integer-sequence-1.pas rename to Task/Integer-sequence/PascalABC.NET/integer-sequence.pas diff --git a/Task/Integer-sequence/PowerShell/integer-sequence.ps1 b/Task/Integer-sequence/PowerShell/integer-sequence.psh similarity index 100% rename from Task/Integer-sequence/PowerShell/integer-sequence.ps1 rename to Task/Integer-sequence/PowerShell/integer-sequence.psh diff --git a/Task/Integer-sequence/Rust/integer-sequence-1.rs b/Task/Integer-sequence/Rust/integer-sequence-1.rust similarity index 100% rename from Task/Integer-sequence/Rust/integer-sequence-1.rs rename to Task/Integer-sequence/Rust/integer-sequence-1.rust diff --git a/Task/Integer-sequence/Rust/integer-sequence-2.rs b/Task/Integer-sequence/Rust/integer-sequence-2.rust similarity index 100% rename from Task/Integer-sequence/Rust/integer-sequence-2.rs rename to Task/Integer-sequence/Rust/integer-sequence-2.rust diff --git a/Task/Integer-sequence/Scheme/integer-sequence.scm b/Task/Integer-sequence/Scheme/integer-sequence.ss similarity index 100% rename from Task/Integer-sequence/Scheme/integer-sequence.scm rename to Task/Integer-sequence/Scheme/integer-sequence.ss diff --git a/Task/Integer-sequence/Sidef/integer-sequence.sidef b/Task/Integer-sequence/Sidef/integer-sequence.sidef index 7af70b5f89..35b95992fe 100644 --- a/Task/Integer-sequence/Sidef/integer-sequence.sidef +++ b/Task/Integer-sequence/Sidef/integer-sequence.sidef @@ -1 +1 @@ -1..Inf -> each {.say} +{|i| say i } * Math.inf; diff --git a/Task/Integer-sequence/Uiua/integer-sequence.uiua b/Task/Integer-sequence/Uiua/integer-sequence.uiua deleted file mode 100644 index 008b417081..0000000000 --- a/Task/Integer-sequence/Uiua/integer-sequence.uiua +++ /dev/null @@ -1 +0,0 @@ -⍢(&p.+1)1 1 diff --git a/Task/Integer-sequence/Ursalang/integer-sequence.ursa b/Task/Integer-sequence/Ursalang/integer-sequence.ursa deleted file mode 100644 index 1a461ebf35..0000000000 --- a/Task/Integer-sequence/Ursalang/integer-sequence.ursa +++ /dev/null @@ -1,5 +0,0 @@ -let i = 1 -loop { - print(i) - i := i + 1 -} diff --git a/Task/Integer-sequence/Uxntal/integer-sequence.uxnatl b/Task/Integer-sequence/Uxntal/integer-sequence.uxnatl deleted file mode 100644 index fdc8e1419c..0000000000 --- a/Task/Integer-sequence/Uxntal/integer-sequence.uxnatl +++ /dev/null @@ -1,23 +0,0 @@ -%comma { [ LIT2 ", -Console/write ] DEO } -%space { [ LIT2 20 -Console/write ] DEO } - -|18 @Console/write - -|100 - -#0001 -&loop - DUP2 print/dec comma space - INC2 !&loop - -BRK - -@print/dec ( short* -- ) - #000a SWP2 [ LITr ff ] - &get - SWP2k DIV2k MUL2 SUB2 STH - POP OVR2 DIV2 ORAk ?&get - POP2 POP2 - &put - STHr INCk ?{ POP JMP2r } - [ LIT "0 ] ADD .Console/write DEO !&put diff --git a/Task/Integer-sequence/Zig/integer-sequence.zig b/Task/Integer-sequence/Zig/integer-sequence.zig deleted file mode 100644 index b3e6c9abd9..0000000000 --- a/Task/Integer-sequence/Zig/integer-sequence.zig +++ /dev/null @@ -1,9 +0,0 @@ -const stdout = @import("std").io.getStdOut().writer(); - -pub fn main() !void { - var i: u128 = 1; - - while (true) : (i += 1) { - try stdout.print("{}, ", .{i}); - } -} diff --git a/Task/Interactive-programming-repl-/AWK/interactive-programming-repl-.awk b/Task/Interactive-programming-repl-/AWK/interactive-programming-repl-.awk deleted file mode 100644 index af020ed818..0000000000 --- a/Task/Interactive-programming-repl-/AWK/interactive-programming-repl-.awk +++ /dev/null @@ -1,4 +0,0 @@ -GAWK -f CON -BEGIN { print(f("Rosetta","Code",":")) } -function f(s1,s2,s3) { return(s1 s3 s3 s2) } -^Z <-- CTRL-Z diff --git a/Task/Interactive-programming-repl-/Crystal/interactive-programming-repl-.cr b/Task/Interactive-programming-repl-/Crystal/interactive-programming-repl-.cr deleted file mode 100644 index 17ba1deb2d..0000000000 --- a/Task/Interactive-programming-repl-/Crystal/interactive-programming-repl-.cr +++ /dev/null @@ -1,11 +0,0 @@ -> crystal i -Crystal interpreter 1.15.1 [89944bf] (2025-02-04). -EXPERIMENTAL SOFTWARE: if you find a bug, please consider opening an issue in -https://github.com/crystal-lang/crystal/issues/new/ -icr:1> def f(s1, s2, sep) -icr:2> s1 + sep + sep + s2 -icr:3> end - => nil -icr:4> f "Rosetta", "Code", ":" - => "Rosetta::Code" -icr:5> diff --git a/Task/Interactive-programming-repl-/Elena/interactive-programming-repl-.elena b/Task/Interactive-programming-repl-/Elena/interactive-programming-repl-.elena index 473d529309..db73a8852d 100644 --- a/Task/Interactive-programming-repl-/Elena/interactive-programming-repl-.elena +++ b/Task/Interactive-programming-repl-/Elena/interactive-programming-repl-.elena @@ -1,29 +1,11 @@ -c:\Alex\ELENA\bin>elt-cli -ELENA command line VM terminal 6.9.6 (C)2021-25 by Aleksey Rakov -Loading repl template -Loading multiline template -Loading get_var template -Loading set_var template -ELENA VM 6.9.14 (32-bit) (C)2022-2025 by Aleksey Rakov, ELENA-LANG Org +c:\Alex\ELENA\bin>elt +ELENA command line VM terminal 5.1.13 (C)2011-2020 by Alexei Rakov +ELENA VM 5.1.17 (C)2005-2020 by Alex Rakov Initializing... -@help - help -@quit - quit -@multiline - switching to a multi-line mode - - evaluate the expression and print the result -$ := ; - assign a global variable -.. $ .. - get a global variable value -@base - set the base path for scripts -@load - execute a script from file -@import - load the script into multi-line script -@use