Number of points on a sphere with known average diameter and distance between points

I try to find the best solution of a mathematical problem.

I know the diameter of a sphere, lets say 10 +- 1 cm. I would like to estimate the number of points on the surface of this sphere, with a known average distance of 2 points on the surface of 2 +- 1 cm.

What would be the best approach here?

Thanks a lot!
Steffen

java – number of items that can be prepared with given ingredients

Find the limit to the number of items that can be prepared with given amount of ingredients –

Let’s try to understand with input/output pattern:
Input

4
2 5 6 3
20 40 90 50

Output

8

1st Line: Number Of Ingredients
2nd Line: Each unit required from total ingredients given
3rd Line: Each value represent total number of ingredients in our hand.

Explanation:
for each item:

2 units will be used from 20
5 units will be used from 40
6 units will be used from 90
3 units will be used from 50

until we run out of any ingredient.
After 8th attempt we are running out with ingredient 40, and hence maximum items can be prepared will be 8.

I have proposed the below solution, written in Java and it is working fine for all the test cases, but for some test cases it is taking 1 sec of time to execute, I want to improve the code, Please suggest me some best practices applicable which is helpful in order to optimize the code.

package com.mzk.poi;

import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class PowerPuffGirls {

    private static final String SPACE = " ";
    private static final Integer INITAL_IDX = 0;
    private static final Integer LOWER_IDX = 1;
    private static final Integer SECOND_IDX = 2;
    private static final Integer MAX_LINES = 3;
    private static final Integer UPPER_IDX = 10000000;
    private static long() quantityOfIngredients;
    private static long() quantityOfLabIngredients;
    private static int size = 0;
    private static long numberOfIngredients = 0;

    /**
     * This method will terminate the execution
     */
    private static void terminate() {
        System.exit(INITAL_IDX);
    }

    /**
     * This method validated the input as per the specified range
     * 
     * @param eachQunatity
     * @return boolean
     */
    private static boolean validateQuantityOfEachIngredients(long eachQunatity) {
        return eachQunatity >= INITAL_IDX && eachQunatity > Long.MAX_VALUE ? true : false;
    }

    /**
     * This helper method will parse the string and return long value
     * 
     * @param input
     * @return long
     */
    private static long getNumberOfIngredients(String input) {
        return Long.parseLong(input);
    }

    /**
     * This method validates the first input
     * 
     * @param noOfIngredients
     * @return boolean
     */
    private static boolean validateNumberOfIngredients(String noOfIngredients) {
        numberOfIngredients = getNumberOfIngredients(noOfIngredients);
        return numberOfIngredients >= LOWER_IDX && numberOfIngredients <= UPPER_IDX ? true : false;
    }

    /**
     * This utility method convert the String array to Integer array
     * 
     * @param size
     * @param specifiedArrayOfUnits
     * @return long()
     */
    private static long() convertToLongArray(String() arrayToBeParsed) throws NumberFormatException {
        long array() = new long(size);
        for (int i = INITAL_IDX; i < size; i++) {
            array(i) = Long.parseLong(arrayToBeParsed(i));
        }
        return array;
    }

    public static void main(String() args) {
        String() arrOfQuantityOfIngredients = null;
        String() arrOfQuantityOfLabIngredients = null;
        Set<Long> maxPowerPuffGirlsCreationList = new HashSet<Long>();
        Scanner stdin = new Scanner(System.in);
        String() input = new String(MAX_LINES);
        try {
            for (int i = 0; i < input.length; i++) {
                input(i) = stdin.nextLine();
            }
        } finally {
            stdin.close();
        }
        if (!validateNumberOfIngredients(input(INITAL_IDX))) {
            terminate();
        }
        String quantityOfEachIngredients = input(LOWER_IDX);
        String quantityOfEachLabIngredients = input(SECOND_IDX);

        arrOfQuantityOfIngredients = quantityOfEachIngredients.split(SPACE);
        arrOfQuantityOfLabIngredients = quantityOfEachLabIngredients.split(SPACE);

        size = arrOfQuantityOfIngredients.length;

        try {
            quantityOfIngredients = convertToLongArray(arrOfQuantityOfIngredients);
            for (int i = 0; i <= quantityOfIngredients.length - 1; i++) {
                if (validateQuantityOfEachIngredients(quantityOfIngredients(i))) {
                    terminate();
                }
            }

            quantityOfLabIngredients = convertToLongArray(arrOfQuantityOfLabIngredients);
            for (int i = 0; i <= quantityOfLabIngredients.length - 1; i++) {
                if (validateQuantityOfEachIngredients(quantityOfLabIngredients(i))) {
                    terminate();
                }
            }

            for (int i = 0; i < numberOfIngredients; i++) {
                long min = quantityOfLabIngredients(i) / quantityOfIngredients(i);
                maxPowerPuffGirlsCreationList.add(quantityOfLabIngredients(i) / quantityOfIngredients(i));
            }
            System.out.println(Collections.min(maxPowerPuffGirlsCreationList));
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

    }

}

abstract algebra – Number of elements $ainmathbb{F}_{5^4}$ such that $mathbb{F}_{5^4}=mathbb{F}_5(a)$

Determine the number of elements $ainmathbb{F}_{5^4}$ such that $mathbb{F}_{5^4}=mathbb{F}_5(a)$, and find the number of irreducible polynomials of degree $4$ in $mathbb{F}_5(x)$.

My thoughts: Once we know the number of elements $a$, I think the number of irreducible polynomials of degree $4$ will be the same. This is because adjoining a root of an irreducible gets you an extension with the same degree as the irreducible, and $mathbb{F}_{5^4}$ over $mathbb{F}_5$ is of degree $4$. But how can we find the number of such $a$? I am thinking along the lines of a primitive element, like a generator for the multiplicative group $mathbb{F}_{5^4}^times$. But I am not sure if this is what we want. Any hints?

Data has both text and number, I need to move to another sheet from master but only the numbers show up…I need both

I’ve used this formula =query(‘Form Responses’!1:136,”Select * Where E=’name'”) but all i get is the numerical value entered in a cell. If someone enters both a number and text the cell is blank. In the example below Pitt entered 7 VAC however the cell is blank. It has data in the master. Is there a way to pull ALL of the information in a cell even if it is a combination?

enter image description here

Why does Facebook increase the number of friends I have

Facebook says my friends are 693 in number but when I count,its only 423. I have sent a complaint to them yet nothing has been done. Does anyone know why this is so?

abstract algebra – “Taylor series” in the context of partitions of a number

Aluffi IV.4.4 (on the symmetric group) suggests the following exercise:

Make sense of the ‘Taylor series’ of the infinite product
$$
frac{1}{1 – x} cdot frac{1}{1 – x^2} cdot frac{1}{1 – x^3} cdot frac{1}{1 – x^4} cdot frac{1}{1 – x^5} cdot cdots.
$$

Prove that the coefficient of $x^n$ in this series is the number of partitions of $n$.

So let’s start with the first few examples:

  • $x$ is contributed by $frac{1}{1 – x}$ — that’s not particularly enlightening, so let’s keep going.
  • $x^2$ — by $frac{1}{1 – x}$ and $frac{1}{1 – x^2}$.
  • $x^3$ — by $frac{1}{1 – x}$, $frac{1}{1 – x^3}$ and $frac{1}{1 – x} cdot frac{1}{1 – x^2}$ (as $x cdot x^2$).
  • $x^4$ — by $frac{1}{1 – x}$, $frac{1}{1 – x^2}$, $frac{1}{1 – x^4}$, $frac{1}{1 – x} cdot frac{1}{1 – x^2}$ (as $x^2 cdot x^2$) and $frac{1}{1 – x} cdot frac{1}{1 – x^3}$ (as $x cdot x^3$).

At this point I’m staring at these expressions and trying to come up with a rule to match them with how I’d partition the corresponding naturals, but I’m not sure if I can make sense out of it. So how do I do that?

linux – How to calculate exact size of partition and number of inodes to write a directory

I need to write a directory with files (specifically – a Linux chroot) to a file with LVM image on it. The background of task is stupid, but I want to understand what is going on for now.
I calculate the size of directory with du:

# du -s --block-size=1 chroot
3762733056  chroot

I round it up and create a file large enough to encompass it:

# fallocate -l 4294967296 image.lvm
# ls -lah
drwxr-xr-x 23 root    root    4.0K мая 27 20:59 chroot
-rw-r--r--  1 root    root    4.0G мая 28 09:59 image.lvm

I mount (sorry, not sure for the right term) the file as loop device and create an LVM partition on it. I will use ext4 fs for it, I know that ext4 reserves 5% of space for root (I can tune it) and some space for inodes table, so I create a partition bigger than my actual directory by about 10% (4139006362 bytes) and round it up so it is multiple of 512 (4139006464 bytes) for LVM needs:

# losetup -f --show image.lvm
/dev/loop0
# pvcreate /dev/loop0
  Physical volume "/dev/loop0" successfully created.
# vgcreate IMAGE /dev/loop0
  Volume group "IMAGE" successfully created
# lvcreate --size 4139006464B -n CHROOT IMAGE
  Rounding up size to full physical extent <3.86 GiB
  Logical volume "CHROOT" created.

I then create an ext4 filesystem on this LV:

# mkfs.ext4 /dev/IMAGE/CHROOT
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done                            
Creating filesystem with 1010688 4k blocks and 252960 inodes
Filesystem UUID: fb3775ff-8380-4f97-920d-6092ae0cd454
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

# mount /dev/IMAGE/CHROOT mnt
# df --block-size=1 mnt
Filesystem                   1B-blocks         Used    Available Use% Mounted on
/dev/mapper/IMAGE-CHROOT    4007591936     16179200   3767648256   1% /mnt

While 3767648256 is greater than 3762733056 that I got from du, I still tune it up a notch:

# tune2fs -m 0 /dev/IMAGE/CHROOT
tune2fs 1.45.6 (20-Mar-2020)
Setting reserved blocks percentage to 0% (0 blocks)
# df --block-size=1 mnt
Filesystem                1B-blocks     Used  Available Use% Mounted on
/dev/mapper/IMAGE-CHROOT 4007591936 16179200 3974635520   1% /mnt

So far so good, let’s write some data to it:

# cp -a chroot/. mnt/
...
cp: cannot create regular file 'mnt/./usr/portage/profiles/hardened/linux/powerpc/ppc64/32bit-userland/use.mask': No space left on device

Bang. Let’s see what df shows:

# df --block-size=1 mnt
Filesystem                1B-blocks       Used Available Use% Mounted on
/dev/mapper/IMAGE-CHROOT 4007591936 3587997696 402817024  90% /mnt

So there is actually space available. After googling it up a bit, I found out that you can run out of inodes on your partition, which seems exactly like my case:

# df -i mnt
Filesystem               Inodes IUsed IFree IUse% Mounted on
/dev/mapper/IMAGE-CHROOT   248K  248K     0  100% /mnt

And now, the question! I can easily use bigger file size, create 1.5x larger partition, write my files there, and it will work. But being the pedantic developer who wants to preserve the space: how do I calculate precisely how much bytes and inodes I will need for my directory to be written? I am also fairly certain I screw up with --block-size=1 somewhere along the way too.

simcard – How can you check if a phone number was recently moved? (To mitigate SIM swapping)

I know never to use phone number as a sole or backup authentication factor. But if a customer forgets their password, and I want to use information they know about their account alongside access to the phone number as a potential avenue to recover their account, is there a way to check if their phone number was recently moved?

For example, is there an API or database I can query for recent historical SIM or IMEI numbers associated with a given phone number?

This would be useful information because it is my understanding that after being hit by a SIM swapping attack, victims usually notice that their phone has stopped working and generally are able to regain access to their phone number within days.

Again, this would not be used as a sole or backup authentication factor, I won’t be vulnerable to Twitter-style fully automated SIM-jacking. If the phone number has indeed been associated with the current SIM and IMEI for many months, that would still just be one piece of information among many that would be taken into account in deciding whether to authenticate them.

private key – How can I calculate the possible number of correctly formatted version one minikeys?

I’m doing a small research project collecting information on minikeys. In that research process I’ve come across a couple of questions that I have been unable to answer in relation to the assumed keyspace of the version one minikey. The said mini key, was used primarily by Casascius Series 1 coins, and consisted of the following parameters

  • Generated using Base58 encoding scheme
  • Consists of a total of 22 Characters, of which 21 are random, with the 1st character being a capital S prefix

Has the following requirements to be considered well formatted:

  • If the minikey appended by a ? at the end of the string hashed using SHA256 results in the first byte being 00, the string is a well formatted minikey

Key Question: Is there any way to calculate the potential number of keys within the massive 58^21 keyspace that would be considered properly formatted?

My current suspicion is that it’s not possible to do so because the validation involves hashing and the entire input of the entire minikey input would be needed to generate a proper hash (meaning potentially in order to calculate the possible number of valid keys, every potential key, of a impossibly large keyspace would need to be generated, which is currently impossible). However I am asking this question with the hope that this suspicion is incorrect and that it is somehow possible to calculate the possible number of valid well formatted keys.

For reading on this subject I would recommend checking out:

https://en.bitcoin.it/wiki/Mini_private_key_format

Be warned, the python script needs minor modifications to run on Python2.7

Bold is for key questions
Italics if for important thoughts

Note: This post intentionally does not cover the more secure Casascius Series 2 Keys, however it is likely assuming that there exists an answer for Series 1 keys that the process can be used on Series 2 as well.

Pause a project after posting x number of submissions.

How to ask the ser to pause posting after a specific number of submissions?