`SET @sql = NULL; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'max(CASE WHEN ca.date = ''', date_format(date, '%Y-%m-%d'), ''' THEN coalesce(ca.remarks, ''N'') END) AS `', date_format(date, '%Y-%m-%d'), '`' ) ) INTO @sql FROM time_dimension where date>='2020-09-01' and date <= '2020-09-30'; select @sql; SET @sql = CONCAT('SELECT ca.employee_id, ', @sql, ' from ( select c.date, a.employee_id,a.remarks from time_dimension c left join attendance a on c.date=a.date ) ca where ca.date>=''2020-09-01'' and ca.date <= ''2020-09-30'' and employee_id is not null group by ca.employee_id'); select @sql; PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; `

# Tag: write

## I’m trying to write a randomly patrolling AI for my 2D Platformer

I’m trying to write a randomly patrolling AI for my 2D Platformer. The AI already has a ground checker function which checks if there are tiles nearby or not. What I want to do is randomize its actions and create an illusion of a somewhat "sentient" enemy. What I tried to create below is using the built in RNG to make the enemy either jump, change direction, or keep moving.

The problem is, it doesn’t seem to work properly. The enemy just jumps every second I want it to change behaviour. The change direction functions, however, don’t occur as frequently. I need to know what I’ve done wrong here. Thanks.

`void Update() { //RNG behaviour = Random.Range(0,3); jumpSpeed = Random.Range(1,5); //clock timer += Time.deltaTime; } //time private float waitTime = 2.0f; private float timer = 0.0f; void MoveRandomizer() { if((Mathf.Round(timer%waitTime)) == 0) { if(behaviour == 0) { movingRight = false; } if(behaviour == 1) { movingRight = true; } if(behaviour == 2) { rb.velocity = new Vector2(rb.velocity.x, jumpSpeed); } } } `

## How to write “∀x.F(x)” for “F(x)=λx.Φ(x)” in one expression (sequel from question about “∀(λφ. (φ x m→ φ y))”?

This question is sequel from How to understand quantifier without predication " ∀(λφ. (φ x m→ φ y))"? which further explains the notation and context.

So – I have anonymous Boolean-valued function `F(y)=λx.Φ(x)`

(of course, y and x point to the same variable, I just used different syntactic names, to point out, that x is bound variable) and I would like to write the statement, that `F(x)`

is true for all the values of the argument and it can be written `∀x.F(x)`

. But `F(x)`

is named function, but I would like to write the same expression for the anonymous function that uses lambda, so I am with my suggestion: `∀x.λx.Φ(x)`

or `∀x.λy.Φ(y)`

? And apparently they both are wrong.

What I am trying to achieve? I just want to build parser for language that is declared in https://www.isa-afp.org/browser_info/current/AFP/GoedelGod/GoedelGod.html. This language contains expressions like `[∀(λΦ. P (λx. m¬ (Φ x)) m→ m¬ (P Φ))]`

.

I am using ANTLR grammar for lambda calculus https://github.com/antlr/grammars-v4/blob/master/lambda/lambda.g4 and I understand that the 1) quantifiers; 2) logical connectives; 3) arithmetic functions are just another lambda functions (it is just syntactic sugar that they are written in the specific non-lambda syntax/prefix form etc.) and as such I express them in the existing lambda.g4 grammar https://github.com/antlr/grammars-v4/blob/master/lambda/lambda.g4. So – my first step is to write the cited expressions with the named functions and then I will just replace them with anonymous functions because lambda.g4 has no options to introduce named functions. But it is so confusing to write anonymous function and the quantifier function for the same argument.

*Just side question – maybe there is better ANTLR grammar for lambda calculus with syntactic sugar for quantifiers and connectives?*

## Why did Hopcroft and Karp write $M_0, M_1, M_2, \cdots, M_i, \cdots$? (Hopcroft – Karp Algorithm)

I am reading “An $ n^{\frac{5}{2}}$ Algorithm for Maximum Matchings in Bipartite Graphs” by Hopcroft and Karp.

Please see the image below.

Let $ s$ be the cardinality of a maximum matching.

I think any of $ M_0, M_1, M_2, \cdots, M_s$ is a matching and $ M_s$ is a maximum matching.

So, I think $ P_s$ doesn’t exist.

But the authors wrote $ M_0, M_1, M_2, \cdots, M_i, \cdots$ and $ |P_0|, |P_1|, \cdots, |P_i|, \cdots$ .

Why?

Maybe I am confused.

## How do you write a python\pseudo code that generates all pair permutations?

What would be a good pseudo code or Python 3 code for the following permutations problem? Let us define a n-permutation as a bijective function $ \pi: \{0,…,n-1\}\rightarrow \{0,…,n-1\} $ and represent it using a list, meaning that $ \pi(i)=j $ iff list[i]=j. Let us also define a pair permutation as a permutation in which for every $ i\neq j , \thinspace \pi(i)=j \Leftrightarrow \pi(j)=i $ . I need to write a *recursive* function code, that takes an interger n, and generates all n-pair permutations (every permutation appears, and only once). [This question appeared on a test, that it’s solution remains confidential 🙁 ]

## Limiting where a Turing Machine can write

Suppose I have a Turing Machine A, generated by somebody else, trying to break my system. To break my system they would have to write to the tape at some point X (this can be a range of the tape).

If I can force the machine A to be in some state q1 at some point, can I make a Turing Machine B such that for any Machine A it will *never* write in X?

## FTP server and chroot: SSL3 alert write: fatal: protocol version

When i enable "chroot_local_user=YES" in my FTP server config /etc/vsftpd/vsftpd.conf

then the FTP client (WinSCP) says:

when it is commented out and "service vsftpd restart" , it login OK, but allows browsing system directories in the /.

This is CentOS 7 Linux.

These are…

FTP server and chroot: SSL3 alert write: fatal: protocol version

## Search Engine Ranker is trying to write on the link lists. How to stop?

I might have changed some settings and ended up at Search Engine Ranker trying to write on the link lists that I provide. Where can I find the settings to stop rewriting on the folders that I import links.

## How do I write a tooltip for this list of cities?

`distanceToSanFrancisco[s_] := QuantityMagnitude[ TravelDistance[cityList[[859]], Interpreter["City"][s]]] (* table1 takes a while to run on my system*) table1 = Table[{cityList[[k]], distanceToSanFrancisco[cityList[[k]]]}, {k, Length[cityList]}]; citiesWithin[range_] := Module[{s = {}}, Do[If[table1[[k, 2]] <= range, s = Join[s, {cityList[[k]]}]], {k, Length[cityList]}]; s] (*This lists all cities in California that are within `range` of San Francisco.*) radius = 25; tolerance = 0.05; a1 = GeoDisk[ QuantityMagnitude[ LatitudeLongitude[Interpreter["City"]["San Francisco"]]], Quantity[radius, "Miles"]]; a3 = Complement[ citiesWithin[radius*(1 + tolerance)], citiesWithin[radius*(1 - tolerance)] ]; Table[a3[[k]] -> distanceToSanFrancisco[a3[[k]]], {k, 1, Length[a3]}] Show[a2, GeoListPlot[a3, PlotMarkers -> Point], ImageSize -> Medium] `

This last one is what I want the tooltips on. For the red points around San Francisco, ideally I would like to get just city name. TIA