PTAS vs. FPTAS input

I am trying to understand what is the PTAS, FPTAS and what is the difference between them.

I found this analysis:

PTAS definition vs. FPTAS

but I cannot understand what do we mean by saying:

“….time complexity is polynomial in the input size and also polynomial in 1/ϵ” ?? Ok n has to do with the linear O(n) worst case that the algorithm runs. But O(1/ε) how does it work?

How to capture an input device and prevent it’s default behavior

I have an RFID tag reader. But it works like a HID device (like a keyboard). It sends keystrokes to the computer when a tag is scanned. When I open notepad and scan a tag – it types the ID one digit at a time. Is there a way to create a program to listen to this device (or this port) and capture (intercept) all input. So that the keystrokes wouldn’t appear on my system but I could assign my own events when the device sends and input. I don’t want it to show up on Notepad.

I realize that the implementation can differ depending on the OS and programming language used. Ideally, I would like to make this work on both Windows and Linux. I would prefer to use something like Node.js but I suppose C could also be good.

I would appreciate any hints or pointing me in the right direction.

enter image description here

Does input type=”file” selection support url ( upload from web ) ? -html

I wonder can I use the option of input type=”file” in html to upload from url ( web/ftp etc. ) ? Is there option to it? To more explain, I want to select zip file with url and uoload it to website.Which operating systems support it? How can do it on linux,mac and windows 10? I talking about the option on the link:

<input type="file">: How to Use This HTML Value

Adding to the query string via input

I have a form that takes multiple input fields and makes an API request via GET.

The fields are not properly sanitizing input and I am able to add arbitrary parameters to the query string by submitting input such as test&color=red.

Instead of some sort of encoding, the resulting API query looks like

I cannot think of any malicious use to this, as anybody could just hit this endpoint directly or use a proxy to bypass any client side validation.

If you were performing an application review, is this something that might be worth calling out?

Why is my algorithm version so slow with this input?

I’ve written my F# code to solve Advent of Code Day 18 Part 1. While it seems to work fine with other simple demo inputs, it stuck with the following input

################# #i.G..c...e..H.p# ########.######## #j.A..b...f..D.o# ########@######## #k.E..a...g..B.n# ########.######## #l.F..d...h..C.m# ################# 

Tehre is reference solution in Python which is correct and quick, but I fail to see where is the fundamental difference between the two algorithms, behind the other minor code differences (also because the languages are different).

I’ve tried with concurrency vs a queue, with a tree vs a grid/map (see my github history) but with no luck until now.

The principal part of the code is described below. It should fall under a breadth first search (BFS) algorithm.

Here is how the single step by which I elaborate the solution.

let next (step:Step) (i:int) (solution: Solution) (fullGrid: Map<char,Map<char,Grid>>) : Solution =     let branches = solution.tree.branches     let distance = solution.tree.distance + branches.[i].distance     let area = branches.[i].area       //let newbranches, back, keys =     match step with     | SpaceStep ->         failwith "not expected with smart grid"     | KeyStep ->         let keys = area :: solution.keys         let grid = fullGrid.[area]         let tree = grid2tree area distance keys grid         {keys=keys; tree=tree} 

The fullGrid is supposed to contain the matrix of distances. The wrapping solver is simply a recursion or queue based version of the BFS.

let findSolution (keynum:int) (solution: Solution) (fullGrid: Map<char,Map<char,Grid>>) : Solution option =     let mutable solution_queue : queue<Solution> = MyQueue.empty     solution_queue <- enqueue solution_queue solution     let mutable mindistance : int option = None     let mutable alternatives : Solution list = List.empty      while (MyQueue.length solution_queue > 0) do         let solution = dequeue &solution_queue         let solution = {solution with tree = grid2tree solution.tree.area solution.tree.distance solution.keys fullGrid.[solution.tree.area]}         let branches = solution.tree.branches         if  (branches = [||] ) then              if solution.keys.Length = keynum              then updateMin &mindistance &alternatives solution         else         match mindistance with         | Some d when d < solution.tree.distance + (solution.tree.branches |> (fun t -> t.distance) |> Array.min) -> ()          | _ ->         let indexes =             [|0..branches.Length-1|]             |> Array.sortBy(fun idx -> ((if isKey branches.[idx].area then 0 else 1) , branches.[idx].distance))         for i in indexes do             if branches.[i].area = '#' then                  failwith "not expected with smart grid"              else             if branches.[i].area = Space then                 failwith "not expected with smart grid"             else             if (Char.IsLower branches.[i].area) then                 let solutionNext = next KeyStep i solution fullGrid                 if solutionNext.keys.Length = keynum                 then  updateMin &mindistance &alternatives solutionNext                 else                 solution_queue <- enqueue solution_queue solutionNext             else             if (Char.IsUpper branches.[i].area) then                 failwith "not expected with smart grid"      match alternatives with     | [] -> None     | alternatives ->         alternatives |> List.minBy(fun a -> a.tree.distance) |> Some 

Undo dynamic input

Here is a simplified example of the problem.

DynamicModule[{customControl, eq, x, y, z},  eq[] := Quiet@Solve[x + y + z == 10];  customControl[{var_, init_, lbl_}] :=    Column[{Row[{lbl, Button["Clear", Unset[var]]}],      Control[{{var, init},        InputField[         Dynamic[var, (var = #; (eq[] /. (lhs_ -> rhs_Integer) :>                Set[lhs, rhs])) &], Number, FieldSize -> 6] &}]},     Alignment -> Center];  Framed@Row@{customControl[{x, x, "x"}], customControl[{y, y, "y"}],      customControl[{z, z, "z"}], Spacer[50],      Dynamic[Column@{x, y, z}]}] 

This piece of code solves the equation $ x+y+z=10$ with $ x$ , $ y$ and $ z$ entered using InputField. For instance, when you enter $ 1$ for $ x$ , $ 2$ for $ y$ , $ z$ is automatically set equal to $ 7$ . Now how do you undo the last operation? Something like Ctrl+Z for dynamic input to Unset the value of $ y$ AND the value of $ z$ ?

When you Unset the value of y (by clicking the button), z is still equal to 7.

How to sort ints with user input?

I am trying to sort in ascending or descending order with user input however its telling me about a syntax error that i have no idea about. This is the code that I have.

N = [10, 2, 1, 8, 5, 7, 6, 4, 3] A = int(input(“Ascending or Desending order, press 1 for acsending or 2 for descending order”) if (number == 1): N.sort() print(N) elif (number == 2): N.sort(reverse = True) print(N) else: print(“Sorry, but there is no sorting pattern”)

Undecidability of two Turing machines acting the same way on an input

So I need to find a reduction to the (undecidable) problem of deciding if two Turing machines $ M_1$ and $ M_2$ behave the same way on an input $ x$ . “Behaving the same way” is defined like this:

$ M_1$ and $ M_2$ behave the same way on an input $ x$ , when they both don’t halt, or when they both accept $ x$ or when they both halt and reject $ x$ .

I found a reduction from the halting problem which uses the fact that if the Turing machines behave in the same way, than they must have the same language. But this all breaks down in the case that $ M_1$ rejects $ x$ and $ M_2$ doesn’t halt, obviously they could have the same language, but they don’t act in the same way.

I do think the best way to approach this is by reducing from the halting problem, but I just can’t find a valid reduction. Any help would be appreciated.