Friday, July 19, 2024

 Sample program to count the number of different triplets (a, b, c) in which a occurs before b and b occurs before c from a given array.

Solution: Generate all combinations in positional lexicographical order for given array using getCombinations method described above. Select those with size 3. When selecting the elements, save only their indexes, so that we can determine they are progressive. 

 

class solution {

 

public static void getCombinations(List<Integer> elements, int N, List<List<Integer>> combinations) { 

      for (int i = 0; i < (1<<N); i++) { 

          List<Integer> combination = new ArrayList<>(); 

          for (int j = 0; j < elements.size(); j++) { 

              if ((i & (1 << j)) > 0) { 

                combination.add(j); 

              } 

          } 

          List<Integer> copy = new ArrayList<Integer>(combination); 

          combinations.add(copy); 

      } 

   }

 public static void main (String[] args) {

                  List<Integer> elements = Arrays.asList(1,2,3,4);

List<List<Integer>> indices = new ArrayList<Integer>();

        getCombinations(elements, elements.size(), indices);

        indices.stream().filter(x -> x.size() == 3)  

                      .filter(x -> x.get(0) < x.get(1)  && x.get(1) < x.get(2)) 

                       .forEach(x -> printList(elements, x)); 

       }

 

public static void printList(List<Integer> elements, List<Integer> indices) {

                 StringBuilder sb = new StringBuilder();

                 for (int i = 0; i < indices.size(); i++) {

                        sb.append(elements.get(indices.get(i)) + " "); 

                 }

                 System.out.println(sb.toString());

}

}

/* sample output:

1 2 3 

1 2 4 

1 3 4 

2 3 4

 */


Thursday, July 18, 2024

 

This is a summary of the book titled “The Canary Code:  A guide to Neurodiversity, Dignity and Intersectional Belonging at work”  written by Ludmila Praslova and published by Berrett-Koehler in 2024.  This book is about how to foster an inclusive workplace that celebrates neurodiversity and intersectional dignity and where everyone feels valued and respected. Neurodivergent people with conditions such as autism spectrum disorder, attention deficit disorder, dyslexia, or obsessive-compulsive disorder that impacts the way brain processes information, have suffered to keep up with the rest of the workforce because they don’t fit the status quo. The flexibility provided during Covid-19 came to their rescue and more steps can be taken to promote inclusivity such as hiring and onboarding them by understanding their needs, heeding their input on office space design and workflow flexibility. Leaders should create psychologically safe workplaces by listening, communicating clearly, and aiming for objective performance reviews. When these same employees become leaders, they could pass on the same benefits to others.

Inclusive workplaces promote diverse interaction, communication, and productivity styles by challenging neuronormative standards. Neurodiversity acknowledges the vast variations in human cognition, emotion, and perception, including conditions like ADHD, autism, and dyslexia. Myths about neurodiversity perpetuate exclusion in the workplace, as they lump people together while ignoring neurodivergent needs and preferences. To enable neurodivergent employees to do their best work, organizations must create flexible, inclusive environments that respect individual differences in social, cognitive, emotional, and sensory needs.

The "Canary Code" framework promotes inclusivity for neurodivergent employees. It emphasizes the importance of involving marginalized employees in decision-making, focusing on outcomes, ensuring flexibility, promoting organizational justice, and maintaining transparency, and using appropriate decision-making tools. By adopting these principles, organizations can create a more productive and inclusive workplace.

Companies like Deloitte, Infinite Flow, Legalite, Call Yachol, Ultranauts, and Dell have implemented these principles to ensure a diverse workforce. These practices have improved onboarding processes, engagement, and overall performance. Companies like Dell have also implemented neurodiversity programs, allowing candidates to showcase their abilities. Overall, these principles promote a more inclusive and productive workplace.

To make hiring and onboarding more inclusive, organizations should understand the needs of neurodivergent employees and conduct thorough analyses to ensure job descriptions accurately reflect the position's requirements. This includes separating essential qualifications from desirable ones, using plain language, and focusing on outcomes rather than methods. Onboarding should integrate new employees into the organization, offering a quality "preboarding" experience, providing clear information, and tailoring training methods.

Inclusive office spaces should accommodate a wide range of sensory, physical, and cognitive needs, with employees' input in the design process. Flexible work arrangements, such as flexible schedules, remote work options, and hybrid models, can enhance productivity for neurodivergent employees. Psychologically safe workspaces should be created by listening, communicating clearly, and aiming for objective performance reviews. A toxic work environment features non-inclusive, disrespectful, unethical, cutthroat, and abusive behaviors, which can negatively impact all employees' well-being and performance. By implementing these strategies, organizations can create a more inclusive and supportive work environment for all employees.

