Lists
#include <vector> void re_arrange(std::vector<int>& data) { std::sort(data.begin(), data.end(), [](int x, int y) { return std::make_pair(x % 2 != 0, x) < std::make_pair(y % 2 != 0, y); }); }
- #include <vector>
- void re_arrange(std::vector<int>& data) {
auto it = std::partition(data.begin(), data.end(), [](int x) { return x % 2 == 0; });std::sort(data.begin(), it);std::sort(it, data.end());- std::sort(data.begin(), data.end(), [](int x, int y) { return std::make_pair(x % 2 != 0, x) < std::make_pair(y % 2 != 0, y); });
- }
Fundamentals
import random as r class Dice: def __init__(self, faces): self.faces = faces def roll(self): return r.choice(self.faces) dice = Dice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]) d = dice.roll
- import random as r
- class Dice:
- def __init__(self, faces):
- self.faces = faces
- def roll(self):
- return r.choice(self.faces)
- dice = Dice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])
d = lambda :dice.roll()- d = dice.roll