Euler problem 21.2.2

import Data.Array ( (!), accumArray )

-- ...
    
p21 :: Integer -> Integer
p21 max_ = sum $ filter isAmicable [1 .. max_ - 1]
  where     
    gen n | n > max_ = []
          | otherwise = [(i*n, n) | i <- [2 .. max_ `div` n]] ++ gen (n+1)
    arr = accumArray (+) 0 (0, max_) (gen 1)
    arrb b | b < max_ = arr!b
           | otherwise = sumProperDivisors b
    isAmicable a = let b = (arr!a)
                     in b /= a && arrb b == a

λ> :set +s
λ> p21 10000
31626
(0.06 secs, 71,654,248 bytes)
λ> p21 100000
852810
(0.69 secs, 911,377,712 bytes)
λ> p21 1000000
27220963
(9.84 secs, 11,333,936,728 bytes)
λ> p21 10000000
649734295
(134.77 secs, 139,491,977,584 bytes)
λ> 

— Me@2024-08-18 07:32:17 AM

.

.

2024.08.18 Sunday (c) All rights reserved by ACHK

CSS, 4.2

htmlize, 2.2

.

<pre style="color: #333333;background-color: #f8f8f8;font-size: 16px">
...
</pre>

— Me@2024-08-15 01:20:39 PM

.

.

2024.08.15 Thursday (c) All rights reserved by ACHK

Posted in CSS

Watermelon 2

Euler problem 21.2.1

.

primes :: [Integer]
primes = 2 : filter (null . tail . primeFactors) [3, 5 ..]

primeFactors :: Integer -> [Integer]
primeFactors n = factor n primes
  where
    factor n (p : ps)
      | p * p > n = [n]
      | n `mod` p == 0 = p : factor (n `div` p) (p : ps)
      | otherwise = factor n ps

groupFactors :: [Integer] -> [[Integer]]
groupFactors = gf []
  where
    gf acc lst
      | null lst = reverse acc
      | null acc = gf [[p,1]] ps
      --
      | p == head (head acc) =
        gf ([p, head (tail (head acc)) + 1]:tail acc) ps
      --  
      | otherwise = gf ([p,1]:acc) ps
      where
        p = head lst
        ps = tail lst

generateDivisors :: Integral b => [[b]] -> [b]
generateDivisors xs = go xs 1
  where
    go [] acc = [acc]
    go (pe:ps) acc = concat [go ps (acc*p^e) | e <- [0..n]]
      where
        p = head pe
        n = pe !! 1

sumProperDivisors :: Integer -> Integer
sumProperDivisors n
  = -n + sum (generateDivisors
              (groupFactors (primeFactors n)))

amicableNumbers :: Integer -> [Integer]
amicableNumbers limit
  = [a | a <- [1..(limit-1)],
      let b = sumProperDivisors a, 
            a == sumProperDivisors b,
            a /= b]

λ> :set +s
λ> sum (amicableNumbers 10000)
31626
(0.35 secs, 511,950,576 bytes)
λ> sum (amicableNumbers 100000)
852810
(4.73 secs, 6,902,354,168 bytes)
λ> sum (amicableNumbers 1000000)
27220963
(66.07 secs, 93,880,279,320 bytes)
λ> 

— Me@2024-08-11 10:40:06 AM

.

.

2024.08.12 Monday (c) All rights reserved by ACHK

CSS, 4.1

htmlize, 2.1

.

blockquote {
	font-family: Helvetica;
	font-style: normal;
	color: #4f7499;
	background: #EAEFF3;
	border-left: solid 2px #9ab3cb;
	padding-left: 10px;
	margin-left: 20px;
}

pre {
	white-space: pre-wrap;
	word-wrap; break-word;
}

#infinite-handle {
	display: none;
}

.infinite-scroll #nav-below {
	display: block;
}

.infinite-scroll #content {
	margin-bottom: 0;
}

.wp-caption .wp-caption-text:before {
	display: none;
}

.wp-caption .wp-caption-text {
	text-align: center;
	padding: 5px 7px 0;
}

— Me@2024-08-09 07:00:38 AM

.

.

2024.08.09 Friday (c) All rights reserved by ACHK

Euler problem 21.1

