Skip to content

plerros/helsing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

336 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Helsing

Helsing is a command-line program that scans intervals for vampire numbers.

helsing_gif

The default algorithm has a time complexity of $O(u)$ and a space complexity of $O(\sqrt{u})$, where $u$ is the upper bound argument -u.

In helsing/configuration.h you can toggle the algorithms and tune them, adjust verbosity, change the numeral base system, enable 128-bit (or bigger) maths, and set a fang pairs filter. Some of the features aren't compatible with Windows. Be sure to read the documentation.

MacOS Preparation

On MacOS you'll have to install homebrew.

Building

  1. Install dependencies

    Platform Install Command Packages Optional
    Windows (*) - MSVC -
    MacOS brew install git gcc cmake openssl (broken)
    Debian/Ubuntu sudo apt install libssl-dev
    Fedora/RHEL sudo dnf install openssl-devel
    FreeBSD: pkg install openssl-devel
    HaikuOS pkgman install (pre-installed)
    Openindiana pkg install git gcc-14 cmake library/security/openssl-3
    You can also use clang instead of gcc
  2. Download

    git clone https://github.com/plerros/helsing.git
    cd helsing/helsing
    
  3. Compile

    Platform Compile
    Windows (*) mkdir build & cd build & cmake .. & cmake --build . --config Release
    MacOS mkdir build; cd build; cmake ..; make
    Debian/Ubuntu
    Fedora/RHEL
    FreeBSD:
    HaikuOS
    Openindiana

(*): Some configuration.h features are linux-only and lead to build failure on Windows.

Run

./helsing -l min -u max

Examples:

$ ./helsing -l 1260 -u 1260
Checking interval: [1260, 1260]
Found: 1 vampire number(s).

$ ./helsing -l 0 -u 1172560176
Adjusted min from 0 to 10
Checking interval: [10, 99]
Checking interval: [1000, 9999]
Checking interval: [100000, 999999]
Checking interval: [10000000, 99999999]
Checking interval: [1000000000, 1172560176]
Found: 10000 vampire number(s).

$ ./helsing -l 18446744073709551615 -u 18446744073709551615
Checking interval: [18446744073709551615, 18446744073709551615]
Found: 0 vampire number(s).

Run for all n-digit numbers

./helsing -n number_of_digits

Examples:

$ ./helsing -n 2
Checking interval: [10, 99]
Found: 0 vampire number(s).

$ ./helsing -n 4
Checking interval: [1000, 9999]
Found: 7 vampire number(s).

$ ./helsing -n 12
Checking interval: [100000000000, 999999999999]
Found: 4390670 vampire number(s).

$ ./helsing -n 14
Checking interval: [10000000000000, 99999999999999]
Found: 208423682 vampire number(s).

$ ./helsing -n 16
Checking interval: [1000000000000000, 9999999999999999]
Found: 11039126154 vampire number(s).

Checkpoints:

./helsing -n number_of_digits -c checkpoint
./helsing -l min -u max -c checkpoint

Example:

$ ./helsing -n 4 -c my.checkpoint
Checking interval: [1000, 9999]
Found: 7 vampire number(s).

$ ls
build           configuration_adv.h  helsing   my.checkpoint  src
CMakeLists.txt  configuration.h      Makefile  scripts        test

To resume from it:

./helsing -c checkpoint

Set the number of threads

./helsing -t threads

Examples:

$ time ./helsing -n 12 -t 1
Checking interval: [100000000000, 999999999999]
Found: 4390670 vampire number(s).

real	0m36.781s
user	0m36.678s
sys	0m0.025s

$ time ./helsing -n 12 -t 2
Checking interval: [100000000000, 999999999999]
Found: 4390670 vampire number(s).

real	0m18.592s
user	0m36.581s
sys	0m0.037s

$ time ./helsing -n 12 -t 4
Checking interval: [100000000000, 999999999999]
Found: 4390670 vampire number(s).

real	0m9.402s
user	0m37.361s
sys	0m0.041s

time ./helsing -n 12 -t 8
Checking interval: [100000000000, 999999999999]
Found: 4390670 vampire number(s).

real	0m4.913s
user	0m38.510s
sys	0m0.044s

time ./helsing -n 12 -t 12
Checking interval: [100000000000, 999999999999]
Found: 4390670 vampire number(s).

real	0m3.344s
user	0m39.233s
sys	0m0.030s

Display progress

./helsing --progress

Example:

$ ./helsing -n 12 --progress
Checking interval: [100000000000, 999999999999]
100000000000, 199999999999  1/9
200000000000, 299999999999  2/9
300000000000, 399999999999  3/9
400000000000, 499999999999  4/9
500000000000, 599999999999  5/9
600000000000, 699999999999  6/9
700000000000, 799999999999  7/9
800000000000, 899999999999  8/9
900000000000, 999998000001  9/9
Found: 4390670 vampire number(s).

Dry run

./helsing --dry-run

Example:

$ ./helsing -l 0 -u 18446744073709551615 --dry-run
Adjusted min from 0 to 10
Checking interval: [10, 99]
Checking interval: [1000, 9999]
Checking interval: [100000, 999999]
Checking interval: [10000000, 99999999]
Checking interval: [1000000000, 9999999999]
Checking interval: [100000000000, 999999999999]
Checking interval: [10000000000000, 99999999999999]
Checking interval: [1000000000000000, 9999999999999999]
Checking interval: [100000000000000000, 999999999999999999]
Checking interval: [10000000000000000000, 18446744073709551615]
Found: 0 vampire number(s).

Display build configuration

./helsing --buildconf

Example:

$ ./helsing --buildconf
  configuration:
    FANG_PAIR_OUTPUTS=false
    VAMPIRE_NUMBER_OUTPUTS=true
        VAMPIRE_INDEX=false
        VAMPIRE_PRINT=false
        VAMPIRE_INTEGRAL=false
        VAMPIRE_HASH=false
    MIN_FANG_PAIRS=1
    MAX_FANG_PAIRS=1
    MEASURE_RUNTIME=false
    ALG_NORMAL=false
    ALG_CACHE=true
        PARTITION_METHOD=0
        MULTIPLICAND_PARTITIONS=2
        PRODUCT_PARTITIONS=3
    BASE=10
    MAX_TASK_SIZE=99999999999
    USE_CHECKPOINT=true
    LINK_SIZE=100
    LLMSENTENCE_LIMIT=10000
    TASKBOARD_LIMIT=1000000
    SAFETY_CHECKS=false