There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

nickwitha_k , (edited )

<span style="color:#323232;">var LogicGate = map[string]string{
</span><span style="color:#323232;">    "OR": "OR",
</span><span style="color:#323232;">    "AND":  "AND",
</span><span style="color:#323232;">    "NOT": "NOT",
</span><span style="color:#323232;">    "NOR": "NOR",
</span><span style="color:#323232;">    "NAND": "NOR",
</span><span style="color:#323232;">    "XOR": "XOR",
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">func isLogicGate(inString string) (bool) {
</span><span style="color:#323232;">    _, ok := LogicGate[strings.ToUpper(inString)]
</span><span style="color:#323232;">    if ok {
</span><span style="color:#323232;">        return true
</span><span style="color:#323232;">    } else {
</span><span style="color:#323232;">        return false
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">func stringAsGateLogic(inString string) (bool, error) {
</span><span style="color:#323232;">    inSplit := strings.Split(inString, " ")
</span><span style="color:#323232;">    var phrase1 strings.Builder
</span><span style="color:#323232;">    var phrase2 stringa.Builder
</span><span style="color:#323232;">    var gateString string
</span><span style="color:#323232;">    for word := range inSplit {
</span><span style="color:#323232;">        if isLogicGate(word) {
</span><span style="color:#323232;">            if len(gateString) &lt; 1{
</span><span style="color:#323232;">                gateString = word
</span><span style="color:#323232;">            } else {
</span><span style="color:#323232;">                phrase2.WriteString(word)
</span><span style="color:#323232;">            }
</span><span style="color:#323232;">        } else {
</span><span style="color:#323232;">            if len(gateString) &lt; 1{
</span><span style="color:#323232;">                phrase1.WriteString(word)
</span><span style="color:#323232;">            } else {
</span><span style="color:#323232;">                phrase2.WriteString(word)
</span><span style="color:#323232;">            }
</span><span style="color:#323232;">        }
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">    boolPhrase1 := bool(phrase1.String())
</span><span style="color:#323232;">    boolPhrase2 := bool(phrase2.String())
</span><span style="color:#323232;">    switch strings.ToUpper(gateString) {
</span><span style="color:#323232;">        case "OR":
</span><span style="color:#323232;">            return (boolPhrase1 || boolPhrase2), nil
</span><span style="color:#323232;">        case "AND":
</span><span style="color:#323232;">            return (boolPhrase1 &amp;&amp; boolPhrase2), nil
</span><span style="color:#323232;">        case "NOT":
</span><span style="color:#323232;">            return (!boolPhrase2), nil
</span><span style="color:#323232;">        case "NOR":
</span><span style="color:#323232;">            return (!(boolPhrase1 || boolPhrase2)), nil
</span><span style="color:#323232;">        case "NAND":
</span><span style="color:#323232;">            return (!(boolPhrase1 &amp;&amp; boolPhrase2)
</span><span style="color:#323232;">        case "XOR":
</span><span style="color:#323232;">            orRes := (boolPhrase1 || boolPhrase2)
</span><span style="color:#323232;">            nandRes := (!(boolPhrase1 &amp;&amp; boolPhrase2))
</span><span style="color:#323232;">            return (orRes &amp;&amp; nandRes), nil
</span><span style="color:#323232;">        default:
</span><span style="color:#323232;">            return false, fmt.Errorf("Why you do dis?: %v", inString)
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">func main(){
</span><span style="color:#323232;">    answer, err := stringAsGateLogic ("This person misunderstands a beautiful function code can be very sexy or maybe I'm a odd girl.")
</span><span style="color:#323232;">    if err != nil {
</span><span style="color:#323232;">        fmt.Println(err)
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">    fmt.Println(answer)
</span><span style="color:#323232;">}
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines