- Commit
- ea51224d227b1056ee562dba10f035f2a2729fa4
- Parent
- 20e70ab22a0de1ec9713cc6aeb61235ac9c64d16
- Author
- Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>
- Date
Restructured the repository to include other language implementations.
An exercise on polyglossy: the same problem solved on multiple languages
Restructured the repository to include other language implementations.
30 files changed, 1672 insertions, 287 deletions
diff --git a/.gitignore b/.gitignore @@ -1,2 +0,0 @@ -/target -**/*.rs.bk
diff --git a/Cargo.lock b/Cargo.lock @@ -1,275 +0,0 @@ -[[package]] -name = "bitflags" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "conjecture_tester" -version = "0.1.0" -dependencies = [ - "crossterm 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_cursor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_input 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_screen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_style 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_terminal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_cursor" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_input" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_screen" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_style" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_terminal" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_cursor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossterm_winapi" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.44" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "termios" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum crossterm 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91f04a703cb52c7ea4f800cda4e6839fb61c33955703dea2a8252d81d87178b3" -"checksum crossterm_cursor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e91c25e521708bd85fbdbdc34a854d1582793ab36e9aff2cee58fc79d7728e82" -"checksum crossterm_input 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "937c314942c75a7893303e3fa1857cfbafdd8a7d8ee369389c79b55cc268c7a7" -"checksum crossterm_screen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48eb1d3e7c5fea9b5a15c8667cb18b8c8fdfb28e38cd8faa048b9b7490cd9f69" -"checksum crossterm_style 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2e4b4a13093fd9c0c16167b14a69ceb8166e079ccda904d41bbfc8ba2714b1b" -"checksum crossterm_terminal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1b61af4ef3ed3624994e8af7ac87b6a483c2936e63eebe38d9a2810cd4a6d44" -"checksum crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d26f24386ea91f9c55a85531dd3ee3673e4c82729e64567928665aca3a47c741" -"checksum crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f63b02344710452064687251b49cb0c275df10ea70dcd6038b1eec11665efc0a" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" -"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" -"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" -"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" -"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" -"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/Cargo.toml b/Cargo.toml @@ -1,9 +0,0 @@ -[package] -name = "conjecture_tester" -version = "0.1.0" -authors = ["Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>"] - -[dependencies] -crossterm = "0.6" -num_cpus = "1.0" -rand = "0.6.1"- \ No newline at end of file
diff --git a/Haskell/.gitignore b/Haskell/.gitignore @@ -0,0 +1 @@ +.stack-work+ \ No newline at end of file
diff --git a/Haskell/LICENSE b/Haskell/LICENSE @@ -0,0 +1,30 @@ +Copyright Author name here (c) 2019 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Author name here nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Haskell/app/Main.hs b/Haskell/app/Main.hs @@ -0,0 +1,55 @@ +module Main where + +import Numeric +import Numeric.Natural +import System.Clock + +main :: IO () +main = do + putStrLn "\nThis program is a simple test for the following conjecture:\n" + putStrLn "Let S: N -> N be the sum of the digits of a positive integer." + putStrLn "For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n" + putStrLn "What value would you like to test the conjecture for?" + + maxStr <- getLine + let max = readDec maxStr + + if (not $ null max) && ((snd $ head max ) == "") + then let counter = exceptions' 0 (fst $ head max) in do + start <- getTime Monotonic + putStrLn "\nLOADING. . ." + + if null counter + then do + end <- getTime Monotonic + putStrLn $ "LOADED in " ++ formatTime (end - start) ++ "s [1 Thread]" + putStrLn $ "\nThe conjecture is proved for all natural numbers smaller or equals to " ++ show (fst $ head max) ++ "!" + exit + else do + putStrLn $ "\nThe conjecture is disproved! Here are the counter examples:\n" ++ (init $ tail $ show counter) + exit + else do + putStrLn $ "\n'" ++ maxStr ++ "' is not a natural number!" + exit + +exit :: IO () +exit = do + putStrLn "Press any key to continue. . ." + getChar + return () + +digs :: Natural -> [Natural] +digs 0 = [0] +digs x = digs (x `div` 10) ++ [x `mod` 10] + +sum' :: Natural -> Natural +sum' x = sum $ digs x + +test' :: Natural -> Natural -> Bool +test' a b = ((fromEnum $ sum' (a + b)) - (fromEnum $ sum' a) - (fromEnum $ sum' b)) `mod` 9 == 0 + +exceptions' :: Natural -> Natural -> [(Natural, Natural)] +exceptions' min max = [(a, b) | a <- [min..max], b <- [a..max], not $ test' a b] + +formatTime :: TimeSpec -> [Char] +formatTime t = show (sec t) ++ "." ++ show (nsec t `div` 10^8)+ \ No newline at end of file
diff --git a/Haskell/conjecture.cabal b/Haskell/conjecture.cabal @@ -0,0 +1,56 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.1. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 3cf9a6d881ec7aedbc39501d43197ec9a1e4562b5d73a7f1f14420405cc67697 + +name: conjecture +version: 1.0.0.0 +description: This program is a simple test for a little conjecture of mine. +author: GarkGarcia +maintainer: thiago.brevidelli.garcia@gmail.com +copyright: 2019 GarkGarcia +license: BSD3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Lib + other-modules: + Paths_conjecture + hs-source-dirs: + src + build-depends: + base >=4.7 && <5 + , clock ==0.7.2 + default-language: Haskell2010 + +executable conjecture-exe + main-is: Main.hs + other-modules: + Paths_conjecture + hs-source-dirs: + app + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + base >=4.7 && <5 + , clock ==0.7.2 + , conjecture + default-language: Haskell2010 + +test-suite conjecture-test + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Paths_conjecture + hs-source-dirs: + test + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + base >=4.7 && <5 + , clock ==0.7.2 + , conjecture + default-language: Haskell2010
diff --git a/Haskell/package.yaml b/Haskell/package.yaml @@ -0,0 +1,47 @@ +name: conjecture +version: 1.0.0.0 +license: BSD3 +author: "GarkGarcia" +maintainer: "thiago.brevidelli.garcia@gmail.com" +copyright: "2019 GarkGarcia" + +extra-source-files: [] + +# Metadata used when publishing your package +# synopsis: Short description of your package +# category: Web + +# To avoid duplicated efforts in documentation and dealing with the +# complications of embedding Haddock markup inside cabal files, it is +# common to point users to the README.md file. +description: This program is a simple test for a little conjecture of mine. + +dependencies: + - base >= 4.7 && < 5 + - clock == 0.7.2 + +library: + source-dirs: src + +executables: + conjecture-exe: + main: Main.hs + source-dirs: app + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - conjecture + - clock == 0.7.2 + +tests: + conjecture-test: + main: Spec.hs + source-dirs: test + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - conjecture
diff --git a/Haskell/src/Lib.hs b/Haskell/src/Lib.hs @@ -0,0 +1 @@ +module Lib where+ \ No newline at end of file
diff --git a/Haskell/stack.yaml b/Haskell/stack.yaml @@ -0,0 +1,68 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# https://docs.haskellstack.org/en/stable/yaml_configuration/ + +# Resolver to choose a 'specific' stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# resolver: lts-3.5 +# resolver: nightly-2015-09-21 +# resolver: ghc-7.10.2 +# +# The location of a snapshot can be provided as a file or url. Stack assumes +# a snapshot provided as a file might change, whereas a url resource does not. +# +# resolver: ./custom-snapshot.yaml +# resolver: https://example.com/snapshots/2018-01-01.yaml +resolver: lts-13.10 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# - location: +# git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# subdirs: +# - auto-update +# - wai +packages: + - . +# Dependency packages to be pulled from upstream that are not in the resolver +# using the same syntax as the packages field. +# (e.g., acme-missiles-0.3) +extra-deps: + - conduit-1.2.13.1@sha256:afd4db7fe66ae7af3d418e1a932384a8dee08df2f6299cca80e53ba964ce1228 + - conduit-extra-1.1.17@sha256:a4e6f476ba86db2c7cb76993b43b2a156b010de2917d239af66f9d7e7599e269 + - resourcet-1.1.11@sha256:096a3db6774a728bbe264e3e25c4e40d60e527ebd4b90c0b311deaa8d4cf4f27 + - streaming-commons-0.1.19@sha256:3a02f84578f75eac1425dca877f8d697b68d379a21970c1dad96196620404803 + +# Override default flag values for local packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=1.9" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor
diff --git a/Haskell/test/Spec.hs b/Haskell/test/Spec.hs @@ -0,0 +1,2 @@ +main :: IO () +main = putStrLn "Test suite not yet implemented"
diff --git a/Latex/digital_sum.aux b/Latex/digital_sum.aux @@ -0,0 +1 @@ +\relax
diff --git a/Latex/digital_sum.log b/Latex/digital_sum.log @@ -0,0 +1,384 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6745 64-bit) (preloaded format=pdflatex 2018.8.8) 27 FEB 2019 11:08 +entering extended mode +**./digital_sum.tex +(digital_sum.tex +LaTeX2e <2018-04-01> patch level 5 +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\article.cls" +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\size10.clo" +File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count80 +\c@section=\count81 +\c@subsection=\count82 +\c@subsubsection=\count83 +\c@paragraph=\count84 +\c@subparagraph=\count85 +\c@figure=\count86 +\c@table=\count87 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\blindtext\blindtex +t.sty" +Package: blindtext 2012/01/06 V2.0 blindtext-Package + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\xspace.sty" +Package: xspace 2014/10/28 v1.13 Space after command names (DPC,MH) +) +\c@blindtext=\count88 +\c@Blindtext=\count89 +\c@blind@countparstart=\count90 +\blind@countxx=\count91 +\blindtext@numBlindtext=\count92 +\blind@countyy=\count93 +\c@blindlist=\count94 +\c@blindlistlevel=\count95 +\c@blindlist@level=\count96 +\blind@listitem=\count97 +\c@blind@listcount=\count98 +\c@blind@levelcount=\count99 +\blind@mathformula=\count100 +\blind@Mathformula=\count101 +\c@blind@randomcount=\count102 +\c@blind@randommax=\count103 +\c@blind@pangramcount=\count104 +\c@blind@pangrammax=\count105 +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\amsfonts. +sty" +Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support +\@emptytoks=\toks14 +\symAMSa=\mathgroup4 +\symAMSb=\mathgroup5 +LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold' +(Font) U/euf/m/n --> U/euf/b/n on input line 106. +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\mathtools\mathtool +s.sty" +Package: mathtools 2018/01/08 v1.21 mathematical typesetting tools + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\keyval.st +y" +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks15 +) ("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\calc.sty" +Package: calc 2017/05/25 v4.3 Infix arithmetic (KKT,FJ) +\calc@Acount=\count106 +\calc@Bcount=\count107 +\calc@Adimen=\dimen103 +\calc@Bdimen=\dimen104 +\calc@Askip=\skip43 +\calc@Bskip=\skip44 +LaTeX Info: Redefining \setlength on input line 80. +LaTeX Info: Redefining \addtolength on input line 81. +\calc@Ccount=\count108 +\calc@Cskip=\skip45 +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\mathtools\mhsetup. +sty" +Package: mhsetup 2017/03/31 v1.3 programming setup (MH) +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsmath.st +y" +Package: amsmath 2017/09/02 v2.17a AMS math features +\@mathmargin=\skip46 + +For additional information on amsmath, use the `?' option. + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amstext.st +y" +Package: amstext 2000/06/29 v2.01 AMS text + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty +" +File: amsgen.sty 1999/11/30 v2.0 generic functions +\@emptytoks=\toks16 +\ex@=\dimen105 +)) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty +" +Package: amsbsy 1999/11/29 v1.2d Bold Symbols +\pmbraise@=\dimen106 +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty +" +Package: amsopn 2016/03/08 v2.02 operator names +) +\inf@bad=\count109 +LaTeX Info: Redefining \frac on input line 213. +\uproot@=\count110 +\leftroot@=\count111 +LaTeX Info: Redefining \overline on input line 375. +\classnum@=\count112 +\DOTSCASE@=\count113 +LaTeX Info: Redefining \ldots on input line 472. +LaTeX Info: Redefining \dots on input line 475. +LaTeX Info: Redefining \cdots on input line 596. +\Mathstrutbox@=\box26 +\strutbox@=\box27 +\big@size=\dimen107 +LaTeX Font Info: Redeclaring font encoding OML on input line 712. +LaTeX Font Info: Redeclaring font encoding OMS on input line 713. +\macc@depth=\count114 +\c@MaxMatrixCols=\count115 +\dotsspace@=\muskip10 +\c@parentequation=\count116 +\dspbrk@lvl=\count117 +\tag@help=\toks17 +\row@=\count118 +\column@=\count119 +\maxfields@=\count120 +\andhelp@=\toks18 +\eqnshift@=\dimen108 +\alignsep@=\dimen109 +\tagshift@=\dimen110 +\tagwidth@=\dimen111 +\totwidth@=\dimen112 +\lineht@=\dimen113 +\@envbody=\toks19 +\multlinegap=\skip47 +\multlinetaggap=\skip48 +\mathdisplay@stack=\toks20 +LaTeX Info: Redefining \[ on input line 2817. +LaTeX Info: Redefining \] on input line 2818. +) +LaTeX Info: Thecontrolsequence`\('isalreadyrobust on input line 129. +LaTeX Info: Thecontrolsequence`\)'isalreadyrobust on input line 129. +LaTeX Info: Thecontrolsequence`\['isalreadyrobust on input line 129. +LaTeX Info: Thecontrolsequence`\]'isalreadyrobust on input line 129. +\g_MT_multlinerow_int=\count121 +\l_MT_multwidth_dim=\dimen114 +\origjot=\skip49 +\l_MT_shortvdotswithinadjustabove_dim=\dimen115 +\l_MT_shortvdotswithinadjustbelow_dim=\dimen116 +\l_MT_above_intertext_sep=\dimen117 +\l_MT_below_intertext_sep=\dimen118 +\l_MT_above_shortintertext_sep=\dimen119 +\l_MT_below_shortintertext_sep=\dimen120 +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\geometry\geometry. +sty" +Package: geometry 2018/04/16 v5.8 Page Geometry + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.s +ty" +Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ifvtex. +sty" +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\ifxetex\ifxetex. +sty" +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count122 +\Gm@cntv=\count123 +\c@Gm@tempcnt=\count124 +\Gm@bindingoffset=\dimen121 +\Gm@wd@mp=\dimen122 +\Gm@odd@mp=\dimen123 +\Gm@even@mp=\dimen124 +\Gm@layoutwidth=\dimen125 +\Gm@layoutheight=\dimen126 +\Gm@layouthoffset=\dimen127 +\Gm@layoutvoffset=\dimen128 +\Gm@dimlist=\toks21 + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\geometry\geometry. +cfg")) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\inputenc.sty" +Package: inputenc 2018/04/06 v1.3b Input encoding file +\inpenc@prehook=\toks22 +\inpenc@posthook=\toks23 +) (digital_sum.aux) +\openout1 = `digital_sum.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 11. +LaTeX Font Info: ... okay on input line 11. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 11. +LaTeX Font Info: ... okay on input line 11. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 11. +LaTeX Font Info: ... okay on input line 11. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 11. +LaTeX Font Info: ... okay on input line 11. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 11. +LaTeX Font Info: ... okay on input line 11. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 11. +LaTeX Font Info: ... okay on input line 11. + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\graphicx. +sty" +Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\graphics. +sty" +Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\trig.sty" +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-cfg\graph +ics.cfg" +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-def\pdfte +x.def" +File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\context\base\supp-pdf.mk +ii" +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count125 +\scratchdimen=\dimen129 +\scratchbox=\box28 +\nofMPsegments=\count126 +\nofMParguments=\count127 +\everyMPshowfont=\toks24 +\MPscratchCnt=\count128 +\MPscratchDim=\dimen130 +\MPnumerator=\count129 +\makeMPintoPDFobject=\count130 +\everyMPtoPDFconversion=\toks25 +))) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\epstopdf- +base.sty" +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\infware +rr.sty" +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\grfext.st +y" +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\kvdefin +ekeys.sty" +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds +.sty" +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +))) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\kvoptions +.sty" +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\kvsetke +ys.sty" +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\etexcmd +s.sty" +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) + +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ifluate +x.sty" +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\pdftexc +mds.sty" +Package: pdftexcmds 2018/01/30 v0.27 Utility functions of pdfTeX for LuaTeX (HO +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. +) +\Gin@req@height=\dimen131 +\Gin@req@width=\dimen132 +) +*geometry* driver: auto-detecting +*geometry* detected driver: pdftex +*geometry* verbose mode - [ preamble ] result: +* driver: pdftex +* paper: a4paper +* layout: <same size as paper> +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* modes: +* h-part:(L,W,R)=(81.94394pt, 433.62pt, 81.94394pt) +* v-part:(T,H,B)=(77.84674pt, 650.43pt, 116.77011pt) +* \paperwidth=597.50787pt +* \paperheight=845.04684pt +* \textwidth=433.62pt +* \textheight=650.43pt +* \oddsidemargin=9.67395pt +* \evensidemargin=9.67395pt +* \topmargin=-31.42325pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=10.0pt +* \footskip=30.0pt +* \marginparwidth=65.0pt +* \marginparsep=11.0pt +* \columnsep=10.0pt +* \skip\footins=9.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +LaTeX Font Info: Try loading font information for U+msa on input line 12. +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd" +File: umsa.fd 2013/01/14 v3.01 AMS symbols A +) +LaTeX Font Info: Try loading font information for U+msb on input line 12. +("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd" +File: umsb.fd 2013/01/14 v3.01 AMS symbols B +) [1 + +{C:/Users/thiag/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] +(digital_sum.aux) ) +Here is how much of TeX's memory you used: + 3364 strings out of 492973 + 50647 string characters out of 3126693 + 126345 words of memory out of 3000000 + 7177 multiletter control sequences out of 15000+200000 + 11901 words of font info for 46 fonts, out of 3000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 55i,7n,34p,301b,197s stack positions out of 5000i,500n,10000p,200000b,50000s +<C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type +1/public/amsfonts/cm/cmbx10.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2 +.9/fonts/type1/public/amsfonts/cm/cmbxti10.pfb><C:/Users/thiag/AppData/Local/Pr +ograms/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmex10.pfb><C:/Users/thiag/App +Data/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Us +ers/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi +7.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsf +onts/cm/cmr10.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1 +/public/amsfonts/cm/cmr12.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9 +/fonts/type1/public/amsfonts/cm/cmr17.pfb><C:/Users/thiag/AppData/Local/Program +s/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr7.pfb><C:/Users/thiag/AppData/Lo +cal/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Users/thi +ag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy7.pfb>< +C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm +/cmti10.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/publi +c/amsfonts/symbols/msbm10.pfb> +Output written on digital_sum.pdf (1 page, 123385 bytes). +PDF statistics: + 58 PDF objects out of 1000 (max. 8388607) + 0 named destinations out of 1000 (max. 500000) + 1 words of extra memory for PDF output out of 10000 (max. 10000000) +
diff --git a/Latex/digital_sum.pdf b/Latex/digital_sum.pdf Binary files differ.
diff --git a/Latex/digital_sum.synctex.gz b/Latex/digital_sum.synctex.gz Binary files differ.
diff --git a/Latex/digital_sum.tex b/Latex/digital_sum.tex @@ -0,0 +1,42 @@ +\documentclass{article} +\usepackage{blindtext} +\usepackage{amsfonts} +\usepackage{mathtools} +\pagenumbering{gobble} +\usepackage[a4paper, total={6in, 9in}]{geometry} +\usepackage[utf8]{inputenc} +\title{Conjectura Mia} +\author{Eli \& Thiago} +\date{29 de dezembro de 2018} +\begin{document} + \maketitle + \section*{\textit{Conjecture:}} + Let $S:\mathbb{N} \rightarrow \mathbb{N}$ be the sum of digits of a number $n \in \mathbb{N}$ --- represented in a \textit{base $\delta$ posicional system} --- and let $\nu \coloneqq \delta - 1$. We have: + + $$ + \forall a, b \in \mathbb{N} : S_{a+b}=S_a + S_b + \nu k, k \in \mathbb{Z} + $$ + + \section*{\textit{Proof:}} + For all $a \in \mathbb{N}$: + $$ + a = a_0 \cdot 10_\delta^0 + a_1 \cdot 10_\delta^1 + \dots + a_n \cdot 10_\delta^n \Rightarrow S_a = a_0 + a_1 + \dots + a_n + $$ + \noindent Therefore: + $$ + \begin{matrix} + a = a_0 \cdot (1 + \nu)^0 + \dots + a_n (1 + \nu)^n = a_0 \cdot (1 + \nu k_0) + \dots + a_n \cdot (1 + \nu k_n) \\ = a_0 + \dots + a_n + \nu k = S_a + \nu k, k \in \mathbb{Z} + \end{matrix} + $$ + + \noindent Thus, for $c \coloneqq a + b$: + $$ + \begin{cases} + & c = S_c + \nu k, k \in \mathbb{Z} \\ + & a + b = (S_a + \nu k) + (S_b + \nu k') = S_a + S_b + \nu k''\;|\; k, k', k''\in \mathbb{Z} + \end{cases} + $$ + + Therefore $c = a + b \Rightarrow S_c + \nu k = S_a + S_b + \nu k'\;|\; k, k'\in \mathbb{Z} \Rightarrow S_c = S_{a + b} = S_a + S_b + \nu k, k \in \mathbb{Z}$ + \noindent \textbf{Q.E.D} +\end{document}+ \ No newline at end of file
diff --git a/README.md b/README.md @@ -0,0 +1,18 @@ +# Conjecture Testing +An exercise on _polyglossy_. The same problem solved on multiple languages. + +## Problem +Let <img src="https://latex.codecogs.com/gif.latex?S:\mathbb{N}&space;\mapsto&space;\mathbb{N}" title="S:\mathbb{N} \mapsto \mathbb{N}" /> be the sum of the digits of a positive integer. + +Prove that <img src="https://latex.codecogs.com/gif.latex?\forall&space;a,&space;b&space;\in\mathbb{N}&space;:&space;S_{a&space;+&space;b}&space;=&space;S_a&space;+&space;S_b&space;+&space;9&space;k,&space;k&space;\in&space;\mathbb{Z}" title="\forall a, b \in\mathbb{N} : S_{a + b} = S_a + S_b + \nu \cdot k, k \in \mathbb{Z}" />. + +## Performance +The conjecture was [proved by exhaustion](https://en.wikipedia.org/wiki/Proof_by_exhaustion) for the interval <img src="https://latex.codecogs.com/gif.latex?[0;10^3]" title="[0;10^3]" /> in multiple language implementations. The performance of each language was then avaliated as the following: +|Language |Time |Number of Threads Used| +|--------------|-------|----------------------| +|**Rust** |22 _s_ |2 | +|**Haskell** |60 _s_ |1 | +|**TypeScript**|198 _s_|1 | +|**JavaScript**|202 _s_|1 | +|**Ruby** |273 _s_|1 | +|**Python** |400 _s_|1 |+ \ No newline at end of file
diff --git a/.gitignore b/Rust/.gitignore
diff --git a/Rust/Cargo.lock b/Rust/Cargo.lock @@ -0,0 +1,275 @@ +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_cursor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_input 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_style 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_terminal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_cursor" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_input" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_screen" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_style" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_terminal" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_cursor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_winapi" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "digital_sum" +version = "0.1.0" +dependencies = [ + "crossterm 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.44" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num_cpus" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_pcg" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "termios" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum crossterm 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91f04a703cb52c7ea4f800cda4e6839fb61c33955703dea2a8252d81d87178b3" +"checksum crossterm_cursor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e91c25e521708bd85fbdbdc34a854d1582793ab36e9aff2cee58fc79d7728e82" +"checksum crossterm_input 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "937c314942c75a7893303e3fa1857cfbafdd8a7d8ee369389c79b55cc268c7a7" +"checksum crossterm_screen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48eb1d3e7c5fea9b5a15c8667cb18b8c8fdfb28e38cd8faa048b9b7490cd9f69" +"checksum crossterm_style 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2e4b4a13093fd9c0c16167b14a69ceb8166e079ccda904d41bbfc8ba2714b1b" +"checksum crossterm_terminal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1b61af4ef3ed3624994e8af7ac87b6a483c2936e63eebe38d9a2810cd4a6d44" +"checksum crossterm_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d26f24386ea91f9c55a85531dd3ee3673e4c82729e64567928665aca3a47c741" +"checksum crossterm_winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f63b02344710452064687251b49cb0c275df10ea70dcd6038b1eec11665efc0a" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" +"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" +"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" +"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" +"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/Rust/Cargo.toml b/Rust/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "digital_sum" +version = "0.1.0" +authors = ["Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>"] + +[dependencies] +crossterm = "0.6" +num_cpus = "1.0" +rand = "0.6.1"+ \ No newline at end of file
diff --git a/src/main.rs b/Rust/src/main.rs
diff --git a/TypeScript/script.js b/TypeScript/script.js @@ -0,0 +1,109 @@ +// The following script is a simple test for the following conjecture: +// Let S: N -> N be the sum of the digits of a positive integer. +// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. +const readline = require('readline'); +class Int { + constructor(n) { + this.val = n; + } + add(n) { + return new Int(this.val + n.val); + } + subtrack(n) { + return new Int(this.val - n.val); + } + multiply(n) { + return new Int(this.val * n.val); + } + divide(n) { + return new Int(Math.floor(this.val / n.val)); + } + incrementBy(n) { + this.val += n.val; + } + divides(n) { + return (n.val / this.val) % 1 == 0; + } + getDigits() { + return Array.from(this.val.toString()).map(char => Int.from(char)); + } + sumDigits() { + let sum = Int.zero(); + const digits = this.getDigits(); + for (const n of digits) + sum.incrementBy(n); + return sum; + } + toString() { + return `${this.val}`; + } + static from(a) { + return new Int(Math.round(Number(a))); + } + static getRange(a, b) { + const start = a.val, end = b.val, range = []; + for (let i = start; i < end; i++) { + range.push(Int.from(i)); + } + return range; + } + static zero() { + return new Int(0); + } + static one() { + return new Int(1); + } +} +function askQuestion(query) { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + return new Promise((resolve) => rl.question(query, (ans) => { + rl.close(); + resolve(ans); + })); +} +function getCounterExp(max) { + const starTime = new Date(), counterexmpls = [], nine = Int.from(9); + let loadBar = Int.zero(); + for (const a of Int.getRange(Int.one(), max)) { + const newLoadBar = a.multiply(Int.from(100)).divide(max); + if (loadBar != newLoadBar) { + console.clear(); + loadBar = newLoadBar; + console.log(`LOADING. . . ${loadBar}%`); + } + for (const b of Int.getRange(a, max)) { + // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9 + const conjectureHolds = nine.divides(a.add(b).sumDigits().subtrack(a.sumDigits().add(b.sumDigits()))); + if (!conjectureHolds) + counterexmpls.push([a, b]); + } + } + const elepsedTime = (new Date().getTime() - starTime.getTime()) / 1000; + console.clear(); + console.log(`LOADED. . . ${loadBar}% in ${elepsedTime}s\n`); + return counterexmpls; +} +console.log(`This script is a simple test for the following conjecture: + +Let S: N -> N be the sum of the digits of a positive integer. +For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. +`); +askQuestion("What value would you like to test the conjecture for? ").then(ans => { + if (!isNaN(Number(ans))) { + const max = Int.from(ans), counterexmpls = getCounterExp(max); + if (counterexmpls.length == 0) + console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`); + else { + console.log("The conjecture is disproved! Here are the counter examples:"); + let counterexmplsStr = ""; + for (const pair of counterexmpls) + counterexmplsStr = `${counterexmplsStr}, (${pair[0]}, ${pair[1]})`; + console.log(counterexmplsStr); + } + } + else + console.log(`'${ans}' is not an interger!`); +}).catch(console.error);
diff --git a/TypeScript/script.min.js b/TypeScript/script.min.js @@ -0,0 +1 @@ +const e=require("readline");class t{constructor(e){this.val=e}add(e){return new t(this.val+e.val)}subtrack(e){return new t(this.val-e.val)}multiply(e){return new t(this.val*e.val)}divide(e){return new t(Math.floor(this.val/e.val))}incrementBy(e){this.val+=e.val}divides(e){return e.val/this.val%1==0}getDigits(){return Array.from(this.val.toString()).map(e=>t.from(e))}sumDigits(){let e=t.zero();const o=this.getDigits();for(const t of o)e.incrementBy(t);return e}toString(){return`${this.val}`}static from(e){return new t(Math.round(Number(e)))}static getRange(e,o){const r=e.val,n=o.val,s=[];for(let e=r;e<n;e++)s.push(t.from(e));return s}static zero(){return new t(0)}static one(){return new t(1)}}console.log("This script is a simple test for the following conjecture:\n \nLet S: N -> N be the sum of the digits of a positive integer.\nFor all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"),function(t){const o=e.createInterface({input:process.stdin,output:process.stdout});return new Promise(e=>o.question(t,t=>{o.close(),e(t)}))}("What value would you like to test the conjecture for? ").then(e=>{if(isNaN(Number(e)))console.log(`'${e}' is not an interger!`);else{const o=t.from(e),r=function(e){const o=new Date,r=[],n=t.from(9);let s=t.zero();for(const o of t.getRange(t.one(),e)){const i=o.multiply(t.from(100)).divide(e);s!=i&&(console.clear(),s=i,console.log(`LOADING. . . ${s}%`));for(const s of t.getRange(o,e))n.divides(o.add(s).sumDigits().subtrack(o.sumDigits().add(s.sumDigits())))||r.push([o,s])}const i=((new Date).getTime()-o.getTime())/1e3;return console.clear(),console.log(`LOADED. . . ${s}% in ${i}s\n`),r}(o);if(0==r.length)console.log(`The conjecture is proved for all natural numbers smaller or equals to ${o}!`);else{console.log("The conjecture is disproved! Here are the counter examples:");let e="";for(const t of r)e=`${e}, (${t[0]}, ${t[1]})`;console.log(e)}}}).catch(console.error);+ \ No newline at end of file
diff --git a/TypeScript/script.ts b/TypeScript/script.ts @@ -0,0 +1,140 @@ +// The following script is a simple test for the following conjecture: + +// Let S: N -> N be the sum of the digits of a positive integer. +// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. + +const readline = require('readline'); + +class Int { + private val: number; + + private constructor(n: number) { + this.val = n; + } + + public add(n: Int): Int { + return new Int(this.val + n.val); + } + + public subtrack(n: Int): Int { + return new Int(this.val - n.val); + } + + public multiply(n: Int): Int { + return new Int(this.val * n.val); + } + + public divide(n: Int): Int { + return new Int(Math.floor(this.val / n.val)); + } + + public incrementBy(n: Int) { + this.val += n.val; + } + + public divides(n: Int): boolean { + return (n.val / this.val) % 1 == 0; + } + + public getDigits(): Int[] { + return Array.from(this.val.toString()).map(char => Int.from(char)); + } + + public sumDigits(): Int { + let sum = Int.zero(); + const digits = this.getDigits(); + + for (const n of digits) + sum.incrementBy(n); + + return sum; + } + + public toString(): string { + return `${this.val}`; + } + + static from(a: number | string): Int { + return new Int(Math.round(Number(a))); + } + + static getRange(a: Int, b: Int): Int[] { + const start = a.val, end = b.val, range: Int[] = []; + + for (let i = start; i < end; i++) { + range.push(Int.from(i)); + } + + return range; + } + + static zero(): Int { + return new Int(0); + } + + static one(): Int { + return new Int(1); + } +} + +function askQuestion(query: string): Promise<string> { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + return new Promise(resolve => rl.question(query, (ans: string) => { + rl.close(); + resolve(ans); + })); +} + +function getCounterExp(max: Int) { + const starTime = new Date(), counterexmpls: [Int, Int][] = [], nine = Int.from(9); + let loadBar = Int.zero(); + + for (const a of Int.getRange(Int.one(), max)) { + + const newLoadBar = a.multiply(Int.from(100)).divide(max); + if (loadBar != newLoadBar) { + console.clear(); + loadBar = newLoadBar; + console.log(`LOADING. . . ${loadBar}%`); + } + + for (const b of Int.getRange(a, max)) { + // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9 + const conjectureHolds = nine.divides(a.add(b).sumDigits().subtrack(a.sumDigits().add(b.sumDigits()))); + if (!conjectureHolds) counterexmpls.push([a, b]); + } + } + + const elepsedTime = (new Date().getTime() - starTime.getTime()) / 1000; + console.clear(); + console.log(`LOADED. . . ${loadBar}% in ${elepsedTime}s\n`); + return counterexmpls; +} + +console.log(`This script is a simple test for the following conjecture: + +Let S: N -> N be the sum of the digits of a positive integer. +For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. +`); + +askQuestion("What value would you like to test the conjecture for? ").then(ans => { + if (!isNaN(Number(ans))) { + const max = Int.from(ans), counterexmpls = getCounterExp(max); + + if (counterexmpls.length == 0) + console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`); + else { + console.log("The conjecture is disproved! Here are the counter examples:"); + + let counterexmplsStr = ""; + for (const pair of counterexmpls) + counterexmplsStr = `${counterexmplsStr}, (${pair[0]}, ${pair[1]})`; + + console.log(counterexmplsStr); + } + } else console.log(`'${ans}' is not an interger!`); +}).catch(console.error);+ \ No newline at end of file
diff --git a/script.js b/script.js @@ -0,0 +1,96 @@ +// The following script is a simple test for the following conjecture: + +// Let S: N -> N be the sum of the digits of a positive integer. +// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. + +const readline = require('readline'); + +Array.prototype.none = function() { + return this.length == 0; +} + +Number.prototype.getDigits = function() { + return Array.from(String(this)).map(char => Number(char)); +} + +Number.prototype.divides = function(n) { + return (n / this) % 1 == 0; +} + +Number.prototype.sumDigits = function() { + let sum = 0; + const digits = this.getDigits(); + + for (n of digits) + sum += n; + + return sum; +} + +function askQuestion(query) { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + return new Promise(resolve => rl.question(query, ans => { + rl.close(); + resolve(ans); + })) +} + +function getCounterExp(max) { + const starTime = new Date(); + + const counterexmpls = []; + let loadBar = 0; + + for (let a = 1; a <= max; a++) { + + // Print the progress on the screen + const newLoadBar = Math.round(a * 100 / max); + if (loadBar != newLoadBar) { + console.clear(); + loadBar = newLoadBar; + console.log(`LOADING. . . ${loadBar}%`); + } + + for (b = a; b <= max; b++) { + + // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9 + const conjectureHolds = (9).divides( + (a + b).sumDigits() - (a.sumDigits() + b.sumDigits()) + ); + if (!conjectureHolds) counterexmpls.push([a, b]); + } + } + + const elepsedTime = (new Date() - starTime) / 1000; + console.clear(); + console.log(`LOADED. . . ${loadBar}% in ${elepsedTime}s\n`); + return counterexmpls; +} + +console.log(`This script is a simple test for the following conjecture: + +Let S: N -> N be the sum of the digits of a positive integer. +For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. +`); + +askQuestion("What value would you like to test the conjecture for? ").then(ans => { + if (!isNaN(Number(ans))) { + const max = Math.round(Number(ans)), counterexmpls = getCounterExp(max); + + if (counterexmpls.none()) + console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`); + else { + console.log("The conjecture is disproved! Here are the counter examples:"); + + let counterexmplsStr = ""; + for (pair in counterexmpls) + counterexmpls = `${counterexmplsStr}, (${pair[0]}, ${pair[1]})`; + + console.log(counterexmplsStr); + } + } else console.log(`'${ans}' is not an interger!`); +});+ \ No newline at end of file
diff --git a/script.min.js b/script.min.js @@ -0,0 +1 @@ +const e=require("readline");Array.prototype.t=function(){return 0==this.length},Number.prototype.o=function(){return Array.from(String(this)).map(e=>Number(e))},Number.prototype.s=function(e){return e/this%1==0},Number.prototype.i=function(){let e=0;const t=this.o();for(n of t)e+=n;return e},console.log("This script is a simple test for the following conjecture:\n \nLet S: N -> N be the sum of the digits of a positive integer.\nFor all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"),function(n){const t=e.createInterface({input:process.stdin,output:process.stdout});return new Promise(e=>t.question(n,n=>{t.close(),e(n)}))}("What value would you like to test the conjecture for? ").then(e=>{if(isNaN(Number(e)))console.log(`'${e}' is not an interger!`);else{const n=Math.round(Number(e)),t=function(e){const n=new Date,t=[];let r=0;for(let n=1;n<=e;n++){const o=Math.round(100*n/e);for(r!=o&&(console.clear(),r=o,console.log(`LOADING. . . ${r}%`)),b=n;b<=e;b++)9..s((n+b).i()-(n.i()+b.i()))||t.push([n,b])}const o=(new Date-n)/1e3;return console.clear(),console.log(`LOADED. . . ${r}% in ${o}s\n`),t}(n);if(t.t())console.log(`The conjecture is proved for all natural numbers smaller or equals to ${n}!`);else{console.log("The conjecture is disproved! Here are the counter examples:");let e="";for(pair in t)t=`${e}, (${pair[0]}, ${pair[1]})`;console.log(e)}}});+ \ No newline at end of file
diff --git a/script.py b/script.py @@ -0,0 +1,84 @@ +# The following script is a simple test for the following conjecture: + +# Let S: N -> N be the sum of the digits of a positive integer. +# For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. + +import sys +import os +import time + +# A function for clearing the prompt +clear = (lambda : os.system("cls")) if sys.platform.startswith("win") else (lambda : os.system("clear")) + +def is_multiple_of_nine(n): + return (n / 9) % 1 == 0 + +def get_digits(n): + output = [] + + for ch in str(n): + output.append(int(ch)) + + return output + +def sum_digits(n): + digits = get_digits(n) + output = 0 + + for d in digits: + output += d + + return output + +def get_counterexmpls(n): + start_time = time.time() + + load_bar = 0 + counterexmpls = [] + + for a in range(n + 1): + + # Print the progress on the screen + if not round(a * 100 / n) == load_bar: + load_bar = round(a * 100 / n) + clear() + print("LOADING. . . %s%%" % load_bar) + + for b in range(a, n + 1): + difference = sum_digits(a + b) - (sum_digits(a) + sum_digits(b)) + + if not is_multiple_of_nine(difference): + counterexmpls.append([a, b]) + + # Mesure the elepsed time + elepsed_time = time.time() - start_time + clear() + print("LOADED. . . %s%% in %ds\n" % (load_bar, elepsed_time)) + + return counterexmpls + + +print("""The following script is a simple test for the following conjecture: + +Let S: N -> N be the sum of the digits of a positive integer. +For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. +""") +user_input = input("What value would you like to test the conjecture for? ") + +try: + maximum = abs(int(user_input)) + clear() + counterexmpls = get_counterexmpls(maximum) + + if len(counterexmpls) == 0: + print("The conjecture is proved for all natural numbers smaller or equals to %s!" % maximum) + else: + print("The conjecture is disproved! Here are the counter examples:") + + counterexmpls_str = "" + for pair in counterexmpls: + counterexmpls_str = "%s, (%d, %f)" % (counterexmpls_str, pair[0], pair[1]) + + print(counterexmpls_str) +except: + print("'%s' isn't a valid number!" % user_input)
diff --git a/script.rb b/script.rb @@ -0,0 +1,98 @@ +class Integer + def divides n + return (n / self) * self == n + end + + def digits base: 10 + quotient, remainder = divmod(base) + return quotient == 0 ? [remainder] : [*quotient.digits(base: base), remainder] + end + + def sum_digits + sum = 0 + + for n in self.digits + sum += n + end + + return sum + end +end + +def get_counterexpls max + start_time = Time.now + + counterexpls = [] + progress_percent = 0 + + for a in (0..max) + new_progress = a * 100 / max + + if progress_percent != new_progress + progress_percent = new_progress + clear() + puts "LOADING. . . #{new_progress}%" + end + + for b in (a..max) + difference = (a + b).sum_digits() - a.sum_digits() - b.sum_digits() + + if !9.divides(difference) + counterexpls.push([a, b]) + end + end + end + + elepsed_time = Time.now - start_time + clear() + puts "LOADED. . . #{progress_percent}% in #{elepsed_time}s\n\n" + + return counterexpls +end + +def clear + if /win32|win64|\.NET|windows|cygwin|mingw32/i.match(RUBY_PLATFORM) + system('cls') + else + system('clear') + end +end + +def pause + if /win32|win64|\.NET|windows|cygwin|mingw32/i.match(RUBY_PLATFORM) + system('pause') + else + system('read') + end +end + +puts "The following script is a simple test for the following conjecture:\n\n" +puts "Let S: N -> N be the sum of the digits of a positive integer." +puts "For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n\n" +puts "What value would you like to test the conjecture for?" + +user_input = gets + +# Check if the input provided by the user in an iteger +if /^(?:-?[1-9]\d*$)|(?:^0)$/.match(user_input) + max = user_input.to_i() + counterexpls = get_counterexpls(max) + + if counterexpls.length == 0 + puts "The conjecture is proved for all natural numbers smaller or equals to #{max}!" + else + puts "The conjecture is disproved! Here are the counter examples:" + + counterexpls_str = "" + for pair in counterexpls + counterexpls_str = "#{counterexpls_str}, (#{pair[0]}, #{pair[1]})" + end + + puts counterexpls_str + end +else + puts "'#{user_input.chomp}' isn't an iteger!" +end + +puts "" +pause()+ \ No newline at end of file
diff --git a/script.ts b/script.ts @@ -0,0 +1,140 @@ +// The following script is a simple test for the following conjecture: + +// Let S: N -> N be the sum of the digits of a positive integer. +// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. + +const readline = require('readline'); + +class Int { + private val: number; + + private constructor(n: number) { + this.val = n; + } + + public add(n: Int): Int { + return new Int(this.val + n.val); + } + + public subtrack(n: Int): Int { + return new Int(this.val - n.val); + } + + public multiply(n: Int): Int { + return new Int(this.val * n.val); + } + + public divide(n: Int): Int { + return new Int(Math.floor(this.val / n.val)); + } + + public incrementBy(n: Int) { + this.val += n.val; + } + + public divides(n: Int): boolean { + return (n.val / this.val) % 1 == 0; + } + + public getDigits(): Int[] { + return Array.from(this.val.toString()).map(char => Int.from(char)); + } + + public sumDigits(): Int { + let sum = Int.zero(); + const digits = this.getDigits(); + + for (const n of digits) + sum.incrementBy(n); + + return sum; + } + + public toString(): string { + return `${this.val}`; + } + + static from(a: number | string): Int { + return new Int(Math.round(Number(a))); + } + + static getRange(a: Int, b: Int): Int[] { + const start = a.val, end = b.val, range: Int[] = []; + + for (let i = start; i < end; i++) { + range.push(Int.from(i)); + } + + return range; + } + + static zero(): Int { + return new Int(0); + } + + static one(): Int { + return new Int(1); + } +} + +function askQuestion(query: string) { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + return new Promise((resolve: (value?: string | PromiseLike<string>) => void) => rl.question(query, (ans: string) => { + rl.close(); + resolve(ans); + })); +} + +function getCounterExp(max: Int) { + const starTime = new Date(), counterexmpls: [Int, Int][] = [], nine = Int.from(9); + let loadBar = Int.zero(); + + for (const a of Int.getRange(Int.one(), max)) { + + const newLoadBar = a.multiply(Int.from(100)).divide(max); + if (loadBar != newLoadBar) { + console.clear(); + loadBar = newLoadBar; + console.log(`LOADING. . . ${loadBar}%`); + } + + for (const b of Int.getRange(a, max)) { + // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9 + const conjectureHolds = nine.divides(a.add(b).sumDigits().subtrack(a.sumDigits().add(b.sumDigits()))); + if (!conjectureHolds) counterexmpls.push([a, b]); + } + } + + const elepsedTime = (new Date().getTime() - starTime.getTime()) / 1000; + console.clear(); + console.log(`LOADED. . . ${loadBar}% in ${elepsedTime}s\n`); + return counterexmpls; +} + +console.log(`This script is a simple test for the following conjecture: + +Let S: N -> N be the sum of the digits of a positive integer. +For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. +`); + +askQuestion("What value would you like to test the conjecture for? ").then(ans => { + if (!isNaN(Number(ans))) { + const max = Int.from(ans), counterexmpls = getCounterExp(max); + + if (counterexmpls.length == 0) + console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`); + else { + console.log("The conjecture is disproved! Here are the counter examples:"); + + let counterexmplsStr = ""; + for (const pair of counterexmpls) + counterexmplsStr = `${counterexmplsStr}, (${pair[0]}, ${pair[1]})`; + + console.log(counterexmplsStr); + } + } else console.log(`'${ans}' is not an interger!`); +}).catch(console.error);+ \ No newline at end of file
diff --git a/script.ts.js b/script.ts.js @@ -0,0 +1 @@ +const e=require("readline");class t{constructor(e){this.val=e}add(e){return new t(this.val+e.val)}subtrack(e){return new t(this.val-e.val)}multiply(e){return new t(this.val*e.val)}divide(e){return new t(Math.floor(this.val/e.val))}incrementBy(e){this.val+=e.val}divides(e){return e.val/this.val%1==0}getDigits(){return Array.from(this.val.toString()).map(e=>t.from(e))}sumDigits(){let e=t.zero();const o=this.getDigits();for(const t of o)e.incrementBy(t);return e}toString(){return`${this.val}`}static from(e){return new t(Math.round(Number(e)))}static getRange(e,o){const r=e.val,n=o.val,s=[];for(let e=r;e<n;e++)s.push(t.from(e));return s}static zero(){return new t(0)}static one(){return new t(1)}}console.log("This script is a simple test for the following conjecture:\n \nLet S: N -> N be the sum of the digits of a positive integer.\nFor all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"),function(t){const o=e.createInterface({input:process.stdin,output:process.stdout});return new Promise(e=>o.question(t,t=>{o.close(),e(t)}))}("What value would you like to test the conjecture for? ").then(e=>{if(isNaN(Number(e)))console.log(`'${e}' is not an interger!`);else{const o=t.from(e),r=function(e){const o=new Date,r=[],n=t.from(9);let s=t.zero();for(const o of t.getRange(t.one(),e)){const i=o.multiply(t.from(100)).divide(e);s!=i&&(console.clear(),s=i,console.log(`LOADING. . . ${s}%`));for(const s of t.getRange(o,e))n.divides(o.add(s).sumDigits().subtrack(o.sumDigits().add(s.sumDigits())))||r.push([o,s])}const i=((new Date).getTime()-o.getTime())/1e3;return console.clear(),console.log(`LOADED. . . ${s}% in ${i}s\n`),r}(o);if(0==r.length)console.log(`The conjecture is proved for all natural numbers smaller or equals to ${o}!`);else{console.log("The conjecture is disproved! Here are the counter examples:");let e="";for(const t of r)e=`${e}, (${t[0]}, ${t[1]})`;console.log(e)}}}).catch(console.error);+ \ No newline at end of file