Neurodivergent leaders can create more inclusive workspaces by overcoming myths and stigmas that limit recognition and development of diverse leadership talents. By leveraging individual strengths, creating growth tracks, and fostering a culture that values diverse perspectives, companies can unlock innovation, improve morale, and build more resilient leadership teams. Neurodivergent leaders can overcome biases by embracing unique experiences, fostering empathy, and fostering inclusivity within their teams. By remaining authentic, trusting in their unique perspective, and focusing on transparent communication, neurodivergent leaders can inspire others and promote a culture of acceptance and understanding.

Wednesday, July 17, 2024

 Problem Statement: Given an integer array arr, in one move you can select a palindromic subsequence arr[i], ..., arr[j] where 0 <= i <= j < arr.length, and remove that subsequence from the given array. Note that after removing a subarray, the elements move to remove the gap between them.

 

Return the minimum number of moves needed to remove all numbers from the array.

 

Solution:

import java.util.*;

class Solution {

    public int minimumMoves(int[] arr) {

        int N = arr.length;

        int max = 1;

        int min = Integer.MAX_VALUE;

        List<Integer> A = new ArrayList<>();

        for (int i = 0; i < arr.length; i++) A.add(arr[i]);

        int count = 0;

        while(A.size() > 0) {

           boolean hasPalindrome = false; 

           List<Integer> elements = new ArrayList<>();

           for (int i = 0; i < (1<<N); i++) { 

               

               List<Integer> combination = new ArrayList<>(); 

                for (int j = 0; j < A.size(); j++) { 

                  if ((i & (1 << j)) > 0) { 

                    combination.add(j); 

                  } 

                } 

                if (isPalindrome(A, combination) && (combination.size() > max) && getCharactersToRemove(A, combination) < min) {

                      hasPalindrome = true;

                      max = combination.size();

                      min = getCharactersToRemove(A, combination);

                      elements = new ArrayList<>(combination);                

                      if (getCharactersToRemove(A, combination) == 0) { break;}

                } else {

                    // System.out.println("A: " + print(A) + " Elements: " + print(elements) + " Combination: " + print(combination) + "isPalindrome=" + String.valueOf(isPalindrome(A, combination)) + " getCharsToRemove=" + getCharactersToRemove(A, combination) + " min = " + min);

                }

           }            

           if (!hasPalindrome) {

               count += 1;

               A.remove(A.size() - 1);

           } else {

               count += getCharactersToRemove(A, elements) + 1;

               A = removeCharacters(A, elements);

               // System.out.println("Removing " + count + " characters at indices:" + print(elements) + " and remaining elements: " + print(A));

               // elements = new ArrayList<>();

               max = 1;

               min = Integer.MAX_VALUE;

           }

        }

        return count;

    }

    public boolean isPalindrome(List<Integer> A, List<Integer> combination) {

        int start = 0;

        int end = combination.size()-1;

        while (start <= end) {

            if (A.get(combination.get(start)) != A.get(combination.get(end))) {

                return false;

            }

            start++;

            end--;

        }

        return true;

    }

    public int getCharactersToRemove(List<Integer> A, List<Integer> combination){

        if (combination.size() < 2) return 0;

        List<Integer> clone = new ArrayList<>(A); 

        return removeCharacters(clone, combination).size();

    }

    public List<Integer> removeCharacters(List<Integer> A, List<Integer> combination) {

     int start = 0;

     int end = combinations.size()-1;

     int last = 0;

     while (start <= end) {

             for (int i = last; i< A.size(); i++) {

                    if (A.get(i) == combination.get(start)) {

                          A.set(I, Integer.MAX_VALUE);

                          last = i+1;

                          start++;

                    }

             }

     }

    List<Integer> result = new ArrayList<>();

    For (int I = 0; I < A.size(); i++) {

         if (A.get(i) != Integer.MAX_VALUE) {

               result.add(A.get(i));

          }

    }

    return result;

    }

    public List<Integer> removeCharacters(List<Integer> A, List<Integer> combination) {

        int start = combination.get(0);

        int end = combination.get(combination.size()-1);

        List<Integer> result = new ArrayList<>();

        if (start > 0){

            result.addAll(A.subList(0, start));

        }

        if (end < A.size() - 1) {

            result.addAll(A.subList(end + 1,A.size()));

        }

        return result;

    }

