Questions tagged [simplification]
249 questions
0
votes
1 answer
Coud you help me understand the code ? the task is to find first non consecutive number
const firstNonConsecutive = arr => arr.find((number, index) => index > 1 && number !== arr[index -1] + 1)
Is there anyone who could help me break the above function down for me ?
I wrote a very long code to solve the task and someone sent me a…

Krystian Małysek
- 11
- 1
0
votes
1 answer
Simplify a string with MATLAB script
I have a string format which looks like this (this is not always 'A' and 'number' before '_' and numbers) :
Eq = 'A_number_1+((A_number_2+A_number_3)&(A_number_+A_number_5))+A_number_6';
How can i simplify the string like this (with a script) :
Eq…

Lucas
- 247
- 3
- 13
0
votes
1 answer
Inconsistent satisfiability between Z3's "ctx-solver-simplify" and "ctx-simplify"
I'm trying to make z3 (I'm using z3py) to check whether a formula is satisfiable or not and if it is satisfiable then simplify it.
I initially used Z3's ctx-solver-simplify. However, since I am repeatedly making many calls, using this tactic turns…

CXB
- 241
- 5
- 14
0
votes
0 answers
Simplifing a Boolean Expression
Please see my image for the question - it includes a work-through of my equation, and I'd like some clarification on some points.

BinaryFinary
- 3
- 3
0
votes
1 answer
How to avoid for loops for multiplication of all permutations of a matrix?
I have the following code:
N=8;
K=10;
a=zeros(1,N^(K-1));
b=zeros(1,N^(K-1));
for ii=1:K
p0{ii}=rand(1,N);
p1{ii}=rand(1,N);
end
k=1;
for j1=1:N
for j3=1:N
for j4=1:N
for j5=1:N
for j6=1:N
…

Seyhmus Güngören
- 139
- 5
0
votes
0 answers
Simplify java enum test
Given the code:
@Test
public void testEnum() {
for (SomeEnum someEnum : SomeEnum.values()) {
// in case of no match: throw exception
OtherEnum.valueOf(someEnum.name());
}}
I am thinking about how to simplify this…

DerBenniAusA
- 727
- 1
- 7
- 13
0
votes
2 answers
Boolean Expression with Laws
Hello can somebody help me? How this boolean expression simplified?
abcd + d
it simplified as:
d
im trying to use the Laws I don't understand at all
Here's the Laws
Basic Boolean Laws
Idempotent Law
A * A = A
A + A = A
Associative Law
…

Sesese
- 33
- 8
0
votes
1 answer
Can I combine boolean and null checks somehow? I would like to know if this kotlin method can be simplied further
I am new to Kotlin and I would like to know the most optimized way in which I can simplify the following method.
If the amount is payable by person X then I need to return the amount payable, else I need to return 0.
In the code below payments is an…

Devenom
- 915
- 1
- 9
- 20
0
votes
4 answers
Make regexp shorter
I have the following text: var avarb avar var varb var. What I want to do is to extract only "direct" var occurrences. The above string contains 3 of them.
While playing with rubular I made up the following Regexp: /\A(var)|\s(var)\s|(var)\z/.
Is…

oldhomemovie
- 14,621
- 13
- 64
- 99
0
votes
1 answer
Is there a way I can simplify the code below using vectors?
I am using R. I need to create a new column in a data frame that is the sum of the three variables. The sum should only take place if there are numeric values for each of the three variables. In other words, if there are any NAs or blanks the sum…

user11036517
- 65
- 5
0
votes
1 answer
How do I simplify an overly broad if statement?
I have no clue how to clearly simplify the requirements for the if statement to run.
Is there a simpler way I could have done this?
The code is supposed to return True if the number is 2 integers near 10, either being above or below.
def…
0
votes
1 answer
how can I undo the collapsed edges in a specific region using CGAL
I'm creating an application on QT-creator and using CGAL to read .off file as Linear_cell_complex_for_bgl_combinatorial_map_helper , simplify it using edge_collapse method and re-insert the collapsed edges by undo method
void MainWindow…

n.m
- 485
- 1
- 5
- 15
0
votes
4 answers
Simplifying many if-statements
Is there a way to simplify this pile of if-statements? This parsing function sure works (with the right dictionaries), but it has to test 6 if-statements for each word in the input. For a 5-word sentence that would be 30 if-statements. It is also…

lare290
- 11
0
votes
1 answer
How to simplify ( ~A * B) + C * (~B + A)
I have simplified a Boolean function up to a point but I got stuck on the last step, I can't see which rule (if any) I should apply to get to the simplified expression.
I want to simplify the following Boolean function:
( ~A * B) + C * (~B + A)
I…

Sergi
- 471
- 3
- 13
0
votes
2 answers
Simplifying jQuery If-Statement
I have this jQuery if-statement working. Is there a more simple/elegant or less repetitive way to write it?
“If foo is visible, add this HTML element to #message, else add this other HTML element to #message.”
$(document).ready(function() {
var…
user7358991