Jump to content

Wikipedia:Reference desk/Archives/Computing/2021 January 29

From Wikipedia, the free encyclopedia
Computing desk
< January 28 << Dec | January | Feb >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


January 29

[edit]

What devices really needed to solve P versus NP ?

[edit]

I took interest in one of the open question: P versus NP problem. What devices really needed to solve it ? Rizosome (talk) 05:00, 29 January 2021 (UTC)[reply]

A quantum computer. Here is a nice easily understandable article: https://www.quantamagazine.org/finally-a-problem-that-only-quantum-computers-will-ever-be-able-to-solve-20180621/ 41.165.67.114 (talk) 07:24, 29 January 2021 (UTC)[reply]
P = NP is a purely mathematical statement, just like the Mertens conjecture, Fermat's Last Theorem and Goldbach's conjecture. The Mertens conjecture and Fermat's Last Theorem have lost their conjectural status: the former has been settled in the negative (the conjecture is false) and the latter has been solved in the positive (the conjecture is true, and it is indeed a theorem). The status of Goldbach's conjecture is still open; most mathematicians who have looked at, starting with Euler, think it is true, but the question may keep evading the combined ingenuity of all minds and remain unsettled forever. Precisely the same holds for the question whether the two complexity classes P and NP coincide or not. Most theorists think they differ, since no one has found a polynomial-time algorithm for any NP-complete problem, but that does not necessarily mean no such algorithm exists, and no one has found a proof that no such algorithm can exist. To settle the question requires a bright mathematical mind – whether human, an AI, or a hivemind – to come up with a mathematical proof of either the statement P = NP or the statement P ≠ NP. Neither more nor less is required. The devices needed are mathematicians.  --Lambiam 09:07, 29 January 2021 (UTC)[reply]

What does "fillers" mean in video editing software?

[edit]

From here , I want to know "fillers" mean in video editing context? Google didn't help me much. Rizosome (talk) 15:20, 29 January 2021 (UTC)[reply]

It's not a technical term. Sometimes the stabilization software will need to create a portion of the screen where there is no original video (because things have shifted during the stabilization process) and something needs to go there. "Filler" is a generic English term for anything that covers up or over gaps or holes in something, so that's the term that got used. It's the second sense listed here. Matt Deres (talk) 16:43, 29 January 2021 (UTC)[reply]
The filler, using technical terms, is a black matte. The original video is transformed to steady it and then superimposed on a black matte. 97.82.165.112 (talk) 15:57, 31 January 2021 (UTC)[reply]

Specifying a file for both StdIn and StdOut in Java using Windows cmd

[edit]

I have written the following Java class called Test.java:

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int value = in.nextInt();
		System.out.println(2 * value);
	}
}

I can run the compiled class file from the command line on Windows and have it use an arbitrary file for standard input by using:

java Test < file.txt

and I can do the same for standard output by using:

java Test > file.txt

How do I specify both an input file and an output file? --PuzzledvegetableIs it teatime already? 15:53, 29 January 2021 (UTC)[reply]

Fairly certain that's just going to be this: java Test < input.txt > output.txt. Don't have ready access to a Windows machine, so I can't confirm. Jdphenix (talk) 19:09, 29 January 2021 (UTC)[reply]

SQL question - using MAX of a different field to find something else.

[edit]

Let's say I have a dataset with customers, stores, products, sale dates, and prices. If I wanted to find the last sale date for an item I could do this:
select product, max(sales_date) from sales group by product
But what if I want to find the last sale price for each product from each store (and not include the sales date in the return)? It seems like I should be able to use a case statement including a MAX function, but that does not parse (as an aggregate; I thought maybe it would work as an analytic function, but it doesn't seem to be what I want. Basically what I want to be able to see is one product per one line and use CASE statements to split up the different stores into columns. Example:

PRODUCT NYC CHI TOR
Carrots $15 $14 $18
Bananas $12 $10 $15

That doesn't seem crazy, but I can't seem to figure it out. Any help? Matt Deres (talk) 17:04, 29 January 2021 (UTC)[reply]

Assuming Oracle based on the link, but you're looking for PIVOT. If you don't know how many columns you'll have, you'll have to resort to dynamic SQL or having application code process the rows into columns. Jdphenix (talk) 20:37, 29 January 2021 (UTC)[reply]
Yes, sorry, it is Oracle, but my issue isn't with the pivoting (I use CASE statements to split that stuff up), it's with returning the price associated with the latest sell date. I might have a thousand sales on the carrots in Toronto; I want to find the last one and return the price on it. Matt Deres (talk) 20:49, 29 January 2021 (UTC)[reply]

This is postgresql, but everything here is as far as I know ANSI SQL,

insert into products values
('Bananas', '01-21-2021', 'CHI', 13),
('Bananas', '01-20-2021', 'CHI', 14),
('Bananas', '01-21-2021', 'TOR', 18),
('Bananas', '01-20-2021', 'TOR', 16),
('Carrots', '01-21-2021', 'CHI', 9),
('Carrots', '01-20-2021', 'CHI', 10),
('Carrots', '01-20-2021', 'TOR', 9);

with sale_dates_by_location as
(
select 
	product, 
    location, 
    max(sale_date) as sale_date
from products
group by product, location
)

select 
  products.product, 
  products.location, 
  products.price
from products
join sale_dates_by_location cte on 
  cte.sale_date = products.sale_date and
  cte.product = products.product and 
  cte.location = products.location

This result set will show price by product and location. Jdphenix (talk) 21:01, 29 January 2021 (UTC)[reply]

@Jdphenix Thank you very much - I'll give it a shot as soon as I can access that stuff again. Matt Deres (talk) 20:29, 1 February 2021 (UTC)[reply]