Scale object based on another object's position

Despite an hour or so of trying to solve it I can’t seem to figure out how to calculate the scale factor based on distance. Here’s the illustration of my problem.

100374-cube.gif

I’ve tried manipulating the x values and such, but until now I still cannot figure it out. Here’s the snippet:

Vector3 v3Scale = frontWall.transform.localScale;
frontWall.transform.localScale = new Vector3(v3Pos.x*2.0f , v3Scale.y , v3Scale.z);

I use the v3Pos as v3Pos is used to track the mouse position, here it is:

ray = mainCamera.ScreenPointToRay(Input.mousePosition);
float dist;
plane.Raycast(ray, out dist);
Vector3 v3Pos = ray.GetPoint(dist); 

I’ve been stuck on this problem like forever, so any help would be appreciated.
UPDATE:
Here’s the full code,

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DragDropScript : MonoBehaviour
{
    //Initialize Variables
    GameObject getTarget;
    Ray ray;
    bool isMouseDragging;
    private Plane plane;
    public Camera mainCamera;

    void Update()
    {
        //Mouse Button Press Down
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hitInfo;
            getTarget = ReturnClickedObject(out hitInfo);
            if (getTarget != null)
            {
                getTarget.transform.position = new Vector3(getTarget.transform.position.x,getTarget.transform.position.y,getTarget.transform.position.z);
                isMouseDragging = true;
            }
        }
        //Mouse Button Up
        if (Input.GetMouseButtonUp(0))
        {
            isMouseDragging = false;
        }
        //Is mouse Moving
        if (isMouseDragging)
        {
            //tracking mouse position.
            ray = mainCamera.ScreenPointToRay(Input.mousePosition);
            float dist;
            plane.Raycast(ray, out dist);
            Vector3 v3Pos = ray.GetPoint(dist); 
            if(getTarget.CompareTag("LeftRightWall") && getTarget.transform.childCount == 1)
            {
                foreach (GameObject frontWall in GameObject.FindGameObjectsWithTag("TopWall"))
                {
                    Vector3 v3Scale = frontWall.transform.localScale;
                    frontWall.transform.localScale = new Vector3(v3Pos.x*2.0f , v3Scale.y , v3Scale.z);
                }
                v3Pos.z = getTarget.transform.position.z;
                v3Pos.y = getTarget.transform.position.y;
                getTarget.transform.position = v3Pos;
                getTarget.transform.GetChild(0).gameObject.transform.position = new Vector3(-v3Pos.x, v3Pos.y, v3Pos.z);
            }   
            if(getTarget.CompareTag("TopWall") && getTarget.transform.childCount == 1)
            {
                foreach (GameObject leftRightWall in GameObject.FindGameObjectsWithTag("LeftRightWall"))
                {
                    Vector3 v3Scale = leftRightWall.transform.localScale;
                    leftRightWall.transform.localScale = new Vector3(leftRightWall.transform.localScale.x , leftRightWall.transform.localScale.y , v3Pos.z*2.0f);
                    Debug.Log("clicked TopWall");
                }
                v3Pos.y = getTarget.transform.position.y;
                v3Pos.x = getTarget.transform.position.x;
                getTarget.transform.position = v3Pos;
                getTarget.transform.GetChild(0).gameObject.transform.position = new Vector3(v3Pos.x, v3Pos.y, -v3Pos.z);
            }
        }
    }
    //Method to Return Clicked Object
    GameObject ReturnClickedObject(out RaycastHit hit)
    {
        GameObject target = null;
        ray = mainCamera.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray.origin, ray.direction * 10, out hit))
        {
            target = hit.collider.gameObject;
        }
        return target;
    }
}

Right wall is the parent of the left wall, and tagged as LeftRightWall, while the upper wall is the parent of the bottom wall, and tagged as TopWall. Both parents is draggable, thus enabling one another to scale based on the drag distances. Hope it’s clear enough.

UPDATE:
This is the closest one from what I’m trying to achieve… ((

100425-cube2.gif

Here’s the code:

float translate = getTarget.transform.position.x - getTarget.transform.GetChild(0).gameObject.transform.position.x;
                Debug.Log("value :"+translate);
                foreach (GameObject frontWall in GameObject.FindGameObjectsWithTag("TopWall"))
                {
                    Vector3 v3Scale = frontWall.transform.localScale;
                    frontWall.transform.localScale = new Vector3(translate+v3Pos.x, v3Scale.y , v3Scale.z);
                }

I just need to use math for it, thanks to this answer.
The reasons my walls behaved like that is because all four walls are inside another empty objects. So problem solved.