[Community Puzzle] Logic gates

It might be the same.

ummm i’m really stuck on this puzzle and it’s breaking my brain :joy: Are ‘A’, ‘B’, ‘C’ etc letters in the output represent AND, OR, XOR etc? Then how do you get the following output of 'C _- … - ’ etc?
When i tried to test it by printing n and m, it prints numbers from 0 to 2 and i am confused.

No, A, B and C are inputs.

I don’t know if you’ve solved it already, but here are some insights, in case you didn’t:

  1. n is the number of input signals, so in the first for loop, you will be reading n input signals, in which the input signal has a name, which is the first non-space separated string, then it’s followed by the form of its signal.
  2. m is the number of output signals, which you’ll be reading them in the 2nd for loop. Each line will be composed of: “OutputName GateToApply FirstInputSignal SecondInputSignal”; here, OutputName is the name of the resulting form of the signal after applying the gate to FirstInputSignal and SecondInputSignal, the GateToApply is the logic gate, FirstInputSignal is the form of the signal, represented by its name, so if you have an ‘A’ signal, that means, you need the form of the signal called ‘A’ and the same happens with SecondInputSignal. For example, “C AND A B”, C is OutputName, AND is GateToApply, A is FirstInputSignal, and B is SecondInputSignal.

Hope this helps.

4 Likes

i solved it, thank you <3 This will definitely be helful for the people who will be completing this puzzle in the future

Since when is NXOR a logic gate type? Shouldn’t that be XNOR?

And is there any particular point in using _ and - for the inputs and outputs rather than the somewhat more logical 0 and 1?

Other than that, pretty cool puzzle.

2 Likes

I think NXOR is simply the opposite of XOR … like NAND and NOR

6 Likes

And NXOR is equality.

I know what they mean, but that gate type is called XNOR, not NXOR.

Both versions appear on https://en.wikipedia.org/wiki/XNOR_gate.

1 Like

Next time b0n5a1 you will call your gates “toto”, “tata” … or “foo”, “bar” for the english speaking people ^^
Since it is in the statement, it should not be a problem :crazy_face:

8 Likes

you got a ‘mdr’ from me for that :smiley:

4 Likes

Hello, I’m new here and I struggle to get the first answer, how am I supposed to change the strings inside the signals ?

I’m using this in the m loop but it doesn’t change the signal form :

if input_signal_1 == “A” and input_signal__2 ==“B”:
print(output_name, input_signal)

I’m willing to learn by myself and don’t find any good tips on google. thank you guys :blush:

What does your current code do? Can you describe it, like step by step? The code you have provided does not perform any string manipulation.

You can google “python strings tutorial” to get resources on how to manipulate strings.

1 Like

Well, my code is kind of empty, I’m still figuring out how to use those strings … Should I use an array list to classify each character ?

Thank you for the tip, I’ll check tutorials right now. :slight_smile:

It seems to me that arrays are seldom talked about in Python (except under libraries e.g. numpy). In my solution to this puzzle, I use a dictionary and lists.

need help, I’m still learning Python, don’t know what I need to do even for the first task :frowning:

Try other puzzles first. And if even other puzzles prove to be too difficult for you, you should consider learning more before coming back to CodinGame to practise.

I’ve done other puzzle on other language, I’m just new with Python.

and now I have other problem, after learning the code, I have trouble on storing data from the signal form input, when I use “append” it storing every char, not the whole signal form, how to store the whole signal?

What do you mean? If your code is able to store every character then the result should be the whole string / whole signal form? Any examples to illustrate your question?