jblog
toc

A285494

2017-06-03, post № 171

mathematics, OEIS, programming, Python, Wolfram Language, #decimal, #decimal sum, #digit sum, #distinct prime, #int, #integer, #number, #number theory, #prime, #prime factors, #primes

The On-Line Encyclopedia of Integer Sequences gets regularly updated with new integer sequences. One of the recent updates was contributed by me, A285494.

A285494 is the list of all numbers 𝑘 so that its digit sum equals its number of distinct prime factors.
A number’s digit sum is the sum of all of its decimal digits. The number 𝟨𝟤𝟪𝟥𝟣𝟪𝟧𝟥, for example, has a digit sum of 𝟨 + 𝟤 + 𝟪 + 𝟥 + 𝟣 + 𝟪 + 𝟧 + 𝟥 = 𝟥𝟨.
A number’s number of distinct prime factors is the number of different prime numbers that multiply together to result in the original number. As an example, 62831853=3^2\cdot 7\cdot 127\cdot 7853, so it has five prime factors of which four are distinct.
Thereby one can conclude that 𝟨𝟤𝟪𝟥𝟣𝟪𝟧𝟥 is not an entry in this sequence, as 36\neq 4.

The sequence is certainly infinite, as the number k=2\cdot 10^n with n\in \mathbb{N}^* has a digit sum of 2+(0\cdot n)=2 and — because k=2^{n+1}\cdot 5^n — exactly two distinct prime factors.

In the encyclopedia entry, I provided a Mathematica one-liner to compute the first few entries of this sequence. Since then, I have also written a Python two-liner to achieve the same goal.

(* Mathematica *)
Select[Range[2,10000],Total[IntegerDigits[#]]==Length[FactorInteger[#]]&]
Out = {20, 30, 102, 120, 200, 300, 1002, 1200, 2000, 2001, 2002, 3000, 3010}
# Python 2.7
>>> def p(n):exec"i,f=2,set()\nwhile n>1:\n\tif n%i==0:f.add(i);n/=i;i=1\n\ti+=1";return len(f)
>>> print filter(lambda n:p(n)==sum(map(int,str(n))),range(2,10001))
[20, 30, 102, 120, 200, 300, 1002, 1200, 2000, 2001, 2002, 3000, 3010]

JSweeper

2017-05-20, post № 170

games, Java, programming, #2016, #classic, #clone, #mine, #Minesweeper, #pixel, #sweeping, #Windows

Adding to my collection of clones of popular, well-known games, I created back in November of 2016 a Java-implementation of the all-time Windows classic game, Minesweeper.

Minesweeper was pre-installed on every installation of Windows up to and including Windows 7 and has been ported to a variety of different systems. Because of this, nearly everyone has at least once in their life played Minesweeper or at least heard of it.
In Minesweeper you are presented with a square grid of covered tiles containing either numbers or mines. Your task is it to uncover all tiles which are not mines in the least amount of time. When you uncover a mine, it explodes and the game is lost. To aid in figuring out which tiles are mines and which are not, every tile that is not a mine tells you how many mines are in the neighbouring eight tiles. Tiles which have no neighbouring mines are drawn gray and uncover neighbouring non-mine tiles once uncovered.
More on Minesweeper can be found in this Wikipedia article — I am linking to the German version, as the current English version has major flaws and lacks crucial information. If you are so inclined, feel free to fix the English Minesweeper Wikipedia article.

In my clone, there are three pre-defined difficulty levels, directly ported from the original Minesweeper game, and an option to freely adjust the board’s width and height as well as the number of bombs which will be placed. Gameplay is nearly identical to the original, as my clone also uses a square grid and the tile’s numbers correspond to the number of bombs in the eight tiles surrounding that tile.
The game has a purposefully chosen pixel-look using a self-made font to go along with the pixel-style.

Controls

  • Arrow keys and enter to navigate the main menu,
  • Arrow keys or mouse movement to select tiles,
  • ‘Space’, enter or left-click to expose a tile,
  • ‘f’ or right-click to flag a tile,
  • ‘r’ to restart game when game is either won or lost,
  • ‘Escape’ to return to the main menu when game is either won or lost,
  • ‘F11’ toggles fullscreen.

To play the game, you can either download the .jar file or compile the source code for yourself. The source code is listed below and can be downloaded as a .java file.

jsweeper-0.png
jsweeper-2.png
jsweeper-5.png
Source code: Main.java

Pinhole Photographs MMXVII

2017-05-06, post № 169

art, #light, #nature, #photography, #picture, #tulip, #World-Wide Pinhole Day, #WWPD

pinhole-photographs-mmxvii_purple-tulip.jpg
Purple Tulip
pinhole-photographs-mmxvii_crimson-tulip.jpg
Crimson Tulip
pinhole-photographs-mmxvii_bee-light-interference.jpg
Light Interference
Jonathan Frech's blog; built 2021/04/16 21:21:49 CEST