Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Post Undeleted by Delfad0r
added 814 characters in body
Source Link
Delfad0r
  • 6.3k
  • 20
  • 32

Haskell, 34 bytes

data T=E|N T T
f=E:scanl N(N E E)f

Try it online!

f is the infinite list of Fibonacci trees, represented as a custom type defined in the first line (E is the empty tree, N l r is the tree with left subtree l and right subtree r).

How?

Haskell is usually very well-suited for Fibonacci-related tasks. Assume we have a recurrence of the form $$ \begin{cases} \texttt{f}_0=\texttt{a}\\ \texttt{f}_1=\texttt{b}\\ \texttt{f}_{n+2}=\texttt{g}(\texttt{f}_{n+1},\texttt{f}_n), \end{cases} $$ where \$\texttt{g}\$ is a binary operator. Then the corresponding Haskell definition is simply

f=a:scanl g b f

Unfortunately, Haskell is not very well-suited for problems involving trees, since it can't (natively) handle nested lists or tuples. Defining my own data type for trees was the shortest way I could find to solve this issue.

Haskell, 34 bytes

data T=E|N T T
f=E:scanl N(N E E)f

Try it online!

Haskell, 34 bytes

data T=E|N T T
f=E:scanl N(N E E)f

Try it online!

f is the infinite list of Fibonacci trees, represented as a custom type defined in the first line (E is the empty tree, N l r is the tree with left subtree l and right subtree r).

How?

Haskell is usually very well-suited for Fibonacci-related tasks. Assume we have a recurrence of the form $$ \begin{cases} \texttt{f}_0=\texttt{a}\\ \texttt{f}_1=\texttt{b}\\ \texttt{f}_{n+2}=\texttt{g}(\texttt{f}_{n+1},\texttt{f}_n), \end{cases} $$ where \$\texttt{g}\$ is a binary operator. Then the corresponding Haskell definition is simply

f=a:scanl g b f

Unfortunately, Haskell is not very well-suited for problems involving trees, since it can't (natively) handle nested lists or tuples. Defining my own data type for trees was the shortest way I could find to solve this issue.

deleted 71 characters in body
Source Link
Delfad0r
  • 6.3k
  • 20
  • 32

Haskell, 2534 bytes

[n|n<-[1..],moddata T=E|N T T
f=E:scanl N(60^nN E E)n>0]f

Try it online!

The infinite list of non-Hamming numbers

How?

(Hopefully) a positive integer \$n\$ is Hamming if and only if \$n\$ does not divide \60ドル^n\$.Try it online!

Haskell, 25 bytes

[n|n<-[1..],mod(60^n)n>0]

Try it online!

The infinite list of non-Hamming numbers

How?

(Hopefully) a positive integer \$n\$ is Hamming if and only if \$n\$ does not divide \60ドル^n\$.

Haskell, 34 bytes

data T=E|N T T
f=E:scanl N(N E E)f

Try it online!

Post Deleted by Delfad0r
Source Link
Delfad0r
  • 6.3k
  • 20
  • 32

Haskell, 25 bytes

[n|n<-[1..],mod(60^n)n>0]

Try it online!

The infinite list of non-Hamming numbers

How?

(Hopefully) a positive integer \$n\$ is Hamming if and only if \$n\$ does not divide \60ドル^n\$.

AltStyle によって変換されたページ (->オリジナル) /