问:
Expanding a list of numbers into a matrix (list with n values to multiply to a n x n matrix)
I have a set of numbers, which I want to expand into a matrix.
There are 4 values in the list which I want to expand into a 4x4 matrix.
Here is some example data

```<code>freq <- c(627,449,813,111)
</code>```

I want to expand this into a matrix of so that it's like this.
Apologies I have just copied and pasted data, thus it's not an R output, but hope it helps to get the idea across.

```<code>    1   2   3   4   Total
1   197 141 255 35  627
2   141 101 183 25  449
3   255 183 330 45  813
4   35  25  45  6   111
    627 449 813 111 2000
</code>```

The cells are multiplication of the (row total)x(column total)/(table total). The value in 1,1 = (627 x 627)/2000 = 197. The value in 2,1 = (627 x 449)/2000 = 141, and so on.

Is there a function that will create this matrix? I will try to do it via a loop but was hoping there is a function or matrix calculation trick that can do this more efficiently? Apologies if I didn't articulate the above too well, any help is greatly appreciated. Thanks

Body:
I have a set of numbers, which I want to expand into a matrix.
There are 4 values in the list which I want to expand into a 4x4 matrix.
Here is some example data

freq <- c(627,449,813,111)

I want to expand this into a matrix of so that it's like this.
Apologies I have just copied and pasted data, thus it's not an R output, but hope it helps to get the idea across.

    1   2   3   4   Total
1   197 141 255 35  627
2   141 101 183 25  449
3   255 183 330 45  813
4   35  25  45  6   111
    627 449 813 111 2000

The cells are multiplication of the (row total)x(column total)/(table total). The value in 1,1 = (627 x 627)/2000 = 197. The value in 2,1 = (627 x 449)/2000 = 141, and so on.

Is there a function that will create this matrix? I will try to do it via a loop but was hoping there is a function or matrix calculation trick that can do this more efficiently? Apologies if I didn't articulate the above too well, any help is greatly appreciated. Thanks

Body:
freq <- c(627,449,813,111)
round(outer(freq, freq)/sum(freq))
#>      [,1] [,2] [,3] [,4]
#> [1,]  197  141  255   35
#> [2,]  141  101  183   25
#> [3,]  255  183  330   45
#> [4,]   35   25   45    6


来源: stackexchange

问:
Why doesn't this __repr__ function return a string?
```<code>class Person:
    greeting = 'Hello'
    def __repr__(self):
        return self.greeting

>>> Sam = Person()
>>> Sam.greeting
'Hello'
>>> Sam
Hello
</code>```

I am having difficulty understanding why the __repr__ function returns self.greeting without quotes. Any help is greatly appreciated.

答:
If you call repr() function, it returns Person object. But If you want to return string value, you can use str()

```<code>    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __repr__(self):
        rep = 'Person(' + self.name + ',' + str(self.age) + ')'
        return rep

person = Person("John", 24)```
print(repr(person)) # Person(John,24)
```

ContentLicense: CC BY-SA 3.0

Body:
class Person:
    greeting = 'Hello'
    def __repr__(self):
        return self.greeting

>>> Sam = Person()
>>> Sam.greeting
'Hello'
>>> Sam
Hello

I am having difficulty understanding why the __repr__ function returns self.greeting without quotes. Any help is greatly appreciated.

Body:
If you call repr() function, it returns Person object. But If you want to return string value, you can use str()

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __repr__(self):
        rep = 'Person(' + self.name + ',' + str(self.age) + ')'
        return rep

person = Person("John", 24)```
print(repr(person)) # Person(John,24)

ContentLicense: CC BY-SA 4.0


问:
Why is a "use" needed for env::args() but not Vec::new()?
For env::args() I am having to explicitly include the env module by

use std::env;
```

But I am able to use Vec::new() without the use std::vec statement, though both are from the standard library.

Is there a subset of standard library modules that are made available by default for all programs?

答: Yes, everything in the Rust prelude (including std::vec::Vec) is available by default.

Body:
For env::args() I am having to explicitly include the env module by

use std::env;

But I am able to use Vec::new() without the use std::vec statement, though both are from the standard library.

Is there a subset of standard library modules that are made available by default for all programs?


答: Yes, all programs implicitly import all members of the prelude module.</p>

Title: Why is a "use" needed for env::args() but not Vec::new()?


问:
Nodejs write multiple dynamically changing files with fs writefile
I need to write multiple dynamically changing files based on an array consisting of objects passed to a custom writeData() function. This array consists of objects containing the file name and the data to write as shown below:

```<code>[
  {
    file_name: "example.json",
    dataObj,
  },
  {
    file_name: "example2.json",
    dataObj,
  },
  {
    file_name: "example3.json",
    dataObj,
  },
  {
    file_name: "example4.json",
    dataObj,
  },
];
</code>```

My current method is to map this array and read + write new data to each file:

```<code>array.map((entry) => {
  fs.readFile(
    entry.file_name,
    "utf8",
    (err, unparsedData) => {
      if (err) console.log(err);
      else {
        var parsedData = JSON.parse(unparsedData);
        parsedData.data.push(entry.dataObj);
        const parsedDataJSON = JSON.stringify(parsedData, null, 2);
        fs.writeFile(
          entry.file_name,
          parsedDataJSON,
          "utf8",
          (err) => {
            if (err) console.log(err);
          }
        );
      }
    }
  );
});

</code>```

This however, does not work. Only a small percent of data is written to these files and often times the file is not correctly written in json format (I think this is because two writeFile processes are writing to the same file at once and that breaks the file). Obviously this does not work the way I expected it to.

The multiple ways I have tried to resolve this problem consisted of attempting to make the fs.writeFile synchronous (delay the map loop, allowing each process to finish before moving to the next entry), but this is not a good practice as synchronous processes hang up the entire app.  I have also looked into implementing promises but to no avail. I am a new learner to nodejs so apologies for missed details/information. Any help is appreciated!

答:
The same file is often listed multiple times in the array if that changes anything.

Well, that changes everything.  You should have shown that in the original question.  If that is the case, then you have to sequence each individual file in the loop so it finishes one before advancing to the next.  To prevent conflicts between writing to the same file, you have to assure yourself of two things:

You sequence each of the files in the loop so the next one doesn't start until the previous one is done.

You don't call this code again while its still in operation.

You can assure yourself of the first item like this:

```<code>async function processFiles(array) {
    for (let entry of array) {
        const unparsedData = await fs.promises.readFile(entry.file_name, "utf8");
        const parsedData = JSON.parse(unparsedData);
        parsedData.data.push(entry.dataObj);
        const json = JSON.stringify(parsedData, null, 2);
        await fs.promise.writeFile(entry.file_name, json, "utf8");
    }
}
</code>```

This will abort the loop if it gets an error on any of them.  If you want it to continue to write the others, you can add a try/catch internally:

```<code>async function processFiles(array) {
    let firstError;
    for (let entry of array) {
        try {
            const unparsedData = await fs.promises.readFile(entry.file_name, "utf8");
            const parsedData = JSON.parse(unparsedData);
            parsedData.data.push(entry.dataObj);
            const json = JSON.stringify(parsedData, null, 2);
            await fs.promise.writeFile(entry.file_name, json, "utf8");
        } catch (e) {
            // log error and continue with the rest of the loop
            if (!firstError) {
                firstError = e;
            }
            console.log(e);
        }
    }
    // make sure we communicate back any error that happened
    if (firstError) {
        throw firstError;
    }
}
</code>```

To assure yourself of the second point above, you will have to either not use a setInterval() (replace it with a setTimeout() that you set when the promise that processFiles()resolves or make absolutely sure that the setInterval() time is long enough that it will never fire before processFiles() is done.

Also, make absolutely sure that you are not modifying the array used in this function while that function is running.

Body:
I need to write multiple dynamically changing files based on an array consisting of objects passed to a custom writeData() function. This array consists of objects containing the file name and the data to write as shown below:

[
  {
    file_name: "example.json",
    dataObj,
  },
  {
    file_name: "example2.json",
    dataObj,
  },
  {
    file_name: "example3.json",
    dataObj,
  },
  {
    file_name: "example4.json",
    dataObj,
  },
];

My current method is to map this array and read + write new data to each file:

array.map((entry) => {
  fs.readFile(
    entry.file_name,
    "utf8",
    (err, unparsedData) => {
      if (err) console.log(err);
      else {
        var parsedData = JSON.parse(unparsedData);
        parsedData.data.push(entry.dataObj);
        const parsedDataJSON = JSON.stringify(parsedData, null, 2);
        fs.writeFile(
          entry.file_name,
          parsedDataJSON,
          "utf8",
          (err) => {
            if (err) console.log(err);
          }
        );
      }
    }
  );
});

This however, does not work. Only a small percent of data is written to these files and often times the file is not correctly written in json format (I think this is because two writeFile processes are writing to the same file at once and that breaks the file). Obviously this does not work the way I expected it to.

The multiple ways I have tried to resolve this problem consisted of attempting to make the fs.writeFile synchronous (delay the map loop, allowing each process to finish before moving to the next entry), but this is not a good practice as synchronous processes hang up the entire app.  I have also looked into implementing promises but to no avail. I am a new learner to nodejs so apologies for missed details/information. Any help is appreciated!

Body:
The same file is often listed multiple times in the array if that changes anything.

Well, that changes everything.  You should have shown that in the original question.  If that is the case, then you have to sequence each individual file in the loop so it finishes one before advancing to the next.  To prevent conflicts between writing to the same file, you have to assure yourself of two things:

You sequence each of the files in the loop so the next one doesn't start until the previous one is done.

You don't call this code again while its still in operation.

You can assure yourself of the first item like this:

async function processFiles(array) {
    for (let entry of array) {
        const unparsedData = await fs.promises.readFile(entry.file_name, "utf8");
        const parsedData = JSON.parse(unparsedData);
        parsedData.data.push(entry.dataObj);
        const json = JSON.stringify(parsedData, null, 2);
        await fs.promise.writeFile(entry.file_name, json, "utf8");
    }
}

This will abort the loop if it gets an error on any of them.  If you want it to continue to write the others, you can add a try/catch internally:

async function processFiles(array) {
    let firstError;
    for (let entry of array) {
        try {
            const unparsedData = await fs.promises.readFile(entry.file_name, "utf8");
            const parsedData = JSON.parse(unparsedData);
            parsedData.data.push(entry.dataObj);
            const json = JSON.stringify(parsedData, null, 2);
            await fs.promise.writeFile(entry.file_name, json, "utf8");
        } catch (e) {
            // log error and continue with the rest of the loop
            if (!firstError) {
                firstError = e;
            }
            console.log(e);
        }
    }
    // make sure we communicate back any error that happened
    if (firstError) {
        throw firstError;
    }
}

To assure yourself of the second point above, you will have to either not use a setInterval() (replace it with a setTimeout() that you set when the promise that processFiles()resolves or make absolutely sure that the setInterval() time is long enough that it will never fire before processFiles() is done.

Also, make absolutely sure that you are not modifying the array used in this function while that function is running.


问:
Why Does The Flex Compiler Get Confused If a Property Name Matches A Class Type?
This is more of a rant than a question; but I am curious to know if anyone has some insight for me.  The application I am working on deals with a C# .NET backend; communication is achieved via a socket over which we push AMF objects.  The AMF object class definitions are generated by the server side team and I just have to use registerClassAlias on the flash side to link them up - pretty standard; the only difference being that as they come from a C# background they prefer to use UpperCammelCasing instead of lowerCamelCasing for property names.

Today I got a bunch of updated AMF objects which I dropped into the project; but I noticed that after updating my project would no longer compile - here are the class definitions in question:

LeaderboardInfo.as Generated Class

```<code>package com.generated {
    public class LeaderboardInfo {
        public var IsTied : Boolean;
    }
}</code>```

GameResult.as Generated Class

```<code>package com.generated {
    public class GameResult {
        public var LeaderboardInfo : LeaderboardInfo;
    }
}</code>```

MXMLC error

```[mxmlc] .../GameResult.as(27): col: 32 Error: Type was not found or was not a compile-time constant: LeaderboardInfo.
[mxmlc]         public var LeaderboardInfo : LeaderboardInfo;
[mxmlc]                                      ^```

If I change the property name from LeaderboardInfo to SomethingElse then it compiles fine; my only guess would be that the Compiler can not distinguish between the property name and the type attribute, but is that really the case?!

答:
I think it's because you've just overwritten the "definition" of LeaderboardInfo to be a property and not a class, so when it's looking for the class, the property definition takes precedence, which breaks it.

I'd imagine you'd get the same result if you tried to do something like public var return:int = 0;

Body:
This is more of a rant than a question; but I am curious to know if anyone has some insight for me.  The application I am working on deals with a C# .NET backend; communication is achieved via a socket over which we push AMF objects.  The AMF object class definitions are generated by the server side team and I just have to use registerClassAlias on the flash side to link them up - pretty standard; the only difference being that as they come from a C# background they prefer to use UpperCammelCasing instead of lowerCamelCasing for property names.

Today I got a bunch of updated AMF objects which I dropped into the project; but I noticed that after updating my project would no longer compile - here are the class definitions in question:

LeaderboardInfo.as Generated Class

package com.generated {
    public class LeaderboardInfo {
        public var IsTied : Boolean;
    }
}

GameResult.as Generated Class

package com.generated {
    public class GameResult {
        public var LeaderboardInfo : LeaderboardInfo;
    }
}

MXMLC error

[mxmlc] .../GameResult.as(27): col: 32 Error: Type was not found or was not a compile-time constant: LeaderboardInfo.
[mxmlc]         public var LeaderboardInfo : LeaderboardInfo;
[mxmlc]                                      ^

If I change the property name from LeaderboardInfo to SomethingElse then it compiles fine; my only guess would be that the Compiler can not distinguish between the property name and the type attribute, but is that really the case?!


问:
AngularJS two different actions in ng-submit
I'm new to AngularJS, currently I am trying to create a spa for tracking expenses as a simple project but I have some problems with my code.

I managed to do the most of the function but I got stuck at the update function, I want to be able to update the data without creating another button, instead using the same submit button which is used to add new data

Here is the html and js code:

```<code><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Expenses Tracker</title>
    <link rel="stylesheet" href="bootstrap.min.css">
    <link href="style.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <span class="navbar-brand"><img src="logo.png" class="brand" height="40" />
                 Simple Expenses App Tracker</span>
            </div>
        </div>
    </nav>

    <div class="main" ng-app="myList" ng-controller="myListController">

        <img src="logo.png" class="logo">

    <form ng-submit="newItem()" class="form">
        <input required type="number" placeholder="Amount" ng-model="amount">
        <input required type="text" placeholder="Description" ng-model="description">
        <input type="submit" value="Submit" class="btn btn-success">
    </form>
        <ul>
            <li ng-repeat="item in items">
                <span  class="pull-left"> {{item.amount}} den.</span> {{item.description}}
                <span class="buttons">
                    <input type="button" ng-click="editItem($index)" value="Edit" class="btn btn-primary" >
                    <input type="button" ng-click="deleteItem($index)" value="Delete" class="btn btn-danger">
                </span>
            </li>
            <br>
            <li><span class="total">{{totalPrice()}} den.</span> <span class="expense"> Total Expenses</span></li>
        </ul>

    </div>

    <script src="bootstrap.min.js"></script>
    <script src="angular.min.js"></script>
    <script src="angular-route.min.js"></script>
    <script src="app.js"></script>