    public String print(List<Integer> elements){

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < elements.size(); i++) {

            sb.append(elements.get(i) + " ");

        }

        return sb.toString();

    }

}


Examples:

A = [-1,0,1]           => 3

A = [-1,0,-1]          => 1

A = [-1]                    => 1

A = [-1,0]                => 2

A = [0,0]                 => 1

A = [1,0,1,2,3]     => 3

A = [-2,-1,0,1,0]   => 3


Tuesday, July 16, 2024

 These are more use cases targeted for a commercial drone fleet management software that scales elastically and helps drones manage their flight path in real-time.

Case 8: Safety enforcement on failures across multiple drone units is a scenario that should not be the norm, but it is dedicated to the platform for its capability to operate different fleets. Take the specific example of 55 drone units failing out of 200 for a 4th of July show where the failed units landed in Angle Lake close to SeaTac airport and sank to the bottom, some with their lights on. It was a technical glitch where multiple airborne units failed with “no global positioning” and instead of falling from the sky, made controlled landings into the lake. If there were an override to the GPS failure, it could have resulted in runaways, injury or damage. Each of the drones cost about $2600 to the Great Lakes Drone Co based out of Coloma, Michigan before they engaged in safety policies, procedures and programming to make controlled landings.  External interference such as radio deterrence devices including radio frequency jammers or internal malfunctions such as system compromise were not ruled out. The point of this use case is that the responsibility for the flight of the drones lies not just with the controller but also with the platform relaying commands to the drones. Such a use case that spans all drone fleets and their formations and flight paths across tenants is a specific use case that must be tried out with drills and controlled environments. Some amount of Chaos Engineering practices apply to the handling of these drones via the portal.

Case 9: One of the benefits of a cloud native platform for drone fleet management is that this pseudo resource can make use of other user-friendly services such as OpenAI for chatbot like interaction with the software, Cognitive services for multi-media analysis from drone captures, and for voice translation into commands for the drone fleet. From mundane tasks of using a data lake to stash all sensor captures from the drone fleet organized by individual drones as folders and with data plane access separate from control plane access, to more advanced and sophisticated use cases of correlating and automation service requests against drone fleet inventory and dynamic control of fleet crew, the possibilities are endless. Even workflow management becomes easier with cloud resources and integration. Customized automations are facilitated by the cloud’s powerful methods of interactions namely api, sdk, command line and portal.

Previous use cases: DFCSUseCasesList.docx : https://1drv.ms/w/s!Ashlm-Nw-wnWhPB1Ov2NRhBtAQFyNQ?e=GhfAMw

References: https://1drv.ms/w/s!Ashlm-Nw-wnWhPA9saJLYQGA7q2Wiw?e=AONTxo for data architecture 

https://1drv.ms/w/s!Ashlm-Nw-wnWhO4OGADjCj0GVLyFTA?e=UGMEpB for software description.


Monday, July 15, 2024

 Drone Data Architecture:

One of the advantages of a cloud platform for real-time drone data capture and analysis is that the businesses who sign up for it do not have to reinvent it for themselves. In fact, the cloud data architecture, deployment and data driven applications can be stood up with full IaC and data seeding without even involving any drones. When this proof-of-concept has succeeded, scaled, performed and optimized for lowest cost, it is a veritable proprietary patentable asset and one that can serve the world for various use cases. As of today, just a little bit over 10% of enterprises, enact data strategy that works. Drone data a niche but any investments in its planning and architecture will win over mindshare that can only grow. Data is regarded as a byproduct of operations but it can become a driver of business value. With that comes many choices for data infrastructure and tools in a vast ecosystem. Cloud continues to dominate this space with ever increasing storage and computing power to crunch the data. With drone data, the options for being tied down with legacy or on-premises silos just do not exist, so there is an opportunity to start right. Some consider data architecture to be an oxymoron because databases, data warehouses and data lake do not eliminate one another and evolve their own architectures, so that is again an opportunity to start right for drone data without complexity and even come with full-service in the foreseeable increase in regulatory requirements on drone data. Data democratization will favor data literacy which in turn will foster data culture. Also, this builds a single source of truth with purview and that matters.

The previous articles regarding storage of Drone Data enumerated the following components or lines of data organization for workloads such as business analytics, data engineering, streaming and Machine Learning:

Traditional databases for inventory including progressive states and timestamps along with drone capabilities such as degrees of freedom which is inherently relational 

Vector database for training and inferences for both self-organizing maps and CNNs