(defmacro sum (lst)
  `(reduce #'+ ,lst))

(defun proper-divisors (n)
  (when (> n 1)  
    (let ((divisors '())
          (limit (floor (sqrt n))))  
      (loop :for i :from 1 :to limit
            :when (zerop (mod n i))  
              :do (progn
                    (push i divisors)  
                    (when (/= n (floor n i))  
                      (push (floor n i)
                            divisors))))  
      (remove-duplicates (sort divisors #'<)
                         :test
                         #'equal))))

(defmacro sum-proper-divisors (n)
  `(sum (proper-divisors ,n)))

(defun amicable-numbers (limit)
  (let ((amicable-pairs '()))
    (loop :for a :from 2 :below limit
          :do (let* ((b (sum-proper-divisors a))
                     (c (sum-proper-divisors b)))
                (when (and (or (< b a)
                               (>= b limit))
                           (= a c))                      
                  (push a amicable-pairs)                 
                  (when (< b limit)
                    (push b amicable-pairs)))))
    (remove-duplicates amicable-pairs
                       :test
                       #'equal)))

(sum (amicable-numbers 10000))

 
CL-USER> (sum (amicable-numbers 10000))
31626
CL-USER> 

— Me@2024-08-06 03:47:01 PM

.

.

2024.08.06 Tuesday (c) All rights reserved by ACHK

1.9 Abstraction of Path Functions, 3.1

Structure and Interpretation of Classical Mechanics

.

(define ((F->C F) local)
  (->local (time local)
           (F local)
           (+ (((partial 0) F) local)
              (* (((partial 1) F) local)
                 (velocity local)))))

The goal of this post is to explain why the code above can be replaced by the following code:

(define (F->C F)
  (define (f-bar q-prime)
    (define q
      (compose F (Gamma q-prime)))
    (Gamma q))
  (Gamma-bar f-bar))

.

While the input of \displaystyle{f} is a tuple \displaystyle{(t, q, v, \cdots)}, the input of \displaystyle{\bar f} is an abstract path \displaystyle{q}.

\displaystyle{\begin{aligned} \Gamma [q] &= (t, q, v, \cdots) \\ \bar f &= f \circ \Gamma \\ \end{aligned}}

.

Let us define \bar \Gamma as

\displaystyle{\begin{aligned}  f &= \bar \Gamma (\bar f) \\  \end{aligned}}

The difference between \displaystyle{\begin{aligned} \Gamma \end{aligned}} and \displaystyle{\begin{aligned} \bar \Gamma \end{aligned}} is that, in an abstract sense, \Gamma transforms f to \bar f, while \bar \Gamma does the opposite.

The explicit form of \bar \Gamma is provided by

\displaystyle{\begin{aligned}  f (t, q(t), v(t), \cdots, q^{(n)}(t))     &= f(\Gamma[q])(t) \\     \bar \Gamma (\bar f) (t, q(t), v(t), \cdots, q^{(n)}(t))     &= \bar f [q](t) \\     \end{aligned}}

(define ((Gamma-bar f-bar) path-q-local-tuple)
  (let* ((tqva path-q-local-tuple)
         (t (time tqva))         
         (O-tqva (osculating-path tqva)))   
    ((f-bar O-tqva) t)))

Note that \bar f is not defined yet because it can be any path-dependent function.

.

What is \displaystyle{F}?

Equation (1.68):

\displaystyle{\begin{aligned}   L' \circ \Gamma[q'] &= L \circ \Gamma [q] \\   \Gamma[q] &= C \circ \Gamma[q'] \\   L' &= L \circ C \\   \end{aligned}}

While F is a coordinate transformation, C is the corresponding local-tuple transformation.

Equation (1.74):

\displaystyle{\begin{aligned}   \Gamma[q] &= C \circ \Gamma[q'] \\   (t, x, v, \cdots) &= (t, F(t,x'), \partial_0 F(t, x') + \partial_1 F(t, x') v', \cdots) \\    \end{aligned}}

Note that:

1. The input of F is a tuple of a path q'. And the output is a coordinate x (aka q(t)).

2. The symbol q represents not the coordinate of a path, but the path itself. The coordinate of the path q is represented by the symbol q(t).

— Me@2024-08-05 10:09:25 PM

.

.

2024.08.05 Monday (c) All rights reserved by ACHK

Zsh, 3

1. Assuming you have already installed the Nix package manager on Ubuntu 22.04 or later, type the following command into the terminal:

nix-env -iA nixpkgs.zsh-autocomplete  

2. Open the Zsh configuration file:

~/.zshrc

Add the following lines to it:

source ~/.nix-profile/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh
 
bindkey -M menuselect '\e' undo

— Me@2024-01-23 08:52:05 AM

.

.

2024.08.01 Thursday (c) All rights reserved by ACHK

World Cup 94, 2

Find the sum of the digits in the number \displaystyle{100!}.

import Data.Char ( digitToInt )

p_20 = sum
       $ map digitToInt
       $ show $ product [1..100]

λ> p_20
648

— Haskell official

— Me@2024-07-17 03:44:42 PM

.

.

2024.07.18 Thursday (c) All rights reserved by ACHK

Batman: Return of the Joker

Euler problem 20.1

.

Find the sum of the digits in the number \displaystyle{100!}.

(reduce #'+
        (map 'list #'digit-char-p
             (write-to-string
              (reduce #'* (loop for i
                                from 1 to 100
                                collect i)))))

CL-USER> 
648

— Me@2024-06-25 08:26:22 PM

.

.

2024.06.26 Wednesday (c) All rights reserved by ACHK

1.9 Abstraction of Path Functions, 2

Structure and Interpretation of Classical Mechanics

.

Let \displaystyle{\bar \Gamma} be a function such that

\displaystyle{\begin{aligned}  f &= \bar \Gamma (\bar f) \\  \end{aligned}}

So, to get a value of \displaystyle{\begin{aligned} f \end{aligned}}, we input a local tuple:

\displaystyle{\begin{aligned}  f (t, q(t), v(t), \cdots, q^{(n)}(t))   &= f (t, q, v, \cdots, q^{(n)})(t) \\   &= f(\Gamma[q])(t) \\   &= f \circ \Gamma[q](t) \\   &= \bar f [q](t) \\   \bar \Gamma (\bar f) (t, q(t), v(t), \cdots, q^{(n)}(t))   &= \bar f [q](t) \\   \end{aligned}}

(define ((Gamma-bar f-bar) path-q-local-tuple)
  (let* ((tqva path-q-local-tuple)
         (t (time tqva))         
         (O-tqva (osculating-path tqva)))   
    ((f-bar O-tqva) t)))

.

The procedure osculating-path takes a number of local components and returns a path with these components; it is implemented as a power series.

In scmutils, you can use the pp function to get the definition of a function. For example, the code

(pp osculating-path)

results

(define ((osculating-path state0) t)
  (let ((t0 (time state0))
        (q0 (coordinate state0))
        (k (vector-length state0)))
    (let ((dt (- t t0)))
      (let loop ((n 2) (sum q0) (dt^n/n! dt))
        (if (fix:= n k)
            sum
            (loop (+ n 1)
                  (+ sum
                     (* (vector-ref state0 n)
                        dt^n/n!))
                  (/ (* dt^n/n! dt) n)))))))

\displaystyle{\begin{aligned}   q(t) &= q_0 + v_0 (t-t_0) + \frac{1}{2} a_0 (t-t_0)^2 + ... +\frac{1}{n!} q^{(n)}_0 (t-t_0)^n \\   &= q_0 + v_0 (dt) + \frac{1}{2} a_0 (dt)^2 + ... +\frac{1}{n!} q^{(n)}_0 (dt)^n \\  \end{aligned}}

.

Note that for the function in the program, \displaystyle{\bar \Gamma (\bar f)}, the input is actually not \displaystyle{(t, q, v, \cdots, q^{(n)})} but \displaystyle{(t, q(t), v(t), \cdots, q^{(n)}(t))}.

\displaystyle{\begin{aligned}  \bar \Gamma (\bar f) (t, q(t), v(t), \cdots) &= \bar f[O(t, q, v, \cdots)](t) \\   \end{aligned}}

.

(define (F->C F)
  (define (f-bar q-prime)
    (define q
      (compose F (Gamma q-prime)))
    (Gamma q))
  (Gamma-bar f-bar))

(show-expression 
 ((F->C p->r)
  (->local 't
           (up 'r 'theta)
           (up 'rdot 'thetadot))))

— Me@2023-12-19 08:16:40 PM

.

.

2024.06.15 Saturday (c) All rights reserved by ACHK

NixOS config

Zsh, 4

.

# Edit this configuration file to define what should be installed on your system.  Help is available in the configuration.nix(5) man page and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/sda";
  boot.loader.grub.useOSProber = true;

  networking.hostName = "hi"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
  networking.wireless.enable = false;
  hardware.bluetooth.enable = false;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Australia/Perth";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_GB.UTF-8";
    LC_IDENTIFICATION = "en_GB.UTF-8";
    LC_MEASUREMENT = "en_GB.UTF-8";
    LC_MONETARY = "en_GB.UTF-8";
    LC_NAME = "en_GB.UTF-8";
    LC_NUMERIC = "en_GB.UTF-8";
    LC_PAPER = "en_GB.UTF-8";
    LC_TELEPHONE = "en_GB.UTF-8";
    LC_TIME = "en_GB.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default, no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.hi = {
    isNormalUser = true;
    description = "hi";
    extraGroups = [ "networkmanager" "wheel" "vboxsf" "vboxusers"];
    shell = pkgs.zsh;
    packages = with pkgs; [
      firefox
      kate
      thunderbird
      chromium
    ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # virtualisation.virtualbox.guest.enable = true;
  # virtualisation.virtualbox.guest.x11 = true;
  # virtualisation.virtualbox.host.enable = true;
  # virtualisation.virtualbox.host.enableExtensionPack = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
    zsh
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-powerlevel10k
    meslo-lgs-nf

    oh-my-zsh
    corefonts
    fira
    powerline-fonts
    ubuntu_font_family
    unifont

    p7zip
    unrar
    unzip

    util-linux
    meld

    home-manager

    git
    git-cola
    github-desktop

    emacs29

    autokey
    virtualbox
    librewolf
    palemoon-bin
    ventoy-full

    flatpak
    steam
    libsForQt5.falkon
    libsForQt5.korganizer
    krusader

    psensor
    playonlinux
    protonvpn-gui

    # vmware-workstation

    quickemu
    quickgui

    neofetch
  ];

  # Some programs need SUID wrappers, can be configured further or are   # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  programs.zsh = {
    enable = true;
    enableCompletion = true;
    autosuggestions.enable = true;
    interactiveShellInit = ''
      source /run/current-system/sw/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
      source /run/current-system/sw/share/zsh-autosuggestions/zsh-autosuggestions.zsh
      source /run/current-system/sw/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
    '';
  };

  fonts = {
    fontDir.enable = true;
    packages = with pkgs; [
      corefonts
      fira
      powerline-fonts
      ubuntu_font_family
      unifont
    ];
  };

  # List services that you want to enable:

   systemd.services.rfkill-block-all = {
     path = [ pkgs.networkmanager ];
     script = ''
       nmcli radio wifi off
     '';
     wantedBy = [ "multi-user.target" ];
   };

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  networking.firewall.enable = true;
  powerManagement.enable = true;
  services.thermald.enable = true;

  # This value determines the NixOS release from which the default settings for stateful data, like file locations and database versions on your system were taken. It‘s perfectly fine and recommended to leave this value at the release version of the first install of this system. Before changing this value read the documentation for this option (e.g. man configuration.nix or on ... ).
  system.stateVersion = "23.11"; # Did you read the comment?
}

— Me@2024-01-23 09:55:24 AM

.

.

2024.02.29 Thursday (c) All rights reserved by ACHK

Euler problem 19.2

How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?

isLeap :: Int -> Bool
isLeap year
  = (mod year 4 == 0
     && mod year 100 /= 0)
  || mod year 400 == 0

daysInMonth :: Int -> Int -> Int
daysInMonth year month
  | month `elem` [1, 3, 5, 7, 8, 10, 12] = 31
  | month `elem` [4, 6, 9, 11] = 30
  | month == 2 = if isLeap year
                 then 29
                 else 28

nextMonth :: Int -> Int -> Int -> Int
nextMonth dayOfWeek y m 
  = (dayOfWeek + daysInMonth y m) `mod` 7

countSundays :: Int -> Int -> Int -> Int -> Int
countSundays startYear startMonth dayOfWeek sundays
  | y > 2000  = sundays
  | m > 12    = countSundays (y+1) 1 dayOfWeek sundays
  | otherwise = countSundays y (m+1) nextDayOfWeek sun
  where
    y = startYear
    m = startMonth
    nextDayOfWeek = nextMonth dayOfWeek y m 
    sun | dayOfWeek == 0 = sundays + 1
        | otherwise      = sundays

e19 :: Int
e19 = countSundays 1901 1 2 0
-- The third argument is dayOfWeek.
-- Its value is 2 here  
-- because 1 Jan 1901 was a Tuesday. 

λ> e19
171
λ> 

— Me@2024-02-10 12:00:39 PM

.

.

2024.02.11 Sunday (c) All rights reserved by ACHK

Euler problem 19.1

How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?

(defun is-leap-year (year)
  (or (and (zerop (mod year 4))
           (not (zerop (mod year 100))))
      (zerop (mod year 400))))

(defun days-in-month (month year)
  (case month
    ((1 3 5 7 8 10 12) 31)
    ((4 6 9 11) 30)
    (2 (if (is-leap-year year)
           29
           28))))

(defun euler-19 ()
  (let ((day-of-week 2) ; 1 Jan 1901 was a Tuesday
        (sundays 0))
    (loop :for year :from 1901 :to 2000 :do
      (loop :for month :from 1 :to 12 :do
        (when (zerop day-of-week) ; 0 represents Sunday
          (incf sundays))
        (setf day-of-week
              (mod
               (+ day-of-week
                  (days-in-month month year))
               7))))
    sundays))

(print (euler-19))

CL-USER> (euler-19)
171
CL-USER> 

— Me@2024-01-30 01:46:11 PM

.

.

2024.01.30 Tuesday (c) All rights reserved by ACHK

1.9 Abstraction of Path Functions

Structure and Interpretation of Classical Mechanics

.

Given a function \displaystyle{f} of a local tuple, a corresponding path-dependent function \displaystyle{\bar f[q]} is

\displaystyle{\bar f[q] = f \circ \Gamma[q]}.

So while the input of \displaystyle{f} is a tuple \displaystyle{(t, q, v, \cdots)}, the input of \displaystyle{\bar f} is an abstract path \displaystyle{q}.

\displaystyle{\begin{aligned}  \Gamma [q] &= (t, q, v, \cdots) \\   \bar f &= f \circ \Gamma \\  \end{aligned}}

.

Given \displaystyle{\bar f} we can reconstitute \displaystyle{f} by taking the argument of \displaystyle{f}, which is a finite initial segment of a local tuple, constructing a path that has this local description, and finding the value of \displaystyle{\bar f} for this path.

1. The goal is to use \displaystyle{\bar f} to reconstitute \displaystyle{f}.

2. The argument of \displaystyle{f} is

\displaystyle{\begin{aligned}  \Gamma [q] &= (t, q, v, \cdots, q^{(n)}) \\   &= (t, q^{(0)}, q^{(1)}, \cdots, q^{(n)}) \\   \end{aligned}}

3. Assume that we have the value of the initial position of the path, \displaystyle{q_0 = q(t=0)}. Then the path \displaystyle{q(t)} can be constructed by

\displaystyle{q(t) = q_0 + v_0 t + \frac{1}{2} a_0 t^2 + ... +\frac{1}{n!} q^{(n)}_0 t^n}

Note that while \displaystyle{q} represents a path, \displaystyle{q(t)} represents the coordinates of the particle location on the path at time \displaystyle{t}.

Knowing the value of \displaystyle{q(t)} for every moment \displaystyle{t} is equivalent to knowing the path \displaystyle{q} as a whole.

— Me@2023-12-19 08:16:40 PM

.

.

2024.01.29 Monday (c) All rights reserved by ACHK

Privacy Statement

Last Updated: November 14, 2025

.

Apps Covered:

1. Keyboard Calendar
2. Keyboard Date Stamp Light
3. Keyboard Date Stamp Pro

Introduction: Our Android apps are designed to enhance user experience by storing settings locally on the device without transmitting them over the internet. We prioritize user privacy and ensure that no personal data is collected or shared.

Data Collection: We want to assure our users that our apps do not collect any personal information, such as names, email addresses, or location data. The apps solely store user preferences and settings locally on the device.

Permissions Note: In particular, Keyboard Calendar requires access to the device’s calendar (via READ_CALENDAR and WRITE_CALENDAR permissions) to enable adding events while typing; this access is local-only and does not involve data transmission.

Keyboard Date Stamp Light and Pro function as input methods and may use standard Android keyboard permissions (e.g., BIND_INPUT_METHOD). They require no special permissions beyond basic app functionality.

Data Security: We take the privacy and security of our users’ data seriously. Since our apps do not transmit any data over the internet, there is minimal risk of data breaches or unauthorized access to personal information.

App Settings Backup: As a default Android setting, the apps allow backup of local app data via the device’s backup service (e.g., to Google Drive). This occurs through Android’s default auto-backup feature, which is enabled by default but configurable in device settings (e.g., Settings > System > Backup). The apps do not send any data over the internet by themselves, and backups are handled entirely by the Android system.

User Control: We believe in empowering our users to have full control over their settings. Users can easily modify or delete their preferences within the apps at any time.

.

.

2024.01.20 Saturday ACHK

7z to encrypt folder with AES 256

Sequential speed, 2 | Restore, 2

.

7za a -mmt4 -tzip -p -mem=AES256 /target_folder/the_zip_file.zip /source_folder/

a

Add files to archive

-mmt[N]

set number of CPU threads

-t{Type}

Set type of archive

-p{Password}

set Password

-m{Parameters}

set compression Method

.

How to check the encryption algorithm of a 7z/zip file?

7z l -slt /target_folder/file.zip

l

List contents of archive

-slt

show technical information for l (List) command

.
To unzip:

7za x /source_folder/the_zip_file.7z -o/target_folder/

x

eXtract files with full paths

-o{Directory}

set Output directory

— Me@2023-11-26 12:17:46 PM

.

.

2024.01.14 Sunday (c) All rights reserved by ACHK

Euler problem 18.2

tri = [[75],
       [95,64],
       [17,47,82],
       [18,35,87,10],
       [20,04,82,47,65],
       [19,01,23,75,03,34],
       [88,02,77,73,07,63,67],
       [99,65,04,28,06,16,70,92],
       [41,41,26,56,83,40,80,70,33],
       [41,48,72,33,47,32,37,16,94,29],
       [53,71,44,65,25,43,91,52,97,51,14],
       [70,11,33,28,77,73,17,78,39,68,17,57],
       [91,71,52,38,17,14,91,43,58,50,27,29,48],
       [63,66,04,68,89,53,67,30,73,16,69,87,40,31],
       [04,62,98,27,23,09,70,98,73,93,38,53,60,04,23]]
  
pathAddItem x (y:ys) (z:zs)
  = (x+m):x:ms
  where 
    (m:ms) | y > z = y:ys
           | otherwise = z:zs
           
listApplyPathAddItem xs ys
  = zipWith3 f xs ys $ tail ys 
  where
    f = pathAddItem
   
e18 = foldr g acc (init tri) 
  where
    toPair x = [x,x]
    g = listApplyPathAddItem
    acc = map toPair $ last tri

— Me@2023-12-28 11:25:22 AM

.

.

2023.12.28 Thursday (c) All rights reserved by ACHK

Euler problem 18.1

(ql:quickload "str")

;; (defun file-get-contents (filename)
;;   (with-open-file (stream filename)
;;     (let ((contents (make-string
;;                      (file-length stream))))
;;       (read-sequence contents stream)
;;       contents)))

(defun file-get-lines (filename)
  (with-open-file (stream filename)
    (loop :for line = (read-line stream nil)
          :while line
          :collect line)))

;; (defun string-to-list (the-string)
;;   (loop :for char :across the-string
;;         :collect char))

;; (defun char-to-integer-list (char-list)
;;   (mapcar #'digit-char-p char-list))

(defun path-add-item (x yys zzs)
  (let* ((y (car yys))
         (ys (cdr yys))
         (z (car zzs))
         (zs (cdr zzs))
         (m (if (> y z) y z))
         (ms (if (> y z) ys zs)))
    (cons (+ x m) (cons x ms))))

(defmacro zipWith3 (f xs ys zs)
  `(mapcar ,f ,xs ,ys ,zs))

(defun path-add-item-zip (acc xs)
  (zipWith3 #'path-add-item xs acc (cdr acc)))

(defun foldl (f acc xs)
  (if (not xs)
      acc
      (foldl f (funcall f acc (car xs)) (cdr xs))))

(defun string-split (x)
  (str:split #\space x))

(defun map-parse-integer (xs)
  (mapcar #'parse-integer xs))

(defmacro map-string-split (xs)
  `(mapcar #'string-split ,xs))

(defmacro head (xs)
  `(car ,xs))

(defmacro tail (xs)
  `(cdr ,xs))

(defun pair-double (x)
  (list x x))

(defun e18 ()
  (let* ((string-lines (file-get-lines #P"n.txt"))
         (string-lists (map-string-split string-lines))
         (number-tower (mapcar #'map-parse-integer
                               string-lists))
         (r-tower (reverse number-tower))
         (acc (mapcar #'pair-double (head r-tower))))
    
    (foldl #'path-add-item-zip acc (tail r-tower))))

CL-USER> (e18)
((1074 75 64 82 87 82 75 73 28 83 32 91 78 58 73 93))
CL-USER> 

— Me@2023-12-20 07:32:00 PM

.

.

2023.12.21 Thursday (c) All rights reserved by ACHK

Taylor expansion of f around x

Series can also be formed by processes such as exponentiation of an
operator or a square matrix. For example, if f is any function of one
argument, and if x and dx are numerical expressions, then this
expression denotes the Taylor expansion of f around x.

(((exp (* dx D)) f) x)
= (+ (f x) (* dx ((D f) x)) (* 1/2 (expt dx 2) (((expt D 2) f) x)) ...)

— refman

.

(((exp (* 'dx D)) (literal-function 'f)) 'x)
#| (*series* (0 . 0) (*number* (expression (f x)) (literal-function #[apply-hook 40]) (type-expression Real)) . #[promise 41 (unevaluated)]) |#

(show-expression
 (series:print (((exp (* 'dx D))
                 (literal-function 'f)) 'x)))
(f x)
(* dx ((D f) x))
(* 1/2 (expt dx 2) (((expt D 2) f) x))
(* 1/6 (expt dx 3) (((expt D 3) f) x))
(* 1/24 (expt dx 4) (((expt D 4) f) x))
(* 1/120 (expt dx 5) (((expt D 5) f) x))
(* 1/720 (expt dx 6) (((expt D 6) f) x))
(* 1/5040 (expt dx 7) (((expt D 7) f) x))
(* 1/40320 (expt dx 8) (((expt D 8) f) x))
(* 1/362880 (expt dx 9) (((expt D 9) f) x))
(* 1/3628800 (expt dx 10) (((expt D 10) f) x))
(* 1/39916800 (expt dx 11) (((expt D 11) f) x))
(* 1/479001600 (expt dx 12) (((expt D 12) f) x))
(* 1/6227020800 (expt dx 13) (((expt D 13) f) x))
(* 1/87178291200 (expt dx 14) (((expt D 14) f) x))
;Aborting!: maximum recursion depth exceeded

— Me@2023-12-20 11:30:50 AM

.

.

2023.12.20 Wednesday (c) All rights reserved by ACHK

Eval the buffer

(defun common-lisp-eval (str)
  (unless (slime-current-connection)
    (let ((wnd (current-window-configuration)))
      (slime)
      (while (not (and (slime-current-connection)
                       (get-buffer-window
                        (slime-output-buffer))))
        (sit-for 0.2))
      (set-window-configuration wnd)))
  (let (deactivate-mark)
    (slime-eval `(swank:eval-and-grab-output ,str))))

(defun file-eval ()
  (interactive)
  (message
   (car (common-lisp-eval
         (concat "(format t \"~{~a~%~}\" (list "
                 (string-make-unibyte
                  (buffer-string)) "))")))))

(defun region-eval (from to)
  (interactive "r")
  (message
   (car (common-lisp-eval
         (concat "(format t \"~{~a~%~}\" (list "
                 (string-make-unibyte
                  (buffer-substring
                   from to)) "))")))))

(global-set-key (kbd "C-F") 'file-eval)
(global-set-key (kbd "C-R") 'region-eval)

— Me@2023-12-10 09:59:57 AM

.

.

2023.12.11 Monday (c) All rights reserved by ACHK