</body>
</html>
</code>```
```<code>var myApp = angular.module("myList", []);

myApp.controller("myListController", function($scope) {
    $scope.items = [];

    $scope.newItem = function() {
            $scope.items.push({description:$scope.description, amount: $scope.amount});
            $scope.description = '';
            $scope.amount = 0
    };

    $scope.deleteItem = function(index) {
        $scope.items.splice(index, 1);
    }

    $scope.totalPrice = function() {
        var total = 0;
        for(count=0; count<$scope.items.length;count++){
            total += $scope.items[count].amount;
        }
        return total;
    };

    $scope.editItem = function(index) {
        $scope.amount = $scope.items[index].amount;
        $scope.description = $scope.items[index].description;
    };

});

</code>```

答:
You could have two scope variables to keep track if in edit mode and to keep track of the index that is being edited, and in the newItem() can have an if else statement based on edit mode or not
For example you could do something like

var myApp = angular.module("myList", []);

myApp.controller("myListController", function($scope) {
    $scope.items = [];
    $scope.isEdit = false; // initialize
    $scope.editingIndex = null;  //initialize
    $scope.newItem = function() {
     if(!$scope.isEdit){  //if not in edit mode -> add new
       $scope.items.push({description:$scope.description, amount: $scope.amount});

     }
      else{  //in edit mode -> edit the object
        $scope.items[$scope.editingIndex] = {  //replace with new values
          description:$scope.description, amount: $scope.amount
        }
        $scope.isEdit = false;    //setting back to false
        $scope.editingIndex = null;
      }
            $scope.description = '';
            $scope.amount = 0
    };

    $scope.deleteItem = function(index) {
        $scope.items.splice(index, 1);
    }

    $scope.totalPrice = function() {
        var total = 0;
        for(count=0; count<$scope.items.length;count++){
            total += $scope.items[count].amount;
        }
        return total;
    };

    $scope.editItem = function(index) {
        $scope.isEdit = true;  //setting edit mode true
        $scope.editingIndex = index; //setting the index to edit
        $scope.amount = $scope.items[index].amount;
        $scope.description = $scope.items[index].description;
    };

});

```

demo

Body:
I'm new to AngularJS, currently I am trying to create a spa for tracking expenses as a simple project but I have some problems with my code.

I managed to do the most of the function but I got stuck at the update function, I want to be able to update the data without creating another button, instead using the same submit button which is used to add new data

Here is the html and js code:

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Expenses Tracker</title>
    <link rel="stylesheet" href="bootstrap.min.css">
    <link href="style.css" rel="stylesheet">

                 Simple Expenses App Tracker

    <form ng-submit="newItem()" class="form">
        <input required type="number" placeholder="Amount" ng-model="amount">
        <input required type="text" placeholder="Description" ng-model="description">
        <input type="submit" value="Submit" class="btn btn-success">
    </form>

                 {{item.amount}} den. {{item.description}}

                    <input type="button" ng-click="editItem($index)" value="Edit" class="btn btn-primary" >
                    <input type="button" ng-click="deleteItem($index)" value="Delete" class="btn btn-danger">

{{totalPrice()}} den.  Total Expenses

var myApp = angular.module("myList", []);

myApp.controller("myListController", function($scope) {
    $scope.items = [];

    $scope.newItem = function() {
            $scope.items.push({description:$scope.description, amount: $scope.amount});
            $scope.description = '';
            $scope.amount = 0
    };

    $scope.deleteItem = function(index) {
        $scope.items.splice(index, 1);
    }

    $scope.totalPrice = function() {
        var total = 0;
        for(count=0; count<$scope.items.length;count++){
            total += $scope.items[count].amount;
        }
        return total;
    };

    $scope.editItem = function(index) {
        $scope.amount = $scope.items[index].amount;
        $scope.description = $scope.items[index].description;
    };

});

Body:
You could have two scope variables to keep track if in edit mode and to keep track of the index that is being edited, and in the newItem() can have an if else statement based on edit mode or not
For example you could do something like

var myApp = angular.module("myList", []);

myApp.controller("myListController", function($scope) {
    $scope.items = [];
    $scope.isEdit = false; // initialize
    $scope.editingIndex = null;  //initialize
    $scope.newItem = function() {
     if(!$scope.isEdit){  //if not in edit mode -> add new
       $scope.items.push({description:$scope.description, amount: $scope.amount});

     }
      else{  //in edit mode -> edit the object
        $scope.items[$scope.editingIndex] = {  //replace with new values
          description:$scope.description, amount: $scope.amount
        }
        $scope.isEdit = false;    //setting back to false
        $scope.editingIndex = null;
      }
            $scope.description = '';
            $scope.amount = 0
    };

    $scope.deleteItem = function(index) {
        $scope.items.splice(index, 1);
    }

    $scope.totalPrice = function() {
        var total = 0;
        for(count=0; count<$scope.items.length;count++){
            total += $scope.items[count].amount;
        }
        return total;
    };

    $scope.editItem = function(index) {
        $scope.isEdit = true;  //setting edit mode true
        $scope.editingIndex = index; //setting the index to edit
        $scope.amount = $scope.items[index].amount;
        $scope.description = $scope.items[index].description;
    };

});

demo


问:
.NET Blazor and client-side debugging?
Is Blazor client-side debugging possible or what is that experience like?

Blazor is new to me. I've used Razor / MVC significantly in the past but moved on to other technologies. Checking it out now, Blazor is definitely an improvement and seems to replace Javascript with dot NET. One of the things mentioned is it can run on the browser. My question then is: how is the client-side debugging experience in Dev Chrome Tools?

One of the Blazor videos in checking out:

https://www.youtube.com/watch?v=Z0c7d64W-B8&list=PLcYfGPOcgilkwLcDgXrOoqvTd-2ettqED

答:
Your browser's developer tools aren't going to be particularly useful when debugging Blazor apps. Here are the types of messages you'll see in the console.

The code running the browser is WebAssembly, compiled from C# or other .NET language. WebAssembly is binary, so you're not going to be able to debug that in your browser. Instead, you'd want to debug the .NET language in an IDE (Visual Studio, VS Code, etc.).

Title: .NET Blazor and client-side debugging?


问:
how to change my icon layout to flex on css
I'm trying to change my icons to flex but that didn't work. This was my original CSS code:

```<code>.recipe-icons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2rem 0;
  text-align: center;
}
</code>```

I also tried setting display to flex, justify-content to center and all that but that didn't work either. How can I fix this? This is my html code for my icons:

```<code>div class="recipe-icons">
            <article>
              <!-- single recipe icon -->
              <i class="fas fa-clock"></i>
              <h5>prep time</h5>
              <p>30 min.</p>
              <!-- single recipe icon -->
              <i class="far fa-clock"></i>
              <h5>cook time</h5>
              <p>15 min.</p>
              <!-- single recipe icon -->
              <i class="fas fa-user-friends"></i>
              <h5>servings</h5>
              <p>6 servings</p>
              <!-- recipe tags -->
              <div class="recipe-tags">
                Tags: <a href="tag-template.html">beef</a>
                <a href="tag-template.html">breakfast</a>
                <a href="tag-template.html">pancakes</a>
                <a href="tag-template.html">food</a>
              </div>
            </article>
</div>
</code>```

答:
I have an alternative way of doing something like that using display: flex;
Also you should surround the elements in a div to group them.
Working example https://jsfiddle.net/r5Lfcbh8/1/

Html:

```<code><article>
  <div class="recipe-icons">
    <div class="iconRow">
      <i class="fas fa-clock"></i>
      <h5>prep time</h5>
      <p>30 min.</p>
    </div>
    <div class="iconRow">
      <i class="far fa-clock"></i>
      <h5>cook time</h5>
      <p>15 min.</p>
    </div>
    <div class="iconRow">
      <i class="fas fa-user-friends"></i>
      <h5>servings</h5>
      <p>6 servings</p>
    </div>
  </div>
  <div class="recipe-tags">
    <span>Tags:</span>
    <a href="tag-template.html">beef</a>
    <a href="tag-template.html">breakfast</a>
    <a href="tag-template.html">pancakes</a>
    <a href="tag-template.html">food</a>
  </div>
</article>
</code>```

And css:

```<code>article, .recipe-icons, .recipe-tags {
  display: flex;
}

article {
  flex-direction: column;
}

.recipe-tags {
  margin-top: 10px;
}

.recipe-tags > * {
  margin-left: 5px;
}

.recipe-icons > .iconRow {
  flex: 1 1 auto;
  text-align: center;
}

.recipe-icons > .iconRow > * {
  margin: 5px 0;
}
</code>```

Body:
I'm trying to change my icons to flex but that didn't work. This was my original CSS code:

.recipe-icons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2rem 0;
  text-align: center;
}

I also tried setting display to flex, justify-content to center and all that but that didn't work either. How can I fix this? This is my html code for my icons:

div class="recipe-icons">

prep time

30 min.

cook time

15 min.

servings

6 servings

                Tags: beef
                breakfast
                pancakes
                food

Body:
I have an alternative way of doing something like that using display: flex;
Also you should surround the elements in a div to group them.
Working example https://jsfiddle.net/r5Lfcbh8/1/

Html:

<article>
  <div class="recipe-icons">
    <div class="iconRow">
      <i class="fas fa-clock"></i>
      <h5>prep time</h5>
      <p>30 min.</p>
    </div>
    <div class="iconRow">
      <i class="far fa-clock"></i>
      <h5>cook time</h5>
      <p>15 min.</p>
    </div>
    <div class="iconRow">
      <i class="fas fa-user-friends"></i>
      <h5>servings</h5>
      <p>6 servings</p>
    </div>
  </div>
  <div class="recipe-tags">
    <span>Tags:</span>
    <a href="tag-template.html">beef</a>
    <a href="tag-template.html">breakfast</a>
    <a href="tag-template.html">pancakes</a>
    <a href="tag-template.html">food</a>
  </div>
</article>

And css:

article, .recipe-icons, .recipe-tags {
  display: flex;
}

article {
  flex-direction: column;
}

.recipe-tags {
  margin-top: 10px;
}

.recipe-tags > * {
  margin-left: 5px;
}

.recipe-icons > .iconRow {
  flex: 1 1 auto;
  text-align: center;
}

.recipe-icons > .iconRow > * {
  margin: 5px 0;
}


问:
WSL vscode command returning error "not found"
I have this message whenenver i try to type code .

Can someone help me please ?

Thanks in advance

答:
Fixed it

Open VS Code on Windows

Open Extensions and then search on WSL

It should say the extension needs to be reloaded - go ahead and reload it

Open WSL and type code

This should force another upgrade of code and this time it should launch.


问:
How to redraw specific DOM asynchronously in Mithril
I have sub-components that are updated by injecting state from the parent component.

I need to populate the model using an asynchronous function when the value of the parent component changes.

And I want to draw a new subcomponent after the asynchronous operation is finished.

I checked the change of the parent component value in onbeforeupdate, executed the asynchronous function, and then executed the redraw function, but this gets stuck in an infinite loop.

```<code>...

async onbeforeupdate((vnode)) => {
  if (this.prev !== vnode.attrs.after) {
    // Update model data
    await asyncRequest();
    m.redraw();
  }
}

view() {
  return (...)
}

...

</code>```

答: It should work. Maybe something is wrong with updating this.prev

Body:
I have sub-components that are updated by injecting state from the parent component.

I need to populate the model using an asynchronous function when the value of the parent component changes.

And I want to draw a new subcomponent after the asynchronous operation is finished.

I checked the change of the parent component value in onbeforeupdate, executed the asynchronous function, and then executed the redraw function, but this gets stuck in an infinite loop.

...

async onbeforeupdate((vnode)) => {
  if (this.prev !== vnode.attrs.after) {
    // Update model data
    await asyncRequest();
    m.redraw();
  }
}

view() {
  return (...)
}

...


问:
Change Placement of pagination in .mat-tab-group
I am trying to move the .mat-tab-header-pagination-after to next to the .mat-tab-header-pagination-before in a .mat-tab-group, the angular tab component. I am wondering how I am able to move the after pagination either in the html or css. Since it is automatic when the pagination shows, I am not sure how I am able to instantiate it differently so that it moves  to the placement I want it to be. Any help from html or css familiar with angular components?

<mat-tab-group [selectedIndex]="selected.value"
             (selectedIndexChange)="selected.setValue($event)">
  <mat-tab *ngFor="let tab of tabs; let index = index" [label]="tab" (contextmenu)="onContextMenu($event, tab)">
    <ng-template mat-tab-label>

{{tab}}

      <button *ngIf="tab.name !== 'Main'" style="color:black; bottom:10px; right:10px" mat-icon-button (click)="closeTab(index)">
      <mat-icon>close</mat-icon>
      </button>
      <button mat-icon-button [matMenuTriggerFor]="contextMenu">
        <mat-icon>more_vert</mat-icon>
      </button>
    </ng-template>
    Contents for {{tab}} tab
  </mat-tab>
  <mat-tab disabled>
    <ng-template mat-tab-label>
        <button mat-icon-button (click)="addTab(selectAfterAdding.checked)">
            <mat-icon>add_circle</mat-icon>
        </button>
    </ng-template>
  </mat-tab>
</mat-tab-group>```

Before Picture:
Image of how it is now

After Picture with wanted placement:
Image with moved placement

答:
Since .mat-tab-header is a flex container, you can user the order property on child elements to change it's order:

```<code>.mat-tab-header-pagination-controls-enabled {
  .mat-tab-header-pagination-before {
    order: 0;
  }

  .mat-tab-header-pagination-after {
    order:1;
  }

  .mat-tab-label-container {
    order: 2;
  }
}
</code>```

Note that due to style encapsulation you need to apply those in global styles.

Stackblitz with updated styles (forked from official examples) here.

Body:
I am trying to move the .mat-tab-header-pagination-after to next to the .mat-tab-header-pagination-before in a .mat-tab-group, the angular tab component. I am wondering how I am able to move the after pagination either in the html or css. Since it is automatic when the pagination shows, I am not sure how I am able to instantiate it differently so that it moves  to the placement I want it to be. Any help from html or css familiar with angular components?

<mat-tab-group [selectedIndex]="selected.value"
             (selectedIndexChange)="selected.setValue($event)">
  <mat-tab *ngFor="let tab of tabs; let index = index" [label]="tab" (contextmenu)="onContextMenu($event, tab)">
    <ng-template mat-tab-label>

{{tab}}

      <button *ngIf="tab.name !== 'Main'" style="color:black; bottom:10px; right:10px" mat-icon-button (click)="closeTab(index)">
      <mat-icon>close</mat-icon>
      </button>
      <button mat-icon-button [matMenuTriggerFor]="contextMenu">
        <mat-icon>more_vert</mat-icon>
      </button>
    </ng-template>
    Contents for {{tab}} tab
  </mat-tab>
  <mat-tab disabled>
    <ng-template mat-tab-label>
        <button mat-icon-button (click)="addTab(selectAfterAdding.checked)">
            <mat-icon>add_circle</mat-icon>
        </button>
    </ng-template>
  </mat-tab>
</mat-tab-group>

Before Picture:
Image of how it is now

After Picture with wanted placement:
Image with moved placement

Body:
Since .mat-tab-header is a flex container, you can user the order property on child elements to change it's order:

.mat-tab-header-pagination-controls-enabled {
  .mat-tab-header-pagination-before {
    order: 0;
  }

  .mat-tab-header-pagination-after {
    order:1;
  }

  .mat-tab-label-container {
    order: 2;
  }
}

Note that due to style encapsulation you need to apply those in global styles.

Stackblitz with updated styles (forked from official examples) here.


问:
Reset/clear viewmodel or livedata
I am following the one-single-activity app pattern advised by Google, so if I want to share data between Fragments I have to share a ViewModel whose owner must be the parent Activity. So, the problem becomes because I want to share data between only two Fragments, independently from the others.

Imagine I have  MainFragment, CreateItemFragment and ScanDetailFragment. So, from first one I navigate to CreateItemFragment in which whenever I press a button I navigate to  ScanDetailFragment in order to scan a barcode and, in consequence, through a LiveData object inside the ViewModel I can get the scanned value back into the CreateItemFragment once ScandDetailFragment finishes. The problem becomes when I decide to cancel the creation of the item: I go back to the `MainFragment' and because the ViewModel's owner was the Activity's lifecycle, once I go again into CreateItemFragment, the previously scanned value is still there.

Any idea to reset that ViewModel?

答:
At the moment (on 2022), the method viewmodel.getViewModelStore.clear(); or onCleared(); is deprecated.

So, if you want to clear data holded by ViewModel or clear value of LiveData, you just need use 1 line code like this:

```<code>mainViewModel.getLiveData().getValue().clear();
</code>```

getLiveData() is my method inside MainViewModel class to return liveData variable

getValue() is defaut method provided by LiveData (MutableLiveData: setValue(), postValue())

If you need to clear data when user press on Back button in Fragment, you can do like the code below & put it inside the onViewCreated method - the method of LifecycleFragment.

```<code>private void handleOnBackPressed() {
        requireActivity().getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
            @Override
            public void handleOnBackPressed() {
                Objects.requireNonNull(mainViewModel.getLiveData().getValue()).clear();
                requireActivity().finish();
            }
        });
    }
</code>```

My project on Git if you want to refer code (it still updated): https://github.com/Nghien-Nghien/PokeAPI-Java/blob/master/app/src/main/java/com/example/pokemonapi/fragment/MainFragment.java

Title: Reset/clear viewmodel or livedata

Body:
At the moment (on 2022), the method viewmodel.getViewModelStore.clear(); or onCleared(); is deprecated.

So, if you want to clear data holded by ViewModel or clear value of LiveData, you just need use 1 line code like this:

mainViewModel.getLiveData().getValue().clear();

getLiveData() is my method inside MainViewModel class to return liveData variable

getValue() is defaut method provided by LiveData (MutableLiveData: setValue(), postValue())

If you need to clear data when user press on Back button in Fragment, you can do like the code below & put it inside the onViewCreated method - the method of LifecycleFragment.

private void handleOnBackPressed() {
        requireActivity().getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
            @Override
            public void handleOnBackPressed() {
                Objects.requireNonNull(mainViewModel.getLiveData().getValue()).clear();
                requireActivity().finish();
            }
        });
    }

My project on Git if you want to refer code (it still updated): https://github.com/Nghien-Nghien/PokeAPI-Java/blob/master/app/src/main/java/com/example/pokemonapi/fragment/MainFragment.java


答:
Sequence operator can be used

# when to start when to finish
my $start = DateTime.now.truncated-to("day");
my $end   = $start.later(:1day);

# after start, add 5 mins repeatedly, and stop when end is exceeded
say $start, *.later(:5minutes) ... * >= $end;
```

Body:
How to generate a DateTime range by step of 5 minutes? The following is the output:

2022-02-13 00:00:00, 2022-02-13 00:05:00
2022-02-13 00:05:00, 2022-02-13 00:10:00
2022-02-13 00:10:00, 2022-02-13 00:15:00
2022-02-13 00:15:00, 2022-02-13 00:20:00
...
2022-02-13 23:45:00, 2022-02-13 23:50:00
2022-02-13 23:50:00, 2022-02-13 23:55:00
2022-02-13 23:55:00, 2022-02-14 00:00:00


问:
rake db:migrate doesn't detect new migration?
Experienced with Rails / ActiveRecord 2.1.1

You create a first version with (for example) ruby script\generate scaffold product title:string description:text image_url:string

This create (for example) a migration file called 20080910122415_create_products.rb

You apply the migration with rake db:migrate

Now, you add a field to the product table with ruby script\generate migration add_price_to_product price:decimal

This create a migration file called 20080910125745_add_price_to_product.rb

If you try to run rake db:migrate, it will actually revert the first migration, not apply the next one! So your product table will get destroyed!

But if you ran rake alone, it would have told you that one migration was pending

Pls note that applying rake db:migrate (once the table has been destroyed) will apply all migrations in order.

The only workaround I found is to specify the version of the new migration as in:

```<code>rake db:migrate version=20080910125745
</code>```

So I'm wondering: is this an expected new behavior?

答:
Jean,

Thanks a lot for your investigation. You're right, and actually I think you've uncovered a more severe bug, of species 'design bug'.

What's happening is that rake will grab whatever value you pass to the command line and store them as environment variables. The rake tasks that will eventually get called will just pull this values from the environment variable.
When db:migrate queries ENV["VERSION"], it actually requests the version parameter which you set calling rake. When you call rake db:migrate, you don't pass any version.

But we do have an environment variable called VERSION that has been set for other purposes by some other program (I don't which one yet). And the guys behind rake (or behind database.rake) haven't figured this would happen. That's a design bug. At least, they could have used more specific variable names like "RAKE_VERSION" or "RAKE_PARAM_VERSION" instead of just "VERSION".

Tom, I will definitely not close but edit my bug report on lighthouse to reflect these new findings.

And thanks again Jean for your help. I've posted this bug on lighthouse like 5 days agao and still got no answer!

Rollo

Body:
Experienced with Rails / ActiveRecord 2.1.1

You create a first version with (for example) ruby script\generate scaffold product title:string description:text image_url:string

This create (for example) a migration file called 20080910122415_create_products.rb

You apply the migration with rake db:migrate

Now, you add a field to the product table with ruby script\generate migration add_price_to_product price:decimal

This create a migration file called 20080910125745_add_price_to_product.rb

If you try to run rake db:migrate, it will actually revert the first migration, not apply the next one! So your product table will get destroyed!

But if you ran rake alone, it would have told you that one migration was pending

Pls note that applying rake db:migrate (once the table has been destroyed) will apply all migrations in order.

The only workaround I found is to specify the version of the new migration as in:

rake db:migrate version=20080910125745

So I'm wondering: is this an expected new behavior?

ContentLicense: CC BY-SA 2.5


问:
check if first two letter (digits) in a ip adress is '41' with PHP?
I use PHP:s ['REMOTE_ADDR'] to fetch the users ip.

I want to see if that ip starts with a 41.

```<code>$usr_ip = $_SERVER['REMOTE_ADDR'];
</code>```

Then I want to match, and if it starts with 41, then die()

I don't know how to do the matching.

答:
```<code>if(substr($_SERVER['REMOTE_ADDR'], 0, 2) == '41') die();
</code>```

Body:
I use PHP:s ['REMOTE_ADDR'] to fetch the users ip.

I want to see if that ip starts with a 41.

$usr_ip = $_SERVER['REMOTE_ADDR'];

Then I want to match, and if it starts with 41, then die()

I don't know how to do the matching.


问:
how do i rename fei62x64.sys in order to enable TPM
Trying to turn on TPM on a computer with the TPM chip on windows 10 pro, version 10.0.19043, build 19043
Get a message to resolve any driver incompatibilities and scan again
I reviewed  incompatible driver list
fei62x64.sys is the only one listed
It appears to be an intel network driver with creation date 10/1/2009

I have searched through stack for similar problems and they have not helped

I tried a program called dependency walker to see if it is in use and could not determine if it was
I added my userid and administrator explicitly with full control to the file

Looked at each of the entries for Intel under device manager driver details and the driver, fei62x64 is not mentioned
Decided to try to rename file
First did backup, fresh system image, and restore point
Unable to rename file
Added my personal user id and administrator as owners with full control
Still unable to rename file.  The error I get is

ren : Access to the path is denied.
At line:1 char:1

ren fei62x64.sys fei62x64.old

```<code>  + CategoryInfo          : PermissionDenied: (C:\windows\syst...c1\fei62x64.sys:String) [Rename-Item], Unauthorized
AccessException
  + FullyQualifiedErrorId : RenameItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.RenameItemCommand
</code>```

Checked with computer maker, Puget Systems, and they sent a list of updated drivers which had no impact on this issue since fei62x64 remains.
Any thoughts on how to either rename this file or another way to allow me to enable to turn on core isolation with fei62x64 listed as incompatible driver

答: Okay I think my best solution is to use pnputil, a microsoft utility which allows you to delete a driver.  Obviously be good to do a backup before using something like this. pnputil will allow you to delete individual drivers</p>

Body:
Trying to turn on TPM on a computer with the TPM chip on windows 10 pro, version 10.0.19043, build 19043
Get a message to resolve any driver incompatibilities and scan again
I reviewed  incompatible driver list
fei62x64.sys is the only one listed
It appears to be an intel network driver with creation date 10/1/2009

I have searched through stack for similar problems and they have not helped

I tried a program called dependency walker to see if it is in use and could not determine if it was
I added my userid and administrator explicitly with full control to the file

Looked at each of the entries for Intel under device manager driver details and the driver, fei62x64 is not mentioned
Decided to try to rename file
First did backup, fresh system image, and restore point
Unable to rename file
Added my personal user id and administrator as owners with full control
Still unable to rename file.  The error I get is

ren : Access to the path is denied.
At line:1 char:1

ren fei62x64.sys fei62x64.old

  + CategoryInfo          : PermissionDenied: (C:\windows\syst...c1\fei62x64.sys:String) [Rename-Item], Unauthorized
AccessException
  + FullyQualifiedErrorId : RenameItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.RenameItemCommand

Checked with computer maker, Puget Systems, and they sent a list of updated drivers which had no impact on this issue since fei62x64 remains.
Any thoughts on how to either rename this file or another way to allow me to enable to turn on core isolation with fei62x64 listed as incompatible driver


问:
Find of N numbers K numbers xor equalling 0
My Problem is to find k Numbers in e.g. an Vector/Array with n Numbers, which equal calculated with xor 0. I tried already to brutforce all combinations without repetition, but with n=100 and k=10 the Time Complexity is to high. (about 1.7*10^13 possibilities)

Does anyone have any ideas, to speed up the process of finding the k Numbers in an Array with n Numbers?

I think my approach is not the smartest with such a high number of possibilities, but I really do not know how to make my program faster.

I would appreciate suggestions for a solution.

My program is in C++.

```<code>SOLUTION comb(int N, int K, const std::vector<KEY>& bit_codes)
{
    std::vector<KEY> chosen_keys;
    std::vector<KEY> failed{KEY(100000, "Error")};
    std::string bitmask(K, 1);
    bitmask.resize(N, 0); // N-K trailing 0's

    std::vector<int> comb;
    // print integers and permute bitmask
    do {
        comb.clear();
        for (int i = 0; i < N; ++i) // [0..N-1] integers
        {
            if (bitmask[i]){
                comb.emplace_back(i);
            }
        }
        //do all code till next permutation

        //reserve the size
        for (auto & i : comb) {
            chosen_keys.emplace_back(bit_codes[i]);
        }

        std::string string = chosen_keys[0].bits;
        std::string helper;
        for (size_t i = 1; i < chosen_keys.size(); ++i) {
            helper = to_string(to_bitset(string) ^ to_bitset(chosen_keys[i].bits));
            string = helper;
        }
        for(auto & item: bit_codes){
            if (item.bits == string){
                return {chosen_keys, item};
            }
        }

        chosen_keys.clear();

    } while (std::prev_permutation(bitmask.begin(), bitmask.end()));

    return {failed, KEY(100000, "Error")};
}
</code>```

bitCodes = These are the numbers in a Vector in which I search for the k Numbers, where the xor of them equals 0 (KEY is a class in which bits are saved)

I use these binary Numbers:
All bitCodes:

```<code>1.  001001101100101001000100101
2.  101111001100011110101010000
3.  001111010101110001101001100
4.  111111100010110100010000001
5.  000100000011001010001110000
6.  110101111110101111011011111
7.  110111011001000010010100110
8.  111000111001000110101001011
9.  111001100011011111000110010
10. 101011001111110110101000111
11. 100000110010100011010111011
12. 101110000110011100001010101
13. 011011110010010111010001101
14. 100011101111000110100100001
15. 100001101110001110010111011
16. 011001011101011000010011110
17. 101100000110110001011110100
18. 000111111010001100010001111
19. 001111101111011100010000010
20. 001001000111111111011011001
</code>```

There are k=20 and I search n=5 numbers.

The output is:

```<code>3.  001111010101110001101001100
4.  111111100010110100010000001
6.  110101111110101111011011111
10. 101011001111110110101000111
12. 101110000110011100001010101
</code>```

...because they equal 0.

The code finished executing after about 100ms for 15504 Possibilities.

Now you can calculate yourself how long it will need to do n=100 and k=10.

答:
For k = 10, n = 100, a brute force approach isn't feasible, since there are over 17 trillion combinations:

```<code>comb(100,10) = 17310309456440
</code>```

Since the xor of two equal values is zero, my first thought was to reduce the problem to k = 5, n = 100, a bit over 75 million combinations:

```<code>comb(100,5) = 75287520
</code>```

storing each combination's xor sum, an index count (5), and 5 index values into an array of 75287520 structures. For odd k, such as k = 9, store the 3921225 combinations for k = 4, n = 100 into the array (index count = 4), followed by the 75287520 combinations for k = 5, n = 100 (index count = 5) into the array. To save space, store the number of indexes and the index values as 8 bit unsigned integers.

After creating the array of structures, sort it according to the xor sums. Scan the sorted array looking for equal xor sums (since xor of two equal values is zero), and no duplicates between the two sets of index values, which will be detected when merging the two sets of index values to create a single vector of k index values. If the goal is to find any single set that works, stop here. If the goal is to find all unique sets, use std::map using vector of k index values as the key and an 8 bit integer as the value (the value isn't used, but required by std::map). Note - std::map could consume a lot of space and time if there are a lot of unique sets that xor to zero.

Using a pseudo random number generator to create the array of 100 integers, for k = 10, n = 100, my test code found 4099 unique sets that xor to zero. On my laptop (Intel Core i7-10510U, Win 10 Pro 64 bit, Visual Studio 2019), with radix sort, it takes about 1.5 seconds total time: generate ~= 0.37 seconds, sort ~=0.88 seconds, scan ~= 0.25 seconds, using 1.7 GB of memory.  With quick sort, it take about 6.5 seconds, sort ~= 5.88 seconds, using 0.9 GB of memory

```<code>#include <algorithm>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <map>
#include <vector>

typedef unsigned char      uint8_t;
typedef unsigned short     unit16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

// N numbers xored K at a time

#define K 10
#define N 100

#define K0 (K/2)
#define K1 (K - K0)

typedef struct _SUMIDX {
    uint32_t sum;
    uint8_t cnt;
    uint8_t idx[K1];
}SUMIDX;

clock_t ctTimeBeg;                      // clock values
clock_t ctTimeMid;
clock_t ctTimeEnd;

//----------------------------------------------------------------------//
//      Comb(n,k)                                                       //
//----------------------------------------------------------------------//
static int Comb(int n, int k)
{
uint64_t dvnd = 1;
uint64_t dvsr = 1;
uint64_t quot;
    for(int i = n-k+1; i <= n; i++)
        dvnd *= i;
    for(int i = 1; i <= k; i++)
        dvsr *= i;
    quot = dvnd/dvsr;
    return (int) quot;
}

//----------------------------------------------------------------------//
//      InitCombination - init combination                              //
//----------------------------------------------------------------------//
void InitCombination(std::vector<uint8_t> &x, uint8_t n, uint8_t k) {
    for(uint8_t i = 0; i < k; i++)
        x[i] = i;
    --x[k-1];
}

//----------------------------------------------------------------------//
//      NextCombination - generate next combination                     //
//----------------------------------------------------------------------//
int NextCombination(std::vector<uint8_t> &x, uint8_t n, uint8_t k) {
uint8_t j = k - 1;
    while (j != (uint8_t)(-1) && x[j] == n - k + j)
        --j;
    if (j == (uint8_t)(-1))
        return 0;
    ++x[j];
    for (uint8_t i = j + 1; i < k; ++i)
        x[i] = x[j] + i - j;
    return 1;
}

//----------------------------------------------------------------------//
//      RadixSort                                                       //
//----------------------------------------------------------------------//
// sort a bin by 3 least significant bytes
void RadixSort3(std::vector<SUMIDX> &sumidx, std::vector<SUMIDX> &rdxsrt,
                uint32_t beg, uint32_t end)
{
uint32_t mIndex[3][256] = {0};          // count / index matrix
uint32_t i,j,m,n;
SUMIDX u;
    std::swap(sumidx, rdxsrt);          // swap vectors
    for(i = beg; i < end; i++){         // generate histograms
        u.sum = sumidx[i].sum;
        for(j = 0; j < 3; j++){
            mIndex[j][(size_t)(u.sum & 0xff)]++;
            u.sum >>= 8;
        }
    }
    for(j = 0; j < 3; j++){             // convert to indices
        m = beg;
        for(i = 0; i < 256; i++){
            n = mIndex[j][i];
            mIndex[j][i] = m;
            m += n;
        }
    }
    for(j = 0; j < 3; j++){             // radix sort
        for(i = beg; i < end; i++){     //  sort by current lsb
            u = sumidx[i];
            m = (u.sum>>(j<<3))&0xff;
            rdxsrt[mIndex[j][m]++] = u;
        }
        std::swap(sumidx, rdxsrt);      //  swap vectors
    }
}

// split vector into 256 bins according to most significant byte
void RadixSort(std::vector<SUMIDX> &sumidx, std::vector<SUMIDX> &rdxsrt)
{
uint32_t aIndex[260] = {0};             // count / array
uint32_t cnt = (uint32_t)sumidx.size();
uint32_t i;
    for(i = 0; i < cnt; i++)            // generate histogram
        aIndex[1+(sumidx[i].sum >> 24)]++;
    for(i = 2; i < 257; i++)            // convert to indices
        aIndex[i] += aIndex[i-1];
    for(i = 0; i < cnt; i++)            // sort by msb
        rdxsrt[aIndex[sumidx[i].sum>>24]++] = sumidx[i];
    for(i = 256; i; i--)                // restore aIndex
        aIndex[i] = aIndex[i-1];
    aIndex[0] = 0;
    for(i = 0; i < 256; i++)            // radix sort the 256 bins
        RadixSort3(sumidx, rdxsrt, aIndex[i], aIndex[i+1]);
}

//----------------------------------------------------------------------//
//      QuickSort                                                       //
//----------------------------------------------------------------------//
#define ISZ (24)                // use insertion sort for <= ISZ elements

void InsertionSort(std::vector<SUMIDX> &sumidx, int lo, int hi)
{
    if(lo >= hi)
        return;
    SUMIDX t;
    int i, j;
    lo--;
    for (j = lo + 2; j <= hi; j++) {
        t = sumidx[j];
        i = j-1;
        while(i != lo && sumidx[i].sum > t.sum){
            sumidx[i+1] = sumidx[i];
            i--;
        }
        sumidx[i+1] = t;
    }
}

void QuickSort(std::vector<SUMIDX> &sumidx, int lo, int hi)
{
    while (hi - lo >= ISZ){
        uint32_t p = sumidx[lo + (hi - lo) / 2].sum;
        int i = lo - 1;
        int j = hi + 1;
        while (1){
            while (sumidx[++i].sum < p);
            while (sumidx[--j].sum > p);
            if (i >= j)
                break;
            std::swap(sumidx[i], sumidx[j]);
        }
        if(j - lo < hi - j){
            QuickSort(sumidx, lo, j);
            lo = j+1;
        } else {
            QuickSort(sumidx, j+1, hi);
            hi = j;
        }
    }
    InsertionSort(sumidx, lo, hi);
}

void QuickSort(std::vector<SUMIDX> &sumidx)
{
    QuickSort(sumidx, 0, (int)sumidx.size());
}

//----------------------------------------------------------------------//
//      Rnd32 - return 32 bit random number                             //
//----------------------------------------------------------------------//
int Rnd32()
{
static unsigned int r = 0;
    r = r*1664525 + 1013904223;
    return r;
}

#define RDXSRT 1

int main(int argc, char**argv)
{
    int c, c0, c1;                          // combinations
    int sxi = 0;                            // index to sumidx
    c0 = Comb(N, K0);                       // generate # of combinations
    c1 = Comb(N, K1);
    c = c0;
    if (K0 != K1)
        c = c0 + c1;
    std::vector<SUMIDX> sumidx(c);          // vector of sums and indexes
#if RDXSRT
    std::vector<SUMIDX> rdxsrt(c);          // vector for radix sort
#endif
    std::vector<int> v(N);                  // vector of numbers
    std::vector<uint8_t> x(K);              // vector of indexes
    std::map<std::vector<uint8_t>, uint8_t> m;            // map of sets of K indexes
    std::map<std::vector<uint8_t>, uint8_t>::iterator mi; // iterator for m
    for(int i = 0; i < N; i++)
        v[i] = Rnd32();
    ctTimeBeg = clock();
    // generate vector of sums and indexes
    InitCombination(x, N, K0);
    while (NextCombination(x, N, K0)) {
        int sum = 0;
        for (int i = 0; i < K0; i++)
            sum ^= v[x[i]];
        sumidx[sxi].sum = sum;
        sumidx[sxi].cnt = K0;
        for (int i = 0; i < K0; i++)
            sumidx[sxi].idx[i] = x[i];
        sxi++;
        }
#if (K0 != K1)
    InitCombination(x, N, K1);
    while (NextCombination(x, N, K1)) {
        int sum = 0;
        for (int i = 0; i < K1; i++)
            sum ^= v[x[i]];
        sumidx[sxi].sum = sum;
        sumidx[sxi].cnt = K1;
        for (int i = 0; i < K1; i++)
            sumidx[sxi].idx[i] = x[i];
        sxi++;
    }
#endif
    ctTimeMid = clock();
    std::cout << "# of ticks " << ctTimeMid - ctTimeBeg << std::endl;
    // sort the vector according to the sums
#if RDXSRT
    RadixSort(sumidx, rdxsrt);
#else
    QuickSort(sumidx);
#endif
#if 0
    std::sort(sumidx.begin(), sumidx.end(),
        [](SUMIDX s0, SUMIDX s1)
        {return s0.sum < s1.sum;});
#endif
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    ctTimeMid = ctTimeEnd;
    // scan the sorted vector for equal sums
    for (int i = 0; i < c - 1; i++) {
        for (int j = i + 1; j < c; j++) {
            if (sumidx[i].sum != sumidx[j].sum)
                break;
#if (K0 != K1)
            if (K != (sumidx[i].cnt + sumidx[j].cnt))
                continue;
#endif
            //  merge indexes
            int ii = 0, jj = 0, im = 0;
            while (1) {
                // if duplicate indexes skip
                if (sumidx[i].idx[ii] == sumidx[j].idx[jj])
                    break;
                if (sumidx[i].idx[ii] < sumidx[j].idx[jj]) {
                    x[im++] = sumidx[i].idx[ii++];
                    if (ii >= sumidx[i].cnt) {
                        do
                            x[im++] = sumidx[j].idx[jj++];
                        while (jj < sumidx[j].cnt);
                        break;
                    }
                }
                else {
                    x[im++] = sumidx[j].idx[jj++];
                    if (jj >= sumidx[j].cnt) {
                        do
                            x[im++] = sumidx[i].idx[ii++];
                        while (ii < sumidx[i].cnt);
                        break;
                    }
                }
            }
            if (im != K)                // if duplicate indexes skip
                continue;
            m[x];                       // insert if unique set
        }
    }
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    std::cout << "# of ticks " << ctTimeEnd - ctTimeBeg << std::endl;
    std::cout << "number of combinations found " << m.size() << std::endl;
#if 1                                   // show and check what was found
    for (mi = m.begin(); mi != m.end(); mi++) {
        x = mi->first;
        for (int i = 0; i < K; i++)
            std::cout << std::setw(3) << (uint32_t) x[i] << " ";
        std::cout << std::endl;
        int sum = 0;
        for (int i = 0; i < K; i++)
           sum ^= v[x[i]];
        if (sum != 0)
            std::cout << "error" << std::endl;
    }
#endif
    return(0);
}
</code>```

The above code would work for 128 bit keys, N=111, K=11 on a system with 64GB. To reduce the amount of memory used, the code below only stores entries for N=111, K=5, and calculates xor and does a binary search for the combinations of N=111, K=6. It can run on a system with 16GB of memory. It's much slower than the above code, taking a bit less than 4 minutes on my laptop. The binary search was modified to search for the first matching entry. I did some simple tests to confirm it's working, but haven't done exhaustive test to make sure there aren't any issues.

```<code>#include <algorithm>
#include <ctime>
#include <iostream>
#include <iomanip>

typedef unsigned char      uint8_t;
typedef unsigned short     unit16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

// N numbers xored K at a time

#define K 11
#define N 111

#define K0 (K/2)
#define K1 (K - K0)

typedef struct _SUMIDX {
    uint64_t sum[2];
    uint8_t idx[K0];
}SUMIDX;

clock_t ctTimeBeg;                      // clock values
clock_t ctTimeMid;
clock_t ctTimeEnd;

//----------------------------------------------------------------------//
//      Comb(n,k)                                                       //
//----------------------------------------------------------------------//
static uint32_t Comb(uint32_t n, uint32_t k)
{
uint64_t dvnd = 1;
uint64_t dvsr = 1;
uint64_t quot;
    for(uint32_t i = n-k+1; i <= n; i++)
        dvnd *= i;
    for(uint32_t i = 1; i <= k; i++)
        dvsr *= i;
    quot = dvnd/dvsr;
    return (uint32_t) quot;
}

//----------------------------------------------------------------------//
//      InitCombination - init combination                              //
//----------------------------------------------------------------------//
void InitCombination(uint8_t x[], uint8_t n, uint8_t k) {
    for(uint8_t i = 0; i < k; i++)
        x[i] = i;
    --x[k-1];
}

//----------------------------------------------------------------------//
//      NextCombination - generate next combination                     //
//----------------------------------------------------------------------//
uint32_t NextCombination(uint8_t x[], uint8_t n, uint8_t k) {
uint8_t j = k - 1;
    while (j != (uint8_t)(-1) && x[j] == n - k + j)
        --j;
    if (j == (uint8_t)(-1))
        return 0;
    ++x[j];
    for (uint8_t i = j + 1; i < k; ++i)
        x[i] = x[j] + i - j;
    return 1;
}

//----------------------------------------------------------------------//
//      RadixSort                                                       //
//----------------------------------------------------------------------//
// sort a bin by 15 least significant bytes
void RadixSort7(SUMIDX sumidx[], SUMIDX rdxsrt[],
                uint32_t beg, uint32_t end)
{
uint32_t mIndex[15][256] = {0};         // count / index matrix
uint32_t i,j,m,n;
SUMIDX u;
    std::swap(sumidx, rdxsrt);          // swap array pointers
    for(i = beg; i < end; i++){         // generate histograms
        u.sum[0] = sumidx[i].sum[0];
        for(j = 0; j < 8; j++){
            mIndex[j][(size_t)(u.sum[0] & 0xff)]++;
            u.sum[0] >>= 8;
        }
        u.sum[1] = sumidx[i].sum[1];
        for(j = 8; j < 15; j++){
            mIndex[j][(size_t)(u.sum[1] & 0xff)]++;
            u.sum[1] >>= 8;
        }
    }
    for(j = 0; j < 15; j++){            // convert to indices
        m = beg;
        for(i = 0; i < 256; i++){
            n = mIndex[j][i];
            mIndex[j][i] = m;
            m += n;
        }
    }
    for(j = 0; j < 8; j++){             // radix sort
        for(i = beg; i < end; i++){     //  sort by current lsb
            u = sumidx[i];
            m = (u.sum[0]>>(j<<3))&0xff;
            rdxsrt[mIndex[j][m]++] = u;
        }
        std::swap(sumidx, rdxsrt);      //  swap array pointers
    }
    for (j = 0; j < 7; j++) {           // radix sort
        for(i = beg; i < end; i++){     //  sort by current lsb
            u = sumidx[i];
            m = (u.sum[1]>>(j<<3))&0xff;
            rdxsrt[mIndex[8+j][m]++] = u;
        }
        std::swap(sumidx, rdxsrt);      //  swap array pointers
    }
}

// split vector into 256 bins according to most significant byte
void RadixSort(SUMIDX sumidx[], SUMIDX rdxsrt[], uint32_t cnt)
{
uint32_t aIndex[260] = {0};             // count / array
uint32_t i;
    for(i = 0; i < cnt; i++)            // generate histogram
        aIndex[1+(sumidx[i].sum[1] >> 56)]++;
    for(i = 2; i < 257; i++)            // convert to indices
        aIndex[i] += aIndex[i-1];
    for(i = 0; i < cnt; i++)            // sort by msb
        rdxsrt[aIndex[sumidx[i].sum[1] >>56]++] = sumidx[i];
    for(i = 256; i; i--)                // restore aIndex
        aIndex[i] = aIndex[i-1];
    aIndex[0] = 0;
    for(i = 0; i < 256; i++)            // radix sort the 256 bins
        RadixSort7(sumidx, rdxsrt, aIndex[i], aIndex[i+1]);
}

//----------------------------------------------------------------------//
//      BinSrc  return index to first match                             //
//----------------------------------------------------------------------//
uint32_t BinSrc(SUMIDX sumidx[], uint64_t x[2], uint32_t cnt)
{
uint32_t lo = 0;
uint32_t hi = cnt;
uint32_t i;
    while((hi - lo) > 1){               // find a match
        i = (lo + hi)/2;
        if((x[1] <  sumidx[i].sum[1]) ||
           (x[1] == sumidx[i].sum[1]) &&
           (x[0] <  sumidx[i].sum[0])){
            hi = i;
            continue;
        }
        if((x[1] >  sumidx[i].sum[1]) ||
           (x[1] == sumidx[i].sum[1]) &&
           (x[0] >  sumidx[i].sum[0])){
            lo = i;
            continue;
        }
        break;
    }
    hi = i;                             // find first match
    while (hi != lo) {
        i = (lo + hi) / 2;
        if ((x[1] == sumidx[i].sum[1]) &&
            (x[0] == sumidx[i].sum[0])) {
            hi = i;
            continue;
        }
        if ((x[1] >  sumidx[i].sum[1]) ||
            (x[1] == sumidx[i].sum[1]) &&
            (x[0] >  sumidx[i].sum[0])) {
            lo = i+1;
            continue;
        }
        break;
    }
    if((x[1] == sumidx[lo].sum[1]) &&
       (x[0] == sumidx[lo].sum[0]))
        return lo;
    return uint32_t(0-1);
}

//----------------------------------------------------------------------//
//      Rnd64 - return 64 bit random number                             //
//----------------------------------------------------------------------//
uint64_t Rnd64()                        // random 64 bit integer
{
static uint64_t r = 1ull;
    r = r * 6364136223846793005ull + 1442695040888963407ull;
    return r;
}

//----------------------------------------------------------------------//
//      Rnd32 - return 32 bit random number                             //
//----------------------------------------------------------------------//
uint32_t Rnd32()
{
static uint32_t r = 0;
    r = r*1664525 + 1013904223;
    return r;
}

int main(int argc, char**argv)
{
    uint64_t sum[2];                        // 128 bit key
    uint32_t c0;                            // combinations(N, K0)
    uint32_t xi;                            // index to sumidx
    uint32_t i, ii, jj, im;
    c0 = Comb(N, K0);                       // generate # of combinations
    SUMIDX *sumidx = new SUMIDX[c0];        // array of xors + indexes
    SUMIDX *rdxsrt = new SUMIDX[c0];        // array for radix sort
    uint64_t v[N][2];
    uint8_t x[K1];
    uint8_t m[K];
    for(i = 0; i < N; i++){
      v[i][0] = Rnd64()&0x000000000000ffffull;
      v[i][1] = Rnd64()&0xffffffff00000000ull;
    }
    ctTimeBeg = clock();
    // generate array of xors and indexes
    xi = 0;
    InitCombination(x, N, K0);
    while (NextCombination(x, N, K0)) {
        sum[1] = sum[0] = 0;
        for (i = 0; i < K0; i++){
            sum[0] ^= v[x[i]][0];
            sum[1] ^= v[x[i]][1];
        }
        sumidx[xi].sum[0] = sum[0];
        sumidx[xi].sum[1] = sum[1];
        for (i = 0; i < K0; i++)
            sumidx[xi].idx[i] = x[i];
        xi++;
        }
    ctTimeMid = clock();
    std::cout << "# of ticks " << ctTimeMid - ctTimeBeg << std::endl;
    // sort the vector according to the sums
    RadixSort(sumidx, rdxsrt, c0);
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    ctTimeMid = ctTimeEnd;
    // scan the sorted vector for equal xors
    InitCombination(x, N, K1);
#if 0
    uint32_t z = K1;
#endif
    while (NextCombination(x, N, K1)) {
#if 0
        if (z != x[1]) {
            z = x[1];
            for (i = 0; i < K1; i++)
                std::cout << std::setw(3) << (uint32_t)x[i] << " ";
            std::cout << std::endl;
        }
#endif
        sum[1] = sum[0] = 0;
        for (i = 0; i < K1; i++){
            sum[0] ^= v[x[i]][0];
            sum[1] ^= v[x[i]][1];
        }
        i = BinSrc(sumidx, sum, c0);
        if(i == uint32_t(0-1))
            continue;
        while((sum[0] == sumidx[i].sum[0]) &&
              (sum[1] == sumidx[i].sum[1])){
            //  merge indexes
            ii = jj = im = 0;
            while (1) {
                // if duplicate indexes skip
                if (sumidx[i].idx[ii] == x[jj])
                    break;
                if (sumidx[i].idx[ii] <  x[jj]) {
                    m[im++] = sumidx[i].idx[ii++];
                    if (ii >= K0) {
                        do
                            m[im++] =x[jj++];
                        while (jj < K1);
                        break;
                    }
                }
                else {
                    m[im++] = x[jj++];
                    if (jj >= K1) {
                        do
                            m[im++] = sumidx[i].idx[ii++];
                        while (ii < K0);
                        break;
                    }
                }
            }
            if (im == K)                // if not duplicate indexes stop
                goto found0;
            i++;
        }
    }
found0:
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    std::cout << "# of ticks " << ctTimeEnd - ctTimeBeg << std::endl;
    if(im != K){
        std::cout << "not found" << std::endl;
        goto exit0;
    }
    for (i = 0; i < K; i++)
        std::cout << std::setw(3) << (uint32_t)m[i] << " ";
    std::cout << std::endl;
    sum[1] = sum[0] = 0;
    for (i = 0; i < K; i++){
        sum[0] ^= v[m[i]][0];
        sum[1] ^= v[m[i]][1];
    }
    if (sum[0] != 0 || sum[1] != 0)
        std::cout << "error" << std::endl;
exit0:
    delete rdxsrt;
    delete sumidx;
    return(0);
}
</code>```

Body:
My Problem is to find k Numbers in e.g. an Vector/Array with n Numbers, which equal calculated with xor 0. I tried already to brutforce all combinations without repetition, but with n=100 and k=10 the Time Complexity is to high. (about 1.7*10^13 possibilities)

Does anyone have any ideas, to speed up the process of finding the k Numbers in an Array with n Numbers?

I think my approach is not the smartest with such a high number of possibilities, but I really do not know how to make my program faster.

I would appreciate suggestions for a solution.

My program is in C++.

SOLUTION comb(int N, int K, const std::vector<KEY>& bit_codes)
{
    std::vector<KEY> chosen_keys;
    std::vector<KEY> failed{KEY(100000, "Error")};
    std::string bitmask(K, 1);
    bitmask.resize(N, 0); // N-K trailing 0's

    std::vector<int> comb;
    // print integers and permute bitmask
    do {
        comb.clear();
        for (int i = 0; i < N; ++i) // [0..N-1] integers
        {
            if (bitmask[i]){
                comb.emplace_back(i);
            }
        }
        //do all code till next permutation

        //reserve the size
        for (auto & i : comb) {
            chosen_keys.emplace_back(bit_codes[i]);
        }

        std::string string = chosen_keys[0].bits;
        std::string helper;
        for (size_t i = 1; i < chosen_keys.size(); ++i) {
            helper = to_string(to_bitset(string) ^ to_bitset(chosen_keys[i].bits));
            string = helper;
        }
        for(auto & item: bit_codes){
            if (item.bits == string){
                return {chosen_keys, item};
            }
        }

        chosen_keys.clear();

    } while (std::prev_permutation(bitmask.begin(), bitmask.end()));

    return {failed, KEY(100000, "Error")};
}

bitCodes = These are the numbers in a Vector in which I search for the k Numbers, where the xor of them equals 0 (KEY is a class in which bits are saved)

I use these binary Numbers:
All bitCodes:

1.  001001101100101001000100101
2.  101111001100011110101010000
3.  001111010101110001101001100
4.  111111100010110100010000001
5.  000100000011001010001110000
6.  110101111110101111011011111
7.  110111011001000010010100110
8.  111000111001000110101001011
9.  111001100011011111000110010
10. 101011001111110110101000111
11. 100000110010100011010111011
12. 101110000110011100001010101
13. 011011110010010111010001101
14. 100011101111000110100100001
15. 100001101110001110010111011
16. 011001011101011000010011110
17. 101100000110110001011110100
18. 000111111010001100010001111
19. 001111101111011100010000010
20. 001001000111111111011011001

There are k=20 and I search n=5 numbers.

The output is:

3.  001111010101110001101001100
4.  111111100010110100010000001
6.  110101111110101111011011111
10. 101011001111110110101000111
12. 101110000110011100001010101

...because they equal 0.

The code finished executing after about 100ms for 15504 Possibilities.

Now you can calculate yourself how long it will need to do n=100 and k=10.

Body:
For k = 10, n = 100, a brute force approach isn't feasible, since there are over 17 trillion combinations:

comb(100,10) = 17310309456440

Since the xor of two equal values is zero, my first thought was to reduce the problem to k = 5, n = 100, a bit over 75 million combinations:

comb(100,5) = 75287520

storing each combination's xor sum, an index count (5), and 5 index values into an array of 75287520 structures. For odd k, such as k = 9, store the 3921225 combinations for k = 4, n = 100 into the array (index count = 4), followed by the 75287520 combinations for k = 5, n = 100 (index count = 5) into the array. To save space, store the number of indexes and the index values as 8 bit unsigned integers.

After creating the array of structures, sort it according to the xor sums. Scan the sorted array looking for equal xor sums (since xor of two equal values is zero), and no duplicates between the two sets of index values, which will be detected when merging the two sets of index values to create a single vector of k index values. If the goal is to find any single set that works, stop here. If the goal is to find all unique sets, use std::map using vector of k index values as the key and an 8 bit integer as the value (the value isn't used, but required by std::map). Note - std::map could consume a lot of space and time if there are a lot of unique sets that xor to zero.

Using a pseudo random number generator to create the array of 100 integers, for k = 10, n = 100, my test code found 4099 unique sets that xor to zero. On my laptop (Intel Core i7-10510U, Win 10 Pro 64 bit, Visual Studio 2019), with radix sort, it takes about 1.5 seconds total time: generate ~= 0.37 seconds, sort ~=0.88 seconds, scan ~= 0.25 seconds, using 1.7 GB of memory.  With quick sort, it take about 6.5 seconds, sort ~= 5.88 seconds, using 0.9 GB of memory

#include <algorithm>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <map>
#include <vector>

typedef unsigned char      uint8_t;
typedef unsigned short     unit16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

// N numbers xored K at a time

#define K 10
#define N 100

#define K0 (K/2)
#define K1 (K - K0)

typedef struct _SUMIDX {
    uint32_t sum;
    uint8_t cnt;
    uint8_t idx[K1];
}SUMIDX;

clock_t ctTimeBeg;                      // clock values
clock_t ctTimeMid;
clock_t ctTimeEnd;

//----------------------------------------------------------------------//
//      Comb(n,k)                                                       //
//----------------------------------------------------------------------//
static int Comb(int n, int k)
{
uint64_t dvnd = 1;
uint64_t dvsr = 1;
uint64_t quot;
    for(int i = n-k+1; i <= n; i++)
        dvnd *= i;
    for(int i = 1; i <= k; i++)
        dvsr *= i;
    quot = dvnd/dvsr;
    return (int) quot;
}

//----------------------------------------------------------------------//
//      InitCombination - init combination                              //
//----------------------------------------------------------------------//
void InitCombination(std::vector<uint8_t> &x, uint8_t n, uint8_t k) {
    for(uint8_t i = 0; i < k; i++)
        x[i] = i;
    --x[k-1];
}

//----------------------------------------------------------------------//
//      NextCombination - generate next combination                     //
//----------------------------------------------------------------------//
int NextCombination(std::vector<uint8_t> &x, uint8_t n, uint8_t k) {
uint8_t j = k - 1;
    while (j != (uint8_t)(-1) && x[j] == n - k + j)
        --j;
    if (j == (uint8_t)(-1))
        return 0;
    ++x[j];
    for (uint8_t i = j + 1; i < k; ++i)
        x[i] = x[j] + i - j;
    return 1;
}

//----------------------------------------------------------------------//
//      RadixSort                                                       //
//----------------------------------------------------------------------//
// sort a bin by 3 least significant bytes
void RadixSort3(std::vector<SUMIDX> &sumidx, std::vector<SUMIDX> &rdxsrt,
                uint32_t beg, uint32_t end)
{
uint32_t mIndex[3][256] = {0};          // count / index matrix
uint32_t i,j,m,n;
SUMIDX u;
    std::swap(sumidx, rdxsrt);          // swap vectors
    for(i = beg; i < end; i++){         // generate histograms
        u.sum = sumidx[i].sum;
        for(j = 0; j < 3; j++){
            mIndex[j][(size_t)(u.sum & 0xff)]++;
            u.sum >>= 8;
        }
    }
    for(j = 0; j < 3; j++){             // convert to indices
        m = beg;
        for(i = 0; i < 256; i++){
            n = mIndex[j][i];
            mIndex[j][i] = m;
            m += n;
        }
    }
    for(j = 0; j < 3; j++){             // radix sort
        for(i = beg; i < end; i++){     //  sort by current lsb
            u = sumidx[i];
            m = (u.sum>>(j<<3))&0xff;
            rdxsrt[mIndex[j][m]++] = u;
        }
        std::swap(sumidx, rdxsrt);      //  swap vectors
    }
}

// split vector into 256 bins according to most significant byte
void RadixSort(std::vector<SUMIDX> &sumidx, std::vector<SUMIDX> &rdxsrt)
{
uint32_t aIndex[260] = {0};             // count / array
uint32_t cnt = (uint32_t)sumidx.size();
uint32_t i;
    for(i = 0; i < cnt; i++)            // generate histogram
        aIndex[1+(sumidx[i].sum >> 24)]++;
    for(i = 2; i < 257; i++)            // convert to indices
        aIndex[i] += aIndex[i-1];
    for(i = 0; i < cnt; i++)            // sort by msb
        rdxsrt[aIndex[sumidx[i].sum>>24]++] = sumidx[i];
    for(i = 256; i; i--)                // restore aIndex
        aIndex[i] = aIndex[i-1];
    aIndex[0] = 0;
    for(i = 0; i < 256; i++)            // radix sort the 256 bins
        RadixSort3(sumidx, rdxsrt, aIndex[i], aIndex[i+1]);
}

//----------------------------------------------------------------------//
//      QuickSort                                                       //
//----------------------------------------------------------------------//
#define ISZ (24)                // use insertion sort for <= ISZ elements

void InsertionSort(std::vector<SUMIDX> &sumidx, int lo, int hi)
{
    if(lo >= hi)
        return;
    SUMIDX t;
    int i, j;
    lo--;
    for (j = lo + 2; j <= hi; j++) {
        t = sumidx[j];
        i = j-1;
        while(i != lo && sumidx[i].sum > t.sum){
            sumidx[i+1] = sumidx[i];
            i--;
        }
        sumidx[i+1] = t;
    }
}

void QuickSort(std::vector<SUMIDX> &sumidx, int lo, int hi)
{
    while (hi - lo >= ISZ){
        uint32_t p = sumidx[lo + (hi - lo) / 2].sum;
        int i = lo - 1;
        int j = hi + 1;
        while (1){
            while (sumidx[++i].sum < p);
            while (sumidx[--j].sum > p);
            if (i >= j)
                break;
            std::swap(sumidx[i], sumidx[j]);
        }
        if(j - lo < hi - j){
            QuickSort(sumidx, lo, j);
            lo = j+1;
        } else {
            QuickSort(sumidx, j+1, hi);
            hi = j;
        }
    }
    InsertionSort(sumidx, lo, hi);
}

void QuickSort(std::vector<SUMIDX> &sumidx)
{
    QuickSort(sumidx, 0, (int)sumidx.size());
}

//----------------------------------------------------------------------//
//      Rnd32 - return 32 bit random number                             //
//----------------------------------------------------------------------//
int Rnd32()
{
static unsigned int r = 0;
    r = r*1664525 + 1013904223;
    return r;
}

#define RDXSRT 1

int main(int argc, char**argv)
{
    int c, c0, c1;                          // combinations
    int sxi = 0;                            // index to sumidx
    c0 = Comb(N, K0);                       // generate # of combinations
    c1 = Comb(N, K1);
    c = c0;
    if (K0 != K1)
        c = c0 + c1;
    std::vector<SUMIDX> sumidx(c);          // vector of sums and indexes
#if RDXSRT
    std::vector<SUMIDX> rdxsrt(c);          // vector for radix sort
#endif
    std::vector<int> v(N);                  // vector of numbers
    std::vector<uint8_t> x(K);              // vector of indexes
    std::map<std::vector<uint8_t>, uint8_t> m;            // map of sets of K indexes
    std::map<std::vector<uint8_t>, uint8_t>::iterator mi; // iterator for m
    for(int i = 0; i < N; i++)
        v[i] = Rnd32();
    ctTimeBeg = clock();
    // generate vector of sums and indexes
    InitCombination(x, N, K0);
    while (NextCombination(x, N, K0)) {
        int sum = 0;
        for (int i = 0; i < K0; i++)
            sum ^= v[x[i]];
        sumidx[sxi].sum = sum;
        sumidx[sxi].cnt = K0;
        for (int i = 0; i < K0; i++)
            sumidx[sxi].idx[i] = x[i];
        sxi++;
        }
#if (K0 != K1)
    InitCombination(x, N, K1);
    while (NextCombination(x, N, K1)) {
        int sum = 0;
        for (int i = 0; i < K1; i++)
            sum ^= v[x[i]];
        sumidx[sxi].sum = sum;
        sumidx[sxi].cnt = K1;
        for (int i = 0; i < K1; i++)
            sumidx[sxi].idx[i] = x[i];
        sxi++;
    }
#endif
    ctTimeMid = clock();
    std::cout << "# of ticks " << ctTimeMid - ctTimeBeg << std::endl;
    // sort the vector according to the sums
#if RDXSRT
    RadixSort(sumidx, rdxsrt);
#else
    QuickSort(sumidx);
#endif
#if 0
    std::sort(sumidx.begin(), sumidx.end(),
        [](SUMIDX s0, SUMIDX s1)
        {return s0.sum < s1.sum;});
#endif
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    ctTimeMid = ctTimeEnd;
    // scan the sorted vector for equal sums
    for (int i = 0; i < c - 1; i++) {
        for (int j = i + 1; j < c; j++) {
            if (sumidx[i].sum != sumidx[j].sum)
                break;
#if (K0 != K1)
            if (K != (sumidx[i].cnt + sumidx[j].cnt))
                continue;
#endif
            //  merge indexes
            int ii = 0, jj = 0, im = 0;
            while (1) {
                // if duplicate indexes skip
                if (sumidx[i].idx[ii] == sumidx[j].idx[jj])
                    break;
                if (sumidx[i].idx[ii] < sumidx[j].idx[jj]) {
                    x[im++] = sumidx[i].idx[ii++];
                    if (ii >= sumidx[i].cnt) {
                        do
                            x[im++] = sumidx[j].idx[jj++];
                        while (jj < sumidx[j].cnt);
                        break;
                    }
                }
                else {
                    x[im++] = sumidx[j].idx[jj++];
                    if (jj >= sumidx[j].cnt) {
                        do
                            x[im++] = sumidx[i].idx[ii++];
                        while (ii < sumidx[i].cnt);
                        break;
                    }
                }
            }
            if (im != K)                // if duplicate indexes skip
                continue;
            m[x];                       // insert if unique set
        }
    }
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    std::cout << "# of ticks " << ctTimeEnd - ctTimeBeg << std::endl;
    std::cout << "number of combinations found " << m.size() << std::endl;
#if 1                                   // show and check what was found
    for (mi = m.begin(); mi != m.end(); mi++) {
        x = mi->first;
        for (int i = 0; i < K; i++)
            std::cout << std::setw(3) << (uint32_t) x[i] << " ";
        std::cout << std::endl;
        int sum = 0;
        for (int i = 0; i < K; i++)
           sum ^= v[x[i]];
        if (sum != 0)
            std::cout << "error" << std::endl;
    }
#endif
    return(0);
}

The above code would work for 128 bit keys, N=111, K=11 on a system with 64GB. To reduce the amount of memory used, the code below only stores entries for N=111, K=5, and calculates xor and does a binary search for the combinations of N=111, K=6. It can run on a system with 16GB of memory. It's much slower than the above code, taking a bit less than 4 minutes on my laptop. The binary search was modified to search for the first matching entry. I did some simple tests to confirm it's working, but haven't done exhaustive test to make sure there aren't any issues.

#include <algorithm>
#include <ctime>
#include <iostream>
#include <iomanip>

typedef unsigned char      uint8_t;
typedef unsigned short     unit16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

// N numbers xored K at a time

#define K 11
#define N 111

#define K0 (K/2)
#define K1 (K - K0)

typedef struct _SUMIDX {
    uint64_t sum[2];
    uint8_t idx[K0];
}SUMIDX;

clock_t ctTimeBeg;                      // clock values
clock_t ctTimeMid;
clock_t ctTimeEnd;

//----------------------------------------------------------------------//
//      Comb(n,k)                                                       //
//----------------------------------------------------------------------//
static uint32_t Comb(uint32_t n, uint32_t k)
{
uint64_t dvnd = 1;
uint64_t dvsr = 1;
uint64_t quot;
    for(uint32_t i = n-k+1; i <= n; i++)
        dvnd *= i;
    for(uint32_t i = 1; i <= k; i++)
        dvsr *= i;
    quot = dvnd/dvsr;
    return (uint32_t) quot;
}

//----------------------------------------------------------------------//
//      InitCombination - init combination                              //
//----------------------------------------------------------------------//
void InitCombination(uint8_t x[], uint8_t n, uint8_t k) {
    for(uint8_t i = 0; i < k; i++)
        x[i] = i;
    --x[k-1];
}

//----------------------------------------------------------------------//
//      NextCombination - generate next combination                     //
//----------------------------------------------------------------------//
uint32_t NextCombination(uint8_t x[], uint8_t n, uint8_t k) {
uint8_t j = k - 1;
    while (j != (uint8_t)(-1) && x[j] == n - k + j)
        --j;
    if (j == (uint8_t)(-1))
        return 0;
    ++x[j];
    for (uint8_t i = j + 1; i < k; ++i)
        x[i] = x[j] + i - j;
    return 1;
}

//----------------------------------------------------------------------//
//      RadixSort                                                       //
//----------------------------------------------------------------------//
// sort a bin by 15 least significant bytes
void RadixSort7(SUMIDX sumidx[], SUMIDX rdxsrt[],
                uint32_t beg, uint32_t end)
{
uint32_t mIndex[15][256] = {0};         // count / index matrix
uint32_t i,j,m,n;
SUMIDX u;
    std::swap(sumidx, rdxsrt);          // swap array pointers
    for(i = beg; i < end; i++){         // generate histograms
        u.sum[0] = sumidx[i].sum[0];
        for(j = 0; j < 8; j++){
            mIndex[j][(size_t)(u.sum[0] & 0xff)]++;
            u.sum[0] >>= 8;
        }
        u.sum[1] = sumidx[i].sum[1];
        for(j = 8; j < 15; j++){
            mIndex[j][(size_t)(u.sum[1] & 0xff)]++;
            u.sum[1] >>= 8;
        }
    }
    for(j = 0; j < 15; j++){            // convert to indices
        m = beg;
        for(i = 0; i < 256; i++){
            n = mIndex[j][i];
            mIndex[j][i] = m;
            m += n;
        }
    }
    for(j = 0; j < 8; j++){             // radix sort
        for(i = beg; i < end; i++){     //  sort by current lsb
            u = sumidx[i];
            m = (u.sum[0]>>(j<<3))&0xff;
            rdxsrt[mIndex[j][m]++] = u;
        }
        std::swap(sumidx, rdxsrt);      //  swap array pointers
    }
    for (j = 0; j < 7; j++) {           // radix sort
        for(i = beg; i < end; i++){     //  sort by current lsb
            u = sumidx[i];
            m = (u.sum[1]>>(j<<3))&0xff;
            rdxsrt[mIndex[8+j][m]++] = u;
        }
        std::swap(sumidx, rdxsrt);      //  swap array pointers
    }
}

// split vector into 256 bins according to most significant byte
void RadixSort(SUMIDX sumidx[], SUMIDX rdxsrt[], uint32_t cnt)
{
uint32_t aIndex[260] = {0};             // count / array
uint32_t i;
    for(i = 0; i < cnt; i++)            // generate histogram
        aIndex[1+(sumidx[i].sum[1] >> 56)]++;
    for(i = 2; i < 257; i++)            // convert to indices
        aIndex[i] += aIndex[i-1];
    for(i = 0; i < cnt; i++)            // sort by msb
        rdxsrt[aIndex[sumidx[i].sum[1] >>56]++] = sumidx[i];
    for(i = 256; i; i--)                // restore aIndex
        aIndex[i] = aIndex[i-1];
    aIndex[0] = 0;
    for(i = 0; i < 256; i++)            // radix sort the 256 bins
        RadixSort7(sumidx, rdxsrt, aIndex[i], aIndex[i+1]);
}

//----------------------------------------------------------------------//
//      BinSrc  return index to first match                             //
//----------------------------------------------------------------------//
uint32_t BinSrc(SUMIDX sumidx[], uint64_t x[2], uint32_t cnt)
{
uint32_t lo = 0;
uint32_t hi = cnt;
uint32_t i;
    while((hi - lo) > 1){               // find a match
        i = (lo + hi)/2;
        if((x[1] <  sumidx[i].sum[1]) ||
           (x[1] == sumidx[i].sum[1]) &&
           (x[0] <  sumidx[i].sum[0])){
            hi = i;
            continue;
        }
        if((x[1] >  sumidx[i].sum[1]) ||
           (x[1] == sumidx[i].sum[1]) &&
           (x[0] >  sumidx[i].sum[0])){
            lo = i;
            continue;
        }
        break;
    }
    hi = i;                             // find first match
    while (hi != lo) {
        i = (lo + hi) / 2;
        if ((x[1] == sumidx[i].sum[1]) &&
            (x[0] == sumidx[i].sum[0])) {
            hi = i;
            continue;
        }
        if ((x[1] >  sumidx[i].sum[1]) ||
            (x[1] == sumidx[i].sum[1]) &&
            (x[0] >  sumidx[i].sum[0])) {
            lo = i+1;
            continue;
        }
        break;
    }
    if((x[1] == sumidx[lo].sum[1]) &&
       (x[0] == sumidx[lo].sum[0]))
        return lo;
    return uint32_t(0-1);
}

//----------------------------------------------------------------------//
//      Rnd64 - return 64 bit random number                             //
//----------------------------------------------------------------------//
uint64_t Rnd64()                        // random 64 bit integer
{
static uint64_t r = 1ull;
    r = r * 6364136223846793005ull + 1442695040888963407ull;
    return r;
}

//----------------------------------------------------------------------//
//      Rnd32 - return 32 bit random number                             //
//----------------------------------------------------------------------//
uint32_t Rnd32()
{
static uint32_t r = 0;
    r = r*1664525 + 1013904223;
    return r;
}

int main(int argc, char**argv)
{
    uint64_t sum[2];                        // 128 bit key
    uint32_t c0;                            // combinations(N, K0)
    uint32_t xi;                            // index to sumidx
    uint32_t i, ii, jj, im;
    c0 = Comb(N, K0);                       // generate # of combinations
    SUMIDX *sumidx = new SUMIDX[c0];        // array of xors + indexes
    SUMIDX *rdxsrt = new SUMIDX[c0];        // array for radix sort
    uint64_t v[N][2];
    uint8_t x[K1];
    uint8_t m[K];
    for(i = 0; i < N; i++){
      v[i][0] = Rnd64()&0x000000000000ffffull;
      v[i][1] = Rnd64()&0xffffffff00000000ull;
    }
    ctTimeBeg = clock();
    // generate array of xors and indexes
    xi = 0;
    InitCombination(x, N, K0);
    while (NextCombination(x, N, K0)) {
        sum[1] = sum[0] = 0;
        for (i = 0; i < K0; i++){
            sum[0] ^= v[x[i]][0];
            sum[1] ^= v[x[i]][1];
        }
        sumidx[xi].sum[0] = sum[0];
        sumidx[xi].sum[1] = sum[1];
        for (i = 0; i < K0; i++)
            sumidx[xi].idx[i] = x[i];
        xi++;
        }
    ctTimeMid = clock();
    std::cout << "# of ticks " << ctTimeMid - ctTimeBeg << std::endl;
    // sort the vector according to the sums
    RadixSort(sumidx, rdxsrt, c0);
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    ctTimeMid = ctTimeEnd;
    // scan the sorted vector for equal xors
    InitCombination(x, N, K1);
#if 0
    uint32_t z = K1;
#endif
    while (NextCombination(x, N, K1)) {
#if 0
        if (z != x[1]) {
            z = x[1];
            for (i = 0; i < K1; i++)
                std::cout << std::setw(3) << (uint32_t)x[i] << " ";
            std::cout << std::endl;
        }
#endif
        sum[1] = sum[0] = 0;
        for (i = 0; i < K1; i++){
            sum[0] ^= v[x[i]][0];
            sum[1] ^= v[x[i]][1];
        }
        i = BinSrc(sumidx, sum, c0);
        if(i == uint32_t(0-1))
            continue;
        while((sum[0] == sumidx[i].sum[0]) &&
              (sum[1] == sumidx[i].sum[1])){
            //  merge indexes
            ii = jj = im = 0;
            while (1) {
                // if duplicate indexes skip
                if (sumidx[i].idx[ii] == x[jj])
                    break;
                if (sumidx[i].idx[ii] <  x[jj]) {
                    m[im++] = sumidx[i].idx[ii++];
                    if (ii >= K0) {
                        do
                            m[im++] =x[jj++];
                        while (jj < K1);
                        break;
                    }
                }
                else {
                    m[im++] = x[jj++];
                    if (jj >= K1) {
                        do
                            m[im++] = sumidx[i].idx[ii++];
                        while (ii < K0);
                        break;
                    }
                }
            }
            if (im == K)                // if not duplicate indexes stop
                goto found0;
            i++;
        }
    }
found0:
    ctTimeEnd = clock();
    std::cout << "# of ticks " << ctTimeEnd - ctTimeMid << std::endl;
    std::cout << "# of ticks " << ctTimeEnd - ctTimeBeg << std::endl;
    if(im != K){
        std::cout << "not found" << std::endl;
        goto exit0;
    }
    for (i = 0; i < K; i++)
        std::cout << std::setw(3) << (uint32_t)m[i] << " ";
    std::cout << std::endl;
    sum[1] = sum[0] = 0;
    for (i = 0; i < K; i++){
        sum[0] ^= v[m[i]][0];
        sum[1] ^= v[m[i]][1];
    }
    if (sum[0] != 0 || sum[1] != 0)
        std::cout << "error" << std::endl;
exit0:
    delete rdxsrt;
    delete sumidx;
    return(0);
}