From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Brute Force in an array

Solved!
Go to solution

hey everyone so i am trying to use the brute force method in an array string data where if there is value B it should give me two different array having 0 and 1 in the place of B. And if there are 2 B's then there should be four different arrays having values 00, 01, 10,11. can abyone help me with this ?

0 Kudos
Message 1 of 22
(3,453 Views)

Can you give an example of data and result?

0 Kudos
Message 2 of 22
(3,423 Views)

well  if i have an array of ( 1 0 1 0 0 0 B B 1 0) it should have now four different array in place of B having values of 00 01 10 11. if you want i can explain more and it is a 1D array as well

Message 3 of 22
(3,420 Views)

and i am getting the data from and exel file and  then extracting one column at a time and if there is a B in that column it will change to  0 and 1 to have to different input by using this brute force method 

0 Kudos
Message 4 of 22
(3,417 Views)

I not understand. Can you make LabVIEW FP with control and indicator?
control is what you have and indicator is what you need

0 Kudos
Message 5 of 22
(3,394 Views)
Solution
Accepted by topic author hasnain123

Hi hasnain,

 

a little recursion job…

 

check.png

(Well, recursion brought back to iteration form…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 22
(3,390 Views)

sorry if i couldn't explain it before i am attaching the picture to show you what i am looking for and with the increase in that b the values should increase exponetially too like if there are 3 B's then there are 8 possible outcomes from that.if you still don't understand let me know i will explain a little bit more 

0 Kudos
Message 7 of 22
(3,360 Views)

You have a string made up of 0, 1, and B (let's say, N B's) and you want to replace all the B's with 0's or 1's to make all the different (let's call them) Binary Strings, right?

 

First, understand the Problem without worrying about the Solution.  Let's look at having N B's (let's say the B's are called "Bits"), so you have an N-Bit String and you want to replace each Bit with 0 or 1 to make all possible N-Bit (let's call them) Binary Numbers.

 

Do you know how to do that?  Do you know how to generate all N-Bit Binary Numbers in some "natural" order?  Then all you have to do is the following:

  • For every N-bit Binary Number,
    • Generate a String where all the B's are replaced by the Bits of the N-Bit Binary number.

I'll leave the Implementation of this simple scheme up to you.  It will be a useful exercise in counting, logic, etc.  You might find some functions on the Boolean Palette that fit nicely with this scheme.  I suspect that you can "do it all" with a single For Loop, but you'll learn the most out of this exercise if you work it out on your own without much more help from the Forum (copying out a completed solution won't teach you as much as doing it yourself).

 

Bob Schor

Message 8 of 22
(3,355 Views)

the main problem i am coming across is if i have 0 and 1 for every B how can i place them in a 2D array because i can search  the B but then using this to have that many values i can't seem to have the algorithm for that atm. so if you have any ideas you can suggest me.

0 Kudos
Message 9 of 22
(3,316 Views)

Hi hasnain,

 

what's wrong with my idea?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 22
(3,311 Views)