Performance databases leveraging embedded, unstructured, QoS and cloud databases

Graph databases to serve graph analytics between drones 

Cache infrastructure to mitigate the load on the data tier 

Streaming Data services such as Apache Flink Live and others.

Leaving out the microservices, apis, UI, scriptability and analytics stacks out of the data access discussion and in this section, we describe the workloads in terms of updates and search. This data architecture drawn out from the previous articles strives to drive the most relevant, real-time application experience supporting data acquisition, metadata filtering and the highest F-score search results. A single query must be responded to using vector search, text search, and metadata filtering and consequently span multiple data sources which may not have been virtualized or made amenable to a single SQL-like query interface. While vector embeddings use large language models are becoming popular on the web and cloud computing, model for drones is subject to more specific domain data and filters and draws from the interdisciplinary science from traffic engineering, computer networks, pattern recognition and database systems. This translates to the following requirements:

Fast complex search – spanning vectors, txt, geo and custom json data

Data and index changes – spanning large number of vectors

Rankings – from various ranking algorithms

Real-time and historical updates – with ability to update and delete any data including vectors in milliseconds without incurring reindexing costs

Hyperconverged indexing that includes different types of indexes such as vector index, range index, column store and documents will be sought-after for this kind of platform to manage drone fleet.

#codingexercise: CodingExercise-07-15-2024.docx


Sunday, July 14, 2024

 Drone:

- SysId

- ID

- Name

- Status

- Created

- Modified

- CreatedBy

- ModifiedBy

- Degree-of-freedom

- Max speed

- FuelType

- BatteryLife

- NumberOfFans

- FanStatus1-8

- Location

- Weight

- PayloadWeight

- Mileage

- Color

- LightSensor

- HeatSensor

- IRSensor

- Camera

- Zoom

- Pitch

- Yaw

- Roll

- Display0-255

Fleet:

- ID

- Name

- Drones

- Created

- Modified

- CreatedBy

- ModifiedBy

Location

- Geo coordinates

- GPS Tracking

- LastUpdated

-


Friday, July 12, 2024

 These are more use cases targeted for a commercial drone fleet management software that scales elastically and helps drones manage their flight path in real-time.

Case 6: So far the use cases have elaborated conveniences for drone makers, fleet operators, businesses leveraging drone for delivery, but the following use case focuses on end-users. A drone unit and a small personal fleet of drones can come in helpful for individuals such as farmers or for home security where the units fly to take aerial photo/video around a specific landmark such as a home or barn. Today a single drone is sold along with its remote-operated controller for manual flying but a small fleet of drones can also be sold if they are registered with and controlled by cloud software for specific limited activities. The end-user may download an application and scan the qrcodes off the back of drones so that the application registers them with the clouds and is able to relay commands individually to them. Then a set of predetermined algorithms can help navigate the  drones for aerial surveillance and footage. They can be launched on ad hoc basis or scheduled periodically and matched with image recognition for durations when active monitoring might help. With the potential to build different models of drones for different range and speed and the possibility to scale up the number of drones in the fleet seamlessly, this software could meet a variety of usages across sectors such as fire and rescue, pet surveillance, pest control, improved security, and many more that do not fall under the small-and-medium business category and enterprise category of use cases mentioned earlier.  With topologies that allow dedicated controller for a fleet of lightweight drones and the controller receiving input from the cloud software and relaying to the drones while sending back the sensor data from the drones, the entire compute, storage and network available from the cloud can be leveraged to overcome the limitations on what is shipped out-of-box today or enhance existing fleet of popular appliances like vacuum robots. A high volume of sensor data traffic over the internet might be considered slow for response times in near real-time to drones but they are more for guidance or changes to schedule so-to-speak for mundane activities in these limited scopes for drones. The cloud is uniquely positioned to scale up to the demands of real-time traffic.

Case 7: Federal Regulatory Compliance and Governance of drone usages and activities across tenants is a specific use case dedicated to this platform and one that can be alleviated from the responsibilities of the businesses signing up as tenants. The platform is uniquely positioned to provide a full data purview including genealogy, history, archival and auditing of every operation associated with the drones registered with the platform. Information as requested and required to be disclosed based on sub-poena sent by law enforcement agencies are easy to be drafted and responded to by the platform. For the businesses themselves, change data capture of the drone data as well as real-time information from logs and metrics stores are something that they can view for themselves and thus enforce necessary role-based access controls and auditing for their requirements on governance.

Previous use cases: DFCSUseCasesList.docx