| ID | dc8243bc-1d7e-4229-92a0-4f697ace3c74 |
|---|---|
| DEERTOPIAVISIBILITY | public |
Project Euler (APL)
unimplemented! (keyword)
{:type "keyword",
:affiliated {},
:key "PROPERTY",
:value "header-args :session *new*",
:position
{:start {:line 6, :column 1, :offset 125},
:end {:line 7, :column 1, :offset 164}}}
This is an attempt to learn APL. }:)
Problems
1. Multiples of 3 or 5
βIOβ1
+/βΈβ¨βΏ0=3 5β.|β³999
unimplemented! (fixed-width)
{:type "fixed-width",
:affiliated {:results ""},
:value "233168\n",
:position
{:start {:line 22, :column 1, :offset 391},
:end {:line 23, :column 2, :offset 401}}}
2. Even Fibonacci
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first terms will be 1, 2, 3, 5, 8, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
{+/β΅[βΈ~2|β΅]}({β΅,+/Β―2ββ΅}β£{4e6<Β―1ββ΅})0 1
unimplemented! (fixed-width)
{:type "fixed-width",
:affiliated {:results ""},
:value "4613732\n",
:position
{:start {:line 38, :column 1, :offset 825},
:end {:line 39, :column 2, :offset 836}}}
3. Largest prime factor
The prime factors of 13 915 are 5, 7, 13, and 29.
What is the largest prime factor of 600 851 475 143?
fβ{βΊβ2β(βΊΓβΊ)>ββ΅:ββ΅β0=βΊ|ββ΅:βΊβ((ββ΅)Γ·βΊ),βΊ,1ββ΅β({2=β΅:3ββ΅+2}βΊ)ββ΅}
f 600851475143
unimplemented! (fixed-width)
{:type "fixed-width",
:affiliated {:results ""},
:value "6857\n",
:position
{:start {:line 55, :column 1, :offset 1119},
:end {:line 56, :column 2, :offset 1127}}}
4. Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 91 Γ 99.
Find the largest palindrome made from the product of two 3-digit numbers.
First solution
I wrote this before learning I could use Format (β) in place of d.
βIOβ0
dβ{β΅<10:β΅β(βββ΅Γ·10),(10|β΅)}
pβ{{β§/=βΏββ΅ (β½β΅)}dβ΅}
{{β/β΅[βΈpΒ¨β΅]}β΅β.Γβ΅}100+β³899
unimplemented! (fixed-width)
{:type "fixed-width",
:affiliated {:results ""},
:value "906609\n",
:position
{:start {:line 78, :column 1, :offset 1608},
:end {:line 79, :column 2, :offset 1618}}}
Second solution
βIOβ0
pβ{{β§/=βΏββ΅(β½β΅)}ββ΅}
{β/β΅[βΈpΒ¨β΅]}β.Γβ¨100+β³899 β 10+β³89
unimplemented! (fixed-width)
{:type "fixed-width",
:affiliated {:results ""},
:value "906609\n",
:position
{:start {:line 90, :column 1, :offset 1745},
:end {:line 91, :column 2, :offset 1755}}}
5. Smallest Multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
Using the built-in LCM function
This is a bit too easy. }:P
βIOβ1
β§/β³20
unimplemented! (fixed-width)
{:type "fixed-width",
:affiliated {:results ""},
:value "232792560\n",
:position
{:start {:line 111, :column 1, :offset 2139},
:end {:line 112, :column 2, :offset 2152}}}
Handmade LCM
β Modified from function used in the "Largest Prime Factor"
β problem.
fβ{βΊβ2β(βΊΓβΊ)>ββ΅:β΅β0=βΊ|ββ΅:βΊβ((ββ΅)Γ·βΊ),βΊ,1ββ΅β({2=β΅:3ββ΅+2}βΊ)ββ΅}
uhhhh longest mountain pass lol
References
[cite:@geiss2022getting]