By default, Sabre does not return the cheapest results. It returns some sort of different price categories. How can I get the cheapest N (20, 50, 100, ...) prices?
This is my code:
"TPA_Extensions": {
"IntelliSellTransaction": {
"RequestType": {
"Name": "20ITINS"
}
}
},
Related
I am learning Rust and came upon a problem that I can easily solve by using nested loops with conditions. Unfortunately I fail miserably when trying to rewrite it using more idiomatic rust by the use of iterators and and things like fold, filter and flatten.
I have a vector of vectors of structs. Each struct has an identifier and a value. For each possible identifier I want to find the maximum value and return everything in a new vec of max values. The code below works fine.
struct MyStruct {
id: usize,
value: usize,
}
fn main() {
let vecvec_of_structs = vec![
vec![
MyStruct { id: 2, value: 1 },
MyStruct { id: 1, value: 15 },
MyStruct { id: 0, value: 31 },
],
vec![
MyStruct { id: 3, value: 10 },
MyStruct { id: 4, value: 25 },
MyStruct { id: 0, value: 150 },
MyStruct { id: 2, value: 150 },
],
];
let groups = 5;
let mut max_values_by_id: Vec<usize> = vec![0; groups];
// iterate over group_ids, in structs with respective group_id to find max value associated with it.
for id in 0..groups {
for vec_of_structs in &vecvec_of_structs {
for s in vec_of_structs {
if s.id == id {
if max_values_by_id[id] < s.value {
max_values_by_id[id] = s.value
};
}
}
}
}
println!("{:?}", max_values_by_id);
}
Now I tried to rewrite it like the piece below, that I am stuck with and which doesn't work. I don't know how to combine the different pieces. Or maybe they are not supposed to fit together in the first place.
let max_delay: Vec<usize> = max_values_by_node
.iter()
.enumerate()
.fold(0, |max_value, i| {
&vecvec_of_structs
.into_iter()
.flatten()
.filter(|e| e.id == i)
.max_by_key(|e| e.value)
.unwrap()
.value
})
.collect();
I would do something like this.
I start from the end: we want to collect five numbers.
For each of them considered as an id, we have have to iterate over all the structs: map() + iter() + flatten()
For each struct, we are only interested in the specific id, then we get its value: filter_map()
These values, if any, have to be folded.
let max_delay: Vec<usize> = (0..5)
.map(|i| {
vecvec_of_structs
.iter()
.flatten()
.filter_map(|s| if s.id == i { Some(s.value) } else { None })
.fold(0, |acc, value| acc.max(value))
})
.collect();
for (Node &i : myNodes){
if (CheckCollisionPointCircle(Vector2{ (float)(GetMouseX()),(float)(GetMouseY()) }, Vector2{ (float)(i.X),(float)(i.Y) }, i.radient)) {
auto index = std::find(myNodes.begin(), myNodes.end(), i);
myNodes.erase(index);
}
}
trying to remove a Node from vector of nodes if the CheckCollisionPointCircle() returns true
for (auto iter = myNodes.begin(); iter != myNodes.end();) {
if (CheckCollisionPointCircle(Vector2{ (float)(GetMouseX()),(float)(GetMouseY()) }, Vector2{ (float)(iter->X),(float)(iter->Y) }, iter->radient)) {
iter = myNodes.erase(iter);
}
else {
++iter;
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have create school database on the firebase, I want to sum all the same keys of the one school. Like School1 have Subject key , inside Subject have students : name1, name2 , etc and each student have same subjects "AAA" , "BBB" , "CCC", now I want to sum of the subject "AAA", Can you help me how can sum of the value "AAA" keys
{
"School1": {
"Subject": {
"Name1": {
"AAA": 50,
"BBB": 60,
"CCC": 70,
"DDD": 80
},
"Name2": {
"AAA": 50,
"BBB": 60,
"CCC": 70,
"DDD": 80
},
"Name3": {
"AAA": 50,
"BBB": 60,
"CCC": 70,
"DDD": 80
}
}
},
"School2": {
"Subject": {
"Name1": {
"AAA": 50,
"BBB": 60,
"CCC": 70,
"DDD": 80
}
}
}
}
Output result of AAA:
School1:
AAA : 150
Here is how to go about it.
DatabaseReference aaa = FirebaseDatabase.getInstance().getReference().child("School1").child("Subject");
aaa.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot) {
int sum = 0;
for (DataSnapshot child : dataSnapshot.getChildren()) {
sum = (int) child.child("AAA").getValue() + sum;
}
Toast.makeText(MainActivity.this, "Total Sum is "+ sum, Toast.LENGTH_SHORT).show();
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
});
I am working with Chart.js on Asp.Net and I have a bar chart. My dataset has not very close numbers so I can not determine any fixed stepSize for this dataset.
My dataset like that;
[105000,200000,310000,0.0002]
So, y-axis range seems like that [0 - 100000 - 200000 - 300000 ...] but I want to show it like that [ 0 - 0.005 - 100000 - 200000 - 300000 ...].
My chart options :
options = {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
responsive: true,
mainAspectRatio: false
}
}]
}
}
I tried to add to options "suggestedMin: 0.005" but y-axis values didn't change.
How can I define custom scale for y-axis?
Try to use the callback property:
options = {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
responsive: true,
mainAspectRatio: false,
callback: (v) => !!~[0, 0.005, 100000, 200000, 300000].indexOf(v) ? v : '',
min: 0,
max: 300000,
step: 0.005
}
}]
}
}
I am using EON plot (which is just using c3.js) to plot real-time timeseries graphs. I am using the subplot because I want to be able to see 12 hours of data at once. However, I have a issue where there are way to many ticks on the subplot or way to few on the main plot. How can I specify a different tick style for each? I am trying to do this in the subplot, but it doesn't work. Below is my generate call and a screenshot (note how the ticks in the subplot make a giant smear). What I would like to do is just have 12 ticks/labels shown in each plot regardless of the data that is being shown.
generate: {
transition: {
duration: 3
},
bindto: '#TimeSeries',
point: {
show: false
},
data: {
x: 'x'
},
subchart: {
show: true,
tick: {
count: 12,
format: '%H:%M',
culling: {
max: 12 // the number of tick texts will be adjusted to less than this value
}
}
},
zoom: {
enabled: false
},
axis: {
x: {
type: 'timeseries',
tick: {
count: 24,
format: '%H:%M',
culling: {
max: 12 // the number of tick texts will be adjusted to less than this value
}
}
}
}
},